fix(chat-thread): stop the thread yanking back to an earlier prompt - #4026
fix(chat-thread): stop the thread yanking back to an earlier prompt#4026adboio 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
|
Hey @adboio, we've migrated this repo into the PostHog/posthog monorepo, so this PR needs to be recreated there. Easiest path: check out the monorepo and run the Shout if you get stuck. |

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