08feae8bef
落地 H5 Session 架构 Patch 1–5(Broker 收口、Router decision、SSE taxonomy、goosed 边界检查), 并新增可选 MEMIND_RUN_STREAM_REPLAY run 事件回放与 H5 假交付 guard;修复 Finish 先于 agent-run gate 导致 UI 永久 loading 的竞态,接入 verify:h5-session-patches 回归脚本。 Co-authored-by: Cursor <cursoragent@cursor.com>
32 lines
1.2 KiB
JavaScript
32 lines
1.2 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import {
|
|
resolvePostAgentRunChatState,
|
|
shouldPromoteSessionIdToStreaming,
|
|
} from './chat-agent-run-gate.mjs';
|
|
|
|
test('resolvePostAgentRunChatState keeps idle when Finish beat agent-run gate', () => {
|
|
assert.equal(
|
|
resolvePostAgentRunChatState({ chatState: 'idle', finishedViaPortalDirectChat: false }),
|
|
'idle',
|
|
);
|
|
});
|
|
|
|
test('resolvePostAgentRunChatState returns streaming while still waiting for session Finish', () => {
|
|
assert.equal(resolvePostAgentRunChatState({ chatState: 'waiting' }), 'streaming');
|
|
assert.equal(resolvePostAgentRunChatState({ chatState: 'streaming' }), 'streaming');
|
|
});
|
|
|
|
test('resolvePostAgentRunChatState prefers portal direct chat completion', () => {
|
|
assert.equal(
|
|
resolvePostAgentRunChatState({ chatState: 'streaming', finishedViaPortalDirectChat: true }),
|
|
'idle',
|
|
);
|
|
});
|
|
|
|
test('shouldPromoteSessionIdToStreaming skips re-streaming after Finish', () => {
|
|
assert.equal(shouldPromoteSessionIdToStreaming('idle'), false);
|
|
assert.equal(shouldPromoteSessionIdToStreaming('waiting'), true);
|
|
assert.equal(shouldPromoteSessionIdToStreaming('streaming'), true);
|
|
});
|