fix: scroll bottom when generation text (#4323)
* fix: scroll bottom when generation text * chore: update logic when prepare generate * chore: fix case no switch thread * chore: remore dep thread id * chore: handle fix generation without have dep thread id
This commit is contained in:
parent
df1c465fd9
commit
56d1ffa136
@ -86,23 +86,32 @@ const ChatBody = memo(
|
|||||||
})
|
})
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (parentRef.current && isGeneratingResponse) {
|
|
||||||
requestAnimationFrame(() => {
|
|
||||||
if (parentRef.current) {
|
|
||||||
parentRef.current.scrollTo({ top: parentRef.current.scrollHeight })
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}, [count, virtualizer, isGeneratingResponse])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
isUserManuallyScrollingUp.current = false
|
|
||||||
requestAnimationFrame(() => {
|
|
||||||
if (parentRef.current) {
|
if (parentRef.current) {
|
||||||
parentRef.current.scrollTo({ top: parentRef.current.scrollHeight })
|
parentRef.current.scrollTo({ top: parentRef.current.scrollHeight })
|
||||||
virtualizer.scrollToIndex(count - 1)
|
virtualizer.scrollToIndex(count - 1)
|
||||||
}
|
}
|
||||||
})
|
}, [count, virtualizer])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (parentRef.current && isGeneratingResponse) {
|
||||||
|
parentRef.current.scrollTo({ top: parentRef.current.scrollHeight })
|
||||||
|
virtualizer.scrollToIndex(count - 1)
|
||||||
|
}
|
||||||
|
}, [count, virtualizer, isGeneratingResponse])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (parentRef.current && isGeneratingResponse) {
|
||||||
|
parentRef.current.scrollTo({ top: parentRef.current.scrollHeight })
|
||||||
|
virtualizer.scrollToIndex(count - 1)
|
||||||
|
}
|
||||||
|
}, [count, virtualizer, isGeneratingResponse, currentThread?.id])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
isUserManuallyScrollingUp.current = false
|
||||||
|
if (parentRef.current) {
|
||||||
|
parentRef.current.scrollTo({ top: parentRef.current.scrollHeight })
|
||||||
|
virtualizer.scrollToIndex(count - 1)
|
||||||
|
}
|
||||||
}, [count, currentThread?.id, virtualizer])
|
}, [count, currentThread?.id, virtualizer])
|
||||||
|
|
||||||
const items = virtualizer.getVirtualItems()
|
const items = virtualizer.getVirtualItems()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user