Skip to content

fix(chat): release the bottom lock as soon as the user scrolls up - #899

Merged
xintaofei merged 2 commits into
spacering-net:mainfrom
Adam-Dalloul:fix/transcript-scroll-jump
Oct 9, 2026
Merged

xintaofei merged 2 commits into
spacering-net:mainfrom
Adam-Dalloul:fix/transcript-scroll-jump

Conversation

@Adam-Dalloul

Copy link
Copy Markdown
Contributor

Scrolling a conversation while a reply streams, or while rows are still being measured, can pull the view back to the bottom. It happens on desktop and on the mobile web UI.

Cause: use-stick-to-bottom only learns that the user left the bottom in two ways, and neither works reliably in this transcript.

  • Its wheel listener escapes only when the nearest overflow: auto ancestor of the event target is the viewport. A wheel over a code block, table, or tool output therefore never escapes.
  • Its scroll listener ignores every scroll event that arrives while a content resize is in flight. Streaming and virtua's row measurement keep a resize in flight almost all the time, so touch, scrollbar, and keyboard scrolls are ignored as well.

The lock stays engaged while the user reads history, and the next content growth or viewport resize scrolls them back down.

Fix: a small listener next to StickThroughViewportResize reads the user's intent from the input and calls the library's stopScroll(). It responds to an upward wheel that no nested scroller takes, a finger dragging the transcript down, an upward scroll key on the focused viewport, and an upward drag of the native scrollbar. It does nothing when the lock is already released, during an ignoreEscapes scroll, or when the content fits without scrolling. Following the stream while pinned, the scroll-to-bottom button, and the jump actions are unchanged.

Tests: added cases to message-thread.test.tsx for each escape path and for each case that must leave the lock alone.

Checks: pnpm lint ., tsc --noEmit, and the message-thread tests pass. Full-suite failures on my machine were 5-second timeouts in unrelated files, which pass when run on their own.

Adam-Dalloul and others added 2 commits October 8, 2026 11:29
Scrolling a transcript while a reply streams (or while virtua is still
measuring rows) could pull the view back to the bottom, on desktop and
on mobile.

use-stick-to-bottom only learns about an escape two ways. Its wheel
listener escapes only when the nearest overflow:auto ancestor of the
event target is the viewport, so a wheel over a code block, table or
tool output never escapes. Its scroll listener drops every scroll event
that lands while a content resize is in flight, and streaming plus
virtua's row measurement keep one in flight almost constantly, so touch,
scrollbar and keyboard scrolls are dropped too. The lock stays engaged
while the user reads history, and the next content growth or viewport
resize scrolls them back down.

Read the intent from the input instead: an upward wheel not taken by a
nested scroller, a finger dragging the transcript down, an upward
scroll key on the focused viewport, or an upward scrollbar drag now
release the lock through the library's stopScroll. Following the
stream while pinned, the scroll-to-bottom button and jump actions are
unchanged.
… scrollbars

A mostly sideways wheel or touch pan across a code block or table drifts
a few pixels vertically. The escape listener released the lock on that
drift even though the horizontal scroller took the gesture and the
transcript never moved, so the streaming reply stopped being followed.
A wheel whose horizontal delta dominates is now ignored, and a touch
settles its axis once, when it first travels past the slop.

The scrollbar-drag detector looked for a press outside the viewport's
client box. An overlay scrollbar (the macOS default) takes no layout
space, so a press on it never matched. A primary press whose target is
the viewport element itself now counts as a scrollbar press, and a press
on the transcript ends a drag whose release never reached the page.
@xintaofei

Copy link
Copy Markdown
Collaborator

codeg work task 296 is done — #899 (2 files, +157/-22).

@xintaofei
xintaofei merged commit 4ca52ca into spacering-net:main Oct 9, 2026
7 checks passed
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