fix: enable auto-scroll during assistant response streaming#15110
fix: enable auto-scroll during assistant response streaming#15110BunsDev merged 6 commits intoopenclaw:mainfrom
Conversation
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 badge to see streaming responses. Fixes openclaw#14959 Changes: - Reset chat scroll state before sending message to ensure viewport readiness - Force scroll to bottom after message send to position viewport correctly - Detect streaming start (chatStream: null -> string) and trigger auto-scroll - Ensure smooth scroll-following during entire streaming response Co-Authored-By: Claude Opus 4.6 <[email protected]>
Additional Comments (1)
Prompt To Fix With AIThis is a comment left during a code review.
Path: ui/src/ui/app-lifecycle.ts
Line: 21:35
Comment:
**Incorrect `chatStream` type**
`LifecycleHost` declares `chatStream: string`, but the actual app state uses `string | null` (`ui/src/ui/app.ts:131`) and multiple code paths explicitly assign `null` (e.g. `ui/src/ui/controllers/chat.ts:137-139`, `197-207`). This PR’s new `previousStream === null/undefined` logic depends on that nullable state, so the local type is now actively misleading and may hide real null handling issues. Update `LifecycleHost.chatStream` (and any related signatures) to `string | null` to match runtime/state usage.
How can I resolve this? If you propose a fix, please make it concise. |
bfc1ccb to
f92900f
Compare
|
This pull request has been automatically marked as stale due to inactivity. |
BunsDev
left a comment
There was a problem hiding this comment.
This looks good to me. The approach is small, targeted, and reuses the existing scroll state machinery rather than introducing a parallel path. I pushed a follow-up commit to align LifecycleHost.chatStream with the nullable state the UI already uses, which makes the new stream-start detection logic consistent with reality. With that in place, I’m comfortable approving this.
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:
This creates a tedious conversation experience where users can't see responses in real-time.
Changes
resetChatScroll()before sending to ensure viewport readinessforce=truetoscheduleChatScroll()to position viewport correctlychatStreamchanges fromnullto a string value inhandleUpdated()Technical Details
ui/src/ui/app-chat.ts: Reset scroll state and force scroll on message sendui/src/ui/app-lifecycle.ts: Detect streaming start and enable auto-scrollTest Results
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 [email protected]
Greptile Overview
Greptile Summary
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.tsresets chat scroll state before sending and forces a scroll scheduling after send.ui/src/ui/app-lifecycle.tsadds detection for whenchatStreamtransitions 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.Confidence Score: 4/5
LifecycleHost.chatStreamis 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.Last reviewed commit: 36a47a3
(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!