Skip to content

fix(tui): keep custom answer input focused while typing - #41517

Open
ziuus wants to merge 1 commit into
anomalyco:devfrom
ziuus:fix-question-input-v2
Open

fix(tui): keep custom answer input focused while typing#41517
ziuus wants to merge 1 commit into
anomalyco:devfrom
ziuus:fix-question-input-v2

Conversation

@ziuus

@ziuus ziuus commented Aug 10, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #30393
Closes #41514

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

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 the return -> submit binding never fires and typing is unreliable. Root causes and fixes:

  1. TUI (packages/tui/src/routes/session/question.tsx): the editing-mode useBindings had no target, so the keymap didn't route keys to the <textarea> and the focused textarea captured Enter. Added target: textareaTarget and priority: 1, matching the DialogPrompt pattern which submits a focused textarea through the keymap.
  2. CLI direct mode (packages/opencode/src/cli/cmd/run/footer.question.tsx): a createEffect re-ran on every keystroke (each onContentChange updates state), re-setting the textarea text and calling area.focus() on every character, fighting the user's input. Now it only syncs/focuses on the editing-mode transition.
  3. App (packages/app/src/pages/session/composer/session-question-dock.tsx): added the 19 digit shortcuts to nav() for parity with the TUI, and as a direct way to reach the custom option.

How did you verify your code works?

  • bun typecheck passes clean in packages/tui, packages/opencode, and packages/app.
  • Question unit tests pass (bun test test/cli/run/question.shared.test.ts test/tool/question.test.ts -> 7 pass, 0 fail).
  • Changes only reuse already-imported types and existing helpers.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found

PR #41079: feat(tui): type into custom form answers

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.

@ziuus

ziuus commented Aug 10, 2026

Copy link
Copy Markdown
Author

Regarding the duplicate flag: PR #41079 targets the form UI (packages/tui/src/routes/session/form.tsx, packages/tui/src/mini/footer.form.tsx). This PR targets the question prompt UI (packages/tui/src/routes/session/question.tsx, packages/opencode/src/cli/cmd/run/footer.question.tsx). They are separate components with separate input paths, so this is complementary rather than a duplicate.

@ziuus

ziuus commented Aug 10, 2026

Copy link
Copy Markdown
Author

Updated the PR description: now Closes #30393 (the canonical issue for this bug) and Closes #41514 (which I opened and have closed as a duplicate). Note that #41079 targets the form UI while this PR targets the question prompt UI — different components.

@ziuus
ziuus force-pushed the fix-question-input-v2 branch from 301a9a8 to a39ba1f Compare August 10, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant