Commit 2c1392e
authored
fix(chat): autoscroll follow-ups — re-engage threshold + keep end-of-turn options in view (#5094)
* fix(chat): align scrollbar/keyboard detach with wheel/touch re-engage threshold
The onScroll detach branch set only stickyRef.current = false, leaving
userDetachedRef false, so a scrollbar-drag or keyboard detach kept the lenient
30px (STICK_THRESHOLD) re-engage threshold instead of the strict 5px
(REATTACH_THRESHOLD) used after wheel/touch. A programmatic virtualizer re-pin
landing within 30px could then snap autoscroll back on right after the user
deliberately scrolled away. Reuse the detach() helper so all detach paths set
userDetachedRef consistently.
* fix(chat): keep end-of-turn options in view after streaming
When a stream ends, the suggested-follow-up options and the actions row (gated
on !isStreaming) mount, but the virtualizer's getTotalSize — which drives the
scroll container's scrollHeight — only catches up a frame or two later via its
ResizeObserver. The single scrollToBottom() on effect teardown therefore landed
on a stale, too-short bottom and the options were clipped behind the input.
(Pre-virtualization this worked because scrollHeight reflected the new rows
immediately.)
Extract the rAF follow loop already used for CSS height animations into a shared
followToBottom(window) helper and run it for a short settle window on teardown,
so the bottom is chased until the virtualizer re-measures. The follow is
self-interrupting — height growth leaves scrollTop where we put it, while a user
scroll moves it up, so it bails the instant the user scrolls and never fights a
real gesture even with listeners torn down.1 parent e1f22bd commit 2c1392e
1 file changed
Lines changed: 34 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
27 | 37 | | |
28 | 38 | | |
29 | 39 | | |
| |||
147 | 157 | | |
148 | 158 | | |
149 | 159 | | |
150 | | - | |
| 160 | + | |
151 | 161 | | |
152 | 162 | | |
153 | 163 | | |
| |||
166 | 176 | | |
167 | 177 | | |
168 | 178 | | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
173 | 188 | | |
174 | | - | |
| 189 | + | |
175 | 190 | | |
176 | | - | |
| 191 | + | |
| 192 | + | |
177 | 193 | | |
178 | 194 | | |
| 195 | + | |
179 | 196 | | |
| 197 | + | |
180 | 198 | | |
181 | 199 | | |
182 | 200 | | |
183 | 201 | | |
184 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
185 | 211 | | |
186 | 212 | | |
187 | 213 | | |
| |||
209 | 235 | | |
210 | 236 | | |
211 | 237 | | |
212 | | - | |
| 238 | + | |
213 | 239 | | |
214 | 240 | | |
215 | 241 | | |
| |||
0 commit comments