fix(web): stabilize chat timeline positioning - #5449
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 221222ccb8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (timelineScrollModeRef.current !== "anchoring-new-turn") { | ||
| return; | ||
| } |
There was a problem hiding this comment.
Restore end-follow while an anchor remains
When a sent message remains as anchorMessageId, MessagesTimeline still passes maintainScrollAtEnd={false} whenever anchoredEndSpace is truthy, so this effect is the only fallback that keeps an at-end timeline pinned during later streaming/final timeline updates. If onIsAtEndChange flips timelineScrollModeRef back to following-end while that anchor is still present, this new guard skips the old scrollToEnd path and subsequent rows/size changes can stop following even though the user never manually navigated away.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 221222c. Configure here.
ApprovabilityVerdict: Needs human review This PR refactors the chat timeline scroll anchoring system, removing ~600 lines of custom logic in favor of library features. This constitutes a significant behavioral change to a core UX element. An unresolved review comment also flags a potential bug where scroll-following may stop working when an anchor is present. You can customize Macroscope's approvability policy. Learn more. |
Keep maintainScrollAtEnd active alongside anchored end space so streaming updates follow the list threshold. Remove the manual navigation detection and scroll correction state that competed with the list.
c446547 to
8cf8708
Compare

What Changed
Fixed some usage of LegendList to make the chat smoother. This mostly removes app code in favor of using LegendList's internal behavior.
Why
Chat was not as smooth as it could be.
UI Changes
Checklist
Note
Medium Risk
Large removal of scroll state in a core chat UI with behavior changes during streaming, send anchoring, and expand/collapse; risk is regressions in scroll position rather than data/security.
Overview
Bumps
@legendapp/listfrom 3.2.0 to 3.3.3 and shifts chat timeline scroll behavior onto the list’s built-inmaintainScrollAtEnd/maintainVisibleContentPositioninstead of custom logic.Removes the manual scroll system in
ChatView(scroll modes, live-follow refs, wheel/touch/pointer opt-out, rAF follow loops, anchor size restore) and deletestimelineScrollAnchoring.tsand its tests. Send/scroll-to-bottom still settimelineAnchorand callscrollToIndex/scrollToEnd, but no longer drive anchoring metrics or manual navigation cancellation.In
MessagesTimeline,maintainScrollAtEndstays on (non-animated, on data/layout changes) even whenanchoredEndSpaceis active—previously it was disabled during anchoring. Fold/expand for turns and work groups briefly turns off end maintenance and usesshouldRestorePositionscoped to the toggled row; the oldflushSync+ DOM scroll delta compensation on work-group toggles is gone.onAnchorSizeChangedandonManualNavigationare dropped from the timeline API.Reviewed by Cursor Bugbot for commit 8cf8708. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Stabilize chat timeline scroll positioning by replacing manual anchor logic with
maintainScrollAtEndTimelineScrollModeanchoring system and all associated refs, state, and scroll-restore logic from ChatView.tsx and MessagesTimeline.tsx, deleting timelineScrollAnchoring.ts entirely.TIMELINE_MAINTAIN_SCROLL_AT_ENDconfig inMessagesTimelineusing@legendapp/listv3.3.3'smaintainScrollAtEnd(bumped from 3.2.0), withanimated=falseand all layout change hooks enabled.maintainScrollAtEndis briefly suspended viasuspendEndScrollMaintenanceForDisclosureto let the layout settle, withmaintainVisibleContentPositionscoped to the toggled row viashouldRestorePosition.WorkGroupToggleTimelineRowno longer performs manual DOM measurement or scroll delta compensation on click — position maintenance is fully delegated to the list.onAnchorSizeChangedandonManualNavigationprops are removed fromMessagesTimeline's public API.Macroscope summarized 8cf8708.