#15110: fix: enable auto-scroll during assistant response streaming
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
#7522: fix(webchat): auto-scroll when message queue changes
by alsoknownasfoo · 2026-02-02
86.8%
#3721: fix(ui): webchat not displaying chat responses
by maxmaxrouge-rgb · 2026-01-29
82.6%
#20347: fix(webchat): resolve streaming scroll race condition
by ndaemy · 2026-02-18
81.9%
#8353: fix(ui): display tool calls during webchat streaming
by MarvinDontPanic · 2026-02-03
81.6%
#14309: fix(ui): resolve chat event session key mismatch
by justonlyforyou · 2026-02-11
81.4%
#4495: Fix: emit final assistant event when reply tags hide stream
by ukeate · 2026-01-30
80.2%
#14966: fix(webchat): preserve user message visibility after chat.send
by BenediktSchackenberg · 2026-02-12
79.5%
#22798: feat(webchat): ChatGPT-style multi-chat threads with generated titles
by opnsec · 2026-02-21
79.2%
#23073: fix(ui): strip reply directive tags from assistant messages in WebC...
by x4v13r1120 · 2026-02-22
79.0%
#11889: fix(chat): filter HEARTBEAT_OK messages in chat.history when showOk...
by bendyclaw · 2026-02-08
78.3%