import { pauseShotQueue, setQueueJob } from '~/server/utils/shotQueue' export default defineEventHandler(async (event) => { const body = await readBody<{ jobId?: string; kind?: string }>(event).catch(() => ({})) const jobId = String(body?.jobId || '') const job = jobId ? getJob(jobId) : undefined if (job) { job.status = 'cancelled' emitJob(job, { type: 'status', message: 'Cancelling job...' }) removeExtendTemp(job.library?.extendTmpDir) if (job.library?.queueId) { job.library.stopAfterCurrent = true job.library.queueAutoRun = false await pauseShotQueue(job.library.ownerKey, job.library.queueId).catch(() => null) setQueueJob(job.library.queueId, null) } } if (jobId) deletePendingJob(jobId) const ok = await interruptComfy() if (job) { emitJob(job, { type: 'error', error: 'Job interrupted.', message: 'Job interrupted.' }) } return { ok } })