diff --git a/src/renderer/src/hooks/useTopic.ts b/src/renderer/src/hooks/useTopic.ts index 02868a3a90..c6913bd7eb 100644 --- a/src/renderer/src/hooks/useTopic.ts +++ b/src/renderer/src/hooks/useTopic.ts @@ -121,7 +121,7 @@ export const autoRenameTopic = async (assistant: Assistant, topicId: string) => startTopicRenaming(topicId) const data = { ...topic, name: topicName } as Topic - _setActiveTopic(data) + topic.id === _activeTopic.id && _setActiveTopic(data) store.dispatch(updateTopic({ assistantId: assistant.id, topic: data })) } finally { finishTopicRenaming(topicId) @@ -138,7 +138,7 @@ export const autoRenameTopic = async (assistant: Assistant, topicId: string) => const summaryText = await fetchMessagesSummary({ messages: topic.messages, assistant }) if (summaryText) { const data = { ...topic, name: summaryText } - _setActiveTopic(data) + topic.id === _activeTopic.id && _setActiveTopic(data) store.dispatch(updateTopic({ assistantId: assistant.id, topic: data })) } } finally { diff --git a/src/renderer/src/pages/home/Tabs/TopicsTab.tsx b/src/renderer/src/pages/home/Tabs/TopicsTab.tsx index 04930a624f..6d370484fb 100644 --- a/src/renderer/src/pages/home/Tabs/TopicsTab.tsx +++ b/src/renderer/src/pages/home/Tabs/TopicsTab.tsx @@ -197,7 +197,6 @@ const Topics: FC = ({ assistant: _assistant, activeTopic, setActiveTopic if (summaryText) { const updatedTopic = { ...topic, name: summaryText, isNameManuallyEdited: false } updateTopic(updatedTopic) - topic.id === activeTopic.id && setActiveTopic(updatedTopic) } else { window.message?.error(t('message.error.fetchTopicName')) } @@ -221,7 +220,6 @@ const Topics: FC = ({ assistant: _assistant, activeTopic, setActiveTopic if (name && topic?.name !== name) { const updatedTopic = { ...topic, name, isNameManuallyEdited: true } updateTopic(updatedTopic) - topic.id === activeTopic.id && setActiveTopic(updatedTopic) } } }, diff --git a/src/renderer/src/services/ApiService.ts b/src/renderer/src/services/ApiService.ts index d9becd6952..02763079d4 100644 --- a/src/renderer/src/services/ApiService.ts +++ b/src/renderer/src/services/ApiService.ts @@ -416,7 +416,10 @@ export async function fetchTranslate({ content, assistant, onResponse }: FetchTr export async function fetchMessagesSummary({ messages, assistant }: { messages: Message[]; assistant: Assistant }) { const prompt = (getStoreSetting('topicNamingPrompt') as string) || i18n.t('prompts.title') const model = getTopNamingModel() || assistant.model || getDefaultModel() - const userMessages = takeRight(messages, 5) + const userMessages = takeRight(messages, 5).map((message) => ({ + ...message, + content: getMainTextContent(message) + })) const provider = getProviderByModel(model)