react-virtual in messages list

This commit is contained in:
2026-02-21 13:33:09 +00:00
parent f089a89eae
commit fda5ea147a
+12 -5
View File
@@ -40,8 +40,9 @@ export const MessageList = ({
Send a message to start Send a message to start
</div> </div>
)} )}
{messages.length > 0 && (
<div <div
className="p-4 space-y-3" className="relative w-full"
style={{ height: virtualizer.getTotalSize() }} style={{ height: virtualizer.getTotalSize() }}
> >
{virtualizer.getVirtualItems().map((virtualRow) => { {virtualizer.getVirtualItems().map((virtualRow) => {
@@ -49,18 +50,24 @@ export const MessageList = ({
return ( return (
<div <div
key={virtualRow.key} key={virtualRow.key}
className="absolute left-0 w-full" className="absolute top-0 left-0 w-full px-4"
style={{ style={{
top: virtualRow.start, transform: `translateY(${virtualRow.start}px)`,
height: virtualRow.size,
}} }}
> >
<div className="py-1.5">
<MessageBubble message={msg} onAnswer={onQuestionAnswer} /> <MessageBubble message={msg} onAnswer={onQuestionAnswer} />
</div> </div>
</div>
); );
})} })}
</div> </div>
{isGenerating && <StreamingBubble text={streamingText} />} )}
{isGenerating && (
<div className="px-4 py-1.5">
<StreamingBubble text={streamingText} />
</div>
)}
<div ref={bottomRef} /> <div ref={bottomRef} />
</div> </div>