Skip to content

Support mouse Back/Forward buttons in shortcuts - #23287

Merged
nwparker merged 2 commits into
mainfrom
nwparker/mouse-key
Sep 27, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/mouse-key

Conversation

@nwparker

@nwparker nwparker commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​572 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​567
Prod 20 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​228 $\color{#cf222e}{\Huge{\mathbf{−}}}$​11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​217

ELI5

Assign your mouse's Back/Forward side buttons to Orca shortcuts, including switching terminal tabs. Modifiers such as Shift work too.

What Changed

Settings now records side buttons and shows Mouse Back / Mouse Forward labels. keybindings.json accepts MouseBack and MouseForward, with optional modifiers. Mouse presses reuse the existing focused shortcut handlers; app-wide commands use the existing Electron shortcut dispatcher. A handled press consumes its release so it runs once without also navigating history.

Why

The recorder previously ignored side buttons and the file parser rejected them. Reusing the shortcut routing preserves context, conflict checks, and terminal/floating-workspace behavior without a separate set of mouse actions. This addresses the original issue only; navigation-history behavior is unchanged.

Linked Issue

Fixes #23255

Visual Proof

Before: Mouse Back leaves the recorder waiting.

Before: Mouse Back ignored

After: the same button is saved as Mouse Back; Shift+Forward is also recorded.

After: Mouse Back recorded

After: Shift+Mouse Forward recorded

Testing

  • Tested locally on macOS with hidden Electron and real CDP Back/Forward input: recording, Shift matching, file reload, rendered terminal switching, and Open Settings.
  • Automated coverage for parsing, conflicts, modifiers, event consumption/release, terminal and floating-tab routing, recorder isolation, and native command dispatch.
  • pnpm tc, focused Vitest suites, changed-code quality gate, localization checks, and Electron build.
  • Windows/Linux modifier behavior covered in unit tests; native hardware and SSH sessions were not exercised. Keybindings stay client-local, with no remote protocol changes or Git-worktree assumptions. Embedded browser pages retain their native mouse navigation.

Review

Agent skill upstream boundary

  • Not applicable; no skill-sharing code changed.

Notes

No default shortcuts changed. Primary, middle, right, and unbound side-button clicks retain their behavior.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • Local focused checks passed; CI covers full lint, test, and build gates

@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: fa951e88-7e4d-45ca-b5cf-72d3c31858b9

📥 Commits

Reviewing files that changed from the base of the PR and between 6e30bad and 9f00941.

📒 Files selected for processing (2)
  • src/renderer/src/lib/mouse-shortcut-dispatch.test.ts
  • src/renderer/src/lib/mouse-shortcut-dispatch.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.


📝 Walkthrough

Walkthrough

Mouse Back and Mouse Forward can now be recorded as keybindings, with optional modifiers, and assigned to terminal-tab or native window actions. The renderer converts mouse side-button presses into shortcut events and routes matching actions through the preload API and main-window IPC. Shortcut recorder input is excluded from terminal shortcut and dictation handling. Tests cover parsing, dispatch, recording, and end-to-end tab switching and Settings access. The Settings documentation and translated recording prompts now mention mouse side buttons.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 9f009

The change adds configurable mouse side-button shortcuts, with no confirmed regression remaining. The supplied tests cover parsing, dispatch, terminal-tab switching, and Settings actions; the change appears ready to merge subject to normal project checks.

Architecture Summary

Architecture risk: 🔵 Low · up to 9f009

The change affects 3 systems.

Changed systems: src, docs, tests

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (service) was modified; 25 changed files map to changed impact.
  • observed — docs (service) was modified; 1 changed file maps to changed impact.
  • observed — tests (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in docs/site/content/docs/settings.mdx: Adds documentation for recording mouse side buttons with optional modifiers in Settings or ~/.orca/keybindings.json, and assigning them to navigate between terminal tabs.
  • observed — Modified behavior in src/main/window/main-window-mouse-shortcuts.test.ts: Adds Electron and utility mocks backed by the main-window test harness, then imports the mocked IPC interface, window factory, and reset helpers.
  • observed — Modified behavior in src/main/window/main-window-mouse-shortcuts.test.ts: Adds a MouseBack input fixture and setup helper that creates mocked window and web contents, registers the app.settings binding, and returns the event objects used by the tests.
  • observed — Modified behavior in src/main/window/main-window-mouse-shortcuts.test.ts: Adds a test expecting the assigned mouse shortcut to dispatch ui:openSettings once and the dispatch listener to be removed after the window closes.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.76% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 20 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: adding support for mouse Back and Forward buttons in shortcuts.
Description check ✅ Passed The description includes the required sections, explains the user-facing and implementation changes, links issue #23255, provides visual proof, documents testing and limitations, and completes the che…
Linked Issues check ✅ Passed Issue #23255 requires MouseBack and MouseForward bindings in Settings and keybindings.json, with optional modifiers. The PR adds token parsing, normalization, formatting, conflict coverage, reco…
Out of Scope Changes check ✅ Passed The changes remain within issue #23255. Documentation, localization, recorder isolation, routing, release handling, native fallback, and tests support mouse Back/Forward keybindings. No unrelated feat…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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.

@nwparker

Copy link
Copy Markdown
Contributor Author

Addressed the duplicate-press concern in 9f00941: a side button with an outstanding press is not dispatched again, and a handled press keeps consuming its release even if a duplicate changes modifiers. The regression test also verifies that the next complete gesture works. All 46 focused dispatch, tab-routing, and hold-dictation tests pass.

The docstring-coverage suggestion is not applied because AGENTS.md explicitly asks for concise, non-obvious comments only.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • MouseBack/MouseForward as first-class keybindings — the parser, normalizer (bare mouse buttons allowed), and formatter now accept and label side buttons, with optional modifiers; a new MouseShortcutInput type plus parseMouseShortcutInput validates the IPC payload at the main boundary.
  • Unified dispatch in the renderer — registerMouseShortcutDispatch captures side-button mousedown, synthesizes a keydown dispatched at document.activeElement, and reuses the existing focused-surface keydown handlers, so mouse gestures flow through the same matcher, context, and conflict logic as keys. A handled press consumes the matching mouseup/auxclick to suppress Chromium back/forward navigation, and a synthesized keyup on release supports hold dictation.
  • App-wide commands via the existing main-process dispatcher — registerAppMouseShortcuts resolves the window shortcut policy and forwards to a new ui:dispatchMouseShortcut IPC, which main re-resolves and dispatches through the same WindowShortcutAction allowlist. The handler checks sender, main frame, and the recorder flag.
  • Recorder and isolation — the recorder message documents side buttons, and recorder guards were added to the global app dispatcher, the terminal workspace handler, and hold dictation so recording a mouse shortcut does not execute the binding it is capturing.
  • Tests — 7 new/updated suites cover parsing, conflicts, modifier capture across platforms, event consumption and release, recorder isolation, terminal/floating routing, the native main-process dispatch, and an end-to-end CDP-driven flow.

I traced the full renderer↔main event lifecycle: the input.defaultPrevented gate means the synthesized keydown cannot both execute in the renderer and reach the IPC path, and preventDefault on mouseup (the phase Chromium consults for history navigation) is correctly applied to consumed gestures. The tests assert exact values rather than loose truthiness, so they can genuinely fail.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

Reviewed the delta since the prior pullfrog review (6e30bad → 9f00941), one commit.

  • Ignore duplicate mouse presses until release — onMouseDown now early-returns when pressedInputs already owns the button, re-consuming the event (preventDefault + stopImmediatePropagation) only when that button was already a handled gesture. A duplicate mousedown before mouseup (e.g. modifiers change mid-press) can no longer resolve and fire a second binding, while an unhandled bound press still falls through to native navigation.
  • Test — a new case pins exact call counts across the duplicate press, the release/auxclick, and a fresh press after release.

The guard is placed before consumedButtons.delete, so ownership of an in-flight press is preserved until release, and pressedInputs is only populated for dispatched presses, so duplicate presses of unbound buttons still take the normal path. No regression found.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit a86fae0 into main Sep 27, 2026
48 checks passed
@AmethystLiang

Copy link
Copy Markdown
Contributor

@nwparker we reverted this in #23350. Please reland with a fix.

Saving a mouse Back/Forward shortcut and then rolling back the paired web app can drop that action's saved shortcuts, including keyboard shortcuts stored on the same action.

Tracking the reland in https://linear.app/stably/issue/STA-8684

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.

[Feature]: Support mouse buttons (Back/Forward) in keybindings

2 participants