hotfix: error on deleting assistant (#8190)

fix: error on deleting assistant
This commit is contained in:
one
2025-07-16 14:16:08 +08:00
committed by GitHub
parent 27c39415c2
commit df218ee6c8
2 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ export function useActiveTopic(assistantId: string, topic?: Topic) {
useEffect(() => {
// activeTopic not in assistant.topics
if (assistant && !find(assistant.topics, { id: activeTopic?.id })) {
if (assistant && assistant.topics.length > 0 && !find(assistant.topics, { id: activeTopic?.id })) {
setActiveTopic(assistant.topics[0])
}
}, [activeTopic?.id, assistant])
+2 -1
View File
@@ -29,6 +29,7 @@ const HomePage: FC = () => {
const setActiveAssistant = useCallback(
(newAssistant: Assistant) => {
if (newAssistant.id === activeAssistant.id) return
startTransition(() => {
_setActiveAssistant(newAssistant)
// 同步更新 active topic,避免不必要的重新渲染
@@ -36,7 +37,7 @@ const HomePage: FC = () => {
_setActiveTopic((prev) => (newTopic?.id === prev.id ? prev : newTopic))
})
},
[_setActiveTopic]
[_setActiveTopic, activeAssistant]
)
const setActiveTopic = useCallback(