Repository navigation
Kill the check's browser instead of closing it, and stop drawing thread markup before posting - #1691
Merged
Merged
Conversation
…ad markup before posting #1562 put a browser run on two everyday paths: plain `page check` on any page with a data widget, and every `thread open`/`thread reply` whose `--markup` held one. With the installed Chrome each run took about 6s, of which about 4s was Chrome's graceful shutdown. ## What changes - **The browser is killed rather than closed.** `ending` (`render_gate/browser.py`) reads the browser's pid over CDP on entry and kills its process group on exit; Playwright starts the browser as a group leader, so the group is the browser and every process it started. A graceful close saved nothing: the profile is Playwright's throwaway one, which it removes once the process exits. The gate (`in_browser`) and `leaf-dev`'s `chrome()` both end their browser this way, so `--render` and `package check --render` gain too. - **Thread markup is no longer drawn before it posts.** `run_markup`, `message_code_check` and `message_page` are gone, and `check_markup`/`message_markup_error` are back to one gate under the page lock. A chart whose body doesn't draw now posts, and reports to the agent as an `error` event (naming the widget) when the user opens its thread, the same channel a browserless host already relied on. A broken message doesn't fail later `page check` runs: the thread is shut there, so its chart never draws. | | before | after | |---|---|---| | plain `page check`, page with a chart (Chrome) | ~5.9s | ~1.3s | | `thread open --markup` with a chart | ~5.6s | ~0.15s | | page or reply without one | ~0.15s | ~0.15s | Measured on macOS with the installed Chrome, three runs each. ## Docs and tests `threads.md` tells the agent a broken widget in its reply reaches it as an `error` event, to be answered with a corrected reply. `validation.md` and `scripts/AGENTS.md` follow. `test_a_message_is_refused_where_its_widget_would_fail` becomes `test_a_widget_that_fails_in_a_message_reports_when_its_thread_draws`: the bad chart posts with no browser asked for, and opening its thread puts `<lf-chart id="t-bad"> failed: …` in the log. `TODO.md` gains an item to decide what plain `page check` runs from measured agent mistakes: eval cases per widget kind, then run what agents get wrong and stop running what they get right. No `evals/` case covers the `threads.md` sentence; it restores the pre-#1562 behaviour and says how the failure now arrives. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Oct 3, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 20, 2026
…3355) On macOS, every launch of Google-signed Chrome runs a Secure Enclave self-test that creates two keychain keys and deletes them when it finishes. A Chrome that ends first leaves both behind, and nothing ever collects them. Every leaked key makes each later keychain read in Chrome slower. Since #1691, `ending()` has SIGKILLed the browser's process group after each render gate run, because installed Chrome's graceful close took about 4 s. That slow close was itself caused by leaked keys, so the kill fed the cost it was avoiding. One Mac reached about 27k keys, which kept `secd` at 50–70% CPU. **Close gracefully.** `ending()` is gone, and every browser closes through Playwright's own context manager. The headless shell, Chrome for Testing and Firefox close in 0.02–0.3 s, so dropping the kill costs nothing there: `page check --render` on the shell takes 5.2–5.6 s either way. Installed Chrome 157 (Stable 2026-11-03) delays the self-test by 45 s and runs it on only 1 Mac Stable launch in 64, so short checks will stop creating keys once users update. Until then, on a Mac whose keychain is already bloated, a check with installed Chrome can take up to about 10 s to close. **Dev evals on Chrome for Testing.** `eval-ui-review`, the ui-review-detection provider and the arrangement eval's judge now launch Chrome for Testing, which has no keychain entitlement, instead of installed Chrome. It is a full Chrome build, so unlike the headless shell it still reports the autofill layer's form issues. `eval-ui-review` needs its screenshots and the model's live tool to come from one build, but the Python (1.63) and Node (1.64) Playwright pins resolved different Chromium builds. So the Python lock moves to Playwright 1.64.0. Both sides now launch Chrome for Testing 156, and the suite's headless shell moves from 153 to the same build. `leaf-dev setup` installs the full Chromium build beside the shell, about 360 MB more per fresh setup. It still installs branded Chrome, because the render gate's default-channel journey test launches it on purpose. Tested locally on macOS: the pre-merge selection (1,912 passed), and Chrome for Testing launched from both Node and Python Playwright, including through the judge's `playwright-cli --browser=chromium`. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Oct 25, 2026
…e check misses (#3923) This settles two measurement items in `TODO.md` ("Decide what plain `page check` runs in a browser from the mistakes agents make" and "Read the full render gate after handover") with new evals, and acts on what they found. The studies, with commands to reproduce, are in `notes/agent-usability-evals.md`, "Widgets plain page check doesn't run, 2026-10-24" and "Render findings after handover, 2026-10-24". ## What agents get wrong in widgets plain `page check` skips `evals/widgets-draw-as-written` has authors write playgrounds, a text document, a visual review, and a chart and a Mermaid diagram inside a thread message; `dev/leaf_dev/draw_failures.py` grades what failed to draw from the final `--render` and every check the author ran. Over Claude Code (Opus 5.5) and Codex (Sol 6.1) authors: - Playgrounds, text documents and visual reviews: 0 of 104 failed to draw, including harder variants (0–4%). - A chart in a thread message: 0 of 16. - A Mermaid diagram in a thread message: 5 of 6 Codex messages didn't draw (44–97%), each from a `;` inside a loop label or note; 0 of 10 Claude Code messages. So plain `page check` keeps its rule. The failures are in thread messages, which nothing drew before posting: - **`thread create` and `thread reply` now draw a message holding a chart, diagram, page widget or media widget in a browser before posting, and refuse it if it fails** (`thread.py`). This reverses #1691's decision for those messages only; `validation.md` and `threads.md` say so. The run leaves out the message's scripts, since the thread inserts markup through `template.innerHTML`, which runs none of them. Reposting all 32 eval messages refused exactly the 5 broken ones, at 1.3–1.9 s each. Beside the merge base, Codex diagram failures went from 4 of 8 to 0 of 8, with 7 of 8 authors refused once and fixing it. - **Charts drawn at NaN are left to #3956.** 5 of 10 Claude Code dashboards first drew labels at NaN, each from a function passed to Plot's constant `dy`, which plain check passed because the runtime reported nothing. #3956, merged since, refuses such a mark before Plot draws it and names the option, so plain check, `--render` and `leaf wait` all hear it. This branch's after-draw NaN scan covered no case that refusal misses, so the merge with `main` dropped it; the notes say which mechanism hears the mistake. - **A Codex author's own `page check` runs now reach the eval's check log** (they went through Codex's MCP tool and were lost), so the 2026-10-20 study's Codex "author's own checks" figures likely undercount. ## Render findings after handover `page check --render` takes a median 7.0 s on the 17 catalog examples (5.3–11.6 s, load 6–10) and 7.7 s on 70 eval pages; plain check takes 0.2–1 s. `document/render-after-handover` and its `-quick` variant run `--render` after the agent hands over and post what plain check missed as the page's `error` event. Over 60 sessions: - Without the usual "use headless browser tooling" line, 8 of 20 agents skipped `--render` before handing over a one-line edit, saving about 40 s. - Of 21 sessions that got findings after handover, 20 fixed the page and re-ran `--render` in the same turn, about 35 s after delivery. - Under the `error` event's "fix the failure the user saw", agents also changed the page for every piece of advice (11 of 11). A trial clause separating failures from advice (not committed) kept all 10 failures fixed while Claude Code left the advice alone in 4 of 5. The TODO item now recommends building the server-side pass with its own handling clause; nothing here builds it. ## Checks Model tests around threads, markup and the render gate, two process tests and five browser and journey tests touching markup pass; each new test fails on the old code. Timings were taken on a shared Mac at load 6–39. After the merge with `main`: `test_a_widget_that_fails_in_a_message_is_refused_where_a_browser_draws_it`, the model tests that post widget markup in `test_interact_product.py` (with the new `test_a_reply_drawn_before_posting_runs_no_script_its_thread_would_not`, which fails with the script stripping disabled), and `tests/model/test_render_gate.py` pass. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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.
#1562 put a browser run on two everyday paths: plain
page checkon any page with a data widget, and everythread open/thread replywhose--markupheld one. With the installed Chrome each run took about 6s, of which about 4s was Chrome's graceful shutdown.What changes
ending(render_gate/browser.py) reads the browser's pid over CDP on entry and kills its process group on exit; Playwright starts the browser as a group leader, so the group is the browser and every process it started. A graceful close saved nothing: the profile is Playwright's throwaway one, which it removes once the process exits. The gate (in_browser) andleaf-dev'schrome()both end their browser this way, so--renderandpackage check --rendergain too.run_markup,message_code_checkandmessage_pageare gone, andcheck_markup/message_markup_errorare back to one gate under the page lock. A chart whose body doesn't draw now posts, and reports to the agent as anerrorevent (naming the widget) when the user opens its thread, the same channel a browserless host already relied on. A broken message doesn't fail laterpage checkruns: the thread is shut there, so its chart never draws.page check, page with a chart (Chrome)thread open --markupwith a chartMeasured on macOS with the installed Chrome, three runs each.
Docs and tests
threads.mdtells the agent a broken widget in its reply reaches it as anerrorevent, to be answered with a corrected reply.validation.mdandscripts/AGENTS.mdfollow.test_a_message_is_refused_where_its_widget_would_failbecomestest_a_widget_that_fails_in_a_message_reports_when_its_thread_draws: the bad chart posts with no browser asked for, and opening its thread puts<lf-chart id="t-bad"> failed: …in the log.TODO.mdgains an item to decide what plainpage checkruns from measured agent mistakes: eval cases per widget kind, then run what agents get wrong and stop running what they get right.No
evals/case covers thethreads.mdsentence; it restores the pre-#1562 behaviour and says how the failure now arrives.