Repository navigation
feat(browser): open links beside their pane, focus link tabs, honor window.close() - #31844
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🟡 Moderate · up to
|
b22107d to
45c8597
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
814e5b30-77f8-4066-a1c6-fc21f88f7afb
📥 Commits
Reviewing files that changed from the base of the PR and between 31bffb8 and 45c85977630183a92b0134dd6a3a14b8f99bd833.
📒 Files selected for processing: 42
src/preload/browser-window-close-installation.tssrc/preload/browser-window-close.test.tssrc/preload/browser-window-close.tssrc/renderer/src/components/browser-pane/assemble-chrome/browser-page-context-menu-items.tsxsrc/renderer/src/components/browser-pane/assemble-chrome/browser-page-guest-focus.tssrc/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.tssrc/renderer/src/components/browser-pane/browser-client-page-retained-elements.tssrc/renderer/src/components/browser-pane/browser-client-page-retained-registry.tssrc/renderer/src/components/browser-pane/host-guest/browser-page-webview.tssrc/renderer/src/components/browser-pane/host-guest/browser-page-window-close.test.tssrc/renderer/src/components/browser-pane/host-guest/browser-page-window-close.tssrc/renderer/src/components/settings/BrowserLinkRoutingBackgroundSetting.tsxsrc/renderer/src/components/settings/BrowserPane.search-catalog.test.tsxsrc/renderer/src/components/settings/BrowserPane.tsxsrc/renderer/src/components/settings/browser-link-routing-copy.tssrc/renderer/src/components/settings/browser-search.test.tssrc/renderer/src/components/settings/browser-search.tssrc/renderer/src/hooks/ipc-events/browser-state-ipc-bridge.tssrc/renderer/src/hooks/ipc-events/browser-state-open-link-profile.test.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/fr.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/pt.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/lib/browser-page-tab-opening.tssrc/renderer/src/lib/http-link-browser-placement.test.tssrc/renderer/src/lib/http-link-browser-placement.tssrc/renderer/src/lib/http-link-routing.test.tssrc/renderer/src/lib/http-link-routing.tssrc/renderer/src/lib/workspace-browser-tab-open.tssrc/renderer/src/main.tsxsrc/renderer/src/runtime/web-runtime-browser-client-target-group.tssrc/renderer/src/store/slices/editor/tabs/editor-open-target-group.tssrc/shared/browser-guest-window-close.tssrc/shared/browser-link-opening-settings.tssrc/shared/default-global-settings.tssrc/shared/global-settings-base.tssrc/shared/telemetry-property-schemas.tstests/e2e/ssh-orcad-terminal-browser-link.spec.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
45c8597 to
b9009b3
Compare
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 · Preserve the clicked pane while registering a localhost label. · http-link-routing.ts:213-214
src/renderer/src/lib/http-link-routing.ts:213-214
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winPreserve the clicked pane while registering a localhost label.
If the user clicks a link in pane A and selects pane B before registration completes, this callback reads the new active group.
openLocalHttpLinkTabcan then open the link beside pane B instead of pane A. Resolve the placement at click time and pass it through the registration callback.
🟡 Minor · Check user focus again when the guest attaches. · use-browser-page-chrome-focus.ts:231-233
src/renderer/src/components/browser-pane/assemble-chrome/use-browser-page-chrome-focus.ts:231-233
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winCheck user focus again when the guest attaches.
If the user focuses the address bar after one wait frame and the guest attaches before the next frame, this branch skips the focus-change check.
focusGuestNow()then takes focus from the address bar. Check whether focus moved before every guest-focus attempt, including the first frame with an attached guest.
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
4edf73da-f623-4f12-8093-35cadace5d5a
📥 Commits
Reviewing files that changed from the base of the PR and between 45c85977630183a92b0134dd6a3a14b8f99bd833 and b9009b3.
📒 Files selected for processing: 12
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.tssrc/renderer/src/components/editor/rich-markdown-editor-click-routing.test.tssrc/renderer/src/components/terminal-pane/terminal-link-action-routing.test.tssrc/renderer/src/components/terminal-pane/terminal-runtime-host-link-routing.test.tssrc/renderer/src/lib/http-link-browser-placement.tssrc/renderer/src/lib/http-link-modifier-routing.test.tssrc/renderer/src/lib/http-link-routing.test.tssrc/renderer/src/lib/http-link-routing.tssrc/renderer/src/lib/workspace-browser-tab-open.test.tssrc/renderer/src/lib/workspace-browser-tab-open.tssrc/renderer/src/store/index.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
b9009b3 to
e01320f
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
418a9f74-6a2c-4530-81b4-42558068a1f2
📥 Commits
Reviewing files that changed from the base of the PR and between b9009b3 and e01320f1ad9822b8fc46a8bb29d5f3ef55368db9.
📒 Files selected for processing: 16
src/preload/browser-window-close.tssrc/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.tssrc/renderer/src/components/settings/BrowserPane.tsxsrc/renderer/src/components/settings/browser-search.test.tssrc/renderer/src/components/settings/browser-search.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/fr.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/pt.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/lib/http-link-browser-placement.tssrc/renderer/src/lib/http-link-routing.tssrc/renderer/src/lib/workspace-browser-tab-open.ts
🚧 Files skipped from review as they are similar to previous changes: 7
- src/renderer/src/i18n/locales/pt.json
- src/renderer/src/i18n/locales/fr.json
- src/renderer/src/i18n/locales/en.json
- src/renderer/src/i18n/locales/zh.json
- src/renderer/src/i18n/locales/ko.json
- src/renderer/src/i18n/locales/es.json
- src/renderer/src/i18n/locales/ja.json
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
The client page renderer also runs in a bare Electron fixture, so the window.close handler is registered from main.tsx. The SSH link e2e prints a blank row after each URL now that links open beside the terminal and narrow it.
…itch An SSH page renders on this desktop, so the remote opener now returns its page id and the link path focuses it like a local link. A pending page focus is dropped when the user leaves the tab.
… focus on attach A labeled localhost link resolved its pane after an async lookup, so a click elsewhere moved it. The page-focus wait now yields to user focus in the frame the guest attaches too.
…vent A remote link's focus request can land after its pane mounted but before the guest attached; the event path tried once and lost it.
e01320f to
6d132ae
Compare
ELI5
Clicking a link in the terminal or an agent chat used to throw a browser tab over the thing you were looking at, even when a browser was already open next to it. Now the link opens in the browser you can see. If none is visible, it opens in a new pane beside the one you clicked in. New tabs opened from links get keyboard focus, so Cmd/Ctrl+W closes them. Sign-in pages that say "you can close this window" now close their own tab.
What Changed
Where links from Orca open (terminal, agent chat, markdown/editor preview, PR checks)
Tabs opened from a page (target=_blank, window.open)
window.close()<webview>and crashed main ([Bug]: Main-process SIGSEGV after window.close() in a link-opened embedded browser tab #11763, fix(browser): prevent window.close guest crashes #11910, fix(browser): remove unsafe window close bypass #12040).Why
Design
openHttpLinkis the single place every Orca-surface link goes through, so placement is decided there (http-link-browser-placement.ts) for both the local and the remote path. No caller changes.window.close()rule in the renderer. The renderer knows whether a page opened the tab, and the webview'scanGoBack/canGoForwardtell it the history length. The opened-by-page mark lives in memory only. The saved session schema drops unknown page fields, and Chrome also forgets openers after a restore.Ruled out
sourceTabIdto every link path. The active group already says where the click came from.Built on what users asked for in #22686, #13392, #31536, #10549, #18834 and #27194. None of those PRs is merged here; this branch rebuilds the behaviour.
Linked Issue
Fixes #13390
Fixes #31530
Fixes #18832
Fixes #26939
#7813: a link clicked in Agents View now switches to the workspace view so the tab is visible. That's covered by a unit test only; I couldn't get an agent terminal into Agents View in the scratch profile.
#10546: links no longer cover a live agent. Browser tabs that agents open from the CLI or automation already open in the background; this PR doesn't change them.
#16020 (new tabs next to the active tab) is left out. It changes tab order for every tab kind and is waiting on a maintainer decision.
Visual Proof
Recorded in a hidden dev build (macOS, light theme) by driving real terminal clicks and in-page clicks. Cmd+W is sent through the main-process key path.
A. Link from the terminal, no browser open
before-A-terminal-link.mp4
after-A-terminal-link.mp4
B. Link from the terminal, browser already visible on the right
before-B-visible-browser.mp4
after-B-visible-browser.mp4
E. "Open links in the background" on (no browser / browser visible): focus stays in the terminal
after-E-background-no-browser.mp4
after-E-background-visible-browser.mp4
C. target=_blank link in a page, then Cmd+W
before-C-target-blank.mp4
after-C-target-blank.mp4
Cmd+click still opens in the background (after): https://github.com/user-attachments/assets/41524bdf-c32b-4006-81a1-5c2505002cfa
D. A sign-in page that calls
window.close()1.5s after loadingbefore-D-window-close.mp4
after-D-window-close.mp4
New setting (light / dark)
Testing
Every flow above was run in a hidden dev build on macOS.
Focused tests: placement rule, background mode and Agents View in
openHttpLink, page-opened tab focus, focus waiting for a new tab's guest (fails on main), thewindow.close()rule (single entry, navigated, opened-by-page, pinned, multi-page), and the preload channel pin.Ran locally:
check:code-quality:changed,check:react-doctor:changed,tc:web,tc:node. CI covers the rest.Not tested live: SSH and paired-runtime workspaces (they go through the existing remote opener with the same placement fields), Windows and Linux (no platform-specific code here), and Agents View with a real agent.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Open questions for Kelvin
orca open-url($BROWSERon headless runtimes, used by CLI OAuth) is placed by the runtime's own publish path, so it doesn't follow this rule yet. Worth a follow-up?Narrower terminals and wrapped URLs. Opening links beside the terminal makes split panes more common. In CI the terminal came out exactly 36 columns wide, and
http://localhost:18080/echo/modifieris 36 characters. A URL that exactly fills a row gets the next row (the prompt) joined on as its continuation by #31713's edge-wrap detection. The SSH e2e now prints a blank row after each URL. The detection itself is unchanged here; whether it should also check xterm'sisWrappedis a question for #31713's owner.Sibling branches
use-browser-page-chrome-focus.tsandbrowser-page-guest-focus.tsare shared withbrowser-page-focus-and-navigation. The edits are limited to the page-focus request: wait for real guest attachment, then yield to the user.Mobile. Mobile only shows the host's screencast, so
window.close()and page-opened tabs follow the desktop host. Mobile has no splits, so placement doesn't apply. A mobile "open links in background" would need its own setting.Server-streamed pages (headless serve) have no close preload, so
window.close()there still tears down the offscreen window. Not changed here.Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platoform 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)