Repository navigation
fix(chat): a row opened or an output unfolded while the list still scrolls to the end is not scrolled past - #3622
Conversation
…rolls to the end is not scrolled past The chat's list keeps a scroll "in progress" for 100 ms after it has moved the view, and for that time keeps the scroll's target in view as rows change size. A reader's open is meant to stop all following, but it only superseded a list scroll still waiting to start, not one already started. A tool row opened, or an output unfolded, within a tenth of a second of the chat moving to its end grew under a view the list then moved past it, to the new end. The request that stands for "no row" now ends a started scroll as the list's own timer would (one hunk in the @legendapp/list patch). scripts/chat-virtual-browser-qa.ts failed for this on loaded runners (12 of 362 jobs, 4 red): it clicks "Show all" 76 to 99 ms after Jump to latest and passed by 5 to 13 ms. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
Merge passMerged head
Merge pass note (head b61dd7c). Both reviewers CLEAR with no findings. The patch was applied to a clean @legendapp/list 3.3.5 with main's patch and with this one: the only difference is the scrollToItem block; package.json and bun.lock are unchanged. Behaviour and the new browser check were judged from the code, not run by the reviewers; GitHub's browser jobs ran the script. It touches patches/, so it merged on GitHub's checks, and the next release raises REMOTE_BUNDLE_VERSION. |
…umps back to where you were (#3650) ## Why `scripts/chat-virtual-browser-qa.ts` timed out in `settleBottom` (`: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 #463). The rule mirrors `ChatTimeline.followMeasured`. `bun.lock` is 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 exact `TimeoutError: 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's `scrollBy(-54972)` right after the write. ## Validation - `bun run check fast` on 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. - The 16 chat scripts from #3622 (chat-history-browser-qa, chat-scroll-padding-regression, chat-local-send-follow-demo-regression, chat-no-rewind-demo-regression, chat-selection-turn-end-demo-regression, chat-gjc-streaming-browser-qa, todo-snapshots-demo-regression, chat-tool-paths-demo-regression, chat-working-line-demo-regression, chat-select-quote-demo-regression, chat-selection-copy-regression, chat-quote-selection-end-regression, docked-file-link-demo-regression, pane-paging-demo-regression, chat-request-details-demo-regression, chat-fallback-browser-qa): 16/16 pass with the fix. - A clean frozen install reproduces the patched `react.mjs` byte for byte. - Skipped: `check full`, the integration suite, `ui-regression.ts`, WebKit, Firefox, macOS, Windows. It touches `patches/`, so it waits for GitHub's checks. ## Not verified - The script's other intermittent failure, `: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. - No deterministic regression check was added: the forcing is frame-timing based and caught a written frame in only about 3 of 4 passes at 390. ## Not in this PR (LOW) - A scroll up the list has not heard (a wheel up in the frame of a measurement) is still adjusted from the stale position, on purpose: a move up can be the browser's clamp. - Other list adjustments not driven by a measurement (header size, content inset) still use the stale position. - Upstream 3.7.2 still adjusts from `state.scroll`; worth reporting to LegendApp/legend-list.
Why
scripts/chat-virtual-browser-qa.tsfailed in "Browser regression (other scripts)" on PRs that do not touch chat: 12 times in 362 jobs since #3482 added its fold section, 4 of them red (run 42838750903 twice, 42808284998, 42902121998). Two errors, one cause::375 unfolding the newest output keeps a following reader where they were: 422 -> 1842(or825 -> 2245), and aJump to latestclick that times out because the button left by itself.It is not the test. The chat's list keeps a scroll to the end "in progress" for 100 ms after it moved the view, and for that time it keeps the end in view as rows change size. A reader's open is meant to stop all following, but
dropPendingListScrollonly superseded a list scroll still waiting to start, not one already started. So a tool row opened, or a long output unfolded, within 100 ms of the chat moving to its end (Jump to latest, or any update while an agent writes) was scrolled past, to the new end, with Jump to latest showing. The test clicks about 82 ms after Jump to latest in every run; it passed by the 5-13 ms between the list's timer and the frame that measures the grown row.What
patches/@legendapp%[email protected]:scrollToItemfor a row the list does not hold (the requestdropPendingListScrollmakes) ends a non-initial scroll in progress withfinishScrollTo, as the list's own timer does 100 ms later.bun.lockunchanged.src/lib/followScroll.ts: the comment says so. Every caller gets it: an open, a wheel or drag up, a page up, a selection starting, a grown footer, a following reader's fold.scripts/chat-virtual-browser-qa.ts: a check that unfolds in the frame after the list's scroll starts. It fails on main every time with CI's numbers and touches no timer.changelog.d/chat-open-during-follow.md.No design change: this makes #3482's rule hold (a reader who unfolds an output stops following there; reference there, the Claude app).
Proof
All in the CI runner image, one container,
WORKERS=1, on5c66921c3:422 -> 1842; with every list scroll kept in progress and the phone width first, 3/3 fail with825 -> 2245. The trace shows the list'sscrollBy(1440)fromrequestAdjust0.7 ms after the grown row is measured, with the chat not following.422 -> 1842. With the fix: passes in all 33 runs it ran in.Validation
SCRIPTS=scripts/chat-virtual-browser-qa.ts WORKERS=1 CPUS=120-127 REPEAT=5 RETRY=0 PATCHES=<the diff> run-browser.sh k 5c66921c3: 5/5.scripts/ui-regression.tsonce in the same image: pass.bun run typecheck;bun test ./scripts/conventions.test.ts ./src/conventions.test.ts ./server/conventions.test.ts ./server/catalog.conventions.test.ts(62 pass);bun test ./src/components/ChatTimeline.test.tsx ./scripts/changelog-fold.test.ts ./scripts/release-guards.test.ts ./scripts/ci-browser-parallel.test.ts(45 pass);bun test ./src/components/ChatView.scrollInput.test.tsx ./src/components/ChatView.goalWait.test.tsx ./src/components/ChatView.scrollback.test.ts ./src/components/ChatView.stoppedTurn.test.ts(20 pass).bun install --frozen-lockfilein an empty directory: applies, and gives the intendedreact.mjsbyte for byte.bun run check fast: pass on this head (15742 unit tests pass, 0 fail), which is that diff rebased ontoorigin/mainf6cc7c384. On this head, in the CI runner image:chat-virtual-browser-qa.ts, 2 of 2. The other browser runs above were made on5c66921c3with the diff as a patch.main(a reader follows the end, an answer still being written comes in, and the reader opens something right after the list starts its scroll: scrolled past what was opened, with Jump to latest shown) and saw the view stay with the product hunk alone; applied the test part alone tomain(fails at the new assertion, at both widths); and ran five more chat scripts.bun run check full, the integration suite, WebKit, Firefox, macOS, Windows.patches/, so it waits for GitHub's checks rather than the local gate.Not in this PR
:97 settleBottomtimeout in the eviction section at 390 (the fix(relay): the PC's approval prompt says what to do with the number and how long is left #3570 gate's failure is this one) and:883.dropPendingListScrollkeeps its name though it now ends a started scroll too.mainthe chat re-armed following by itself in 2 of 6 runs of the section at 390, and with the fix in 0 of 15.🤖 Generated with Claude Code