Skip to content

feat: add integrated browser - #277

Merged
hyrious merged 3 commits into
mainfrom
feat/integrated-browser
Jul 28, 2026
Merged

feat: add integrated browser#277
hyrious merged 3 commits into
mainfrom
feat/integrated-browser

Conversation

@hyrious

@hyrious hyrious commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add a task-scoped integrated browser backed by Electron WebContentsView and playwright-core, with an authenticated loopback bridge and seven flat browser tools.
  • Expose Browser as a Wanta-owned built-in Skill, add the shared right-panel UI and controls, and support persistent account-scoped browser data, settings, downloads, cancellation, cleanup, and a three-page LRU cap.
  • Preserve the existing access-mode and security boundaries: ordinary web URLs only, no credential/profile import, no arbitrary Playwright code, and manual login/CAPTCHA.
  • Polish the UI integration by separating Browser and Artifacts widths, allowing long chat titles to shrink, preserving localized/custom Skill reference titles, respecting light-only transparent pages, and moving the resize sash outside the webpage viewport.
  • Document the product model, architecture, implementation evidence, and remaining scope.

Verification

  • corepack pnpm run ts-check
  • corepack pnpm run lint
  • corepack pnpm run format
  • corepack pnpm test — 276 files, 2,061 tests
  • corepack pnpm run build
  • Runtime/UI verification completed or not applicable

Machine-observable Electron 42 probes passed for the Playwright CDP relay, theme inheritance, and the light-only transparent-page fallback. Final human visual checks remain for the native browser panel, resize sash, long-title compression, and the referenced Zhihu page, following the repository instruction not to automate visual inspection.

Safety and Compatibility

  • Local BYOK and signed-in OOMOL modes were considered separately.
  • No credential was exposed to the renderer, logs, fixtures, screenshots, or committed files.
  • Agent tools, permissions, and system prompts remain aligned, or the change does not affect them.
  • Migration, packaging, endpoint, and update implications were considered.
  • Relevant documentation and tests were updated.

playwright-core adds no bundled browser binary. A macOS arm64 package comparison measured an increase of 10.999 MiB in app.asar and 2.635 MiB in the final zip.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: da5fae67-758d-44ae-8b1f-4bcba32e9626

📥 Commits

Reviewing files that changed from the base of the PR and between 3177e16 and 0568720.

📒 Files selected for processing (9)
  • electron/browser/control-server.ts
  • electron/browser/policy.test.ts
  • electron/browser/policy.ts
  • electron/chat/context-system.test.ts
  • electron/chat/context-system.ts
  • electron/chat/node.ts
  • electron/main.ts
  • src/components/app-shell/use-browser-panel-state.ts
  • src/routes/Chat/BrowserPanel.tsx
🚧 Files skipped from review as they are similar to previous changes (6)
  • electron/browser/policy.test.ts
  • electron/browser/control-server.ts
  • src/components/app-shell/use-browser-panel-state.ts
  • electron/browser/policy.ts
  • src/routes/Chat/BrowserPanel.tsx
  • electron/main.ts

Summary by CodeRabbit

  • New Features
    • Added an integrated browser (navigate/read/click/type/scroll/screenshot/dialogs) with continuous in-task control and a dedicated browser panel (address bar, navigation controls, resizing, open-in-system-browser).
    • Added a built-in browser skill to the chat composer (shown/hidden based on browser availability).
    • Added settings to enable/disable the browser, clear browsing data, and open downloads, plus download completion notifications.
    • Updated permission-mode guidance to include integrated-browser “Default vs Full Access” rules and manual handling for sensitive login/verification actions.
  • Documentation
    • Published new and expanded browser documentation, including the integrated-browser implementation status and related architecture updates.
  • Bug Fixes
    • Improved browser control request handling (authorization enforcement, scroll delta clamping, and request abort behavior).

Walkthrough

This PR introduces an integrated browser backed by an Electron WebContentsView, a Playwright CDP relay, a main-process browser service, and an authenticated loopback control server. It adds seven browser_* agent tools, browser settings and persistence, bundled browser skills, renderer browser-panel controls, chat skill-palette support, permission-mode guidance, localization, and lifecycle handling for sessions, profiles, downloads, and shutdown. It also adds tests for browser control, policy, relay, page behavior, settings, tools, workspace synchronization, and UI-related contracts.

Sequence Diagram(s)

sequenceDiagram
  participant Renderer as Chat/BrowserPanel
  participant Main as Electron Main
  participant Manager as BrowserManager
  participant Page as BrowserPage/Relay
  participant AgentTool as browser_* tool
  participant ControlServer as BrowserControlServer

  Renderer->>Main: invoke browser operation
  Main->>Manager: delegate request
  Manager->>Page: create or reuse page
  Page-->>Manager: browser state or result
  Manager-->>Renderer: stateChanged event

  AgentTool->>ControlServer: POST /v1/browser with bearer token
  ControlServer->>Manager: execute(request, signal)
  Manager->>Page: perform browser action
  Page-->>Manager: action result
  Manager-->>ControlServer: JSON result
  ControlServer-->>AgentTool: response
Loading
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title uses a valid conventional-commit style and matches the integrated browser change.
Description check ✅ Passed The description follows the required template and covers summary, verification, and safety/compatibility items.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch feat/integrated-browser

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (1)
electron/browser/playwright-relay.ts (1)

88-127: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

send()'s CDP special-case routing is not exercised by any test.

playwright-relay.test.ts fully mocks chromium.connectOverCDP, so this method's routing (Browser.getVersion, Browser.setDownloadBehavior, Target.setAutoAttach/announcePage, scoped Target.getTargetInfo, and the generic passthrough/error path) never actually runs in the test suite — only the higher-level connect()/emulateMedia behavior is verified. Since this is the core protocol-translation logic bridging Electron's debugger and Playwright's CDP client, consider adding a test that drives transport.send(...) directly (e.g. by having the mocked connectOverCDP invoke transport.send with sample CDP requests) to assert the correct onmessage replies for each branch.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@electron/browser/playwright-relay.ts` around lines 88 - 127, Add direct
coverage for the private send() CDP routing by having the mocked
chromium.connectOverCDP invoke transport.send with representative requests.
Assert onmessage replies for Browser.getVersion, Browser.setDownloadBehavior,
Target.setAutoAttach and announcePage, scoped Target.getTargetInfo, generic
debugger passthrough, and debugger errors.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@electron/browser/control-server.ts`:
- Line 14: Update BrowserControlServer’s response handling so both execute()
completion branches call respond() only while the response socket remains
connected, and remove the redundant request.once("aborted") listener while
preserving the existing response.once("close") abort behavior.

In `@electron/browser/policy.ts`:
- Around line 5-14: Update parseBrowserUrl so bare host:port inputs such as
localhost:5173 and example.com:8080 are prefixed with https:// instead of being
interpreted as custom schemes, while preserving explicit HTTP/HTTPS handling.
Add a regression test covering a local development address and verify it returns
an HTTP(S) URL.

In `@electron/chat/context-system.ts`:
- Around line 131-133: Update buildPermissionModeSystem to conditionally include
the integrated-browser guidance only when the effective browser state indicates
the browser is available and enabled. Pass that state into the prompt builder
from its caller, accounting for settings still loading, and omit the
browser-specific bullets when browserEnabled is false or unavailable.

In `@src/components/app-shell/use-browser-panel-state.ts`:
- Around line 38-64: Update the browserRequested event handler in the browser
panel state hook to set receivedStateEvent before opening the panel, so an
in-flight getState(activeSessionId) result cannot overwrite the requested open
state. Preserve the existing active-session filtering and panel-opening
behavior.

In `@src/routes/Chat/BrowserPanel.tsx`:
- Around line 59-65: Update the unmount cleanup in BrowserPanel’s effect to
report failures from browserService.invoke("hide", sessionId) through the
existing reportRendererHandledError mechanism instead of silently swallowing
them. Preserve the cleanup’s observer, resize-listener, and animation-frame
teardown while ensuring hide failures leave the same diagnostic trail as other
browserService invocations.

---

Nitpick comments:
In `@electron/browser/playwright-relay.ts`:
- Around line 88-127: Add direct coverage for the private send() CDP routing by
having the mocked chromium.connectOverCDP invoke transport.send with
representative requests. Assert onmessage replies for Browser.getVersion,
Browser.setDownloadBehavior, Target.setAutoAttach and announcePage, scoped
Target.getTargetInfo, generic debugger passthrough, and debugger errors.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cae769f7-d899-4692-9da3-3b27f93caa05

📥 Commits

Reviewing files that changed from the base of the PR and between 77dbd6a and 3177e16.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (64)
  • AGENTS.md
  • docs/ai/README.md
  • docs/ai/integrated-browser-implementation.md
  • docs/architecture.md
  • docs/conventions.md
  • docs/integrated-browser.md
  • docs/openconnector-support-plan.md
  • docs/project-overview.md
  • electron/agent/binaries.ts
  • electron/agent/manager.ts
  • electron/agent/tool-sources.test.ts
  • electron/agent/tool-sources.ts
  • electron/agent/workspace.test.ts
  • electron/agent/workspace.ts
  • electron/browser/common.ts
  • electron/browser/control-server.test.ts
  • electron/browser/control-server.ts
  • electron/browser/node.test.ts
  • electron/browser/node.ts
  • electron/browser/page.test.ts
  • electron/browser/page.ts
  • electron/browser/playwright-relay.test.ts
  • electron/browser/playwright-relay.ts
  • electron/browser/policy.test.ts
  • electron/browser/policy.ts
  • electron/chat/common.ts
  • electron/chat/context-system.test.ts
  • electron/chat/context-system.ts
  • electron/main.ts
  • electron/settings/common.test.ts
  • electron/settings/common.ts
  • electron/settings/node.test.ts
  • electron/settings/node.ts
  • electron/settings/store.test.ts
  • electron/settings/store.ts
  • package.json
  • resources/wanta-skills/browser/SKILL.md
  • scripts/check-oo.ts
  • scripts/skills.test.ts
  • scripts/skills.ts
  • src/components/AppContext.ts
  • src/components/ai-elements/message.test.ts
  • src/components/app-shell/AppShell.tsx
  • src/components/app-shell/AppShellMainTitlebar.tsx
  • src/components/app-shell/AppShellRightPanel.tsx
  • src/components/app-shell/app-shell-model.ts
  • src/components/app-shell/use-artifacts-panel-state.ts
  • src/components/app-shell/use-browser-download-notifications.ts
  • src/components/app-shell/use-browser-panel-state.ts
  • src/hooks/useAppSettings.ts
  • src/i18n/app-messages.en.ts
  • src/i18n/app-messages.zh.ts
  • src/main.tsx
  • src/routes/Chat/BrowserPanel.tsx
  • src/routes/Chat/ChatComposer.tsx
  • src/routes/Chat/ContextMentionChips.tsx
  • src/routes/Chat/composer-palette-items.test.ts
  • src/routes/Chat/composer-palette-items.ts
  • src/routes/Chat/context-mention-label.test.ts
  • src/routes/Chat/context-mention-label.ts
  • src/routes/Chat/useComposerPalette.ts
  • src/routes/Settings/index.tsx
  • src/styles/app-shell.css
  • vite.config.ts

Comment thread electron/browser/control-server.ts
Comment thread electron/browser/policy.ts
Comment thread electron/chat/context-system.ts Outdated
Comment thread src/components/app-shell/use-browser-panel-state.ts
Comment thread src/routes/Chat/BrowserPanel.tsx
@hyrious
hyrious merged commit 332dea4 into main Jul 28, 2026
2 checks passed
@hyrious
hyrious deleted the feat/integrated-browser branch July 28, 2026 07:47
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