Repository navigation
Conversation
Terminal activation hands the keyboard to xterm before returning, but every browser tab activation path only updated store state, so an already-mounted guest kept whatever focus it had until the user clicked the page. Request page focus from the three activation routes (tab strip, tab cycle, tab-number shortcut) through the shared focus request that all browser pane flavors already claim on activation.
There was a problem hiding this comment.
ℹ️ Minor suggestion only — one blank-page rough edge. The fix is otherwise well-targeted and well-tested.
Reviewed changes
- New
requestBrowserWorkspaceTabPageFocusinsrc/renderer/src/lib/browser-workspace-tab-activation.ts: resolves the workspace'sactivePageIdfrombrowserTabsByWorktreeand issues the durablerequestBrowserFocus({ pageId, target: 'webview' })queue entry. - Tab-strip click (
useTabGroupActivationCommands.tsactivateBrowser) calls it after activating. - Cmd/Ctrl+number (
tab-number-shortcuts.tsactivateTabNumberShortcutbrowser branch) calls it. - Ctrl+Tab cycling / recent-tab switcher (
ipc-tab-switch.tsactivateCyclableTabbrowser branch, shared byhandleSwitchTab,handleSwitchTabAcrossAllTypes,handleSwitchRecentTab) calls it. - Tests: three routes each assert the queued request (
consumeBrowserFocusRequest→'webview', or mockedrequestBrowserFocusargs). I traced each assertion against the behavior it pins — all three would fail with the source change reverted.
I verified the mechanics end to end: all three pane flavors call useBrowserPageChromeFocus, which consumes the pageId-keyed queue on mount/isActive change and on the live ORCA_BROWSER_FOCUS_REQUEST_EVENT, so one request reaches whichever pane renders the page; next.id/target.entityId are the browser workspace entity id in every route; and the 30s TTL covers a pane that mounts a frame later. No correctness, security, or cross-platform concerns.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Warning Review limit reachedNext included review available in 46 seconds. View limit detailsLimit details: You’ve used all 10 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe change adds browser page focus requests to direct browser activation, browser tab cycling, and number-shortcut activation. The helper targets the address bar for blank pages and the webview for other pages. Guest-focus requests retry while the guest is unavailable, and cancellation stops retries when focus changes or the pane deactivates. Tests cover activation focus requests and guest-focus retries. Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🟡 Moderate · up to In a narrow timing window, the page can take keyboard focus back after the user focuses the address bar. Cancel that retry before merging. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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 |
…vation A blank page has nothing to receive keys, so re-activating one now requests address-bar focus, matching the palette path (isBlankBrowserUrl -> New Tab) and the new-tab address-bar grab. Non-blank tabs still hand focus to the page.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Blank tabs now land in the address bar —
requestBrowserWorkspaceTabPageFocusreads the workspace's mirroredurland pickstarget: 'address-bar'viaisBlankBrowserUrl, falling back towebviewfor real URLs. This resolves the prior review's one inline suggestion and aligns re-activation withactivateBrowserPagePaletteResultand the new-tabpendingAddressBarFocusByPageIdpath. - Regression test for the blank case —
useTabGroupWorkspaceModel.focus.test.tsadds a blank-tab case assertingrequestBrowserFocus({ pageId, target: 'address-bar' }); it would fail with the old hardcoded'webview'. Fixtures in the same file and inipc-tab-switch.test.ts/tab-number-shortcuts.test.tsgained theurlfield the helper now reads.
I verified the new branch against the panes that consume the request: the queue is keyed by page id and only useBrowserPageChromeFocus consumes it, so local, client-hosted and streamed URL pages get the address bar / guest they expect. A workspace-doc page also carries a blank url by design, but it renders WorkspaceDocPagePane, which registers no chrome-focus consumer — the request is a no-op there exactly as before, so no regression.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Merged upstream
mainand adapted the branch to its newsetActiveTabType(type, worktreeId)signature — the three browser activation routes now passworktreeId(the hook's worktree,target.worktreeId, andstore.activeWorktreeIdrespectively) instead of the old one-arg call, and the three test assertions were updated to match. Each passes the correct worktree, and upstream's contract (set the globalactiveTabTypeonly for the active worktree, always recordactiveTabTypeByWorktree) holds at all three sites. - Upstream test rename carried in by the merge in
useTabGroupWorkspaceModel.focus.test.ts(closes the durable native owner…→routes durable native owner close through the unified tab action) — unrelated to this PR's behavior.
The prior blank-page focus-target suggestion remains resolved and its regression test is intact. I re-ran the three changed renderer suites (40 tests) and pnpm run typecheck:web — both green — and confirmed the merge left no conflict markers. No new correctness, security, or cross-platform concerns.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 Minor · Retry the webview focus request until the guest… · browser-workspace-tab-activation.ts:80-83
src/renderer/src/lib/browser-workspace-tab-activation.ts:80-83
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winRetry the webview focus request until the guest attaches.
When
browser-workspace-tab-activation.tsactivates an already-mounted page, its focus hook consumes thewebviewrequest immediately. If the guest is not attached,focusGuestNow()returnsfalse, but the live event handler does not retry. Guest attachment does not re-emit or re-consume the request, so the page can remain unfocused. Use the same bounded retry handoff as the mount path.Suggested fix
- cancelAddressBarFocusGrab() - focusGuestNow() + cancelAddressBarFocusGrab() + let attempts = 0 + const runFocus = (): void => { + attempts += 1 + if (!focusGuestNow() && attempts < ADDRESS_BAR_FOCUS_FRAMES) { + window.requestAnimationFrame(runFocus) + } + } + window.requestAnimationFrame(runFocus)
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 20b944e8-25f1-453e-945b-c5ce9e95199e
📒 Files selected for processing (5)
src/renderer/src/components/tab-group/useTabGroupActivationCommands.tssrc/renderer/src/components/tab-group/useTabGroupWorkspaceModel.focus.test.tssrc/renderer/src/hooks/ipc-tab-switch.test.tssrc/renderer/src/hooks/ipc-tab-switch.tssrc/renderer/src/lib/tab-number-shortcuts.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.
…till attaching A focus request consumed by an already-active page's live listener tried the guest once, so a guest still attaching lost it. Share the mount path's bounded frame retry, cancelled on deactivation or when a newer request takes over.
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: c74fe062-b8c6-40c7-b7d9-fadecc31a12e
📒 Files selected for processing (2)
src/renderer/src/components/browser-pane/assemble-chrome/use-browser-page-chrome-focus.test.tsxsrc/renderer/src/components/browser-pane/assemble-chrome/use-browser-page-chrome-focus.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Guest-attach retry for an already-active page — the live
ORCA_BROWSER_FOCUS_REQUEST_EVENThandler previously made a singlefocusGuestNow()attempt, so a webview request consumed while the guest was still attaching was lost. The mount-path retry is now extracted into a sharedstartGuestFocusRetry(deferFirstAttempt)and called from both that handler (false, immediate first try) and the mount/isActivequeue-claim path (true, deferred a frame), retrying up toADDRESS_BAR_FOCUS_FRAMES. This resolves CodeRabbit's outside-diff suggestion. - Mutual grab cancellation —
startGuestFocusRetrynow cancels any in-flight address-bar grab andstartAddressBarFocusGrabcancels an in-flight guest retry, so neither spends its remaining frames pulling focus off the surface the other just aimed at. The retry canceller is parked inguestFocusRetryRef, so the listener effect's cleanup drops an in-flight retry when the pane goes inactive. - Regression tests —
use-browser-page-chrome-focus.test.tsxadds a case where an already-active pane's guest attaches a frame after the request (fails without the retry) and a case where an in-flight retry is dropped on deactivation. I confirmed the latter fails when the cleanup'scancelGuestFocusRetry()is removed, so it exercises the cancellation rather than passing vacuously. Re-ran the suite: 26 tests green.
The retry is render-stable: guestFocus is memoized on refs in all three panes, so startGuestFocusRetry/startAddressBarFocusGrab don't change identity per render and the effect doesn't tear down a retry mid-flight. No new correctness, security, or cross-platform concerns.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- The address bar now beats a pending guest retry —
focusAddressBarNowcallscancelGuestFocusRetry()before blurring the guest and focusing the input, andstartAddressBarFocusGrabcancels a guest retry on entry. Previously a webview request consumed while the guest was still attaching scheduled a retry that pulled focus back to the guest the moment it attached, even after Cmd/Ctrl+L or the forwarded IPC had taken the bar. - Guest retry extracted into
startGuestFocusRetry(deferFirstAttempt)— the mount/queue-claim path passestrue(deferred a frame) and the liveORCA_BROWSER_FOCUS_REQUEST_EVENThandler passesfalse(immediate first try); the canceller is parked inguestFocusRetryRef, so the listener-effect cleanup still drops an in-flight retry when the pane goes inactive. - Regression test for both bar paths —
use-browser-page-chrome-focus.test.tsxadds anit.eachover the chord and IPC that holds the bar against a guest attaching a frame later. I confirmed both cases fail withcancelGuestFocusRetry()removed fromfocusAddressBarNow(2 failed / 26 passed) and pass with it restored (28 passed).
I verified the new cancellation is symmetric with the existing grab cancellation, so neither retry can outlive the surface the other just aimed at, and re-ran pnpm run typecheck:web (green). Prior feedback remains addressed; no correctness, security, or cross-platform concerns.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Thanks for digging into the activation asymmetry, @mmarabel! This is already fixed on main by #31859 (1b0e56e), which also closed #20533. The once-per-activation guest focus that only the client-hosted pane used to have now lives in the shared If switching to a browser tab still leaves your typing in the previous terminal on the latest build, please comment or reopen and we'll take another look. |

ELI5
Switching tabs with the mouse or the keyboard handed the keyboard to a terminal tab, but not to a browser tab. Clicking a browser tab switched what you were looking at, yet your typing still went to whatever had focus before — usually the terminal you came from — so the page only became usable after clicking inside it. Activating a browser tab now hands it the keyboard the same way activating a terminal tab does.
What Changed
Browser tab activation now requests page focus on all three activation routes:
src/renderer/src/lib/browser-workspace-tab-activation.ts— newrequestBrowserWorkspaceTabPageFocus(worktreeId, workspaceId). It resolves the workspace tab's currentactivePageIdfrom the store and issues the existing queued requestrequestBrowserFocus({ pageId, target: 'webview' })fromcomponents/browser-pane/host-guest/browser-focus.ts.src/renderer/src/components/tab-group/useTabGroupActivationCommands.ts—activateBrowser(tab-strip click) calls it after activating.src/renderer/src/lib/tab-number-shortcuts.ts—activateTabNumberShortcutbrowser branch (Cmd/Ctrl+number) calls it.src/renderer/src/hooks/ipc-tab-switch.ts—activateCyclableTabbrowser branch (Ctrl+Tab cycling, Ctrl+Shift+[ / ], recent-tab switcher) calls it.The three call sites are one line each; no other behavior changed.
Why
activateTerminalends by callingfocusTerminalTabSurface(...), but every browser activation path only wrote store state. The local pane and the streamed remote pane had noisActive→ guest focus effect at all; only the client-hosted pane did (use-client-hosted-guest-activation-focus.ts), which is the asymmetry the issue reports.Routing through the shared focus request rather than adding a pane-level effect:
use-browser-page-chrome-focus.ts(local<webview>, client-hosted<webview>, streamed element guest), so one request reaches whichever pane renders the page.tab-bar/open-tab-selection-routing.ts), so this makes tab activation consistent with it instead of introducing a second mechanism.isActiveeffect is deliberately kept: it also covers activation routes that never enqueue a request (e.g. worktree switches), and its drag gate is what protects tab-drag previews.Tab-drag preview activation (
tab-drag-preview-activation.ts) writes store state directly and never goes through these commands, so no focus request fires mid-drag. Creating a new blank tab goes through the store'spendingAddressBarFocusByPageIdpath, not these commands, so a new tab still lands in the address bar.Linked Issue
Fixes #20533
Visual Proof
N/A— no visual change. The fix only moves keyboard focus into the page on activation; rendered pixels are identical before and after. The behavior is covered by the unit tests below rather than screenshots.Testing
Automated (Linux, headless):
pnpm tc→ exit 0.pnpm test src/renderer/src/components/tab-group/useTabGroupWorkspaceModel.focus.test.ts src/renderer/src/lib/tab-number-shortcuts.test.ts src/renderer/src/hooks/ipc-tab-switch.test.ts src/renderer/src/components/browser-pane/assemble-chrome/use-browser-page-chrome-focus.test.tsx→ 4 files, 60 tests passed. The last file is the existing negative control: a pane still takes page focus only from a queued/announced request.pnpm test src/renderer/src/components/browser-pane/ src/renderer/src/components/tab-bar/→ 167 files, 1340 tests passed.ORCA_CODE_QUALITY_BASE=60d793956af91d16070d852567d7d82718aaf0db pnpm run check:code-quality:changed→ pass, 0 findings in all six scanners.Regression tests added (one per activation route):
useTabGroupWorkspaceModel.focus.test.ts— tab activation queues a webview focus request for the tab's active page.tab-number-shortcuts.test.ts— the number shortcut does the same.ipc-tab-switch.test.ts— the existing browser-cycle test now also asserts the focus request.All three tests were confirmed to fail with the source change stashed and pass with it applied.
Not tested: no macOS/Windows device run. The report is macOS-specific; the unit proof is platform-independent, but a smoke check on macOS of tab-strip click, Ctrl+Tab and Cmd+number into an already-open browser tab is worthwhile before merge.
AI Disclosure
AI-assisted: opencode-go / deepseek-flash (Pi coding agent, reasoning effort max). The change, tests and results were reviewed and run locally by the contributor before submission.
Review
metaKey/accelerator additions. The shortcuts keep using the existing keybinding layer, so Mac and non-Mac chords are unaffected.Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
tab switch --focusbridge were left as they are.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred) — ranpnpm tc, the targeted vitest suites above andcheck:code-quality:changedlocally; the full suites/build are left to CI.