From 274729aa477826a041b4e1f044f085757b839baa Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Fri, 10 Jul 2026 20:30:55 +0200 Subject: [PATCH] fix: socket reconnect recovery never runs for chats started from the home page (#26913) When a chat is started from the home page, the URL is switched to /c/{id} with history.replaceState, so the Chat component is never remounted and chatIdProp stays empty for the lifetime of that view. Both websocket recovery paths, handleSocketConnect and the chat:active fallback, are gated on chatIdProp and therefore never run for these chats. After any websocket drop during a response (mobile backgrounding, VPN or IP change, wake from sleep) the completed response is never fetched and the chat stays stuck in a loading state until a manual page refresh. Chats opened directly via /c/{id} recover fine, which is why the bug only reproduces reliably on freshly started chats. Gate both recovery paths on the chatId store instead, which is set for every persisted chat, and let loadChat fall back to it so the recovery reload also works when chatIdProp is empty. Chats opened via /c/{id} behave exactly as before and temporary chats stay excluded. The same gate likely explains the remaining reports in #26315. Fixes #26844 --- src/lib/components/chat/Chat.svelte | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index 56bd0660cc..85308451b7 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -634,7 +634,7 @@ } else if (type === 'chat:active') { if (!data?.active) { taskIds = null; - if (chatIdProp && !$temporaryChatEnabled && hasPendingAssistantLeaf()) { + if ($chatId && !$temporaryChatEnabled && hasPendingAssistantLeaf()) { await loadChat(); } } @@ -907,7 +907,8 @@ ); const handleSocketConnect = async () => { - if (!chatIdProp || $temporaryChatEnabled) { + // Gate on $chatId, not chatIdProp: chats started from the home page keep an empty chatIdProp + if (!$chatId || $temporaryChatEnabled) { return; } @@ -1590,7 +1591,8 @@ }; const loadChat = async () => { - chatId.set(chatIdProp); + // chatIdProp is empty for chats started from the home page (URL set via replaceState) + chatId.set(chatIdProp || $chatId); if ($temporaryChatEnabled) { temporaryChatEnabled.set(false);