43 Commits

Author SHA1 Message Date
Tommy D. Rossi 6224a0f374 fix: render ghost cursor as inline SVG instead of a data URL background
The ghost cursor painted its arrow with
`background-image: url("data:image/svg+xml;base64,…")`. Pages with a
strict `img-src` CSP refuse to load that URL, so on Hacker News every
navigation logged a CSP violation and the cursor rendered as an empty
box.

Changes:

- `setInnerSvg()` parses the markup with `DOMParser`, validates the root
  is a real SVG element, imports it into the document, and appends it to
  the cursor. No image URL is involved, so no `img-src` rule applies.
- The generated cursor module now exports raw SVG markup
  (`pointer-macos-tahoe-svg.ts`) instead of a base64 data URL
  (`pointer-macos-tahoe-data-url.ts`). `encode-screenstudio-cursor.ts`
  writes the markup with `JSON.stringify`.
- `applyRuntimeVisualOptions()` clears previous children and resets
  `background-image` on every style switch, so toggling between
  `screenstudio`, `minimal`, and `dot` never stacks two arrows.

The always-on cursor test now asserts the injected element contains a
literal `<svg>` and no `data:image/svg` reference.

Session: ses_fe45ea8e3ffepbcZz6OQQ9sFSH
2026-08-20 16:23:03 +02:00
Tommy D. Rossi d1346e7ca4 docs: add profano CPU profiling tips to performance resource
Mention .cpuprofile recording via CDP Profiler.* commands and
profano CLI for inspecting hot functions when vitals alone are
not enough to diagnose performance issues.

Session: ses_208943d84ffenqdbjxK0cO0iak
2026-05-05 11:39:01 +02:00
Tommy D. Rossi 10790c7392 auth: drop loopback bypass, attach token from env in in-process callers
Reviewer flagged the loopback-bypass added in 0.1.5 as a full auth
bypass under the recommended remote-access topology: tunnel agents
(traforo, ngrok, cloudflared) run as local processes and forward
public traffic to localhost:19988, so every public request reaches
the relay from 127.0.0.1. The bypass made `/cli/execute` (RCE),
`/cli/session/*`, `/recording/*` (file writes via outputPath), and
`/mcp-log` callable by anyone with the public tunnel URL.

Fix
---
1. cdp-relay.ts: privilegedRouteMiddleware now requires the token on
   every request, regardless of source. Loopback bypass removed.
2. cli.ts (`serve` action): exports `process.env.PLAYWRITER_TOKEN` at
   startup so in-process callers can attach Authorization: Bearer ...
   when calling the relay's own privileged endpoints.
3. screen-recording.ts: new `recordingHeaders()` helper reads
   PLAYWRITER_TOKEN from env and attaches the Bearer header to all
   four /recording/* calls (start, stop, status, cancel). Mirrors
   what mcp.ts already does for /mcp-log.
4. cli.ts (`executeCode`): refactored the inline header-build into
   the shared `buildAuthHeaders` helper so the six /cli/* fetch
   sites stay in sync.
5. connect-cdp-demo.ts: replaced the hardcoded 'secret_token'
   fallback with a hard error so the demo can never accidentally be
   the source of a leaked credential warning.

Bumps playwriter to 0.1.6 + CHANGELOG entry. Adds a MEMORY.md note
so the next person doesn't re-introduce the bypass.

Session: ses_20d25dcc7ffeJhVK7aC8Zh7OkW
2026-05-04 17:09:28 +02:00
Tommy D. Rossi 3d6f2d4239 auth: thread token through every remote CLI command + protect /mcp-log
Builds on Ivan Leo's auth-header pass with the missing pieces needed to
actually run `playwriter serve --token` end to end against a remote relay.

Fixes
-----
1. `--token` (or PLAYWRITER_TOKEN) now plumbed through every remote
   subcommand: `session new/list/delete/reset` and `browser list`. Until
   now only `playwriter -e` sent the Bearer header, so against a token-
   protected relay every other subcommand returned 401.
2. In-process `ExecutorManager` carries `token` in its `cdpConfig`, so the
   executor's own `chromium.connectOverCDP(ws://127.0.0.1:19988/cdp/<id>)`
   call passes the relay's own auth check.
3. `/mcp-log` is now under `privilegedRouteMiddleware`. Previously open,
   so any reachable client could spam the log file.
4. `mcp.ts` `sendLogToRelayServer` sends `Authorization: Bearer …` when
   `PLAYWRITER_TOKEN` is set.
5. Loopback connections (127.0.0.1, ::1, ::ffff:127.0.0.1) bypass the
   token check on `/cli/*`, `/recording/*`, and `/mcp-log`. They can only
   originate from in-process executor code which already runs downstream
   of an authenticated `/cdp/*` WebSocket, so re-checking the token would
   mean smuggling it into every internal helper for no real security
   gain. Resolves the broken `/recording/*` calls from
   `screen-recording.ts`.
6. New `connect-cdp-demo.ts` script: minimal example showing an external
   Playwright client connecting through `/cdp/<id>?token=<token>` over a
   tunnel.

Bumps `playwriter` to 0.1.5 and updates CHANGELOG.

Co-authored-by: Ivan Leo <ivanleomk@gmail.com>

Session: ses_20d25dcc7ffeJhVK7aC8Zh7OkW
2026-05-04 14:10:42 +02:00
Tommy D. Rossi 480c1b9d64 docs: add performance profiling guide resource
Add a generated website resource that shows how to profile a real site with Playwriter using CDP, Navigation Timing, and PerformanceObserver.

The new guide focuses on the questions people actually ask during performance work: whether rendering is good or bad, which requests dominate transfer cost, what usually blocks first paint or LCP, and what is most likely blocking interactivity. It also includes ready-to-run Playwriter commands plus reusable TypeScript examples so the profiling workflow can be copied directly.

Session: ses_22252b7b8ffee2VFXqmaCzA2NR
2026-04-30 12:24:34 +02:00
Tommy D. Rossi 3dda03ea7e feat(playwriter): launch a managed browser with bundled extension
Bundle the extension into the CLI so fresh AVPS and local source checkouts can start a Playwriter-ready Chrome for Testing or Chromium without separate installation steps. Also disable the packaged welcome tab, reuse Playwright\s managed Chromium fallback, surface searched browser paths on discovery failures, and document that managed browser launches already enable the tab-capture flags needed for recording on normal web pages.
2026-03-25 21:31:47 +01:00
Tommy D. Rossi c812126ef0 Add long-running stability test script
Soak test that creates a session, opens one page, then loops for hours
executing 8 Playwright operations every 5 seconds (title, evaluate x3,
url, snapshot, locator count, goto). Tracks success/failure counts and
prints a summary on exit.

First 30-minute run: 2,272 operations, 0 failures, 100% success rate.

Usage: bun playwriter/scripts/long-running-stability-test.ts --duration 2
2026-03-21 12:30:54 +01:00
Tommy D. Rossi 5c58cac7da docs: improve recording guidance and tune cursor defaults
Clarify recording guidance to prefer interaction-driven flows (click, hover, typing) so ghost cursor motion is visible during demos.

Tune ghost cursor movement defaults for faster, human-like motion and align cursor encoder script path handling with __dirname plus path.resolve conventions.
2026-02-26 13:16:12 +01:00
Tommy D. Rossi 2b5d2fa559 feat: add ghost cursor APIs and harden reconnect flow
Introduce a first-class ghost cursor system for recordings and screenshots with namespace APIs (, ) while preserving backward-compatible top-level recording helpers.

Improve reliability after relay restarts by consolidating extension wait logic around , reducing false disconnected states during  and execute flows.

Refactor recording glue into dedicated modules (,  in ) to keep executor orchestration thin and make cursor lifecycle state explicit and testable.
2026-02-25 19:33:55 +01:00
Tommy D. Rossi f87b0243cd format 2026-02-22 15:21:38 +01:00
Tommy D. Rossi a718299b73 feat: add well-known skills discovery endpoint 2026-02-04 19:20:33 +01:00
Tommy D. Rossi 0a38084263 use unique temp entry files for bundles 2026-02-03 15:40:53 +01:00
Tommy D. Rossi 01a6622d71 use virtual entrypoints for wrapper bundles 2026-02-03 13:51:27 +01:00
Tommy D. Rossi cfd9ba8594 fix entry shit in build for client 2026-02-03 13:46:20 +01:00
Tommy D. Rossi 51704a0922 feat: add getPageMarkdown utility using Mozilla Readability
- Consolidate build scripts into single build-client-bundles.ts
- Add @mozilla/readability for Firefox Reader View content extraction
- New getPageMarkdown() utility extracts main page content as plain text
- Supports search and diff-since-last-call like other utilities
- Add test with file snapshot
2026-02-01 18:44:45 +01:00
Tommy D. Rossi a2fa91584d refactor: replace Playwright internals with in-page dom-accessibility-api
- Add a11y-client.ts: browser-side code using dom-accessibility-api (41KB)
- Single page.evaluate() call instead of multiple CDP roundtrips
- Zero element handles - everything runs in page context
- Stable refs from test IDs (data-testid, data-test-id, id) instead of e1, e2
- Add locator param to scope snapshots to subtrees
- Fixes cross-frame 'Unable to adopt element handle' error (issue #39)
2026-02-01 16:58:29 +01:00
Tommy D. Rossi 45cdc372a8 refactor: move SKILL.md to src, add playwriter skill command
- Move skills/playwriter/SKILL.md to playwriter/src/skill.md (source of truth)
- Add 'playwriter skill' CLI command to output full docs
- Make skills/playwriter/SKILL.md a lightweight stub pointing to CLI
- Generate prompt.md to dist/ instead of src/
- Strip CLI-only content from MCP prompt
2026-01-25 16:18:23 +01:00
Tommy D. Rossi b7edfb52b1 refactor: make SKILL.md source of truth, generate prompt.md from it 2026-01-24 12:21:22 +01:00
Tommy D. Rossi 18d0cdb646 Add prompt.md to website public and link in CLI help 2026-01-22 22:06:29 +01:00
Tommy D. Rossi 58dc932990 Add CLI usage instructions to playwriter skill 2026-01-22 19:31:15 +01:00
Tommy D. Rossi eea0e57a1b Generate playwriter skill for add-skill discovery 2026-01-22 19:27:55 +01:00
Tommy D. Rossi 237f24d3f8 Generate MCP resources at build time and host on playwriter.dev
- Add build-resources.ts script to generate markdown API docs
- Resources now use https://playwriter.dev/resources/*.md URLs
- Output to both playwriter/dist/ and website/public/resources/
- Simplify mcp.ts resource handlers to read pre-built files
2025-12-30 14:30:30 +01:00
Tommy D. Rossi 5e0cd2dd98 Add getReactSource to extract React component source location
- Add bippy library for React fiber introspection
- Create build-bippy.ts and build-selector-generator.ts using Bun.build
- Use CDP Runtime.evaluate instead of addScriptTag to bypass CSP
- Add getReactSource utility function exposed in MCP VMContext
- Works on local React dev servers with JSX transform (not production builds)
2025-12-29 16:11:13 +01:00
Tommy D. Rossi a4e7ce10bd move cdp-relay and protocol out of extension subfolder 2025-12-28 21:05:04 +01:00
Tommy D. Rossi db4f7ef5a5 add test for getLocatorStringForElement 2025-12-17 18:45:30 +01:00
Tommy D. Rossi 7025836f7e new script 2025-11-22 23:44:42 +01:00
Tommy D. Rossi 7c3809b1d4 better prompt 2025-11-16 14:59:28 +01:00
Tommy D. Rossi 29488aca76 nicer icons. different port 2025-11-16 11:29:35 +01:00
Tommy D. Rossi 632cac2052 Update extension-connect.ts 2025-11-16 09:45:01 +01:00
Tommy D. Rossi d5b9ce6f41 Update extension-server.ts 2025-11-15 18:55:33 +01:00
Tommy D. Rossi 06779339ae more prompts 2025-11-15 16:27:59 +01:00
Tommy D. Rossi bbda29069c add support for opening page and closing page 2025-11-15 16:04:50 +01:00
Tommy D. Rossi 1b0480c77f new page handling 2025-11-15 15:55:56 +01:00
Tommy D. Rossi 36da6a1737 format 2025-11-15 13:57:05 +01:00
Tommy D. Rossi a7a550eeb7 fix server with multiple playwrights 2025-11-15 13:37:08 +01:00
Tommy D. Rossi 1ac644d4bd new code 2025-11-15 13:06:08 +01:00
Tommy D. Rossi 6998031438 adding support for multiple tabs 2025-11-14 15:23:47 +01:00
Tommy D. Rossi cef1de124e scripts 2025-11-14 13:50:47 +01:00
Tommy D. Rossi f361b823f8 Update extension-connect.ts 2025-11-14 11:41:39 +01:00
Tommy D. Rossi 339d5d86d3 Update extension-connect.ts 2025-11-13 21:28:47 +01:00
Tommy D. Rossi 46be331120 remove need for uuids 2025-11-13 21:16:25 +01:00
Tommy D. Rossi 8e98c68de4 got it to work 2025-11-13 21:12:31 +01:00
Tommy D. Rossi a47b3bd99d simplifying shit playwright code 2025-11-13 20:37:19 +01:00