Repository navigation
fix(browser): scope back/forward/reload/zoom/grab shortcuts to the originating split - #22340
Conversation
…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.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 📝 WalkthroughWalkthroughBrowser 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 Repeated test runs accumulate small temporary files. The PR remains mergeable with localized cleanup. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Out of Scope Changes checkExplanation The linked issue [ 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 [
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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 |
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.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Page-id targeting for guest-forwarded chords.
ui:focusBrowserAddressBar,ui:reloadBrowserPage,ui:hardReloadBrowserPage,ui:browserHistoryNavigateandui:zoomBrowserPagenow carry{ browserPageId, direction? };src/shared/browser-page-command-target.tsholds the types and admission validators, the preload drops malformed payloads, and every pane filters onbrowserPageId === browserTabId. - Focused-split ownership for chrome-focus chords.
browserChromeShortcutOwnsEventfactors the Find rule (inactive→ false,focused→ true,owned-target→ overlay-owned target only) and replaces the!isActivegates in the webview history/reload paths and the element-grab handler; the two renderer capture paths now usestopImmediatePropagation. - Element-grab selection guard.
hasTextSelectionOutsideOverlaystops 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-unusedisActiveparam was dropped) into the scope-awareuseRemoteBrowserPageChromeChords, reusing the existingrunRemoteNavigation.
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.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ 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/asBrowserPageZoomCommandand 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.
browserChromeShortcutOwnsEventis nowfocused || (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 theowned-targettest. The explicitinactivebranch was safe to drop — every caller returns early oninactivefirst. - 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.
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.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes (delta 22a7d1d → 200f5f4, commits 05fc21ea and 200f5f40)
- Consolidated the zoom command type.
BrowserPageZoomCommandmoved fromsrc/shared/browser-page-command-target.tstosrc/shared/browser-page-zoom.tsand replaced the shape-identicalBrowserPageZoomEventDetail; 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.tsroutes bothonZoomBrowserPageand the localorca:browser-page-zoomevent through a singlehandleZoomthat filters onbrowserPageId === browserTabId. - Narrowed the zoom event without a cast.
addBrowserPageZoomEventListenerusesevent instanceof CustomEventinstead of an assertedCustomEventcast, dropping the lint suppression added in the prior commit. - Renamed the ownership check's parameter
overlayTabId→workspaceIdinbrowserChromeShortcutOwnsEventto 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).
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.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes (delta 200f5f4 → 137b2bd, commit 137b2bd — E2E test commit)
- Split-scoped navigation E2E spec.
browser-split-navigation-shortcuts.spec.tsmounts two real browser splits on different hosts and presses back / forward / reload / hard-reload / zoom / focus-address-bar chords inside the guest throughwebview.sendInputEvent, asserting the sibling split'sdid-start-loadingcount stays0and 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.tsasserts 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.tsand a no-storebrowser-split-page-server.tsreplace the local helpers previously duplicated insidebrowser-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'sfullyParallel: truepins 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'sHostZoomMapis host-keyed — consistent with the documentedsetBrowserPageZoomLevelcontract.
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.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
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: 922b542d-c00d-4e74-9de5-059b013b247d
📒 Files selected for processing (6)
tests/e2e/browser-split-grab-shortcut.spec.tstests/e2e/browser-split-navigation-shortcuts.spec.tstests/e2e/browser-split-shortcuts.spec.tstests/e2e/helpers/browser-split-fixture.tstests/e2e/helpers/browser-split-guest-probes.tstests/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.
| const transcriptPath = path.join( | ||
| mkdtempSync(path.join(os.tmpdir(), 'orca-e2e-split-grab-')), | ||
| `${sessionId}.jsonl` | ||
| ) | ||
| writeFileSync(transcriptPath, claudeTranscript(sessionId, args.reply)) |
There was a problem hiding this comment.
🩺 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.

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:
browserPageId(payload types insrc/shared/browser-page-command-target.tsandsrc/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.chromeShortcutScope+browserOverlayOwnsShortcutTarget+stopImmediatePropagation), factored intobrowserChromeShortcutOwnsEvent, which Find, Focus Address Bar and the remote chord hook now share too.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.a 1,b 1).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.tsxmounts 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.pnpm tc, the 114 affected test files (955 tests), oxlint, oxfmt andcheck:code-quality:changedpass 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.