Repository navigation
Skip the Leaves tray paint when its element has left the document - #850
Conversation
Baking a copy removes `.lf-chrome` from the live page while that page's state stream is still running, so a read landing before the tab closes reached a detached `LiveLeavesList`. `present` threw for the handle its own `disconnectedCallback` had dropped, and the throw came back out of the whole state application: the page reported `State presentation failed` and `read failed`, both naming a tray it no longer had. `presentLeaves` now returns without presenting when the list is not connected — the rule `tickClock` already states for clock-driven paints, applied to the one caller that paints directly — and `renderOthers` is clocked on the list rather than on `document.body`, which never leaves. `test_a_state_read_outlives_the_chrome_the_copy_takes_out` takes the chrome out directly and provokes a read, so the gap is the arrangement rather than the machine's load.
leaf-agent
left a comment
There was a problem hiding this comment.
The runtime change reproduces and the guard holds: against the unchanged live-leaves.js the new test fails with exactly the production pair — State presentation failed: Leaves presentation needs its connected tray / read failed: …, repeated per read — and passes with it. presentation.ts's disconnect retires the region's barrier member, so skipping the present leaves nothing claimed and whenDocumentPresented still settles.
One thing to change: tests/test_render_export.py carries pytestmark = pytest.mark.nightly, so the regression this fix exists for is pinned only in the nightly selection. The test arranges the gap itself — it removes .lf-chrome and appends a command, with no export machinery in it — which makes it a shared-chrome contract rather than an export one, and tests/CLAUDE.md puts those in the everyday gate: "the shared chrome contracts whose regressions must block a pull request". Left where it is, a later change to presentLeaves that drops the guard lands on main and comes back as an occasional nightly error — the loop this PR closes.
tests/test_chrome_contracts.py is that gate's home and already has everything the case needs: open_page, told and serve from render_harness, and render_cases_interaction, where REPORT_PAGE lives. I'll push the move.
test_a_state_read_outlives_the_chrome_the_copy_takes_out arranges the gap itself — it removes `.lf-chrome` and appends a command, with no export machinery in it — so it is a shared chrome contract rather than an export one. `tests/test_render_export.py` carries `pytestmark = pytest.mark.nightly`, which left the guard this branch adds pinned only in the nightly selection: a later change dropping it would reach main and come back as the same occasional error. `tests/test_chrome_contracts.py` is where tests/CLAUDE.md puts the chrome contracts whose regressions must block a pull request.
|
That run's seven failures are the same node ids as run 35430767109's, and
Both routes end at the same |
|
The three occurrences span three separate commits, and the number of reads that land in the gap varies with them — the pair twice over on 767e36c2; two export tests, This branch's own checks are green at its head ( |
nightlyonmainfailed at 767e36c2 with seven failures and one error. #847 has since landed the seven; this is the error, which #847 does not reach. The Leaves tray throws when a state read finds it gone from the document, and the throw comes back out of the whole state application, so a page reportsState presentation failedfor chrome it no longer has.What happens
bake()takes the copy by removing.lf-chromefrom the live page (standalone.js), and that page's state stream goes on running untilexport_pagecloses the tab. A read that lands in the gap reachesrenderOthers→presentLeaves→LiveLeavesList.present, which throwsLeaves presentation needs its connected trayfor the handle its owndisconnectedCallbackhas already dropped.state-application.jscatches it, reportsState presentation failed: …, and rethrows, so the read reports again asread failed: …— the pair, twice over, that the run recorded:Whether a read lands in that gap is a matter of the machine's load, which is why this arrives as an occasional error on a copy that is itself correct: alone it passes, and it reproduced once on
a6c73f3din a seven-case selection and not in two repeats of the same selection.What changes
A tray that has left the document has no region to present into, so
presentLeavesreturns without presenting. That is the rule the runtime already states for clock-driven paints —tickClockculls an entry whoseowner.isConnectedis false — applied to the one caller that paints directly.renderOthersis clocked on the list rather than ondocument.bodyfor the same reason: the body never leaves, so a clock owned by it would go on repainting a tray that has.The rule is stated in Standalone copies and print in
skills/leaf/assets/CLAUDE.md, beside what else baking takes off the live page, because the next chrome paint added here faces the same gap.Verification
test_a_state_read_outlives_the_chrome_the_copy_takes_outtakes.lf-chromeout directly and provokes a read, so the gap is the arrangement rather than the weather. Against the unchanged runtime it fails with exactly the production text; with the change it passes. It sits intests/test_chrome_contracts.pyrather than beside the copy tests: it arranges the gap without any export machinery, so it is one of the shared chrome contracts the everyday gate holds, and a later change dropping the guard is caught on the pull request rather than on main's nightly.Suite run
uv run pytest tests --run-nightly -n 3is green apart from failures this sandbox owns and that reproduce on the unmodified tree: fourtest_render_commandscases and twotest_render_exportcases where the installed Chrome will not launch here,test_staged_writes_honor_umask_without_copying_a_replaced_symlink_mode, and the demo recorder.tests/test_interact_session.py,tests/test_website_server.pyandtests/test_live_shell_artifact.pyare deselected: the first two need a writable/tmp, which the agent sandbox mounts read-only, and the third needsworker/node_modules.