fix(mindspace): fail closed on invalid page data delivery

This commit is contained in:
john
2026-07-14 19:40:47 +08:00
parent 192548b0b9
commit 72fd88219c
6 changed files with 114 additions and 11 deletions
+6 -6
View File
@@ -54,6 +54,7 @@ import { buildAutoChatSkillPrefix } from '../../chat-skills.mjs';
import {
reconcileSessionEventRequestContext,
resolvePostAgentRunChatState,
shouldKeepStreamingAfterRunError,
shouldPromoteSessionIdToStreaming,
} from '../../chat-agent-run-gate.mjs';
import { mergeConversationSnapshot } from '../../chat-finish-sync.mjs';
@@ -233,11 +234,6 @@ function mergeMessagePages(older: Message[], current: Message[]): Message[] {
return merged;
}
function isAmbiguousReplySubmitError(err: unknown) {
if (!(err instanceof ApiError)) return true;
return err.status === 0 || err.status === 409 || err.status >= 500;
}
const SESSION_LIST_RETRY_ATTEMPTS = 3;
const SESSION_LIST_RETRY_DELAY_MS = 450;
@@ -1619,7 +1615,11 @@ export function useTKMindChat(
}
}
} catch (err) {
if (activeSessionId && isAmbiguousReplySubmitError(err)) {
if (
activeSessionId &&
err instanceof ApiError &&
shouldKeepStreamingAfterRunError(err.status)
) {
subscribeToSession(activeSessionId);
setChatState('streaming');
setError(null);