← Back to PRs

#15110: fix: enable auto-scroll during assistant response streaming

by jwchmodx open 2026-02-13 01:41 View on GitHub →
app: web-ui stale size: XS
Fixes #14959 ## Summary Fix auto-scroll behavior when AI assistant streams responses in the web UI. Previously, the viewport would remain at the sent message position and users had to manually click a "new message" badge to see streaming responses. ## Problem When sending a message in the web UI: 1. User sends a message 2. Viewport stays at the sent message position 3. Assistant reply streams below the visible area 4. A notification badge appears, requiring manual click 5. User must click the badge to see the response This creates a tedious conversation experience where users can't see responses in real-time. ## Changes - **Reset chat scroll state before sending**: Call `resetChatScroll()` before sending to ensure viewport readiness - **Force scroll after message send**: Add `force=true` to `scheduleChatScroll()` to position viewport correctly - **Detect streaming start**: Check when `chatStream` changes from `null` to a string value in `handleUpdated()` - **Auto-scroll during streaming**: Trigger auto-scroll when streaming begins to ensure smooth scroll-following ## Technical Details - Modified `ui/src/ui/app-chat.ts`: Reset scroll state and force scroll on message send - Modified `ui/src/ui/app-lifecycle.ts`: Detect streaming start and enable auto-scroll ## Test Results - ✅ All scroll tests pass (13/13 in app-scroll.test.ts) - ✅ Full UI test suite: 192/197 tests passed (5 pre-existing failures unrelated to this change) - ✅ Build successful ## AI-Assisted Development This PR was developed with assistance from Claude Opus 4.6. The code has been reviewed and tested to ensure correctness. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adjusts the web UI’s chat auto-scroll behavior so the viewport follows assistant streaming responses. Changes are primarily in the UI state/lifecycle layer: - `ui/src/ui/app-chat.ts` resets chat scroll state before sending and forces a scroll scheduling after send. - `ui/src/ui/app-lifecycle.ts` adds detection for when `chatStream` transitions from null/undefined to a string, and uses that to force an initial scroll when streaming begins. Overall direction looks consistent with existing `scheduleChatScroll()` semantics (force only applies before the first auto-scroll), but there is a concrete type mismatch in the lifecycle host definition that should be fixed before merge. <h3>Confidence Score: 4/5</h3> - Mostly safe to merge once the lifecycle host type mismatch is corrected - Behavioral changes are small and leverage existing scroll scheduling semantics, but `LifecycleHost.chatStream` is incorrectly typed as non-nullable while the rest of the UI sets it to null; this can mislead future edits and undermine the new streaming-start logic. - ui/src/ui/app-lifecycle.ts <sub>Last reviewed commit: 36a47a3</sub> <!-- greptile_other_comments_section --> <sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub> <!-- /greptile_comment -->

Most Similar PRs