Skip to content

Leave a bounded block in a hidden panel unstyled until it is drawn - #1901

Merged
max-sixty merged 5 commits into
mainfrom
agent-a7f543cd70481bc44
Oct 6, 2026
Merged

max-sixty merged 5 commits into
mainfrom
agent-a7f543cd70481bc44

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

A decided suggestion could keep showing its retired words: the slot carried data-lf-retired, the state.css rule applied, and Chromium still computed display: inline. The style was stale. The operation that left it stale was a forced style read inside a hidden tab panel, made by bounds.js from a MutationObserver.

Cause

On every content change of a bounded block (data-lf-bound), hold.sync found the block's scroller by calling getComputedStyle on every box inside it (scrollerOf). The feature gallery's "Page & layout" tab holds bounded logs, and an inactive tab panel is hidden="until-found", which is content-visibility: hidden. Each read forced Chromium to style that skipped subtree. A Chrome invalidation-tracking trace of a failing run shows the sequence:

  • a row is added to a log in the hidden panel, and :has() invalidation marks #bg-gallery-tabs for a subtree restyle and main for a local one;
  • in the same task, declaresBound reads style inside the panel, which forces a display-lock style update (1011 such reads in a failing run, against 1 in a passing one);
  • that update restyles neither main nor #bg-gallery-tabs and clears the dirty bits above them, so #bg-gallery-tabs stays dirty with nothing pointing at it;
  • every later write under it is never restyled, including the reject's data-lf-retired on #bg-insert lf-new. #bg-gallery-tabs is never resolved again for the rest of the run.

The forced pass orphaning a dirty ancestor is a Chromium defect. I could not reduce it to a page without Leaf.

Fix

  • bounds.js: sync asks skipped(bounded) first, as geometry.js's other readers of skipped content do. A skipped block keeps the scroller it had, or stands as its own, and renews its size observation. The first delivery after the block is drawn syncs again, so an end log that grew while hidden opens on its newest entry.
  • reach.js: paintReadingReach and paintSidewaysReach check unpainted themselves. Review found that a bounded block arriving in a hidden panel registered as a reading region and had its downward cue painted at once, reading overflow-y and scroll extents in skipped content from the same MutationObserver.

Evidence

  • Issue journey (test_a_decision_undone_leaves_every_suggestion_pin_where_it_stood), on macOS Chromium 153: at 0e52b1b it failed 25 of 32 copies, and 0 of 20 with the bounds.js change applied there.
  • Main stopped reproducing after Leave the band under a long thread's pinned reply row out of what is seen #1880 removed a non-subject :has() rule (bisected over the 18 commits from 0e52b1b). That rule supplied the pending subtree invalidation. Adding a no-op rule of the same shape back to chrome.css (.lf-zz-a:has(> .lf-zz-b) * {}) fails 8 of 10 copies on main, and 0 of 20 with this change.
  • New test test_logs_in_a_hidden_tab_open_on_their_newest_entries grows one bounded log in a hidden tab, adds a second, and checks that neither has its style or scroll extents read while the tab is hidden, then that both open at their newest entry, twice. It fails without the bounds.js change, without the reach.js change, and without the renewed size observation.
  • The tests that exercise bounded blocks, reading regions, and reach cues (71 cases) pass, as does npm run test:runtime. test_render_controls.py::test_each_sampled_focus_ring_is_shown_whole_in_its_surface fails on current main without this change too.

A more underlying fix?

Unverified. Other runtime readers still force style or layout in hidden panels: shownParts for target paint (deliberate, per geometry.js's header), readingPosture in recordRegions and scrollersSettled, margin-layout.js's scrollFollows, and user-view.js's seenRect. With this change and the provoking :has() rule, the issue journey stopped failing (0 of 20), so none of them was seen to leave style stale. The run that would settle it is a journey that makes one of them read a hidden panel while an ancestor holds a pending :has() subtree invalidation. Its candidate fix is for those primitives to answer skipped content themselves (a last-seen scroller, an empty shown set) instead of each caller asking skipped first. History read: notes/margin-stuck-style.md (#1506, #1695, #1719), #1834 and #1880.

Fixes #1868

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

max-sixty and others added 4 commits October 6, 2026 02:11
A decided suggestion could keep showing its retired words (#1868): the
slot carried `data-lf-retired`, the state.css rule applied, and Chromium
still computed `display: inline`. The style was stale, not wrong.

The trigger was bounds.js. On every content change of a bounded block,
`hold.sync` found the block's scroller by reading the computed style of
every box inside it. For a log in a hidden tab panel
(`hidden="until-found"`, so `content-visibility: hidden`), each read
forced Chromium to style that skipped subtree. A Chrome trace of a failing
run shows the forced pass, run from the MutationObserver while
`lf-gallery-tabs` held a pending `:has()` subtree invalidation, leaving
that ancestor dirty with no dirty bit above it. Nothing reached it again,
so every later write under it, the retirement mark included, was never
restyled.

`sync` now asks `skipped(bounded)` first, as geometry.js's other readers
of skipped content do. A skipped block keeps the scroller it had, or
stands as its own, and renews its size observation, whose first delivery
comes once the block is drawn. That re-observation keeps an `end` log
that grew while hidden opening on its newest entry.

Measured with the issue's journey (`test_a_decision_undone_leaves_every_
suggestion_pin_where_it_stood`): at 0e52b1b it failed 25 of 32 copies,
and 0 of 20 with this change. Main stopped reproducing it after #1880
removed a non-subject `:has()` rule, which supplied the pending
invalidation; adding a no-op rule of that shape back fails 8 of 10 copies
without this change and 0 of 20 with it.

The new widgets test grows a log in a hidden tab and checks that no style
is asked inside it, then that the tab opens at the newest entry, twice.
It fails without the change on the style read, and without the renewed
observation on the second opening.

Fixes #1868

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Review of the bounds.js change found the same forced read on a second
route: a bounded block that arrives in a hidden panel registers as a
reading region, and `reachReadingScroller` painted its downward cue at
once, reading its `overflow-y` and scroll extents. That is a style and
layout read inside `content-visibility: hidden` content, run from the
arrivals MutationObserver, the same call site as the read behind #1868.

`paintReadingReach` and `paintSidewaysReach` now ask `unpainted` first
themselves, and `paintReach` drops its per-loop checks. A box observed
while skipped is painted by the size delivery that comes once it is drawn.

The widgets test now also adds a bounded log to the hidden tab and checks
that neither log has its style or scroll extents read while hidden. It
fails without this change (`style div`, `scrollHeight div`) and without
the bounds.js change.

The bounds.js header keeps the contract and drops the incident narration.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
leaf-agent previously approved these changes Oct 6, 2026
# Conflicts:
#	skills/leaf/assets/runtime/reach.js
@max-sixty
max-sixty merged commit d552624 into main Oct 6, 2026
4 checks passed
@max-sixty
max-sixty deleted the agent-a7f543cd70481bc44 branch October 6, 2026 10:55
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.

ci-fix: retired suggestion text remains visible after a decision

2 participants