Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.