Skip to content

feat: step worktree history with mouse Back/Forward buttons - #25920

Open
shaharmor wants to merge 10 commits into
stablyai:mainfrom
shaharmor:users/shaharmor/back-forward
Open

shaharmor wants to merge 10 commits into
stablyai:mainfrom
shaharmor:users/shaharmor/back-forward

Conversation

@shaharmor

Copy link
Copy Markdown
Contributor

ELI5

Your mouse's side buttons now work like the ← → buttons in Orca's title bar. Back takes you to the worktree or page you were on before, and Forward takes you back again. If the pointer is over a web page open inside Orca, the buttons go back and forward in that page instead.

What Changed

Before: Orca ignored mouse Back/Forward. In the web client, pressing Back could even take the browser tab away from Orca.

After:

Pointer is over… Mouse Back / Forward does
Any Orca surface (sidebar, terminal, editor, dividers) One step through worktree visit history, the same as the titlebar ← → and Mod+Alt+←/→
Settings, or the new-workspace layout (titlebar ← → hidden) Nothing
A local embedded browser page That page's own Back/Forward
A remote (screencast) browser page That page's own Back/Forward, through the existing browser.back/forward runtime call
The annotation overlay on a page Nothing (the press belongs to the page you are annotating)

Each press moves exactly one step and never navigates Orca's own document. History still records only worktrees and pages, not tabs.

Mechanism:

  • A window capture listener for pointerdown/pointerup with button 3/4 cancels the browser's default action and calls the existing worktree.history.back/forward command handlers, so it reuses their view gating. Whether a press goes to worktree history or to a web page depends on where it started, so a press that starts on a page and ends over Orca chrome stays with the page.
  • Local <webview> pages need a main-process forwarder (browser-guest-mouse-history.ts). Chromium routes an unhandled side-button press to the outermost WebContents (WebContentsImpl::HandleMouseEvent → GetOutermostWebContents()), which is Orca's window, not the page under the pointer. The forwarder catches the press in before-mouse-event and sends the existing ui:browserHistoryNavigate IPC, which the Logitech keystroke remaps already use.
  • Remote pages queue their history step behind any in-flight click, so Back can't overtake a link click that hasn't landed yet. A failure while resolving the remote page now shows the pane's error notice instead of an unhandled rejection.

Why

Linked Issue

Related: #23255 (asks for rebindable mouse-button keybindings; this PR adds fixed history navigation, not rebinding)

Visual Proof

To be attached (needs a physical side-button mouse): before (side buttons do nothing) and after (Back/Forward switch worktrees; over an embedded page they navigate the page).

Testing

Automated:

  • New unit tests cover button mapping, view gating, cancelled pointerdown, a press that starts on one surface and ends on another, the annotation overlay, the guest forwarder, remote input ordering, and remote failure handling. The ordering, failure, and divider tests fail without their fixes.
  • Headless Electron e2e, ORCA_BACKGROUND_LAUNCH=1, CDP Input.dispatchMouseEvent with button: 'back'/'forward':
    • workspace-back-forward-navigation.spec.ts: one step per press, a double step is detectable, Settings does nothing.
    • New browser-mouse-back-forward.spec.ts: a local page navigates while worktree history stays put, and a host-side press over a webview changes nothing.
    • New browser-mouse-back-forward.spec.ts: Back over a split divider (which cancels pointerdown) still steps worktree history. This test fails on the earlier mouse-event version.
    • These e2e tests first give Orca's document and the worktree history a back entry, so the "nothing navigated" assertions can actually fail.
    • 12/12 pass.
  • pnpm tc (web/node), changed-code quality gate, oxlint: clean.
  • 41 tests in src/main/browser/browser-manager-tab-identity.test.ts and browser-manager-viewport-ownership.test.ts fail; they fail identically on the base commit without this branch.

Not yet verified: physical side-button mice on macOS, Windows, and Linux, and the web client in Firefox/Safari.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

AI Disclosure

Planned, implemented, and reviewed with an AI coding agent (Claude Opus via pi). Code review used parallel Claude and GPT arms; all 7 findings were applied.

Review

Known limits, intentionally out of scope:

  • A side button can switch worktrees while a dialog is open, which the existing Mod+Alt+←/→ shortcut already does.
  • Over the artifact and doc preview webviews, which are not registered browser tabs, the side buttons do nothing.
  • Web pages can no longer handle buttons 4/5 themselves, because Orca claims them for page history.
  • The local-page forwarder relies on Electron reporting button: 'back' | 'forward' in before-mouse-event. Electron's converter does this, but its typings list only left/middle/right.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

  • Cross-platform: uses DOM button 3/4, which Chromium reports on macOS, Windows, and Linux. There is no platform branch. Mice whose vendor tool remaps the side buttons to keystrokes (Logi Options+ on macOS) keep using the existing keyboard shortcuts.
  • SSH/remote: remote pages use the existing browser.back/forward runtime RPC. No wire change.
  • Mobile: not affected.

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)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…Forward

Claim side buttons on pointer events with press-origin tracking, treat the
annotation overlay as page content, queue remote page history behind pending
input, handle ensureRemotePage failures, and rename the shared guest mouse slot.
…ward e2e

Seed navigable worktree and host-document history so isolation checks can fail,
cover a divider that cancels pointerdown, and drop the store type assertion.
@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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: f6a9a641-b573-41ca-9bbb-1203bdc9134d
📥 Commits

Reviewing files that changed from the base of the PR and between 5af0202 and 391bde7.

📒 Files selected for processing (2)
  • src/renderer/src/components/browser-pane/stream-remote/use-remote-browser-page-input.test.tsx
  • src/renderer/src/components/browser-pane/stream-remote/use-remote-browser-side-button-press.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/renderer/src/components/browser-pane/stream-remote/use-remote-browser-page-input.test.tsx
  • src/renderer/src/components/browser-pane/stream-remote/use-remote-browser-side-button-press.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

The change adds Back and Forward mouse-button handling for guest browser pages, app-shell worktree history, and remote browser pages. Guest events are forwarded to the renderer, while app-shell and remote-page handlers distinguish browser-page input from worktree navigation. The remote input hook captures side-button presses and queues navigation on matching releases. Navigation setup errors now produce pane notices. Unit and end-to-end tests cover routing, event cancellation, cleanup, and history behavior.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 391bd

This change routes mouse Back and Forward buttons to the right target. I found no concrete merge-blocking issue in the selected changes. Physical side-button hardware testing is still unreported, so a quick manual check is worthwhile.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 38.24% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 34 functions across 26 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 main change: using mouse Back/Forward buttons to navigate worktree history.
Description check ✅ Passed The description is detailed and follows the template. It explains the user-facing change, implementation, rationale, linked issue, and testing. The required visual proof is still marked as pending, an…
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.
  • Fix all pre-merge checks with AI
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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: Advanced
  • Run ID: 66e9b6c0-53bc-4513-807d-94bbfab82d72
📥 Commits

Reviewing files that changed from the base of the PR and between 7faa9f7 and 0118b56.

📒 Files selected for processing (22)
  • src/main/browser/browser-guest-mouse-history.test.ts
  • src/main/browser/browser-guest-mouse-history.ts
  • src/main/browser/browser-manager-bindings.ts
  • src/main/browser/browser-manager-destroyed-guest-test-fixture.ts
  • src/main/browser/browser-manager-registration.ts
  • src/main/browser/browser-manager-state.ts
  • src/renderer/src/app-shell/app-command-handlers-worktree-history.test.ts
  • src/renderer/src/app-shell/mouse-history-buttons.test.ts
  • src/renderer/src/app-shell/mouse-history-buttons.ts
  • src/renderer/src/app-shell/use-global-keybindings.ts
  • src/renderer/src/components/browser-pane/stream-remote/remote-browser-page-input-model.test.ts
  • src/renderer/src/components/browser-pane/stream-remote/remote-browser-page-input-model.ts
  • src/renderer/src/components/browser-pane/stream-remote/remote-browser-page-pane.tsx
  • src/renderer/src/components/browser-pane/stream-remote/remote-browser-page-viewport.tsx
  • src/renderer/src/components/browser-pane/stream-remote/use-remote-browser-page-input.test.tsx
  • src/renderer/src/components/browser-pane/stream-remote/use-remote-browser-page-input.ts
  • src/renderer/src/components/browser-pane/stream-remote/use-remote-browser-page-navigation-failure.test.ts
  • src/renderer/src/components/browser-pane/stream-remote/use-remote-browser-page-navigation.ts
  • src/renderer/src/lib/browser-page-surface.ts
  • tests/e2e/browser-mouse-back-forward.spec.ts
  • tests/e2e/helpers/host-history-probe.ts
  • tests/e2e/workspace-back-forward-navigation.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

- Remote browser frame keeps a side-button press with the surface it started on:
  capture the pointer on press, navigate only on the matching release, and drop
  the press when capture is lost.

@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: Advanced
  • Run ID: 07239173-8020-4b37-b99e-04986c6e7f72
📥 Commits

Reviewing files that changed from the base of the PR and between 0118b56 and f988d11.

📒 Files selected for processing (7)
  • src/renderer/src/components/browser-pane/stream-remote/remote-browser-page-pane.address-bar.test.tsx
  • src/renderer/src/components/browser-pane/stream-remote/remote-browser-page-pane.chrome-chords.test.tsx
  • src/renderer/src/components/browser-pane/stream-remote/remote-browser-page-pane.tsx
  • src/renderer/src/components/browser-pane/stream-remote/remote-browser-page-viewport.tsx
  • src/renderer/src/components/browser-pane/stream-remote/use-remote-browser-page-input.test.tsx
  • src/renderer/src/components/browser-pane/stream-remote/use-remote-browser-page-input.ts
  • src/renderer/src/components/browser-pane/stream-remote/use-remote-browser-side-button-press.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

- Handle a side button pressed or released while another button is held. That
  transition arrives as a chorded pointermove, so both the window listener and the
  remote frame now read side-button presses and releases from pointerdown, pointerup,
  and pointermove alike. The window listener also cancels the side-button mouseup,
  because cancelling a pointermove does not suppress the compat mouse events.

@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: Advanced
  • Run ID: e13c5f0e-c63c-420a-a6c1-3f00ab19ff7a
📥 Commits

Reviewing files that changed from the base of the PR and between f988d11 and 5af0202.

📒 Files selected for processing (11)
  • src/renderer/src/app-shell/mouse-history-buttons.test.ts
  • src/renderer/src/app-shell/mouse-history-buttons.ts
  • src/renderer/src/components/browser-pane/stream-remote/remote-browser-page-pane.address-bar.test.tsx
  • src/renderer/src/components/browser-pane/stream-remote/remote-browser-page-pane.chrome-chords.test.tsx
  • src/renderer/src/components/browser-pane/stream-remote/remote-browser-page-pane.tsx
  • src/renderer/src/components/browser-pane/stream-remote/remote-browser-page-viewport.tsx
  • src/renderer/src/components/browser-pane/stream-remote/use-remote-browser-page-input.test.tsx
  • src/renderer/src/components/browser-pane/stream-remote/use-remote-browser-page-input.ts
  • src/renderer/src/components/browser-pane/stream-remote/use-remote-browser-side-button-press.ts
  • src/renderer/src/lib/side-button-transition.ts
  • tests/e2e/workspace-back-forward-navigation.spec.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • tests/e2e/workspace-back-forward-navigation.spec.ts
  • src/renderer/src/components/browser-pane/stream-remote/use-remote-browser-page-input.test.tsx
  • src/renderer/src/app-shell/mouse-history-buttons.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

- Capture the pointer for a side button chorded with another button too, so its
  release over Orca chrome still reaches the remote frame.

This branch has not been deployed

No deployments
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