Keep remaining multi-shot clips on a Queue page so prompts can be edited between shots, with process-next or overnight run-all.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
import { deleteShotQueue } from '~/server/utils/shotQueue'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const { owner } = assertLibraryOwner(event)
|
||||
const id = String(getRouterParam(event, 'id') || '')
|
||||
await deleteShotQueue(owner, id)
|
||||
return { ok: true }
|
||||
})
|
||||
@@ -0,0 +1,9 @@
|
||||
import { getShotQueue, summarizeQueue } from '~/server/utils/shotQueue'
|
||||
|
||||
export default defineEventHandler((event) => {
|
||||
const { owner } = assertLibraryOwner(event)
|
||||
const id = String(getRouterParam(event, 'id') || '')
|
||||
const queue = getShotQueue(owner, id)
|
||||
if (!queue) throw createError({ statusCode: 404, statusMessage: 'Queue not found' })
|
||||
return summarizeQueue(queue)
|
||||
})
|
||||
@@ -0,0 +1,24 @@
|
||||
import { getShotQueue, patchShotQueueSegments, updateShotQueue, summarizeQueue } from '~/server/utils/shotQueue'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const { owner } = assertLibraryOwner(event)
|
||||
const id = String(getRouterParam(event, 'id') || '')
|
||||
const body = await readBody<{
|
||||
name?: string
|
||||
autoRun?: boolean
|
||||
segments?: Array<{ index: number; prompt?: string; duration?: number }>
|
||||
}>().catch(() => ({}))
|
||||
|
||||
if (Array.isArray(body?.segments) && body.segments.length) {
|
||||
await patchShotQueueSegments(owner, id, body.segments)
|
||||
}
|
||||
if (typeof body?.name === 'string' || typeof body?.autoRun === 'boolean') {
|
||||
await updateShotQueue(owner, id, (queue) => {
|
||||
if (typeof body.name === 'string') queue.name = body.name.trim().slice(0, 80) || queue.name
|
||||
if (typeof body.autoRun === 'boolean' && queue.status !== 'running') queue.autoRun = body.autoRun
|
||||
})
|
||||
}
|
||||
const queue = getShotQueue(owner, id)
|
||||
if (!queue) throw createError({ statusCode: 404, statusMessage: 'Queue not found' })
|
||||
return summarizeQueue(queue)
|
||||
})
|
||||
@@ -0,0 +1,10 @@
|
||||
import { pauseShotQueue, summarizeQueue, getShotQueue } from '~/server/utils/shotQueue'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const { owner } = assertLibraryOwner(event)
|
||||
const id = String(getRouterParam(event, 'id') || '')
|
||||
await pauseShotQueue(owner, id)
|
||||
const queue = getShotQueue(owner, id)
|
||||
if (!queue) throw createError({ statusCode: 404, statusMessage: 'Queue not found' })
|
||||
return summarizeQueue(queue)
|
||||
})
|
||||
@@ -0,0 +1,10 @@
|
||||
import { startQueueBurst } from '~/server/utils/videoChain'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const { owner } = assertLibraryOwner(event)
|
||||
const id = String(getRouterParam(event, 'id') || '')
|
||||
const body = await readBody<{ count?: number | 'all' }>().catch(() => ({}))
|
||||
const raw = body?.count
|
||||
const count = raw === 'all' || raw === 'remaining' ? 'all' as const : Math.max(1, Math.min(50, Number(raw) || 1))
|
||||
return startQueueBurst(owner, id, count)
|
||||
})
|
||||
@@ -0,0 +1,10 @@
|
||||
import { listShotQueues, summarizeQueue } from '~/server/utils/shotQueue'
|
||||
|
||||
export default defineEventHandler((event) => {
|
||||
const { owner } = assertLibraryOwner(event)
|
||||
const queues = listShotQueues(owner).map(summarizeQueue)
|
||||
const pendingCount = queues.reduce((sum, queue) => (
|
||||
queue.status === 'complete' ? sum : sum + queue.pendingCount
|
||||
), 0)
|
||||
return { queues, pendingCount }
|
||||
})
|
||||
Reference in New Issue
Block a user