Repository navigation
Conversation
The guest preload turned window.close() into a no-op so a page could never destroy its own guest (stablyai#11910, stablyai#12040). It now hands the call to the host page instead, and the renderer closes the page through the same path as the tab's close button, so the native close still never runs. Like Chrome, a page can only close a tab that holds a single history entry, and pinned tabs stay open. Fixes stablyai#26939
Contributor
Contributor
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
e3af88a2-97ef-4ea6-bee9-3142a0decb1b
📒 Files selected for processing (9)
src/preload/browser-window-close-installation.tssrc/preload/browser-window-close.test.tssrc/preload/browser-window-close.tssrc/renderer/src/components/browser-pane/host-guest/browser-page-webview.test.tssrc/renderer/src/components/browser-pane/host-guest/browser-page-webview.tssrc/renderer/src/lib/browser-page-guest-close.test.tssrc/renderer/src/lib/browser-page-guest-close.tssrc/shared/browser-guest-window-close.tstests/e2e/browser-window-close.spec.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
…-close-closes-tab # Conflicts: # src/renderer/src/components/browser-pane/host-guest/browser-page-webview.ts
8 of 9 tasks
Contributor
Author
|
Closing since #31844 shipped window.close() support, including the opened-by-page case I left out here. Thanks @AmoabaKelvin. |
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.
ELI5
Some pages close themselves when they are done: "you can close this window" login pages, review tools like Plannotator, confirm pages. In Orca's browser that does nothing today, so these tabs pile up. With this change, when a page calls
window.close(), Orca closes that tab for it, the same as clicking the tab's ×.What Changed
window.closewith a function that does nothing. That guard came from fix(browser): prevent window.close guest crashes #11910 and fix(browser): remove unsafe window close bypass #12040: the native close destroyed the guest under Orca, which crashed main or left a dead tab. So today the call is silently dropped.window.close, so the native close still never runs. Instead of doing nothing, the replacement sends one message to the Orca window withipcRenderer.sendToHost. The renderer hears it on the<webview>(ipc-message) and closes the page through the normal close path:closeBrowserPage);closeWorkspaceBrowserTab, the same call the × button makes, so webview cleanup and reopen-closed-tab work the same way.window.openis re-created as a fresh tab. Pinned tabs stay open, and a page never raises the pin confirm dialog. Pages served by a remote runtime are left alone, the same as the open-link handler does.Why
The issue asks whether the blocked close can be routed into Orca's own tab close without undoing the guard. This does exactly that. The page only asks; Orca does the closing.
Alternatives I looked at:
closeevent: it never fires, because the guard replaceswindow.closebefore page scripts run. Removing the guard to get that event back would bring back [Bug]: Main-process SIGSEGV after window.close() in a link-opened embedded browser tab #11763.The function I pass into the page world is proxied by
contextBridge, so the page gets no new global and noipcRenderer. It can only trigger the same close it could already ask for.One gap, on purpose: in Chrome, a tab opened by
window.openmay close itself even after it navigates. Orca doesn't record which tabs a script opened, so such a tab closes here only while it is still on its first entry. I can follow up if maintainers want that.Linked Issue
Fixes #26939
Visual Proof
Both screenshots come from the new e2e spec, which runs the real app in the background. The terminal area is masked.
window.close(). Onmainthe window still looks like this after the call; the first e2e case fails there for exactly that reason.Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
New e2e
tests/e2e/browser-window-close.spec.ts, running the real app in the background. It has two cases:window.close()removes its tab from both the browser store and the tab strip;I ran the e2e spec against
mainwith only the spec added: the first case fails there, because the tab stays open.Unit tests:
closeBrowserPageFromGuest: last page, sibling page, pinned, remote runtime, and missing page;I loaded the built
out/main/browser-window-close-preload.jsinto a hidden Electron 43.7.5 webview. A fresh page reaches the host'sipc-message, a navigated page does not, and neither fires the nativecloseordestroyed.I checked that the built preload is still one standalone file with no shared chunk, since sandboxed preloads can't load chunks.
pnpm typecheck,electron-vite build,oxlint/oxfmtandpnpm run check:code-quality:changedpass. I ran the neighboring browser, window and preload suites rather than the wholepnpm test. The only failures werebrowser-manager-tab-identityandbrowser-manager-viewport-ownership, which fail the same way onmainon my machine. Tested on macOS.AI Disclosure
I used Claude Code (Claude Opus 5.5) to help me trace the old
window.closeguard and the tab close paths, and to draft the change and tests. I checked the design against Electron 43 myself with the probe above, ran the tests, and reviewed every line.Review
My review of the change, with the agent's help:
sendToHostand webviewipc-messagebehave the same on macOS, Linux and Windows.window.close().Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Mobile and paired clients are unchanged: the remote-runtime webview path is not touched.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)