mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-10 15:36:53 +02:00
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
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user