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() ? "✓" : ""} +