Skip to content

fix(web): bypass xterm for global terminal shortcuts#1580

Open
AriajSarkar wants to merge 4 commits intopingdotgg:mainfrom
AriajSarkar:fix/terminal-toggle
Open

fix(web): bypass xterm for global terminal shortcuts#1580
AriajSarkar wants to merge 4 commits intopingdotgg:mainfrom
AriajSarkar:fix/terminal-toggle

Conversation

@AriajSarkar
Copy link
Copy Markdown
Contributor

@AriajSarkar AriajSarkar commented Mar 30, 2026

What Changed

  • Plumbed the keybindings state down from ChatView.tsx into ThreadTerminalDrawer.tsx.
  • Updated attachCustomKeyEventHandler on the xterm.js instance to explicitly pass the shortcut context: { terminalFocus: true, terminalOpen: true }.
  • Returned false on global shortcut matches (terminal.toggle, terminal.new, terminal.split, terminal.close, diff.toggle) to bypass xterm input capture.

Why

When the terminal was focused, xterm.js eagerly captured shortcut combinations (e.g., intercepting Ctrl+J as an 0x0A Line Feed, or Ctrl+N as ^N).
This prevented the global application shortcut listeners in ChatView.tsx from ever receiving these specific keystrokes. By explicitly whitelisting these application-level combinations in the custom event handler and providing the correct when context, xterm safely ignores them and allows the keydown event to bubble up properly.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Low Risk
Low risk UI behavior change limited to terminal key handling; primary risk is unintended shortcut passthrough or conflicts when the terminal is focused.

Overview
When the thread terminal is focused, xterm no longer swallows app-level shortcuts for terminal.toggle, terminal.split, terminal.new, terminal.close, and diff.toggle, allowing the global keydown handler to receive them.

This wires resolved keybindings from ChatView into ThreadTerminalDrawer/TerminalViewport and uses them in attachCustomKeyEventHandler to explicitly bypass xterm for those shortcuts while keeping terminal navigation/clear handling unchanged.

Written by Cursor Bugbot for commit ca579f7. This will update automatically on new commits. Configure here.

Note

Bypass xterm key handling for global terminal shortcuts when terminal is focused

  • Adds a keybindings prop to TerminalViewport (via ThreadTerminalDrawer) so resolved keybindings flow from ChatView down to the xterm instance.
  • In attachCustomKeyEventHandler, key events matching toggle, split, new-tab, close, or diff shortcuts now return false, preventing xterm from consuming them and allowing higher-level handlers to fire.
  • Navigation and clear shortcuts remain handled inside the terminal as before.
  • Behavioral Change: when the terminal is focused, the listed global shortcuts no longer get swallowed by xterm.

Macroscope summarized ca579f7.

@github-actions github-actions bot added the size:M 30-99 changed lines (additions + deletions). label Mar 30, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

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

Run ID: f0cd8c03-7817-4703-9dec-249b3b2938fe

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
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@github-actions github-actions bot added the vouch:unvouched PR author is not yet trusted in the VOUCHED list. label Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant