diff --git a/apps/ai-game-creator-shell/tests/appSurface/chat-composer.suite.ts b/apps/ai-game-creator-shell/tests/appSurface/chat-composer.suite.ts index 132940ace..3e6545351 100644 --- a/apps/ai-game-creator-shell/tests/appSurface/chat-composer.suite.ts +++ b/apps/ai-game-creator-shell/tests/appSurface/chat-composer.suite.ts @@ -244,11 +244,14 @@ function hostQueue( ) { const queued: Array<{ clientTurnId: string; userItem: unknown }> = []; let running = alreadyRunning; + /** 正在跑那一轮的回合身份:与宿主一致,`alreadyDispatched` 只认它(不是"随便哪一轮在跑")。 */ + let dispatchedClientTurnId: string | null = null; const dispatchHeadIfIdle = () => { if (running) return; const head = queued.shift(); if (!head) return; running = true; + dispatchedClientTurnId = head.clientTurnId; harness.emitDirectThreadEvents( { type: 'queue.removed', @@ -283,7 +286,11 @@ function hostQueue( const index = queued.findIndex( (item) => item.clientTurnId === clientTurnId, ); - if (index < 0) return running ? 'alreadyDispatched' : 'notFound'; + if (index < 0) { + return dispatchedClientTurnId === clientTurnId + ? 'alreadyDispatched' + : 'notFound'; + } queued.splice(index, 1); harness.emitDirectThreadEvents({ type: 'queue.removed', @@ -296,6 +303,7 @@ function hostQueue( /** 回合收尾:宿主在占用释放那一刻踢一脚,队首接上。 */ complete(status = 'completed') { running = false; + dispatchedClientTurnId = null; harness.emitDirectThreadEvents({ type: 'turn.completed', status, at: 4 }); dispatchHeadIfIdle(); },