Skip to content

Studio: paint a long thread's newest messages immediately instead of rebuilding all of them first - #9058

Merged
danielhanchen merged 46 commits into
mainfrom
perf-progressive-mount
Aug 22, 2026
Merged

danielhanchen merged 46 commits into
mainfrom
perf-progressive-mount

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Aug 17, 2026 •

Copy link
Copy Markdown
Member

What this changes

Re-opening a long chat thread rebuilds every message before it can paint anything. #9016 measured
that at 3175ms on Chromium for a 300K-character thread, of which 2817ms is script, growing
7.1x from 25K to 300K. Nothing about it is incremental: the thread unmounts in 85ms and then
rebuilds 220 messages, 43,422 DOM nodes and 77 Shiki fences from nothing.

This bounds the first commit to the last 16 messages and mounts the rest 32 per animation frame,
then drops the restriction. Nothing ever unmounts. The document converges to exactly the tree
that shipped before, a few frames later.

300K characters time to the FIRST PAINTED MESSAGE time to FULL CONVERGENCE
before after after
Chromium 4289.0ms 439.8ms 0.10x 1.18x, worse
WebKit 4647.0ms 354.0ms 0.08x 1.13x, worse
Firefox 4664.5ms 522.0ms 0.11x 1.17x, worse

Read the metric, not the headline. The win is first paint. Time until the whole thread is back
gets 13 to 18 percent WORSE, and that column is in the table rather than 100 lines below it because
the improvement is easy to restate as "thread reopen got 10x faster", which is not what this does.
It is the deliberate trade: a progressive mount does strictly more commits than one big one.

Re-measured independently on a second host, three arms concurrent with a same-commit null control:
first painted row 1542.2 -> 212.0ms (0.14x, a 7.3x win), full convergence 1542.2 -> 1845.6ms
(+19.7%), null -0.7%. Longest single main-thread stall on reopen, which is where the jank actually
lives, 2175.8 -> 294.9ms (-86.4%) against a null of -11.8%. The absolute before-figure is
host-dependent by a factor of 2 to 3
, so read the ratios and not the milliseconds; that second box
is 2 to 3x faster than the one that produced 4289. Every other action metric (keystroke, scroll,
jump, menu, delete, at 25K, 100K and 300K) sits inside its own concurrent null.

UI idempotency, checked before any timing was read

Whole-document structural digest of the settled viewport after close then reopen then full settle,
generated ids normalized, tag boundaries newline-split so differences are countable. Five reps per
arm, three arms concurrent: two independent builds of the merge base, and this head.

pair 100K, 16,466 lines 300K, 45,014 lines
null, same build five reopens apart identical, 0 lines identical, 0 lines
null, same commit, two independent builds identical, 0 lines identical, 0 lines
base vs head 1 line 1 line

The null's own score is zero, so one line is genuinely above the floor rather than lost in it.
That one line was style="" left on the viewport root by removeProperty, an empty attribute with
no rendered effect; computed overflow-anchor was auto on both arms. Fixed in 6af84c8, so the
converged document is now byte-identical. Everything else already matched exactly across all five
reps of all three arms: rows 220/220, 38,752 DOM nodes, 55 <pre>, 35,086 highlighted tokens, 33
images, 22 tool parts, 22 artifact cards, scrollHeight 120,402, scrollTop 119,502.

What a reader sees during the window, per-frame trace at 300K: the bottom gap is 194px on the
first painted frame and 199px thereafter, and the merge base's own single frame is also 194 then
199, so none of that band belongs to this change. No white gap is ever shown. The row a
bottom-parked reader is looking at drifts 5px total over 47 frames and 1.65s. With a real wheel
gesture against a detached reader, total drift is 3,195px on head and 3,195px on base, max per-frame
shift exactly one wheel notch on both: inserting 204 messages above a scrolling reader adds 0px.

Two things do change under the reader, stated rather than buried. The scrollbar thumb steps from
about 12 percent of the track to 0.75 percent in 8 visible steps over 1.65s as scrollHeight grows.
And for those 1.65s the thread reports its own length as 16, then 48, then 80 messages, so a reader
who drags to the top inside that window reaches something that looks like the start and is not. The
merge base cannot exhibit either, because it shows nothing at all until 1.54s. That is the honest
cost of the design.

Those three engines are the warm re-open. As opened, this did nothing at all for the cold open, the
first time a thread is opened in a session, because the component mounts before the messages
arrive; review caught that and it is fixed. The cold-open numbers and the fix are under "Design
notes". What it costs on a slow machine, which the tables above are not, has its own section.

Read this before trusting any WebKit result in this repo

This change found a hole in how we test, not just a bug in itself, so it goes near the top rather
than in a notes section.

Playwright's WebKit implements CSS scroll anchoring. No shipping Safari does. WebKit landed it
in February 2026 and it ships in Safari 27; every Safari and every iOS browser in users' hands
today has none. Playwright bundles a WebKit built from trunk, so webkit in our harnesses reports
the future behaviour. Measured directly here on a 400px scroller with 2000px inserted above the
scroll position: Chromium 151, Firefox 153 and Playwright's WebKit 26.5 all compensate in full, and
all three fire a scroll event for it.

That is not a footnote for this PR, it is the thing that nearly shipped a serious bug. Two earlier
versions of this change were correct on every engine the harness can run and wrong on the engine
Studio Desktop actually embeds on macOS. Standing in for a real Safari with overflow-anchor: none
on the viewport, they walked a parked reader 19,259px, and 45,873px when the reader kept
scrolling. Both read as clean on Playwright WebKit.

So: real Safari and real WKWebView cannot be tested on this machine at all. It is Linux, there
is no macOS and no iOS on it, and Playwright ships no Safari. Everything labelled "webkit" below is
Playwright's build, which advertises Version/26.5 Safari/605.1.15 in its user agent, a version
that has no overflow-anchor in any browser a user can install. To be precise about the timeline,
since "ships in Safari 27" is easy to over-read: WebKit enabled scroll anchoring in stable on
2026-02-13 (307475@main, bug 307734), and Safari 27 has it
in beta as of WWDC26. The newest RELEASED Safari is 26.6, and it, every earlier Safari, and
every iOS browser have none of it.

The overflow-anchor: none runs below are therefore a stand-in for an engine this machine does not
have. But it is a stand-in that can now be checked rather than assumed, because one shipping WebKit
that Desktop DOES embed is on this machine: WebKitGTK 2.50.4, which is what Tauri uses on Linux.
Driven directly through python-gi, same 400px scroller with 2000px inserted above a reader parked at
scrollTop 5000:

CSS.supports('overflow-anchor: none') anchoring left on with overflow-anchor: none
Chromium 151 true 5000 -> 7020, one scroll event 5000 -> 5000
Firefox 153 true 5000 -> 7020, one scroll event 5000 -> 5000
Playwright WebKit 26.5 true 5000 -> 7020, one scroll event 5000 -> 5000
WebKitGTK 2.50.4 (real Desktop Linux) false 5000 -> 5000, no scroll event 5000 -> 5000

The last row is the whole point. On the engine Unsloth Desktop actually runs on Linux, content
inserted above the reader moves them, natively, today, and the two arms are indistinguishable
because there is no anchoring to turn off. That is precisely the behaviour the
overflow-anchor: none stand-in reproduces, so the stand-in is now validated against a shipping
engine rather than only argued for. Real Safari and real WKWebView remain untested and are stated
as such rather than implied.

Worth a wider look than this PR: any harness result on webkit that turns on scroll anchoring,
overflow-anchor, or scroll-position preservation is currently measuring a browser none of our
users run.

This is deliberately not virtualization

I investigated virtualizing the thread first and recommended against it. The short version:

  • The prize is smaller than it looks and lands in one place. I measured the ceiling directly by
    rendering only the last 20 messages of the same fixture through ThreadPrimitive.MessageByIndex:
    re-open goes to 438ms and is flat in thread length (441ms at 25K, 470ms at 100K, 438ms at 300K,
    medians of 8 paired rounds, with a 25K null control reading 0.99x). That is the whole prize, and
    it is all in the re-open. It buys nothing on scrolling, which Studio: let a settled thread skip the code blocks it is not showing #9047 already attributed to paint
    and raster of on-screen content, layout plus style being 13.5ms of a 700ms gesture.
  • It would probably make scrolling worse. Mounting costs 13.1ms per message on this fixture.
    A virtualizer moves that into the scroll path, roughly 14 rows per 20-step gesture, about 180ms
    of new script on top of the 616ms the gesture already costs.
  • Someone already ran the experiment. Open WebUI shipped JS culling in 02690339 (2026-04-13,
    closing #23067) and reverted it ten days
    later in d56d74b3. The comment they left in its place calls it "catastrophic mount/destroy
    thrashing", and #23990 ("it jumps back
    and forth usually around my queries") was filed in between. What they run today is a tail slice
    plus content-visibility, and that has since needed a Safari UA sniff
    (#26805, blank messages on iOS
    #26712), an explicit
    contentVisibility = 'visible' override so export stopped truncating (34146ab6), and still has
    #28658 and
    #28656 open from its height estimates.
  • LibreChat never virtualized their thread at all. MultiMessage.tsx is a recursive spine with
    every row mounted and memoized; react-virtualized is in their tree but only drives composer
    dropdowns. Their long-thread fix,
    #14901 (merged 2026-08-16), is a widen-only
    progressive mount. This change is modelled on it.
  • assistant-ui's own guide opens with "Probably not" on whether you need virtualization, and
    notes that its virtualized composition cannot use ThreadPrimitive.Viewport because the built-in
    auto-scroll assumes every message is mounted. Ours is 616 lines of tuned scroll logic built on
    scrollHeight being the true content height. Virtualizing means rewriting all of it.

Because nothing unmounts, none of find-in-page, selection across messages, copy-the-whole-thread,
screen readers, print or export can regress once it settles: after a few frames the DOM is the
document it was before, and that is checked rather than asserted in "The settled document is the
document that shipped before" below. During the build-in itself they see less, because the rows
genuinely are not there yet. That is the deferred-work half of the trade and it is the half worth
watching: a select-all or a find during the first few hundred milliseconds of a long thread opening
covers the tail rather than the whole conversation. Anything that must not see a partial thread
awaits completeProgressiveMounts(); nothing in Studio reads the thread from the DOM today.

The measurement

Two worktrees whose only difference is this commit, each carrying an identical copy of #9016's
harness. Four rounds per arm with the arm order alternating round to round, three repetitions
inside each run, so each cell is a median of four round-medians. Shared machine, vite dev server.

The harness's existing reopen column stops when every message is back, which by design this does
not improve. So the harness gains one column, firstRowMs, the time from re-open to the first
painted row, applied identically to both arms. Both numbers are below, because quoting only the
first would be quoting only the half that flatters this.

Chromium

25K 100K 300K
first row, before 575.2ms 1734.0ms 4289.0ms
first row, after 566.7ms 412.3ms 439.8ms
0.99x 0.24x 0.10x
worst frame 538.5 -> 511.8ms 1634.1 -> 515.3ms 4065.0 -> 634.5ms
converged 575.2 -> 566.7ms 1734.0 -> 1704.7ms 4289.0 -> 5047.6ms (1.18x)
task ms, CPU 558.7 -> 544.5ms 1704.6 -> 1619.9ms 4118.2 -> 4742.2ms (1.15x)
frames over 33ms 2 -> 2 3 -> 4.5 4 -> 10
rows in the first paint 18 of 20 16 of 80 16 of 220

Per-round first-row medians at 300K do not overlap: before 4199, 4379, 3921, 4817; after 307, 356,
565, 523.

WebKit and Firefox, 300K

WebKit before WebKit after Firefox before Firefox after
first row 4647.0ms 354.0ms (0.08x) 4664.5ms 522.0ms (0.11x)
worst frame 4422.0ms 583.0ms (0.13x) 4570.0ms 577.5ms (0.13x)
converged 4647.0ms 5270.0ms (1.13x) 4664.5ms 5469.0ms (1.17x)
frames over 33ms 4 18 8.5 35.5

The 25K row is the noise floor, and it should be read that way

At 25K nothing is windowed on either arm: 18 rows in the first paint on both sides, because a
20-message thread is under the 40-message floor. The code path is provably identical, so whatever
that column reads is measurement noise on a loaded shared machine. It reads 0.99x on Chromium,
1.13x on Firefox and 1.17x on WebKit, which puts the noise band at roughly plus or minus 17
percent.

That matters for how the costs below are stated, because some of them are inside that band.

What this costs, stated plainly

Total work goes up, not down. Every message still mounts. Convergence and CPU are 13 to 18
percent worse at 300K. On Chromium, where CPU can be attributed directly, task time goes 4118ms to
4742ms at 300K while reading 0.97x at 25K, so that cost is real rather than noise. The
convergence numbers on the other two engines sit inside the noise band, so the honest statement is
that convergence is not improved and is probably 10 to 20 percent worse. What changes is when the
user can see and use the thread.

It is a soft build-in rather than one hard stall, and the frame counts say so. Frames over
33ms at 300K go 4 to 10 on Chromium, 4 to 18 on WebKit and 8.5 to 35.5 on Firefox. Against that,
the worst single frame drops 6.4x, 7.6x and 7.9x: nothing blocks for four seconds any more, and
startTransition keeps the composer live throughout. I think that is the right trade and the
numbers to argue with are right there.

25K is untouched, by design.

The chunk size was measured, not inherited

One build driven at three chunk sizes, 300K, three rounds of three repetitions:

chunk first row converged worst frame frames over 33ms
16 225.8ms 3199.2ms 239.5ms 15
32 236.1ms 3185.9ms 437.0ms 9
64 221.7ms 3169.7ms 702.9ms 6

The headline does not move: the chunk cannot affect the first commit and does not change total
work. It only distributes the rest, trading the height of the build-in against its length. 32 is
the midpoint and is what #14901 uses; the table is in the source so the next person knows they are
choosing a shape rather than buying a speedup.

Design notes worth reviewing

One owner for scrollTop. Widening inserts rows above the viewport, so something must correct
the scroll position. The autoscroll hook already does it for free while the user is following: a
widening commit is a childList mutation, its MutationObserver runs pinIfFollowing in the same
frame before paint, and because widening only ever prepends, "pin to the bottom" and "shift by the
height inserted above" are the same pixel. So the mount window never writes scrollTop. It
reports the height it inserted, and the hook applies it only when the user is detached, which is
the one case where nothing else moves the viewport at all.

Correcting unconditionally would have been the bug: the extra write emits a scroll event, and
onScroll's delta > 0 branch re-attaches a detached user parked within 24px of the bottom, which
detachFromBottom() puts them in whenever the composer grows. The next widening frame would then
yank them to the bottom. The correction therefore also advances lastScrollTop and
lastDistanceFromBottom with its write so the event it provokes reads as no movement, and it does
that whether or not it wrote anything, which is a separate bug found in review and covered
below.

The window owns the viewport's scroll-anchoring mode, and the correction is document space.
This is the part that changed most in review and it is worth reading, because the first two
versions of it were both wrong in ways that only show up off this machine.

Version one measured the anchor's movement in document space with native CSS scroll anchoring
left on. That double-corrects: the browser has usually already moved scrollTop by the inserted
height, a document-space delta reports the insertion regardless, and applying it on top walked a
detached reader from scrollTop 22,897 to 117,104 across seven widenings and dumped them at the
bottom of a 300K thread.

Version two kept anchoring on and measured the leftover residual in viewport space instead, which
is single-digit pixels, and dropped any frame the reader had scrolled through, because in viewport
space a gesture and a layout shift are the same number. That is correct exactly while the browser
compensates, and this code is not in charge of whether it does. Two ways it does not, both
measured at 150K characters on #9016's fixture with a reader parked 4000px above the bottom:

  • No shipping Safari and no iOS browser has scroll anchoring today. WebKit implemented it in
    February 2026; Playwright's WebKit 26.5 has it, which is exactly why this was invisible here.
    Standing in for those builds with overflow-anchor: none, one dropped frame walked the reader
    19,259px, and dropping every frame under continuous scrolling walked them 45,873px, on
    all three engines.
  • Anchoring is also suppressed per frame on engines that do have it, including after a
    programmatic scroll, which is what a scrollbar drag, PageUp, the arrow keys and middle-click
    autoscroll all become. On Chromium 151 with anchoring available and a reader scrolling that way
    through the build-in: 45,161px of drift, because those frames were both uncompensated and
    skipped.

No measurement taken inside the frame can tell a compensated frame from a suppressed one, so the
browser is now taken out of the loop rather than modelled. The viewport sets
overflow-anchor: none for as long as the mount window is open and gets it back the moment the
window closes, so a settled thread is exactly the thread that shipped before. With nothing else
moving scrollTop, the correction is document space, which subtracts the reader's own movement
arithmetically instead of dodging it, so no frame is ever skipped and there is nothing to
feature-probe. That is the shape #14901
uses. Same fixture, same reader, native anchoring available:

reader behaviour during the build-in on-screen drift, chromium webkit
parked 0px 6 to 13px
scrollbar or keyboard throughout 4,081 to 4,226px, all of it their own scrolling (45,161px before)
continuous wheel 4,612 to 4,852px, likewise their own scrolling 4,489 to 4,819px
whole 4000px gesture inside the FIRST mount window 0px, worst frame 0px
a 600px reflow injected above them mid-build-in 0px (600px before this was compensated)

The last two rows are the two things review found after the design above landed, and both are
worth stating as design points rather than as bugfixes.

Disabling native anchoring has to happen before the first sample, not soon. Setting it from a
layout effect did not: this component is a DESCENDANT of the viewport element, so on the commit
that mounts them both React runs this subtree's layout effects before the viewport's own ref
callback and the ref is still null. Measured, computed overflow-anchor stayed auto from the
first painted row at +305ms to the first widening at +803ms, and a reader who scrolled inside that
window lost 776px of it, or all 4000px if the whole gesture landed there. It is now set in the same
animation frame that captures the anchor, which runs after a paint and therefore after the ref
exists.

And with anchoring off for the duration, the compensation has to cover the whole interval rather
than only the widening commits, because nothing else absorbs a <pre> swapping in Shiki output, a
KaTeX resize or an image landing above the fold. Measured by injecting a 600px height change into
one row above a detached reader mid-build-in: the reader moved the full 600px, against 0px on the
merge base where native anchoring absorbed it. The correction therefore also runs between
widenings, one frame later than the movement, at one getBoundingClientRect and one scrollTop
read per frame. Getting that right also required the anchor to stop being the first row in the
LIST and become the first thing the reader can SEE, descending into a row taller than the viewport
to the element that actually reaches the fold: a row growing between the topmost row and the fold
moves the reader while leaving the topmost row exactly where it was, and an anchor taken there
reports a confident zero.

tests/studio/probe_progressive_reflow.py is the probe that found it. Two of its own first
versions reported clean zeros for two different wrong reasons, so its guards are load-bearing.

The window arms on the cold open as well as the warm one, and originally it did not. This is
the second thing review changed, and it mattered more than the scroll work. ProgressiveMessages
mounts before the history adapter has delivered anything, so the useState initialiser ran at
count === 0, declined because 0 is under the floor, and the whole thread then landed in one
unbounded commit. Measured in the app opening a 220-message thread: mount at count 0, count 220
about 160ms later, same thread id, first paint carrying all 220 rows. Every number in the tables
above was taken on the warm re-open, where it did fire. The window now also arms on the commit
that first fills an empty tree, gated on the previous count being zero rather than on crossing
the floor, so it cannot window a conversation the reader is already in the middle of: a tree that
has never rendered a row has nothing on screen and no scroll position to lose. 300K, chromium,
medians of 5:

before after base
cold open, first painted row 2498.8ms, 220 rows 270.6ms, 16 rows 2536ms
warm re-open, first painted row 315.8ms, 16 rows 262.1ms, 16 rows 2579ms

It arms on the first fill only. The history adapter delivers 0 to 220 in a single step, so that
suffices today; a future loader that streamed 0 to 5 to 220 would arm on the first chunk and
decline it as too short.

A thread that shrinks under a live window drops the restriction rather than clamping. Clamping
start to count makes the row map emit nothing. Measured before the fix: dropping a
220-message thread to 10 while the window sat at start 204 painted an empty column for 2 to 8
frames, 37 to 146ms, on all three engines, with the 10 messages sitting in the store the whole
time. The widen that heals it runs inside startTransition, which is why the blank persisted
rather than lasting a frame.

A run drops the window immediately, on two gates: a reactive one for a run starting after the
window opened, and a re-check inside the rAF for one starting between commit and frame. A thread
that is already running never opens a window at all.

ThreadPrimitive.Messages is replaced permanently, not switched. It renders
MessageByIndexProvider -> RenderChildrenWithAccessor -> ThreadMessageComponent;
MessageByIndex drops the middle one. Rendering one while windowed and the other while settled
would change the element type at that position and React would unmount and rebuild the entire
thread on the convergence commit. Output is identical either way:
RenderChildrenWithAccessor emits no DOM and the components form ignores its accessor.

The escape hatch has no in-app caller today, and that is not an oversight. Every export path in
Studio reads thread.export() from the runtime store, and the store was never gated. I grepped for
DOM readers of the thread ([data-role], html2canvas, window.print) and there are none.
completeProgressiveMounts() is there for #9016's DOM census and for the next consumer that reads
the document instead of the store. Review found it did not work: it sampled the completer set once,
and the completers register from an effect, so a caller in the same task as the open returned in
0.1ms with 16 of 220 rows in the document. It now drains across frames, and an empty set is only
believed after 400ms of looking, because a settled thread and a thread whose history is still
loading present the same empty set. A caller on a settled thread therefore pays 400ms, which is
the right direction to be wrong in when the alternative is exporting a conversation that is not
there yet.

The resetKey re-arm branch is unreachable in the app today, and it is kept anyway.
<GeneratedImageOverlayProvider key={runtimeThreadId}> wraps this subtree, so a thread switch
destroys and rebuilds the component and the window re-arms through the useState initialiser
instead. Confirmed three independent ways: zero arm records from that branch across in-app
switches, a fresh instance at every switch, and the viewport DOM node recreated each time. It is
kept rather than deleted because it is what makes the component correct on its own terms, remove
that ancestor key and it is the only thing standing between a thread switch and the previous
thread's window gating the next one, and it is exercised by the unkeyed control in the edge probe
rather than left untested. The comment on it says all of this, so it does not read as a live
safeguard.

What this costs on a slow machine, which is where users are

The tables at the top are an unloaded desktop. The costs move with CPU speed and the benefits move
further, so both are stated. Chromium CDP throttling first, 300K, medians of 4 alternating rounds:

chromium, 300K unthrottled 4x throttle 6x throttle
first painted row 5081 to 351ms (0.07x) 15557 to 1818ms (0.12x) 21260 to 2484ms (0.12x)
converged 0.96x 1.38x 1.45x
frames over 33ms 4 to 10 5 to 19 5 to 18.5

CDP throttling is Chromium-only, so for the other two the machine is made slow instead of the
renderer: both arms pinned to a single core, alternating, medians of 2 rounds of 3 repetitions.
300K, one core, against the current merge base:

one core, 300K chromium webkit firefox
first painted row 5685 to 663ms (0.12x) 4063 to 499ms (0.12x) 8546 to 867ms (0.10x)
worst single frame 5435 to 1109ms (0.20x) 3970 to 695ms (0.18x) 8433 to 1284ms (0.15x)
converged 1.62x 1.29x 1.27x
frames over 33ms 4.5 to 28.5 9 to 44 17 to 47

The WebKit head arm crashed on the last round of the final pass, so its two figures are carried
from the previous pass on the same commit range and are marked here rather than quietly merged.

So the honest summary of the trade on slow hardware: the first-row win gets bigger, the
convergence penalty gets bigger, and the frame-count regression gets bigger.
I think it still
holds, and more strongly than on a fast machine, because the thing on the other side of the trade
is a single unbroken 8433ms frame on Firefox during which nothing on the page responds at all.
Forty-seven slow frames you can read, scroll and type through are better than one eight-second
freeze. That is a judgement, and the numbers to argue with are above.

What it looks like

Same fixture, 220 messages, 310,603 characters, Chromium, merge base on the left and this branch
on the right. Absolute milliseconds are higher than a packaged Studio's because these are vite dev
servers running React in development mode; the ratios and the differences between the halves are
what they support.

The first painted frame, 400ms after the same re-open. The left half has painted nothing since
before the open was asked for. The right half is already showing the tail of the thread. This
difference is the whole point of the change.

first painted frame

Rows on screen at 0, 400, 1000, 2000, 3000 and 4000ms: before 0 / 0 / 0 / 0 / 220 / 220, after
0 / 16 / 48 / 112 / 208 / 220.

build-in timeline

The same thread once it has settled. Indistinguishable, and every census number equal:
220 messages (110 user, 110 assistant), 43,224 DOM nodes, 55 code blocks, 35,086 highlighted
tokens, 22 tool parts, 22 collapsible outputs, 22 artifact cards, 33 images, 110 action bars, 663
tooltip triggers, scrollHeight 118,004, scrollTop 117,104, top visible row #217 of 220 on both.

settled

Scroll position on open, which is what a reader notices first. The reader wheels 4000px up
while the build-in is still running. The picture can only show that two halves differ; the numbers
say which is right, so they are in the label.

scroll on open

That third panel is a bug this evidence found and it is fixed in 896d425, which is later
than the build in these images. The overflow-anchor: none the correction depends on was being
set from a layout effect, and this component is a descendant of the viewport element, so on the
commit that mounts them both React runs this subtree's layout effects before the viewport's ref
callback: the ref was still null and the style was silently skipped until the first widening.
Measured, computed overflow-anchor stayed auto from the first painted row at +305ms to the
first widening at +803ms, and a reader who scrolled inside that window lost 776px of it, or all
4000px if the whole gesture landed there. It is now set in the same animation frame that captures
the anchor, which runs after a paint and therefore after the ref exists. Re-measured on the fix,
300K, three repetitions, with the entire 4000px gesture inside the first mount window while
110,625px of content is inserted above the reader: parked at 4000px from the bottom, ends at
4028px, worst single frame 4px.

fast gesture

The settled document is the document that shipped before

The safety claim, checked rather than asserted, against current main. #9016's fixture at 300K,
220 messages, both arms, several seconds after the build-in completes:

chromium webkit firefox
innerText, sha256 identical identical identical
normalised innerHTML, sha256 identical identical identical
DOM nodes 43,224 both 43,221 both 43,224 both
rendered text length 215,656 both 215,403 both 215,656 both
scrollHeight 118,004 both 118,004 both 118,009 both
viewport overflow-anchor auto, no inline style left behind same same

Every other census field the fixture records is equal too: messages, user and assistant messages,
code blocks, highlighted tokens, tool parts, collapsible outputs, code execution panes, artifact
cards, images, katex nodes, action bars, tooltip triggers.

Everything withheld comes back, and here is what a reader waits for

Worth being explicit, because it is the opposite of how a virtualizer behaves: mounting here is
driven by time, not by scrolling.
A row arrives because the next animation frame arrived, whether
the reader scrolls or not, and once it is mounted it stays. Scrolling neither mounts anything nor
unmounts anything. The jumps below are a stress test of that claim, not the mechanism.

Deferred work is the trade; missing content would be a bug. So this measures both ends of it. The
reader re-opens the 300K thread and jumps to the TOP forty times while the build-in is still
running, then settles. The needle is a string that exists only in the FIRST message, which is the
last one the window admits, and it stands in for find-in-page, which Playwright cannot drive.
Chromium, three repetitions:

this branch main
first painted row 16 of 220 at 383 to 653ms 220 of 220 at 1902 to 4402ms
first message's own text reachable 4877 to 5818ms 1905 to 4418ms
rows at the end 220 220
the top row is the thread's first message yes yes
final scrollTop after jumping to the top 0 0

So nothing is lost and the reader ends up at the true top of the thread, having asked for it while
it was still building. What it costs is stated in the second row and it is the one number in this
PR that is worse for a reader who is looking for the OLDEST message: at 300K they wait about a
second longer for it than they do today, while everything they can actually see arrives about five
times sooner. A find-in-page issued during those few seconds covers the tail rather than the whole
conversation. Anything that must not see a partial thread awaits completeProgressiveMounts();
nothing in Studio reads the thread from the DOM today.

Tests

studio/frontend/tests/progressive-mount-controller.test.ts, 12 tests over the pure state machine,
including that the window only ever moves start down, that it always reaches null, and that a
window left pointing past the end of a thread that shrank is dropped rather than painting nothing.

studio/frontend/tests/progressive-mount-glue.test.ts, 13 source assertions over the parts that
are not pure (the glue is a .tsx and node's type stripping cannot import one, the same reason and
shape as the existing chat-autoscroll-frame-budget.test.ts). Each names the failure it protects:
the primitive swap that would remount everything, rows hidden rather than withheld, the mount
window writing scrollTop itself, the correction not advancing the intent bookkeeping, a
document-wide viewport query that would find the wrong Compare pane.

tests/studio/probe_progressive_anchor.py is what found the scroll bug above, and it is included
here. It re-opens a 300K thread, scrolls the reader up with a real wheel once the first widening
has landed, and samples the anchored message every frame until convergence. It is worth saying that
its own guards did the work: the first three versions of it silently measured the pinned branch
instead of the detached one, and each time the end-of-run check ("the reader was not detached and
this measured the pinned branch instead") refused to report rather than printing a clean zero.
It needs #9016's fixture page, which is the same dependency the whole measurement above has, so it
cannot run in CI until that lands.

npm test 2962 passed, npm run typecheck clean, npm run build clean, biome reports zero errors
on both new source files.

Notes for review

  • One biome-ignore in progressive-messages.tsx, on useExhaustiveDependencies. mountWindow
    is the trigger for the layout effects rather than a value their bodies read, so the rule cannot
    see it; dropping it would run them once and never correct a shift again.
  • Playwright's WebKit is a proxy, not the webview Desktop embeds, and here that proxy is
    actively misleading. See the section at the top; it is the most important thing in this PR.
  • Cross-platform CI ran on a staging replica of this branch rather than in the org queue, which is
    currently carrying 35+ pending checks per PR. Green on all of: Workflow trigger lint, Unsloth UI
    CI, Unsloth API CI, Unsloth GGUF CI, Windows Unsloth UI CI, Windows Unsloth API CI, Windows
    Unsloth GGUF CI, Mac Studio GGUF CI, Mac Studio UI + API + Update CI. So ubuntu-latest, macos-14
    and windows-latest all pass. The staging PR is closed, never merged.
  • firstRowMs is not in Studio: measure where a heavy thread stalls, across engines and thread size #9016's harness on main. Every measurement above used an identical
    patched copy in both arms. It is worth folding into Studio: measure where a heavy thread stalls, across engines and thread size #9016 so this stays measurable, and I have
    not done that here to keep this diff to the change itself.

The composer during the build-in, which is the one number that got worse

An earlier head showed a Firefox composer regression, 36ms to 106ms median, and this PR carried it
as an open question because it predated the scroll rewrite. It is now re-measured on the current
head and it is real. Firefox 153, 220 messages, this branch against the merge base, arms
alternating, two rounds of three repetitions each:

Firefox, per-keystroke latency while the thread builds in merge base this branch
median 35.5ms (33 to 45) 92.5ms (72 to 126)
p90 48ms (44 to 60) 135ms (117 to 158)
worst 58.5ms (50 to 61) 143ms (120 to 159)
rows mounted while those keys were typed 220 of 220 16 or 48 of 220
every character landed in the composer yes yes

Read the last two rows before the first three, because they are what the first three mean. On the
merge base the re-open is one blocking commit, and in all six merge-base repetitions every
keystroke landed with all 220 rows already in the document. The probe cannot even start typing
earlier: the call that focuses the composer does not return until the commit is over. So the
merge base's 35.5ms is not typing through a rebuild, it is typing after one, and the same run
records a 3237ms unbroken stall where that typing could not have happened.

The honest form of this is therefore not "35ms became 92ms". It is that a window in which nothing
could be typed at all became a window in which typing works at 92ms median, and a 3237ms stall
became a 337ms one. startTransition is what buys that, and 92ms is what it costs.

Once the thread settles the two are identical. #9016's harness measures the composer on a settled
thread by construction, and at 300K characters on Firefox over four alternating rounds of three
repetitions it reads 34.0ms on both arms (round medians 33, 35, 34, 34 against 34, 34, 34, 33),
which is the 33 to 34ms double-rAF paint floor both arms were already sitting on.

Chromium and WebKit were not re-measured on this head and still carry the earlier head's numbers.

The reopen number an external study reported, reconciled

A performance study run against a frozen main on real Desktop hardware, with CPU throttling
disabled, reported this branch as inconclusive on its 300K reopen cell, with the medians moving
the wrong way, chromium +15.5% (n=3/3) and firefox +13.6% (n=3/3), samples overlapping the observed
spread. Reopen speed is the point of this branch, so that needed an answer rather than a footnote.

That metric measures full convergence, not first paint. Its reopen clock starts immediately
before openThread() and stops the first frame on which messageCount() >= before, where
messageCount() is document.querySelectorAll("[data-role]").length. The stop condition is "all
220 rows are back in the document". A change that puts the first rows on screen sooner while the
tail arrives later is invisible to it by construction, and in fact scores worse, because a chunked
mount does strictly more commits than one big one. So the study's number is a convergence
regression, and it is real. It is not a statement about when the user first sees anything.

The study's own raw output already contains the other half. On the base arm it logs 7 rAF
callbacks across a 1.8s window with a single 1668.9ms frame. Seven frames in 1.8s is a renderer
that painted nothing.

Both quantities, measured here on the merge base against this head, 300K characters, 220 messages,
six alternating repetitions per arm in one browser process, every repetition gated on the thread
actually unmounting before it is re-opened, and gated on both arms agreeing on highlighted-token,
DOM-node, code-block and message counts before any timing is taken:

merge base this branch
first real content painted, chromium 2554ms (220 of 220 rows, 117757px) 314ms (16 of 220 rows, 7132px)
first real content painted, firefox 3143ms (220 of 220, 117758px) 317ms (16 of 220, 7128px)
longest frame painting nothing, chromium 2533ms 331ms
longest frame painting nothing, firefox 3109ms 387ms
full convergence, all 220 rows, firefox 3149ms 3707ms (+17.7%)
full convergence, all 220 rows, chromium 2554ms roughly +5 to +15%, see below

The structural fact that settles it: on the merge base, first paint and convergence are the same
instant
, 2554 against 2554ms on chromium and 3143 against 3149ms on firefox. The base has no
progressive behaviour at all, so it freezes and then commits all 220 rows in one frame, which is
why the study's convergence metric happened to also be its first-paint metric on the base arm and
is not on this one. That is the entire disagreement.

So the trade is an 8 to 10x improvement in time to first paint, and the removal of a 2.5 to 3.1
second frame in which the renderer cannot paint at all, against a last row that lands later.

Three things about that table are weaker than the rest and should not be quoted as though they
were not.

The chromium convergence delta is soft. A gated run gives +5.5% and an earlier run gave +14.3%.
The base is stable across runs (medians 2554 and 2557) and the head is not (2695 and 2922, an 8%
swing). Pooling all twelve repetitions per arm gives +10.3% with base spanning 2387 to 3038 and
head 2579 to 3082, which overlap. On chromium the direction is a regression and the magnitude
is no tighter than roughly 5 to 15%. Firefox is the cleaner arm and its +17.7% is only barely
non-overlapping (base max 3505, head min 3463).

The first-paint result is not soft: pooled chromium base 2386 to 3038ms against head 279 to
406ms, and firefox base 3085 to 3499ms against head 300 to 406ms. No overlap on either engine.

#8992 was in neither arm when that table was taken. It is in both arms now, and the question
it raised has been answered.
#8992 is +247/-33 in thread.tsx, the same file this branch
changes, and the same study rates it a confirmed improvement on this very convergence metric
(chromium -29.8%, firefox -31.0%), so its win and this branch's cost were originally measured
against bases that each lacked the other. #8992 then merged to main as b0843382d, and this
branch's head is a merge of main, so both the merge base and the head now contain it. Re-measured
on that footing, 12 interleaved repetitions per arm per engine: the cost survives, at
chromium +17.0% with the ranges disjoint and firefox +12.0% with the ranges overlapping on one
of twelve pairs, which by the min-max rule used throughout this description is not resolvable.
The band is unchanged, so #8992 neither absorbs the cost nor amplifies it. Note this reverses which
engine is the clean arm: with #8992 present chromium is the disjoint one and firefox the soft one,
the opposite of the table above. Full numbers, the discrimination check and the remaining loose end
on firefox cold reopens are in the comments on this PR.

Absolute milliseconds here are about 1.5x the study's, on different hardware and a different
viewport, so only the within-run base-against-head comparison is meaningful. Do not read my
milliseconds against theirs. WebKit was not re-measured for first paint; the study's WebKit cells
corroborate the direction (worst frame 1732ms base against 208ms head) and that is all I have there.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ecb065c5df

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +163 to +169
const shift =
captured.element.getBoundingClientRect().top +
viewport.scrollTop -
captured.documentOffset;
// The hook decides whether this is acted on; see adjustForContentInsertedAbove. Rounding
// down to whole pixels keeps a subpixel reflow from issuing a scroll write every frame.
if (Math.abs(shift) >= 1) adjustForContentInsertedAbove(shift);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Disable native anchoring before applying the manual correction

When a user detaches by scrolling upward before progressive mounting converges, Chromium's default scroll anchoring can already increase scrollTop to compensate for the prepended rows. The viewport does not set overflow-anchor: none, so this additional correction applies the inserted height a second time, moving the reader away from the content they were viewing and potentially clamping/re-attaching them near the bottom. Disable native anchoring on this viewport or calculate only the remaining uncompensated movement.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Rejecting the claim, though the second half of the sentence is what the code already did. The correction is not the inserted height, it is the residual: the anchor is captured in viewport space, so a viewport the browser has already compensated reports zero and nothing is applied. Applying the full insertion on top of native anchoring was the earlier version of this code and it did exactly what you describe, walking scrollTop 22,897 to 117,104 and dumping the reader at the bottom; that is why it measures a residual now. Measured on the current code at 150K characters with a reader parked 4000 px above the bottom: per-widening corrections of -3 to -5 px and 8 px of total on-screen drift across the whole build-in, on Chromium 151, WebKit 26.5 and Firefox 153.

The real defect in this area is the one in the sibling item about gesture frames, which is where the residual assumption breaks: on an engine that does not anchor, the residual is the whole insertion. That is fixed in 5a2ba76, by feature-probing whether the engine compensates rather than by disabling native anchoring, so the compensating engines keep the behaviour that is measured above.

danielhanchen and others added 3 commits August 17, 2026 04:00
… through

The correction was measured in document space, following LibreChat#14901. In our
viewport that double-corrects: Chromium's own scroll anchoring has usually already
moved scrollTop by the inserted height, and adding the full insertion on top of it
walked a detached reader 22,897 -> 117,104 and dumped them at the bottom of the
thread. Viewport space measures the residual instead, which is single-digit pixels.

That exposed the other half: across the transition-deferred gap the reader's own
wheel is indistinguishable from a layout shift in viewport space, so a 4000px scroll
during a widening was cancelled inside the frame. The hook now counts user gestures
and the correction skips any frame one landed in.

Found by tests/studio/probe_progressive_anchor.py, added here.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

…the scroll correction

Four fixes, each with a measurement behind it.

1. The cold open never armed. ProgressiveMessages mounts before the history adapter
   has delivered anything, so the useState initialiser ran at count 0, declined, and the
   whole thread then landed in one unbounded commit. Measured in the app: mount at count
   0, count 220 about 160ms later, same resetKey, first paint carrying all 220 rows. The
   window now re-arms on the commit that first fills an empty tree. Gated on the previous
   count being zero rather than on crossing MIN_PROGRESSIVE_MESSAGES, so it cannot window
   a conversation the reader is already in the middle of. 300K, chromium, medians of 5:
   cold open 2498.8ms/220 rows to 270.6ms/16 rows, against a base of 2536ms.

2. The scroll correction assumed the engine had already done the work. It measured the
   anchor in viewport space, which reports the residual left by CSS scroll anchoring, and
   dropped any frame the reader gestured through on the grounds that the residual is
   single-digit pixels. Both hold only where the engine anchors. WebKit implemented scroll
   anchoring in February 2026, so every shipping Safari and every iOS browser today does
   not, and Playwright's WebKit 26.5 does, which is why this was invisible. Measured at
   150K with overflow-anchor:none forced on the viewport: one dropped frame walked a
   parked reader 19,259px, and dropping every frame walked them 45,873px, on all three
   engines. The correction is now a tested pure function that picks its space from a
   one-off feature probe: viewport-space residual where the engine compensates, document
   space where it does not, and no frame is dropped in the second case. Same fixture with
   the fix: 12px and 13px.

3. A thread that shrank under a live window painted nothing. The row loop clamped start
   to count, which makes it emit zero rows. Measured: dropping a 220-message thread to 10
   while the window sat at start 204 painted an empty column for 2 to 8 frames on all
   three engines. The window is dropped in that commit instead.

4. completeProgressiveMounts sampled the completer set once, and the completers register
   from an effect, so a caller in the same task as the open returned on an empty set with
   16 of 220 rows in the document. It now re-reads the set across frames, registers from a
   layout effect, and resolves on the commit that actually dropped the window rather than
   on a two-frame timer started at the call.

Also resets adjustImplRef in the autoscroll teardown alongside the other two impl refs.

Tests: the correction is now testable arithmetic, with both branches covered. The glue
assertions read comment-stripped source for their positive matches too, so commenting the
feature out no longer leaves them green, and every source slice requires both of its
markers instead of silently widening to the end of the file. npm test 3514 passed,
typecheck, build and biome clean.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…rrection is zero

Two more paths where the scroll correction reads the wrong thing, both raised in review and
both reproduced here.

A scrollbar drag, PageUp, the arrow keys and middle-click autoscroll reach the autoscroll
hook as nothing but a scroll event. They detach the reader through onScroll's 2px
accumulator, but they never bumped the user-gesture counter, which only onWheel and
onTouchMove touched. A correction measured across one of them therefore read the reader's
own movement as a layout shift and reversed it. onScroll now counts any scroll with a
non-zero delta. The two scrolls that are not gestures stay excluded by arithmetic rather
than by a flag: the corrective write advances lastScrollTop with itself, and a native
scroll-anchoring adjustment is advanced past by the resync below, so both arrive with
delta 0.

And a widening that native scroll anchoring absorbed in full needs no scroll write, but
the browser still moved scrollTop by the whole inserted height and still fires a scroll
event for it. Measured on a 400px scroller with 2000px inserted above the scroll position:
one scroll event carrying the new offset, on Chromium 151, WebKit 26.5 and Firefox 153.
The old early return left lastScrollTop a whole insertion behind, so that event arrived as
a large downward scroll nobody made, and a reader who had deliberately detached within the
24px re-attach threshold, which detachFromBottom puts them at whenever the composer grows,
was silently re-attached and yanked to the bottom on the next widening. The mount window
now reports every widening including the zero ones, and the hook resyncs its bookkeeping
whether or not it wrote.

npm test 3516 passed, typecheck and build clean.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

danielhanchen added 2 commits August 17, 2026 10:17
completeProgressiveMounts re-read the set across frames but still returned at the first
empty reading, so the one case it was rewritten for stayed broken: a caller in the same
task as a cold open finds the set empty because the history load has not finished, and two
animation frames is nowhere near the roughly 160ms that load takes. The remaining passes
never ran, because the loop exited on the first pass.

An empty set is now only believed after 400ms of looking, while a set that has been
non-empty and has since drained is believed immediately. A caller on a settled thread
therefore pays 400ms, which is the right direction to be wrong in: the alternative is a
screenshot or an export of a conversation that is not there yet, and anything reading the
whole thread out of the DOM is already doing something far more expensive.

npm test 3516 passed, typecheck and build clean.
…edict it

The correction measured the residual left by CSS scroll anchoring and dropped any frame the
reader had scrolled through, on the grounds that the residual is single-digit pixels. That
is true exactly while the browser compensates, and this code was not in charge of whether
it did. Two ways it does not, both measured at 150K characters on the 9016 fixture:

- No shipping Safari and no iOS browser has scroll anchoring at all today. WebKit
  implemented it in February 2026 and Playwright's WebKit 26.5 has it, which is why this
  was invisible here. Standing in for those builds with overflow-anchor:none, one dropped
  frame walked a parked reader 19,259px and dropping every frame walked them 45,873px, on
  all three engines.
- Anchoring is also suppressed per frame on engines that do have it, including after a
  programmatic scroll, which is what a scrollbar drag, PageUp, the arrow keys and
  middle-click autoscroll all become. On Chromium 151 with anchoring available and a reader
  scrolling that way through the build-in: 45,161px of drift, because those frames were
  both uncompensated and skipped. Counting those scrolls as gestures, which is what the
  previous commit did, made this worse rather than better: it added skips to frames that
  needed the correction most.

No measurement taken inside the frame can tell a compensated frame from a suppressed one,
so the browser is taken out of the loop rather than modelled. The viewport sets
overflow-anchor:none for as long as the mount window is open and gets it back the moment
the window closes, so a settled thread is exactly the thread that shipped before. With
nothing else moving scrollTop, the correction is document space, which subtracts the
reader's own movement arithmetically instead of dodging it, so no frame is ever skipped.
That removes the feature probe, the gesture counter and the whole notion of a skipped
frame. This is the shape LibreChat#14901 uses.

Measured on the same fixture and reader, native anchoring available, all three engines:

  parked reader           12px drift (chromium), 6 to 13px (webkit)
  scrollbar or keyboard   4,081 to 4,226px (chromium), all of it the reader's own scrolling
                          against 45,161px before
  continuous wheel        4,612 to 4,852px (chromium), 4,489 to 4,819px (webkit), likewise
                          their own scrolling

npm test 3514 passed, typecheck, build and biome clean.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Aug 17, 2026
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Aug 17, 2026
danielhanchen added 2 commits August 17, 2026 10:52
…hen the thread goes away

Three more from review.

getBoundingClientRect().top is measured against the window, so it also moves when the
scroll container moves, and this container moves for reasons that have nothing to do with
the thread: the composer grows a line, the mobile browser chrome slides away, a parent
relayouts, the window is resized. Any of those landing between the capture and the widening
commit read as content inserted above and were corrected away, moving a detached reader for
no reason. Both ends now go through one sampleAnchor that subtracts the container's own top.

completeProgressiveMounts awaits a promise this component resolves from an effect. If a
thread switch or a navigation unmounted the component first, the layout effect's cleanup
removed the completer from the set but left that promise pending forever, so a DOM capture
that raced an unmount hung rather than completing. Outstanding waiters are now flushed on
unmount, and the ref is emptied by the flush rather than by the effect that schedules it,
so a cancelled frame leaves them to be settled rather than dropping them.

probe_progressive_anchor.py cannot run on this branch, because it drives 9016's fixture and
9016 is not merged. It now exits with a message naming the three files it needs instead of
a bare ModuleNotFoundError. Not fixed by vendoring a copy of the harness: two copies of a
measurement harness is how the two copies stop agreeing, and this probe's numbers are only
comparable to 9016's while there is exactly one of it.

npm test 3515 passed, typecheck, build and biome clean.
One conflict, in thread.tsx, where #9042 replaced the message list's `components` map with a
propless render prop so that assistant-ui's bail-out can skip a message subtree. This branch
had replaced the same element with ProgressiveMessages.

Resolved by taking both: ProgressiveMessages now takes `renderMessage={renderThreadMessage}`
and maps MessageByIndexProvider over its bounded index range, rendering that one shared
propless element in every row. That keeps #9042's optimisation exactly, because the bail-out
it relies on is React's own element-identity check, and it is if anything a better fit here:
a widening commit changes the row count every frame, which is precisely when handing React an
identical element for the rows that already existed pays.

ThreadPrimitive.MessageByIndex is not used, because its props carry the `components` object
#9042 removed. MessageByIndexProvider is the same provider ThreadPrimitive.Messages mounts;
what is dropped is RenderChildrenWithAccessor, whose accessor the thread's slot ignores and
which emits no DOM.

tests/thread-delete-render-budget.test.ts pinned the old JSX by spelling. It now pins the
property instead: the slot reaches the row map, and neither list takes a components object.

npm test 3623 passed, typecheck, build and biome clean.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

The layout effect that set overflow-anchor:none on the viewport did not run in time, and
the window it left open was the worst possible one: the first one.

This component is a descendant of the viewport element, so on the commit that mounts them
both, React runs this subtree's layout effects before the viewport's own ref callback.
viewportRef.current is still null, the style is silently skipped, and it only lands on the
next commit, which is the first widening. Measured on that version: computed overflow-anchor
stayed auto from the first painted row at +305ms until the first widening at +803ms, so that
widening ran with anchoring live and the document-space correction was applied on top of the
browser's own. A reader who scrolled 4000px inside that window was left 776px short of where
they parked, and one whose whole gesture landed inside it was carried back to 24px from the
bottom of a 118,004px thread. Neither happened on the merge base.

The style is now set in the same requestAnimationFrame that captures the anchor, immediately
before the sample it would otherwise invalidate. That frame runs after a paint, so the ref is
populated by definition, and it is by construction before any widening rather than merely
soon. The layout effect keeps only the restore, and an unmount cleanup restores it too.

Measured after, 300K, chromium, three repetitions, the reader's whole 4000px gesture landing
inside the first mount window while 110,625px of content is inserted above them: parked at
4000px from the bottom, ends at 4028px, worst single frame 4px. The merge base under the
same gesture never widens at all and holds 4000px.

npm test 3623 passed, typecheck, build and biome clean.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…etween widenings

Two findings from review, one of which turned out to be the other's cause.

Disabling native scroll anchoring for the whole mount window means nothing absorbs a
relayout above the fold that is not a widening: Streamdown replacing a pre when Shiki
finishes highlighting it, KaTeX resizing a formula, an image landing. The autoscroll hook
does not cover it either, because its mutation path pins a following reader and
deliberately leaves a detached one alone. Measured by injecting a 600px height change into
one row above a detached reader while the window was open: the reader moved the full 600px,
against 0px on the merge base where native anchoring absorbed it. The correction now also
runs between widenings, one frame later than the movement, which is invisible for a single
reflow and is what keeps it to one getBoundingClientRect and one scrollTop read per frame.

The first attempt at that measured nothing, and the reason is the second finding. The
anchor was the first row in the list rather than the first row the reader can SEE. Widening
prepends above everything, so for a widening any row will do; a relayout does not, because
a row growing between the topmost row and the fold moves the reader while leaving the
topmost row exactly where it was. Both paths now hold the first visible row, and that
improved the widening correction too: the whole-gesture-inside-the-first-window case, three
repetitions at 300K with 110,625px inserted above a reader parked 4000px from the bottom,
goes from 28px of drift and a 4px worst frame to 0px and 0px.

tests/studio/probe_progressive_reflow.py is the probe that found it, included with its own
guards, since both of the things it initially got wrong produced a confident clean zero.

npm test 3625 passed, typecheck, build and biome clean.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…chunk boundary

A window whose start is at or past the end of the thread already causes every row to be
rendered, because the row map falls back to no restriction. The STATE was left saying start
204 though, so the next widen clamped to count and subtracted a chunk: against a thread that
had shrunk to 100 messages that is start 68, and rows 0 to 67, which the previous commit had
just mounted, are unmounted again. Nothing in this design is allowed to unmount a row, and
this was the one path that did.

Fixed at both levels, because they protect different things. widen now returns null for any
window at or past the end, which is a property the state machine can hold on its own and is
covered by a test that asserts monotonicity for every reachable window and count rather than
for one example. And the glue reconciles the stale state during render instead of leaving it
for the next frame, so the committed state matches the tree that was committed with it.

npm test 3627 passed, typecheck, build and biome clean.
@danielhanchen

Copy link
Copy Markdown
Member Author

Tauri Linux debug build (no codesign) on c1d5bb9a4 was the apt mirror, not this branch

The job hit timeout-minutes: 25 at 25m07s, and GitHub reports that as "The operation was canceled". Every assertion in it had already passed before the clock ran out:

test result: ok. 373 passed; 0 failed; 0 ignored
10 of 10 launches reached the backend spawn and stayed up

Where the 25 minutes went, per step:

step duration
sudo apt-get update and the system deps 1122.8s
npm ci 53.8s
cargo test --no-fail-fast 39.3s
tauri build --debug --no-bundle 51.5s
the 10 launch smoke 203.5s

So the actual work took about 6 minutes, which is what this job costs on main: the last five studio-tauri-smoke.yml runs there took 449, 406, 401, 427 and 422 seconds and all passed. The 18.7 minutes in front of it is the Azure apt mirror, the same thing that timed out Chat UI Tests (chat) on the previous head while it crawled a 13.6 MB package at roughly 50 KB/s.

Nothing in this branch is compiled into that step, so there is no mechanism by which it could be responsible. Re-running.

@danielhanchen

Copy link
Copy Markdown
Member Author

Closing the open question in the description: whether this branch's full-convergence cost survives #8992 being present. It does. And the caveat itself is now stale, which is the first thing to correct.

#8992 is no longer in neither arm

#8992 merged to main today at 13:19 UTC as squash commit b0843382d. This branch's head c1d5bb9a4 is itself a "Merge branch 'main' into perf-progressive-mount", so it already contains it, and so does the merge base. Verified both ways:

git merge-base --is-ancestor b0843382d bfcaea465   -> true
git merge-base --is-ancestor b0843382d c1d5bb9a4   -> true
git merge-base c1d5bb9a4 origin/main               -> bfcaea465  (= current main tip)

So the run the description asks for needs no synthetic merge, and no conflict resolution could have distorted it. Control is bfcaea465, treatment is c1d5bb9a4, and git diff --name-only between them is exactly this branch's ten files. None of #8992's files appear, because they are byte-identical on both sides.

Result: the cost is still there

Harness reopen ms, the same full-convergence metric, 12 interleaved repetitions per arm per engine, alternating order within each repetition.

engine control median (range) this branch median (range) delta ranges
chromium 2254.4 ([1949.3, 2423.5]) 2637.0 ([2530.3, 2796.3]) +17.0% disjoint
firefox 2250.0 ([2052, 2373]) 2520.0 ([2290, 2808]) +12.0% overlap

Firefox overlaps on exactly one of the twelve pairs, control 2373 against treatment 2290, 83 ms. By the same min-max rule I have been applying to my own numbers all along, that is not resolvable, so do not quote the firefox +12.0% as a result. A rank test puts it at U=139/144, p=0.0001, which I report alongside the overlap rather than instead of it.

One correction to the description. It says chromium is the soft arm and firefox the clean one. With #8992 present that is reversed: chromium is now the disjoint arm and firefox the overlapping one. The magnitude is unchanged, still the +10 to +17% band, so #8992 neither absorbs this cost nor amplifies it.

The discrimination check

Before trusting any of the above, the setup has to be able to see the effect it is looking for. Time to first real content painted, same runs:

engine control this branch delta
chromium 1808.7 ms 254.9 ms -85.9%
firefox 2412.0 ms 279.5 ms -88.4%

Both disjoint. Rows in the DOM at first paint: 220 on the control in all 24 runs, 16 on this branch in all 24. The harness's own paintWaits agrees independently, 1 paint on the control against 24 to 27 on chromium and 9 to 11 on firefox. The trees are what they claim to be.

Both worktrees stayed clean across all 48 runs and the checksums of every changed source file and of the harness were taken before and after each probe and never moved. The harness file is the same git blob in both arms.

What this does not settle

The trade in the description stands unchanged: an 8 to 10x improvement in time to first paint and the removal of a multi-second unpaintable frame, against a last row that lands 10 to 17% later.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

The initial tail was chosen by counting messages, but a message whose role
the thread supplies no component for paints nothing: threadMessageKind
returns "none" and ThreadMessage renders null, so the row has no height.

Both importers preserve the system role (chat-import.ts,
openwebui-import.ts), so an imported conversation whose last 16 messages are
system entries opened on sixteen zero-height rows and no conversation at all
until a later widening frame rescued it, which is the stall this window
exists to remove rather than cause.

Size the tail by walking back until it holds a full tail of renderable rows.
Renderability comes from threadMessageKind through the new rendersAsRow, so
there is no second list of roles to drift from the renderer. Reaching further
back only ever mounts more, so the window still only widens. A thread with
fewer renderable rows than one tail is not windowed at all.

The predicate is read imperatively off the store, not through useAuiState: a
selector touching the messages array runs on every store write, which would
walk the thread once per keystroke and once per streamed token.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5c6e6d50e2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +405 to +407
// A pending widening capture owns the correction until its layout effect runs; stepping in
// between would correct the same movement twice.
if (!viewport || anchorRef.current) return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the idle baseline before yielding to widening

When above-fold content changes after the previous widening commit but before the next captureAnchor callback—for example, a detached reader collapses a reasoning block or an async Shiki update commits between frames—this return prevents the idle sampler from comparing its pre-change baseline, while the widening capture records only the already-shifted layout. The subsequent widening correction therefore sees only the newly prepended rows and permanently leaves the earlier displacement. Unlike the previously reported visibility branch, the fresh evidence here is the pre-capture ordering gap: anchorRef.current is populated before this callback on every widening frame, so the only baseline predating that task is discarded rather than measured.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Refuted in a browser, on the mechanism this item names.

The specific claim was that the widening capture records only the already-shifted layout, so the correction sees just the newly prepended rows. Injecting 1200px above the fold in the disputed gap, against the same anchor element still connected, the capture's baseline comes back identical to the control to the pixel (vo -1029, st 29839), while the layout effect's now sample is exactly +1200. anchorCorrection returns 11526 to 12726, which is the prepend plus the reflow. At 600px it returns 11526 to 12126. The correction carries the reflow.

Net result over ten repetitions at 600 and 1200px: indistinguishable from the zero-injection control, -44 every time, where the -44 is the scene's own baseline. The displacement lasts about two frames and is then fully removed by the next widening commit. Six 600px injections do not accumulate.

The premise is correct and worth recording: idleRan is 0 in every repetition, with 28 to 40 skipped ticks, so the idle sampler genuinely never runs while the window is open. The widening layout effect absorbs the reflow instead, which is why the early return is not a lost baseline.

One neighbouring case does leave a residual, reported because it is real rather than because it changes this verdict: injection in a later task within the same gap leaves roughly 130 to 200px of 1200px. It is bounded, non-accumulating (six 600px injections totalling 3600px left 80 to 165px), and lands at message 220 of 220, after the final widening commit, where no later captureAnchor exists and overflow-anchor has already gone back to the browser. Different and much narrower window than this item describes.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f3f12d776e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

*
* Probe: tests/studio/probe_compact_tail_gap.py.
*/
export const INITIAL_MESSAGES = 16;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Increase the tail for consecutive compact assistant imports

For imported CSV/Open WebUI histories whose tail contains consecutive compact assistant messages, 16 rows cover only about 1280px using this file's measured 80px assistant-row height, rather than the documented 1643px alternating-role total. Thus an otherwise supported 1800px viewport can still paint a substantial empty band until the next expensive widening frame. The fresh case not covered by the prior alternating-tail measurement is the importers' arbitrary role ordering; size the initial tail for the shortest valid single-role sequence or adapt it after measuring the viewport.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not taking this one.

The compact-tail case is already measured rather than assumed. INITIAL_MESSAGES is documented from a 144-message thread whose last 24 messages are one-word replies, three rounds a point, across Chromium, Firefox and WebKit, at 900, 1080, 1440, 1800, 1840 and 1860px of clientHeight. At every one of those the empty band on the first painted commit is exactly the band a settled thread has, so none of it belongs to this window. The probe is tests/studio/probe_compact_tail_gap.py.

The undershoot above 1890px is known, quantified and deliberately left: 10px of band at 1900px, 110px at 2000px, 270px at 2160px, all closed by the first chunk with nothing unreachable meanwhile.

The remedy proposed here, sizing from the viewport, is the option that was considered and rejected on the merits: deriving the window from clientHeight has to guess how many rows fill the viewport before mounting any of them. The alternative it is measured against paints nothing at all for 1318ms at 2160px and then the whole thread at once. 270px of band for a third of a second at a height that needs a 4K panel in portrait is the better trade, and 16 is also what LibreChat ships for the same job.

So this is a tuning preference against a documented trade-off rather than a correctness bug.

…eopen paint floor

Sizing the first commit on renderable rows walks back across every message
that does not render, and that walk was unbounded: sixteen visible messages
followed by two hundred system entries walked to index zero, so the commit
rebuilt every provider in the thread. That is the bound this window exists to
create, so cap the span at four tails. A thread has to be three quarters
non-rendering across its whole tail before the cap binds; below that the
window is exactly the renderable-row one. When it does bind the first commit
shows whatever renders inside the cap and widening reaches the rest within a
few frames, which is bounded either way.

The heavy-thread smoke declared a fixed floor of one double-rAF wait for
'reopen ms'. That was right while the tail arrived in a single commit. The
mount window brings a long thread back over several frames, and 'reopen ms'
runs until the message count is whole, so it now spans one wait per commit:
one at 25K and ten at 100K. Read the count the reopen loop already reports
instead of declaring it, and resolve the declaration per row so a hand
written literal is still caught when it drifts.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 81cfd8a925

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…croll anchoring back

removeProperty empties the inline declaration but keeps the attribute, so a converged
viewport carried style="" where the shipping one carries no style at all. Inert, but it
was the only difference a whole-document structural digest could find between this branch
and its merge base at 100K and 300K: 45,014 normalized lines, one changed line, against a
null control that scored exactly zero. Byte-identical is worth being able to state rather
than footnote.

Both hand-back paths now go through one helper, and the test asserts there is no second
removeProperty outside it, so a future path cannot reintroduce the residue.
@danielhanchen danielhanchen changed the title Studio: stop a long thread rebuilding every message before it can paint Studio: paint a long threads newest messages immediately instead of rebuilding all of them first Aug 22, 2026
@danielhanchen danielhanchen changed the title Studio: paint a long threads newest messages immediately instead of rebuilding all of them first Studio: paint a long thread's newest messages immediately instead of rebuilding all of them first Aug 22, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

Re-measured this independently on a second machine, with a concurrent same-commit null control in
band, and updated the body with the result. Parity first, then timings.

UI idempotency: holds. Whole-document structural digest of the settled viewport after close,
reopen and full settle, five reps per arm, three arms concurrent (two independent builds of the
merge base plus this head). Both nulls scored 0 changed lines at 100K (16,466 lines) and 300K
(45,014 lines), so the floor is genuinely zero. Base against head scored exactly 1 line, and the
whole of it was style="" left on the viewport root: removeProperty empties the declaration but
keeps the attribute. Computed overflow-anchor was auto on both arms, so it was inert, but a
byte-identical converged document is worth being able to state rather than footnote. Fixed in
6af84c8, with both hand-back paths routed through one helper and a test asserting there is no
second removeProperty outside it. Everything else already matched exactly: 220 rows, 38,752 nodes,
55 <pre>, 35,086 highlighted tokens, 33 images, 22 tool parts, 22 artifact cards, scrollHeight
120,402, scrollTop 119,502.

Nothing visibly reflows either. The bottom gap is 194px on the first painted frame and 199px after,
and the merge base's single frame is also 194 then 199, so no part of that band belongs to this
change. A bottom-parked reader drifts 5px total across 47 frames and 1.65s. With a real wheel
gesture against a detached reader, drift is 3,195px on head and 3,195px on base: inserting 204
messages above a scrolling reader adds 0px.

Performance. The win reproduces in shape and roughly in ratio, but only as first paint, which is
what the table always said. On this host first painted row at 300K goes 1542.2 -> 212.0ms (0.14x, a
7.3x win) against a claimed 0.10x, and full convergence goes 1542.2 -> 1845.6ms (+19.7%) where the
body already states 1.18x. The base figure here is 1.5 to 2.2s rather than 4.3s, so this box is 2 to
3x faster than the one that produced 4289 and the ratios are the thing to read.

The largest effect is the one that was understated: longest single main-thread stall on reopen,
2175.8 -> 294.9ms, -86.4%, against a null of -11.8%
. Worst frame 2130.1 -> 282.3ms. That is the
frame a user actually feels. Frames over 33ms go 3 -> 9 at 300K, which the body already declares,
and each of those nine is far shorter than the single 2,130ms frame it replaces.

Every other metric is inside its null: keystroke, scroll, jump, menu and delete at all three sizes,
on wall time, worst frame and frames over 33ms. Reopen-to-convergence at 300K is itself inside the
null band on the harness run (+6.7% treatment against -11.8% null) and only reads as a clear
regression on the cleaner probe run.

Mechanism confirmed armed from the artefact rather than assumed: reopen.paintWaits 1 -> 8 at 100K
and 1 -> 24 at 300K on head, unchanged at 1 on both base arms, and 1 -> 1 at 25K where 20 messages
is below the threshold of 40. Distinct served-bundle SHAs per arm, engine read from the payload,
each arm its own worktree and its own install.

Two things do change under the reader and I would rather state them than have someone find them.
The scrollbar thumb steps from about 12 percent of the track to 0.75 percent in 8 visible steps over
1.65s. And for those 1.65s the thread reports its own length as 16, then 48, then 80 messages, so a
reader who drags to the top inside the window reaches something that looks like the start and is
not. The merge base cannot exhibit either, because it shows nothing at all until 1.54s. Both are the
honest cost of the design and both are now in the body.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 22, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 22, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6af84c8907

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tests/studio/playwright_heavy_thread.py Outdated
# still worse than either: that left a full ~33ms vsync floor of constant baseline in
# both ends, which compresses the ratio towards 1 and can report a real reopen curve as
# flat when the smallest fixture rebuilds near the floor.
("reopen ms", _action("reopen", "ms"), _floor_from("reopen", "paintWaits")),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep progressive frame latency in the reopen metric

When longer threads require more widening frames, paintWaits grows with thread size because these double-rAF polls overlap the application's own rAF-driven progressive commits. Subtracting every wait from reopen ms therefore removes real, size-dependent convergence latency rather than just the constant delay needed to observe a completed reopen, distorting the growth ratio and potentially making a regression appear flat. Keep the progressive-frame time in this metric and subtract only the final observation floor, if any.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Correct, and it is worse than a distorted ratio: it inverted the sign. Fixed in b4b38c0.

paintWaits is a property of the application, not of the instrument. The poll shares the rAF queue with the mount's own commits, so the count is 1 on a single-commit rebuild and 1 / 8 / 24 at 25K / 100K / 300K on this head. Subtracting all of them removed 33.3ms from the base arm's 300K cell and 796.8ms from head's. On the three-arm run in hand:

300K, chromium base head
raw reopen ms 2184.1 2329.7
old, minus every wait 2150.8 1532.9
corrected, minus the observation wait 2150.8 2296.5

So a reopen that is 6.8 percent slower read as 28.7 percent faster, and the 25K -> 300K curve read as 5.07x against base's 7.08x when it is really 7.60x, steeper than base rather than shallower.

Only the terminal observation wait comes out now, and as a constant: reopen is driven by a React state update, so the count check straight after openThread() always still sees the unmounted tree and the loop always waits out exactly one paint before a finished reopen is observable at all. Everything past that one is a frame the application spent committing rows.

reopen wall ms had the same defect through the generated wall axes, which take the recorder window's paint_waits (2 -> 25 across the ladder on head). WALL_FLOOR_OVERRIDES pins reopen to its two terminal waits, one per loop, and leaves every other action on the measured count, where those waits really are the harness idling between driven steps. The paintWaits check is now a lower bound rather than equality, so subtracting a floor the metric never waited out is still a failure while paying more waits than are subtracted is not.

Re-measured on the corrected metric, five repetitions, three arms concurrent, same-commit null:

chromium 100K 300K
convergence, head vs base 0.96x 1.21x
concurrent null 1.02x 1.09x

At 300K that is about 1.11x net of the null, against 1.20x from an independent probe that does not use this harness at all and carried a -0.7 percent null. The convergence figures in the PR body were read from raw reopen.ms rather than from the floored growth report, so they are unchanged by this; what changes is the growth ratio the harness itself prints and gates its discrimination check on.

… metric

`reopen ms` had its paint floor read from the run: `_floor_from("reopen",
"paintWaits")` subtracted one ~33ms vsync floor for every double-rAF wait the
poll loop paid. That is right only while the wait count is a property of the
instrument. It is not. The loop polls in the same rAF queue as the application's
own commits, so on a build that brings a long thread back over several animation
frames the count is a property of the APPLICATION: 1 on a single-commit rebuild,
and 1 at 25K, 8 at 100K, 24 at 300K on a progressive mount.

So the subtraction was asymmetric between the two arms of a comparison and grew
with the axis being varied. On the 220-message fixture it removed 33.3ms from
the single-commit arm's 300K cell and 796.8ms from the progressive one's, which
turned a reopen that is 6.8% slower into one that reads 28.7% faster, and turned
a 25K -> 300K curve that rises faster than the single-commit build's (7.60x
against 7.08x) into one that rises slower (5.07x). A floor removes a constant
the instrument adds; the moment it tracks the thing being measured it stops
being a floor and starts being the measurement.

Only the observation floor comes out now, and it is a constant: reopen is driven
by a React state update, so the count check straight after openThread() always
still sees the unmounted tree and the loop always waits out exactly one paint
before a finished reopen can be observed at all. Every wait past that one is a
frame the application spent committing rows and stays in the number.

`reopen wall ms` had the same defect through the generated wall axes, which take
the recorder window's measured `paint_waits` (2 -> 25 across the ladder on head).
WALL_FLOOR_OVERRIDES pins reopen to its two terminal observation waits, one per
loop, and leaves every other action on the measured count, where those waits
really are the harness idling between driven steps.

`paintWaits` is still reported and still checked, now as a lower bound rather
than as equality: subtracting a floor the metric never waited out is the failure,
paying more waits than are subtracted is the normal state of a progressive mount.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: b4b38c0405

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit fdeefc5 into main Aug 22, 2026
36 checks passed
@danielhanchen
danielhanchen deleted the perf-progressive-mount branch August 22, 2026 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants