Repository navigation
Isolate automation previews from task delivery - #295
Conversation
Reuse one process-owned page server across the browser harness, render gates, and live automation previews while leaving standing reader services durable. Match Codex delivery retries by stable event identity so recreated preview paths cannot suppress new events.
leaf-agent
left a comment
There was a problem hiding this comment.
Two things, both about what the PR says rather than what the code does — I traced the server lifetime, the watcher control flow, and the mode-reuse refusals and they hold together. TemporaryPageServer.close() is also a quiet improvement on what it replaces: every ephemeral server in the old code called shutdown() without server_close(), so each one leaked its listening socket.
Three files of unrelated work ride in the merge commit. skills/leaf/packages/default/theme.css, skills/leaf/packages/default/widgets/lf-options-addition.js, and tests/test_render_options_addition.py differ from both parents of 3100c05f — they exist in neither b061c49d nor 56c5663c, so they were authored inside "Merge main into codex/isolate-preview-delivery". Reproduce with comm -23 over git diff --name-only 56c5663c 3100c05f and the branch commit's own file list. The change itself is a user-visible one: the Add button in lf-another now disappears (visibility: hidden via data-lf-empty) while the field is empty, and #sync() pulls focus back to the input when the button it was on goes away. Nothing in the title, the body, or b061c49d's message mentions it, and git log --no-merges — the ordinary way to read a branch's own work — doesn't show it. Root CLAUDE.md asks for "the smallest artifact that proves it… One sentence and an lf-shot before/after is the usual artifact for a static change"; there's neither. I'd move those three files to their own PR with that artifact, or at minimum say in the body what changed and why.
The README now points a human at the mode built to keep their gestures out of delivery. The sentence two lines above still promotes scripts/preview.py triage-board as the preview "with the real agent loop behind it, preserving reader feedback across edits", and this PR's own skill text says to "use the reader preview's distinct page when presenting a URL for feedback". An --automation page takes no claim, so a reader who follows the README to look at the feature gallery and leaves a comment has it sit in .tmp/previews/feature-gallery-automation/events.jsonl with nothing watching. The edit also drops the fact the old sentence carried — that the gallery is a developer playground kept out of the public catalog — and replaces it with a statement about the server instead. --automation is already documented where its readers are: scripts/CLAUDE.md, developing-with-leaf, and ui-sweep.
Summary
Browser automation needs Leaf's real HTTP and event-log boundary without turning its gestures into feedback for the current task. This change makes that process-owned lifetime a shared runtime primitive instead of test-only server wiring.
TemporaryPageServerand use it from browser fixtures, exact-version render previews, andleaf server run --temporary.scripts/preview.py --automationto the existing live-reloading preview watcher. It preserves the page and URL across source/runtime reloads but creates no claim or durableservice.json.Verification
uv run pre-commit run --all-filesuv run pytest tests— 863 passeduv run pytest tests/test_render_export.py --run-nightly -k preview_watches_runtime_and_source_without_losing_reader_state— 3 consecutive passes