Skip to content

fix(tui): allow session interrupt (ESC) when dialog is open#27917

Open
ranxianglei wants to merge 1 commit into
anomalyco:devfrom
ranxianglei:fix/esc-cancel-dialog
Open

fix(tui): allow session interrupt (ESC) when dialog is open#27917
ranxianglei wants to merge 1 commit into
anomalyco:devfrom
ranxianglei:fix/esc-cancel-dialog

Conversation

@ranxianglei
Copy link
Copy Markdown

@ranxianglei ranxianglei commented May 16, 2026

Issue for this PR

Closes #27922

Type of change

  • Bug fix

What does this PR do?

When a permission dialog (or any dialog) is open in the TUI, the session_interrupt keybind (double ESC) is completely blocked because dialog.stack.length > 0 disables all keybindings. This creates an infinite dialog loop where the user can only dismiss one dialog at a time while the model keeps retrying.

Two changes in component/prompt/index.tsx:

  1. Split session.interrupt into its own useBindings call without the enabled: command.matcher guard, so it's always reachable regardless of dialog state.

  2. Remove the if (!input.focused) return check from the interrupt handler, so it works even when the prompt input is blurred by an open dialog.

These are minimal changes — all other keybinds remain correctly blocked when dialogs are open. Only session.interrupt is exempted.

How did you verify your code works?

This fix has been running in our fork (based on v1.14.41) for several days. Verified that:

  • Double-ESC cancels the session even when a permission dialog is showing
  • Single ESC still dismisses individual dialogs as before
  • Other keybinds remain blocked during dialog display
  • No regressions in normal dialog flow

Checklist

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

When a permission dialog or other dialog is open, all keybindings including session_interrupt were disabled by the command palette matcher. This trapped users in an infinite dialog loop: dismiss dialog -> model retries tool -> new dialog opens.

Split session.interrupt into its own useBindings call without the dialog guard, and remove the input.focused check in the handler so ESC works even when the input is blurred by a dialog.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels May 16, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Copy Markdown
Contributor

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

Potential Related PR Found:

No complete duplicates found. PR #27917 appears to be addressing a unique root cause that other PRs haven't tackled.

@github-actions github-actions Bot removed needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels May 16, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(tui): ESC cannot cancel session when permission dialog is open (infinite dialog loop)

1 participant