From 62fd43d0861867dd85e57668dcd40cdc0a7d1a58 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 16 Jan 2026 22:37:12 +0000 Subject: [PATCH] fix: load messages early to trigger streaming poll The messages were being streamed successfully but never displayed because: - loadMessages() was only called after sendMessage() completed - By then isStreaming was already false - The polling effect never triggered Now we load messages shortly after starting the send to: 1. Show the user message immediately 2. Trigger the polling effect for streaming updates --- src/components/ai/AIChat.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/ai/AIChat.tsx b/src/components/ai/AIChat.tsx index 5e69b47..905f5d1 100644 --- a/src/components/ai/AIChat.tsx +++ b/src/components/ai/AIChat.tsx @@ -186,7 +186,8 @@ export function AIChat({ conversation, onConversationUpdate }: AIChatProps) { try { setStatus(`Connecting to ${conversation.model}...`); - await aiService.sendMessage( + // Start the message send (don't await yet) + const sendPromise = aiService.sendMessage( conversation.id, content, (_chunk, _fullContent) => { @@ -194,6 +195,15 @@ export function AIChat({ conversation, onConversationUpdate }: AIChatProps) { }, ); + // Small delay to let the user message and streaming assistant message be created + await new Promise((resolve) => setTimeout(resolve, 100)); + + // Load messages to show user message and start polling for streaming updates + await loadMessages(); + + // Now wait for the stream to complete + await sendPromise; + // Reload messages to get final state await loadMessages(); setStatus(null);