Skip to content

fix(browser): scope back/forward/reload/zoom/grab shortcuts to the originating split - #22340

Merged
Jinwoo-H merged 5 commits into
mainfrom
jinwoo/sta-8147-bug-browser-back-forward-reload-shortcuts-affect-multiple
Sep 23, 2026
Merged

Jinwoo-H merged 5 commits into
mainfrom
jinwoo/sta-8147-bug-browser-back-forward-reload-shortcuts-affect-multiple

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1186 $\color{#cf222e}{\Huge{\mathbf{−}}}$​252 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​934
Prod 18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​184 $\color{#cf222e}{\Huge{\mathbf{−}}}$​123 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​61

ELI5

With two browser panes side by side, pressing Back, Reload, zoom, etc. inside one of them did it in both. Now only the pane you pressed it in reacts. Separately, Cmd+C in the native chat no longer gets hijacked by the browser's "grab element" shortcut.

What Changed

Before: in a split with two browser panes, Back / Forward / Reload / Hard Reload / page zoom / Focus Address Bar ran in every visible browser pane. The same happened when the key was pressed in the browser toolbar, or even in a terminal in another split. With a browser pane open, selecting chat transcript text and pressing Cmd+C armed element-grab instead of copying.

After: only the pane the shortcut came from reacts, and Cmd+C copies the chat selection.

Mechanism:

  • When a page has focus, the main process forwards these shortcuts to the Orca window. It used to send them with no indication of which page they came from, and every split's active browser pane listened. They now carry the originating browserPageId (payload types in src/shared/browser-page-command-target.ts and src/shared/browser-page-zoom.ts), and each pane ignores ids that aren't its own, the same way the scroll event already works. Main and preload ship in one bundle, so the payload is typed rather than validated.
  • Shortcuts pressed in Orca's own UI (the toolbar) were handled by one window-wide listener per pane. These now use the same focused-split rule Find already uses (chromeShortcutScope + browserOverlayOwnsShortcutTarget + stopImmediatePropagation), factored into browserChromeShortcutOwnsEvent, which Find, Focus Address Bar and the remote chord hook now share too.
  • Element-grab (Cmd/Ctrl+C) gets the same focused-split rule; clicking the chat focuses its split, so the browser pane stops listening. It also doesn't arm while any text is selected, because surfaces outside split groups (the floating terminal panel, sidebars) don't move split focus.
  • The streamed remote browser pane's own Back/Forward listener had the same bug. It moved into its existing scoped chord hook.

Why

This extends two mechanisms already in the codebase instead of adding a new one. Targeting by page id is what scroll and Cmd+W (#17281) already do; the focused-split rule is what Find (#11351) already does. Page id was chosen over workspace id because client-hosted guests have no workspace id.

Linked Issue

Fixes #22143 (STA-8147). Also fixes STA-7669 (duplicate: Cmd+R refreshes every browser) and STA-3319 (Cmd+C in the native chat arms element-grab).

Visual Proof

Two browser splits, each on its second page (a/2, b/2). Cmd+[ is typed inside the left page only. Captured from the real app (hidden window, CDP screenshots); "before" is this branch with the fix's source files reverted.

Before Back After Back in the left pane
Before fix before-1-before-back.png before-2-after-back.png Both panes went back (a 1, b 1).
With fix after-1-before-back.png after-2-after-back.png Only the left pane went back (a 1, b 2).

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • New use-browser-page-keyboard-shortcuts.split.test.tsx mounts two panes. It covers the page-originated history, reload, hard reload and zoom shortcuts; toolbar keys in the focused, inactive and owned-target scopes; grab arming only in the focused pane; and a live text selection blocking grab.

  • Updated the main-process forwarding and wheel-zoom tests, the address-bar focus test, the client-hosted parity test and the remote chord tests (including address-bar history under the owned-target scope).

  • New e2e specs drive the real app with real key presses, typed into the page itself or into the browser toolbar:

    • tests/e2e/browser-split-navigation-shortcuts.spec.ts, with two browser splits: Back/Forward, Reload/Hard Reload, keyboard page zoom and Focus Address Bar typed in one page act only on that split. Back/Reload pressed with the toolbar focused act only on that split. With a terminal split focused, Back/Reload/Hard Reload leave the browser alone.
    • tests/e2e/browser-split-grab-shortcut.spec.ts: Cmd/Ctrl+C from one split's toolbar arms grab only in that split. With native chat transcript text selected, Cmd/Ctrl+C copies the text to the clipboard and doesn't arm grab, both while the chat is focused and after focus moves to the browser toolbar.
    • With the fix's source files reverted, all 8 new e2e tests fail and the 4 existing Find tests still pass. With the fix, all 12 pass on two runs in a row.
    • Ctrl+wheel zoom isn't covered in e2e: synthetic wheel input never reaches the main-process listener, which only sees OS input. The unit test covers it.
  • pnpm tc, the 114 affected test files (955 tests), oxlint, oxfmt and check:code-quality:changed pass locally on macOS.

Notes

Cross-platform: the shortcuts go through the existing keybindingMatchesAction, with no platform-specific code added. SSH/remote: this is main↔renderer IPC inside one app bundle, and the remote pane's history now goes through its existing scoped hook. Web/mobile stubs are unaffected.

Out of scope, found while fixing: the tab-switch and jump-to-tab shortcuts forwarded from a page carry no source id and can act on the wrong split (related to STA-8148). The markup-mode Cmd+Z and grab-mode Escape handlers are window-wide while those modes are open.

…iginating split

With two browser panes visible in a split, Back, Forward, Reload, Hard
Reload, page zoom and Focus Address Bar fired in every visible pane. Main
forwarded these guest chords without the page id, and each split's active
pane subscribed. The renderer-side listeners for the same chords were also
window-wide per pane, so a key pressed in the toolbar (or in a terminal in
another split) reached every active browser pane.

Guest-forwarded chords now carry the originating browserPageId; preload
admits only well-formed payloads and each pane ignores ids that aren't its
own. Toolbar-path listeners use the same focused-split scope Find already
uses. The streamed remote pane's history chord moves onto that scoped hook.

Cmd/Ctrl+C grab (STA-3319) gets the same scope and no longer arms while a
text selection exists outside the browser pane, so copying from the native
chat transcript works again.
@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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

📝 Walkthrough

Walkthrough

Browser shortcut IPC messages now include a browser page identifier for focus, reload, hard reload, history, and zoom commands. Preload callbacks pass typed payloads through. Renderer listeners filter commands by page and apply chrome shortcut ownership checks. Remote browser back and forward chords are handled by the chrome-chord hook. Grab handling checks shortcut ownership and text selection. Unit, component, and end-to-end tests cover split-pane routing.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 137b2

Repeated test runs accumulate small temporary files. The PR remains mergeable with localized cleanup.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The linked issue [#22143] covers Back, Forward, Reload, and Hard Reload pane targeting. The PR also changes page zoom, Focus Address Bar, Find shortcut ownership, remote navigation behavior, and Cmd/C… Remove the unrelated page zoom, Focus Address Bar, Find ownership, and element-grab/text-selection behavior changes, or link them to separate issue requirements. Keep shared shortcut-routing changes only when they are necessary for the four…
Docstring Coverage ⚠️ Warning Docstring coverage is 22.41% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 58 functions across 31 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue [#22143] requires Back, Forward, Reload, and Hard Reload to affect only the originating browser pane. The PR forwards these commands with browserPageId, filters guest and pane listeners by tha…
Title check ✅ Passed The title clearly identifies the primary change: scoping browser and grab shortcuts to the originating split.
Description check ✅ Passed The description is detailed and covers the user impact, implementation, linked issues, visual proof, testing, and cross-platform considerations. It omits the template's AI Disclosure, Review, Agent sk…
Full details: Out of Scope Changes check

Explanation

The linked issue [#22143] covers Back, Forward, Reload, and Hard Reload pane targeting. The PR also changes page zoom, Focus Address Bar, Find shortcut ownership, remote navigation behavior, and Cmd/Ctrl+C element-grab behavior when text is selected. The PR adds separate E2E coverage for these behaviors. The summary does not establish that these changes are required to fix [#22143].

Resolution

Remove the unrelated page zoom, Focus Address Bar, Find ownership, and element-grab/text-selection behavior changes, or link them to separate issue requirements. Keep shared shortcut-routing changes only when they are necessary for the four navigation shortcuts in [#22143].

  • 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.

Drop the preload payload admission (main and preload ship together), fold
the three inline scope checks into browserChromeShortcutOwnsEvent, and
replace the outside-overlay selection check with a plain live-selection
rule so Cmd+C copies from surfaces that do not move split focus.

@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

  • Page-id targeting for guest-forwarded chords. ui:focusBrowserAddressBar, ui:reloadBrowserPage, ui:hardReloadBrowserPage, ui:browserHistoryNavigate and ui:zoomBrowserPage now carry { browserPageId, direction? }; src/shared/browser-page-command-target.ts holds the types and admission validators, the preload drops malformed payloads, and every pane filters on browserPageId === browserTabId.
  • Focused-split ownership for chrome-focus chords. browserChromeShortcutOwnsEvent factors the Find rule (inactive → false, focused → true, owned-target → overlay-owned target only) and replaces the !isActive gates in the webview history/reload paths and the element-grab handler; the two renderer capture paths now use stopImmediatePropagation.
  • Element-grab selection guard. hasTextSelectionOutsideOverlay stops Cmd/Ctrl+C from arming grab when a live DOM selection sits outside the pane (the native-chat case).
  • Remote pane. Its window-wide Back/Forward listener moved out of useRemoteBrowserPageNavigation (whose now-unused isActive param was dropped) into the scope-aware useRemoteBrowserPageChromeChords, reusing the existing runRemoteNavigation.

I confirmed the load-bearing contract: the workspaceId these hooks pass as overlayTabId is the browser workspace tab id, which is exactly the data-browser-overlay-tab-id value BrowserPaneOverlayLayer renders, and main's browserPageId equals the renderer's browserTabId for local and client-hosted panes. I ran the four targeted suites (65 tests, all pass) plus check:code-quality:changed (clean), and the new split-test assertions are meaningfully regressive — with the old hooks both panes in a split react to a single payload/chord.

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 since the prior review (delta e1cbc4e → 22a7d1d, "simplify split shortcut scoping per review")

  • Dropped the runtime payload validators. Removed asBrowserPageCommandTarget / asBrowserHistoryNavigateCommand / asBrowserPageZoomCommand and their shared test; preload now forwards the typed { browserPageId, direction? } straight to subscribers. Every main-side sender is typed and there is no other sender, so the typed contract is sufficient.
  • Consolidated the scope check. browserChromeShortcutOwnsEvent is now focused || (owned-target && overlay owns target), and Find, Focus Address Bar, the webview history/reload paths and the remote chord hook all call it instead of re-implementing the owned-target test. The explicit inactive branch was safe to drop — every caller returns early on inactive first.
  • Grab selection guard simplified from "selection outside this overlay" to any live host selection (window.getSelection()?.isCollapsed === false), with the corresponding synthetic test removed.
  • Test updates: the remote chord suite now returns the RTL container and adds an owned-target address-bar history case.

I re-read the touched hooks against their callers and re-ran the nine affected suites (108 tests, all pass) plus check:code-quality:changed (clean). The refactor is behavior-preserving apart from the intentionally stricter grab rule (any host selection means copy), and the removed validator test is replaced by the typed contract rather than left as dead coverage.

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

…ents

BrowserPageZoomEventDetail and BrowserPageZoomCommand were the same shape;
keep one in shared/browser-page-zoom.ts and route guest and local zoom
through a single handler.

@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 (delta 22a7d1d → 200f5f4, commits 05fc21ea and 200f5f40)

  • Consolidated the zoom command type. BrowserPageZoomCommand moved from src/shared/browser-page-command-target.ts to src/shared/browser-page-zoom.ts and replaced the shape-identical BrowserPageZoomEventDetail; the preload, the split test and the client-hosted parity test now import it from the new location.
  • Unified the guest and local zoom handlers. use-browser-page-webview-shortcuts.ts routes both onZoomBrowserPage and the local orca:browser-page-zoom event through a single handleZoom that filters on browserPageId === browserTabId.
  • Narrowed the zoom event without a cast. addBrowserPageZoomEventListener uses event instanceof CustomEvent instead of an asserted CustomEvent cast, dropping the lint suppression added in the prior commit.
  • Renamed the ownership check's parameter overlayTabId → workspaceId in browserChromeShortcutOwnsEvent to match the value's actual identity (the browser workspace tab id).

The two callback paths merged in handleZoom were previously identical apart from the guard direction, so the refactor is behavior-preserving. I re-ran pnpm tc (clean), the three affected suites (42 tests, all pass) and oxlint on the four touched source files (0 warnings, 0 errors).

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

Two browser splits (and a terminal beside a browser) now prove that Back,
Forward, Reload, Hard Reload, page zoom, Focus Address Bar, and the element
grab chord act only on the split that sent them, from both the guest page and
the browser toolbar. A native chat selection proves Cmd/Ctrl+C copies instead
of arming grab. Split fixtures move to a shared helper so both specs reuse them.

@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 (delta 200f5f4 → 137b2bd, commit 137b2bd — E2E test commit)

  • Split-scoped navigation E2E spec. browser-split-navigation-shortcuts.spec.ts mounts two real browser splits on different hosts and presses back / forward / reload / hard-reload / zoom / focus-address-bar chords inside the guest through webview.sendInputEvent, asserting the sibling split's did-start-loading count stays 0 and its URL/zoom is untouched. It also covers toolbar-originated chords and a focused-terminal negative case.
  • Element-grab E2E spec. browser-split-grab-shortcut.spec.ts asserts Cmd/Ctrl+C from one split's toolbar arms grab only in that split, and that a live selection (seeded native-chat transcript) makes the chord copy instead of arming even while the browser split holds focus — the case only the live-selection check can distinguish — with a clear-selection presence check so a missing banner is meaningful.
  • Shared E2E helpers extracted. browser-split-fixture.ts, browser-split-guest-probes.ts and a no-store browser-split-page-server.ts replace the local helpers previously duplicated inside browser-split-shortcuts.spec.ts; that file now imports them, behavior-preserving.
  • The two grab tests intentionally share the system clipboard and use test.describe.configure({ mode: 'default' }), which under this config's fullyParallel: true pins them to a single worker. The chords match the platform defaults (Mod+BracketLeft/Alt+ArrowLeft, Mod+R, Mod+Shift+R, Mod+=, Mod+L), and the zoom test isolates panes by host because Chromium's HostZoomMap is host-keyed — consistent with the documented setBrowserPageZoomLevel contract.

No prior inline threads were open. I confirmed the helper extraction preserves behavior against the previous in-file versions (same store calls, same guest sendInputEvent sequence, real DOM assertions), so the new specs would genuinely fail on the pre-fix code rather than only exercising the store. The only production delta is a trailing blank line in shared/browser-page-zoom.ts.

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

@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: 922b542d-c00d-4e74-9de5-059b013b247d

📥 Commits

Reviewing files that changed from the base of the PR and between 200f5f4 and 137b2bd.

📒 Files selected for processing (6)
  • tests/e2e/browser-split-grab-shortcut.spec.ts
  • tests/e2e/browser-split-navigation-shortcuts.spec.ts
  • tests/e2e/browser-split-shortcuts.spec.ts
  • tests/e2e/helpers/browser-split-fixture.ts
  • tests/e2e/helpers/browser-split-guest-probes.ts
  • tests/e2e/helpers/browser-split-page-server.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.

Comment on lines +90 to +94
const transcriptPath = path.join(
mkdtempSync(path.join(os.tmpdir(), 'orca-e2e-split-grab-')),
`${sessionId}.jsonl`
)
writeFileSync(transcriptPath, claudeTranscript(sessionId, args.reply))

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Remove the temporary transcript after Electron shuts down.

These lines create a new orca-e2e-split-grab-* directory for each execution. No code removes the directory.

Register a recursive removal callback with registerPostElectronShutdownCleanup. This prevents repeated local and CI runs from accumulating transcript files.

@Jinwoo-H
Jinwoo-H merged commit dfff391 into main Sep 23, 2026
36 checks passed
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.

[Bug]: Browser Back / Forward / Reload shortcuts affect multiple visible split panes

1 participant