CLI: no way to stop a single managed browser without killing the daemon

Author: johan44coCreated May 12, 2026Updated May 12, 2026

Summary

dev-browser stop kills the daemon and every browser it manages. There's no CLI command to stop just one browser by name, so any workflow that uses unique --browser names (e.g. timestamped names for test isolation) leaks an instance per run — they pile up forever in dev-browser browsers.

Reproduce

bash
# Run a script with a unique browser name N times
for i in 1 2 3; do
  dev-browser --browser smoke-$i <<'JS'
  const page = await browser.getPage("main");
  await page.goto("https://example.com");
JS
done

# Three browser processes now linger forever
dev-browser browsers
# NAME      TYPE      STATUS   PAGES
# smoke-1   launched  running  main
# smoke-2   launched  running  main
# smoke-3   launched  running  main

# Only option to clean them up:
dev-browser stop   # kills the daemon and ALL browsers, disrupting other workflows

The fix is mostly already there

The daemon already implements this — the wiring just stops at the CLI:

  • daemon/src/protocol.ts — BrowserStopRequestSchema ({type: "browser-stop", browser: <name>}) is defined and registered in the request union.
  • daemon/src/daemon.ts — case "browser-stop": handler calls manager.stopBrowser(request.browser) and returns {stopped: true}.
  • daemon/src/browser-manager.ts — stopBrowser(name) removes the entry, clears its pages, and closes the browser (idempotent on unknown names).
  • cli/src/main.rs — no subcommand sends this message.

Proposed CLI shape

Extend Command::Stop with an optional positional NAME:

dev-browser stop          # current daemon-wide behavior (unchanged)
dev-browser stop <name>   # send `browser-stop` for that name; daemon stays up

Backward-compatible — no flag change to the existing default.

Happy to send a PR (~25 lines of Rust); will reference this issue.