Skip to content

fix(web): let Escape reach nvim in the terminal drawer - #7203

Closed
maslinedwin wants to merge 1 commit into
pingdotgg:mainfrom
maslinedwin:fix/terminal-escape-nvim
Closed

maslinedwin wants to merge 1 commit into
pingdotgg:mainfrom
maslinedwin:fix/terminal-escape-nvim

Conversation

@maslinedwin

@maslinedwin maslinedwin commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #6362

Escape in the terminal drawer never reached the PTY, so vim/nvim stayed in insert mode and :q could not be entered. Default close is still mod+w.

When the terminal has focus and no overlay (command palette, dialog) is open, bare Escape is no longer treated as a close/dismiss chord. beforeKey returns true so Ghostty encodes ESC. mod+w, split/toggle, and navigation/delete/clear shortcuts are unchanged.

Grok / T3 Code


Note

Low Risk
Keyboard routing and terminal UX only; no auth, data, or API changes, with broad unit test coverage.

Overview
Fixes bare Escape being swallowed before it reaches the PTY in the thread terminal, so vim/nvim can use Escape normally; terminal close stays on mod+w.

A shared decideTerminalBeforeKey path now treats unmodified Escape as encode (not close), while keeping existing behavior for close, split/toggle, navigation, delete, and clear. ChatView and _chat skip their Escape handlers when the terminal has focus and the command palette is closed, so overlays still own Escape when open. Thread selection is no longer cleared by Escape while the terminal is focused.

Reviewed by Cursor Bugbot for commit 6248904. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Fix bare Escape key pass-through to nvim in the terminal drawer

  • Adds isBareEscapeKey and decideTerminalBeforeKey utilities in terminalBeforeKey.ts to consolidate terminal key-handling decisions (encode, suppress, or send a control sequence).
  • Updates the global keydown handler in ChatView.tsx to skip shortcut processing when a bare Escape is pressed while a terminal has focus and the command palette is closed.
  • Updates ThreadTerminalDrawer.tsx to use decideTerminalBeforeKey instead of inline shortcut checks, letting bare Escape reach the PTY.
  • Adds a guard in _chat.tsx so pressing Escape while the terminal is focused no longer clears selected threads.

Macroscope summarized 6248904.

Bare Escape was treated as a UI chord, so vim/nvim never left insert mode. Forward unclaimed Escape to the PTY; keep mod+w as close.
@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e1439cc5-72ad-4386-93b6-0e1f3081ef4c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Aug 16, 2026
@macroscopeapp

macroscopeapp Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR changes Escape key handling behavior across multiple components to fix terminal/vim interaction. Keyboard shortcut changes warrant human review to verify the intended user experience and ensure no regressions in command palette, dialog, or other Escape-sensitive interactions.

You can customize Macroscope's approvability policy. Learn more.

@shivamhwp

Copy link
Copy Markdown
Collaborator

Note: GPT-6 on behalf of shivam (@shivamhwp).

The Caps Lock remapping case in the latest issue comment remains unresolved. decideTerminalBeforeKey allows { key: "Escape", code: "CapsLock" }, but GhosttyTerminalCore.encodeKey still selects the Ghostty key from event.code. This produces no PTY bytes; physical Escape produces 0x1b.

Please handle semantic Escape at the encoder boundary and cover the remapped event through encodeKey. The added WASM test starts with the physical Escape code, so it cannot catch this case. Until the remapped path is addressed, Fixes #6362 overstates the coverage.

Copy link
Copy Markdown
Member

Note

This comment is posted by Julius' dot

Closing for missing interaction verification. This changes Escape routing across the terminal and global handlers, but the PR reports no focused test results or before/after recording of vim entering command mode. The screenshots in #6362 show the original failure and a cmux comparison. Add results from the changed branch and a short recording covering Escape in the terminal and with an overlay open, including the reported remapped Escape case, then request reconsideration.

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

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Unable to exit nvim in terminal drawer using escape key

3 participants