Skip to content

fix(tui): ESC in dialog rejects background question #45304

Closed as not planned
Closed as not planned

Description

@niho2

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

  1. Open a dialog (e.g. model picker via <leader>m)
  2. Wait for the agent to ask a question in the background
  3. 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".

Activity

  1. yassine-safraoui commented on Oct 21, 2026

    @yassine-safraoui

    just ran into this with the command palette

  2. opencodejr commented on Oct 28, 2026

    @opencodejr

    Thanks for the detailed write-up and root-cause analysis, @niho2!

    The components you mention (QuestionPrompt, PermissionPrompt with OPENCODE_BASE_MODE) are from OpenCode v1 (0.x/1.x, the opencode-ai package). v1 only gets fixes for critical bugs such as data loss, security problems, or crashes with no workaround. This one interrupts the agent but can be worked around by prompting again, so it's unlikely to be fixed in v1.

    We'd encourage upgrading to v2 (@opencode/cli). Its TUI is a separate implementation, and questions are handled by a different form component with its own keybinding handling.

    If you can reproduce this on v2, please reply here with your opencode --version, OS and terminal, and we'll take another look. Please also reply if you think it's critical in v1.

  3. opencodejr commented on Oct 29, 2026

    @opencodejr

    Closing as not planned. This Escape/question conflict is in the v1 TUI (QuestionPrompt / OPENCODE_BASE_MODE), and v1 only gets critical fixes. We haven't heard that it also happens on v2.

    If you see the same thing on v2 (@opencode/cli), please open a new issue with your opencode --version, OS, terminal and the steps to reproduce. Thanks again for the clear write-up, @niho2!

  4. yassine-safraoui commented on Nov 2, 2026

    @yassine-safraoui

    I ran into this on V2 😕

  5. niho2 commented on Nov 2, 2026

    @niho2
    Author

    @yassine-safraoui Thanks for reporting this on v2! Could you share your exact opencode --version, OS and terminal, and confirm whether pressing Escape once closes the command palette/model picker AND rejects the pending background question? My original root-cause analysis was for v1; with a confirmed v2 reproduction, we can open a focused v2 issue and link back here.

  6. yassine-safraoui commented on Nov 2, 2026

    @yassine-safraoui

    I think this may be a duplicate of #52767. When I ran into this in the command palette I commented on both these issues. In this issue I attached as you can see, we do have a reproduction on V2.0.20 by the Opencode bot. Only difference between the two issues is in that issue question tool steals focus from Command palette not from rename dialog, I think this difference is minor and the root cause is very likely the same, so I suggest we close this as duplicate and continue the discussion in that other issue.

  7. yassine-safraoui commented on Nov 2, 2026

    @yassine-safraoui

    For the version I was using when I ran into this, I honestly don't remember exactly which version I was using, however from memory I think it was very likely either V2.0 or V2.1

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions