Drop the unused Klein branch from image-edit prompts and show the real Comfy error.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -204,16 +204,31 @@ export async function downloadEditedImage(image: { filename: string; subfolder:
|
||||
}
|
||||
|
||||
function historyError(history: Record<string, unknown> | null, promptId: string) {
|
||||
const entry = history?.[promptId] as { status?: { status_str?: string; completed?: boolean } } | undefined
|
||||
const entry = history?.[promptId] as {
|
||||
status?: {
|
||||
status_str?: string
|
||||
completed?: boolean
|
||||
messages?: Array<[string, Record<string, unknown>]>
|
||||
}
|
||||
} | undefined
|
||||
const status = entry?.status?.status_str
|
||||
const fromMessages = formatExecutionError(entry?.status?.messages?.find(([type]) => type === 'execution_error')?.[1])
|
||||
if (status === 'interrupted') return 'Job interrupted.'
|
||||
if (status === 'error') return 'Image ComfyUI reported an execution error'
|
||||
if (status === 'error') return fromMessages || 'Image ComfyUI reported an execution error'
|
||||
if (entry?.status?.completed && !extractEditedImage(history, promptId)) {
|
||||
return 'Image ComfyUI finished without an output still'
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
function formatExecutionError(data?: Record<string, unknown> | null) {
|
||||
if (!data) return ''
|
||||
const node = String(data.node_type || data.node_id || '').trim()
|
||||
const message = String(data.exception_message || data.message || '').trim()
|
||||
if (node && message) return `${node}: ${message}`
|
||||
return message
|
||||
}
|
||||
|
||||
export async function waitForImageEdit(opts: {
|
||||
promptId: string
|
||||
clientId: string
|
||||
@@ -240,7 +255,17 @@ export async function waitForImageEdit(opts: {
|
||||
ws.addEventListener('message', (event) => {
|
||||
const payload = JSON.parse(String(event.data || '{}')) as {
|
||||
type?: string
|
||||
data?: { value?: number; max?: number; node?: string | null; prompt_id?: string }
|
||||
data?: {
|
||||
value?: number
|
||||
max?: number
|
||||
node?: string | null
|
||||
prompt_id?: string
|
||||
exception_message?: string
|
||||
exception_type?: string
|
||||
node_id?: string
|
||||
node_type?: string
|
||||
message?: string
|
||||
}
|
||||
}
|
||||
if (payload.type === 'progress' && payload.data) {
|
||||
const max = Math.max(1, Number(payload.data.max || 4))
|
||||
@@ -261,7 +286,7 @@ export async function waitForImageEdit(opts: {
|
||||
})
|
||||
}
|
||||
if (payload.type === 'execution_error') {
|
||||
finish(null, 'Image ComfyUI reported an execution error')
|
||||
finish(null, formatExecutionError(payload.data) || 'Image ComfyUI reported an execution error')
|
||||
}
|
||||
})
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user