fix: Sync streaming content to active messages
This commit is contained in:
parent
aff13cc085
commit
fcb7d1f899
|
|
@ -18,6 +18,7 @@
|
||||||
chatStore,
|
chatStore,
|
||||||
errorDialog,
|
errorDialog,
|
||||||
isLoading,
|
isLoading,
|
||||||
|
isChatStreaming,
|
||||||
isEditing,
|
isEditing,
|
||||||
getAddFilesHandler
|
getAddFilesHandler
|
||||||
} from '$lib/stores/chat.svelte';
|
} from '$lib/stores/chat.svelte';
|
||||||
|
|
@ -75,7 +76,7 @@
|
||||||
let isServerLoading = $derived(serverLoading());
|
let isServerLoading = $derived(serverLoading());
|
||||||
let hasPropsError = $derived(!!serverError());
|
let hasPropsError = $derived(!!serverError());
|
||||||
|
|
||||||
let isCurrentConversationLoading = $derived(isLoading());
|
let isCurrentConversationLoading = $derived(isLoading() || isChatStreaming());
|
||||||
|
|
||||||
let isRouter = $derived(isRouterMode());
|
let isRouter = $derived(isRouterMode());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,8 +106,15 @@ class ChatStore {
|
||||||
this.isLoading = this.chatLoadingStates.get(convId) || false;
|
this.isLoading = this.chatLoadingStates.get(convId) || false;
|
||||||
const s = this.chatStreamingStates.get(convId);
|
const s = this.chatStreamingStates.get(convId);
|
||||||
this.currentResponse = s?.response || '';
|
this.currentResponse = s?.response || '';
|
||||||
if (s?.response && s?.messageId && this.messageUpdateCallback)
|
this.isStreamingActive = s !== undefined;
|
||||||
this.messageUpdateCallback(s.messageId, { content: s.response });
|
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(
|
registerMessageUpdateCallback(
|
||||||
callback: (messageId: string, updates: Partial<DatabaseMessage>) => void
|
callback: (messageId: string, updates: Partial<DatabaseMessage>) => void
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue