import { DataWithScrollModifier, ScrollModifier, VirtuosoMessageList, VirtuosoMessageListLicense, VirtuosoMessageListMethods, VirtuosoMessageListProps, } from '@virtuoso.dev/message-list'; import { useEffect, useMemo, useRef, useState } from 'react'; import DisplayConversationEntry from '../NormalizedConversation/DisplayConversationEntry'; import { useEntries } from '@/contexts/EntriesContext'; import { AddEntryType, PatchTypeWithKey, useConversationHistory, } from '@/hooks/useConversationHistory'; import { Loader2 } from 'lucide-react'; import { TaskAttempt } from 'shared/types'; import { ApprovalFormProvider } from '@/contexts/ApprovalFormContext'; interface VirtualizedListProps { attempt: TaskAttempt; } interface MessageListContext { attempt: TaskAttempt; } const INITIAL_TOP_ITEM = { index: 'LAST' as const, align: 'end' as const }; const InitialDataScrollModifier: ScrollModifier = { type: 'item-location', location: INITIAL_TOP_ITEM, purgeItemSizes: true, }; const AutoScrollToBottom: ScrollModifier = { type: 'auto-scroll-to-bottom', autoScroll: 'smooth', }; const ItemContent: VirtuosoMessageListProps< PatchTypeWithKey, MessageListContext >['ItemContent'] = ({ data, context }) => { const attempt = context?.attempt; if (data.type === 'STDOUT') { return
{data.content}
; } if (data.type === 'STDERR') { return{data.content}
; } if (data.type === 'NORMALIZED_ENTRY' && attempt) { return (Loading History