Repository navigation
Host: no close takes a window's last tab with it (#148) - #150
Merged
Merged
Conversation
Chrome closes a window with its last tab and unloads a profile left with no window, which ends the cua extension and its host: the next session found the profile host_not_live. Every close the host makes or relays (turn end, the create-then-ended cleanups, the agent's Target.closeTarget of a tab's page and Page.close) first opens a New Tab page, inactive, ungrouped and owned by no session, in a normal window whose every other tab is closing too. Checks run one at a time and a tab counts as closing until Chrome reports it removed, so a turn's end closing all of a window's tabs opens one New Tab page. MAWS peers are left alone. The previous host's log is kept as <name>.prev.log, so the next unexplained host_not_live leaves a record of how that host ended. The Chrome fakes now close a window with its last tab, as Chrome does. Plugin 0.12.1.
- A tab whose close succeeded, or that Chrome reported removed, stays going until a check's own tabs.query no longer lists it, so a check holding a list taken before the removal still opens the New Tab page. - Close attempts are counted per tab: a failed one withdraws only itself. - Each window check is bounded at KEEP_WAIT_MS (2 s); past it the close goes ahead, logged, and later closes are not held up. - executeCdp marks itself late at its timeout; a close still behind its preflight is then refused, never dispatched. - A Page.close whose beforeunload is refused keeps its tab going while it lives: accepted, recorded in the comment and the Decision Log entry. The fake extension gains a primitive hold/release for the interleavings.
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.
Closes #148.
What changes
Chrome closes a window together with its last tab, and once a profile has no window left Chrome unloads it, which stops the cua extension and its host. The next session then finds the profile
host_not_live; this happened to the mini'sssfsprofile four times during #116. With this change, every close the host makes or relays checks the tab's window first. If the tab is the last one in a normal window, the host opens a New Tab page there before the close goes through. The New Tab page is inactive and ungrouped, and no session owns it. Four closes are covered:end_task, case end, client disconnect);createTabandtabs.popup;tab.close(), which the service sends asTarget.closeTargetof the tab's page target;Page.closeon a tab's debuggee.Popup windows still close with their last tab. MAWS peers are left alone, because their windows belong to the app.
A turn's end closes all of a window's tabs at once, and it still opens exactly one New Tab page. Three rules make that hold, and they come from review round 1:
A close that executeCdp has already timed out on is never sent afterwards. If a page's beforeunload refuses a
Page.close, the tab stays counted as going. That costs at most one New Tab page the window didn't need, and treating the tab as staying could lose the window.The host also keeps the previous host's log as
<name>.prev.log. In the second, unexplained loss on the mini, the next host's log overwrote the record of how its predecessor ended. The launcher log there shows no reconnect attempt for 55 minutes. That fits a profile Chrome had unloaded because it had no window. It does not fit an extension that lost its port while the profile stayed loaded, since that extension would have retried every 5 s.Why the host and not the extension (the ticket's first sketch)
tab.close()reaches Chrome asdebugger.sendCommand Target.closeTarget, so the extension'stabs.removehandler never sees it.windows.create's url "Defaults to the New Tab Page"). The check therefore never fires for such a window.Decision Log:
docs/doperpowers/specs/2026-10-07-own-chrome-extension-design.md, 2026-10-16. README updated. Plugin 0.12.1.Tests
test/chrome-host.test.mjs: last tab → New Tab first, ungrouped, nobody's; a tab with siblings and a popup window's last tab close as before;Target.closeTargetandPage.closeare guarded; three tabs closing together → one New Tab; MAWS peer unguarded.test/extension-host.test.mjs: the real extension and the real host process in the Chrome stub; a turn ending in a window holding only its tabs leaves the window open.test/chrome-host-run.test.mjs: a second host keeps the first one's log as<name>.prev.log.Review round 1 added four deterministic interleaving tests (removal during another check, overlapping attempts, a check that never answers, a timed-out close). Without the host changes, 10 of the new and updated tests fail; with them, the 259 tests across the 16 test files that use the host or the Chrome fakes all pass locally. CI is the gate.
Live, before the fix (mini,
ssfs, 2026-10-17 04:38Z)Starting from no window in the profile, the runner opened its own loopback page as the profile's only window. A backend client of the host (standing in for the service) created a tab, claimed the page and closed it with
Target.closeTarget, then ended the turn. The unfixed host closed the agent's tab, Chrome closed the window, and the host's port closed in the same millisecond.profiles listthen reportedssfshost_not_live.Not covered here
The live check on the mini's
ssfsprofile (end_task in a window holding only agent tabs, thenprofiles liststill ready) runs after merge, once the mini's resident checkout is updated and its host restarted.