Skip to content

fix(chat): stop following a streaming reply as soon as the reader scrolls up - #679

Merged
kthare10 merged 1 commit into
developfrom
fix/chat-scroll-follow
Nov 13, 2026
Merged

kthare10 merged 1 commit into
developfrom
fix/chat-scroll-follow

Conversation

@kthare10

Copy link
Copy Markdown
Contributor

Closes #678

What changed

  • lib/opencode/scroll-follow.ts (new): nextFollowing() decides follow mode from scroll events. Any move up leaves it. A clamp to the bottom when content shrinks does not. Moving down to within 32px of the bottom rejoins.
  • components/chat/opencode-chat.tsx: the per-update "within 160px? jump to the bottom" check is now "following? jump to the bottom". Sending a message or switching conversations resumes following. While not following, a sticky button at the bottom of the transcript reads "Follow the reply" (streaming) or "Jump to latest" (idle).
  • lib/opencode/scroll-follow.test.ts: covers the reported case (one wheel notch up), content growing under a reader who scrolled away, rejoining, the shrink clamp, and our own follow scrolls.

Verification

  • tsc --noEmit clean, npm test 110/110.
  • Not tested in a browser. On :develop, ask for a long answer and, while it streams: scroll up one wheel notch (it should stay put), scroll back to the bottom (it should follow again), and use the button.

…olls up

The chat decided on every streamed update whether to follow the tail by
distance from the bottom: within 160px, jump to the bottom. One wheel notch
is about 100px, so the first move up still counted as "near the bottom" and
was undone on the next frame; the reader had to out-scroll the stream to
read anything above it.

Follow is now decided from the reader's scroll events
(lib/opencode/scroll-follow.ts, unit-tested): any move up leaves it, a
clamp from shrinking content does not, and scrolling back near the bottom
rejoins. Sending a message or switching conversations rejoins too, and a
sticky "Jump to latest" / "Follow the reply" button appears while not
following.

Refs #678
@kthare10
kthare10 merged commit 5302af3 into develop Nov 13, 2026
2 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.

1 participant