Skip to content

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

Merged
BunsDev merged 6 commits intoopenclaw:mainfrom
jwchmodx:fix/issue-14959-web-ui-autoscroll-clean
Mar 16, 2026
Merged

fix: enable auto-scroll during assistant response streaming#15110
BunsDev merged 6 commits intoopenclaw:mainfrom
jwchmodx:fix/issue-14959-web-ui-autoscroll-clean

Conversation

@jwchmodx
Copy link
Copy Markdown

@jwchmodx jwchmodx commented Feb 13, 2026

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 [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.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.

Confidence Score: 4/5

  • 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

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!

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]>
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Feb 13, 2026

Additional Comments (1)

ui/src/ui/app-lifecycle.ts
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.

Prompt To Fix With AI
This 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.

@openclaw-barnacle
Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle bot added stale Marked as stale due to inactivity and removed stale Marked as stale due to inactivity labels Feb 21, 2026
@BunsDev BunsDev self-assigned this Mar 10, 2026
Copy link
Copy Markdown
Member

@BunsDev BunsDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@BunsDev BunsDev merged commit 2ab25ba into openclaw:main Mar 16, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Web UI: chat does not auto-scroll to assistant reply, requires clicking 'new message' badge

2 participants