Skip to content

Claude/playwright chrome devtools e6 jaz#14

Merged
a5m0 merged 5 commits intomainfrom
claude/playwright-chrome-devtools-e6JAZ
Feb 24, 2026
Merged

Claude/playwright chrome devtools e6 jaz#14
a5m0 merged 5 commits intomainfrom
claude/playwright-chrome-devtools-e6JAZ

Conversation

@a5m0
Copy link
Owner

@a5m0 a5m0 commented Feb 24, 2026

No description provided.

Introduces a start/stop/status lifecycle script and Python helpers for
connecting to a long-running Chrome instance via CDP (connect_over_cdp),
eliminating the need to launch a fresh browser on every script run.

New files:
- scripts/chrome-instance.sh — start/stop/status a managed Chrome with
  --remote-debugging-port; discovers the patchright Chrome binary first,
  falls back to system Chrome; persists profile in ~/.patchright-session
- skills/playwright-skill/lib/persistent_session.py — three helpers:
  is_persistent_session_running(), get_persistent_session_info(),
  connect_to_persistent_session(p, port, host)

Changes:
- helpers.py: re-exports the three persistent session helpers in __all__
- run.py: _needs_auto_browser() returns False for connect_to_persistent_session
  so the auto-wrapper doesn't fight CDP connect; manual-mode template now
  imports the persistent session helpers so they work in inline snippets
- SKILL.md: new "Persistent Chrome Session" section with lifecycle commands,
  inline and file-based usage patterns, and a use-case table

https://claude.ai/code/session_01HtfxjQtNxaKih4oe5Mr4bb
…er.py

The script now follows the same display handling as get_browser_config():
- Local env with DISPLAY set: headed browser (visible window)
- Remote env (CLAUDE_CODE_REMOTE=true) without display: starts Xvfb on a
  free display number, exports DISPLAY so Chrome inherits it (headed via
  virtual display, better for anti-bot evasion)
- No display + Xvfb unavailable: falls back to --headless=new

Also tracks Xvfb PID in /tmp/patchright-xvfb.pid so `stop` cleans up
the virtual display alongside Chrome, and `status` reports Xvfb state.

https://claude.ai/code/session_01HtfxjQtNxaKih4oe5Mr4bb
Chrome refuses to start without --no-sandbox when running as root
(common in containers and Claude Code web sessions). Mirrors the same
args already used in helpers.py launch_browser().

https://claude.ai/code/session_01HtfxjQtNxaKih4oe5Mr4bb
In CLAUDE_CODE_REMOTE=true environments, Chrome now starts with the same
proxy authentication wrapper used by get_browser_config(), enabling
external site access from the persistent session.

New file:
- scripts/proxy-daemon.py — starts lib/proxy_wrapper.py as a persistent
  Python process, writes the assigned port to /tmp/patchright-proxy-port,
  blocks until SIGTERM. Resolves skill dir relative to scripts/ so it
  works from any working directory.

chrome-instance.sh changes:
- setup_proxy(): starts proxy-daemon.py when CLAUDE_CODE_REMOTE=true and
  HTTPS_PROXY is set; reuses existing daemon if already running; passes
  --proxy-server, --ignore-certificate-errors flags to Chrome
- cmd_stop(): kills proxy daemon and cleans up port file alongside Chrome/Xvfb
- cmd_status(): shows proxy PID and port in status output
- usage(): documents HTTPS_PROXY env var

Chrome's built-in behaviour always bypasses --proxy-server for localhost
and 127.0.0.1, so dev server testing continues to work without any
additional configuration.

https://claude.ai/code/session_01HtfxjQtNxaKih4oe5Mr4bb
1. Signal-handler race fix (proxy-daemon.py)
   Register SIGTERM/SIGINT handlers before writing the port file so a
   signal arriving during startup triggers clean shutdown and port file
   removal rather than leaving a stale file behind.

2. Separate proxy log file (chrome-instance.sh)
   Introduce PROXY_LOG_FILE=/tmp/patchright-proxy.log so proxy daemon
   output is no longer interleaved with Chrome output in LOG_FILE.
   Update the failure message and status output to reference the new
   file, making proxy startup failures easier to diagnose.
   setup_proxy failure now exits with a clear message instead of
   silently falling through under set -e.

3. Comment on --ignore-certificate-errors (chrome-instance.sh)
   Explain that the proxy wrapper uses CONNECT tunneling (not SSL
   interception) so Chrome sees real server certs; the flags are
   included to match get_browser_config() and guard against corporate
   MITM proxies that do return their own cert.

https://claude.ai/code/session_01HtfxjQtNxaKih4oe5Mr4bb
@a5m0 a5m0 merged commit 689b440 into main Feb 24, 2026
1 check passed
@a5m0 a5m0 deleted the claude/playwright-chrome-devtools-e6JAZ branch February 24, 2026 05:57
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.

2 participants