Fix shot auto-run: do not settle or honor stale paused mid-chain, and keep Run remaining from dying after one shot.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-09-05 19:52:29 -05:00
co-authored by Cursor
parent 8ebbc0fc6e
commit 4dccaac6d3
3 changed files with 33 additions and 8 deletions
+23 -4
View File
@@ -20,6 +20,7 @@ import {
isShotQueueCancelled,
lastCompletedIndex,
liveSegmentPrompt,
pendingSegmentCount,
prepareQueueBurst,
remainingFromQueue,
setQueueJob,
@@ -276,7 +277,10 @@ function chainShouldHold(job: Job) {
? getShotQueue(job.library.ownerKey, job.library.queueId)
: null
if (job.library.queueId && !queue) return true
if (queue?.stopAfterCurrent || queue?.status === 'paused') return true
if (queue?.stopAfterCurrent) return true
// A stale "paused" flag used to abort auto-run mid-batch after finishQueueBurst.
// Only honor paused when this live job is not explicitly auto-running.
if (queue?.status === 'paused' && job.library.queueAutoRun !== true) return true
return false
}
@@ -319,9 +323,12 @@ export async function continueQueuedExtensions(
const liveQueue = job.library.queueId
? getShotQueue(job.library.ownerKey, job.library.queueId)
: null
if (liveQueue?.stopAfterCurrent || liveQueue?.autoRun === false) {
if (liveQueue.stopAfterCurrent) job.library.stopAfterCurrent = true
if (liveQueue.autoRun === false) job.library.queueAutoRun = false
// User pause / cut-in only. Do not let a stale autoRun=false on disk cancel an
// in-flight "run remaining" / checkbox auto-run batch (options.autoRun).
if (liveQueue?.stopAfterCurrent) {
job.library.stopAfterCurrent = true
} else if (liveQueue?.autoRun === false && options.autoRun !== true) {
job.library.queueAutoRun = false
}
if (chainShouldHold(job)) {
job.library.stopAfterCurrent = true
@@ -494,12 +501,24 @@ export async function continueQueuedExtensions(
const paused = job.status !== 'error' && job.status !== 'cancelled'
const hold = job.library.stopAfterCurrent === true && paused
if (hold && job.status === 'running') job.status = 'complete'
// Keep autoRun on the shot queue when this burst was an explicit run-all and more
// shots remain — finishQueueBurst used to clear it and force one-click-per-shot.
const keepAuto = autoRun && !hold && job.status !== 'error' && job.status !== 'cancelled'
if (keepAuto && job.library) job.library.queueAutoRun = true
await finishQueueBurst(
job.library.ownerKey,
job.library.queueId,
hold || (paused && !job.library.queueAutoRun),
job.status === 'error' || job.status === 'cancelled' ? (job.error || 'Stopped') : undefined
).catch(() => null)
if (keepAuto) {
await updateShotQueue(job.library.ownerKey, job.library.queueId, (queue) => {
if (pendingSegmentCount(queue) > 0 && queue.status !== 'complete' && queue.status !== 'error') {
queue.autoRun = true
if (queue.status === 'paused') queue.status = 'idle'
}
}).catch(() => null)
}
setQueueJob(job.library.queueId, null)
}
}