Skip to content

Add batched POST /chromium/configure with optional start_url#244

Open
hiroTamada wants to merge 3 commits into
mainfrom
feat/chromium-configure-multipart
Open

Add batched POST /chromium/configure with optional start_url#244
hiroTamada wants to merge 3 commits into
mainfrom
feat/chromium-configure-multipart

Conversation

@hiroTamada
Copy link
Copy Markdown
Contributor

@hiroTamada hiroTamada commented May 19, 2026

Summary

  • Adds POST /chromium/configure: one multipart request to batch display sizing, Chrome policies, Chromium flags, profile archive, extensions, and optional start_url navigation after a single Chromium restart.
  • Introduces cdpclient.NavigateFirstPage for post-ready Page.navigate (flattened CDP session, waits for load / domcontentloaded). Fixes concurrent WebSocket reads that caused flaky navigate failures.
  • Refactors extension upload logic into shared applyExtensionZipItems used by configure and existing upload-and-restart.
  • E2e: 31-way powerset over optional configure parts plus bare/JSON start_url tests; local runner script and DETACHED=1 headless run-docker.sh for manual API use.
  • make test: e2e package timeout raised to 120m (full suite exceeds default 10m).

Test plan

  • go vet ./... and unit tests (go test excluding /e2e)
  • ./scripts/run-local-chromium-configure-powerset.sh (31 permutations + start_url variants) against locally built headless image
  • Full go test -race -timeout 120m ./e2e/ with E2E_CHROMIUM_HEADLESS_IMAGE / E2E_CHROMIUM_HEADFUL_IMAGE pointing at images built from this branch

Made with Cursor


Note

Medium Risk
Adds a new multipart endpoint that can stop/start Chromium and mutate policies, flags, extensions, display, and user profile in one call; failures can leave partial side effects. Also changes Chromium supervisorctl invocation and CDP navigation behavior, which may impact runtime stability and e2e reliability.

Overview
Adds POST /chromium/configure to apply multiple Chromium configuration changes in a single multipart request (display sizing, enterprise policies, launch flags, extension zips, and a tar.zst profile archive) with a single stop/start cycle and a structured ChromiumConfigureError (phase + optional step).

Introduces best-effort start_url dispatch after DevTools readiness (including bare-host normalization), and expands cdpclient with navigation helpers that manage flattened sessions and event waits.

Refactors extension installation into shared applyExtensionZipItems (used by both configure and the existing upload-and-restart path) with partial-install cleanup, adds supervisorctl start/stop helpers, updates OpenAPI/generated client/server bindings, and adds unit/e2e coverage (including a powerset matrix) plus a longer e2e test timeout in make test.

Reviewed by Cursor Bugbot for commit 2f7e5d6. Bugbot is set up for automated code reviews on this repo. Configure here.

hiroTamada and others added 2 commits May 19, 2026 09:27
Single multipart request can apply display, policies, flags, extensions, and profile changes with one Chromium restart, then navigate via CDP after DevTools is ready.

Co-authored-by: Cursor <cursoragent@cursor.com>
Drop DETACHED run-docker mode, the powerset runner script, and related AGENTS.md notes.

Co-authored-by: Cursor <cursoragent@cursor.com>
@hiroTamada hiroTamada marked this pull request as ready for review May 20, 2026 15:22
Comment thread server/cmd/api/api/chromium_configure.go
@firetiger-agent
Copy link
Copy Markdown

Monitoring Plan: POST /chromium/configure

This PR introduces a new batched multipart endpoint (POST /chromium/configure) that consolidates display resizing, Chromium flag merging, enterprise policy application, extension installation, user-data profile loading, and optional CDP navigation into a single API call. It also refactors UploadExtensionsAndRestart to share logic with the new endpoint via applyExtensionZipItems(), and adds new stopChromium()/startChromiumAndWait() helpers backed by supervisorctl with 2-minute timeouts and a 15-second DevTools readiness wait.

Key risks to watch post-deploy: (1) the new endpoint is not yet exercised in production so a spike in 400/500 responses would indicate client or validation issues; (2) the refactored stop/start cycle now shares code paths with existing extension uploads — any regression in the supervisorctl integration would surface as stop chromium failed or CDP ready wait failed errors, which today run at ~1–14/hr per signal; (3) startChromiumAndWait() now uses a 15-second readiness timeout (previously indefinite via subscription) which could produce devtools not ready in time errors if Chromium is slow to start under load. Status updates will be posted automatically on this PR as monitoring progresses.

View agent

Batching keeps a single Chromium restart while preserving Kernel's configure order, propagating required-step failures, and keeping start_url best-effort.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2f7e5d6. Configure here.

n++
}
return n
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary stop/restart from inconsistent actionable checks

Medium Severity

cfgActionables uses policiesContentNonEmpty for policies (deep content check) but flagsNonEmpty for flags (shallow string check). A flagsContentNonEmpty helper exists and is tested but is never called in production code. This means inputs like {"flags":[]} pass the "at least one actionable" gate, and chromiumNeedsStopCycle (also using flagsNonEmpty) triggers a full Chromium stop cycle, only for chromiumValidateFlags to reject the input with a 400. Chromium is then unnecessarily restarted via the safety defer.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2f7e5d6. Configure here.

Phase: oapi.NavigatePhase,
Message: msg,
})
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple unused functions introduced as dead code

Low Severity

Several new functions have no callers anywhere in the codebase: cfg500Configure, cfg500Navigate, chromiumDisplayHasSizedRequest in chromium_configure.go, and the exported NavigateFirstPage in cdpclient.go. These are dead code that adds maintenance burden. chromiumDisplayHasSizedRequest also has a logic issue where its int type assertion branch can never succeed since json.Unmarshal into map[string]interface{} always produces float64 for numbers.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2f7e5d6. Configure here.

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.

1 participant