Repository navigation
Restore previously-active tab when closing a browser tab - #16306
Merged
AmethystLiang merged 2 commits intoAug 24, 2026
Merged
AmethystLiang merged 2 commits into
AmethystLiang merged 2 commits into
Conversation
Closing a browser tab now activates the most-recently-used (MRU) tab instead of the visual neighbor. This provides more predictable navigation behavior when switching between tabs.
Contributor
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughBrowser tab closure now validates the remaining target and updates the browser bridge before webview destruction. Terminal, floating-terminal, and tab-group close paths now close browser tabs before destroying workspace webviews. Tests cover unified MRU selection, last-browser-tab fallback, inactive worktrees, legacy browser tabs, active-page notification, and mixed content types. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 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 |
When closing a browser tab, announce the MRU page selection before guest teardown to prevent fallback to registration order. Reorder closeBrowserTab() before destroyWorkspaceWebviews() consistently across all close-tab handlers.
Jinwoo-H
added a commit
that referenced
this pull request
Aug 25, 2026
Main's module-split refactors moved most of the conflicted code out from under
this branch, so several edits had to be relocated rather than merged in place.
Conflicts and how each was resolved:
.github/workflows/pr.yml
Main replaced the inline shell spec routing with config/scripts/pr-e2e-source-routing.mjs.
Ported both client-hosted-browser routes into that script as
client-hosted-browser.host-strip and client-hosted-browser.restart-survival, and rewired
pr-e2e-gate-contract.test.mjs to read the restart-survival route from PR_E2E_SOURCE_ROUTES
instead of scraping the workflow shell that no longer exists. Windows boundary test list is
a union of both sides.
src/main/global-fetch-call-site-audit.test.ts
Union, minus a stale entry: main moved the audited fetch out of opencode/hook-service.ts into
status-plugin-post-source.ts, so main's replacement wins and our browser-route entries stay.
src/main/persistence/loading-store/store.ts
Took main's file wholesale. Our only delta was the runtime-authored guard, which relocated to
main's new chokepoints: preserveRuntimeAuthoredWorkspaceSessionFields now runs at the top of
setLocalWorkspaceSession (loading-store/workspace-session-snapshot-publication.ts) and
setHostWorkspaceSession (loading-store/session-host-partitions.ts). Censused every writer of
state.workspaceSession / workspaceSessionsByHostId on both sides: the guarded and unguarded
sets match pre-split coverage, and stageWorkspaceSessionBeforeUnload still inherits it.
src/main/persistence/restoring-sessions/session-owner-fields.ts
Kept the census-driven delete loop and main's new host-identity-aware scan for
lastVisitedAtByWorktreeId. That field is now excluded from the plain loop alongside
terminalTopologyRevisionByRepoId, since it also carries `${executionHostId}|${worktreeId}`
keys that indexing by owner key would miss. Updated the pinned census list and added explicit
coverage for the bare-vs-host-qualified delete that left the it.each loop.
src/main/runtime/orca-runtime.ts
Import-block conflict only; merged main's widened runtime-browser-commands-factory import with
ours. Verified all 495 added lines from this branch survived the body auto-merge, including
persistClientHostedBrowserPages, rehydrateClientHostedBrowserPages, the boolean-returning
retireRuntimeOwnedBrowserSessionTab, and the ghost-row retirement ordering.
src/main/window/createMainWindow.ts
Main split this into main-window-*-lifecycle modules. The browser-host-id argv stamp stays with
the BrowserWindow construction; the will-attach-webview partition allowlist and did-attach-webview
guest policies moved to main-window-webview-security.ts; registerRendererDocumentNavigation and
the client-page attach/retire wiring moved to main-window-focus-lifecycle.ts. The privileged
navigation policy and plugin panel guard stayed in main's module: neither ordering this branch
established is load-bearing (the guard only handles subframes, the fence reads defaultPrevented
in a microtask). createMainWindow.test.ts now records every handler per event instead of the
last one, because two modules register will-navigate on the same webContents.
src/main/wsl/__fixtures__/wsl-invocation-allowlist.txt
Union, minus a stale entry: main moved the wsl.exe invocation out of claude-accounts/service.ts
into claude-command-process.ts.
src/renderer/src/components/Terminal.tsx
Combined main's #16306 MRU close with our plan-driven close options: closeBrowserTab now runs
before destroyWorkspaceWebviews at all three sites and keeps the plan's reason, main's
hasUnifiedEntry guard is kept, and the visual-neighbor selection main deleted stays deleted
because closeBrowserTab picks the MRU target itself. All browser-guest-paint-retention helpers
remain wired at their sites.
src/renderer/src/components/tab-group/useTabGroupTabCloseCommands.ts
Kept our closeBrowserItem plan helper and carried main's #16306 ordering into it. Applied the
same flip in runtime/browser-workspace-tab-close.ts, a close-tab handler this branch added
after main's commit and which main could not reach.
src/renderer/src/hooks/useIpcEvents.ts
Main reduced this to a shim over ipc-events/app-lifetime-ipc-bridge. Relocated all five edits:
the client-hosted certificate-failure carve-out to ipc-events/browser-state-ipc-bridge.ts, the
paired-device create comment to browser-request-ipc-bridge.ts, the plan-routed menu close to
tab-lifecycle-ipc-bridge.ts, and the browser-remote-viewer plus client-hosted-row channels and
their hydration to mobile-driver-ipc-bridge.ts. Added both channels to main's new
useIpcEvents-lifecycle.test.ts callback census.
src/renderer/src/web/web-preload-api.ts
Main split this into web/preload-api/*. Relocated the web-client no-op stubs into
web-runtime-api.ts, web-runtime-environments-api.ts, and web-browser-api.ts.
Integration fixes outside the conflicts: main's new orcad test fixtures and
external-chromium-tab-registry.ts predate this branch's RuntimeBrowserCommandHost members and
BrowserSessionTabSelectionOptions, so the fixtures gained the four registry accessors and the
external-Chromium create now passes an options object with focusesHost: true, preserving the
always-steer behavior that call had before create learned to stay local.
The renderer close-site census in runtime/browser-workspace-tab-close-census.test.ts was
repointed at the three ipc-events modules that now hold useIpcEvents.ts's seven closeBrowserTab
mentions (tab-lifecycle 2 plan-routed, browser-request 3 and session-tab 2 host-requested).
No wire changes: no RPC params or stream frames were touched by any conflict.
paidaxingyo666
pushed a commit
to paidaxingyo666/Manta
that referenced
this pull request
Aug 25, 2026
) * Restore previously-active tab when closing a browser tab Closing a browser tab now activates the most-recently-used (MRU) tab instead of the visual neighbor. This provides more predictable navigation behavior when switching between tabs. * Restore previously-active tab when closing a browser tab When closing a browser tab, announce the MRU page selection before guest teardown to prevent fallback to registration order. Reorder closeBrowserTab() before destroyWorkspaceWebviews() consistently across all close-tab handlers. (cherry picked from commit 0c4dd2b)
dallascrilley
pushed a commit
to dallascrilley/orca
that referenced
this pull request
Aug 27, 2026
) * Restore previously-active tab when closing a browser tab Closing a browser tab now activates the most-recently-used (MRU) tab instead of the visual neighbor. This provides more predictable navigation behavior when switching between tabs. * Restore previously-active tab when closing a browser tab When closing a browser tab, announce the MRU page selection before guest teardown to prevent fallback to registration order. Reorder closeBrowserTab() before destroyWorkspaceWebviews() consistently across all close-tab handlers.
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
) * Restore previously-active tab when closing a browser tab Closing a browser tab now activates the most-recently-used (MRU) tab instead of the visual neighbor. This provides more predictable navigation behavior when switching between tabs. * Restore previously-active tab when closing a browser tab When closing a browser tab, announce the MRU page selection before guest teardown to prevent fallback to registration order. Reorder closeBrowserTab() before destroyWorkspaceWebviews() consistently across all close-tab handlers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When closing a browser tab, Orca switches to the next tab in visual order (right neighbor, or left if none). This ignores user context — they want to return to what they were working on before, not just the adjacent tab.
Solution
Changed tab-close behavior to restore the previously-active (MRU) tab instead of picking a visual neighbor. This respects the actual usage pattern and works across content types (browser, terminal, editor tabs tracked together in the unified system).
What Changed
browser.ts: Improved next-tab selection when closing a browser tab. Uses
pickNeighbor()to find a candidate, but validates it still exists; falls back to the first remaining tab. Fixed globalactiveBrowserTabIdto use the pre-computed worktree-specific selection instead of recalculating.Terminal.tsx: Removed the inline tab-switching logic that was picking neighbors. Moved responsibility to the store via MRU tracking. When closing the last browser tab in a worktree, checks if it's wrapped in the unified tab system before falling back to a file tab.
Tests: Added 4 new tests for MRU restoration:
Updated existing test to verify MRU works across content types (terminal → browser → editor), not just visual neighbors.
Visual Proof
N/A — interaction change verified by unit tests. Manual verification: open 3+ browser tabs, activate tab A, activate tab B, close tab B → should return to tab A (not the visual neighbor).
Testing
Cross-platform Impact
No platform-specific behavior added. Logic is generic tab management, applicable to macOS, Linux, Windows, and SSH.
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)