AGC 编辑器分支产物归位(M3,待 Windows 验收) #524

Merged
suzmii merged 187 commits from feat/agc-bundled-resources-m3 into fix/agc-rust-staging-idempotency 2026-09-30 17:47:42 +08:00
Showing only changes of commit 3e8954548a - Show all commits
@@ -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();
},