fix(log explorer): a live update no longer throws a scrolled reader to the top

Reported as "scrolling down, I get pushed back to the latest logs, usually after
the 15 second live update". Traced in the browser, the chain was:

Retention was a single threshold that one page of history overshot on arrival,
so every load-more evicted, and every eviction remounts the virtualizer through
keyed(). 76s of scrolling produced 17 remounts. A remount blanks the runway, so
the browser clamps scrollTop to 0 — and fires a scroll event for that clamp.
resumeLiveTailAtEdge read that as "the reader came back to the newest edge" and
flushed the whole buffered tick into someone deep in history, which evicted the
history they were reading and left them at the top on the newest rows.

So: resumeLiveTailAtEdge now stands down while repositioning, as syncBottomPin
and the proximity prefetch already did — a frame of collapsed geometry is not
the reader's intent. And retention became a pair (cross RETENTION_LIMIT, cut
back to MAX_RETAINED_ROWS) so a cut is rare instead of once per page.

80s of continuous scrolling across several real ticks: 4 remounts, no
unexplained scroll losses, buffered rows held rather than flushed.

Off the scroll path as well: healBlankVirtualizer is a last-resort watchdog, but
it ran on every render and measured every mounted row, which was the largest
app-level cost in a CPU profile of a throttled scroll. It now runs only off its
timers, and is O(1) — mounted rows are one contiguous band, so the first and
last bound the rest. The buffer flush is coalesced into one rAF, and the
virtualizer layout specifier is hoisted instead of reallocated per render.

The scroll harness simulated the remount's scrollTop=0 clamp but never fired the
scroll event the browser fires with it, which is why no test caught this. It
does now, and both regressions fail without their fix.

plans/log-list-performance.md records the dominant remaining cost, which is not
fixed: group-has-* utilities on <body> make every DOM mutation restyle the whole
document. The fix for that was attempted and reverted — see the plan for why.
This commit is contained in:
Anthony Alaribe 2026-09-01 00:24:10 +02:00
commit 3d3076037f
7 changed files with 401 additions and 98 deletions