From b782561d084d0f5f5d883f58e7cafb9cbfc51775 Mon Sep 17 00:00:00 2001 From: john Date: Sat, 4 Jul 2026 14:25:19 +0800 Subject: [PATCH] fix: skip goosed aux calls for direct chat sessions --- src/hooks/useTKMindChat.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/hooks/useTKMindChat.ts b/src/hooks/useTKMindChat.ts index ef8e906..3570384 100644 --- a/src/hooks/useTKMindChat.ts +++ b/src/hooks/useTKMindChat.ts @@ -74,8 +74,13 @@ const INSUFFICIENT_BALANCE_NOTICE = '余额不足,请充值后继续使用'; const REPLY_RECOVERY_SYNC_DELAYS_MS = [1500, 5000, 12000]; const FINISH_SYNC_RETRY_DELAYS_MS = [500, 1500, 3000]; const ACTIVE_REQUEST_MISSING_GRACE_MS = 2500; +const DIRECT_CHAT_SESSION_PREFIX = 'h5direct_'; export { INSUFFICIENT_BALANCE_NOTICE }; +function isDirectChatSessionId(sessionId?: string | null) { + return typeof sessionId === 'string' && sessionId.startsWith(DIRECT_CHAT_SESSION_PREFIX); +} + async function waitForAgentRun(runId: string): Promise { return await new Promise((resolve, reject) => { const unsubscribe = subscribeAgentRunEvents( @@ -374,6 +379,7 @@ export function useTKMindChat( }, [user?.id, activeNotification?.id]); const loadProjectMemory = useCallback(async (sessionId: string, force: boolean) => { + if (isDirectChatSessionId(sessionId)) return null; if (!canUseProjectMemory) return null; setMemoryLoading(true); try { @@ -430,6 +436,7 @@ export function useTKMindChat( } : sessionRef.current; if (!currentSession) return false; + if (isDirectChatSessionId(currentSession.id)) return false; if (rememberInFlightRef.current) return false; const contextText = @@ -747,7 +754,7 @@ export function useTKMindChat( setChatState('idle'); setPendingTool(null); activeRequestId.current = null; - if (sessionId.startsWith('h5direct_')) { + if (isDirectChatSessionId(sessionId)) { unsubscribeRef.current?.(); unsubscribeRef.current = null; } @@ -931,6 +938,7 @@ export function useTKMindChat( ); const ensureProvider = useCallback(async (sessionId: string) => { + if (isDirectChatSessionId(sessionId)) return; const provider = appConfig.provider || (await readConfig('TKMIND_PROVIDER')); const model = appConfig.model || (await readConfig('TKMIND_MODEL')); if (provider && model) { @@ -1301,6 +1309,7 @@ export function useTKMindChat( const refreshProjectMemory = useCallback(async () => { if (!session || chatState === 'streaming' || chatState === 'waiting') return; + if (isDirectChatSessionId(session.id)) return; await loadProjectMemory(session.id, true); }, [chatState, loadProjectMemory, session]);