Skip to content

fix(chat): going to the end while a row is still measured no longer jumps back to where you were - #3650

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

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

Conversation

@devswha

@devswha devswha commented Nov 11, 2026

Copy link
Copy Markdown
Owner

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 feat(chat): a 960px chat lane, with a Chat width setting #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 fix(chat): a row opened or an output unfolded while the list still scrolls to the end is not scrolled past #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.

…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.
@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 reaching the end of a long chat could jump back to an earlier reading position while content was being measured.
    • Improved scrolling to the end of long lists so it accounts for rendered content, even when measurements are incomplete.
    • Improved item navigation when the requested item is unavailable, preventing an active scroll from being left unfinished.

The @legendapp/list patch updates scroll reconciliation during item measurement, DOM ordering, and imperative scrolling. The changelog describes a chat jump that occurred when a row was measured.

Changes: Chat list scroll handling

Layer / File(s) Summary
Adopt native scroll before item measurements
patches/@legendapp%[email protected], changelog.d/chat-scroll-not-taken-back.md
Before item-size updates, hearUnheardScroll adopts an eligible unreported downward scroll through updateScroll. The changelog describes the chat jump during row measurement.
Update DOM ordering
patches/@legendapp%[email protected]
DOM sorting uses moveBefore when available. useDOMOrder sorts in a layout effect after position updates instead of using a 500 ms debounce.
Adjust end and item scrolling
patches/@legendapp%[email protected]
Temporary end padding records the browser-serialized style value. scrollToEnd accounts for scrollable content beyond measured content. Imperative scrolling clears mvcpAnchorLock; scrollToItem ends an active non-initial scroll when the requested item is absent.

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

Change: Bug fix · Severity of issue fixed: Low

Possibly related PRs

  • devswha/ovis#3622: Both changes address chat scrolling during content unfolding. That PR stops an active end scroll; this PR adopts an unreported downward scroll before row measurement.
  • devswha/ovis#2647: That PR changes measured-row follow behavior. This PR changes scroll reconciliation during row measurement in the @legendapp/list patch.
  • devswha/ovis#2624: That PR adds scrollToEnd after measured row growth. This PR adjusts end-follow behavior for changing row sizes.
Merge Risk: Minimal · up to b8dc5

No confirmed issue currently blocks merging; complete the normal checks for the affected chat-scroll behavior.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title clearly identifies the primary fix: preventing navigation to the chat end from jumping back to a stale reading position during row measurement.
Description check Passed The description explains the problem, root cause, behavior change, validation results, skipped checks, and known limitations. It uses Why and What instead of the template's Change heading, but the req…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. 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: Description check

Explanation

The description explains the problem, root cause, behavior change, validation results, skipped checks, and known limitations. It uses Why and What instead of the template's Change heading, but the required change information is present and the Validation section is complete.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. 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 0 functions across 0 files. (2 skipped: 2 unsupported.)

Finishing Touches

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 911f159 and b8dc5ee.

Files selected for processing: 2

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

@devswha
devswha merged commit 9819a12 into main Nov 11, 2026
13 checks passed
@devswha
devswha deleted the fix/chat-virtual-settle branch November 11, 2026 07:00
@devswha

devswha commented Nov 11, 2026

Copy link
Copy Markdown
Owner Author

Merge pass

Merged head b8dc5ee4bda5 as 9819a121e111 on GitHub's checks, with no unresolved review threads.

Reviewer Verdict Note
claude CLEAR
codex CLEAR

Two reviewers at this head: Claude (Opus) CLEAR, Codex Terra CLEAR. It changes patches/@legendapp%[email protected] (one hunk) and adds a changelog fragment; no release PR is open, so nothing holds a patches/ change.

It fixes the chat-virtual-browser-qa.ts settleBottom timeout, a real jump back in the chat: the list applied a row's measurement against a scroll position it had not heard yet and scrolled the view back. The author forced that order: main failed 2 of 2 with CI's own error, the fix passed 2 of 2.

Left, both LOW:

  • (both reviewers) no test reaches the patched code deterministically; the proof is the timing-forced browser run.
  • (Claude, not run) while a text selection is held and the chat follows the end, the list now shifts the view a second time for a row that grew above, and the chat's selection-hold undoes it before paint.

Reports: ~/.cache/ovis-tmp/reports/pr-3650-b8dc5ee4-*.report.md.

devswha added a commit that referenced this pull request Nov 11, 2026
… 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).
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