Skip to content

Stop reporting layout shifts before a page first settles - #6127

Merged
max-sixty merged 3 commits into
mainfrom
startup-shift-advice
Nov 16, 2026
Merged

max-sixty merged 3 commits into
mainfrom
startup-shift-advice

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

The render check no longer reports startup-layout-shift advice. That advice counted every layout shift Chrome recorded from navigation until the page settled. A box that changes size during load counts as a shift only if Chrome painted a frame before the change, which differs between identical loads, so the same page got the advice on some runs and not others. It was 64 of the 109 findings the background reading told agents on this machine from 10 to 15 Nov, and agents act on advice they're told.

Traced in the check's own browser, the shifts came from:

  • author <img> elements with no width and height: 4–8 of 10 runs, depending on the page;
  • Leaf's own lf-shot, which has no box until its module draws and then grows to about 720 px: 10 of 10 runs, which the author can't fix;
  • lf-toc map rows rescaling, with a score of 0.001 at most.

About half of what was told came from Leaf's widgets. Telling Leaf's shifts from the author's would need the cause of each shift, which shift entries don't give: they name what moved, not why. A deterministic check for unsized images would be a markup check rather than a timing one. drawn-height advice already covers a widget whose drawing differs from the height it stated, and it reads boxes rather than paint timing.

The 3 s passive watch after presentation (passive-layout-shift) stays. Its observer moves from the shared driver into its own probe in shifts.js.

What to weigh: no check now reports an author <img> without width and height. On a local server that costs a frame or two of jump at load. lf-shot's own jump is being fixed separately: delivery already writes its media size, but no stylesheet reads it.

Max asked for this ("research and resolve 29"). Over 10 runs per page:

  • pages that reported it before: 10/10 → 0/10, 4/10 → 0/10, and 1/10 → 0/10;
  • every other finding on those pages: identical, 10/10, before and after.

Codex reviewed it and found nothing: passive-watch behavior is preserved, and no reference to the old advice remains.

Tests: the passive-watch, delayed-shift and drawn-height browser tests, the timer-movement journey test, the handover tests, and pnpm run check:browser.

This was written by Claude Code on behalf of max-sixty

The render check, in `page check --render` and in each page server's
background reading of a handed-over version, no longer gives the
`startup-layout-shift` advice. From 10 to 15 Nov it made 64 of the 109
findings those readings told agents on the pages in the state home, and
it came and went between readings of the same page: fork-roadmap's 41
readings found it 6 times and told it 5.

It reported every layout-shift entry Chrome recorded between navigation
and the settled page, with no threshold. A box that changes size while
the page loads moves painted content only where a frame was painted
first, so whether a load reports it is a race. Ten runs of the reading's
check per page copy:

- An `<img>` without width and height decodes about 30 ms after
  navigation, around the first frame: thread-option-focus-ring reported
  it in 4 of 10 runs, diagram-fits-column on 6 to 8 of 10 per render page.
- `lf-shot` has no box until its module draws, then 720 px at about
  260 ms: thread-message-times, menu-hovers and error-dot-surface 10 of
  10. The author can't reserve it.
- `lf-toc`'s map rows rescale once the page settles (CLS at most 0.001):
  fable-problems 1 of 10.
- The release-notes, pr-walkthrough and security-boundary examples: 0
  of 10.

About half the real findings came from Leaf's own widgets, whose one
resize as they draw #4724 accepted. A widget that states a height gets
`drawn-height` advice, read from its boxes rather than paint timing,
which #5571 added because shift evidence couldn't carry the height. The
rest were unsized images racing the first frame on a local server; no
check reports those now.

The passive watch after presentation, the only shift reading left, owns
its PerformanceObserver in its probe, since the driver's shared
observer existed for the startup window.
@max-sixty
max-sixty merged commit a5580c9 into main Nov 16, 2026
5 checks passed
@max-sixty
max-sixty deleted the startup-shift-advice branch November 16, 2026 08:44
max-sixty added a commit that referenced this pull request Nov 16, 2026
… jump (#6142)

`lf-shot` now holds its drawn size from first paint, so the content
below no longer jumps when the shot's module draws. Leaf doesn't hide
the page before presentation; it only turns transitions off. So the
empty shot painted first and grew once its module drew. On a test page,
the paragraph under an 1800×746 shot moved from y 207 to y 565. It was
out of place for about 90 ms in Chromium (about 400 ms on a cold load)
and about 450 ms in Firefox, and the render check recorded a layout
shift of CLS 0.179.

Before the module defines the element, `lf-shot:not(:defined)::before`
takes the drawn shot's size. That size is:
- the toolbar row, plus the label row where the shot is narrow;
- the stage's padding and gutter;
- a frame sized from `data-lf-media-width` and `data-lf-media-height`,
which delivery already writes, using typed `attr()`.

The frame follows the drawing's limits: never larger than the captures,
no wider than the stage, no taller than the screen. The screen height is
one registered property, `--lf-shot-screen: 100svh`, read by both the
placeholder and `fit()`, so the two agree. The placeholder applies only
on screen, only while the runtime runs (`html[data-lf-interactive]`),
and only when both media attributes are present.

What to weigh:
- Typed `attr()` arrives in Chrome 133, Firefox 155 and Safari 27.3,
which is still in beta. Current Safari keeps only the toolbar and
padding, so it still jumps by the image height.
- The CSS repeats `fitShotGeometry`'s sizing rules. The widget-quality
check, which now has no accepted lf-shot resize, fails if they drift
apart at desktop width or in a workspace pane, but it doesn't check
narrow widths.
- On a page that scrolls sideways under a classic scrollbar, a shot
capped at the screen's height is now up to the scrollbar's thickness
taller than the visible window, because `fit()` reads the same `100svh`
the placeholder does.
- The gutter under real classic scrollbars is untested: this Mac's
engines use overlay scrollbars.
- The widget-quality case for the default package currently fails on
main, on `lf-note` (`keeps-first-box`, from #6109), not on lf-shot.

Max asked for this after #6127 traced most of the render check's startup
shifts to lf-shot. Codex reviewed it and found three cases where the
held box differed from the drawn one: the screen-height cap under a
horizontal scrollbar, a shot with no media size, and printing during
startup. Each is fixed and measured equal.

Tests: held and drawn heights agree in Chromium, Firefox and WebKit, at
four window sizes, at phone width, in dark, and for five shot shapes.
Stills show no change inside the drawn shot. A new `screenshot-startup`
stills state holds the runtime. The four `test_render_commands` shot
tests, `shot-view.test.mjs` and `pnpm run check:browser` pass.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Nov 16, 2026
… the 3 s shift watch (#6136)

A render reading is now one fresh page load, light at the desktop
viewport, plus the existing width sweep from 360 to 1920 px. It no
longer loads the page again in the dark scheme and at a 540×720 phone
window, and it no longer watches the presented page for 3 s of layout
shifts. Neither part has caught anything on a real page. On this
machine:
- the 3 s watch (`passive-layout-shift`) fired 0 times, across 86 kept
readings and 373 page logs (10–15 Nov);
- of 102 distinct findings, none appeared only in dark or only at the
phone size: the light desktop load and its sweep found every one;
- a search of about 5,900 commits found no dark-only or phone-only
finding from the render check that ever led to a fix. The real
dark-theme defects in history were caught by stills or dedicated tests,
which stay.

Measured with paired runs on 8 pages (4 real page copies, 4 examples),
in shuffled order: a reading falls from about 8.3 s to about 5 s (−37%
wall, −47% CPU). The finding sets (code, element, widths) are identical
on all 13 pages tried.

Two commits:
- **Remove the 3 s passive watch.** −158 production lines, with
`shifts.js` gone. On its own it saves only 0.6 s, since #6114 already
ran the watch alongside the other loads. Combined with #6127, the render
check reads no layout shifts.
- **One light desktop load.** The scheme loop, the phone render and its
short-window sweep, and per-scheme bookkeeping go. Findings lose
`scheme` and `viewports`, which nothing else read; the suite's
syntax-contrast helper keeps the scheme beside each finding itself. A
fault is now reported once, not once per scheme.

What to weigh:
- A fault that shows only in dark CSS, or only when a page first loads
540 px wide, is no longer reported.
- The render suite no longer runs the check over the shipped examples in
dark. Leaf's dark theme keeps its own tests, including code contrast in
both schemes over every example.
- Finding text drops its `[light]`/`[dark]` and `(at 540x720)` marks.
- The phone screenshots `page check --render` saves are unchanged.

This builds on #6127, which deleted `startup-layout-shift`.

Max asked to review keeping these, adding "we generally want to simplify
and remove where possible". Codex reviewed it and found no dangling
consumers of the removed fields, with every remaining check and the
saved screens still working.

Tests: 35 focused tests (render gate model, handover, and single
render-gate journey and browser tests); `pnpm run check:browser`. The
deleted tests covered constructed cases only: the #4704 timer page, a
card clipped only by a dark rule or a 720 px height, and `lf-dusk`,
whose words change only in dark.

> _This was written by Claude Code on behalf of max-sixty_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants