Repository navigation
feat(shortcuts): make Select Tab/Workspace 1–9 remappable - #5789
Conversation
Expose Select Tab 1-9 and Select Workspace 1-9 as single remappable rows in Settings -> Shortcuts. Previously both chords were hardcoded in window-shortcut-policy.ts and absent from the Shortcuts UI. Each is modeled as one ranged action whose stored chord is a representative (digit canonicalized to 1) that fires for any of 1-9, mirroring the cmux single-row UX. Defaults reproduce existing behavior (mac: tab Ctrl+1-9, workspace Cmd+1-9; win/linux: tab Alt+1-9, workspace Ctrl+1-9). Swapping the two modifiers - the headline use case - works without a false conflict. Co-authored-by: Orca <[email protected]>
|
Ready to review this PR? Stage has broken it down into 6 individual chapters for you: Chapters generated by Stage for commit 5b8f7b4 on Jun 19, 2026 9:29am UTC. |
|
Caution Review failedAn error occurred during the review process. Please try again later. 📝 WalkthroughWalkthroughTwo new keybinding action IDs— 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/shared/window-shortcut-policy.test.ts (1)
107-145: ⚡ Quick winMove this new digit-index coverage out of the max-lines-disabled file.
The assertions look good, but this separable block grows a file that already relies on the
max-linesdisable at Line 1. Please move the digit-index policy cases into a focused companion test file instead. As per coding guidelines, “Never add amax-linesdisable comment ... Split the file, extract focused modules, move fixtures/builders into named files, or otherwise reduce the counted lines instead.”Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: fb766487-8492-4628-8cfa-d0a5f5a5a5a5
📒 Files selected for processing (5)
src/renderer/src/components/settings/ShortcutBindingRow.tsxsrc/shared/keybindings.test.tssrc/shared/keybindings.tssrc/shared/window-shortcut-policy.test.tssrc/shared/window-shortcut-policy.ts
| export function normalizeKeybindingListForAction( | ||
| actionId: KeybindingActionId, | ||
| input: string | ||
| ): KeybindingValidationResult | string[] { | ||
| return normalizeKeybindingListWithOptions(input, normalizeOptionsForAction(actionId)) | ||
| return finalizeDigitIndexBindings( | ||
| actionId, | ||
| normalizeKeybindingListWithOptions(input, normalizeOptionsForAction(actionId)) | ||
| ) | ||
| } | ||
|
|
||
| export function normalizeKeybindingArrayForAction( | ||
| actionId: KeybindingActionId, | ||
| input: readonly string[] | ||
| ): KeybindingValidationResult | string[] { | ||
| return normalizeKeybindingArrayWithOptions(input, normalizeOptionsForAction(actionId)) | ||
| return finalizeDigitIndexBindings( | ||
| actionId, | ||
| normalizeKeybindingArrayWithOptions(input, normalizeOptionsForAction(actionId)) | ||
| ) |
There was a problem hiding this comment.
Canonicalize digit-index overrides at the effective-binding boundary.
These helpers canonicalize explicit normalization calls, but effective override arrays can still flow through the generic override path before matchKeybindingDigitIndex, settings display, and conflict detection consume them. A persisted/programmatic override like ['Ctrl+5'] would fire for Ctrl+1–Ctrl+9, while other consumers may still display/key it as Ctrl+5. Consider ensuring getEffectiveKeybindingsForAction also applies digit-index canonicalization for these action ids.
Verified in a dev Electron buildSettings → Shortcuts now lists both ranges as single, inline-remappable rows — Select Workspace 1–9 ( |
- Canonicalize digit-index overrides in getEffectiveKeybindingsForAction so display/conflict detection stay consistent regardless of stored digit. - Use a shared DIGIT_INDEX_KEY_PATTERN regex instead of string comparison. - Document that extra modifiers (e.g. Shift) are allowed on digit-index chords and that the matcher honors terminal-context gating. - Clarify the workspace-first precedence comment. - Add tests: Shift modifier, physical-code fallback matching, both ranges disabled. Co-authored-by: Orca <[email protected]>
) * feat(shortcuts): make Select Tab/Workspace 1-9 remappable (stablyai#5741) Expose Select Tab 1-9 and Select Workspace 1-9 as single remappable rows in Settings -> Shortcuts. Previously both chords were hardcoded in window-shortcut-policy.ts and absent from the Shortcuts UI. Each is modeled as one ranged action whose stored chord is a representative (digit canonicalized to 1) that fires for any of 1-9, mirroring the cmux single-row UX. Defaults reproduce existing behavior (mac: tab Ctrl+1-9, workspace Cmd+1-9; win/linux: tab Alt+1-9, workspace Ctrl+1-9). Swapping the two modifiers - the headline use case - works without a false conflict. Co-authored-by: Orca <[email protected]> * refactor(shortcuts): tighten digit-index review nits - Canonicalize digit-index overrides in getEffectiveKeybindingsForAction so display/conflict detection stay consistent regardless of stored digit. - Use a shared DIGIT_INDEX_KEY_PATTERN regex instead of string comparison. - Document that extra modifiers (e.g. Shift) are allowed on digit-index chords and that the matcher honors terminal-context gating. - Clarify the workspace-first precedence comment. - Add tests: Shift modifier, physical-code fallback matching, both ranges disabled. Co-authored-by: Orca <[email protected]> --------- Co-authored-by: Orca <[email protected]>

Closes #5741
What
Exposes Select Tab 1–9 and Select Workspace 1–9 as remappable shortcuts in Settings → Shortcuts. Previously both chords were hardcoded in
window-shortcut-policy.tsand had no entry in the Shortcuts UI, so there was no way to remap them (the original ask in #5741: "I'd like to swap them, but there's no way to remap those shortcuts today").Approach
Each range is modeled as a single remappable row (matching the cmux "Select Surface 1…9" reference in the issue), not 18 per-digit rows. The stored chord is a representative whose digit is canonicalized to
1, but it fires for any of 1–9. This makes the headline use case — swapping the tab/workspace modifiers — a 2-rebind operation instead of 18.tab.selectByIndexandworkspace.selectByIndexinsrc/shared/keybindings.ts, with a digit-agnostic matcher (matchKeybindingDigitIndex) and digit canonicalization wired into the shared validation chokepoints (capture, save, and on-diskkeybindings.jsonparsing).window-shortcut-policy.tsnow resolves these via the registry (honoring user overrides + the terminal-shortcut policy), replacing the hardcoded digit blocks.conflictGroup(they live in different scopes), so swapping their modifiers is never blocked as a false conflict; runtime stays deterministic because the workspace range is checked first.ShortcutBindingRowrenders the representative chord's trailing cap as the full1–9range.Defaults reproduce existing behavior exactly:
Testing
Made with Orca 🐋