From 55000a7e79536b13165c4c62cf85aaa4bc6d7b1f Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Tue, 13 Jan 2026 21:47:34 -0500 Subject: [PATCH] feat(tui): improve question prompt UX MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add number keys (1-9) for quick option selection - Show inline checkboxes [✓] for multi-select questions - Add input_clear keybind support in custom answer textarea - Fix textarea focus via queueMicrotask in ref callback - Improve review section layout with proper span composition - Extract selectAt helper to deduplicate selection logic - Fix answered questions display to stack vertically (question above answer) --- .../src/cli/cmd/tui/routes/session/index.tsx | 4 +- .../cli/cmd/tui/routes/session/question.tsx | 65 ++++++++++++++----- 2 files changed, 51 insertions(+), 18 deletions(-) diff --git a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx index b6916bc5a58..d91363954a1 100644 --- a/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/routes/session/index.tsx @@ -1894,10 +1894,10 @@ function Question(props: ToolProps) { - + {(q, i) => ( - + {q.question} {format(props.metadata.answers?.[i()])} diff --git a/packages/opencode/src/cli/cmd/tui/routes/session/question.tsx b/packages/opencode/src/cli/cmd/tui/routes/session/question.tsx index 5e8ce23807c..049e320cb99 100644 --- a/packages/opencode/src/cli/cmd/tui/routes/session/question.tsx +++ b/packages/opencode/src/cli/cmd/tui/routes/session/question.tsx @@ -132,6 +132,16 @@ export function QuestionPrompt(props: { request: QuestionRequest }) { setStore("editing", false) return } + if (keybind.match("input_clear", evt)) { + evt.preventDefault() + const text = textarea?.plainText ?? "" + if (!text) { + setStore("editing", false) + return + } + textarea?.setText("") + return + } if (evt.name === "return") { evt.preventDefault() const text = textarea?.plainText?.trim() ?? "" @@ -142,16 +152,11 @@ export function QuestionPrompt(props: { request: QuestionRequest }) { const inputs = [...store.custom] inputs[store.tab] = "" setStore("custom", inputs) - } - const answers = [...store.answers] - if (prev) { + const answers = [...store.answers] answers[store.tab] = (answers[store.tab] ?? []).filter((x) => x !== prev) + setStore("answers", answers) } - if (!prev) { - answers[store.tab] = [] - } - setStore("answers", answers) setStore("editing", false) return } @@ -205,6 +210,16 @@ export function QuestionPrompt(props: { request: QuestionRequest }) { } else { const opts = options() const total = opts.length + (custom() ? 1 : 0) + const max = Math.min(total, 9) + const digit = Number(evt.name) + + if (!Number.isNaN(digit) && digit >= 1 && digit <= max) { + evt.preventDefault() + const index = digit - 1 + moveTo(index) + selectOption() + return + } if (evt.name === "up" || evt.name === "k") { evt.preventDefault() @@ -287,11 +302,16 @@ export function QuestionPrompt(props: { request: QuestionRequest }) { - {i() + 1}. {opt.label} + {multi() + ? `${i() + 1}. [${picked() ? "✓" : " "}] ${opt.label}` + : `${i() + 1}. ${opt.label}`} - {picked() ? "✓" : ""} + + {picked() ? "✓" : ""} + + {opt.description} @@ -304,16 +324,25 @@ export function QuestionPrompt(props: { request: QuestionRequest }) { - {options().length + 1}. Type your own answer + {multi() + ? `${options().length + 1}. [${customPicked() ? "✓" : " "}] Type your own answer` + : `${options().length + 1}. Type your own answer`} - {customPicked() ? "✓" : ""} + + {customPicked() ? "✓" : ""} +