Skip to content

feat(keybindings): swap tab-switch chords to the common convention for new users - #9240

Merged
brennanb2025 merged 4 commits into
mainfrom
brennanb2025/tab-switch-keybinding-swap
Jul 17, 2026
Merged

brennanb2025 merged 4 commits into
mainfrom
brennanb2025/tab-switch-keybinding-swap

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

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.

Chord Existing users (unchanged) New users (this release onward)
Mod+Shift+[ / ] same-type cycle all-types cycle
Mod+Alt+[ / ] all-types cycle same-type cycle

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:

  • Fresh install → tabSwitchKeybindingSeed = 'done'; adopts the new registry defaults, nothing written.
  • Pre-existing install → tabSwitchKeybindingSeed = 'pending'; KeybindingService then pins the legacy chords into ~/.orca/keybindings.json and 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 four tab.*SameType / tab.*AllTypes defaults; export LEGACY_TAB_SWITCH_BINDINGS
  • src/main/persistence.ts + src/shared/types.ts — migrateTabSwitchKeybindings freezes the cohort flag
  • src/main/keybindings/keybinding-file.ts — seedLegacyTabSwitchBindings writes the legacy pins (per-action, customization-aware)
  • src/main/keybindings/keybinding-service.ts + src/main/index.ts — run the seed once for the pending cohort
  • refreshed stale default-chord comments in ipc-tab-switch.ts / tab-type-cycle.ts

Verification

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.ts constructs a real KeybindingService (which runs the seed against a temp home) and asserts both the effective bindings and real keystroke matching for both cohorts:

  • Existing install, clean profile, on darwin / linux / win32 — all four actions resolve to LEGACY_TAB_SWITCH_BINDINGS (the pre-swap defaults); a Mod+Shift+] press still matches tab.nextSameType and not tab.nextAllTypes, and Mod+Alt+[ still matches tab.previousAllTypes — i.e. byte-identical to pre-swap.
  • Fresh install, on darwin / linux / win32 — no file written; Mod+Shift+] now matches tab.nextAllTypes, Mod+Alt+] matches tab.nextSameType.
  • Partially-customized existing user — a rebound action is preserved and the other three still resolve to their pre-swap defaults (not the new ones).
  • Idempotency — a second launch after the seed changes nothing.
  • Seed write fails (home is an unwritable path) — the constructor swallows the error, leaves the cohort 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 the LEGACY_TAB_SWITCH_BINDINGS values; Alt-bracket matcher tests (JIS, dead-key, Option-composed) retargeted to *SameType, which now owns Cmd+Alt+bracket.

Cross-platform / SSH

Mod resolves 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 e199c97e8 in real Electron launches attached through CDP, using isolated profile and keybinding-home paths. The attached app identity matched salmon @ brennanb2025/tab-switch-keybinding-swap.

  • Fresh install: cohort persisted as done; no keybindings file or overrides were created; Settings visibly showed Next tab (same type) as ⌘⌥] and Next tab (all types) as ⌘⇧], with Modified 0 and no conflicts.
  • Pre-existing install: relaunched the same isolated profile with the pre-release marker absent; startup wrote all four legacy pins and persisted the cohort as 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.
  • Both launches had zero renderer console errors and zero keybinding diagnostics.

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.

…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.
@coderabbitai

coderabbitai Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Tab-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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 63.64% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description explains the change well but does not follow the required template sections for Screenshots, Testing, AI Review Report, Security Audit, and Notes. Add the missing template sections, including screenshots or 'No visual change', testing checklist, AI review report, security audit, and notes.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and accurately summarizes the main change: swapping tab-switch chords for new users.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5f2083ee-99e2-4835-ad17-447d1781314d

📥 Commits

Reviewing files that changed from the base of the PR and between b259300 and 30e2fad.

📒 Files selected for processing (11)
  • src/main/index.ts
  • src/main/keybindings/keybinding-file.test.ts
  • src/main/keybindings/keybinding-file.ts
  • src/main/keybindings/keybinding-service.ts
  • src/main/persistence.test.ts
  • src/main/persistence.ts
  • src/renderer/src/components/terminal/tab-type-cycle.ts
  • src/renderer/src/hooks/ipc-tab-switch.ts
  • src/shared/keybindings.test.ts
  • src/shared/keybindings.ts
  • src/shared/types.ts

Comment thread src/main/keybindings/keybinding-file.ts Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 3fcd132c-ee73-4e44-ae1b-e37c76aedd58

📥 Commits

Reviewing files that changed from the base of the PR and between 30e2fad and 1141c56.

📒 Files selected for processing (3)
  • src/main/keybindings/keybinding-file.test.ts
  • src/main/keybindings/keybinding-file.ts
  • src/main/keybindings/keybinding-service.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/keybindings/keybinding-file.ts

Comment on lines +156 to +157
// The user had rebound just one action before upgrading.
writeKeybindingOverride(getUserKeybindingsPath(home), platform, 'tab.nextSameType', ['Mod+K'])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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'])

@brennanb2025
brennanb2025 merged commit 5907816 into main Jul 17, 2026
1 check passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant