Skip to content

Commit b9770ef

Browse files
committed
Improve chat scroll UX with immediate loading feedback
Signed-off-by: Arya Pratap Singh <[email protected]>
1 parent 581dd22 commit b9770ef

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/client/components/ChatV2/ChatV2.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,12 @@ const ChatV2Content = () => {
190190
}, 5000)
191191

192192
setIsStreaming(true)
193-
chatScroll.beginAutoscroll()
193+
194+
// Scroll immediately to show loading dots for better UX feedback
195+
// Small delay ensures React has rendered the loading message
196+
setTimeout(() => {
197+
chatScroll.beginAutoscroll()
198+
}, 10)
194199

195200
const generationInfo: MessageGenerationInfo = {
196201
model: acualModel,

src/client/components/ChatV2/useChatScroll.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,18 @@ export const useChatScroll = () => {
3838
startTransition(() => {
3939
isUserDisabled = false
4040
setIsAutoScrolling(true)
41+
// Immediate scroll to show loading dots right away for better UX
4142
window.scrollTo({
4243
top: document.body.scrollHeight,
43-
behavior: 'smooth',
44+
behavior: 'instant',
4445
})
46+
// Follow up with smooth scroll after a brief delay to maintain smooth UX
47+
setTimeout(() => {
48+
window.scrollTo({
49+
top: document.body.scrollHeight,
50+
behavior: 'smooth',
51+
})
52+
}, 50)
4553
})
4654
}
4755

0 commit comments

Comments
 (0)