Files
aigen/server/api/generate/[id].get.ts
T
TowstyandCursor a7a810a7b3 Let clips move between folders, save busy jobs, and fail dropped Comfy runs.
Held jobs restore the form after a 3-minute wait, hidden stills stay blurred in the picker, and reloading Comfy no longer leaves xaigen spinning.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-25 21:46:24 -05:00

24 lines
661 B
TypeScript

export default defineEventHandler(async (event) => {
const id = getRouterParam(event, 'id')
const live = id ? getJob(id) : undefined
if (live) return jobSnapshot(live)
if (id) {
const pending = readPendingJob(id)
if (pending) {
const done = await resolvePendingJob(pending).catch(() => null)
if (done) return done
return {
type: 'snapshot',
status: 'running',
message: 'Reconnecting to ComfyUI...',
progress: 90,
promptId: pending.promptId,
elapsedMs: Date.now() - pending.startedAt
}
}
}
throw createError({ statusCode: 404, statusMessage: 'Job not found' })
})