feat(keybindings): add terminal cycling and split-focus shortcuts#2632
feat(keybindings): add terminal cycling and split-focus shortcuts#2632janssonoskar wants to merge 7 commits intopingdotgg:mainfrom
Conversation
Adds four new keybinding commands for keyboard-driven terminal navigation: - terminal.next / terminal.previous — cycle terminals with wrap Default: ctrl+tab / ctrl+shift+tab (matches Ghostty, Windows Terminal) Alternate: alt+pagedown / alt+pageup (browser-safe; primary keys are reserved by Chromium/Firefox/Safari and cannot be intercepted in the web app) - terminal.focusLeftPane / terminal.focusRightPane — directional pane focus within the current terminal, no wrap Default: mod+alt+arrowleft / mod+alt+arrowright (matches Ghostty, iTerm2: cmd+alt+arrow on macOS, ctrl+alt+arrow elsewhere) All four are gated on `terminalFocus` so they only fire when focus is inside a terminal and don't hijack ctrl+tab from the chat composer. Pure index helpers (`nextCycleIndex`, `nextDirectionalIndex`) are extracted to apps/web/src/terminalNavigation.ts with unit tests covering wrap, edges, single-element, and out-of-range inputs. Display labels for pageup/pagedown render as PgUp/PgDn. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
terminal.focusLeftPane -> terminal.focusLeft terminal.focusRightPane -> terminal.focusRight The t3code codebase consistently uses "terminal" (the unit) and "split" (the multi-terminal state); "pane" is not used anywhere else. Aligning with native vocabulary keeps the command namespace consistent and auto-generates cleaner labels in the keybindings settings UI: "Terminal: Focus Left" / "Terminal: Focus Right". Naming is still forward-compatible with vertical splits (pingdotgg#1049) — would add terminal.focusUp / terminal.focusDown without renames. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
These were intended as browser-safe alternates to ctrl+tab, but on macOS laptops without dedicated PageUp/PageDown keys, Fn+Option+Arrow doesn't reliably synthesize Alt+PageUp/Down — the OS layer interferes. Same problem VS Code has with its Ctrl+PageUp/Down terminal navigation. Trying to bake browser support into defaults forces ergonomic compromises. Keep the defaults targeted at the desktop app and direct web-app users to customize via ~/.t3/keybindings.json. Docs updated to reflect this. The PgUp/PgDn display labels remain — users who add custom pageup/ pagedown bindings via the settings UI will still see clean labels. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Comment |
ApprovabilityVerdict: Needs human review You can customize Macroscope's approvability policy. Learn more. |
The user-facing commands are terminal.focusLeft / terminal.focusRight, and the codebase uses "split" (not "pane") in UI-layer code. Rename the internal callback to match. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Drops "pane" from describe/it labels to match the focusLeft/focusRight command names. Each platform block now exercises both left and right directions, and the terminalFocus guard test covers both. Added a ctrl+shift+tab Linux/Windows assertion for terminal.previous symmetry. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Out of scope for the terminal navigation feature. No default binding uses these keys after the alt+pageup/pagedown drop. Can be a separate follow-up if needed. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The note was inserted mid-list between terminal.focusRight and commandPalette.toggle, breaking the bullet list in rendered Markdown. Moved it after the list ends and dropped the em-dash for plain punctuation.
What Changed
Adds four keybinding commands for keyboard navigation in the terminal drawer:
terminal.next/terminal.previous: cycle terminals with wrap. Defaultctrl+tab/ctrl+shift+tab.terminal.focusLeft/terminal.focusRight: focus the terminal to the left/right within the current split, no wrap. Defaultmod+alt+arrowleft/mod+alt+arrowright(cmd+option+arrowon macOS,ctrl+alt+arrowelsewhere).All four are gated on
terminalFocus. Pure index helpers extracted toapps/web/src/terminalNavigation.tswith unit tests.Closes #2630.
Why
The drawer already supports creating, splitting, and closing terminals from the keyboard. Moving between them requires the mouse. Defaults match Ghostty's platform defaults.
See #2630 for full context, including the cross-platform caveat (tested on macOS only) and the open question about how to handle the web variant where some of these keys are browser-reserved.
Checklist
Note
Medium Risk
Adds new terminal navigation commands into ChatView’s global keydown handler, which could change keyboard behavior or conflict with browser/OS-reserved shortcuts (especially in web). Logic is straightforward and covered by unit tests, but impacts core interaction flow.
Overview
Adds four new terminal navigation commands—
terminal.next,terminal.previous,terminal.focusLeft, andterminal.focusRight—with new default shortcuts and documentation updates (including a note about browser-reserved keys).Wires these commands into
ChatViewso keyboard input can cycle between terminal groups (wraparound) and move focus left/right within a split (no wrap), using new shared helpers interminalNavigation.tswith accompanying unit tests.Extends the keybinding contract/schema and default keybindings list so these commands are recognized and test-covered in
apps/web/src/keybindings.test.ts.Reviewed by Cursor Bugbot for commit 4bc6864. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add terminal cycling and split-focus keybindings to ChatView
terminal.next,terminal.previous,terminal.focusLeft, andterminal.focusRight, registered inpackages/contracts/src/keybindings.ts.terminalFocus) mapctrl+tab/ctrl+shift+tabto cycle terminal groups with wrap-around, andmod+alt+arrow(macOS) /ctrl+alt+arrow(Linux/Windows) to move focus within the current split without wrap-around.terminalNavigation.tswith two pure index helpers:nextCycleIndex(wrapping) andnextDirectionalIndex(bounded), used by the updatedChatViewkeydown handler.Macroscope summarized 4bc6864.