mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-10 23:59:45 +08:00
fix(TopicRenaming): captured activeTopic.id is outdated and causes accidental topic changing after renaming (#7157)
* fix(TopicRenaming): captured activeTopic.id is outdated and causes accidental topic changing after renaming * fix: prevent topic changing on auto renaming * fix: filter out main text on summarizing
This commit is contained in:
parent
faf14ff10b
commit
c7fd1ac373
@ -121,7 +121,7 @@ export const autoRenameTopic = async (assistant: Assistant, topicId: string) =>
|
|||||||
startTopicRenaming(topicId)
|
startTopicRenaming(topicId)
|
||||||
|
|
||||||
const data = { ...topic, name: topicName } as Topic
|
const data = { ...topic, name: topicName } as Topic
|
||||||
_setActiveTopic(data)
|
topic.id === _activeTopic.id && _setActiveTopic(data)
|
||||||
store.dispatch(updateTopic({ assistantId: assistant.id, topic: data }))
|
store.dispatch(updateTopic({ assistantId: assistant.id, topic: data }))
|
||||||
} finally {
|
} finally {
|
||||||
finishTopicRenaming(topicId)
|
finishTopicRenaming(topicId)
|
||||||
@ -138,7 +138,7 @@ export const autoRenameTopic = async (assistant: Assistant, topicId: string) =>
|
|||||||
const summaryText = await fetchMessagesSummary({ messages: topic.messages, assistant })
|
const summaryText = await fetchMessagesSummary({ messages: topic.messages, assistant })
|
||||||
if (summaryText) {
|
if (summaryText) {
|
||||||
const data = { ...topic, name: summaryText }
|
const data = { ...topic, name: summaryText }
|
||||||
_setActiveTopic(data)
|
topic.id === _activeTopic.id && _setActiveTopic(data)
|
||||||
store.dispatch(updateTopic({ assistantId: assistant.id, topic: data }))
|
store.dispatch(updateTopic({ assistantId: assistant.id, topic: data }))
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@ -197,7 +197,6 @@ const Topics: FC<Props> = ({ assistant: _assistant, activeTopic, setActiveTopic
|
|||||||
if (summaryText) {
|
if (summaryText) {
|
||||||
const updatedTopic = { ...topic, name: summaryText, isNameManuallyEdited: false }
|
const updatedTopic = { ...topic, name: summaryText, isNameManuallyEdited: false }
|
||||||
updateTopic(updatedTopic)
|
updateTopic(updatedTopic)
|
||||||
topic.id === activeTopic.id && setActiveTopic(updatedTopic)
|
|
||||||
} else {
|
} else {
|
||||||
window.message?.error(t('message.error.fetchTopicName'))
|
window.message?.error(t('message.error.fetchTopicName'))
|
||||||
}
|
}
|
||||||
@ -221,7 +220,6 @@ const Topics: FC<Props> = ({ assistant: _assistant, activeTopic, setActiveTopic
|
|||||||
if (name && topic?.name !== name) {
|
if (name && topic?.name !== name) {
|
||||||
const updatedTopic = { ...topic, name, isNameManuallyEdited: true }
|
const updatedTopic = { ...topic, name, isNameManuallyEdited: true }
|
||||||
updateTopic(updatedTopic)
|
updateTopic(updatedTopic)
|
||||||
topic.id === activeTopic.id && setActiveTopic(updatedTopic)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -416,7 +416,10 @@ export async function fetchTranslate({ content, assistant, onResponse }: FetchTr
|
|||||||
export async function fetchMessagesSummary({ messages, assistant }: { messages: Message[]; assistant: Assistant }) {
|
export async function fetchMessagesSummary({ messages, assistant }: { messages: Message[]; assistant: Assistant }) {
|
||||||
const prompt = (getStoreSetting('topicNamingPrompt') as string) || i18n.t('prompts.title')
|
const prompt = (getStoreSetting('topicNamingPrompt') as string) || i18n.t('prompts.title')
|
||||||
const model = getTopNamingModel() || assistant.model || getDefaultModel()
|
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)
|
const provider = getProviderByModel(model)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user