Skip to content

tui-v2: ChoiceList steals focus when ask_user has no candidates #615

@ChaiRZy

Description

@ChaiRZy

Summary

When ask_user is called with candidates=[] (no choices, user types
freely), _drain_ask_user_events still creates a ChoiceList widget
with only a "直接输入文字..." option. This widget calls .focus() on
mount, stealing keyboard focus from the text input.

v3 (tui_v3.py) already has this guard (dfab299). v2 is missing it.

Fix

Check candidates early, return if empty. 0 net line change, walrus operator.
PR: https://github.com/ChaiRZy/GenericAgent/pull/new/fix/v2-ask-user-empty-candidates

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions