From ad0e96d70ad03a58cabc3fcb6aa2d0ccd676efff Mon Sep 17 00:00:00 2001 From: Aniruddha Adak Date: Sun, 23 Aug 2026 02:22:49 +0530 Subject: [PATCH 1/2] fix(tui): clear answer editing state when selecting other options --- packages/tui/src/routes/session/question.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/tui/src/routes/session/question.tsx b/packages/tui/src/routes/session/question.tsx index 5ab467a351d3..637b59d3601f 100644 --- a/packages/tui/src/routes/session/question.tsx +++ b/packages/tui/src/routes/session/question.tsx @@ -100,6 +100,9 @@ export function QuestionPrompt(props: { request: QuestionRequest; directory?: st function selectTab(index: number) { setStore("tab", index) setStore("selected", 0) + // Mouse handlers switch tabs while the custom-answer editor is open; stale editing + // state would keep Return bound to the editor on the new tab. + setStore("editing", false) } function selectOption() { @@ -118,6 +121,9 @@ export function QuestionPrompt(props: { request: QuestionRequest; directory?: st } const opt = options()[store.selected] if (!opt) return + // Mouse handlers reach this while the custom-answer editor is open; leaving it enabled + // keeps Return bound to the editor instead of submit/confirm. + setStore("editing", false) if (multi()) { toggle(opt.label) return From f573c2bf7166f4a0d6a9ff02afd3345b324efbe5 Mon Sep 17 00:00:00 2001 From: Aniruddha Adak Date: Tue, 25 Aug 2026 21:31:07 +0530 Subject: [PATCH 2/2] fix(tui): keep answer editor open when clicking the active question tab Review follow-up for #44240: selectTab previously reset editing state even when the clicked tab was already active, so re-clicking the current tab header closed a custom-answer editor mid-typing. Navigation keybindings are disabled while editing, so mouse clicks were the only path that could hit this. Same-tab selection is now a no-op. Also documents the ordering invariant in selectOption: the custom-answer branch opens the editor and must return before any unconditional editing reset. --- packages/tui/src/routes/session/question.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/tui/src/routes/session/question.tsx b/packages/tui/src/routes/session/question.tsx index 637b59d3601f..1562536cd30a 100644 --- a/packages/tui/src/routes/session/question.tsx +++ b/packages/tui/src/routes/session/question.tsx @@ -98,6 +98,8 @@ export function QuestionPrompt(props: { request: QuestionRequest; directory?: st } function selectTab(index: number) { + // Re-clicking the active tab must not disturb an open custom-answer editor. + if (index === store.tab) return setStore("tab", index) setStore("selected", 0) // Mouse handlers switch tabs while the custom-answer editor is open; stale editing @@ -107,6 +109,7 @@ export function QuestionPrompt(props: { request: QuestionRequest; directory?: st function selectOption() { if (other()) { + // Opens the editor; must return before any unconditional editing reset below. if (!multi()) { setStore("editing", true) return