Fix generation progress getting stuck at 1% after Comfy finishes.

Poll Comfy history and the job snapshot so the browser still gets the video when the live stream is buffered or the websocket misses completion.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-08-25 18:23:23 -05:00
co-authored by Cursor
parent ca51fddea3
commit c4e6af9f77
8 changed files with 326 additions and 182 deletions
+20
View File
@@ -42,6 +42,7 @@ export interface Job {
thumb?: Buffer
}
error?: string
socketReady?: boolean
events: JobEvent[]
listeners: Set<(event: JobEvent) => void>
}
@@ -74,6 +75,25 @@ export function getJob(id: string) {
return jobs.get(id)
}
export function jobSnapshot(job: Job) {
return {
type: 'snapshot' as const,
status: job.status,
message: job.message,
progress: job.progress,
step: job.step,
maxStep: job.maxStep,
promptId: job.promptId,
elapsedMs: Date.now() - job.startedAt,
filename: job.video?.filename,
subfolder: job.video?.subfolder,
mediaType: job.video?.type,
clipId: job.clipId,
hideThumbnail: job.hideThumbnail,
error: job.error
}
}
export function emitJob(job: Job, event: JobEvent) {
if (event.message) job.message = event.message
if (typeof event.progress === 'number') job.progress = event.progress