From 3853eb4c06f30397439f5cb11bc7a3193bc96c6e Mon Sep 17 00:00:00 2001 From: Murphy <69335326+MurphyLo@users.noreply.github.com> Date: Thu, 5 Jun 2025 09:44:11 +0800 Subject: [PATCH] fix: sync active topic after rename (#6804) Co-authored-by: Chen Tao <70054568+eeee0717@users.noreply.github.com> --- src/renderer/src/pages/home/Tabs/TopicsTab.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/pages/home/Tabs/TopicsTab.tsx b/src/renderer/src/pages/home/Tabs/TopicsTab.tsx index 6f5b95484d..490cfb3c29 100644 --- a/src/renderer/src/pages/home/Tabs/TopicsTab.tsx +++ b/src/renderer/src/pages/home/Tabs/TopicsTab.tsx @@ -174,7 +174,9 @@ const Topics: FC = ({ assistant: _assistant, activeTopic, setActiveTopic if (messages.length >= 2) { const summaryText = await fetchMessagesSummary({ messages, assistant }) if (summaryText) { - updateTopic({ ...topic, name: summaryText, isNameManuallyEdited: false }) + const updatedTopic = { ...topic, name: summaryText, isNameManuallyEdited: false } + updateTopic(updatedTopic) + topic.id === activeTopic.id && setActiveTopic(updatedTopic) } else { window.message?.error(t('message.error.fetchTopicName')) } @@ -192,7 +194,9 @@ const Topics: FC = ({ assistant: _assistant, activeTopic, setActiveTopic defaultValue: topic?.name || '' }) if (name && topic?.name !== name) { - updateTopic({ ...topic, name, isNameManuallyEdited: true }) + const updatedTopic = { ...topic, name, isNameManuallyEdited: true } + updateTopic(updatedTopic) + topic.id === activeTopic.id && setActiveTopic(updatedTopic) } } },