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>
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
export default defineEventHandler(async (event) => {
|
|
const owner = libraryOwnerKey(event)
|
|
const live = listJobs()
|
|
.filter(job => job.library?.ownerKey === owner && (job.status === 'queued' || job.status === 'uploading' || job.status === 'running'))
|
|
.sort((a, b) => b.startedAt - a.startedAt)[0]
|
|
if (live) {
|
|
return {
|
|
jobId: live.id,
|
|
hideThumbnail: live.hideThumbnail === true,
|
|
folderLocked: live.library?.folderLocked === true,
|
|
...jobSnapshot(live)
|
|
}
|
|
}
|
|
|
|
const pending = listPendingJobs()
|
|
.filter(job => job.ownerKey === owner)
|
|
.sort((a, b) => b.startedAt - a.startedAt)[0]
|
|
if (pending) {
|
|
const resolved = await resolvePendingJob(pending).catch(() => null)
|
|
if (resolved) return resolved
|
|
return {
|
|
jobId: pending.jobId,
|
|
type: 'snapshot',
|
|
status: 'running',
|
|
message: 'Reconnecting to ComfyUI...',
|
|
progress: Math.max(8, Math.min(90, Math.round((Date.now() - pending.startedAt) / 1000))),
|
|
promptId: pending.promptId,
|
|
elapsedMs: Date.now() - pending.startedAt,
|
|
hideThumbnail: pending.hideThumbnail === true,
|
|
folderLocked: pending.folderLocked === true
|
|
}
|
|
}
|
|
|
|
return { jobId: null }
|
|
})
|