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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user