Skip to content

Stop measurement ranges slowing every DOM write on a long page, paint the margin once per card open, and skip clip walks for boxes off screen - #5893

Merged
max-sixty merged 3 commits into
mainfrom
grind/send-1024-b
Nov 12, 2026
Merged

max-sixty merged 3 commits into
mainfrom
grind/send-1024-b

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

A sent comment on the generated asks page at 1,024 sections now draws in a median 136 ms in Chromium, down from 171 ms on main, and shows the server's reading at 214 ms, down from 271 ms. A Resolve shows the server's reading at 135 ms, down from 177 ms. That is still above the 100 ms root AGENTS.md ("Responsiveness") asks for; what remains is listed at the end. The largest part of the gain comes from DOM writes, which were slow on a long page whatever made them, so it reaches beyond the send. In Firefox the send's main-thread time at 1,024 sections fell from 299 ms to 269 ms, measured with this branch's first commit.

Why

Profiling the send at 1,024 sections on main after #5866 left these growing with the page in the press's task and the frame after it, in ms of real (unprofiled) time from timers placed around each function, against the same at 8 sections:

Work 8 sections 1,024 sections
Thread card build (buildThreadCard) 7.8 17.6
Annotation paints, two in the press's task (paintAnnotations) 2.8 + 2.0 21.3 + 12.9
The send's publication (publish) 1.0 15.1
Recording the reading place (recordPlaces) 0.5 + 1.8 10.7 + 3.1
Margin pass (layoutMarginRows) 1.3 9.3
Tab stop (syncRoving) 0.0 6.1

The card build's growth had no reason in the card. Timing a DOM write alone found it: on the 1,024-section page, inserting and removing one empty element took half a millisecond, against none at 8 sections, and the same for an element never attached to the document.

Changes

Measuring a node's lines reuses one range. A Range stays live until a garbage collection reclaims it, and Chromium updates every live range of a document on each insertion and removal, attached or not. The margin's cover reading (childIndex, margin-layout.js) made a range for each text node it measured: 18,432 of them during load at 1,024 sections, by a count of createRange calls, and every pass that reads all the rows makes its own. Until a major collection, every DOM write on the page walked all of them. 2,000 insert-and-remove pairs on a detached element took 1,110 ms on the loaded page, 35 ms after forcing a collection, and take 24 ms with this change, uncollected. shown-box.js now keeps one range for reading a node's contents (contentsRects, contentsBox, and elementBox for a display: contents element), which lets go of the node once read. A thread card's head fit (wordsWidth), a heading link's first line (firstLine) and a text field's send corner (#cornerTaken) measured through ranges of their own and now read through the shared one, and browser/AGENTS.md names it under "One answer for each question". A count of the ranges made while typing, sending, resolving and scrolling now finds tens per gesture; the largest left are caretAt (editor-view.js), about 4 per keystroke, and rangeOf (passages.js), 54 per send, listed below. The review measured a keystroke at 1,024 sections at 6.5 ms of main thread, from 6.9 ms.

Opening a thread card paints the margin once. showPreview redrew the whole margin after the card opened (#5420), only so that the redraw's tracking would follow the card's message ages. A send paid that as a second full annotation paint in its task. The card's thread now follows its own reads instead (follow, application.js, the mechanism the margin's direct redraws already used), so the card's ages still advance with the clock and the margin is painted once. test_message_age_may_shift_metadata_but_leaves_the_thread_in_place[card] fails with the card's draw left unfollowed and passes with it.

A box outside the visible viewport skips its clip walk. seenRect (geometry.js) cuts a box by every box that clips it and then by the visible viewport's height. The clips only cut, so a box the viewport's height doesn't reach is now answered null before the walk. Choosing the margin's Tab stop asks this of every marker.

Measurements

Chromium, uv run leaf-dev bench asks --sizes 256,1024 --input comment --input resolve --rounds 3 --base 5bb337bca: both arms interleaved in one run, this branch's head against its merge base with main (#5889), load average 7.1 at the start and 6.0 at the end. Each cell is the median of 3 rounds, with the range in brackets. Paint is from the input to the frame that draws its own result; shown is to the frame presenting the server's reading of it; CPU is the input's main-thread time.

Input Sections Paint, main → branch (ms) Shown, main → branch (ms) CPU, main → branch (ms)
Send 8 57 [54–88] → 52 [51–87] 88 [83–90] → 87 [71–90] 82 [75–85] → 81 [74–85]
Send 256 79 [72–82] → 68 [68–70] 119 [105–121] → 105 [105–107] 110 [104–115] → 104 [102–106]
Send 1,024 171 [162–177] → 136 [130–142] 271 [269–278] → 214 [206–233] 258 [258–274] → 209 [198–213]
Resolve 8 35 [19–36] → 18 [17–19] 35 [30–36] → 30 [27–31] 34 [32–39] → 36 [35–37]
Resolve 256 54 [33–62] → 56 [53–57] 59 [54–62] → 56 [53–57] 65 [64–71] → 62 [60–63]
Resolve 1,024 173 [104–179] → 135 [126–153] 177 [173–179] → 135 [126–153] 182 [181–185] → 148 [138–155]

The 8-section rows measure the runtime's fixed work, which this change leaves alone; their differences are within the spread of the rounds. The same run's long-frame attribution at 1,024 sections puts the send's own task at 94 ms of script, from 126, and the frame after it at 40 ms, from 46. Most of the gain is the range change: a two-round run of the first commit's two smaller changes alone read the send's paint at 157 ms against main's 166.

Firefox, the same command with --base origin/main and --browser firefox, which reads only main-thread CPU there, on this branch's first commit, which also wrote only the focused marker's place (withdrawn since); load average 4.3 at the start and 4.0 at the end:

Input Sections CPU, main → branch (ms)
Send 256 136 [130–139] → 124 [113–127]
Send 1,024 299 [297–301] → 269 [267–620]
Resolve 256 108 [96–129] → 107 [103–128]
Resolve 1,024 180 [178–194] → 173 [173–173]
Load 1,024 4,108 [4,064–4,115] → 3,703 [3,639–3,842]

Firefox gains less from the range change than Chromium; I haven't profiled why.

What remains at 1,024 sections

The send's own task is 94 ms of script and the frame after it 40 ms. Timed in the page at 1,024 sections with this branch, against 8 sections, these still grow with the page:

  • The send's publication, 15 ms against 1 (publish, framework/application.js). Every publication derives the whole effective state (derive) and shares each subtree against the last reading (framework/snapshot.js, share), whose module header names this as its design: "a fold rebuilds its whole result on every publication". Removing it takes folds that produce only what a change moved.
  • Recording the reading place on the focus move the send makes, 11 ms against 0.5, and 3 ms more in the frame (recordPlaces, version.js). capturePlace hit-tests the landing edge right after the send's DOM writes, which forces the page's style and layout there, and anchors the line it finds by searching the page's text for that line's copies (findQuote).
  • Collecting the annotation inventory, 9 ms against 0.6 (collectEntries, annotation-inventory.js). It reads every thread, obligation, contribution and change, names every group, and sorts the groups by rendered order, building each node's ancestor chain afresh for every comparison. Caching each node's chain for the sort, and each unchanged group's entry, would take most of it.
  • The margin's rows-only pass, 8 ms against 1.3 (layoutMarginRows), which still visits every row; A change to the page's words or styles lays out only the margin rows it can move #5752 describes seating only the rows a change can move.
  • Naming every marker on each render, about 7 ms in the send's paint (nameMarkers 4.5, readSpokenPositions 2.7). Each marker's name says where its row stands among the rows and how far down the page ("3 of 1,024, 40 percent down"), so a row that comes or goes renames every marker, and every render reads every target's place. Writing the place into the focused marker's name only, which an earlier commit of this branch did, renamed the button in the task that moves focus to it, which a screen reader may announce twice, and took the place from browse mode, so it is withdrawn. The platform can't say the place for us: aria-posinset isn't allowed on a button, and a list item gives a button no position.
  • Ranges made per gesture: caretAt (editor-view.js), about 4 per keystroke, and rangeOf (passages.js), 54 per send. Each stays live until a collection, so moving them onto the shared range would keep DOM writes from slowing as they pile up.
  • Forced style recalculations: in profiled runs, about 30 ms of the send's window at 1,024 sections and about the same at 64, where each restyles 15 to 230 elements at around 15 µs an element. They don't grow with the page, so they are fixed cost, but they are the largest single item left in the send's task, and the same at every size.

Checked

  • pnpm run test:runtime (952 pass), pnpm run check:browser, pre-commit on every changed file.
  • 41 browser tests by name across margin seats, card opening and closing, Resolve and the send (the selection Stop thread cards and Resolve reflecting every key on the page, seat each margin row against only the rows beside it, and name a revealed code block's Copy key #5866 ran): all pass, the full-pass comparison test_a_pass_for_a_change_to_the_rows_seats_them_as_a_whole_pass_would among them, which reads every pin's cover through childIndex.
  • 177 marker, walk and Page Map tests by name, with main's marker names and the tests that read them restored, in margin/test_page_map.py, margin/test_entries.py, margin/test_clusters.py, margin/test_opening_threads.py, margin/test_status.py, navigation/test_threads.py, navigation/test_key_scopes.py and test_render_aim.py: all pass but test_a_comment_uses_the_viewport_when_its_target_fills_the_vertical_lane, which times out the same way with main's runtime.
  • test_message_age_may_shift_metadata_but_leaves_the_thread_in_place (both surfaces) passes; its card case fails with the card's thread draw left unfollowed.
  • 21 tests by name for the card's message ages, heading links, the send corner and held news, which the moved measurements reach.
  • tests/model/test_owner_index.py, which checks the owners table.
  • The stale-keys sweep on all 37 published examples passed on the branch's first commit, with file-tree's teardown flake (Stop thread cards and Resolve reflecting every key on the page, seat each margin row against only the rows beside it, and name a revealed code block's Copy key #5866 describes it).
  • Timers around the functions in the first table, and a count of createRange calls by caller while loading, typing, sending, resolving and scrolling at 1,024 sections, both temporary and not committed.

Not checked

  • Firefox's paint and shown times: the bench reads only CPU there.
  • WebKit.
  • The broad suite and the main-push browser tier.
  • Inputs other than the send and Resolve, beyond the review's keystroke reading above.

Part of #5194.

… the margin once per card open, and name only the focused marker's place

On the bench's asks page at 1,024 sections, inserting and removing one
empty element took half a millisecond, against none at 8 sections, even
for an element never attached to the document. A Range stays live until a
garbage collection reclaims it, and Chromium updates every live range of a
document on each insertion and removal. The margin's cover reading
(childIndex) made a range for each text node it measured: 18,432 in the
margin's first passes at 1,024 sections, and as many again in each pass
that reads every row. 2,000 insert-and-remove pairs on a detached element
took 1,110 ms on the loaded page, 35 ms after forcing a collection, and
24 ms with this change. shown-box.js keeps one range for reading a node's
contents (contentsRects, and elementBox for a display: contents element),
which lets go of the node once read.

Opening a thread card redrew the whole margin (showPreview, #5420) only so
the redraw's tracking would follow the card's message ages; a send paid
that as a second annotation paint in its task. The card's thread draw now
follows its own reads (follow, application.js), so its ages still advance
and the margin is painted once.

Each marker's name said where its row stands among the rows and how far
down the page, so every row that came or went renamed every marker and
every render read every target's place. A listener hears a marker's name
as focus arrives on it, so the place is now written into the focused
marker's name only (placeMarker). Browse mode, which reads names without
moving focus, now hears the other markers without their place. The tests
that read an unfocused marker's place focus it first.

seenRect answers null for a box the visible viewport's height doesn't
reach before walking what clips it, since the clips only cut the box.
The previous commit wrote a marker's place among the rows, and how far down
the page it stands, into the focused marker's name only. That renamed the
focused button in the task that moved focus to it, which a screen reader
may announce twice, and took the place from browse mode, which reads names
without moving focus. The platform can't say the place instead:
aria-posinset isn't allowed on a button, and a list item gives a button no
position. Main's naming is back, and so are the place checks in the tests
that read an unfocused marker's name. Naming every marker on each render
stays a cost of about 7 ms at 1,024 sections.
…eading links and text fields

A thread card's head fit (wordsWidth), a heading link's first line
(firstLine) and a text field's send corner (#cornerTaken) each made a Range
of their own for every measurement, and each such range slows every DOM
write until a collection reclaims it. They now read through shown-box.js's
shared range (contentsRects, and contentsBox for the box around a node's
contents). browser/AGENTS.md names the owner in "One answer for each
question".

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description still presents the marker-naming change as part of this PR, but 6f9384f ("Say every marker's place in its name again") restored main's naming. That covers the A marker says where it stands while the user is on it section, its call for Max about browse mode, and the five tests that now focus a marker first. The squash merge uses the description as main's commit message, so as written it would record a naming change and a browse-mode tradeoff that never landed. Please drop that section and say the naming is unchanged.

The same goes for the numbers. The Measurements table and the opening figures (120 ms / 187 ms for the send, 121 ms for Resolve) don't say whether they were taken before or after the revert. The first table counts nameMarkers + readSpokenPositions at 4.5 + 2.7 ms at 1,024 sections, and with the revert that renaming is back on every render. If the benches ran before 6f9384f, re-running them at the head would show what this PR actually gains.

@max-sixty max-sixty changed the title Stop measurement ranges slowing every DOM write on a long page, paint the margin once per card open, and name only the focused marker's place Stop measurement ranges slowing every DOM write on a long page, paint the margin once per card open, and skip clip walks for boxes off screen Nov 12, 2026
@max-sixty
max-sixty marked this pull request as ready for review November 12, 2026 10:05
@max-sixty
max-sixty merged commit 51f5faa into main Nov 12, 2026
7 checks passed
@max-sixty
max-sixty deleted the grind/send-1024-b branch November 12, 2026 10:14
max-sixty added a commit that referenced this pull request Nov 12, 2026
…ng page, and make a publication cost what it changed (#5899)

On the 1,024-section page `leaf-dev bench` generates, a sent comment now
draws in 93–94 ms in Chromium in two rounds of three, and 139 ms in the
third, from 117–121 ms on main, so it is under the 100 ms root
`AGENTS.md` ("Responsiveness") asks for, but not by much or in every
round. A Resolve draws in 72–84 ms, from 121–130 ms; on main, every
round applied the server's reading of it before the frame that drew it.
The server's reading of a send shows at 174–193 ms, from 184–198 ms, and
still misses 100 ms; what remains is listed at the end. The cost: on a
small page the server's reading of a gesture shows about a frame later,
as `shown` at 8 sections in the table below. In Firefox the send's
main-thread time at 1,024 sections falls from 273 ms to 252, and a
Resolve's from 169 to 134.

## Why

Timing the send at 1,024 sections on main (#5893's head) with timers
around each step, unprofiled, the press's task took about 90 ms and the
frame after it about 40:

| Work | ms at 1,024 |
| --- | ---: |
| Publishing the send (`publish`): rebuilding the whole effective state,
comparing it with the last reading, and re-deriving every widget's
selection | 15 |
| Recording the reading place on the send's focus move, in the press's
task (`recordCurrentLocation` → `capturePlace`), a hit test that forced
the page's layout midway through the task | 14 |
| Collecting the annotation inventory (`collectEntries`) | 9 |
| Forced style recalculations in the press's task, about half of them
restyling the whole thread card (~220 elements) | 26 |

The server answers a send in about 50 ms at 1,024 sections, so its
answer arrived while the press's task was still running. In some rounds
the browser then ran the answer's task, about 50 ms of applying the
reading, before the frame that would have drawn the message, so the
message painted only with the server's reading. A Resolve at 1,024 did
this in nearly every round.

## Changes

**A publication reads again only what it changed.** `derive`
(framework/application.js) runs each step that reads the whole page —
the view, the projection and its coverage, the thread fold, widget
states, widget relations and the served obligations — through `step(key,
make, ...inputs)`, which keeps each result by its inputs
(`keptReadings`, kept.js) and calls `make(...inputs)` with exactly those
inputs, so a step can read nothing its key leaves out. A step whose
inputs are the same objects as last time hands back what it made then.
`logCoverage`, `currentWidgetRelations` and `normalizedObligations` now
take only the parts they read. Sharing the fold's result (`shareFold`,
framework/snapshot.js) remembers, for each subtree it replaced with an
equal one, what it shared it as, and answers that subtree, met again
against the same value, without reading it; `share` itself keeps no
memory, so no other caller is bound to leave a value unchanged after
sharing it. Together, a publication about one thing costs what it
changed rather than what the page holds. Every widget's selection now
derives from one selection of the parts a widget reads (`select`'s new
`from`), so a publication that moves none of them, such as a comment's,
reads no widget again; before, each of the 1,024 asks re-read its inputs
on every publication. The send's publication takes 3.6 ms, from 15.

**The focus place is recorded in the frame only.**
`recordCurrentLocation` (version.js) recorded the reader's place both in
the input's task and in the next frame. The record in the task read the
page's layout midway through the task's writes, a forced layout of the
whole page, only to cover a window resized in the same frame. A frame
that resized already records nothing (`regionsSettled`), so a shift
there restores the place recorded before the input. That record took 14
ms of the send's task; without it the task is about 8 ms shorter, since
the task's next read of the page's layout now lays it out instead. The
frame's record stays.

**A reading waits for the frame a gesture is owed.** `afterOwedFrame`
(rendering.js) resolves once the frame the page has asked for has
painted, or at once where none is asked for or the document draws
nothing. While a gesture of the user's is unresolved, `applyState`
(state-application.js) waits for it before adopting a reading, so the
gesture's own result paints before the server's reading is applied. With
no gesture in flight, as while the page loads or when the agent's news
arrives, a reading is adopted as before: waiting there too drew an extra
frame of the whole page during load, about 75 ms of main-thread time in
Firefox at 1,024 sections. The cost: where the reading would have fitted
before the gesture's frame, it shows one frame later, as for a Resolve
at 8 sections (below).

**The thread card's bounds no longer restyle the whole card.**
`measureThreadCard` and the card's fit wrote the card's width and height
caps as custom properties (`--lf-thread-width`, `--lf-thread-min-width`,
`--lf-thread-max-height`) that only the card itself read, but every
element in the card inherited, so each fit restyled about 220 elements.
They are now the card's own `max-width`, `min-width` and `max-height`.
The transcript's fade lengths (`--lf-thread-fade-top`,
`--lf-thread-fade-height`) still inherit, and each write of them
restyles the thread's elements: registered as not inheriting and taken
with `inherit`, they stay at their first value in WebKit, the gap that
already keeps the column's room inheriting. `notes/browser-support.md`
now records that gap as one entry with a minimal reproduction (WebKit
27.2 keeps the first value; Chromium 158 and Firefox 159 restyle), and
the fade rule names it.

**The annotation inventory sorts each place once and names only outline
targets.** Its sort read both nodes' ancestor chains and walked their
siblings for every comparison; `renderedOrdering` (shadow-tree.js) reads
each node's chain once and each parent's children once per sort, and
`byRenderedOrder` uses it too. `outlineSubjectFor` checked, for every
target, whether it was in the page's outline by scanning the outline, a
walk of one collection per member of another; `outlineContexts`
(thread/placement.js) counts the outline's labels once and reads a label
only for a target in the outline, which is all the inventory used of it.
Each obligation's row shares one reading of its words ("Waiting on me")
rather than a copy per row.

## Measurements

Chromium, `uv run leaf-dev bench asks --sizes 256,1024 --input comment
--input resolve --rounds 3 --base origin/main`, both arms interleaved,
this branch against its merge base with main (#5875); load average 3.5
at the start and 1.9 at the end. Each cell is the lowest of 3 rounds, as
the bench reports, with the range in brackets.

| Input | Sections | Paint, main → branch (ms) | Shown, main → branch
(ms) | CPU, main → branch (ms) |
| --- | ---: | --- | --- | --- |
| Send | 8 | 48.5 [48.5–52.9] → 43.7 [43.7–46.2] | 79.4 [79.4–88.6] →
89.5 [89.5–92.5] | 78.7 [78.7–82.6] → 69.8 [69.8–73.1] |
| Send | 256 | 65.9 [65.9–112.5] → 54.4 [54.4–80.3] | 103.2
[103.2–112.5] → 99.0 [99.0–99.8] | 93.7 [93.7–99.8] → 84.8 [84.8–87.5] |
| Send | 1,024 | 117.0 [117.0–121.4] → 92.8 [92.8–139.2] | 184.2
[184.2–197.6] → 173.7 [173.7–192.5] | 189.5 [189.5–196.3] → 152.1
[152.1–158.4] |
| Resolve | 8 | 20.4 [20.4–29.3] → 18.2 [18.2–26.2] | 30.8 [30.8–44.6] →
39.3 [39.3–64.0] | 41.5 [41.5–49.8] → 41.5 [41.5–52.0] |
| Resolve | 256 | 60.9 [60.9–64.7] → 39.3 [39.3–50.8] | 60.9 [60.9–64.7]
→ 61.1 [61.1–71.5] | 64.7 [64.7–78.4] → 51.8 [51.8–74.5] |
| Resolve | 1,024 | 121.0 [121.0–130.4] → 72.3 [72.3–83.8] | 121.0
[121.0–130.4] → 118.6 [118.6–127.3] | 142.5 [142.5–149.6] → 116.7
[116.7–132.5] |
| Load | 1,024 | | | 4,340 [4,340–4,373] → 4,333 [4,333–4,379] |

Paint is from the input to the frame that draws its own result; shown is
to the frame presenting the server's reading of it; CPU is the input's
main-thread time. Where main's paint equals its shown, the server's
reading was applied before the gesture's frame. The send's three paints
at 1,024 sections on this branch were 92.8, 139.2 and 93.6 ms; the slow
round was not that race (its reading showed at 192.5). The bench's
long-frame attribution at 1,024 sections puts the send's own task at 57
ms of script (19 forced), from 81 (24 forced), and the frame after it at
28 ms, from 35; applying the server's reading now runs in its own task
after that frame (`paintedOwed`).

Firefox, the same command with `--browser firefox`, which reads only
main-thread CPU there; load average 1.8 at the start and 1.9 at the end.

| Input | Sections | CPU, main → branch (ms) |
| --- | ---: | --- |
| Send | 8 | 67.1 [67.1–71.9] → 65.1 [65.1–71.3] |
| Send | 256 | 111.3 [111.3–116.3] → 106.4 [106.4–115.7] |
| Send | 1,024 | 272.6 [272.6–286.2] → 251.8 [251.8–258.3] |
| Resolve | 8 | 38.7 [38.7–56.3] → 38.8 [38.8–48.0] |
| Resolve | 256 | 84.0 [84.0–116.1] → 68.5 [68.5–88.2] |
| Resolve | 1,024 | 168.9 [168.9–184.0] → 133.8 [133.8–151.6] |
| Load | 1,024 | 4,077 [4,077–4,149] → 4,047 [4,047–4,068] |

Firefox gains less than Chromium from these changes; I haven't profiled
it to say why.

## What remains at 1,024 sections

Timed in the page on this branch at 1,024 sections, unprofiled and
before rebasing onto #5875, these still grow with the page:

- **The margin pass** (`layoutMarginRows`), 9 ms in the frame against
about 1.3 at 8 sections. A rows-only pass still visits every row:
finding held rows by one selector over the whole layer, carrying each
row's record, seating every row through `Footprints`, and writing every
row's seat, together about 4.5 ms; and the send's new pin reads every
child of `main` for its cover (`childIndex`), 1.5 ms. #5752 describes
seating only the rows a change can move; the cover index could also be
kept across rows-only passes, which by definition move nothing on the
page.
- **The place record in the frame**, 6–7 ms. Most of it is anchoring the
line at the landing edge (`lineAnchor` → `anchorForPassage`), which
searches the page's text for that line's copies to choose its context;
every focus move, scroll end and keystroke frame pays it. Computing the
anchor only when a record is used, from the line's live nodes, would
remove it. #5875, merged since this was profiled, changed that search,
which I haven't re-profiled.
- **The annotation inventory**, 8 ms in the press's task: it still
builds each obligation's group and entry on every collection. Keeping
each group's entry by the record and target it came from would leave a
collection the groups that changed.
- **The marker names**, 3–4 ms, left alone as #5893 explains.
- **The Tab stop** (`syncRoving`), 2 ms in the frame: it reads every
marker's box to find the highest one in view.
- **Forced style recalculations on the thread card**, still about 20 ms
of the press's task at every size. Three kinds restyle the whole card or
thread: focus marks on the card's ancestors (`data-lf-focus-within`,
`data-lf-control-focus-visible`) match rules that set the inherited
`--lf-ring-at`; the card's `visibility`, which is inherited, is cleared
once it is placed; and the fade's lengths, which inherit because of the
WebKit gap above. The first two are theme-wide patterns, which I left
for a change that can check every surface they reach; the fade could
become an element of its own with inline `top` and `height`.

#5752 stays open: seating only the rows a change can move is still to
do.

## Checked

- `pnpm run test:runtime` (965 pass), `pnpm run check` (which runs
`check:browser`), pre-commit on every changed file.
- New runtime tests, each shown failing without its change: a
publication that moves no widget's part reads no widget again
(`framework-application.test.mjs`); `shareFold` answers a subtree from
its last sharing only against the value it was shared as
(`framework-snapshot.test.mjs`, which fails when `shareFold` answers
regardless of the current value); a task waiting on the frame already
asked for runs once that frame has painted (`rendering.test.mjs`); a
reading arriving while a gesture's frame is owed is adopted after that
frame, and with no gesture pending at once
(`state-application.test.mjs`, which fails with the wait removed and
with it made unconditional); a sort's ordering answers every pair as
rendered order does (`page-walk-order.test.mjs`, which fails with the
sibling order reversed).
- Browser tests on the final head, all passing but three:
`margin/test_page_map.py`, `margin/test_entries.py`,
`drafts/test_reading_place.py`, `threads/test_layout.py` (whose
`test_the_thread_card_opens_on_its_latest_message_under_its_own_name`
reads the fade's box), `margin/test_card_placement.py`,
`margin/test_opening_threads.py`, `margin/test_card_reply.py`,
`threads/test_resolving.py`, `navigation/test_commenting.py`,
`test_render_semantic_news.py`,
`test_news_just_after_a_press_moves_nothing`,
`widgets/test_obligations.py`, `widgets/test_boards.py`,
`test_render_options.py` and `test_render_application_boundary.py` (416
passed); and, before the review fixes, `margin/test_pins.py`,
`margin/test_rail.py`, `margin/test_clusters.py`,
`navigation/test_threads.py` and `navigation/test_obligation_walk.py`.
The three, `test_a_card_s_head_stands_whole_beside_news[True]`,
`test_a_margin_card_is_one_frame_that_rings_for_its_thread` and a
teardown error in
`test_a_zoomed_floating_draft_and_sent_comment_fit_a_narrow_window`
("ResizeObserver loop completed with undelivered notifications"), fail
the same way with main's runtime.
- An independent review compared a live tab with a fresh load of the
same log over 16 steps (picks, undo, a suggestion, reply, resolve,
reopen, an agent's reply, a new version, a refused pick, a second tab),
on main and on this branch. The two differ in one way, the same on both:
after a pick the server refused with 422, the live tab still draws it.
That difference predates this change; no other step differed.

## Not checked

- Firefox's paint and shown times: the bench reads only CPU there.
- WebKit.
- The broad suite, the main-push browser tier and the stale-keys sweep.

## Calls Max may reverse

- Dropping the focus place record from the input's task. A window
resized in the same frame as a focus move now restores the place
recorded before the move.
- While a gesture is unresolved, a reading waits for a frame already
asked for, which shows the reading up to a frame later where it would
have fitted before that frame, as at 8 sections. Two alternatives I
measured and dropped: waiting only for a frame already overdue (asked
for longer ago than a 60 Hz frame lasts) still let every Resolve at
1,024 sections paint only with the server's reading in a three-round
run; waiting for every reading, gesture or not, drew an extra frame of
the whole page during load (about 75 ms of Firefox main-thread time at
1,024 sections). That last version also read the send's paint 4–5 ms
faster at 1,024 in two interleaved runs with the arms swapped; I haven't
found why, and suspect the extra frames during load leave the margin's
and inventory's code warmer for the first send.
- The thread card's fade lengths inherit, as on main, rather than being
registered as non-inheriting: that version restyled only the thread and
its fade, but in WebKit the fade kept its first place whenever nothing
else restyled it. The note on the gap already prescribes inheriting for
the column's room, and the cost is a restyle of the thread's elements
per write, about 1 ms of the send's task.

Part of #5194.
leaf-agent added a commit that referenced this pull request Nov 13, 2026
Since #5893, every thread card a gesture opens wraps its draw in
`follow` (`browser/runtime/application.js`) so the card's message ages
keep advancing with the clock. But only the presenter's next paint
(`forget()`) stopped a follow, and each follow chained a closure onto
the previous one. So opening and closing cards with no margin repaint in
between piled up live effects, each holding that card's host, thread and
outlets. The render gate's closed-surfaces check reported this as the
thread card leaking nodes and listeners on every round trip, on seven
corpus pages.

The card's follow now lasts as long as the card:

- `follow` returns `{drawn, stop}`, and the follows sit in a set that a
stopped follow leaves. Previously they sat in a chain that kept every
stopped closure until `forget()`.
- The card keeps its draw's `stop` on its session as `stopDraw`
(`annotation-overlay/thread-preview.js`). It calls it before drawing
again and when the session retires, so a card holds at most one follow.
The presenter's paint still stops every follow, as before.

This keeps what #5893 meant the follow to do: the card's ages still
advance with the clock, and the margin is still painted once per card
open.

Checked locally on Linux:

- `test_page_fixture_renders` fails on `log-retention` before the
change, with the same counts as CI (`[2486, 3592, 4385, 5178]` nodes).
After the change it passes on all seven pages the issue lists:
`log-retention`, `review-a-plan`, `ship-review`, `feature-gallery`,
`thread-panel-gallery`, `sidebar-contents` and `thread-choice-hints`.
- `test_message_age_may_shift_metadata_but_leaves_the_thread_in_place`
passes for both surfaces. Its card case is the test that showed #5893
needs the card's draw followed.
- `pnpm run test:runtime` passes 965 of 965, and `pnpm run
check:browser` and pre-commit pass. A stub in
`tests/runtime/thread-card.test.mjs` now returns the new `{drawn, stop}`
shape.

On macOS, `thread-panel-gallery` timed out (`work the page deferred past
presentation never landed`) instead of reporting the leak. No runner
here has macOS, so the next scheduled `test-macos` run after merge will
show whether that timeout had the same cause.

Closes #5925 — automated triage

Co-authored-by: leaf-agent <[email protected]>
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