feat: add effect to clear blocks and start new chat when timeline view changes

This commit is contained in:
DIYgod 2025-10-18 10:10:41 +08:00
parent 4a46d457e1
commit 623963951b
No known key found for this signature in database
1 changed files with 16 additions and 0 deletions

View File

@ -107,6 +107,22 @@ export const useAutoTimelineSummaryShortcut = () => {
return keyParts.join("|")
}, [isAllTimeline, timelineId, normalizedFeedId])
const previousIsAllTimelineRef = useRef(isAllTimeline)
useEffect(() => {
const wasAllTimeline = previousIsAllTimelineRef.current
if (
wasAllTimeline &&
!isAllTimeline &&
currentChatId &&
currentChatId.startsWith(AI_CHAT_SPECIAL_ID_PREFIX.TIMELINE_SUMMARY)
) {
blockActions.clearBlocks({ keepSpecialTypes: true })
chatActions.newChat()
}
previousIsAllTimelineRef.current = isAllTimeline
}, [blockActions, chatActions, currentChatId, isAllTimeline])
const contextBlocks = useMemo<AIChatContextBlock[]>(() => {
if (!isAllTimeline) return []