fix: skip goosed aux calls for direct chat sessions

This commit is contained in:
john
2026-07-04 14:25:19 +08:00
parent b5a88d9746
commit b782561d08
+10 -1
View File
@@ -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<AgentRun> {
return await new Promise<AgentRun>((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]);