feat(browser): declarative browser action connectors#152
Conversation
Implements buildDeclarativeScript, which emits a self-contained Playwright JS script supporting fresh-session launch, cookie+localStorage restore, and selective URL-skip for the navigate connector. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ipURLRestore
- Change chromium.launch() to chromium.launch({ headless: true }) per spec
- Update TestBuildDeclarativeScript_FreshSession to assert the explicit headless flag
- Update TestBuildDeclarativeScript_SkipURLRestore to include a real cookie and assert addCookies is emitted even when URL restore is skipped
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… quoting, document localStorage redirect limitation Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughIntroduces a declarative browser automation layer with seven new connector actions (navigate, click, fill, extract, screenshot, wait, evaluate) that generate and execute Playwright scripts inside Docker containers while maintaining browser session state across multiple sequential actions. ChangesDeclarative Browser Automation Actions
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 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: 832ce055c4
ℹ️ 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".
| if err != nil { | ||
| return "", fmt.Errorf("browser: marshaling URL: %w", err) | ||
| } | ||
| fmt.Fprintf(&b, " await page.goto(%s);\n", urlJSON) |
There was a problem hiding this comment.
Restore localStorage before page loads
When a chained browser step restores session_state, this navigation runs before the saved localStorage entries are written back, so any app that reads localStorage during initial load (for example token-based auth or route guards) sees an empty store and may redirect or render as logged out before the connector restores it. This breaks the advertised session handoff for sites that keep session data outside cookies; inject the stored values before navigation (for example with an init script keyed by location.origin) so page startup observes them.
Useful? React with 👍 / 👎.
Closes #33
Summary
browser/navigate,browser/click,browser/fill,browser/extract,browser/screenshot,browser/wait,browser/evaluatesession_stateblob on output and restored on input, enabling stateful multi-step browser automation without persistent containersDockerRunConnectorpipeline — no new infrastructurebuildDeclarativeScriptgenerates complete, self-contained Playwright scripts with proper error propagationTest plan
go test ./internal/connector/ -short -run TestBrowser— all 30 unit tests passgo test ./internal/connector/ -run TestBrowserNavigateExtract_SessionChain -v -timeout 120s— session chain works end-to-endgo test ./internal/connector/ -run TestBrowserWait_TimeoutError_Integration -v -timeout 30s— timeout surfaces as error🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Tests