Virtuoso footer re-rendering issue (#4209)

The Virtuoso component has a inner footer component that serves only as a bottom spacer, after investigation this component keeps re-rendering, beccause its unnecessary it was removed and the spaccing added to the component itselve
This commit is contained in:
kiwina 2025-06-02 04:52:17 +08:00 committed by GitHub
parent 98f5542021
commit 03754f615d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1415,10 +1415,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
<Virtuoso
ref={virtuosoRef}
key={task.ts} // trick to make sure virtuoso re-renders when task changes, and we use initialTopMostItemIndex to start at the bottom
className="scrollable grow overflow-y-scroll"
components={{
Footer: () => <div className="h-[5px]" />, // Add empty padding at the bottom
}}
className="scrollable grow overflow-y-scroll mb-[5px]"
// increasing top by 3_000 to prevent jumping around when user collapses a row
increaseViewportBy={{ top: 3_000, bottom: Number.MAX_SAFE_INTEGER }} // hack to make sure the last message is always rendered to get truly perfect scroll to bottom animation when new messages are added (Number.MAX_SAFE_INTEGER is safe for arithmetic operations, which is all virtuoso uses this value for in src/sizeRangeSystem.ts)
data={groupedMessages} // messages is the raw format returned by extension, modifiedMessages is the manipulated structure that combines certain messages of related type, and visibleMessages is the filtered structure that removes messages that should not be rendered