fix: guard run completion boundary

This commit is contained in:
ZacharyZhang-NY committed 2026-04-23 20:34:31 -04:00
1 parent 245586a9aa
commit d21edb244f
6 files changed
+268 -8

No files matched your search

+9 -2
View File
@@ -90,11 +90,14 @@ async function startRun(job: RunJob) {
await runner.run(job);
} finally {
cancelledRuns.delete(job.runId);
active.delete(job.runId);
tickQueue();
}
}
function acknowledgeRunCompletion(runId: string) {
const released = active.delete(runId);
if (released) tickQueue();
}
function cancelRun(runId: string) {
const queuedIndex = queue.findIndex((entry) => entry.runId === runId);
if (queuedIndex >= 0) {
@@ -129,6 +132,10 @@ parentPort.on("message", (event) => {
cancelRun(message.runId);
return;
}
if (message.type === "run-completion-ack") {
acknowledgeRunCompletion(message.runId);
return;
}
if (message.type === "steer-run") {
const accepted = runner.steer(message.runId, message.message);
post({