Repository navigation
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 18337813c22fdec62ca5f5eb448c9f59c47cadb0 and e6faa2b. 📒 Files selected for processing (13)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughBrowser Find shortcuts now carry browser page and workspace identifiers through guest forwarding, IPC, and preload subscriptions. Browser overlays derive focused, inactive, and owned-target scopes and pass them to browser page panes to gate Find handling. Tests cover exact source dispatch, subscription cleanup, platform shortcuts, focused split routing, ownership across browser splits, and missing or stale focus state. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1🛠️ 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 |
| @@ -154,12 +161,15 @@ const BrowserPaneOverlayLayer = memo(function BrowserPaneOverlayLayer({ | |||
| {browserTabs.map((browserTab) => { | |||
| const assignment = assignments.get(browserTab.id) | |||
| const isActive = Boolean(isWorktreeActive && assignment && assignment.isActiveInGroup) | |||
| // Why: focused only when this browser's group is the focused split — not merely the active tab in its own group. | |||
| const isFocused = isActive && assignment?.groupId === focusedGroupId | |||
There was a problem hiding this comment.
Cmd+F silently breaks when focusedGroupId is undefined
focusedGroupId is undefined when activeGroupIdByWorktree[worktreeId] hasn't been set yet (e.g. on a fresh worktree before any pointer/focus event). In that case assignment?.groupId === undefined is false for any real group string, so isFocused evaluates to false for every browser pane. Because BrowserPaneOverlayLayer always passes an explicit false (not omitting the prop), the ?? isActive fallback inside BrowserPane never fires — resolvedIsFocused stays false, and the Find listener is never registered. The shortcut silently does nothing until the user clicks the browser chrome and triggers focusGroup for the first time. A guard restores pre-fix behaviour for that uninitialized window: const isFocused = isActive && (focusedGroupId === undefined || assignment?.groupId === focusedGroupId). Or equivalently, pass undefined (omit the prop) when focusedGroupId is undefined so the existing fallback in BrowserPane takes over.
Greptile SummaryThis PR fixes a split-pane focus bug where pressing Cmd/Ctrl+F while the terminal was focused incorrectly opened Find in the adjacent browser pane. The browser pane's window-global capture-phase keydown listener was gated on
Confidence Score: 5/5Safe to merge — the change only narrows the condition under which an existing global keydown listener claims the Find shortcut, and the IPC path is now routed by exact page+workspace identity instead of broadcast. The root cause and fix are clearly analysed, the three code paths (renderer-scope, IPC routing, owned-target fallback) are each exercised by unit and e2e tests, all existing callers of onFindInBrowserPage are updated, and the optional findShortcutScope prop defaults to the pre-fix behaviour so floating-browser surfaces are unaffected. Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| src/renderer/src/components/browser-pane/BrowserPaneOverlayLayer.tsx | Core fix: reads activeGroupIdByWorktree[worktreeId] as focusedGroupId, validates it against the live groups list, and derives a BrowserFindShortcutScope for each browser tab; correctly handles undefined/stale focusedGroupId via the 'owned-target' fallback. |
| src/renderer/src/components/browser-pane/BrowserPane.tsx | Gates the renderer-path Find listener on findShortcutScope instead of isActive; adds 'owned-target' DOM-ancestry check via browserOverlayOwnsShortcutTarget; IPC path now subscribes with a typed BrowserFindSource for exact page+workspace routing. |
| src/preload/browser-find-subscriptions.ts | New module implementing two-level (workspace → page) subscription map for browser Find IPC events; dispatch only reaches the exact matching callback set; cleanup correctly removes empty intermediate maps. |
| src/preload/index.ts | Replaces the broadcast ipcRenderer listener with a single global dispatcher into browserFindSubscriptions; exposes browserFindSubscriptions.subscribe as the new onFindInBrowserPage API — the singleton registration pattern is safe for the preload lifetime. |
| src/main/browser/browser-guest-ui.ts | IPC-path Find now sends a typed BrowserFindSource payload; if resolveWorkspaceId returns null (tab not yet registered), the event is intentionally dropped rather than broadcast — this is the correct safe-default behaviour. |
| src/shared/browser-find-source.ts | New shared type BrowserFindSource with a runtime type guard isBrowserFindSource; guards correctly reject null, non-objects, arrays, and empty strings. |
| src/main/browser/browser-manager.ts | One-line addition wiring the existing workspaceIdByPageId map into setupGuestShortcutForwarding; no other call sites exist for this function in production. |
| tests/e2e/browser-split-find-shortcut.spec.ts | New e2e spec covering the primary regression (terminal focus steals Find), multi-browser split IPC routing, and the two focusedGroupId fallback scenarios (missing and stale). |
| src/renderer/src/components/browser-pane/BrowserPaneOverlayLayer.test.tsx | New unit tests verify focused/inactive/owned-target scope assignment including the stale focusedGroupId case and split reordering; mock correctly exposes findShortcutScope via data attribute. |
| src/preload/browser-find-subscriptions.test.ts | Tests exact-match dispatch semantics, malformed-source rejection, and cleanup of empty map entries — covers the subscription module's contract fully. |
| src/preload/api-types.ts | onFindInBrowserPage signature updated to require a BrowserFindSource first argument; the web stub in web-preload-api.ts is a zero-argument noop that remains type-compatible. |
| src/main/browser/browser-guest-ui.test.ts | Two new test cases for the IPC-path Find: forwards with the correct BrowserFindSource when workspace is registered, and drops silently when no workspace resolver is provided. |
| src/shared/keybindings.test.ts | New test confirms browser.find maps to Command on macOS and Control on Linux/Windows, covering all three platforms. |
Reviews (4): Last reviewed commit: "test(browser): focus split before Find r..." | Re-trigger Greptile
07fee35 to
1833781
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/browser/browser-guest-ui.test.ts (1)
590-602: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExercise the missing-owner resolver path.
This test omits
resolveWorkspaceId, so it does not cover the production path where the resolver exists but returnsnullfor an unregistered page.Proposed test adjustment
setupGuestShortcutForwarding({ browserTabId, guest: makeGuest(), - resolveRenderer: () => makeRenderer() + resolveRenderer: () => makeRenderer(), + resolveWorkspaceId: () => null })
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 8610534a-fdbc-420d-bb74-fd9c6b01efba
📥 Commits
Reviewing files that changed from the base of the PR and between 07fee35c39ae4b31063074577a8404c88dd560da and 18337813c22fdec62ca5f5eb448c9f59c47cadb0.
📒 Files selected for processing (13)
src/main/browser/browser-guest-ui.test.tssrc/main/browser/browser-guest-ui.tssrc/main/browser/browser-manager.tssrc/preload/api-types.tssrc/preload/browser-find-subscriptions.test.tssrc/preload/browser-find-subscriptions.tssrc/preload/index.tssrc/renderer/src/components/browser-pane/BrowserPane.tsxsrc/renderer/src/components/browser-pane/BrowserPaneOverlayLayer.test.tsxsrc/renderer/src/components/browser-pane/BrowserPaneOverlayLayer.tsxsrc/shared/browser-find-source.tssrc/shared/keybindings.test.tstests/e2e/browser-split-find-shortcut.spec.ts
) The browser pane's renderer-path Find handler is a window-global capture-phase keydown listener, but it armed on `isActive` (the active tab within its own group) rather than on whether its split holds focus. In a terminal+browser split, the browser was therefore `isActive` even while the terminal held keyboard focus, so it swallowed Cmd/Ctrl+F and opened find-in-page in the browser instead of find-in-terminal. Thread a focused-split signal (`isFocused`) from BrowserPaneOverlayLayer — derived from `activeGroupIdByWorktree` — down to the Find handler and gate the listener on it. This mirrors how terminal leaves already gate global shortcuts via `focusedGroupId` in TabGroupSplitLayout. Floating browser panels omit the prop and fall back to `isActive`, preserving their behavior. The IPC path (webview guest focused) is unchanged; it only fires when the guest genuinely has focus. Not platform-specific: the chord resolves through `keybindingMatchesAction` (Mod -> metaKey on macOS, ctrlKey elsewhere), so the same path is fixed on macOS, Linux, and Windows. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
1833781 to
e6faa2b
Compare
) (stablyai#11351) * fix(browser): scope Cmd/Ctrl+F find to the focused split (stablyai#11348) The browser pane's renderer-path Find handler is a window-global capture-phase keydown listener, but it armed on `isActive` (the active tab within its own group) rather than on whether its split holds focus. In a terminal+browser split, the browser was therefore `isActive` even while the terminal held keyboard focus, so it swallowed Cmd/Ctrl+F and opened find-in-page in the browser instead of find-in-terminal. Thread a focused-split signal (`isFocused`) from BrowserPaneOverlayLayer — derived from `activeGroupIdByWorktree` — down to the Find handler and gate the listener on it. This mirrors how terminal leaves already gate global shortcuts via `focusedGroupId` in TabGroupSplitLayout. Floating browser panels omit the prop and fall back to `isActive`, preserving their behavior. The IPC path (webview guest focused) is unchanged; it only fires when the guest genuinely has focus. Not platform-specific: the chord resolves through `keybindingMatchesAction` (Mod -> metaKey on macOS, ctrlKey elsewhere), so the same path is fixed on macOS, Linux, and Windows. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix(browser): preserve Find before split focus settles * fix(browser): handle stale focused split IDs * fix(browser): route guest Find to source page * test(browser): wait for split address bar * test(browser): focus split before Find routing --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]> Co-authored-by: OrcaWin <[email protected]>
Summary
Fixes #11348.
In a terminal + browser split, pressing Cmd+F (macOS) / Ctrl+F (Windows/Linux) while the terminal was focused opened Find in the browser pane instead of find-in-terminal.
Root cause: the browser pane's renderer-path Find handler (
BrowserPagePaneinBrowserPane.tsx) is a window-global, capture-phasekeydownlistener that was armed onisActive— "am I the active tab within my own group?" — not on whether its split holds keyboard focus.BrowserPaneOverlayLayercomputesisActivefromisWorktreeActive && isActiveInGroup, which ignoresactiveGroupIdByWorktree(the focused split). So in a split the browser wasisActiveeven while the terminal was focused, and its unscoped listener calledpreventDefault()+stopPropagation(), claiming the chord before the (correctly focus-scoped) terminal handler could act.Fix: thread a focused-split signal (
isFocused) fromBrowserPaneOverlayLayer— derived fromactiveGroupIdByWorktree[worktreeId]— throughBrowserPane→BrowserPagePane, and gate the renderer-path Find listener onisFocusedinstead ofisActive. This mirrors how terminal leaves already gate global shortcuts viafocusedGroupIdinTabGroupSplitLayout.tsx. The IPC path (webview guest focused) is left onisActive— it only fires when the guest genuinely has focus, so it is already correct.Screenshots
No visual change. Behavior-only: the Find bar now opens in whichever split (terminal or browser) holds keyboard focus.
Testing
pnpm lint(oxlint + oxfmt ran clean via pre-commit; targeted lint ofbrowser-paneclean)pnpm typecheck(tsconfig.tc.web.jsonclean)pnpm test(browser-pane suite: 32 files / 181 tests pass)pnpm buildBrowserPaneOverlayLayer.test.tsx: an active browser pane isfocusedwhen its own group holds focus, and notfocusedwhen another split (e.g. the terminal) holds focus ([Bug]: Cmd/Ctrl+F opens Find in the browser pane instead of the focused terminal in a split #11348).AI Review Report
Reviewed with an AI coding agent. Checks and outcomes:
keybindingMatchesAction('browser.find', …)which resolvesMod→metaKeyon macOS andctrlKeyelsewhere — a single code path, so the fix applies uniformly. Noe.metaKeyhardcoding introduced; no platform-specific labels or paths touched.BrowserPanegained an optionalisFocusedprop defaulting toisActive, so the floating-browser call sites (Terminal.tsx,FloatingBrowserSlot.tsx) are unchanged. SSH/remote pane (RemoteBrowserPagePane) has no Find handler and is untouched.Security Audit
No new input handling, command execution, path handling, auth, secrets, dependency, or IPC surface. The change only narrows the condition under which an existing renderer keydown listener is registered (fewer events claimed, not more). No IPC channels added or modified. No follow-up needed.
Notes
onPointerDown/onFocusCapture→focusGroup, so Cmd/Ctrl+F opens the browser find bar as before.