Repository navigation
chore(dev): add real browser extension smoke (#2248) - #2280
Conversation
Problem: #2248 still lacked a repo-owned proof that a real Chrome instance could load the unpacked browser extension and reach a branch-local receiver. The existing extension smoke covered the background worker through a Chrome API mock, while browser-plan only produced an operator handoff. What changed: add a no-dependency Node CDP smoke that launches Chrome with browser-extension loaded, discovers the Polylogue service worker, and posts unauthenticated/authenticated receiver requests from the extension-origin context. Wire it into devtools workspace dev-loop --browser-smoke with run-local artifacts/events, inspect-run summaries, docs, and focused tests. The real smoke exposed that receiver CORS preflight did not allow X-Request-ID, so the receiver now advertises that header. Verification: node --check browser-extension/scripts/dev-loop-browser-smoke.mjs; devtools workspace dev-loop --isolated-ports --prepare --browser-smoke --json; devtools test tests/unit/devtools/test_dev_loop.py tests/unit/browser_capture/test_receiver.py -q; devtools verify --quick. Ref #2248
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughAdds a ChangesBrowser Smoke Test Pipeline
Sequence Diagram(s)sequenceDiagram
actor Dev as Developer
participant devloop as dev_loop.py run_browser_smoke()
participant npm as npm run dev-loop-browser-smoke
participant Chrome as Headless Chrome + MV3 Extension
participant SW as Extension Service Worker (CDP)
participant Receiver as Temporary Local Receiver
Dev->>devloop: dev_loop.main --browser-smoke
devloop->>Receiver: start in-process receiver (smoke auth token)
devloop->>npm: subprocess.run with POLYLOGUE_BROWSER_SMOKE_OUT env
npm->>Chrome: spawn --headless --load-extension --remote-debugging-port
npm->>Chrome: waitJson /json/list → find SW target
npm->>SW: connectCdp WebSocket → Runtime.enable
npm->>SW: evaluateJson(unauthenticated POST /capture)
SW->>Receiver: POST /capture (no auth)
Receiver-->>SW: 401 Unauthorized
npm->>SW: evaluateJson(authorized GET /status)
SW->>Receiver: GET /status (Bearer token)
Receiver-->>SW: 200 OK
npm->>SW: evaluateJson(authorized POST /capture)
SW->>Receiver: POST /capture (Bearer token + envelope)
Receiver-->>SW: 200 OK + artifact_ref
npm->>npm: write summary JSON to POLYLOGUE_BROWSER_SMOKE_OUT
npm-->>devloop: exit 0 / exit 1
devloop->>devloop: emit browser_smoke_finished event, write browser-smoke.json
devloop-->>Dev: _print_browser_smoke() output + artifact paths
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 838dff9974
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
## Summary Completes the branch-local dev-loop close-out by making `devtools workspace dev-loop --inspect-run` useful as the first diagnostic stop after daemon, web, CLI, receiver, extension, or browser-loop failures. The helper now surfaces failed summary files, failed terminal captures, slowest timed events, and artifact paths grouped by surface, so a developer can move directly from one run id to the log/stdout/stderr artifact that explains the failure. ## Problem #2248 had already landed branch-local preflight, isolated ports, daemon launch artifacts, `/api/dev-loop`, CLI capture, receiver request ids, extension diagnostics, browser plans, and real Chrome unpacked-extension smoke. The remaining weakness was the final debugging step: when a run produced many local artifacts, `--inspect-run` mostly reported counts and raw failed events, so agents still had to scan the run directory to find the useful next file. ## Solution This PR extends the existing run inspector rather than adding a second observability ledger: - reads duration and artifact metadata from existing `dev-loop.events.jsonl`, daemon/browser/extension/TUI summary JSON, and terminal capture summaries; - reports `failed_summaries`, `failed_terminal_captures`, `slowest_events`, and `artifact_index` in JSON output; - shows the slowest event and available artifact groups in human output; - updates the dev-loop documentation to describe the postmortem workflow; - expands the focused dev-loop test to cover the new failure-postmortem behavior. ## Acceptance Matrix | Requirement | Evidence | | --- | --- | | Branch-local daemon/web/browser-capture runs are isolated from the deployed service | Landed in prior #2248 PRs: preflight, isolated ports, dev archive root, daemon launcher, `/api/dev-loop`; confirmed in issue comments with local smoke run ids. | | CLI/TUI capture artifacts are tied to the same run id | Existing `--capture-cli` and `--tui-plan` write run-local artifacts; this PR indexes terminal capture summaries in `--inspect-run`. | | Browser-extension loop is exercised from the branch | #2280 added real Chrome unpacked-extension smoke and fixed the CORS request-id preflight gap; issue comment records `ok=True` local evidence. | | Failed or slow dev-loop runs are diagnosable from local artifacts | This PR adds failed summaries, failed terminal captures, slowest timed events, and per-surface artifact index to `--inspect-run`. | | No new ops-tier table unless logs are insufficient | No table added. Existing structured launcher JSONL, summary files, `/api/dev-loop`, and daemon events answer the current debugging questions. | | Browser-control boundary stays local/operator-owned | `docs/dev-loop.md` continues to treat real authenticated browser/profile work as local operator/agent procedure; repo owns URLs/config/artifacts and smokes only. | ## Verification - `devtools test tests/unit/devtools/test_dev_loop.py -q` → `19 passed in 41.44s` after formatting. - `devtools render all --check` → all generated surfaces sync OK. - `devtools verify --quick` → all checks passed in 13.1s locally. - Pre-push `devtools verify --quick` → all checks passed in 11.83s, run id `20260621T143839Z-quick-67399-bf5fa775`. ## Notes I did not run a fresh real-browser smoke in this PR because #2280 already added and verified that path. This change is the postmortem layer over the run artifacts produced by those existing commands. Closes #2248
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Add a repo-owned real-browser dev-loop smoke for #2248. The new
devtools workspace dev-loop --browser-smokelaunches Chrome with the unpackedbrowser-extension/, discovers the Polylogue MV3 service worker over CDP, and exercises a temporary branch-local receiver from the extension-origin context. It writes browser smoke summaries, stdout/stderr, env, profile, spool, and dev-loop event rows under the run-local artifact directory.Problem
The branch-local dev loop had preflight, daemon launch, CLI capture, browser-plan handoff, receiver smoke, and mocked extension-background smoke, but it still did not prove that a real Chrome instance could load the unpacked extension and reach the branch-local receiver. During the real-browser probe, receiver CORS preflight also rejected the extension's
X-Request-IDheader, which made request-id correlation fail in actual browser fetches despite passing non-browser mocks.Solution
browser-extension/scripts/dev-loop-browser-smoke.mjs, a no-dependency Node/CDP script that launches Chrome headless with--load-extension, identifies the Polylogue service worker, and sends unauthenticated/authenticated receiver status/capture requests from the extension context.--browser-smokeintodevtools workspace dev-loop, including run-local artifacts, event rows, human/JSON output, and--inspect-runsummaries.docs/dev-loop.mdto distinguish--extension-smoke,--browser-smoke, and--browser-plan.X-Request-ID, with focused receiver coverage.Verification
node --check browser-extension/scripts/dev-loop-browser-smoke.mjsdevtools workspace dev-loop --isolated-ports --prepare --browser-smoke --jsonfeature-chore-dev-loop-browser-e2e-2248-c6f0820c2-api45189-capture52773ok=Truefignfifoniblkonapihmkfakmlgkbkcfchatgpt/dev-loop-browser-smoke-097ac33d4373.jsondevtools test tests/unit/devtools/test_dev_loop.py tests/unit/browser_capture/test_receiver.py -q33 passeddevtools verify --quick20260621T132155Z-quick-3804056-eace7b81Ref #2248
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Documentation
Tests