From 22379ded1aebf0537e1ee3f00a20809d47646bf6 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sun, 30 Aug 2026 12:22:32 -0400 Subject: [PATCH] refac --- src/lib/components/chat/Chat.svelte | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index a58f53d3ff..741c78632b 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -1219,7 +1219,11 @@ } else if (type === 'chat:active') { if (!data?.active) { taskIds = null; - if ($chatId && !$temporaryChatEnabled && hasPendingAssistantLeaf()) { + if ( + $chatId && + !$temporaryChatEnabled && + hasPendingAssistantLeaf(event?.message_id ?? null) + ) { await loadChat(); } if ($chatId && !$temporaryChatEnabled) { @@ -1499,9 +1503,9 @@ } catch {} }; - const hasPendingAssistantLeaf = () => - Object.values(history.messages).some( - (message) => + const hasPendingAssistantLeaf = (messageId: string | null = null) => + (messageId ? [history.messages[messageId]] : Object.values(history.messages)).some( + (message: any) => message?.role === 'assistant' && !message.done && (message.childrenIds?.length ?? 0) === 0 );