Skip to content

fix(ui): stabilize chat scrolling - #3820

Merged
trunk-io[bot] merged 7 commits into
mainfrom
posthog-code/fix-chat-scroll-jitter
Jul 26, 2026
Merged

fix(ui): stabilize chat scrolling#3820
trunk-io[bot] merged 7 commits into
mainfrom
posthog-code/fix-chat-scroll-jitter

Conversation

@richardsolomou

@richardsolomou richardsolomou commented Jul 26, 2026

Copy link
Copy Markdown
Member

Problem

Long legacy chat threads jitter and push the reader back down while scrolling upward. Markdown and tool rows mount with estimated heights, then their real measurements change individual virtual rows above the viewport.

Virtualized chat state can also survive a taskId change, causing a newly opened task to inherit the previous thread's scroll position.

Changes

I changed the legacy view to virtualize complete conversation turns with stable keys. Each prompt and response is measured and cached as one unit, while bottom-follow disengages as soon as an upward wheel or touch gesture begins.

Item-level DOM anchors remain inside each turn so conversation search can still highlight matches. Both thread implementations share the same user-initiated turn boundary, and the stateful chat renderer is keyed by taskId so switching tasks resets its virtualization and scroll state.

There is no visual design change, so screenshots are N/A.

How did you test this?

  • Added unit coverage for turn grouping, synchronous variable-height measurement, and horizontal versus upward-history touch gestures.
  • Ran the 12 experimental-thread virtualization tests, 7 focused legacy-thread tests, the full @posthog/ui typecheck, Biome, and the repository commit hooks.
  • Loaded a copied production database with a long chat history, manually verified smooth upward scrolling, and confirmed conversation search produced both normal and active highlights in the running app.
  • Did not manually re-run the task-switch scenario after adding the taskId remount.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog Code

Virtualize complete conversation turns so Markdown height measurements do not shift individual messages into view.

Generated-By: PostHog Code
Task-Id: f1cb8dcf-8a50-4e12-afbf-19a697d4e63d
@trunk-io

trunk-io Bot commented Jul 26, 2026

Copy link
Copy Markdown

😎 Merged directly without going through the merge queue, as the queue was empty and the PR was up to date with the target branch - details.

@github-actions

github-actions Bot commented Jul 26, 2026

Copy link
Copy Markdown

React Doctor found 2 issues in 2 files · 2 warnings.

2 warnings

src/features/sessions/components/ConversationView.tsx

src/features/sessions/components/VirtualizedList.tsx

Reviewed by React Doctor for commit 47452b2.

@greptile-apps

greptile-apps Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
packages/ui/src/features/sessions/components/VirtualizedList.tsx:252-254
**Touch movement breaks bottom-follow**

When a user moves their finger downward or sideways while the conversation is at the bottom, this handler clears `isAtBottomRef` without checking direction, causing a concurrent streamed-content or row-height update to skip `scrollToEnd` and leave new content below the viewport.

Reviews (1): Last reviewed commit: "fix(ui): stabilize chat scrolling" | Re-trigger Greptile

Comment thread packages/ui/src/features/sessions/components/VirtualizedList.tsx Outdated
@posthog

posthog Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Visual changes approved by @richardsolomou — baseline updated in 0f3e324.

View this run in PostHog

10 changed.

Leave the experimental chat rendering unchanged until it has a bounded solution for long threads.

Generated-By: PostHog Code
Task-Id: f1cb8dcf-8a50-4e12-afbf-19a697d4e63d
@richardsolomou
richardsolomou requested a review from a team July 26, 2026 04:55
richardsolomou and others added 5 commits July 26, 2026 07:57
Preserve item search anchors, distinguish touch direction, and share conversation turn boundaries across both thread groupers.

Generated-By: PostHog Code
Task-Id: f1cb8dcf-8a50-4e12-afbf-19a697d4e63d
10 updated
Run: 1222e7ad-9d74-4457-9327-6b32e657dabd

Co-authored-by: richardsolomou <2622273+richardsolomou@users.noreply.github.com>
Generated-By: PostHog Code
Task-Id: f1cb8dcf-8a50-4e12-afbf-19a697d4e63d
Generated-By: PostHog Code
Task-Id: f1cb8dcf-8a50-4e12-afbf-19a697d4e63d
Generated-By: PostHog Code
Task-Id: f1cb8dcf-8a50-4e12-afbf-19a697d4e63d
@trunk-io
trunk-io Bot merged commit 32e516b into main Jul 26, 2026
32 checks passed
@trunk-io
trunk-io Bot deleted the posthog-code/fix-chat-scroll-jitter branch July 26, 2026 20:30
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.

2 participants