fix: Sync streaming content to active messages

This commit is contained in:
Aleksander Grygier 2026-01-27 16:33:35 +01:00
parent aff13cc085
commit fcb7d1f899
2 changed files with 11 additions and 3 deletions

View File

@ -18,6 +18,7 @@
chatStore,
errorDialog,
isLoading,
isChatStreaming,
isEditing,
getAddFilesHandler
} from '$lib/stores/chat.svelte';
@ -75,7 +76,7 @@
let isServerLoading = $derived(serverLoading());
let hasPropsError = $derived(!!serverError());
let isCurrentConversationLoading = $derived(isLoading());
let isCurrentConversationLoading = $derived(isLoading() || isChatStreaming());
let isRouter = $derived(isRouterMode());

View File

@ -106,8 +106,15 @@ class ChatStore {
this.isLoading = this.chatLoadingStates.get(convId) || false;
const s = this.chatStreamingStates.get(convId);
this.currentResponse = s?.response || '';
if (s?.response && s?.messageId && this.messageUpdateCallback)
this.messageUpdateCallback(s.messageId, { content: s.response });
this.isStreamingActive = s !== undefined;
this.setActiveProcessingConversation(convId);
// Sync streaming content to activeMessages so UI displays current content
if (s?.response && s?.messageId) {
const idx = conversationsStore.findMessageIndex(s.messageId);
if (idx !== -1) {
conversationsStore.updateMessageAtIndex(idx, { content: s.response });
}
}
}
registerMessageUpdateCallback(
callback: (messageId: string, updates: Partial<DatabaseMessage>) => void