Uh oh!
There was an error while loading. Please reload this page.
How to stop chat autoscroll when AI message streams #730
Unanswered
james-pratama
asked this question in
Q&A
Replies: 1 comment 5 replies
@james-pratama you can controll it via one options is to disbale the scroll adjustment when receiving messages, or enable it only when scrolling backward, something like constrowVirtualizer=useVirtualizer({
count,getScrollElement: ()=>parentRef.current,estimateSize: ()=>1000,overscan: 5,});rowVirtualizer.shouldAdjustScrollPositionOnItemSizeChange=(item,_,instance)=>{returnitem.start<instance.scrollOffset&&instance.scrollDirection==='backward'} |
5 replies
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I am building an AI tool that has a chat feature. I am using Vercel's RSC SDK to stream messages, and showing those messages on the client from the array provided by useUIState. I feed UIState messages into Tanstack Virtual, and return message.component in each row, which is a StreamableValue.
https://sdk.vercel.ai/examples/next-app/state-management/ai-ui-states
Everything works fine, except when a new message is being streamed and it is visible on the screen, the list continuously autoscrolls to the bottom until the message stops streaming. Anytime a new message is streamed, it will autoscroll user to bottom unless the user is scrolled above past the current message being streamed.
Tried adding overflowAnchor: "none" but does not work. The autoscroll occurs even when I don't implement any scroll function of my own or use scrollToIndex, on both Safari and Chrome.
Is this a known issue that it autoscrolls when content is being streamed?
Scroll.mov
All reactions