Repository navigation
Conversation
…it ends The server that launches the agent browser records itself as owner in ~/.clawdcursor/agent-browser.json and closes the browser (CDP Browser.close, bounded to 2 s) in the shared exit routine. A server that only connected owns nothing. At start, in the background, a record whose owner is gone (dead pid, or a reused pid with another start time) gets its browser closed, but only if the browser's command line shows the clawdcursor cdp-profile. The test fence blocks closing as it blocks launching. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Chromium answers Browser.getBrowserCommandLine only when started with --enable-automation, which the agent browser is not, so the start-up sweep never closed anything. The launch record now holds the spawned browser's pid and start time; the sweep closes only a browser whose pid is alive with that start time. A gone or reused pid is not closed and the record is dropped. The owner's shutdown close is bounded to 2 s in total. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
What
The agent's browser (its own
~/.clawdcursor/cdp-profileinstance on the agent CDP port, never the user's browser) now closes when the session that opened it ends. A later clawdcursor start also closes one whose session ended without a clean shutdown.Why
cdp-driver.tsspawns the agent browserdetached+unref()so that it survives the server, and nothing ever closed it.How
New
src/platform/agent-browser-life.ts:~/.clawdcursor/agent-browser.json, containing{ownerPid, ownerStarted, port, browserPid, browserStarted}. It uses temp + rename. A server that only connects to a running agent browser owns nothing.exitRoutineinserve.ts(SIGINT, SIGTERM, stdin end/close/error, the parent-pid watchdog, HTTP/stop). The owner sends CDPBrowser.closeover its own connection, bounded to 2 s in total, then deletes the record.Browser.getBrowserCommandLine, which Chromium answers only with--enable-automation.On Windows, a host that terminates the server outright runs no handler. Then the next clawdcursor start cleans up.
Tests
src/__tests__/agent-browser-life.test.tshas 12 cases:typecheck, typecheck:tests, lint (0 errors, the 3 warnings as on main),
npm run test:ci: 4309 passed, 80 skipped, 0 failed.Note for #482 (playwright-core): the new file imports
chromiumfromplaywrightlikecdp-driver.ts, so whichever merges second updates that import.No release: for the 2.4 train.
🤖 Generated with Claude Code