remove completed runs from live flow

This commit is contained in:
2026-05-31 12:42:09 -04:00
parent 4d46c001bb
commit 139bf3b3fb
3 changed files with 15 additions and 15 deletions

View File

@@ -202,18 +202,15 @@ async function executePlanBatches(
failedTaskIds,
);
// Replace remaining batches with filtered ones
const currentIdx = plan.batches.indexOf(batch);
const remainingBatches = newPlan.batches.filter(
(b) => b.batchIndex > currentIdx,
);
// Keep processed batches (up to current batch), replace the rest
// with the fresh plan — its batchIndex restarts at 0, so filtering
// by batchIndex > currentIdx would incorrectly drop the next batch.
const processedCount = plan.batches.indexOf(batch) + 1;
plan.batches.length = processedCount;
plan.batches.push(...newPlan.batches);
// Update the plan's batches in-place
plan.batches.length = 0;
plan.batches.push(...remainingBatches);
// Skip empty batches
if (remainingBatches.length === 0) {
// Skip if nothing remaining
if (plan.batches.length === processedCount) {
break;
}
}