Skip to content

Commit

Permalink
fix: scroll bottom when generation text
Browse files Browse the repository at this point in the history
  • Loading branch information
urmauur committed Dec 23, 2024
1 parent 365cdfa commit 8c1f133
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions web/screens/Thread/ThreadCenterPanel/ChatBody/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,16 @@ const ChatBody = memo(

useEffect(() => {
if (parentRef.current && isGeneratingResponse) {
requestAnimationFrame(() => {
if (parentRef.current) {
parentRef.current.scrollTo({ top: parentRef.current.scrollHeight })
}
})
parentRef.current.scrollTo({ top: parentRef.current.scrollHeight })
}
}, [count, virtualizer, isGeneratingResponse])
}, [count, virtualizer, isGeneratingResponse, currentThread?.id])

useEffect(() => {
isUserManuallyScrollingUp.current = false
requestAnimationFrame(() => {
if (parentRef.current) {
parentRef.current.scrollTo({ top: parentRef.current.scrollHeight })
virtualizer.scrollToIndex(count - 1)
}
})
if (parentRef.current) {
parentRef.current.scrollTo({ top: parentRef.current.scrollHeight })
virtualizer.scrollToIndex(count - 1)
}
}, [count, currentThread?.id, virtualizer])

const items = virtualizer.getVirtualItems()
Expand Down

0 comments on commit 8c1f133

Please sign in to comment.