Skip to content

fix(chat): a row opened or an output unfolded while the list still scrolls to the end is not scrolled past - #3622

Merged
devswha merged 1 commit into
mainfrom
fix/chat-virtual-unfold
Nov 11, 2026
Merged

devswha merged 1 commit into
mainfrom
fix/chat-virtual-unfold

Conversation

@devswha

@devswha devswha commented Nov 11, 2026

Copy link
Copy Markdown
Owner

Why

scripts/chat-virtual-browser-qa.ts failed 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 (or 825 -> 2245), and a Jump to latest click 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 dropPendingListScroll only 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]: scrollToItem for a row the list does not hold (the request dropPendingListScroll makes) ends a non-initial scroll in progress with finishScrollTo, as the list's own timer does 100 ms later. bun.lock unchanged.
  • 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, on 5c66921c3:

  • Forced order on main (the list's 100 ms timer of the scroll Jump to latest starts, stretched to 1 s): 2/2 fail with CI's assertion, 422 -> 1842; with every list scroll kept in progress and the phone width first, 3/3 fail with 825 -> 2245. The trace shows the list's scrollBy(1440) from requestAdjust 0.7 ms after the grown row is measured, with the chat not following.
  • The same forcings with the fix: 2/2 and 3/3 pass; the list's scroll ends at the press and nothing scrolls when the row grows.
  • The new check alone on main: 4/4 fail, 422 -> 1842. With the fix: passes in all 33 runs it ran in.
  • The script plain with the fix: 5/5 (and 5/5 on the earlier wording).

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.
  • The same harness, once each, 16/16: 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.
  • scripts/ui-regression.ts once in the same image: pass.
  • Host: 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).
  • The patch from a clean bun install --frozen-lockfile in an empty directory: applies, and gives the intended react.mjs byte for byte.
  • bun run check fast: pass on this head (15742 unit tests pass, 0 fail), which is that diff rebased onto origin/main f6cc7c384. On this head, in the CI runner image: chat-virtual-browser-qa.ts, 2 of 2. The other browser runs above were made on 5c66921c3 with the diff as a patch.
  • An independent review agent was clear. It reproduced a user's case of its own on 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 to main (fails at the new assertion, at both widths); and ran five more chat scripts.
  • Skipped: bun run check full, the integration suite, WebKit, Firefox, macOS, Windows.
  • It touches patches/, so it waits for GitHub's checks rather than the local gate.

Not in this PR

  • A scroll made just before a click and heard after it still re-arms following (automation's order; the test no longer reaches it). The two-line hardening is described in the report.
  • The script's two other intermittent failures, which have other causes: the :97 settleBottom timeout 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.
  • dropPendingListScroll keeps its name though it now ends a started scroll too.
  • From the review, two things this changes beyond the open: a mouse press anywhere in the chat (the selection hold calls the same drop) now ends a list scroll in progress, and a started scroll to a row (a minimap tick, a restored place, an older page's anchor) is ended early by the same inputs (a wheel or drag up, a press). By the code the list then holds the rows on screen, as it already does when that scroll is still waiting; no run covers a wheel inside those 100 ms.
  • CI's second error (the Jump to latest click that times out) was not reproduced as such. Its precondition is: on main the 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

…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]>
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where opening a tool output or expanding long content near the end of a chat could cause the new lines to scroll out of view.
    • Improved scroll positioning when chat content changes during automatic scrolling, helping keep the reader’s position stable.

The list patch changes scroll handling, including scroll adjustment, web scroll bounds, DOM ordering, and imperative scroll requests. The change also documents follow-scroll behavior, adds a browser QA scenario for unfolding output during automatic scrolling, and records the chat-end issue in the changelog.

Changes: Chat follow scrolling

Layer / File(s) Summary
List scrolling and unfold regression
patches/@legendapp%[email protected], scripts/chat-virtual-browser-qa.ts, src/lib/followScroll.ts, changelog.d/chat-open-during-follow.md
The list patch updates scroll adjustment, web scroll bounds, DOM ordering, and imperative scroll behavior. The browser QA scenario unfolds output during jump-to-latest scrolling and checks the recorded position and jump button. The follow-scroll comment documents pending and in-progress scroll behavior. The changelog describes the chat-end scrolling issue.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related PRs

  • devswha/ovis#2647: Changes ChatTimeline end-follow behavior and interaction handling during a glide.
  • devswha/ovis#1937: Stops end-follow and cancels pending list scrolling when chat content opens.

Suggested reviewers: jpcarranza94

Merge Risk: Minimal · up to b61dd

No merge-blocking issue is established for the chat scrolling change.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title clearly identifies the chat scroll-following bug and the fix. It is specific and related to the main change.
Description check Passed The description explains the problem, the resulting behavior, and the changes. Its “Why” and “What” sections cover the required Change information. Validation lists checks, results, and skipped tests.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files. (2 skipped: 2 unsupported.)

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between ce11b34 and b61dd7c.

Files selected for processing: 4

  • changelog.d/chat-open-during-follow.md
  • patches/@legendapp%[email protected]
  • scripts/chat-virtual-browser-qa.ts
  • src/lib/followScroll.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@devswha
devswha merged commit a1a115e into main Nov 11, 2026
13 checks passed
@devswha

devswha commented Nov 11, 2026

Copy link
Copy Markdown
Owner Author

Merge pass

Merged head b61dd7cf7c70 as a1a115e5d67e on GitHub's checks, with no unresolved review threads.

Reviewer Verdict Note
claude CLEAR
codex CLEAR

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.

@devswha
devswha deleted the fix/chat-virtual-unfold branch November 11, 2026 02:16
devswha added a commit that referenced this pull request Nov 11, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant