diff --git a/ee/tabby-ui/app/chat/page.tsx b/ee/tabby-ui/app/chat/page.tsx index faf0f9a712df..efd6a9087902 100644 --- a/ee/tabby-ui/app/chat/page.tsx +++ b/ee/tabby-ui/app/chat/page.tsx @@ -33,9 +33,8 @@ export default function ChatPage() { null ) const [activeChatId, setActiveChatId] = useState('') - const [initialMessages, setInitialMessages] = useState( - [] - ) + let pendingMessages: ChatMessage[] = [] // FIXME(wwayne): use init message props after Chat component update + const chatRef = useRef(null) const searchParams = useSearchParams() const maxWidth = searchParams.get('max-width') || undefined @@ -71,14 +70,7 @@ export default function ChatPage() { if (chatRef.current) { chatRef.current.sendUserChat(message) } else { - const newInitialMessages = [...initialMessages] - newInitialMessages.push({ - user: { - ...message, - id: nanoid() - } - }) - setInitialMessages(newInitialMessages) + pendingMessages.push(message) } } @@ -88,6 +80,11 @@ export default function ChatPage() { setActiveChatId(nanoid()) setIsInit(true) setFetcherOptions(request.fetcherOptions) + + // FIXME(wwayne): This is no needed after Chat support initMessage + setTimeout(() => { + pendingMessages.forEach(sendMessage) + }, 1000) }, sendMessage: (message: ChatMessage) => { return sendMessage(message) @@ -108,7 +105,6 @@ export default function ChatPage() { key={activeChatId} ref={chatRef} headers={headers} - initialMessages={initialMessages} onThreadUpdates={() => {}} onNavigateToContext={onNavigateToContext} maxWidth={maxWidth}