Skip to content

Fix focused terminal toggle shortcut handling on Windows#2670

Open
justsomelegs wants to merge 4 commits into
pingdotgg:mainfrom
justsomelegs:t3code/6d6f154d
Open

Fix focused terminal toggle shortcut handling on Windows#2670
justsomelegs wants to merge 4 commits into
pingdotgg:mainfrom
justsomelegs:t3code/6d6f154d

Conversation

@justsomelegs
Copy link
Copy Markdown
Contributor

@justsomelegs justsomelegs commented May 13, 2026

What Changed

Fixed the terminal toggle shortcut so keybinds like Ctrl+J works reliably when focus is inside the embedded terminal on Windows.

The change keeps event.key matching as the primary path, but adds a narrow fallback for KeyA-KeyZ physical key codes so modified shortcuts like Ctrl+J still resolve when xterm/Chromium reports the focused-terminal event as a control character instead of "j".

Also added regression coverage for:

  • shortcut resolution of the Windows control-character case
  • browser/xterm interception for macOS Cmd+J, Linux Ctrl+J, and Windows Ctrl+J

Why

On Windows, pressing Ctrl+J while the terminal was focused sent the control character to the terminal instead of closing the drawer. The terminal toggle shortcut already had the right ownership model, but the keybinding matcher was too dependent on event.key for modified letter shortcuts.

This approach is the smallest fix:

  • no keybinding-system redesign
  • no behavior change for normal macOS/Linux Cmd/Ctrl+J
  • explicit tests for the terminal-focused path across platforms

UI Changes

Not applicable. No visual UI changes.

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

Fix focused terminal toggle shortcut handling on Windows for control-character key events

  • On Windows, Ctrl+J fires a keyboard event with key: '\n' (a control character) rather than 'j', causing the terminal toggle shortcut to go unrecognized.
  • Introduces eventCodeAliases in keybindings.ts to derive a lowercase letter alias from event.code (e.g. KeyJ'j'), and updates resolveEventKeys to use it so control-character events are matched correctly.
  • The custom key handler attached to the xterm terminal now correctly returns false for terminal.toggle events, yielding them back to the app instead of consuming them.

Macroscope summarized 52347e9.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 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: 6c7cabd4-f7b3-4416-983e-8907670a3ca9

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 size:S 10-29 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels May 13, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes May 13, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented May 13, 2026

Approvability

Verdict: Approved

Straightforward bug fix for Windows keyboard shortcut handling. The production change adds ~10 lines to extract key letters from event codes when control characters are sent, with comprehensive test coverage across platforms.

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

Comment thread apps/web/src/components/ThreadTerminalDrawer.browser.tsx Outdated
@macroscopeapp macroscopeapp Bot dismissed their stale review May 14, 2026 08:47

Dismissing prior approval to re-evaluate 9bbfd40

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

Labels

size:S 10-29 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants