Skip to content

Make agent-browser launches eager and load-independent - #537

Merged
nedtwigg merged 12 commits into
mainfrom
agent-browser
Sep 3, 2026
Merged

Make agent-browser launches eager and load-independent#537
nedtwigg merged 12 commits into
mainfrom
agent-browser

Conversation

@nedtwigg

@nedtwigg nedtwigg commented Sep 3, 2026

Copy link
Copy Markdown
Member

Summary

  • swap iframe surfaces eagerly while agent-browser boots, preserving minimized surfaces and rolling back failed launches
  • resolve browser launches as soon as the daemon and stream are live instead of waiting for page load
  • make pop-in/pop-out relaunches single-flight and reconnect only to the host-provided stream
  • track committed URL events, including oversized messages and same-URL reload title clearing

Verification

  • CI=true pnpm --filter dormouse-lib test
  • CI=true pnpm --filter dormouse-lib build
  • pnpm lint:specs

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 3, 2026

Copy link
Copy Markdown

Deploying mouseterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: a82c709
Status: ✅  Deploy successful!
Preview URL: https://22dce75a.mouseterm.pages.dev
Branch Preview URL: https://agent-browser.mouseterm.pages.dev

View logs

@dormouse-bot dormouse-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three findings, all inline. The eager-swap rollback paths in Wall.tsx (visible / minimized / killed) and the controller's new single-flight relaunch guard all check out against the tests; the first finding is that the host has no equivalent guard now that relaunch returns before open does.

Comment thread lib/src/host/agent-browser-host.ts Outdated
Comment thread lib/src/host/agent-browser-host.ts Outdated
Comment thread lib/src/components/wall/agent-browser-surface-controller.ts

@dormouse-bot dormouse-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The three fixes check out against their tests — the generation guard covers the relaunch-supersedes-relaunch case the last review raised, the zero-exit message distinguishes the two wsPort === undefined outcomes, and the unconditional session arm reconciles at an already-live port. One finding inline: the generation is bumped only by popOut/popIn, so the other way a session's daemon gap opens — an explicit close from the webview — leaves the previous relaunch's sweep armed.

Minor, same guard: closeStrayBlankTabs's current parameter defaults to () => true, so a second call site opts out of the invalidation check by omitting an argument. Making it required would need binaryPath reordered (a required parameter can't follow an optional one), so it's your call whether it's worth the churn for a one-caller function.

Comment thread lib/src/host/agent-browser-host.ts

@dormouse-bot dormouse-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command('close') fix reads correctly — the delete is synchronous, ahead of the close spawn, so a sweep left by a fast-returning relaunch is invalidated before the close can queue behind open; and making current required closes the omit-the-argument hole. One finding inline: closePoppedOut is the third path that closes a session's browser without touching relaunchGenerations.

Comment thread lib/src/host/agent-browser-host.ts

@dormouse-bot dormouse-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

relaunchGenerations.clear() lands synchronously ahead of the close spawns, so every pending sweep's current() is already false when the shutdown close releases its open — and both hosts (deactivate() in vscode-ext/src/extension.ts, shutdown() in standalone/sidecar/main.js) call closePoppedOut only at teardown, so the blanket clear() can't cancel a sweep that still matters. The regression test drives exactly that release-on-second-close path. One finding inline, on the spec sentence rather than the code.

Comment thread docs/specs/dor-browser.md Outdated
@nedtwigg
nedtwigg merged commit fe4bc50 into main Sep 3, 2026
22 checks passed
@nedtwigg
nedtwigg deleted the agent-browser branch September 3, 2026 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants