Repository navigation
fix(claude-code): patch playwright MCP on every session start (#98) - #99
Merged
Merged
Conversation
Wires patch-playwright-mcp as a Claude Code SessionStart hook via image-baked managed settings. Closes the mid-container-run gap where the playwright plugin auto-updates after postStartCommand fires, leaving newly extracted cache dirs pointing at the missing /opt/google/chrome/chrome binary until the next container start. postCreateCommand and postStartCommand wiring stays as defense-in-depth.
2 of 3 tasks
gatezh
added a commit
that referenced
this pull request
May 13, 2026
…pping (#100) The verify-command added in #99 embedded literal " around the expected path inside a single-quoted jq filter. After GHA expansion into bash -c "...", the inner " terminated and reopened the outer "..." rather than reaching jq as a string delimiter, so jq received .hooks.SessionStart[0].hooks[0].command == /usr/local/bin/patch-playwright-mcp and failed with "unexpected '/'". Switch to the printenv | grep -qx idiom used since #93: jq -r prints the bare string value, grep -qx asserts an exact match. No literal " inside the matrix value, so the value survives both the YAML decode and the bash -c wrapping unchanged.
4 of 5 tasks
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.
What
Wires
patch-playwright-mcpas a Claude CodeSessionStarthook via an image-baked/etc/claude-code/managed-settings.json, so the patch runs before any MCP launches in every new or resumed session — not just at container start.Why
Closes #98. The playwright plugin can auto-update mid-container-run, extracting a fresh cache dir whose
.mcp.jsondefaults to--browser chromeand points at/opt/google/chrome/chrome(not shipped in this image). ExistingpostCreateCommand/postStartCommandwiring only patches cache dirs that exist at the moment they run — anything created later stays broken until the next container restart, producing:SessionStartis the canonical Claude Code hook for "run before the first prompt of every session" and is documented to run synchronously before the model receives input, so by the time MCP launches the patched.mcp.jsonis already on disk.The settings file lives at the Linux managed-settings path (
/etc/claude-code/managed-settings.json) so it has highest precedence, sits outside the/home/node/.claudenamed volume, and survives volume re-creation across container rebuilds.Changes
claude-code/.devcontainer/managed-settings.json—SessionStarthook entry invoking/usr/local/bin/patch-playwright-mcpon all session sources (startup, resume, clear, compact). Matcher omitted; the patch is idempotent and ~20 ms.claude-code/.devcontainer/Dockerfile—COPYthe new file to/etc/claude-code/managed-settings.jsonfor both default and sandbox targets (sharedbasestage)..github/workflows/build-claude-code.yml— extend the build triggerpaths:filter to pick upmanaged-settings.json; add ajq -eassertion to the verify matrix on all four target × arch combinations confirming the hook is actually present in the published image.claude-code/.devcontainer/devcontainer.json+claude-sandbox/devcontainer.json+init-plugins.sh— update comments to describepostCreateCommand/postStartCommandas defense in depth alongside the new hook, and add issue [BUG] patch-playwright-mcp misses mid-session plugin cache updates #98 cross-references.Notes
patch-playwright-mcpwas already idempotent and looped over every cache dir; this PR only adds a third invocation cadence.latestrebuild; downstream projects pick it up on next image pull.SessionStarthook schema and stdin payload percode.claude.com/docs/en/hooks.code.claude.com/docs/en/settings.--browser chromium,--executable-path,--no-sandbox,--headlessflags valid in@playwright/mcpv0.0.75 (README + upstream DockerfileENTRYPOINT).Test plan
jqparse ofmanaged-settings.jsonsucceeds and verify-command predicate evaluatestruelocally.hadolintclean on modified Dockerfile (against.hadolint.yaml).actionlintclean on modified workflow.jq -everify assertion passes on all four target × arch combinations..mcp.jsonmtimes update at every session start (not just container start), and confirmmcp__plugin_playwright_playwright__*tools work after a mid-session plugin auto-update.Closes #98.