fix(tui): keep custom answer input focused while typing - #41517
Conversation
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate FoundPR #41079: This PR appears to address the same root issue: enabling typing into custom answer inputs in TUI question prompts. Your PR (#41517) is a fix that resolves the specific problem where the input wasn't receiving focus/keystrokes, while #41079 was a feature addition for the same functionality. They may have overlapping scope or one may have been superseded by the other. |
|
Regarding the duplicate flag: PR #41079 targets the form UI ( |
301a9a8 to
a39ba1f
Compare
Issue for this PR
Closes #30393
Closes #41514
Type of change
What does this PR do?
Selecting "Type your own answer" in a question prompt opens the custom text input, but the input can't be typed into / submitted. Per #30393, the focused
@opentui/core<textarea>swallows the Enter key, so thereturn -> submitbinding never fires and typing is unreliable. Root causes and fixes:packages/tui/src/routes/session/question.tsx): the editing-modeuseBindingshad notarget, so the keymap didn't route keys to the<textarea>and the focused textarea captured Enter. Addedtarget: textareaTargetandpriority: 1, matching theDialogPromptpattern which submits a focused textarea through the keymap.packages/opencode/src/cli/cmd/run/footer.question.tsx): acreateEffectre-ran on every keystroke (eachonContentChangeupdates state), re-setting the textarea text and callingarea.focus()on every character, fighting the user's input. Now it only syncs/focuses on the editing-mode transition.packages/app/src/pages/session/composer/session-question-dock.tsx): added the1–9digit shortcuts tonav()for parity with the TUI, and as a direct way to reach the custom option.How did you verify your code works?
bun typecheckpasses clean inpackages/tui,packages/opencode, andpackages/app.bun test test/cli/run/question.shared.test.ts test/tool/question.test.ts-> 7 pass, 0 fail).Checklist