Skip to content

feat(cli): persist startup defaults from XDG config - #2629

Open
joebasrawi wants to merge 1 commit into
ChromeDevTools:mainfrom
joebasrawi:cursor/persist-cli-defaults-4750
Open

feat(cli): persist startup defaults from XDG config#2629
joebasrawi wants to merge 1 commit into
ChromeDevTools:mainfrom
joebasrawi:cursor/persist-cli-defaults-4750

Conversation

@joebasrawi

Copy link
Copy Markdown

Summary

The standalone chrome-devtools CLI auto-starts its daemon when the first tool command runs, but that path had no way to reuse user-specific startup options (executablePath, headless, userDataDir, and other start flags). After a reboot, crash, or stop, the next command launched the daemon with built-in defaults.

This adds an XDG-compatible config file:

$XDG_CONFIG_HOME/chrome-devtools/config.json

falling back to ~/.config/chrome-devtools/config.json. For example:

{
  "executablePath": "/usr/bin/chromium",
  "headless": false
}

Precedence is:

explicit command-line options > configuration file > built-in defaults

The same file is applied to automatic daemon startup and to explicit chrome-devtools start when an option is omitted. Config keys are validated with the existing start option parser (including coerce/conflict rules). chrome-devtools status continues to report the effective daemon arguments.

Fixes #2388

Design notes

Implemented against current main rather than resurrecting closed PR #2389.

  • Config loading lives in src/config/cli-config.ts next to the current option modules.
  • Auto-start and start share getCliStartOptions(), applyCliStartDefaults(), and yargs .config(), so CLI-specific defaults such as isolated stay consistent.
  • Auto-start no longer serializes the tool command’s argv into daemon flags. Tool commands do not register start options, and overlapping keys (for example viewport on emulate) could leak into the daemon. Persistent defaults belong in the config file; explicit chrome-devtools start --… still overrides them.
  • Unknown or invalid config keys fail with the same validation as chrome-devtools start.

Testing

  • Unit tests for config path resolution, missing/invalid files, option validation, and CLI > config > built-in precedence (tests/cli-config.test.ts)
  • E2E: automatic list_pages startup uses config values and status shows them
  • E2E: explicit start uses config when flags are omitted
  • E2E: command-line flags override config

Locally: npm run format, npx tsc --noEmit, npm run test tests/cli-config.test.ts, and the chrome-devtools start/commands e2e files.

@google-cla

google-cla Bot commented Aug 29, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Load chrome-devtools start options from
$XDG_CONFIG_HOME/chrome-devtools/config.json (falling back to
~/.config/chrome-devtools/config.json) and apply them when a tool
command auto-starts the daemon and when start is invoked without
those flags. Explicit CLI options still take precedence.

Fixes ChromeDevTools#2388

Co-authored-by: Joseph B <joebasrawi@users.noreply.github.com>
@cursor
cursor Bot force-pushed the cursor/persist-cli-defaults-4750 branch from 31ec446 to 68ed4b9 Compare August 29, 2026 14:30
@joebasrawi
joebasrawi marked this pull request as ready for review August 29, 2026 14:32
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.

Persist CLI defaults for automatic daemon startup

1 participant