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
+9
View File
@@ -3,6 +3,7 @@ import test from 'node:test';
import {
reconcileSessionEventRequestContext,
resolvePostAgentRunChatState,
shouldKeepStreamingAfterRunError,
shouldPromoteSessionIdToStreaming,
} from './chat-agent-run-gate.mjs';
@@ -47,6 +48,14 @@ test('completed run wins when the direct-chat snapshot is not ready', () => {
);
});
test('only ambiguous transport failures keep the chat streaming', () => {
assert.equal(shouldKeepStreamingAfterRunError(0), true);
assert.equal(shouldKeepStreamingAfterRunError(409), true);
assert.equal(shouldKeepStreamingAfterRunError(503), true);
assert.equal(shouldKeepStreamingAfterRunError(400), false);
assert.equal(shouldKeepStreamingAfterRunError(undefined), false);
});
test('shouldPromoteSessionIdToStreaming skips re-streaming after Finish', () => {
assert.equal(shouldPromoteSessionIdToStreaming('idle'), false);
assert.equal(shouldPromoteSessionIdToStreaming('waiting'), true);