Skip to content

gut(browser): remove Playwright automation framework#2330

Merged
alexey-pelykh merged 1 commit intomainfrom
gut/2304-remove-playwright-browser-framework
Apr 12, 2026
Merged

gut(browser): remove Playwright automation framework#2330
alexey-pelykh merged 1 commit intomainfrom
gut/2304-remove-playwright-browser-framework

Conversation

@alexey-pelykh
Copy link
Copy Markdown

Summary

Removes the Playwright browser-automation layer from src/browser/ per the Middleware Boundary Principle. The browser_request MCP tool routes through paired nodes (infrastructure), but src/browser/ also carried a full Playwright stack (~14k lines, 69% of the directory) that was generic browser automation, not node-bound routing. This PR keeps the node-routing layer (~5.5k lines: bridge-server, extension-relay, profiles, config, security, CDP layer, basic+tabs routes) and removes everything else.

~14,373 lines deleted, 253 added across 115 files.

Deleted

Playwright layer (src/browser/):

  • All pw-* files (pw-session, pw-ai, pw-tools-core.*) — 28 files
  • All routes/agent.* files (act, snapshot, storage, debug, hooks, output-paths) — 13 files
  • Chrome process management: chrome.ts, chrome.executables.ts, chrome.profile-decoration.ts + tests
  • Client action wrappers: client-actions.ts, client-actions-core.ts, client-actions-observe.ts, client-actions-state.ts
  • Automation utilities: screenshot.ts, paths.ts, form-fields.ts, safe-filename.ts, output-atomic.ts, session-tab-registry.ts
  • Server agent-contract test harnesses + tests

Downstream consumers (no longer backed by deleted agent routes):

  • src/cli/browser-cli-actions-input{,.ts,/*} (entire /act action surface)
  • src/cli/browser-cli-actions-observe.ts (/console, /pdf, /response/body)
  • src/cli/browser-cli-debug.ts (/highlight, /errors, /requests, /trace/*)
  • src/cli/browser-cli-inspect.ts (/screenshot, /snapshot)
  • src/cli/browser-cli-state.ts, src/cli/browser-cli-state.cookies-storage.ts (/set/*, /storage/*)
  • src/cli/browser-cli-resize.ts (uses /act)
  • src/agents/tools/browser-tool.actions.ts (orphan — no callers)

Surgically refactored (KEEP files)

  • routes/index.ts — drops registerBrowserAgentRoutes import + call
  • routes/basic.ts — inlines resolveProfileContext (was in deleted agent.shared.ts); drops chrome process metadata fields (chosenBrowser, userDataDir, pid, detectedBrowser*, detectError) from /status payload
  • server-context.ts — drops Playwright tab-op fallbacks (listPages/createPage/focus/close ViaPlaywright); removes local Chrome launch path entirely (launchRemoteClawChrome is gone — only attached/extension/remote modes remain); replaces chrome.ts reachability calls with new cdp-reachability.ts; resetProfile now only moves user-data dir for local-loopback profiles, no Chrome shutdown
  • server-context.types.ts — drops RunningChrome from ProfileRuntimeState (running field gone)
  • profiles-service.ts — switches resolveRemoteClawUserDataDir import to new profile-paths.ts helper; switches movePathToTrash to new infra location
  • server.ts — drops pw-ai-state.isPwAiLoaded shutdown branch
  • control-service.ts — drops pw-ai.closePlaywrightBrowserConnection shutdown branch
  • client.ts — drops browserSnapshot (uses deleted /snapshot route); drops dead BrowserStatus fields (pid, chosenBrowser, userDataDir, executablePath, detectedBrowser*, detectError); drops SnapshotResult/SnapshotAriaNode types
  • gateway/server-methods/sessions.ts — drops closeTrackedBrowserTabsForSessions call (the registry was never populated by any caller in this codebase, so the call was a no-op)
  • gateway/server-methods/agents.ts — switches movePathToTrash import to infra/trash.js
  • gateway/server-methods/browser.ts — switches proxy-files import to local browser-proxy-files.ts

Relocated (used by KEEP code)

From To Reason
src/browser/trash.ts src/infra/trash.ts Used by gateway, CLI, and profiles-service — generic FS utility, not browser-specific
src/browser/proxy-files.ts src/gateway/server-methods/browser-proxy-files.ts Only consumer was gateway/server-methods/browser.ts
Reachability checks from chrome.ts New src/browser/cdp-reachability.ts Pure CDP HTTP/WS reachability, no Chrome process semantics
resolveRemoteClawUserDataDir from chrome.ts New src/browser/profile-paths.ts Small path helper used by profiles-service and server-context.resetProfile

Other

  • package.json — removes playwright-core dependency
  • Dockerfile — drops the Playwright browser install step (still installs Xvfb when REMOTECLAW_INSTALL_BROWSER=1)
  • src/dockerfile.test.ts — updated to assert playwright-core is NOT in the Dockerfile
  • src/browser/cdp-timeouts.ts — renames CHROME_REACHABILITY_TIMEOUT_MS/CHROME_WS_READY_TIMEOUT_MS to CDP_* (more accurate; the chrome bootstrap/launch timeouts that are no longer used were removed)
  • server.control-server.test-harness.ts — slimmed down: only mocks what still exists (cdp-reachability, profile-paths, infra/trash, cdp.js); drops the Playwright/Chrome mock surface
  • New server-context.cdp-test-harness.ts — minimal CDP reachability mock for the few tests that need it

Acceptance criteria

  • No pw-* files remain in src/browser/
  • No routes/agent.* files remain
  • No chrome.* process management files remain
  • server-context.ts has no Playwright imports
  • routes/index.ts registers only basic + tabs routes
  • Node-routing layer intact: bridge-server, extension-relay, profiles, config, security, CDP, client, basic+tabs routes
  • Build passes
  • Tests pass (743 files / 6488 tests)

Test plan

  • pnpm check (format + typecheck + lint) — clean
  • pnpm build — clean (warnings unchanged from main)
  • pnpm test — 743 files, 6488 tests pass, 0 failures
  • Manual: remoteclaw browser status, remoteclaw browser tabs, remoteclaw browser open, remoteclaw browser focus, remoteclaw browser close against an attached Chrome
  • Manual: profile create/delete/reset CRUD via CLI
  • Manual: extension-driver profile end-to-end

Closes #2304

🤖 Generated with Claude Code

Per the Middleware Boundary Principle, the browser_request MCP tool
routes through paired nodes — that's infrastructure. The Playwright
automation layer (~14k lines) was generic browser automation, not
node-bound routing.

Deletes the Playwright layer in src/browser/:
- All pw-* files (pw-session, pw-ai, pw-tools-core.*)
- All routes/agent.* files (act, snapshot, storage, debug, hooks)
- Chrome process management (chrome.ts, chrome.executables,
  chrome.profile-decoration)
- Client action wrappers (client-actions*)
- Automation utilities (screenshot, paths, form-fields, safe-filename,
  output-atomic, session-tab-registry)

Removes downstream consumers backed by deleted agent routes:
- src/cli/browser-cli-{actions-input,actions-observe,debug,inspect,
  resize,state,state.cookies-storage}
- src/agents/tools/browser-tool.actions.ts (orphan since no callers)

Surgically refactors KEEP files:
- routes/index.ts: drops registerBrowserAgentRoutes
- routes/basic.ts: inlines resolveProfileContext, drops chrome
  process metadata from /status
- server-context.ts: drops Playwright fallbacks, drops local Chrome
  launch path (only attached/extension/remote modes remain)
- profiles-service.ts: switches resolveRemoteClawUserDataDir to new
  profile-paths helper
- client.ts: drops browserSnapshot + dead BrowserStatus fields
- gateway/server-methods/sessions.ts: drops
  closeTrackedBrowserTabsForSessions (registry was never populated)

Relocates utilities used by KEEP code:
- browser/trash.ts → infra/trash.ts (used by gateway, CLI, profiles)
- browser/proxy-files.ts → gateway/server-methods/browser-proxy-files.ts
  (only consumer was gateway/server-methods/browser.ts)
- Extracted CDP reachability checks from chrome.ts into a new
  cdp-reachability.ts (no Chrome process semantics)
- Added profile-paths.ts for resolveRemoteClawUserDataDir

Removes playwright-core from package.json and Dockerfile.

Build, lint, format, and tests all green (743 files / 6488 tests).
~14,213 lines deleted, 99 added.

Closes #2304
@alexey-pelykh alexey-pelykh merged commit 1aae7da into main Apr 12, 2026
10 checks passed
@alexey-pelykh alexey-pelykh deleted the gut/2304-remove-playwright-browser-framework branch April 12, 2026 23:17
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.

gut: remove Playwright automation framework from browser subsystem (MBP audit)

1 participant