perf: stick-to-bottom chat scroll - #19
Merged
Merged
Conversation
The chat auto-scrolled to the bottom on every appended message, so reading earlier history while the agent was actively streaming was impossible — each delta yanked the view back down. Track a JS 'stickToBottom' flag from the window scroll position: auto-scroll only while the user is following the tail (within ~3 lines of the end), and stop the instant they scroll up. Following resumes automatically when they scroll back down. Submitting a message re-engages follow and jumps to the bottom (via a new force_scroll flag on append_user_message), so a scrolled-up user still sees their own message and the reply; history replay passes false.
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.
Problem
The chat scrolled to the bottom on every appended message. Useful normally, but it made it impossible to scroll up and read earlier messages while the agent was actively streaming — each delta yanked the view back to the tail.
Fix
Auto-follow the bottom only when the user is already there. A JS `stickToBottom` flag is updated from the window scroll position:
The two modes are distinguished automatically from scroll position — no toggle, no button.
Submitting a message is an explicit "I'm engaging again" signal, so it re-engages follow and jumps to the bottom (new `force_scroll` flag on `append_user_message`), ensuring a scrolled-up user still sees their own message and the reply. History replay passes `false` so loading a tab doesn't yank a reader who scrolled up mid-load.
Scope
All other scroll call sites (streaming deltas, tool calls, system messages) inherit the behavior unchanged through the gated `scrollToBottom()`.
Checks
fmt ✅ · clippy `-D warnings` (lib+bins) ✅ · tests ✅