fix: forked topic and rename modal retaining old name after rename (#10528)

fix: sync active topic metadata after rename
This commit is contained in:
Murphy 2025-10-07 00:02:48 +08:00 committed by GitHub
parent 8bec7640fa
commit d2d5064eed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -48,6 +48,17 @@ export function useActiveTopic(assistantId: string, topic?: Topic) {
}
}, [activeTopic?.id, assistant])
useEffect(() => {
if (!assistant?.topics?.length || !activeTopic) {
return
}
const latestTopic = assistant.topics.find((item) => item.id === activeTopic.id)
if (latestTopic && latestTopic !== activeTopic) {
setActiveTopic(latestTopic)
}
}, [assistant?.topics, activeTopic])
return { activeTopic, setActiveTopic }
}