Skip to content

fix(tui): resolve keyboard deadlock in question mode#36550

Open
maharshi365 wants to merge 2 commits into
anomalyco:devfrom
maharshi365:fix-question-keyboard-deadlock
Open

fix(tui): resolve keyboard deadlock in question mode#36550
maharshi365 wants to merge 2 commits into
anomalyco:devfrom
maharshi365:fix-question-keyboard-deadlock

Conversation

@maharshi365

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #36382
Closes #30517

Type of change

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

What does this PR do?

The QuestionPrompt component has two useBindings calls with mutually exclusive enabled conditions:

  • Editing bindings: enabled: store.editing && !confirm()
  • List bindings: enabled: !store.editing

When a user starts typing a custom answer (store.editing = true) and then clicks the Confirm tab with the mouse (confirm() = true), both binding sets become disabled simultaneously. This causes a full keyboard lockout — Enter, Escape, Ctrl+C, and all shortcuts stop responding. Mouse events still work because they bypass the keymap system.

The fix:

  1. Reset editing on tab changeselectTab() now sets editing = false, preventing the deadlock state from being reachable.
  2. Add priority: 1 to both binding sets so they take precedence over the global managedTextareaLayer (which can intercept Enter when a textarea has focus).
  3. Add app.exit to editing mode bindings so Ctrl+C works while typing a custom answer.
  4. Key QuestionPrompt by request using <Show keyed> so stale internal state doesn't persist across different question requests.

How did you verify your code works?

Reproduced the deadlock locally by entering "Type your own answer" editing mode then clicking the Confirm tab. Verified that after the fix, keyboard remains responsive in all tab/editing combinations. Typecheck passes (bun typecheck from packages/tui).

Screenshots / recordings

N/A — keyboard input fix, no visual change.

Checklist

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

After answering questions, opencode just hangs there. The OpenCode's Questions tool is not working in PowerShell on Windows 11

1 participant