Repository navigation
fix(chat): stop following a streaming reply as soon as the reader scrolls up - #679
Merged
Merged
Conversation
…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
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.
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 --noEmitclean,npm test110/110.: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.