Repository navigation
fix(ui): prevent programmatic scrollTo from flipping chatUserNearBott… - #76991
Conversation
|
Codex review: needs real behavior proof before merge. Summary Reproducibility: unclear. The review failed before ClawSweeper could establish a reproduction path. Real behavior proof Next step before merge Review detailsBest possible solution: Retry the Codex review after fixing the execution failure. Do we have a high-confidence way to reproduce the issue? Unclear. The review failed before ClawSweeper could establish a reproduction path. Is this the best way to solve the issue? Unclear. Retry the review first so ClawSweeper can evaluate the actual issue and fix direction. What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 556c45cfbfd1. |
d983e21 to
a7d6484
Compare
…om during streaming
…ic scroll guard window
9c4e68a to
8df12a9
Compare
Behavior ProofAfter fix issue Screen.Recording.2026-05-08.at.4.39.21.PM.movWhat to observe in the recording:
|
|
@clawsweeper Re-run |
# Conflicts: # ui/src/ui/app.ts
# Conflicts: # src/auto-reply/reply/inbound-dedupe.test.ts
openclaw#76991) * fix(ui): prevent programmatic scrollTo from flipping chatUserNearBottom during streaming * fix(ui): preserve user scroll-up events that arrive during programmatic scroll guard window * test(ui): add unit coverage for programmatic scroll guard boundary and retry path * fix(ui): preserve chat scroll bookkeeping * chore: drop unrelated slack formatting * test: narrow inbound dedupe claim result --------- Co-authored-by: Peter Steinberger <[email protected]>
openclaw#76991) * fix(ui): prevent programmatic scrollTo from flipping chatUserNearBottom during streaming * fix(ui): preserve user scroll-up events that arrive during programmatic scroll guard window * test(ui): add unit coverage for programmatic scroll guard boundary and retry path * fix(ui): preserve chat scroll bookkeeping * chore: drop unrelated slack formatting * test: narrow inbound dedupe claim result --------- Co-authored-by: Peter Steinberger <[email protected]>
openclaw#76991) * fix(ui): prevent programmatic scrollTo from flipping chatUserNearBottom during streaming * fix(ui): preserve user scroll-up events that arrive during programmatic scroll guard window * test(ui): add unit coverage for programmatic scroll guard boundary and retry path * fix(ui): preserve chat scroll bookkeeping * chore: drop unrelated slack formatting * test: narrow inbound dedupe claim result --------- Co-authored-by: Peter Steinberger <[email protected]>
Summary
scrollTo()to pin the viewport to the bottom fires a synchronousscrollevent. Because new content has grownscrollHeightbetween thescrollTocall and the event,handleChatScrollcomputes a largedistanceFromBottom(≥ 450 px) and flipschatUserNearBottomtofalse, breaking the auto-scroll loop for all subsequent streaming tokens.chatIsProgrammaticScrollboolean flag is set on the host before each programmaticscrollTo/scrollTopwrite and cleared viarequestAnimationFrameafter.handleChatScrollreturns early when the flag is set, so our own scroll events cannot corrupt the near-bottom state.forcesemantics, logs scroll logic, or any non-scroll UI behavior are untouched.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
scheduleChatScrollcallstarget.scrollTo({top: scrollHeight})to pin the viewport. This fires ascrollevent thathandleChatScrollhandles. By the time that event fires, streamed content has already grownscrollHeight, sodistanceFromBottom = newScrollHeight - oldScrollTop - clientHeightexceedsNEAR_BOTTOM_THRESHOLD(450 px).handleChatScrollthen setschatUserNearBottom = false, and all subsequent streaming ticks seeshouldStick = false— auto-scroll breaks.scrollTocalls.handleChatScrolltreated both identically.scrollTocall and the scroll event dispatch — slower models or short responses may not trigger it.Regression Test Plan (if applicable)
chatIsProgrammaticScrollistrue, callinghandleChatScrollwith a scroll event whosedistanceFromBottomexceeds the threshold must NOT flipchatUserNearBottomtofalse."programmatic scroll guard"suite (16 total, all passing).User-visible / Behavior Changes
Diagram (if applicable)
Before:
[streaming token] -> scheduleChatScroll -> scrollTo(bottom)
-> scroll event fires -> handleChatScroll
-> distanceFromBottom > 450 (content grew)
-> chatUserNearBottom = false
-> next token: shouldStick = false -> viewport drifts up
After:
[streaming token] -> scheduleChatScroll -> chatIsProgrammaticScroll = true -> scrollTo(bottom)
-> scroll event fires -> handleChatScroll
-> chatIsProgrammaticScroll == true -> return early (no state change)
-> rAF fires -> chatIsProgrammaticScroll = false
-> next token: chatUserNearBottom still true -> stays pinned
Security Impact (required)
Repro + Verification
Environment
Steps
Expected
Actual (before fix)
Evidence
"programmatic scroll guard"suite directly exercises the previously missing guard. Before this PR,handleChatScrollwithdistanceFromBottom > 450would unconditionally setchatUserNearBottom = falseeven during a programmatic scroll.Behavior Proof
Screen.Recording.2026-05-08.at.4.39.21.PM.mov
What to observe in the recording:
Human Verification (required)
"scheduleChatScroll sets chatIsProgrammaticScroll…"test.chatUserNearBottomtofalse(verified in third new test).resetChatScrollalso clears the flag.Review Conversations
Compatibility / Migration
Risks and Mitigations
requestAnimationFramefires before the browser dispatches the scroll event in some edge cases (e.g. very fast rAF in a headless environment), clearing the flag too early.scheduleChatScroll(120 ms timeout) re-scrolls and sets the flag again, recovering on the very next cycle.You've used 74% of your weekly rate limit. Your weekly rate limit will reset on May 10 at 7:00 PM. Learn More