Repository navigation
fix(chat): going to the end while a row is still measured no longer jumps back to where you were - #3650
Conversation
…umps back to where you were The chat's list learns where the view is only from scroll events. When it applied a row's new size in the frame a scroll to the end happened, before that scroll's event, it adjusted from where it last heard the view and moved the view back there. That is the settleBottom timeout of chat-virtual-browser-qa.ts (:97) seen in CI, and a user meets it when they drag or press End to the end while a long output they just unfolded is still being measured. The list's patch now hears a downward scroll it has not heard yet, and did not make itself, before it applies measurements, as the coming scroll event would. A move up is left to the list's own reconciliation: it can be the browser keeping the view inside content that got shorter.
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
Merge passMerged head
Two reviewers at this head: Claude (Opus) CLEAR, Codex Terra CLEAR. It changes It fixes the Left, both LOW:
Reports: |
… rows it uncovered (#3659) ## Why `scripts/chat-virtual-browser-qa.ts:728` ("PageUp stays at its anchor through output") failed in both attempts of CI run 42989933116 on PR #3655 (an unrelated change): the row the reader was on moved 20 px. The test reads the reader's place right after PageUp. On a loaded runner the list draws the rows that PageUp uncovered a frame or more later, so the top of the view is still blank and the first drawn row (ROW-987, y=116) is taken as the anchor. The list then draws ROW-986 at its estimate and holds that one; ROW-986 measures 20 px shorter, so ROW-987 moves up 20 px. CI's numbers fit exactly: the `away` keys `[7, 8, 987..999]` show nothing above 987 was drawn, and the scroll height changed by -18 = -20 + 2. This is not #3650's `hearUnheardScroll`: it never fires in this step, and the same forced order fails the same way on 301934f, the commit before #3650. ## What - `scripts/chat-virtual-browser-qa.ts`: after `page(-1)`, wait until a drawn row covers the top of the view, then read the place. No sleep, no timeout change, the assertion unchanged. No product change, no `patches/` change, so no changelog fragment. ## Proof In the CI runner image (fix-ci harness, `WORKERS=1`): a forced order (PageUp, then 600 px past the drawn rows, the place read in the same task) fails 2/2 on main and 2/2 on 301934f at the same assertion (anchor 240 -> 226), and passes 2/2 with this change. Traces on main show `hearUnheardScroll` never firing in the step (16 plain, 12 CPU-throttled steps). ## Validation - `bun run check fast` on this head (rebased on a55d9b7): pass (unit 16104 pass, 0 fail). - `chat-virtual-browser-qa.ts`, plain, interleaved: main 4/4, this change 4/4. - #3650's :97 forcing: fails 2/2 on 301934f, passes 2/2 with this change. - The 16 chat scripts from #3650 plus chat-virtual-browser-qa: 17/17 pass. - Skipped: `check full`, the integration suite, `ui-regression.ts`, WebKit, Firefox, macOS, Windows. ## Not verified - The exact frame order on the CI runner. The forcing reproduces the same mechanism, and CI's numbers fit it. ## Not in this PR (LOW) - When a slow device draws the uncovered rows a frame late, the list holds a row drawn at its estimate, so text the reader already sees moves by the estimate's error (14 px forced, 20 px in CI). Upstream behaviour, on main and before #3650. - `hearUnheardScroll` may treat the chat's selection-hold write as a reader's scroll, so a row that grew above would be applied twice. Found by reading, not run (Opus's LOW on #3650).
Why
scripts/chat-virtual-browser-qa.tstimed out insettleBottom(:97) at width 390 in five CI or gate runs: 42748366477, 42820178379, 42872446311, 42886093402 and the #3570 gate. The cause is the chat's list. It learns where the view is only from scroll events. When it applies a row's new size in the frame a scroll to the end happened, before that scroll's event, it adjusts from where it last saw the view and moves the view back there (scrollBy(-54972)). A user meets this when they drag or press End to the end while a long output they just unfolded is still being measured.What
patches/@legendapp%[email protected]: a downward scroll the list has not heard yet, and did not make itself, is processed before measurements are applied, as the coming scroll event would. A move up is left to the list's existing handling, because it can be the browser's own clamp (upstream feat(chat): a 960px chat lane, with a Chat width setting #463). The rule mirrorsChatTimeline.followMeasured.bun.lockis unchanged.changelog.d/chat-scroll-not-taken-back.md.No timer, wait or timeout is changed.
Proof
In the CI runner image (fix-ci harness,
WORKERS=1): the forced order (the end written in every frame until the list adjusts) fails on main 2 of 2 with CI's exactTimeoutError: waitForFunction: Timeout 15000ms exceeded. at settleBottom (:97:14), and passes 2 of 2 with the fix (3 of 3 more on a debug build of the same rule). A trace on main shows the list'sscrollBy(-54972)right after the write.Validation
bun run check faston this head (rebased on 911f159): pass (unit 16072 pass, 0 fail).chat-virtual-browser-qa.ts, plain, interleaved: main 4/4 and fix 4/4 green. Main never failed plainly here; the forced order is the proof.react.mjsbyte for byte.check full, the integration suite,ui-regression.ts, WebKit, Firefox, macOS, Windows. It touchespatches/, so it waits for GitHub's checks.Not verified
:883("a scroll to the end the list measured short"), was not reproduced: 0 failures in 12 forced runs on main. One candidate (the same race against the chat's own write to the end) is covered by this rule but unverified.Not in this PR (LOW)
state.scroll; worth reporting to LegendApp/legend-list.