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 =