anomalyco / anomalyco/opencode
fix(tui): ESC in dialog rejects background question
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
When a dialog is open (e.g. model picker) and the agent asks a question in the background, pressing ESC closes the dialog AND rejects the question simultaneously. The question disappears and the agent's execution is interrupted.
The expected behavior is that ESC should only close the dialog, leaving the question visible and unanswered so the user can respond to it after the dialog is closed.
Steps to reproduce
- Open a dialog (e.g. model picker via
<leader>m) - Wait for the agent to ask a question in the background
- Press ESC
Expected: Dialog closes, question remains visible.
Actual: Dialog closes AND question is rejected, agent is interrupted.
Root cause
The QuestionPrompt component pushes a "question" mode onto the mode stack. When a dialog is open, the stack becomes ["modal", "question"]. The dialog's ESC binding has no mode restriction, and the question's ESC binding fires in "question" mode — both execute simultaneously.
The PermissionPrompt component avoids this by using OPENCODE_BASE_MODE, but QuestionPrompt uses a dedicated mode that stacks on top of "modal".
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the QuestionPrompt and PermissionPrompt components and reading how their ESC bindings use the mode stack, especially OPENCODE_BASE_MODE. Reproduce the issue with a dialog open while a background question appears. Done means ESC closes only the dialog, while the question remains visible and unanswered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100