refactor: add isNameManuallyEdited flag to topic management
- Introduced isNameManuallyEdited property to the Topic type for better tracking of manual edits. - Updated topic update logic to set isNameManuallyEdited based on user actions in the TopicsTab. - Enhanced autoRenameTopic function to respect manual edits and prevent automatic renaming when applicable.
This commit is contained in:
parent
3fdbb5a9da
commit
b3fbe35efe
@ -61,6 +61,10 @@ export const autoRenameTopic = async (assistant: Assistant, topicId: string) =>
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (topic.isNameManuallyEdited) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (!enableTopicNaming) {
|
if (!enableTopicNaming) {
|
||||||
const topicName = topic.messages[0]?.content.substring(0, 50)
|
const topicName = topic.messages[0]?.content.substring(0, 50)
|
||||||
if (topicName) {
|
if (topicName) {
|
||||||
|
|||||||
@ -138,7 +138,7 @@ const Topics: FC<Props> = ({ assistant: _assistant, activeTopic, setActiveTopic
|
|||||||
if (messages.length >= 2) {
|
if (messages.length >= 2) {
|
||||||
const summaryText = await fetchMessagesSummary({ messages, assistant })
|
const summaryText = await fetchMessagesSummary({ messages, assistant })
|
||||||
if (summaryText) {
|
if (summaryText) {
|
||||||
updateTopic({ ...topic, name: summaryText })
|
updateTopic({ ...topic, name: summaryText, isNameManuallyEdited: false })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ const Topics: FC<Props> = ({ assistant: _assistant, activeTopic, setActiveTopic
|
|||||||
defaultValue: topic?.name || ''
|
defaultValue: topic?.name || ''
|
||||||
})
|
})
|
||||||
if (name && topic?.name !== name) {
|
if (name && topic?.name !== name) {
|
||||||
updateTopic({ ...topic, name })
|
updateTopic({ ...topic, name, isNameManuallyEdited: true })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -47,7 +47,8 @@ export function getDefaultTopic(assistantId: string): Topic {
|
|||||||
createdAt: new Date().toISOString(),
|
createdAt: new Date().toISOString(),
|
||||||
updatedAt: new Date().toISOString(),
|
updatedAt: new Date().toISOString(),
|
||||||
name: i18n.t('chat.default.topic.name'),
|
name: i18n.t('chat.default.topic.name'),
|
||||||
messages: []
|
messages: [],
|
||||||
|
isNameManuallyEdited: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -96,6 +96,7 @@ export type Topic = {
|
|||||||
messages: Message[]
|
messages: Message[]
|
||||||
pinned?: boolean
|
pinned?: boolean
|
||||||
prompt?: string
|
prompt?: string
|
||||||
|
isNameManuallyEdited?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type User = {
|
export type User = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user