Repository navigation
Hold a page arriving until an off-screen block sample takes its height - #6783
Conversation
A block live sample that starts just out of view, as the feature gallery's "delivery status without a rail" does once a state scrolls past it, stood at its 32rem loading height when the page first read as ready, and shrank to its page's height (552px to 309px for that sample) 100-200 ms later. `leaf-dev stills` captured the taller side in one arm and reported the whole frame changed: four of the seven stills that differed on #6715, and two of four states on identical arms in each engine here. Three gaps let a reader read ready before the frame had its height: - The sample's host counted what the child document does after loading only while its frame is on screen (#6558), since in Chromium a frame off screen gets no rendering and a chart waits on one. But a block frame takes its document's height, which moves the containing page's boxes wherever the frame stands, and most documents arrive with no rendering: a board and a diff both did, off screen, in Chromium and Firefox. The host now counts a block's document until it arrives wherever its frame stands. A 20 s deadline ends that wait for a document that waits on a rendering it won't get, so a chart sample off screen in Chromium reads ready after 20 s rather than never. A window sample's frame keeps its own height, so it counts as before. - The child sent its height as it upgraded and then only through a ResizeObserver, which Chromium doesn't deliver off screen, so a page whose recorded history changes its height after upgrading stayed at the upgrade's height (381px for a page of 326px). The child now reads its height again as it arrives and sends it before `arrived`. - `leaf-dev`'s `settle` read readiness right after a state's scroll, before the rendering update in which the near observer reports the sample, so in Chromium the sample started after `settle` returned. It now lets that update pass before each read, after the input and again after the motion `pageSettled` waits out. Measured on 2026-11-22, Playwright 1.65.2: an opaque frame 300 px below the window ran 600 animation frames in 5 s in Firefox 159.0 and none in Chromium 159.0.8154.6. Arrival off screen at load average 28-117: a board or a diff within 100-500 ms of its frame's load; a chart up to 1.6 s in Firefox (its plotting library loading) and never in Chromium. The deadline is ten times the longest. Checked: with this change on both arms, the four gallery states that shifted (native-code, screenshot-comparison, screenshot-pair, screenshot-pixels) read unchanged in all 7 runs per engine, the last 2 on this commit; main against itself shifted two of them in one of two runs per engine. Tests: a browser test holds an off-screen block sample's registry, checks the page reads arriving rather than ready, then that the ready page shows the frame at the height its page arrived at, a board whose recorded moves shorten it (fails on main: readiness None, and 381 vs 326 without the child's change); the off-screen chart journey gains a block chart sample, which the page reads ready without and a check then shows.
leaf-agent
left a comment
There was a problem hiding this comment.
The 20 s deadline also lands on leaf page check --render, which is in the agent's edit-and-check loop, not only on stills and tests. In the render gate (render_gate/scheme.py and render_gate/page_code.py), start_near_work calls startNearWork and then wait_until_ready. On base, a block sample whose page waits on a rendering, such as a chart below the fold, was marked data-lf-unseen right away, so the check scrolled it into view and moved on. With this change its host keeps the page arriving until SIZING_MS passes, so each gate pass that opens the page waits 20 s before it reads anything. The chart journey going from a few seconds to about 28 s is this same path. No page in examples/ has such a sample yet, but a chart inside a live sample is an ordinary thing for an author to write, and the agent would pay this on every check of that page. The inline comment suggests a narrow way to keep the deadline for readers that don't scroll frames into view while giving the check its old speed back.
A check that reads every document (`start_near_work`) brings each frame the page stopped counting into view itself, so once it has asked, the wait for an off-screen block sample's height only delayed it: a block chart sample held each `page check --render` pass for the 20 s deadline. The host now drops that wait when the check asks and marks the frame for it at once. A new browser test checks the page reads ready, with the frame marked, as soon as the check asks (it reads "arrived" without this change).
# Conflicts: # dev/leaf_dev/browser.py
…6808) A live sample the reader sees as it starts holds what showed it until its frame fits the sample's page: the containing page's presentation, for a frame seen as it mounts, or the landing of the jump that brought it into view. In Chromium a sample's page gets no rendering while its frame is off screen, so a child holding a chart never upgrades there, and a reader who scrolled past the frame while it loaded held the page until they scrolled back. On main, a page whose first screen held a chart sample never presented (readiness stuck at "upgraded" 23 s after the child loaded), so its keys stayed dead; one reached by a jump kept an arrival outstanding and its rendering unsettled. The hold now also ends once the frame's growth would move nothing the reader sees (`whenNone` over `growthIsSeen`); the host keeps counting the child's arrival by its own rules (`sample.js`, #6783). To weigh: - `whenNone`, which `heldGrowth` already uses inside the runtime, joins the package API, documented beside `heldGrowth`. `heldGrowth` can't end this hold, since before the page presents it applies at once. - A frame clipped sideways, as by a horizontal scroller, still counts as seen (`growthIsSeen` reads only the vertical band), so its hold still waits in Chromium, as on main. - A reader who jumps to a sample, away and back before its page loads no longer has the second jump own the fit (the shift watch would report the fit as moving without input; the pixels move as on main). A version that re-decided ownership on return needed a watch per near-reading, Reset and disconnect, and Codex found four defects in it, so it isn't here. Found by Codex reviewing #6783, as an existing defect; Codex reviewed this fix in two rounds. Tests: a new journey test holds both children's registries while it checks that the page presents and settles; it fails on main (no presentation within 120 s) and passes in Chromium and Firefox. The sample hosting, shift-watch jump and live-sample tests, `pnpm run test:runtime` and `pnpm run check:browser` pass. > _This was written by Claude Code on behalf of max-sixty_
…vent that ends its input (#6798) `leaf-dev stills` reported states as changed when both arms ran the same commit, each state for a cause of its own. Each is fixed where it arises: - retained-quote pressed inside its live sample before the sample's page had started, so Playwright retried, and each retry scrolled by a different amount. The state now waits for the sample first. - A thread view named its quote with a random id, and stills keys styles by id, so every state with an open thread read as restyled. `thread-card.js` now numbers views in drawing order, since one thread can show in two views at once. - Three hover states were captured on either side of the preview's 200 ms delay. They now wait for the preview, which is what a resting pointer gets. - States that press Tab for keyboard focus styling placed focus before the runtime's Tab step had ended, so the focused control's preview opened in some runs (panel-leaf in 5 of 10). A `keyboard_modality` helper now waits for that step, in 12 states. - gallery-theme scrolled before a margin layout pass that closing its disclosure queues. - After the screenshot's style on the root, Chromium can report an auto margin as 0px though the box hasn't moved. Stills now reads styles before it takes the screenshot. The flake that started this, the chart states' scroll offset, was fixed in the runtime by #6783, which landed meanwhile, so this branch takes main's `settle`. With it, chart-preview, chart-point-aim, gallery-metrics and six of the fixed states drew unchanged stills in two runs on identical arms, and each fix's own reruns match across runs. Max asked for the chart flake to be fixed, as a follow-up to #6771; these are the other flakes the survey for it found. `dev/tests/model/test_stills.py` and the thread-quote tests in `tests/browser/threads/test_targets.py` and `tests/browser/test_render_floating_panel.py` pass. > _This was written by Claude Code on behalf of max-sixty_
A block live sample that starts just out of view stood at its 32rem loading height when the page first read as ready, and shrank to its page's height 100–200 ms later. On the feature gallery,
#bg-margin-layer-statusdrops from 552px to 309px, soleaf-dev stillscaught the taller side in one arm and reported the whole frame changed: four of the seven stills that differed on #6715, and two of four states on identical arms in each engine here. With this change on both arms, those four states read unchanged in all 7 runs per engine.Three gaps closed, each needed:
sample.js): a block's document now counts toward the page's arrival wherever its frame stands, until it arrives, since the frame takes its height. Before, it counted only while the frame was on screen (Keep a page ready while a chart sample is out of view, and show a check every waiting sample #6558). A window sample's frame keeps its own height, so it counts as before, and so does a block once a check asks for all near work, sincestart_near_workthen brings the frame into view itself.sample-child.js): it reads its height again as it arrives. Chromium delivers no ResizeObserver change off screen, so a page whose recorded history changes its height after upgrading kept the upgrade's height (381px for a page of 326px).settle(leaf-dev): it lets one rendering update pass before reading readiness, after the input and again after the motionpageSettledwaits out. In Chromium the near observer reports a scrolled-to sample only in that update.To weigh: Chromium gives an off-screen opaque frame no rendering (0 animation frames in 5 s; Firefox ran 600), so a block sample whose page waits on a rendering, such as a chart, never arrives there. A 20 s deadline ends that wait, so
leaf-dev stillsandproberead such a page as ready after 20 s rather than never, with the frame still at its loading height;page check --renderdoesn't wait. No page inexamples/ordocs/has one; the chart journey test, which covers the deadline, now takes about 28 s.Asked for by Max as "fix" on a question in the theme session's Leaf page. Reviewed by a fresh Claude agent (two rounds), Codex and the automated review; the fixes for their findings are in.
Tests: two new browser tests, one failing on main (readiness
None, and 381 vs 326 without the child's change), the other checking a check's near-work ask ends the wait; the off-screen chart journey gains a block chart sample. The hosting, frame-visibility and sample-delivery tests,pnpm run test:runtimeandpnpm run check:browserpass.