Repository navigation
Description
channel="chrome" at both user-path launches means a host with a working Chromium but no Google Chrome can neither render-check nor export. And skills/leaf/references/serving-pages.md:50 names export as the fallback for when no network route reaches the page, so that goes too.
Line numbers are read at 0de0118006f9.
Where
skills/leaf/scripts/leaf/render_gate/command.py:46skills/leaf/scripts/leaf/exporting.py:172
Both are browser = p.chromium.launch(channel="chrome"). Two more sit in scripts/ (record-demo.py:529, example-previews.py:58), and those are out of scope: no leaf command invokes them, and bin/leaf passes --no-dev, so an install never fetches the dev group they need.
Repro
Any machine or container with uv and no Google Chrome installed, from a checkout:
uv sync
uv run playwright install chromium --only-shell # a Chromium, and no Chrome
uv run leaf page init /tmp/p
uv run leaf version check /tmp/p --render
uv run leaf version stamp /tmp/p --text repro # export needs a stamped version
uv run leaf version export /tmp/p -o /tmp/out.html
Both browser commands die on the same line:
✗ render check failed — Chrome did not launch: BrowserType.launch: Chromium distribution 'chrome' is not found at /opt/google/chrome/chrome
export needs Chrome, and it didn't launch (BrowserType.launch: Chromium distribution 'chrome' is not found at /opt/google/chrome/chrome). A copy is the drawn page, so there is nothing to write without one.
Only the launch needs Chrome
Launching a Chromium by executable_path instead of channel="chrome", nothing else changed, render_version returns no failures on a leaf page: light and dark, console errors, widget size, overflow and print all pass.
The suite already relies on that. tests/conftest.py:199 launches p.chromium.launch() with no channel, so the fixture-driven browser tests run every invariant on Playwright's headless shell. Only the four tests that shell out to the real launcher — tests/test_render_commands.py:191, :228, :446, :728, the third through version export — need Chrome, which is why CI installs the headless shell alone (.github/workflows/ci.yaml:28) and leans on the runner's preinstalled Chrome for those.
channel="chrome" requires a Google Chrome release-channel install at a fixed OS path, so Chrome for Testing, a distro or Homebrew Chromium, and a self-hosted build all fail it; with no outbound network, Playwright's usual answer of downloading its own browser isn't available either. CLAUDE.md:68-69 states the policy as "browser checks launch the host's installed Chrome, and leaf does not download a browser". channel="chrome" implements it as one vendor's build at one fixed path, which is narrower than the policy needs.
Fix
Honour an explicit browser executable when the user names one; keep channel="chrome" as the default when they don't. Playwright ships no general executable-path variable to pass through, so leaf takes its own name, LEAF_BROWSER_EXECUTABLE, in the namespace host.py already uses for LEAF_AGENT and LEAF_SESSION_ID.
One helper, two callers. exporting.py already imports preview_server from leaf.render_gate.preview, so leaf/render_gate/ is the home:
# leaf/render_gate/browser.py
import os
def launch_browser(p):
"""The host's browser: whichever executable LEAF_BROWSER_EXECUTABLE names, else
the installed Chrome release channel. Raises PlaywrightError, which each gate
reports in its own words."""
if executable := os.environ.get("LEAF_BROWSER_EXECUTABLE"):
return p.chromium.launch(executable_path=executable)
return p.chromium.launch(channel="chrome")
def browser_hint() -> str:
"""The line each gate appends when the launch failed."""
if executable := os.environ.get("LEAF_BROWSER_EXECUTABLE"):
return f"LEAF_BROWSER_EXECUTABLE named {executable}."
return "LEAF_BROWSER_EXECUTABLE names one if this host has no installed Chrome."
The variable carries a path and nothing else — no args plumbing.
Both failure messages should stop naming Chrome and append browser_hint(), keeping each site's own construction of the error's first line: ✗ render check failed — no browser launched: … and export needs a browser, and none launched (…). A copy is the drawn page, so there is nothing to write without one.
Acceptance criteria
- With
LEAF_BROWSER_EXECUTABLEunset, both commands behave exactly as today. - With it set to a Chromium binary,
leaf version check <page> --renderandleaf version export <page> -o <file>both succeed where no Google Chrome is installed. - With it set to a path that isn't a browser, the failure names the variable and the value it was given, rather than "Chrome did not launch".
- Both call sites change together through the helper. Fixing only the render gate leaves the documented export fallback broken.
- The four subprocess tests (
tests/test_render_commands.py:191,:228,:446,:728) gain an arm that setsLEAF_BROWSER_EXECUTABLEto the headless shellplaywright install chromium --only-shellprovides. Each arm must set the variable explicitly rather than inherit it: they pass the ambient environment today, so a developer or CI job that exported it would silently stop covering thechromechannel those tests exist to cover. The new arm runs on the headless shell CI already installs at.github/workflows/ci.yaml:28; the existing arm still needs the runner's Chrome, which is what keeps that channel covered. - The README's Install section names Google Chrome and the override beside it. It currently asks only for "a browser on the same machine as the session" (
README.md:61), which reads as satisfied by a Chromium already on the box.
This was written by Claude Code on behalf of max-sixty
Activity