Skip to content

Commit 84c8e30

Browse files
authored
Fix missing messages on sibling navigation (#16408)
* fix: resolve message disappearing issue when navigating between regenerated siblings by using current leaf nodes instead of cached sibling IDs * chore: update webui build output * chore: update webui build output
1 parent 2aaf0a2 commit 84c8e30

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

tools/server/public/index.html.gz

2 Bytes
Binary file not shown.

tools/server/webui/src/lib/stores/chat.svelte.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -860,15 +860,18 @@ class ChatStore {
860860
this.currentResponse = '';
861861

862862
try {
863-
const assistantMessage = await this.createAssistantMessage();
863+
const parentMessageId =
864+
this.activeMessages.length > 0
865+
? this.activeMessages[this.activeMessages.length - 1].id
866+
: null;
867+
868+
const assistantMessage = await this.createAssistantMessage(parentMessageId);
864869

865870
if (!assistantMessage) {
866871
throw new Error('Failed to create assistant message');
867872
}
868873

869874
this.activeMessages.push(assistantMessage);
870-
await DatabaseStore.updateCurrentNode(this.activeConversation.id, assistantMessage.id);
871-
this.activeConversation.currNode = assistantMessage.id;
872875

873876
const conversationContext = this.activeMessages.slice(0, -1);
874877

@@ -1124,8 +1127,10 @@ class ChatStore {
11241127
(m) => m.role === 'user' && m.parent === rootMessage?.id
11251128
);
11261129

1127-
await DatabaseStore.updateCurrentNode(this.activeConversation.id, siblingId);
1128-
this.activeConversation.currNode = siblingId;
1130+
const currentLeafNodeId = findLeafNode(allMessages, siblingId);
1131+
1132+
await DatabaseStore.updateCurrentNode(this.activeConversation.id, currentLeafNodeId);
1133+
this.activeConversation.currNode = currentLeafNodeId;
11291134
await this.refreshActiveMessages();
11301135

11311136
// Only show title dialog if we're navigating between different first user message siblings

0 commit comments

Comments
 (0)