From abdaa9d143bd232d2d337fd11c9980b50ab6a301 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Tue, 1 Dec 2026 00:14:25 +0400 Subject: [PATCH] refac --- src/lib/components/chat/Chat.svelte | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index c5e875dd9a..fea036ec81 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -1837,8 +1837,8 @@ const connectionId = socket?.id; if (next && socket) socket.emit('events:chat', { chat_id: next, data: { type: 'join' } }, (accepted: boolean) => { - if (!socket.connected || socket.id !== connectionId || $chatId !== next) return; - if (!accepted) clearPresence(); + if (accepted || !socket.connected || socket.id !== connectionId || $chatId !== next) return; + clearPresence(); // A refused join can mean access was lost; the refresh then sends the reader home. void refreshChat(); }); @@ -2325,6 +2325,8 @@ } joinedChatId = ''; syncChatRoom($socket, $chatId, $temporaryChat); + // Updates sent while disconnected were missed. + void refreshChat(); const id = $chatId; const tasks = await getTaskIdsByChatId(localStorage.token, id).catch(() => null); if ($chatId !== id || !tasks) return; @@ -3580,6 +3582,7 @@ // nodes from failed regenerations (#24424, #24157, #20474) sanitizeHistory(history); cachedHistory = cached ? { ...history, messages: { ...history.messages } } : null; + if (cached) void refreshChat(); chatTitle.set(chatContent.title); branchPointMessageId =