Skip to content

proto-window.mjs

Launches Chrome with remote debugging on, at a fixed window position and size, for proto-view.mjs to drive.

Contributor toolingproto-window.mjs

What it does

Finds a local Chrome install, then launches it against a URL — the vite dev server by default — with its CDP port open. Positions the window at a fixed offset and size, so the window lands in the same place across sessions. Blocks until that Chrome process exits.

Usage

The minimal invocation that works:

bash
npm run proto:window

The direct form, with the flags it accepts:

bash
node tools/proto-window.mjs [--port <n>] [--url <url>] [--position <x,y>]

Options

These three are Chrome's own launch flags, hardcoded into every launch — not read from proto-window.mjs's command line. (--port, --url, and --position are the flags this script does read from its own command line; see Usage and Notes.)

FlagValueWhat it doesDefault
--no-first-runno valueSkips Chrome's first-run onboarding flow. Fixed; not a proto-window.mjs flag.fixed
--no-default-browser-checkno valueSkips the "set as default browser" prompt. Fixed; not a proto-window.mjs flag.fixed
--start-maximizedno valueMaximizes the window after positioning it. Fixed; not a proto-window.mjs flag.fixed

Inputs and outputs

Reads: the Chrome binary, from one of three candidate install paths (the Program Files path, its x86 twin, or %LOCALAPPDATA%/Google/Chrome/Application/chrome.exe).

Writes: a scratch Chrome profile at <tmpdir>/gw-proto-chrome-profile, reused across launches via --user-data-dir.

Binds: Chrome's CDP endpoint on 127.0.0.1:<port> (default 9222), positions the window at <position> (default 2560,0) sized 1920,1080 (fixed, no flag), and navigates to <url> (default http://localhost:5173/).

Stops: this script's own process is synchronous around the browser (spawnSync), so it holds the terminal for the whole session. Close the Chrome window, or tree-kill this node process, to stop it — both are printed to the console at launch.

Exit codes: mirrors whatever Chrome itself exited with. If no Chrome binary is found, the lookup throws uncaught, which exits 1 with a Node stack trace listing every path it checked.

Examples

Bring the live preview up for a design session — the second step of the ui-room workflow, after npm run dev:

bash
npm run proto:window

Run a second Chrome instance on a non-default CDP port, to avoid colliding with one already open on 9222:

bash
node tools/proto-window.mjs --port 9223

Notes

The flags --port, --url, and --position are real ones this script reads from its own argv (see Usage). They are not in Options above because that section covers only the flags found literally in the source. These three are built dynamically (`--${name}`) rather than written out.

Ctrl-C does not close the launched window; closing the window, or a tree-kill of this process, does — spawnSync blocks this process on Chrome's own exit.

The scratch profile persists across launches, so browser state — including the proto.skin key the ui-room workflow reads — survives a restart of this script.

Source

tools/proto-window.mjs — part of Contributor tooling