diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index 79284751e6..a4e2829f82 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -438,11 +438,14 @@ } else if (type === 'chat:completion') { chatCompletionEventHandler(data, message, event.chat_id); } else if (type === 'chat:tasks:cancel') { - taskIds = null; - const responseMessage = history.messages[history.currentId]; - // Set all response messages to done - for (const messageId of history.messages[responseMessage.parentId].childrenIds) { - history.messages[messageId].done = true; + if (event.message_id === history.currentId) { + taskIds = null; + // Set all response messages to done + for (const messageId of history.messages[message.parentId].childrenIds) { + history.messages[messageId].done = true; + } + } else { + message.done = true; } } else if (type === 'chat:message:delta' || type === 'message') { message.content += data.content;