You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(chat): keep autoscroll pinned when the virtualizer re-scrolls during streaming (#5093)
* fix(chat): keep autoscroll pinned when the virtualizer re-scrolls during streaming
The sticky-scroll detach heuristic (scrollTop drops while scrollHeight
doesn't grow) could not distinguish a user scrollbar drag from a
programmatic scroll. react-virtual re-pins content by moving scrollTop
whenever a measured row's size changes — including the transient height
shrinks streamdown emits as it re-parses each streaming token — so the
hook misread those upward programmatic scrolls as the user scrolling
away and detached mid-stream.
Gate the scroll-delta detach branch behind a genuine recent user gesture
(pointerdown/up tracking + wheel/touch/keydown stamp). Programmatic
scrolls have no preceding gesture, so they no longer detach; scrollbar
drag, wheel, and keyboard detach are preserved.
* fix(chat): address review — reset pointer ref on teardown, stop wheel/touch opening detach window
- Reset pointerDownRef in effect cleanup so a pointer held through teardown
(e.g. dragging the scrollbar as a stream finishes) can't leak a stuck-true
ref into the next session and detach on the first programmatic re-pin.
- Wheel-up and touch-drag already detach directly, so the onScroll delta
heuristic only needs to authorize scrollbar drag (pointerDownRef) and
keyboard. Stop stamping the gesture window on wheel/touch, which otherwise
let a harmless downward wheel open a 250ms window where a virtualizer
shrink could falsely detach.
* fix(chat): scope detach authorization to real scroll gestures; TSDoc comments
- onPointerDown only marks an active drag when the press targets the scroll
container itself (the scrollbar), not its content, so a text-selection drag
on a message can't authorize a detach during a programmatic re-pin.
- Reset lastUserGestureAtRef on teardown alongside pointerDownRef so neither a
held pointer nor a late keydown can leak across streaming sessions.
- Convert the hook's inline comments to TSDoc on the relevant declarations per
codebase conventions.
* fix(chat): only upward scroll keys authorize a keyboard detach
onKeyDown stamped the gesture window on any bubbling key, so an unrelated
keypress within USER_GESTURE_WINDOW of a programmatic virtualizer re-pin
could satisfy userDriven and detach mid-stream. Filter to the upward scroll
keys (ArrowUp, PageUp, Home, Shift+Space), mirroring the wheel handler's
upward-only rule, so only a genuine upward keyboard scroll authorizes detach.
0 commit comments