From 12022941ef6cd66590f8b184491ab6d5135acc91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B4=E8=8B=A5=E6=A1=A2?= Date: Mon, 15 Jun 2026 16:29:25 +0800 Subject: [PATCH] fix(tui-v2): skip ChoiceList when ask_user has no candidates When candidates is empty/absent, the picker would still create a ChoiceList with only a free-text option, stealing focus from the input. Check candidates early and return if there are none. - 0 net line change, no comment needed - v3 (tui_v3.py) already has the same guard (dfab299) - v2 parity with v3 --- frontends/tuiapp_v2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontends/tuiapp_v2.py b/frontends/tuiapp_v2.py index 6af579557..edae7b470 100644 --- a/frontends/tuiapp_v2.py +++ b/frontends/tuiapp_v2.py @@ -6133,8 +6133,8 @@ def _drain_ask_user_events(self, sess: AgentSession) -> None: while True: try: latest = sess.ask_user_events.get_nowait() except queue.Empty: break - if not latest: return - question = latest["question"]; candidates = latest["candidates"] + if not latest or not (candidates := latest.get("candidates")): return + question = latest["question"] multi = bool(self._MULTI_RE.search(question)) kind = "multi_choice" if multi else "choice" choices = [(c, c) for c in candidates] + [(FREE_TEXT_LABEL, FREE_TEXT_CHOICE)]