Skip to content

feat: stop a single browser by name - #108

Open
johan44co wants to merge 1 commit into
SawyerHood:mainfrom
johan44co:cli-stop-named-browser
Open

feat: stop a single browser by name#108
johan44co wants to merge 1 commit into
SawyerHood:mainfrom
johan44co:cli-stop-named-browser

Conversation

@johan44co

Copy link
Copy Markdown

Closes #107.

Summary

Adds an optional NAME positional argument to dev-browser stop:

dev-browser stop          # daemon-wide stop (unchanged)
dev-browser stop <name>   # stop just that browser, leave the daemon up

The daemon already implements browser-stop (protocol.ts, daemon.ts, browserManager.stopBrowser); this just exposes it on the CLI. Stopping an unknown name is a silent no-op, matching the daemon's idempotent behavior.

Why

Without this, any workflow that uses unique --browser names (e.g. timestamped names for test isolation) leaks an instance per run — there's no way to clean them up except dev-browser stop, which also kills every other browser. See #107 for a full reproducer.

Diff

Single file, ~25 lines of Rust:

  • Command::StopCommand::Stop { name: Option<String> }
  • Match arm branches on name:
    • None → existing {type: "stop"} flow (daemon kill)
    • Some(name) → new {type: "browser-stop", browser: name} flow
  • Help text updated to describe both modes.

No daemon changes. No new dependencies.

Verification

$ dev-browser browsers
NAME             TYPE      STATUS   PAGES
smoke-a          launched  running  login
smoke-b          launched  running  login
tabs-experiment  launched  running  page-a, page-b

$ dev-browser stop tabs-experiment
Stopped browser 'tabs-experiment'.

$ dev-browser browsers
NAME      TYPE      STATUS   PAGES
smoke-a   launched  running  login
smoke-b   launched  running  login

$ dev-browser stop unknown-name
Stopped browser 'unknown-name'.   # idempotent no-op, exit 0

$ dev-browser stop --help
Stop the daemon, or a single managed browser

Usage: dev-browser stop [NAME]

Arguments:
  [NAME]
          Optional name of a managed browser to stop. Without this, stops
          the daemon and all browsers.

Local CI checks pass: cargo fmt -- --check, cargo check, cargo build.

I left CHANGELOG.md alone since the maintainer manages versioning/release entries — happy to add an entry under an Unreleased heading if preferred.

`Command::Stop` now takes an optional NAME positional argument.

  dev-browser stop          # daemon-wide stop (unchanged)
  dev-browser stop <name>   # stop just that browser, leave the daemon up

The daemon's `browser-stop` IPC message and the corresponding
`browserManager.stopBrowser(name)` method already existed and are
covered by daemon tests; this just exposes them on the CLI. Stopping
an unknown name is a silent no-op, matching the daemon's idempotent
behavior.

Motivated by the fact that there was previously no way to dispose
a single managed browser without killing the daemon (and every other
browser it manages), which makes timestamped or per-test `--browser`
names accumulate forever in `dev-browser browsers`.
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.

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

1 participant