Repository navigation
Conversation
…rop them Relands #23287. The revert (#23350) was for a shortcut-loss regression: saving a mouse binding put `MouseBack` in the same per-action array as that action's keyboard chords, and a build that predates the token dropped the whole array rather than the one entry it could not parse. On the paired web app the loss was permanent, because an older bundle rewrites its whole document from its own parsed view. Mouse bindings now persist in a section older builds ignore — a `mouse` root key in keybindings.json, a separate localStorage key on web — and are rejoined into one list per action on read, so nothing above the two stores changes. Reads also normalize each stored entry on its own, keeping the bindings they understand instead of discarding the action.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 📝 WalkthroughWalkthroughThe change adds Mouse Back and Mouse Forward as keybinding tokens, with optional modifiers. Desktop and web storage keep mouse bindings separate from keyboard bindings and combine them when reading settings. Renderer and main-window routing dispatch matching shortcuts, including terminal-tab and native actions. Stored bindings are normalized one entry at a time, and invalid entries produce diagnostics. The change also updates recording instructions and adds unit and end-to-end tests. Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🔵 Low · up to A rarely triggered case could swallow one mouse side-button release, and the impact is minor. The shortcut storage and dispatch changes show no blocking issues, though physical side-button behavior on Linux and Windows was not tested. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to Separating mouse shortcuts protects older versions from losing keyboard shortcuts, and native actions remain gated by configured bindings. On the web, however, a failed save can leave the two shortcut stores out of sync, including when a user tries to remove a mouse shortcut. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 20.97% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 62 functions across 30 files. (10 skipped: 10 unsupported.)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
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: Advanced
Run ID: 0b0fb80a-6d7c-476b-9d8a-4f68e1574a2f
📒 Files selected for processing (40)
.gitignoreAGENTS.mddocs/reference/keybinding-token-downgrade-safety.mddocs/site/content/docs/settings.mdxsrc/main/keybindings/keybinding-file-mouse-section.test.tssrc/main/keybindings/keybinding-file-parser.tssrc/main/keybindings/keybinding-file.tssrc/main/window/main-window-mouse-shortcuts.test.tssrc/main/window/main-window-shortcut-routing.tssrc/preload/api/ui-bridge-clipboard-and-window-controls.tssrc/preload/api/ui-window-api.tssrc/renderer/src/app-shell/register-app-mouse-shortcuts.tssrc/renderer/src/app-shell/use-global-keybindings.tssrc/renderer/src/components/dictation/use-hold-dictation-gesture.test.tsxsrc/renderer/src/components/dictation/use-hold-dictation-gesture.tssrc/renderer/src/components/settings/ShortcutCommandBlock.tsxsrc/renderer/src/components/terminal-workspace-keydown.test.tssrc/renderer/src/components/terminal-workspace-keydown.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/fr.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/lib/mouse-shortcut-dispatch.test.tssrc/renderer/src/lib/mouse-shortcut-dispatch.tssrc/renderer/src/web/preload-api/web-keybinding-normalization.tssrc/renderer/src/web/preload-api/web-keybindings-api.tssrc/renderer/src/web/preload-api/web-storage.tssrc/renderer/src/web/web-preload-api-keybindings-mouse.test.tssrc/shared/keybindings-mouse.test.tssrc/shared/keybindings.tssrc/shared/keybindings/definitions.tssrc/shared/keybindings/formatting.tssrc/shared/keybindings/mouse-bindings.tssrc/shared/keybindings/normalization.tssrc/shared/keybindings/parser.tssrc/shared/mouse-shortcut-input.test.tssrc/shared/mouse-shortcut-input.tstests/e2e/mouse-button-shortcuts.spec.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
| const onMouseRelease = (event: MouseEvent): void => { | ||
| const pressed = pressedInputs.get(event.button) | ||
| if (event.type === 'mouseup' && pressed) { | ||
| pressedInputs.delete(event.button) | ||
| const target = pressed.target.isConnected ? pressed.target : window | ||
| target.dispatchEvent( | ||
| new KeyboardEvent('keyup', { | ||
| key: pressed.key, | ||
| code: pressed.key, | ||
| altKey: event.altKey, | ||
| ctrlKey: event.ctrlKey, | ||
| metaKey: event.metaKey, | ||
| shiftKey: event.shiftKey, | ||
| bubbles: true, | ||
| cancelable: true | ||
| }) | ||
| ) | ||
| } | ||
| if (!consumedButtons.has(event.button)) { | ||
| return | ||
| } | ||
| event.preventDefault() | ||
| event.stopImmediatePropagation() | ||
| if (event.type === 'auxclick') { | ||
| consumedButtons.delete(event.button) | ||
| } | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Clear stale consumedButtons entries when auxclick does not fire.
consumedButtons removes an entry only on auxclick or blur. The code runs consumedButtons.delete(event.button) on the next fresh mousedown. Between gestures, a missing auxclick leaves the entry set. Chromium can skip auxclick when the press and release land on different elements. It can also skip auxclick when the target is removed, for example after a tab switch. The next plain mouseup for that button then gets preventDefault and stopImmediatePropagation. This happens even when the button is unbound or is released after a press outside the window. That mouseup can suppress native back-navigation for the button. It also hides the mouseup from page handlers. Delete the entry on mouseup when no pressed entry exists. Alternatively, delete it on the next mousedown before the early returns.
Proposed fix
const pressed = pressedInputs.get(event.button)
+ if (event.type === 'mouseup' && !pressed) {
+ consumedButtons.delete(event.button)
+ return
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const onMouseRelease = (event: MouseEvent): void => { | |
| const pressed = pressedInputs.get(event.button) | |
| if (event.type === 'mouseup' && pressed) { | |
| pressedInputs.delete(event.button) | |
| const target = pressed.target.isConnected ? pressed.target : window | |
| target.dispatchEvent( | |
| new KeyboardEvent('keyup', { | |
| key: pressed.key, | |
| code: pressed.key, | |
| altKey: event.altKey, | |
| ctrlKey: event.ctrlKey, | |
| metaKey: event.metaKey, | |
| shiftKey: event.shiftKey, | |
| bubbles: true, | |
| cancelable: true | |
| }) | |
| ) | |
| } | |
| if (!consumedButtons.has(event.button)) { | |
| return | |
| } | |
| event.preventDefault() | |
| event.stopImmediatePropagation() | |
| if (event.type === 'auxclick') { | |
| consumedButtons.delete(event.button) | |
| } | |
| } | |
| const onMouseRelease = (event: MouseEvent): void => { | |
| const pressed = pressedInputs.get(event.button) | |
| if (event.type === 'mouseup' && !pressed) { | |
| consumedButtons.delete(event.button) | |
| return | |
| } | |
| if (event.type === 'mouseup' && pressed) { | |
| pressedInputs.delete(event.button) | |
| const target = pressed.target.isConnected ? pressed.target : window | |
| target.dispatchEvent( | |
| new KeyboardEvent('keyup', { | |
| key: pressed.key, | |
| code: pressed.key, | |
| altKey: event.altKey, | |
| ctrlKey: event.ctrlKey, | |
| metaKey: event.metaKey, | |
| shiftKey: event.shiftKey, | |
| bubbles: true, | |
| cancelable: true | |
| }) | |
| ) | |
| } | |
| if (!consumedButtons.has(event.button)) { | |
| return | |
| } | |
| event.preventDefault() | |
| event.stopImmediatePropagation() | |
| if (event.type === 'auxclick') { | |
| consumedButtons.delete(event.button) | |
| } | |
| } |
|
| if ( | ||
| !mouseInput || | ||
| !window.api.ui.dispatchMouseShortcut || | ||
| !resolveWindowShortcutAction(mouseInput, shortcutPlatform, state.keybindings, { | ||
| context: getKeybindingContext(input.target), | ||
| terminalShortcutPolicy: state.terminalShortcutPolicy | ||
| }) | ||
| ) { | ||
| return false | ||
| } | ||
| window.api.ui.dispatchMouseShortcut(mouseInput) |
There was a problem hiding this comment.
Web native shortcuts do nothing
On the paired web app, a user can save a mouse binding for a native action such as Open Settings, but pressing the button does nothing. The synthetic keydown has no renderer handler for that action, and the web UI API does not provide dispatchMouseShortcut, so this path returns without handling it. The button may then retain its normal browser behavior. Handle these actions in the web renderer or prevent users from assigning them there.
Knowledge Base Used: Desktop application platform
| writeJson(KEYBINDINGS_STORAGE_KEY, { | ||
| version: 1, | ||
| keybindings: currentSnapshot.commonOverrides, | ||
| keybindings: commonSplit.keyboard, | ||
| platforms: { | ||
| ...currentSnapshot.platformOverrides, | ||
| darwin: currentSnapshot.platformOverrides.darwin ?? {}, | ||
| linux: currentSnapshot.platformOverrides.linux ?? {}, | ||
| win32: currentSnapshot.platformOverrides.win32 ?? {}, | ||
| [platform]: activePlatform | ||
| darwin: {}, | ||
| linux: {}, | ||
| win32: {}, | ||
| ...otherPlatforms.keyboard, | ||
| [platform]: activeSplit.keyboard | ||
| } | ||
| } satisfies WebKeybindingDocument) | ||
| writeWebMouseKeybindingDocument({ | ||
| version: 1, | ||
| keybindings: commonSplit.mouse, | ||
| platforms: { ...otherPlatforms.mouse, [platform]: activeSplit.mouse } | ||
| }) |
There was a problem hiding this comment.
Failed writes leave split bindings
If the second localStorage operation fails, the keyboard document has already been saved but the mouse document still holds its old bindings. The edit reports an error, yet later reads can show a combination the user never saved. Keep the two documents consistent when either write fails.
Knowledge Base Used: Restore stable shortcut persistence after mouse-button regression
| const nextMouseSection = buildMouseSection(mouseCommon, { | ||
| ...mousePlatforms, | ||
| [keybindingPlatform]: mouseActivePlatform | ||
| }) | ||
| if (nextMouseSection) { | ||
| document[MOUSE_SECTION_KEY] = nextMouseSection | ||
| } else { | ||
| delete document[MOUSE_SECTION_KEY] |
There was a problem hiding this comment.
Mouse section loses unknown properties
An unrelated desktop shortcut edit rebuilds the entire mouse object using only keybindings and platforms. If a hand-authored or future-version section contains another property, that edit silently deletes it, even though unknown root properties survive. Preserve unrecognized mouse-section properties while pruning empty binding sections.
There was a problem hiding this comment.
ℹ️ No critical issues — one informational note inline.
Reviewed changes — reland of mouse Back/Forward shortcut support with the downgrade-dropped-keyboard-binding regression addressed by splitting mouse bindings into storage locations older builds ignore.
- Desktop storage split: mouse bindings move to a root
mousekey (mouse.keybindings/mouse.platforms.<os>) in~/.orca/keybindings.json;readKeybindingFilerejoins the two sections per action. - Web storage split: mouse bindings move to a separate
localStoragekey (orca.web.keybindingsMouse.v1), since an older web bundle rebuilds its whole document rather than spreading it. - Per-entry read tolerance:
normalizeStoredKeybindingArrayForActiondrops only the unparseable entry and reports it, leaving the action unset (so it falls back to defaults) when nothing survives. - Dispatch plumbing: renderer synthesizes a
keydown/keyupfor side buttons and routes through existing focused-surface handlers plus a nativeui:dispatchMouseShortcutbridge; recorder and sender/frame guards added. - Tests/docs/i18n: new suites for both stores and dispatch, e2e spec, reference doc, and localized recorder copy.
I read the full diff and ran the 10 new/changed suites (6 node — 56 tests, 4 renderer — 54 tests); all pass. I also confirmed #23287 did not ship in desktop releases (v1.4.215 has no src/shared/mouse-shortcut-input.ts), which bounds the severity of the note below.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| const common = isJsonObject(document.keybindings) | ||
| ? { ...document.keybindings } | ||
| : { ...fallbackCommonOverrides } | ||
| : { ...fallbackCommon.keyboard } |
There was a problem hiding this comment.
The web write path re-splits its common/other-platform sections before writing (splitOverridesByInputKind in web-keybindings-api.ts), but the desktop path only re-splits the fallback here — document.keybindings on the line above and the non-active platforms sections are copied verbatim. A mouse token already sitting in the keyboard section therefore gets written back there (and also into the new mouse section), so a later downgrade can still drop the keyboard chords stored with it.
I confirmed this with a scratch test: writing an unrelated action to a file whose keybindings held ["Mod+Shift+P","MouseBack"] left keybindings unchanged and added mouse.keybindings alongside it. This state only arises from a hand-authored file or the pre-revert #23287 build (which never shipped in a desktop release per v1.4.215), so it is not blocking — but it contradicts the "a mouse binding must never land in the keyboard section" invariant this comment states, and the web path already handles it. Re-splitting the raw sections on the desktop side too would make the two stores consistent.
Technical details
# Desktop write does not re-split existing keyboard sections
## Affected sites
- `src/main/keybindings/keybinding-file.ts:235` — `common` copies `document.keybindings` verbatim when it is an object.
- `src/main/keybindings/keybinding-file.ts:243` — `platforms` is spread from the raw document, so non-active platform sections keep any mouse token.
- `src/main/keybindings/keybinding-file.ts:270` — `buildMouseSection` then adds the same token under `mouse`, leaving it in both places.
## Required outcome
- A mouse binding present in `keybindings`/`platforms.*` should end up only in the `mouse` section after any desktop write, matching the web store.
## Suggested approach (optional)
- Run the parsed keyboard common and each platform's overrides through `splitOverridesByInputKind`, writing `keyboard` back to `keybindings`/`platforms.*` and merging `mouse` into the mouse sections. `splitBindingsByInputKind` classifies only recognized mouse tokens as mouse, so hand-authored/future unknown tokens remain in the keyboard section.
## Open questions for the human (optional)
- Was copying `document.keybindings` verbatim deliberate for forward-compatibility, and if so, is the downgrade gap documented as accepted?|
Hi! I'm hoping to see this land (mouse side buttons on Windows), so I went through the open bot findings and put together fixes for the three that still apply. Sharing it as a patch in case it's useful. It applies cleanly on top of Fixed
Each fix adds one test that fails when the fix is reverted. The keybinding and mouse suites (79 tests), oxlint, oxfmt, Not changed, on purpose
Patch (
|

ELI5
You can assign your mouse's Back/Forward side buttons to Orca shortcuts again, including switching terminal tabs. This time, saving a mouse shortcut can't take your keyboard shortcut for the same command down with it.
What Changed
This relands #23287 and fixes the reason it was reverted (#23350).
The regression: a shortcut is stored as a string, and each command keeps one list of them. #23287 saved
MouseBackinto that same list. An Orca build that shipped beforeMouseBackexisted can't parse it — and both stores reacted by throwing away the command's entire list, soCtrl+PageDowndisappeared along with it. On the paired web app the loss was permanent: an older bundle rewrites its whole stored document from its own parsed view, so the shortcut it dropped is gone from storage for good, even after upgrading again.Before: save Mouse Back on "Next terminal tab", run an older build, and the keyboard shortcut you'd had for years stops working too.
After: the older build still reads the keyboard shortcut; it simply doesn't know about the mouse one.
The mechanism: mouse bindings are persisted in a place older builds ignore, and rejoined into one list per command on read.
~/.orca/keybindings.jsonkeybindings,platforms.<os>mouse.keybindings,mouse.platforms.<os>localStorageorca.web.keybindings.v1orca.web.keybindingsMouse.v1{ "platforms": { "darwin": { "tab.nextTerminal": ["Ctrl+PageDown"] } }, "mouse": { "platforms": { "darwin": { "tab.nextTerminal": ["MouseBack"] } } } }Only the two storage layers know the layout is split —
splitBindingsByInputKindon write,unionKeybindingOverrideson read. Settings, conflict detection, and matching still see one list per command, so nothing else changed. The section is omitted until a mouse binding exists and pruned when the last one goes, so a file that never had one gains no new shape. A command whose only binding is a mouse button is written as[]in the keyboard section, so an older build reads it as "no keyboard shortcut" rather than falling back to the default.Second, independent of the layout: reads now normalize each stored entry on its own and drop only the entry they can't parse, reporting it as a diagnostic. This is what
getEffectiveKeybindingsForActionalready did downstream; the persistence layer was the odd one out. If nothing survives, the command is left unset so it falls back to its defaults instead of reading as deliberately unbound.Everything else is #23287 unchanged: recording, dispatch, terminal/floating routing, and native command dispatch.
Why
The revert's loss is a downgrade problem, so it can't be fixed by teaching new builds to be more careful — the builds that do the damage have already shipped. The only thing that helps them is not putting the token where they will look. A separate section works because an older build preserves an unknown root key through its own writes; on web it would destroy one, which is why that side needs its own storage key rather than a key inside the same document.
Alternatives considered: keeping one list and making readers tolerant (doesn't help already-shipped builds, which is the actual bug); mirroring the full list into the new section (preserves list order exactly, but duplicates every keyboard binding and silently wins over a hand-edit); and a separate set of mouse-only actions (loses the shortcut routing, conflict checks, and context handling that reusing the keybinding path buys). The chosen split costs one thing: a round-trip orders keyboard bindings before mouse ones within a command. Chips are unordered in the UI, so this is invisible.
Rule 2 is the durable one — it's why the next new token can't repeat this even if someone forgets rule 1. Both are written down in
docs/reference/keybinding-token-downgrade-safety.md, linked from AGENTS.md.Linked Issue
Relands #23287, reverted by #23350. Original feature request: #23255.
Visual Proof
The UI is unchanged from #23287. Before: Mouse Back leaves the recorder waiting.
After: the same button is saved as Mouse Back; Shift+Forward is also recorded.
Testing
Verified end-to-end in a real hidden Electron instance on macOS over CDP, driving the actual Settings UI:
⌃ PageDownandMouse Back.~/.orca/keybindings.jsonon disk heldplatforms.darwin["tab.nextTerminal"] = ["Ctrl+PageDown"]withMouseBackisolated undermouse.platforms.darwin.mousesection to stand in for a build that can't see it, reloaded in the running app:tab.nextTerminalstill resolved to["Ctrl+PageDown"], zero diagnostics. Onmaintoday this is where the keyboard shortcut vanishes.Automated coverage added for both stores: the split layout, the downgrade read, a downgraded build's write leaving the section untouched, mouse-only commands, reset clearing both sections, section pruning, hand-authored sections, and per-entry tolerance. Plus unit tests for the split/union helpers. All of #23287's original suites still pass unchanged.
pnpm tc,oxlint,pnpm run check:code-quality:changed, and the localization gates pass. Ran ~15,600 tests acrosssrc/shared,src/main, and the affected renderer areas.Not exercised: physical side-button hardware on Linux/Windows (modifier and platform behavior is covered by unit tests), and the restored e2e spec, which CI runs.
Review
Agent skill upstream boundary
Notes
Keybindings are client-local: no remote protocol change, no wire compatibility surface, and no worktree assumptions. Both stores are pure local persistence, so SSH and remote hosts are unaffected. No default shortcuts changed, and primary/middle/right and unbound side-button clicks keep their behavior. Embedded browser pages keep their native mouse navigation.
Backwards compatibility both ways: an existing
keybindings.jsonis read exactly as before and gains nomousekey until a mouse binding is saved; a file or localStorage document written by this build is read correctly by older builds, minus the mouse bindings they can't do anyway.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)