fix(chat-thread): stop the thread yanking back to an earlier prompt - #4026
Draft
adboio wants to merge 3 commits into
Draft
fix(chat-thread): stop the thread yanking back to an earlier prompt#4026adboio wants to merge 3 commits into
adboio wants to merge 3 commits into
Conversation
The scroller engine treats a row marked `scrollAnchor` as one it owns the scroll position for: on every content change it pins the first anchor it has not pinned before to the top of the viewport. Anchors present at mount are never recorded as pinned, so the first row swap after load scrolls the thread to the very first prompt, the next swap to the second, and so on — and a scroll-to-bottom lasts only until the next swap moves you one prompt down. Rows are no longer anchors, and the current turn (minimap highlight + the virtualization handoff anchor) is measured from the viewport instead, reusing the same `computeStickyAnchor` the windowed body already uses. The scroll-to-bottom button now also re-arms auto-follow, so it holds the bottom while a reply is still streaming rows in below. Generated-By: PostHog Code Task-Id: ae1e23ab-61e6-4a59-bc42-77667af0baab
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
React Doctor found 1 issue in 1 file · 1 warning. 1 warning
Reviewed by React Doctor for commit |
Scanning `[data-message-id]` under the viewport visited every node inside every turn card — thousands of elements on a long thread — once per scroll frame. The rows are the content element's direct children and sit in ascending vertical order, so the scan walks those children backwards and stops at the first prompt at or above the peek line: at the live tail that is the first row it reads, and it never touches the thread above the anchor. Generated-By: PostHog Code Task-Id: ae1e23ab-61e6-4a59-bc42-77667af0baab
Generated-By: PostHog Code Task-Id: ae1e23ab-61e6-4a59-bc42-77667af0baab
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
In a task's chat thread the view very often scrolls itself back to the top, and the scroll-to-bottom arrow only moves you one prompt further down instead of to the bottom.
Both come from marking user rows as
scrollAnchor. The quill/shadcn scroller engine treats an anchored row as one it owns the scroll position for: on each content change it pins the first anchor it has not pinned before to the top of the viewport. Anchors that exist at mount are never recorded as pinned, so the first row swap after opening a task jumps to the very first prompt, the next swap to the second, and so on. That also eats the scroll-to-bottom: you land at the bottom, then the next swap moves you to the next un-pinned prompt.Separately, the arrow never re-armed auto-follow (the code comment claimed it did), so hitting bottom mid-reply lasted exactly until the next streamed row.
Why: reported as extremely disruptive while reading a running task — you lose your place constantly and can't get back to the live tail.
Changes
scrollAnchorany more, which removes the whole class of engine-initiated scroll jumps.computeStickyAnchorhelper the virtualized body already uses.MessageMinimapno longer subscribes to the engine's per-scroll visibility state — both bodies now pass the anchor in.How did you test this?
pnpm typecheck(all 24 packages),pnpm lint,pnpm --filter @posthog/ui test(2411 tests) — all pass.Automatic notifications
Created with PostHog Code