Repository navigation
Leave a bounded block in a hidden panel unstyled until it is drawn - #1901
Merged
Merged
Conversation
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
previously approved these changes
Oct 6, 2026
# Conflicts: # skills/leaf/assets/runtime/reach.js
leaf-agent
approved these changes
Oct 6, 2026
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.
A decided suggestion could keep showing its retired words: the slot carried
data-lf-retired, thestate.cssrule applied, and Chromium still computeddisplay: inline. The style was stale. The operation that left it stale was a forced style read inside a hidden tab panel, made bybounds.jsfrom a MutationObserver.Cause
On every content change of a bounded block (
data-lf-bound),hold.syncfound the block's scroller by callinggetComputedStyleon every box inside it (scrollerOf). The feature gallery's "Page & layout" tab holds bounded logs, and an inactive tab panel ishidden="until-found", which iscontent-visibility: hidden. Each read forced Chromium to style that skipped subtree. A Chrome invalidation-tracking trace of a failing run shows the sequence::has()invalidation marks#bg-gallery-tabsfor a subtree restyle andmainfor a local one;declaresBoundreads style inside the panel, which forces a display-lock style update (1011 such reads in a failing run, against 1 in a passing one);mainnor#bg-gallery-tabsand clears the dirty bits above them, so#bg-gallery-tabsstays dirty with nothing pointing at it;data-lf-retiredon#bg-insert lf-new.#bg-gallery-tabsis 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:syncasksskipped(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 anendlog that grew while hidden opens on its newest entry.reach.js:paintReadingReachandpaintSidewaysReachcheckunpaintedthemselves. Review found that a bounded block arriving in a hidden panel registered as a reading region and had its downward cue painted at once, readingoverflow-yand scroll extents in skipped content from the same MutationObserver.Evidence
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 thebounds.jschange applied there.: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 tochrome.css(.lf-zz-a:has(> .lf-zz-b) * {}) fails 8 of 10 copies on main, and 0 of 20 with this change.test_logs_in_a_hidden_tab_open_on_their_newest_entriesgrows 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 thebounds.jschange, without thereach.jschange, and without the renewed size observation.npm run test:runtime.test_render_controls.py::test_each_sampled_focus_ring_is_shown_whole_in_its_surfacefails on current main without this change too.A more underlying fix?
Unverified. Other runtime readers still force style or layout in hidden panels:
shownPartsfor target paint (deliberate, per geometry.js's header),readingPostureinrecordRegionsandscrollersSettled,margin-layout.js'sscrollFollows, anduser-view.js'sseenRect. 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 askingskippedfirst. History read:notes/margin-stuck-style.md(#1506, #1695, #1719), #1834 and #1880.Fixes #1868