From 7f402d101d07074c5d116a16b0439a26e00b350b Mon Sep 17 00:00:00 2001 From: _00_ <131402327+rgaricano@users.noreply.github.com> Date: Mon, 27 Apr 2026 09:23:10 +0200 Subject: [PATCH] Update Chat.svelte --- src/lib/components/chat/Chat.svelte | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index 03af994a68..4a20ae8acf 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -1648,7 +1648,25 @@ }; const chatCompletionEventHandler = async (data, message, chatId) => { - const { id, done, choices, content, output, sources, selected_model_id, error, usage } = data; + const { id, done, choices, content, output, sources, selected_model_id, error, usage, yjs_update } = data; + + // Handle Yjs updates for streaming + if (yjs_update && message.id) { + // Get or create Yjs handler for this message + if (!message.yjsHandler) { + message.yjsHandler = new ChatMessageYjsHandler( + message.id, + $socket, + (content) => { + message.content = content; + } + ); + } + + // Apply Yjs update (handled internally by ChatMessageYjsHandler) + // The handler will update message.content via the callback + return; // Skip traditional processing for Yjs updates + } // Store raw OR-aligned output items from backend if (output) {