diff --git a/apps/ai-game-creator-shell/tests/appSurface/harness.ts b/apps/ai-game-creator-shell/tests/appSurface/harness.ts index d0e923feb..dc18ea287 100644 --- a/apps/ai-game-creator-shell/tests/appSurface/harness.ts +++ b/apps/ai-game-creator-shell/tests/appSurface/harness.ts @@ -754,6 +754,9 @@ function createProjectSupervisorRuntimeHarness({ let pendingDirectThreadEvents: Array> = []; let directThreadHistoryItems: Array> = []; let directThreadLastCompletedItemId: string | null = null; + // 运行态事件里只有一个"最新回合是否在跑"的布尔:与 Thread Manager 只保留一条生命周期 + // 锚点一致,重复 `turn.started` 在生产里不会出现。 + let directThreadTurnRunning = false; const conversationRecord = ( role: 'user' | 'assistant', @@ -1184,6 +1187,10 @@ function createProjectSupervisorRuntimeHarness({ const emitDirectThreadEvents = ( ...events: Array> ) => { + for (const event of events) { + if (event.type === 'turn.started') directThreadTurnRunning = true; + if (event.type === 'turn.completed') directThreadTurnRunning = false; + } pendingDirectThreadEvents.push(...events); if (directThreadSubscriptionId) { directThreadNotifyHandler?.({ @@ -1303,7 +1310,10 @@ function createProjectSupervisorRuntimeHarness({ at?: number; status?: string; }) { - const events: Array> = [{ type: 'turn.started' }]; + // 生命周期锚点只有一份:回合已经在跑时不再补 `turn.started`。 + const events: Array> = directThreadTurnRunning + ? [] + : [{ type: 'turn.started' }]; if (prompt.trim()) { events.push({ type: 'item.completed',