Repository navigation
feat(keybindings): swap tab-switch chords to the common convention for new users - #9240
Conversation
…r new users New installs now get the widespread mapping — Mod+Shift+[ / ] cycles across all tabs, Mod+Alt+[ / ] cycles within the active tab type. Pre-existing installs keep today's mapping: a one-time cohort seed (frozen on first launch via the fileExistedOnLoad signal, mirroring the telemetry migration) pins the legacy chords into keybindings.json, skipping any action the user already customized. - shared registry: swap the four tab.*SameType / tab.*AllTypes defaults; export LEGACY_TAB_SWITCH_BINDINGS for the seed - persistence: migrateTabSwitchKeybindings freezes the existing-vs-fresh cohort (tabSwitchKeybindingSeed = pending | done) - keybinding-file: seedLegacyTabSwitchBindings writes the legacy pins into the active-platform section so Settings reset still works - refresh stale default-chord comments - tests for the swapped defaults, the seed (fresh/existing/customized/idempotent), and the cohort migration
…y per-action seedLegacyTabSwitchBindings now pins each un-customized action individually instead of skipping all four when any one is customized. A partially-customized existing user keeps their rebound action AND the pre-swap default on the rest; no existing user's behavior changes. The skip check keys on this platform's effective overrides so a foreign-platform-only override can't leave the active platform on a new default. Adds keybinding-service.test.ts: constructs a real KeybindingService and asserts effective bindings + real keystroke matching for both cohorts across darwin/ linux/win32, plus partial-customization, idempotency, and seed-failure retry.
📝 WalkthroughWalkthroughTab-switch defaults now use separate chords for same-type and all-types cycling, with legacy mappings preserved for migration. Persistence records whether data predates the convention swap. Existing installs conditionally receive legacy platform keybinding overrides, while customized actions are preserved and repeated seeding is idempotent. Tests cover fresh and upgraded installs, migration states, platform overrides, keyboard layouts, and composed macOS shortcuts. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
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
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 5f2083ee-99e2-4835-ad17-447d1781314d
📒 Files selected for processing (11)
src/main/index.tssrc/main/keybindings/keybinding-file.test.tssrc/main/keybindings/keybinding-file.tssrc/main/keybindings/keybinding-service.tssrc/main/persistence.test.tssrc/main/persistence.tssrc/renderer/src/components/terminal/tab-type-cycle.tssrc/renderer/src/hooks/ipc-tab-switch.tssrc/shared/keybindings.test.tssrc/shared/keybindings.tssrc/shared/types.ts
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 3fcd132c-ee73-4e44-ae1b-e37c76aedd58
📒 Files selected for processing (3)
src/main/keybindings/keybinding-file.test.tssrc/main/keybindings/keybinding-file.tssrc/main/keybindings/keybinding-service.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/keybindings/keybinding-file.ts
| // The user had rebound just one action before upgrading. | ||
| writeKeybindingOverride(getUserKeybindingsPath(home), platform, 'tab.nextSameType', ['Mod+K']) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
Initialize the keybindings file before attempting to write an override.
writeKeybindingOverride explicitly throws an error if the target document does not exist (Could not read keybindings file.). Since home is a freshly created temporary directory without a .orca folder or a keybindings.json file, this call will crash the test.
You must create the directory and an empty JSON file first. Make sure to add mkdirSync to your node:fs imports at the top of the file as well.
🐛 Proposed fix for the test setup
- // The user had rebound just one action before upgrading.
- writeKeybindingOverride(getUserKeybindingsPath(home), platform, 'tab.nextSameType', ['Mod+K'])
+ // Create the initial keybindings file so writeKeybindingOverride does not throw
+ const configPath = getUserKeybindingsPath(home)
+ mkdirSync(join(home, '.orca'), { recursive: true })
+ writeFileSync(configPath, '{}', 'utf8')
+
+ // The user had rebound just one action before upgrading.
+ writeKeybindingOverride(configPath, platform, 'tab.nextSameType', ['Mod+K'])…r new users (stablyai#9240) * feat(keybindings): swap tab-switch chords to the common convention for new users New installs now get the widespread mapping — Mod+Shift+[ / ] cycles across all tabs, Mod+Alt+[ / ] cycles within the active tab type. Pre-existing installs keep today's mapping: a one-time cohort seed (frozen on first launch via the fileExistedOnLoad signal, mirroring the telemetry migration) pins the legacy chords into keybindings.json, skipping any action the user already customized. - shared registry: swap the four tab.*SameType / tab.*AllTypes defaults; export LEGACY_TAB_SWITCH_BINDINGS for the seed - persistence: migrateTabSwitchKeybindings freezes the existing-vs-fresh cohort (tabSwitchKeybindingSeed = pending | done) - keybinding-file: seedLegacyTabSwitchBindings writes the legacy pins into the active-platform section so Settings reset still works - refresh stale default-chord comments - tests for the swapped defaults, the seed (fresh/existing/customized/idempotent), and the cohort migration * test(keybindings): prove existing-user parity + make the seed strictly per-action seedLegacyTabSwitchBindings now pins each un-customized action individually instead of skipping all four when any one is customized. A partially-customized existing user keeps their rebound action AND the pre-swap default on the rest; no existing user's behavior changes. The skip check keys on this platform's effective overrides so a foreign-platform-only override can't leave the active platform on a new default. Adds keybinding-service.test.ts: constructs a real KeybindingService and asserts effective bindings + real keystroke matching for both cohorts across darwin/ linux/win32, plus partial-customization, idempotency, and seed-failure retry. * fix(keybindings): preserve legacy files during tab shortcut seed * fix(keybindings): preserve valid pre-swap overrides
What & why
Orca's default tab-switch chords are inverted from the widespread desktop convention. Across common terminals and editors, Cmd/Ctrl+Shift+[ / ] is the broad "switch to the next/previous tab" chord, and the Alt-modified bracket is the narrower within-container move. Orca ships the opposite: Shift+bracket is the same-type cycle and Alt+bracket is the all-types cycle.
This aligns new installs with the convention while leaving existing users exactly where they are.
Mod+Shift+[ / ]Mod+Alt+[ / ]How the cohort split works
The install cohort is frozen once on the first launch after this release, using the existing
fileExistedOnLoad"has this user run Orca before?" signal — mirroring the telemetry cohort one-shot:tabSwitchKeybindingSeed = 'done'; adopts the new registry defaults, nothing written.tabSwitchKeybindingSeed = 'pending';KeybindingServicethen pins the legacy chords into~/.orca/keybindings.jsonand flips the flag to'done'.The seed is strictly per-action: it pins each swapped action to its pre-swap chord only when this platform has no effective override for it yet. So a user who rebound just one of the four keeps that binding and keeps the pre-swap default on the other three — an existing user's behavior is never altered, whether they customized none, some, or all of them. The skip check keys on the active platform's effective overrides, so a foreign-platform-only override can't leave the active platform on a new default. Writes go to the active-platform section so the pins stay resettable from Settings, and the one-shot only marks done on success (a transient IO error retries next launch).
Because every pin equals the action's old default, the seeded set reproduces exactly today's effective config and introduces no new conflicts. Action IDs keep their meaning, so every dispatch/matcher consumer (Terminal, floating terminal, browser guest) needs no change.
Changes
src/shared/keybindings.ts— swap the fourtab.*SameType/tab.*AllTypesdefaults; exportLEGACY_TAB_SWITCH_BINDINGSsrc/main/persistence.ts+src/shared/types.ts—migrateTabSwitchKeybindingsfreezes the cohort flagsrc/main/keybindings/keybinding-file.ts—seedLegacyTabSwitchBindingswrites the legacy pins (per-action, customization-aware)src/main/keybindings/keybinding-service.ts+src/main/index.ts— run the seed once for the pending cohortipc-tab-switch.ts/tab-type-cycle.tsVerification
Automated, at the real-function level (no mocked keybinding layer). 526 tests pass across the five affected suites; node + CLI + web typecheck and changed-file oxlint clean.
End-to-end cohort proof —
keybinding-service.test.tsconstructs a realKeybindingService(which runs the seed against a temp home) and asserts both the effective bindings and real keystroke matching for both cohorts:LEGACY_TAB_SWITCH_BINDINGS(the pre-swap defaults); aMod+Shift+]press still matchestab.nextSameTypeand nottab.nextAllTypes, andMod+Alt+[still matchestab.previousAllTypes— i.e. byte-identical to pre-swap.Mod+Shift+]now matchestab.nextAllTypes,Mod+Alt+]matchestab.nextSameType.pending, and retries next launch.Cohort classification —
persistence.test.ts(Store.migrateTabSwitchKeybindings): fresh →'done', pre-existing file →'pending', corrupt data file →'pending'(treated as existing, matching the telemetry migration), already-frozen cohort preserved on later launches.Seed file mechanics —
keybinding-file.test.ts: writes to the active-platform section; preserves a customized action while pinning the rest; migrates root-level legacy overrides without data loss; refuses to replace an unreadable user file; a foreign-platform override does not block the active-platform pin; idempotent; no conflict diagnostics.Browser guest routing —
browser-manager.test.ts: verifies the new Shift chord reaches all-types cycling and the new Alt chord reaches same-type cycling while focus is inside a guest.Registry —
keybindings.test.ts: the swapped fresh-install defaults and theLEGACY_TAB_SWITCH_BINDINGSvalues; Alt-bracket matcher tests (JIS, dead-key, Option-composed) retargeted to*SameType, which now owns Cmd+Alt+bracket.Cross-platform / SSH
Modresolves to Cmd on macOS and Ctrl on Linux/Windows; the seed writes to the active-platform section. Keybindings are per-home, so each machine (including SSH hosts) freezes its own cohort independently.Reviewer note
Existing users will see the four tab-switch shortcuts flagged as "modified" in Settings (they're now real overrides); resetting any one adopts that action's new default. This is the deliberate, precedent-matching tradeoff (same approach as the existing legacy-keybindings migration).
Electron cohort validation
Validated PR head
e199c97e8in real Electron launches attached through CDP, using isolated profile and keybinding-home paths. The attached app identity matchedsalmon @ brennanb2025/tab-switch-keybinding-swap.done; no keybindings file or overrides were created; Settings visibly showed Next tab (same type) as⌘⌥]and Next tab (all types) as⌘⇧], withModified 0and no conflicts.done. Settings visibly showed Next tab (same type) as⌘⇧]and Next tab (all types) as⌘⌥], marked Modified with zero conflicts. The on-disk file contained the corresponding previous-direction pins as well.Remaining gap: this quick Electron pass did not create heterogeneous tabs and observe selection after pressing the chord; real keystroke matching and browser-guest dispatch remain covered by the automated cohort and routing tests above.