Reattach Comfy watchers after refresh so pending jobs finish and save.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-08-27 08:09:20 -05:00
co-authored by Cursor
parent 159c84be75
commit 1466762af4
8 changed files with 137 additions and 30 deletions
+2 -8
View File
@@ -8,14 +8,8 @@ export default defineEventHandler(async (event) => {
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
}
const job = ensurePendingWatch(pending)
return jobSnapshot(job)
}
}
+5 -1
View File
@@ -1,6 +1,10 @@
export default defineEventHandler(async (event) => {
const id = getRouterParam(event, 'id')
const job = id ? getJob(id) : undefined
let job = id ? getJob(id) : undefined
if (!job && id) {
const pending = readPendingJob(id)
if (pending) job = ensurePendingWatch(pending)
}
if (!job) {
throw createError({ statusCode: 404, statusMessage: 'Job not found' })
}
+3 -7
View File
@@ -35,17 +35,13 @@ export default defineEventHandler(async (event) => {
...resolved
}
} else {
const job = ensurePendingWatch(pending)
video = {
jobId: pending.jobId,
kind: 'video',
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
folderLocked: pending.folderLocked === true,
...jobSnapshot(job)
}
}
}
+1 -11
View File
@@ -9,17 +9,7 @@ export default defineEventHandler(async (event) => {
if (pending) {
const done = await resolvePendingJob(pending)
if (done) return done
return {
type: 'snapshot',
status: 'running',
jobId,
message: 'Reconnecting to ComfyUI...',
progress: 90,
promptId: pending.promptId,
elapsedMs: Date.now() - pending.startedAt,
hideThumbnail: pending.hideThumbnail,
folderLocked: pending.folderLocked
}
return jobSnapshot(ensurePendingWatch(pending))
}
throw createError({ statusCode: 404, statusMessage: 'Job not found' })
}