Skip to content

Commit 274729a

Browse files
authored
fix: socket reconnect recovery never runs for chats started from the home page (open-webui#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 open-webui#26315. Fixes open-webui#26844
1 parent 65a5fad commit 274729a

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/lib/components/chat/Chat.svelte

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@
634634
} else if (type === 'chat:active') {
635635
if (!data?.active) {
636636
taskIds = null;
637-
if (chatIdProp && !$temporaryChatEnabled && hasPendingAssistantLeaf()) {
637+
if ($chatId && !$temporaryChatEnabled && hasPendingAssistantLeaf()) {
638638
await loadChat();
639639
}
640640
}
@@ -907,7 +907,8 @@
907907
);
908908
909909
const handleSocketConnect = async () => {
910-
if (!chatIdProp || $temporaryChatEnabled) {
910+
// Gate on $chatId, not chatIdProp: chats started from the home page keep an empty chatIdProp
911+
if (!$chatId || $temporaryChatEnabled) {
911912
return;
912913
}
913914
@@ -1590,7 +1591,8 @@
15901591
};
15911592
15921593
const loadChat = async () => {
1593-
chatId.set(chatIdProp);
1594+
// chatIdProp is empty for chats started from the home page (URL set via replaceState)
1595+
chatId.set(chatIdProp || $chatId);
15941596
15951597
if ($temporaryChatEnabled) {
15961598
temporaryChatEnabled.set(false);

0 commit comments

Comments
 (0)