From 03907f9a8adde951a855e665bc61e6fbc265a42a Mon Sep 17 00:00:00 2001 From: Danny Liu Date: Mon, 4 Mar 2024 21:23:41 -0800 Subject: [PATCH] check if deleted message response has sibling responses for multi model chats --- src/lib/components/chat/Messages.svelte | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/components/chat/Messages.svelte b/src/lib/components/chat/Messages.svelte index 3f1ee28b..2ce107bb 100644 --- a/src/lib/components/chat/Messages.svelte +++ b/src/lib/components/chat/Messages.svelte @@ -228,10 +228,12 @@ const messageParentId = messageToDelete.parentId; const messageChildrenIds = messageToDelete.childrenIds ?? []; + const hasSibling = messageChildrenIds.some(childId => history.messages[childId]?.childrenIds?.length > 0); + messageChildrenIds.forEach((childId) => { const child = history.messages[childId]; if (child && child.childrenIds) { - if (child.childrenIds.length == 0) { // if last prompt/response pair + if (child.childrenIds.length === 0 && !hasSibling) { // if last prompt/response pair history.messages[messageParentId].childrenIds = [] history.currentId = messageParentId; }