Kick the studio dispatcher when the UI polls a stalled waiting queue.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-09-04 14:14:26 -05:00
co-authored by Cursor
parent 91855a0103
commit 41ba5e3aab
+7 -2
View File
@@ -1,5 +1,5 @@
import { listShotQueues, summarizeQueue } from '~/server/utils/shotQueue'
import { listStudioJobs, summarizeStudioJob } from '~/server/utils/studioQueue'
import { kickStudioQueue, listStudioJobs, summarizeStudioJob } from '~/server/utils/studioQueue'
export default defineEventHandler((event) => {
const { owner } = assertLibraryOwner(event)
@@ -54,10 +54,15 @@ export default defineEventHandler((event) => {
.filter(queue => !claimed.has(queue.id) && queue.status !== 'complete')
.map(summarizeQueue)
: []
const waitingCount = jobs.filter(job => job.status === 'waiting').length
// Nudge the dispatcher whenever the UI polls a stalled waiting queue.
if (waitingCount > 0 && !jobs.some(job => job.status === 'running')) {
void kickStudioQueue()
}
return {
jobs,
orphans,
waitingCount: jobs.filter(job => job.status === 'waiting').length,
waitingCount,
paused: jobs.some(job => job.pausedByUser === true)
|| orphans.some(queue => queue.stopAfterCurrent === true && queue.status !== 'running'),
willPause: jobs.some(job => (