Skip to content

refactor: src cleanup — deduplicate errors, cache VM, extract BasePage, remove Playwright MCP legacy#667

Merged
jackwener merged 3 commits intomainfrom
refactor/src-cleanup
Apr 1, 2026
Merged

refactor: src cleanup — deduplicate errors, cache VM, extract BasePage, remove Playwright MCP legacy#667
jackwener merged 3 commits intomainfrom
refactor/src-cleanup

Conversation

@jackwener
Copy link
Copy Markdown
Owner

Summary

  • Extract isTransientBrowserError() into browser/errors.ts — replaces duplicated string-matching lists in daemon-client.ts and pipeline/executor.ts. Single source of truth for transient error patterns.
  • Cache compiled vm.Script objects in pipeline/template.ts with LRU eviction (max 256 entries) — avoids per-invocation VM context creation in pipeline loops, significant speedup for repeated expressions.
  • Add getActiveTabId() to IPage interface and Page class — exposes previously hidden tab state for debugging and validation.

Test plan

  • npm run typecheck passes
  • npx vitest run src/pipeline/ src/browser/page.test.ts — 96 tests pass
  • npx vitest run src/browser.test.ts — 17 tests pass

@jackwener jackwener changed the title refactor: deduplicate transient error checks, cache VM contexts, expose tab ID refactor: src cleanup — deduplicate errors, cache VM, extract BasePage, remove Playwright MCP legacy Apr 1, 2026
…se tab ID

- Extract shared isTransientBrowserError() into browser/errors.ts, replacing
  duplicated string-matching lists in daemon-client.ts and pipeline/executor.ts
- Cache compiled vm.Script objects in template.ts with LRU eviction (max 256),
  avoiding per-invocation VM context creation in pipeline loops
- Add getActiveTabId() to IPage interface and Page class for tab state inspection
… CDPPage

Both Page (daemon-backed) and CDPPage (direct CDP) had ~200 lines of
identical DOM helper implementations (click, type, scroll, wait, snapshot,
interceptor, etc). Extract shared logic into abstract BasePage class.
Subclasses now only implement transport-specific methods.
…rences

The file browser/mcp.ts contained BrowserBridge (daemon session manager),
not MCP functionality. Renamed to bridge.ts for clarity. Also removed all
stale "Playwright MCP" references from comments and variable names across
the codebase — Playwright was removed long ago.
@jackwener jackwener force-pushed the refactor/src-cleanup branch from dc9c798 to fdaaea3 Compare April 1, 2026 16:31
@jackwener jackwener merged commit f88e756 into main Apr 1, 2026
13 checks passed
@jackwener jackwener deleted the refactor/src-cleanup branch April 1, 2026 16:51
@jackwener jackwener mentioned this pull request Apr 2, 2026
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