From 504870c4eca69ed2c9087f5fe774362e917f2260 Mon Sep 17 00:00:00 2001 From: Aleksander Grygier Date: Sun, 6 Sep 2026 00:19:23 +0200 Subject: [PATCH] ui : update active conversation fields in place updateCurrentNode, applyConversationUpdate, updateConversationTimestamp and the pin toggle replaced the whole activeConversation object, so its identity changed on every send, tool result and rename. ChatMessages tracks that identity to refresh sibling info, so each replacement triggered a full refetch of every message in the conversation. Write the changed fields instead, mirroring updateMessageAtIndex. Assisted-by: pi:zai-org/GLM-5.3 --- .../lib/stores/conversations/index.svelte.ts | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/tools/ui/src/lib/stores/conversations/index.svelte.ts b/tools/ui/src/lib/stores/conversations/index.svelte.ts index df5b1ecef3..caefe67901 100644 --- a/tools/ui/src/lib/stores/conversations/index.svelte.ts +++ b/tools/ui/src/lib/stores/conversations/index.svelte.ts @@ -88,7 +88,13 @@ class ConversationsStore implements ConversationsPreferencesHost { } if (this.activeConversation?.id === id) { - this.activeConversation = { ...this.activeConversation, ...updates }; + // field-wise, not object replacement: effects that track the active + // conversation identity would otherwise refire on every rename or pin + const target = this.activeConversation as unknown as Record; + + for (const [key, value] of Object.entries(updates)) { + if (target[key] !== value) target[key] = value; + } } } @@ -202,11 +208,8 @@ class ConversationsStore implements ConversationsPreferencesHost { const updates = await DatabaseService.bulkToggleConversationPins(convIds); const activeId = this.activeConversation?.id; - if (activeId && updates.has(activeId)) { - this.activeConversation = { - ...this.activeConversation!, - pinned: updates.get(activeId)! - }; + if (this.activeConversation && activeId && updates.has(activeId)) { + this.activeConversation.pinned = updates.get(activeId)!; } for (let i = 0; i < this.conversations.length; i++) { @@ -558,7 +561,7 @@ class ConversationsStore implements ConversationsPreferencesHost { const currentLeafNodeId = findLeafNode(allMessages, siblingId); await DatabaseService.updateCurrentNode(this.activeConversation.id, currentLeafNodeId); - this.activeConversation = { ...this.activeConversation, currNode: currentLeafNodeId }; + this.activeConversation.currNode = currentLeafNodeId; await this.refreshActiveMessages(); if (rootMessage && this.activeMessages.length > 0) { @@ -694,7 +697,7 @@ class ConversationsStore implements ConversationsPreferencesHost { } if (this.activeConversation?.id === targetId) { - this.activeConversation = { ...this.activeConversation, lastModified: now }; + this.activeConversation.lastModified = now; } DatabaseService.updateConversation(targetId, { lastModified: now }).catch((error) => @@ -710,7 +713,7 @@ class ConversationsStore implements ConversationsPreferencesHost { if (!this.activeConversation) return; await DatabaseService.updateCurrentNode(this.activeConversation.id, nodeId); - this.activeConversation = { ...this.activeConversation, currNode: nodeId }; + this.activeConversation.currNode = nodeId; } /**