Skip to content

feat(browse): env-driven Chromium launch overrides - #1933

Closed
jeanfw wants to merge 1 commit into
garrytan:mainfrom
jeanfw:feat/env-launch-overrides
Closed

jeanfw wants to merge 1 commit into
garrytan:mainfrom
jeanfw:feat/env-launch-overrides

Conversation

@jeanfw

@jeanfw jeanfw commented Jun 9, 2026

Copy link
Copy Markdown

What

Two no-op-by-default launch overrides for the browse server's Chromium, read from the environment so users can customize the browser without patching the source (which /gstack-upgrade wipes via git reset --hard):

  • GSTACK_CHROMIUM_ARGS — extra Chromium command-line flags appended to the launch args. Accepts a JSON array of strings ('["--mute-audio", "--use-fake-ui-for-media-stream"]') or a whitespace-separated string ('--flag-a --flag-b').
  • GSTACK_HTTP_CREDENTIALS — HTTP basic-auth as "user:pass", auto-answers 401 challenges (e.g. a dev environment behind a shared gate). Splits on the first colon so passwords may contain colons.

Both default to a no-op, so out-of-the-box launch behavior is unchanged.

Why

There's currently no supported way to add Chromium flags or basic-auth credentials to the headed/headless browser. The only option is editing browser-manager.ts directly, and that edit is lost on every upgrade. This mirrors the existing GSTACK_CLAUDE_BIN_ARGS env-override pattern (JSON-array-or-scalar) so the convention is consistent.

How

  • Parsing extracted into a small pure module browse/src/launch-overrides.ts (parseExtraChromiumArgs, parseHttpCredentials) with unit tests.
  • Wired into all three launch paths: headless launch(), headed launchHeaded(), and the headless→headed handoff re-launch.

Tests

bun test browse/test/launch-overrides.test.ts — 13 assertions covering JSON-array, whitespace-split, single-flag, empty-drop, colon-in-password, and the unset/blank/no-colon no-op cases.

🤖 Generated with Claude Code

Add two no-op-by-default launch overrides so users can customize the
browse server's Chromium without patching the source (which is wiped on
every `/gstack-upgrade`):

- GSTACK_CHROMIUM_ARGS: extra Chromium flags appended to the launch args.
  Accepts a JSON array of strings or a whitespace-separated string.
- GSTACK_HTTP_CREDENTIALS: "user:pass" basic-auth, auto-answers 401
  challenges (e.g. a dev environment behind a shared gate).

Both default to a no-op, so out-of-the-box launch behavior is unchanged.
Parsing lives in a small pure module (browse/src/launch-overrides.ts)
mirroring the existing GSTACK_CLAUDE_BIN_ARGS pattern, with unit tests.
Wired into all three launch paths: headless launch(), headed
launchHeaded(), and the headless→headed handoff re-launch.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@trunk-io

trunk-io Bot commented Jun 9, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@jbetala7

Copy link
Copy Markdown
Contributor

The parsing helpers are clean and well-covered by launch-overrides.test.ts. Two things before this lands:

1. Security — GSTACK_HTTP_CREDENTIALS is unscoped. Setting httpCredentials without an origin means Playwright will answer a 401 from any origin the browse session reaches with these basic-auth creds, not just the intended dev gate. If a session navigates to (or is redirected to) an untrusted site that returns 401, the credentials leak to that origin. Playwright's httpCredentials accepts an optional origin to restrict sending to a single origin — worth either threading an origin through the env var or, at minimum, documenting in the helper comment that creds are sent to any 401-issuing origin. A test asserting the origin is honored would lock it in.

2. Coordination. This overlaps #1968 (executablePath in the headless launch()) and #1915 (GSTACK_HEADED_NOGPU) on the same launch paths. #1915's hard-coded --disable-gpu ... is exactly the kind of thing a user could pass through your GSTACK_CHROMIUM_ARGS, so there may be room to consolidate — flagging so the three don't conflict on merge.

@time-attack

Copy link
Copy Markdown
Contributor

@16francej not needed close agent does this for you

@capy-ai

capy-ai Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Thank you for this, @jeanfw. It's a reasonable idea, but not one we can take right now: An extra-args escape hatch is reasonable only with a denylist (for example --remote-debugging-port and --disable-web-security undo the browse security model). Basic-auth credentials belong in a scoped $B command, not a process-wide env var. We're parking it: closing the PR and recording the idea in TODOS.md under its theme, so it isn't lost. When we pick that theme up we'll reference this PR and credit you.

@capy-ai capy-ai Bot closed this Oct 8, 2026
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.

3 participants