Repository navigation
fix(tui): prevent scroll snap when reading history during LLM response - #21343
divitkashyap wants to merge 3 commits into
Conversation
When a user scrolls up to read chat history while an LLM is still streaming, the view would snap back to the bottom on every token update due to stickyScroll=true always forcing scroll-to-bottom. This change tracks user scroll state via a userScrolledUp signal and makes stickyScroll reactive - only auto-scrolling when the user is at the bottom. User scroll commands (page up, line up, first message) set the flag to pause auto-scroll, while toBottom() and last message reset it to resume. Fixes anomalyco#4196
|
Hi! I previously had this PR open (#21342) but accidentally closed it. This fix resolves issue #4196 - it prevents scroll snap when reading chat history during LLM response by adding a The changes follow existing TUI patterns and mirror the web app's |
|
👋 Bumping this PR for review. This fix prevents scroll snap when reading history during LLM response — adds signal to track manual scroll state. Changes: |
|
👋 Bumping this PR for review. This fix prevents scroll snap when reading history during LLM response. Changes in packages/opencode/src/cli/cmd/tui/routes/session/index.tsx |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Type of change
What does this PR do?
When a user scrolls up to read chat history while an LLM is still streaming, the view snaps back to the bottom on every token update. This is because
stickyScroll={true}on the message scrollbox forces scroll-to-bottom regardless of user scroll state.The fix adds a
userScrolledUpsignal that tracks when the user has manually scrolled away from the bottom. ThestickyScrollprop is now reactive (!userScrolledUp()), so auto-scroll only engages when the user is at the bottom.Upward scroll commands (Page Up, Line Up, Half Page Up, First Message) set the flag. Commands that return to bottom (toBottom(), Last Message) and session sync reset it.
How did you verify your code works?
bun run typecheckpasses in all 13 packagespackages/ui/src/hooks/create-auto-scroll.tsxfrom the web app, which implements the same behavior for the web clientChecklist