From 70e25fbdce1183177703c24b69ce855be694fcf1 Mon Sep 17 00:00:00 2001 From: Vinh Trinh Date: Thu, 12 Nov 2026 19:37:07 -0800 Subject: [PATCH 01/13] Mark nodes red when Cloud reports skipped outputs Listen for the prompt_outputs_skipped socket message and record its node_errors under the run's error key, buffering it until the job is known, so the skipped nodes turn red and show in the Errors tab. --- packages/api-client/src/ComfyApi.ts | 3 ++ packages/api-client/src/executionTypes.ts | 5 ++ src/stores/executionErrorStore.test.ts | 42 +++++++++++++++ src/stores/executionErrorStore.ts | 19 +++++++ src/stores/executionStore.test.ts | 62 ++++++++++++++++++++++- src/stores/executionStore.ts | 54 +++++++++++++++++--- 6 files changed, 176 insertions(+), 9 deletions(-) diff --git a/packages/api-client/src/ComfyApi.ts b/packages/api-client/src/ComfyApi.ts index 8b63609294f..ee13cd914dc 100644 --- a/packages/api-client/src/ComfyApi.ts +++ b/packages/api-client/src/ComfyApi.ts @@ -48,6 +48,7 @@ import type { ProgressStateWsMessage, ProgressTextWsMessage, ProgressWsMessage, + PromptOutputsSkippedWsMessage, StatusWsMessage, StatusWsMessageStatus } from './executionTypes' @@ -205,6 +206,7 @@ interface BackendApiCalls { execution_error: ExecutionErrorWsMessage execution_interrupted: ExecutionInterruptedWsMessage execution_cached: ExecutionCachedWsMessage + prompt_outputs_skipped: PromptOutputsSkippedWsMessage logs: LogsWsMessage /** Binary preview/progress data */ b_preview: Blob @@ -1147,6 +1149,7 @@ export class ComfyApi extends EventTarget { case 'execution_interrupted': case 'execution_cached': case 'execution_success': + case 'prompt_outputs_skipped': case 'progress': case 'progress_state': case 'executed': diff --git a/packages/api-client/src/executionTypes.ts b/packages/api-client/src/executionTypes.ts index 22639644394..dc68a4818dc 100644 --- a/packages/api-client/src/executionTypes.ts +++ b/packages/api-client/src/executionTypes.ts @@ -3,6 +3,7 @@ import type { PromptInfo } from '@comfyorg/ingest-types' import { z } from 'zod' import { zNodeId } from '@comfyorg/graph-model/workflowSchema' import type { TaskStatus } from './taskSchema' +import type { NodeError } from './types' import { resultItemType } from './resultItemTypeSchema' export type JobId = string @@ -111,6 +112,10 @@ export interface ExecutionErrorWsMessage extends ExecutionWsMessageBase { current_inputs?: unknown current_outputs?: unknown } +export interface PromptOutputsSkippedWsMessage { + prompt_id: JobId + node_errors: Record +} export interface ProgressTextWsMessage { nodeId: NodeId text: string diff --git a/src/stores/executionErrorStore.test.ts b/src/stores/executionErrorStore.test.ts index d751b77098c..ead387c02a3 100644 --- a/src/stores/executionErrorStore.test.ts +++ b/src/stores/executionErrorStore.test.ts @@ -813,6 +813,48 @@ describe('surfaceMissingMedia — silent option', () => { }) }) +describe('surfaceNodeErrors', () => { + const visibleGraphId = '11111111-1111-4111-8111-111111111111' + const backgroundGraphId = '22222222-2222-4222-8222-222222222222' + const nodeErrors = { + '9': nodeError( + [validationError('required_input_missing', 'images')], + 'SaveImage' + ) + } + + beforeEach(() => { + useSettingStore().settingValues['Comfy.RightSidePanel.ShowErrorsTab'] = true + }) + + it('records the errors and opens the overlay for the run on screen', () => { + const store = useExecutionErrorStore() + store.setActiveGraph(visibleGraphId, 'workflows/a.json') + + store.surfaceNodeErrors( + nodeErrors, + store.runErrorKey(visibleGraphId, 'workflows/a.json') + ) + + expect(store.lastNodeErrors).toEqual(nodeErrors) + expect(store.isErrorOverlayOpen).toBe(true) + }) + + it('records a background run without opening the overlay', () => { + const store = useExecutionErrorStore() + store.setActiveGraph(visibleGraphId, 'workflows/a.json') + + store.surfaceNodeErrors( + nodeErrors, + store.runErrorKey(backgroundGraphId, 'workflows/b.json') + ) + + expect(store.isErrorOverlayOpen).toBe(false) + store.setActiveGraph(backgroundGraphId, 'workflows/b.json') + expect(store.lastNodeErrors).toEqual(nodeErrors) + }) +}) + describe('recordNodeErrors', () => { it('normalizes an empty error record to null', () => { const store = useExecutionErrorStore() diff --git a/src/stores/executionErrorStore.ts b/src/stores/executionErrorStore.ts index 1d0651a3852..4edde3fd566 100644 --- a/src/stores/executionErrorStore.ts +++ b/src/stores/executionErrorStore.ts @@ -454,6 +454,24 @@ export const useExecutionErrorStore = defineStore('executionError', () => { } } + /** + * Records `nodeErrors` under `key` and opens the error overlay when that + * run is on screen. + */ + function surfaceNodeErrors( + nodeErrors: Record, + key: string + ) { + recordNodeErrors(nodeErrors, key) + if ( + key === activeRunErrorKey.value && + hasNodeError.value && + useSettingStore().get('Comfy.RightSidePanel.ShowErrorsTab') + ) { + showErrorOverlay() + } + } + function recordExecutionError( detail: ExecutionErrorWsMessage, key: string | null = activeRunErrorKey.value @@ -979,6 +997,7 @@ export const useExecutionErrorStore = defineStore('executionError', () => { // Recording recordNodeErrors, + surfaceNodeErrors, recordExecutionError, recordPromptError, diff --git a/src/stores/executionStore.test.ts b/src/stores/executionStore.test.ts index 9c09343392c..321570acb74 100644 --- a/src/stores/executionStore.test.ts +++ b/src/stores/executionStore.test.ts @@ -22,6 +22,7 @@ import { createNodeLocatorId } from '@comfyorg/graph-model/nodeIdentification' import { executionIdToNodeLocatorId } from '@/utils/graphTraversalUtil' +import { nodeError, validationError } from '@/utils/__tests__/nodeErrorHelpers' import type { NodeProgressState } from '@comfyorg/api-client/executionTypes' const apiEvents: EventTarget = api @@ -980,6 +981,22 @@ describe('useExecutionStore - background workflow error routing', () => { ) } + function fireOutputsSkipped(jobId: string, nodeId: string) { + apiEvents.dispatchEvent( + new CustomEvent('prompt_outputs_skipped', { + detail: { + prompt_id: jobId, + node_errors: { + [nodeId]: nodeError( + [validationError('required_input_missing', 'images')], + 'SaveImage' + ) + } + } + }) + ) + } + const cloudValidationMessage = JSON.stringify({ error: { type: 'prompt_outputs_failed_validation', message: 'invalid' }, node_errors: { @@ -1151,6 +1168,48 @@ describe('useExecutionStore - background workflow error routing', () => { expect(errorStore.lastExecutionError?.prompt_id).toBe('job-ambiguous') }) + it('marks the skipped outputs of the visible run as node errors', () => { + callStoreJob('job-a', workflowA) + fireOutputsSkipped('job-a', '9') + + expect(Object.keys(errorStore.lastNodeErrors ?? {})).toEqual(['9']) + }) + + it('files the skipped outputs of a background run under its workflow', () => { + callStoreJob('job-b', workflowB) + fireOutputsSkipped('job-b', '9') + + expect(errorStore.lastNodeErrors).toBeNull() + + errorStore.setActiveGraph(graphBId, workflowB.path) + expect(Object.keys(errorStore.lastNodeErrors ?? {})).toEqual(['9']) + }) + + it('applies skipped outputs that arrive before the job is stored', () => { + fireOutputsSkipped('job-a', '9') + expect(errorStore.lastNodeErrors).toBeNull() + + callStoreJob('job-a', workflowA) + + expect(Object.keys(errorStore.lastNodeErrors ?? {})).toEqual(['9']) + }) + + it('keeps skipped outputs of an unknown job off the visible run', () => { + callStoreJob('job-a', workflowA) + fireOutputsSkipped('job-a', '9') + fireOutputsSkipped('job-unknown', '5') + + expect(Object.keys(errorStore.lastNodeErrors ?? {})).toEqual(['9']) + }) + + it('keeps skipped-output errors through execution_start', () => { + callStoreJob('job-a', workflowA) + fireOutputsSkipped('job-a', '9') + fireExecutionStart('job-a') + + expect(Object.keys(errorStore.lastNodeErrors ?? {})).toEqual(['9']) + }) + it('does not route an unattributable failure to the visible workflow', () => { fireExecutionError('job-unknown') @@ -2595,7 +2654,8 @@ describe('useExecutionStore - WebSocket event handlers', () => { 'executing', 'progress', 'progress_state', - 'execution_error' + 'execution_error', + 'prompt_outputs_skipped' ] store.unbindExecutionEvents() diff --git a/src/stores/executionStore.ts b/src/stores/executionStore.ts index 8f52d0eda3e..aeb76524043 100644 --- a/src/stores/executionStore.ts +++ b/src/stores/executionStore.ts @@ -29,7 +29,8 @@ import type { NodeProgressState, NotificationWsMessage, ProgressStateWsMessage, - ProgressWsMessage + ProgressWsMessage, + PromptOutputsSkippedWsMessage } from '@comfyorg/api-client/executionTypes' import { api } from '@/scripts/api' import { useApp } from '@/scripts/appInstance' @@ -183,6 +184,10 @@ export const useExecutionStore = defineStore('execution', () => { // FIFO-capped to bound growth if a matching storeJob never fires. const pendingWorkflowStatusByJobId = new Map() const pendingExecutionErrorsByJobId = new Map() + const pendingSkippedOutputsByJobId = new Map< + string, + PromptOutputsSkippedWsMessage + >() function bufferPendingWorkflowStatus( jobId: string, @@ -205,17 +210,20 @@ export const useExecutionStore = defineStore('execution', () => { } } - function bufferPendingExecutionError(error: PendingExecutionError) { - const jobId = error.detail.prompt_id - pendingExecutionErrorsByJobId.delete(jobId) - pendingExecutionErrorsByJobId.set(jobId, error) - while (pendingExecutionErrorsByJobId.size > MAX_PROGRESS_JOBS) { - const oldest = pendingExecutionErrorsByJobId.keys().next().value + function bufferByJobId(buffer: Map, jobId: string, value: T) { + buffer.delete(jobId) + buffer.set(jobId, value) + while (buffer.size > MAX_PROGRESS_JOBS) { + const oldest = buffer.keys().next().value if (oldest === undefined) break - pendingExecutionErrorsByJobId.delete(oldest) + buffer.delete(oldest) } } + function bufferPendingExecutionError(error: PendingExecutionError) { + bufferByJobId(pendingExecutionErrorsByJobId, error.detail.prompt_id, error) + } + function mutateStatus( mutator: (map: Map) => void ) { @@ -459,6 +467,7 @@ export const useExecutionStore = defineStore('execution', () => { api.addEventListener('progress_state', handleProgressState) api.addEventListener('status', handleStatus) api.addEventListener('execution_error', handleExecutionError) + api.addEventListener('prompt_outputs_skipped', handlePromptOutputsSkipped) } function unbindExecutionEvents() { @@ -473,10 +482,15 @@ export const useExecutionStore = defineStore('execution', () => { api.removeEventListener('progress_state', handleProgressState) api.removeEventListener('status', handleStatus) api.removeEventListener('execution_error', handleExecutionError) + api.removeEventListener( + 'prompt_outputs_skipped', + handlePromptOutputsSkipped + ) if (workflowStatus.value.size > 0) workflowStatus.value = new Map() pendingWorkflowStatusByJobId.clear() pendingExecutionErrorsByJobId.clear() + pendingSkippedOutputsByJobId.clear() jobIdToWorkflow.clear() jobIdToStampedWorkflowId.clear() @@ -879,6 +893,28 @@ export const useExecutionStore = defineStore('execution', () => { processExecutionError(e.detail, runErrorKey, endTime) } + function handlePromptOutputsSkipped( + e: CustomEvent + ) { + recordSkippedOutputs(e.detail) + } + + function recordSkippedOutputs(detail: PromptOutputsSkippedWsMessage) { + const runErrorKey = runErrorKeyForJob(detail.prompt_id) + if (runErrorKey === null) { + bufferByJobId(pendingSkippedOutputsByJobId, detail.prompt_id, detail) + return + } + executionErrorStore.surfaceNodeErrors(detail.node_errors, runErrorKey) + } + + function flushPendingSkippedOutputs(jobId: string) { + const pending = pendingSkippedOutputsByJobId.get(jobId) + if (!pending) return + pendingSkippedOutputsByJobId.delete(jobId) + recordSkippedOutputs(pending) + } + function processExecutionError( detail: ExecutionErrorWsMessage, runErrorKey: string, @@ -1152,6 +1188,7 @@ export const useExecutionStore = defineStore('execution', () => { } flushPendingWorkflowStatus(id, workflow) flushPendingExecutionError(id) + flushPendingSkippedOutputs(id) if (queuedJob.executionStartedAt !== undefined) adoptActiveWorkflowJob() } @@ -1235,6 +1272,7 @@ export const useExecutionStore = defineStore('execution', () => { if (!jobId || !workflowId) return jobIdToWorkflowId.value.set(jobId, workflowId) flushPendingExecutionError(jobId) + flushPendingSkippedOutputs(jobId) } /** From ec1b8b9fc5f5f31c4cbc750a33f998bbf301e94c Mon Sep 17 00:00:00 2001 From: Vinh Trinh Date: Thu, 12 Nov 2026 20:41:58 -0800 Subject: [PATCH 02/13] fix(execution): keep skipped-output errors when the submission response arrives Queue polling can map a Cloud job to its workflow before the /prompt response returns, so prompt_outputs_skipped may record node errors first. The response then carried empty node_errors and replaced them with null. Clear the run's node errors when the prompt is sent and record the response's node_errors only when it has some. --- src/scripts/app.test.ts | 38 ++++++++++++++++++++++++++++++++++++++ src/scripts/app.ts | 11 +++++++---- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/scripts/app.test.ts b/src/scripts/app.test.ts index 58678ec83f6..3d906c2d887 100644 --- a/src/scripts/app.test.ts +++ b/src/scripts/app.test.ts @@ -2242,6 +2242,44 @@ describe('ComfyApp', () => { expect(mockCanvas.draw).toHaveBeenCalledWith(true, true) }) + it('keeps skipped-output errors that arrive before the submission response', async () => { + prepareEmptyPromptQueue() + const workflow = useWorkflowStore().activeWorkflow + if (!workflow) throw new Error('Expected an active workflow') + const graphId = '11111111-1111-4111-8111-111111111111' + workflow.changeTracker.activeState = { + ...createWorkflowGraphData(), + id: graphId + } + Object.assign(useWorkflowStore(), { openWorkflows: [workflow] }) + const executionStore = useExecutionStore() + const errorStore = useExecutionErrorStore() + errorStore.setActiveGraph(graphId, workflow.path) + executionStore.bindExecutionEvents() + onTestFinished(() => executionStore.unbindExecutionEvents()) + const skippedErrors = { + '9': nodeError( + [validationError('required_input_missing', 'images')], + 'SaveImage' + ) + } + const socket: EventTarget = api + vi.spyOn(api, 'queuePrompt').mockImplementation(async () => { + executionStore.registerJobWorkflowIdMapping('job-1', graphId) + socket.dispatchEvent( + new CustomEvent('prompt_outputs_skipped', { + detail: { prompt_id: 'job-1', node_errors: skippedErrors } + }) + ) + return { prompt_id: 'job-1', node_errors: {} } + }) + + await app.queuePrompt(0) + + expect(errorStore.lastNodeErrors).toEqual(skippedErrors) + expect(errorStore.isErrorOverlayOpen).toBe(true) + }) + it('stores workflow telemetry metadata for every accepted batch submission', async () => { prepareEmptyPromptQueue() const registry = new TelemetryRegistry() diff --git a/src/scripts/app.ts b/src/scripts/app.ts index 9942da1fd31..4786c23c57a 100644 --- a/src/scripts/app.ts +++ b/src/scripts/app.ts @@ -1919,6 +1919,7 @@ export class ComfyApp implements IComfyApp { try { api.authToken = comfyOrgAuthToken api.apiKey = comfyOrgApiKey ?? undefined + executionErrorStore.recordNodeErrors(null, queuedRunErrorKey) const res = await api.queuePrompt(number, p, { partialExecutionTargets: queueNodeIds, previewMethod @@ -1936,10 +1937,12 @@ export class ComfyApp implements IComfyApp { ...(workflowContext && { workflowContext }) }) } - executionErrorStore.recordNodeErrors( - res.node_errors ?? null, - queuedRunErrorKey - ) + if (res.node_errors && Object.keys(res.node_errors).length > 0) { + executionErrorStore.recordNodeErrors( + res.node_errors, + queuedRunErrorKey + ) + } queueResultOverride = null try { if (res.prompt_id) { From a1259aafdd5ee135972de511b1b8fd0046324251 Mon Sep 17 00:00:00 2001 From: Vinh Trinh Date: Thu, 12 Nov 2026 20:42:48 -0800 Subject: [PATCH 03/13] fix(execution): normalize string entries in skipped-output node errors Cloud relays each validator's errors as sent, and a custom validator can report a bare string. A string reached the validation-surface WeakMap, which threw after the record was stored, so the overlay never opened. Type the socket payload's errors as unknown and turn each entry into a node validation error before any state change: a string becomes an error of type "error" with that message, like normalizePromptError does, and any other non-object entry is dropped. --- packages/api-client/src/executionTypes.ts | 4 ++- src/stores/executionStore.test.ts | 28 +++++++++++++++ src/stores/executionStore.ts | 26 +++++++++----- src/utils/executionErrorUtil.ts | 44 +++++++++++++++++++++++ 4 files changed, 93 insertions(+), 9 deletions(-) diff --git a/packages/api-client/src/executionTypes.ts b/packages/api-client/src/executionTypes.ts index dc68a4818dc..1500265f2c1 100644 --- a/packages/api-client/src/executionTypes.ts +++ b/packages/api-client/src/executionTypes.ts @@ -112,9 +112,11 @@ export interface ExecutionErrorWsMessage extends ExecutionWsMessageBase { current_inputs?: unknown current_outputs?: unknown } +/** A node error as Cloud relays it: an entry in `errors` may be a bare string. */ +export type RelayedNodeError = Omit & { errors: unknown[] } export interface PromptOutputsSkippedWsMessage { prompt_id: JobId - node_errors: Record + node_errors: Record } export interface ProgressTextWsMessage { nodeId: NodeId diff --git a/src/stores/executionStore.test.ts b/src/stores/executionStore.test.ts index 321570acb74..628fef5dd51 100644 --- a/src/stores/executionStore.test.ts +++ b/src/stores/executionStore.test.ts @@ -16,6 +16,7 @@ import '@/scripts/changeTracker' import { defaultGraph } from '@/scripts/defaultGraph' import { MAX_PROGRESS_JOBS, useExecutionStore } from '@/stores/executionStore' import { useExecutionErrorStore } from '@/stores/executionErrorStore' +import { useSettingStore } from '@/platform/settings/settingStore' import { useMissingNodesErrorStore } from '@/platform/workflowErrors/nodeReplacement/missingNodesErrorStore' import { createNodeExecutionId, @@ -1210,6 +1211,33 @@ describe('useExecutionStore - background workflow error routing', () => { expect(Object.keys(errorStore.lastNodeErrors ?? {})).toEqual(['9']) }) + it('shows skipped outputs whose errors include a bare string', () => { + useSettingStore().settingValues['Comfy.RightSidePanel.ShowErrorsTab'] = true + const inputError = validationError('required_input_missing', 'images') + callStoreJob('job-a', workflowA) + + apiEvents.dispatchEvent( + new CustomEvent('prompt_outputs_skipped', { + detail: { + prompt_id: 'job-a', + node_errors: { + '9': { + class_type: 'SaveImage', + dependent_outputs: ['9'], + errors: [inputError, 'Image is not valid', 42] + } + } + } + }) + ) + + expect(errorStore.lastNodeErrors?.['9']?.errors).toEqual([ + inputError, + { type: 'error', message: 'Image is not valid', details: '' } + ]) + expect(errorStore.isErrorOverlayOpen).toBe(true) + }) + it('does not route an unattributable failure to the visible workflow', () => { fireExecutionError('job-unknown') diff --git a/src/stores/executionStore.ts b/src/stores/executionStore.ts index aeb76524043..2901959ea59 100644 --- a/src/stores/executionStore.ts +++ b/src/stores/executionStore.ts @@ -32,6 +32,7 @@ import type { ProgressWsMessage, PromptOutputsSkippedWsMessage } from '@comfyorg/api-client/executionTypes' +import type { NodeError } from '@comfyorg/api-client/types' import { api } from '@/scripts/api' import { useApp } from '@/scripts/appInstance' import { useNodeOutputStore } from '@/stores/nodeOutputStore' @@ -42,7 +43,10 @@ import type { NodeLocatorId } from '@comfyorg/graph-model/nodeIdentification' import type { AppMode } from '@comfyorg/graph-model/appMode' import { isAppModeValue } from '@comfyorg/graph-model/appMode' import { zeroUuid } from '@comfyorg/graph-model/uuid' -import { classifyCloudValidationError } from '@/utils/executionErrorUtil' +import { + classifyCloudValidationError, + normalizeRelayedNodeErrors +} from '@/utils/executionErrorUtil' import { executionIdToNodeLocatorId } from '@/utils/graphTraversalUtil' import { createRafCoalescer } from '@/utils/rafBatch' @@ -186,7 +190,7 @@ export const useExecutionStore = defineStore('execution', () => { const pendingExecutionErrorsByJobId = new Map() const pendingSkippedOutputsByJobId = new Map< string, - PromptOutputsSkippedWsMessage + Record >() function bufferPendingWorkflowStatus( @@ -896,23 +900,29 @@ export const useExecutionStore = defineStore('execution', () => { function handlePromptOutputsSkipped( e: CustomEvent ) { - recordSkippedOutputs(e.detail) + recordSkippedOutputs( + e.detail.prompt_id, + normalizeRelayedNodeErrors(e.detail.node_errors) + ) } - function recordSkippedOutputs(detail: PromptOutputsSkippedWsMessage) { - const runErrorKey = runErrorKeyForJob(detail.prompt_id) + function recordSkippedOutputs( + jobId: string, + nodeErrors: Record + ) { + const runErrorKey = runErrorKeyForJob(jobId) if (runErrorKey === null) { - bufferByJobId(pendingSkippedOutputsByJobId, detail.prompt_id, detail) + bufferByJobId(pendingSkippedOutputsByJobId, jobId, nodeErrors) return } - executionErrorStore.surfaceNodeErrors(detail.node_errors, runErrorKey) + executionErrorStore.surfaceNodeErrors(nodeErrors, runErrorKey) } function flushPendingSkippedOutputs(jobId: string) { const pending = pendingSkippedOutputsByJobId.get(jobId) if (!pending) return pendingSkippedOutputsByJobId.delete(jobId) - recordSkippedOutputs(pending) + recordSkippedOutputs(jobId, pending) } function processExecutionError( diff --git a/src/utils/executionErrorUtil.ts b/src/utils/executionErrorUtil.ts index b1efa38608e..a1bfa2f9887 100644 --- a/src/utils/executionErrorUtil.ts +++ b/src/utils/executionErrorUtil.ts @@ -1,3 +1,4 @@ +import type { RelayedNodeError } from '@comfyorg/api-client/executionTypes' import type { NodeError, PromptError } from '@comfyorg/api-client/types' import type { SerializedNodeId } from '@comfyorg/graph-model/nodeId' @@ -78,6 +79,49 @@ export function normalizePromptError(error: unknown): PromptError | null { : null } +function isExtraInfo( + value: unknown +): value is NonNullable { + return ( + value !== null && + typeof value === 'object' && + !Array.isArray(value) && + (!('input_name' in value) || typeof value.input_name === 'string') + ) +} + +function toNodeValidationErrors(error: unknown): NodeValidationError[] { + const promptError = normalizePromptError(error) + if (!promptError) return [] + const extraInfo = + error !== null && typeof error === 'object' && 'extra_info' in error + ? error.extra_info + : undefined + return [ + isExtraInfo(extraInfo) + ? { ...promptError, extra_info: extraInfo } + : promptError + ] +} + +/** + * Turns relayed node errors into `NodeError`s: a string entry becomes an + * error whose message is that string, and any other non-object is dropped. + */ +export function normalizeRelayedNodeErrors( + nodeErrors: Record +): Record { + return Object.fromEntries( + Object.entries(nodeErrors).map(([nodeId, nodeError]) => [ + nodeId, + { + ...nodeError, + errors: nodeError.errors.flatMap(toNodeValidationErrors) + } + ]) + ) +} + export function isMissingNodePromptError( promptError: PromptError | null | undefined ): boolean { From b86ebcc04f65dd6fba645f8c2c57a7a8b1cbf936 Mon Sep 17 00:00:00 2001 From: Vinh Trinh Date: Thu, 12 Nov 2026 20:57:57 -0800 Subject: [PATCH 04/13] fix(execution): drop an older job's skipped-output errors on a clean submission Run errors are filed per workflow and graph, not per job. If an older job's prompt_outputs_skipped arrived while a newer clean submission awaited its /prompt response, the empty response kept those errors, the nodes stayed red and queuePrompt returned false. Remember which job's message recorded a run's node errors. An empty response keeps them only when they came from the job it accepted. --- src/scripts/app.test.ts | 32 ++++++++++++++++--- src/scripts/app.ts | 11 +++---- src/stores/executionErrorStore.test.ts | 6 ++-- src/stores/executionErrorStore.ts | 43 ++++++++++++++++++++++---- src/stores/executionStore.ts | 2 +- 5 files changed, 75 insertions(+), 19 deletions(-) diff --git a/src/scripts/app.test.ts b/src/scripts/app.test.ts index 3d906c2d887..5bd3c3f9bec 100644 --- a/src/scripts/app.test.ts +++ b/src/scripts/app.test.ts @@ -2242,7 +2242,7 @@ describe('ComfyApp', () => { expect(mockCanvas.draw).toHaveBeenCalledWith(true, true) }) - it('keeps skipped-output errors that arrive before the submission response', async () => { + function prepareSkippedOutputsRun() { prepareEmptyPromptQueue() const workflow = useWorkflowStore().activeWorkflow if (!workflow) throw new Error('Expected an active workflow') @@ -2264,13 +2264,22 @@ describe('ComfyApp', () => { ) } const socket: EventTarget = api - vi.spyOn(api, 'queuePrompt').mockImplementation(async () => { - executionStore.registerJobWorkflowIdMapping('job-1', graphId) + function dispatchSkippedOutputs(jobId: string) { + executionStore.registerJobWorkflowIdMapping(jobId, graphId) socket.dispatchEvent( new CustomEvent('prompt_outputs_skipped', { - detail: { prompt_id: 'job-1', node_errors: skippedErrors } + detail: { prompt_id: jobId, node_errors: skippedErrors } }) ) + } + return { errorStore, skippedErrors, dispatchSkippedOutputs } + } + + it('keeps skipped-output errors that arrive before the submission response', async () => { + const { errorStore, skippedErrors, dispatchSkippedOutputs } = + prepareSkippedOutputsRun() + vi.spyOn(api, 'queuePrompt').mockImplementation(async () => { + dispatchSkippedOutputs('job-1') return { prompt_id: 'job-1', node_errors: {} } }) @@ -2280,6 +2289,21 @@ describe('ComfyApp', () => { expect(errorStore.isErrorOverlayOpen).toBe(true) }) + it("drops an older job's skipped-output errors when a newer submission comes back clean", async () => { + const { errorStore, dispatchSkippedOutputs } = prepareSkippedOutputsRun() + vi.spyOn(api, 'queuePrompt') + .mockResolvedValueOnce({ prompt_id: 'job-a', node_errors: {} }) + .mockImplementationOnce(async () => { + dispatchSkippedOutputs('job-a') + return { prompt_id: 'job-b', node_errors: {} } + }) + await app.queuePrompt(0) + + await expect(app.queuePrompt(0)).resolves.toBe(true) + + expect(errorStore.lastNodeErrors).toBeNull() + }) + it('stores workflow telemetry metadata for every accepted batch submission', async () => { prepareEmptyPromptQueue() const registry = new TelemetryRegistry() diff --git a/src/scripts/app.ts b/src/scripts/app.ts index 4786c23c57a..84fb59b1129 100644 --- a/src/scripts/app.ts +++ b/src/scripts/app.ts @@ -1937,12 +1937,11 @@ export class ComfyApp implements IComfyApp { ...(workflowContext && { workflowContext }) }) } - if (res.node_errors && Object.keys(res.node_errors).length > 0) { - executionErrorStore.recordNodeErrors( - res.node_errors, - queuedRunErrorKey - ) - } + executionErrorStore.recordSubmissionNodeErrors( + res.node_errors, + queuedRunErrorKey, + res.prompt_id + ) queueResultOverride = null try { if (res.prompt_id) { diff --git a/src/stores/executionErrorStore.test.ts b/src/stores/executionErrorStore.test.ts index ead387c02a3..9291ccb2f90 100644 --- a/src/stores/executionErrorStore.test.ts +++ b/src/stores/executionErrorStore.test.ts @@ -833,7 +833,8 @@ describe('surfaceNodeErrors', () => { store.surfaceNodeErrors( nodeErrors, - store.runErrorKey(visibleGraphId, 'workflows/a.json') + store.runErrorKey(visibleGraphId, 'workflows/a.json'), + 'job-1' ) expect(store.lastNodeErrors).toEqual(nodeErrors) @@ -846,7 +847,8 @@ describe('surfaceNodeErrors', () => { store.surfaceNodeErrors( nodeErrors, - store.runErrorKey(backgroundGraphId, 'workflows/b.json') + store.runErrorKey(backgroundGraphId, 'workflows/b.json'), + 'job-1' ) expect(store.isErrorOverlayOpen).toBe(false) diff --git a/src/stores/executionErrorStore.ts b/src/stores/executionErrorStore.ts index 4edde3fd566..c6458c48a5f 100644 --- a/src/stores/executionErrorStore.ts +++ b/src/stores/executionErrorStore.ts @@ -75,6 +75,8 @@ interface RunErrorState { MissingResourceAbsorption > nodeErrors: Record | null + /** The job whose socket message recorded `nodeErrors`, if one did. */ + nodeErrorsJobId: string | null executionError: ExecutionErrorWsMessage | null promptError: PromptError | null } @@ -118,6 +120,7 @@ export const useExecutionErrorStore = defineStore('executionError', () => { const next: RunErrorState = { absorbedValidationErrors: new WeakMap(), nodeErrors: null, + nodeErrorsJobId: null, executionError: null, promptError: null, ...runErrorsByWorkflow.value.get(key), @@ -434,12 +437,17 @@ export const useExecutionErrorStore = defineStore('executionError', () => { */ function recordNodeErrors( nodeErrors: Record | null, - key: string | null = activeRunErrorKey.value + key: string | null = activeRunErrorKey.value, + jobId: string | null = null ) { const record = nodeErrors && Object.keys(nodeErrors).length > 0 ? nodeErrors : null updateRunErrors( - { nodeErrors: record, absorbedValidationErrors: new WeakMap() }, + { + nodeErrors: record, + nodeErrorsJobId: record ? jobId : null, + absorbedValidationErrors: new WeakMap() + }, key ) if (record && key !== null && key === activeRunErrorKey.value) { @@ -455,14 +463,36 @@ export const useExecutionErrorStore = defineStore('executionError', () => { } /** - * Records `nodeErrors` under `key` and opens the error overlay when that - * run is on screen. + * Records the node errors of the submission `jobId` from `key`'s run. An + * empty response keeps errors that `jobId`'s own socket message recorded + * before the response arrived, and drops those of any older job. + */ + function recordSubmissionNodeErrors( + nodeErrors: Record | null | undefined, + key: string | null, + jobId: string | undefined + ) { + if (nodeErrors && Object.keys(nodeErrors).length > 0) { + recordNodeErrors(nodeErrors, key) + return + } + const recordedJobId = + key === null ? null : runErrorsByWorkflow.value.get(key)?.nodeErrorsJobId + if (jobId === undefined || recordedJobId !== jobId) { + recordNodeErrors(null, key) + } + } + + /** + * Records `nodeErrors` of job `jobId` under `key` and opens the error + * overlay when that run is on screen. */ function surfaceNodeErrors( nodeErrors: Record, - key: string + key: string, + jobId: string ) { - recordNodeErrors(nodeErrors, key) + recordNodeErrors(nodeErrors, key, jobId) if ( key === activeRunErrorKey.value && hasNodeError.value && @@ -997,6 +1027,7 @@ export const useExecutionErrorStore = defineStore('executionError', () => { // Recording recordNodeErrors, + recordSubmissionNodeErrors, surfaceNodeErrors, recordExecutionError, recordPromptError, diff --git a/src/stores/executionStore.ts b/src/stores/executionStore.ts index 2901959ea59..aca0d40a76d 100644 --- a/src/stores/executionStore.ts +++ b/src/stores/executionStore.ts @@ -915,7 +915,7 @@ export const useExecutionStore = defineStore('execution', () => { bufferByJobId(pendingSkippedOutputsByJobId, jobId, nodeErrors) return } - executionErrorStore.surfaceNodeErrors(nodeErrors, runErrorKey) + executionErrorStore.surfaceNodeErrors(nodeErrors, runErrorKey, jobId) } function flushPendingSkippedOutputs(jobId: string) { From 59b1d2e0bf20cd60fda547c377c871563395f38f Mon Sep 17 00:00:00 2001 From: Vinh Trinh Date: Thu, 12 Nov 2026 20:59:23 -0800 Subject: [PATCH 05/13] fix(execution): drop skipped-output nodes with no error to show A relayed node whose errors all normalized away stayed in the record with an empty errors list, so it was marked as having an error and the overlay could open with nothing to show. Nothing reads dependent_outputs, so drop such nodes, and ignore a message left with no nodes instead of clearing the run's errors with it. --- src/stores/executionStore.test.ts | 25 ++++++++++++++++++++ src/stores/executionStore.ts | 7 +++--- src/utils/executionErrorUtil.test.ts | 34 +++++++++++++++++++++++++++- src/utils/executionErrorUtil.ts | 13 +++++------ 4 files changed, 67 insertions(+), 12 deletions(-) diff --git a/src/stores/executionStore.test.ts b/src/stores/executionStore.test.ts index 628fef5dd51..51022bf75a0 100644 --- a/src/stores/executionStore.test.ts +++ b/src/stores/executionStore.test.ts @@ -1238,6 +1238,31 @@ describe('useExecutionStore - background workflow error routing', () => { expect(errorStore.isErrorOverlayOpen).toBe(true) }) + it('ignores a skipped-outputs message with no error to show', () => { + useSettingStore().settingValues['Comfy.RightSidePanel.ShowErrorsTab'] = true + callStoreJob('job-a', workflowA) + fireOutputsSkipped('job-a', '9') + errorStore.dismissErrorOverlay() + + apiEvents.dispatchEvent( + new CustomEvent('prompt_outputs_skipped', { + detail: { + prompt_id: 'job-a', + node_errors: { + '5': { + class_type: 'SaveImage', + dependent_outputs: ['5'], + errors: [42] + } + } + } + }) + ) + + expect(Object.keys(errorStore.lastNodeErrors ?? {})).toEqual(['9']) + expect(errorStore.isErrorOverlayOpen).toBe(false) + }) + it('does not route an unattributable failure to the visible workflow', () => { fireExecutionError('job-unknown') diff --git a/src/stores/executionStore.ts b/src/stores/executionStore.ts index aca0d40a76d..aa042ac2a9d 100644 --- a/src/stores/executionStore.ts +++ b/src/stores/executionStore.ts @@ -900,10 +900,9 @@ export const useExecutionStore = defineStore('execution', () => { function handlePromptOutputsSkipped( e: CustomEvent ) { - recordSkippedOutputs( - e.detail.prompt_id, - normalizeRelayedNodeErrors(e.detail.node_errors) - ) + const nodeErrors = normalizeRelayedNodeErrors(e.detail.node_errors) + if (Object.keys(nodeErrors).length === 0) return + recordSkippedOutputs(e.detail.prompt_id, nodeErrors) } function recordSkippedOutputs( diff --git a/src/utils/executionErrorUtil.test.ts b/src/utils/executionErrorUtil.test.ts index b4c11a90487..a3b530bc584 100644 --- a/src/utils/executionErrorUtil.test.ts +++ b/src/utils/executionErrorUtil.test.ts @@ -4,7 +4,8 @@ import { isCloudValidationError, tryExtractValidationError, classifyCloudValidationError, - isValueStillOutOfRange + isValueStillOutOfRange, + normalizeRelayedNodeErrors } from '@/utils/executionErrorUtil' describe('executionErrorUtil', () => { @@ -371,4 +372,35 @@ describe('executionErrorUtil', () => { expect(isValueStillOutOfRange(5, errors, { min: 1, max: 10 })).toBe(false) }) }) + + describe('normalizeRelayedNodeErrors', () => { + it('drops a node none of whose errors can be shown', () => { + const inputError = { + type: 'required_input_missing', + message: 'Required input is missing', + details: 'images' + } + + expect( + normalizeRelayedNodeErrors({ + '9': { + class_type: 'SaveImage', + dependent_outputs: ['9'], + errors: [inputError] + }, + '10': { + class_type: 'SaveImage', + dependent_outputs: ['10'], + errors: [42, null] + } + }) + ).toEqual({ + '9': { + class_type: 'SaveImage', + dependent_outputs: ['9'], + errors: [inputError] + } + }) + }) + }) }) diff --git a/src/utils/executionErrorUtil.ts b/src/utils/executionErrorUtil.ts index a1bfa2f9887..b7980180174 100644 --- a/src/utils/executionErrorUtil.ts +++ b/src/utils/executionErrorUtil.ts @@ -107,18 +107,17 @@ function toNodeValidationErrors(error: unknown): NodeValidationError[] { /** * Turns relayed node errors into `NodeError`s: a string entry becomes an * error whose message is that string, and any other non-object is dropped. + * A node left with no errors is dropped too, so it is not marked red with + * nothing to show. */ export function normalizeRelayedNodeErrors( nodeErrors: Record ): Record { return Object.fromEntries( - Object.entries(nodeErrors).map(([nodeId, nodeError]) => [ - nodeId, - { - ...nodeError, - errors: nodeError.errors.flatMap(toNodeValidationErrors) - } - ]) + Object.entries(nodeErrors).flatMap(([nodeId, nodeError]) => { + const errors = nodeError.errors.flatMap(toNodeValidationErrors) + return errors.length > 0 ? [[nodeId, { ...nodeError, errors }]] : [] + }) ) } From e66f649f6e7dce19c9dc4b2d5c859069245c2f37 Mon Sep 17 00:00:00 2001 From: Vinh Trinh Date: Thu, 12 Nov 2026 21:00:37 -0800 Subject: [PATCH 06/13] test(execution): cover skipped outputs in the editor end to end Send prompt_outputs_skipped over the mocked socket after a clean run and check that the node gets the error and the error overlay shows it. --- .../fixtures/helpers/ExecutionHelper.ts | 10 +++++++ browser_tests/tests/execution.spec.ts | 26 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/browser_tests/fixtures/helpers/ExecutionHelper.ts b/browser_tests/fixtures/helpers/ExecutionHelper.ts index 8fd01678c44..318739580ba 100644 --- a/browser_tests/fixtures/helpers/ExecutionHelper.ts +++ b/browser_tests/fixtures/helpers/ExecutionHelper.ts @@ -255,6 +255,16 @@ export class ExecutionHelper { ) } + /** Send `prompt_outputs_skipped` WS event for outputs Cloud skipped. */ + outputsSkipped(jobId: string, nodeErrors: Record): void { + this.requireWs().send( + JSON.stringify({ + type: 'prompt_outputs_skipped', + data: { prompt_id: jobId, node_errors: nodeErrors } + }) + ) + } + /** Send `execution_interrupted` WS event (user-initiated stop). */ executionInterrupted(jobId: string, nodeId: string): void { this.requireWs().send( diff --git a/browser_tests/tests/execution.spec.ts b/browser_tests/tests/execution.spec.ts index ede6dd98dfb..2ebd15270d5 100644 --- a/browser_tests/tests/execution.spec.ts +++ b/browser_tests/tests/execution.spec.ts @@ -174,6 +174,32 @@ test.describe('Execution validation errors', { tag: '@workflow' }, () => { await expect(errorOverlay).toBeVisible() }) + test('marks the outputs a run skipped as node errors', async ({ + comfyPage, + getWebSocket + }) => { + await comfyPage.workflow.loadWorkflow('execution/partial_execution') + + const ws = await getWebSocket() + const exec = new ExecutionHelper(comfyPage, ws) + const jobId = await exec.run() + exec.executionStart(jobId) + exec.outputsSkipped(jobId, { + [VALIDATION_ERROR_NODE_ID]: buildPreviewAnyValidationError() + }) + + await expect + .poll(() => getValidationErrorMessage(comfyPage)) + .toBe(VALIDATION_ERROR_MESSAGE) + const errorOverlay = comfyPage.page.getByTestId( + TestIds.dialogs.errorOverlay + ) + await expect(errorOverlay).toBeVisible() + await expect(errorOverlay).toContainText( + 'Preview as Text is missing a required input: source' + ) + }) + test( 'renders cloud node errors when optional details are omitted', { tag: '@cloud' }, From 28134ba475dfb4d8f3fc80a31ab51f3484e57e07 Mon Sep 17 00:00:00 2001 From: Vinh Trinh Date: Thu, 12 Nov 2026 21:12:58 -0800 Subject: [PATCH 07/13] style(execution): drop the comment on an internal error-store field --- src/stores/executionErrorStore.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/stores/executionErrorStore.ts b/src/stores/executionErrorStore.ts index c6458c48a5f..a81fcc6ad1a 100644 --- a/src/stores/executionErrorStore.ts +++ b/src/stores/executionErrorStore.ts @@ -75,7 +75,6 @@ interface RunErrorState { MissingResourceAbsorption > nodeErrors: Record | null - /** The job whose socket message recorded `nodeErrors`, if one did. */ nodeErrorsJobId: string | null executionError: ExecutionErrorWsMessage | null promptError: PromptError | null From ab511a7059804d80fcc212408c5500aee4968d57 Mon Sep 17 00:00:00 2001 From: Vinh Trinh Date: Thu, 12 Nov 2026 22:10:43 -0800 Subject: [PATCH 08/13] style(execution): cut two exported JSDoc blocks to the contract The repository allows one or two lines of JSDoc on an exported API. The reasons behind the buffering and the response order move to the PR description. --- src/stores/executionErrorStore.ts | 5 ++--- src/utils/executionErrorUtil.ts | 6 ++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/stores/executionErrorStore.ts b/src/stores/executionErrorStore.ts index a81fcc6ad1a..551cb208570 100644 --- a/src/stores/executionErrorStore.ts +++ b/src/stores/executionErrorStore.ts @@ -462,9 +462,8 @@ export const useExecutionErrorStore = defineStore('executionError', () => { } /** - * Records the node errors of the submission `jobId` from `key`'s run. An - * empty response keeps errors that `jobId`'s own socket message recorded - * before the response arrived, and drops those of any older job. + * Records submission `jobId`'s node errors under `key`. An empty response + * keeps errors already recorded for `jobId` and clears any other job's. */ function recordSubmissionNodeErrors( nodeErrors: Record | null | undefined, diff --git a/src/utils/executionErrorUtil.ts b/src/utils/executionErrorUtil.ts index b7980180174..f24515b362e 100644 --- a/src/utils/executionErrorUtil.ts +++ b/src/utils/executionErrorUtil.ts @@ -105,10 +105,8 @@ function toNodeValidationErrors(error: unknown): NodeValidationError[] { } /** - * Turns relayed node errors into `NodeError`s: a string entry becomes an - * error whose message is that string, and any other non-object is dropped. - * A node left with no errors is dropped too, so it is not marked red with - * nothing to show. + * Converts relayed node errors to `NodeError`s; a string entry becomes the + * message, and a node left with no errors is dropped. */ export function normalizeRelayedNodeErrors( nodeErrors: Record From 4b6d4c123ce34744ff0c9bbd0b602e2be6f91ab5 Mon Sep 17 00:00:00 2001 From: Vinh Trinh Date: Thu, 12 Nov 2026 22:32:22 -0800 Subject: [PATCH 09/13] fix(execution): keep an early Cloud validation error through its own submission response Queue polling can map a job to its workflow before the submission response returns, so a Cloud validation execution_error for that job can be recorded first. It was recorded without a job ID, and the job's later empty submission response then cleared it as another job's errors, hiding the overlay and reporting the submission as clean. Record the producing job ID on the Cloud validation path, and on submission responses that carry node errors. --- src/stores/executionErrorStore.ts | 2 +- src/stores/executionStore.test.ts | 16 ++++++++++++++++ src/stores/executionStore.ts | 6 +++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/stores/executionErrorStore.ts b/src/stores/executionErrorStore.ts index 551cb208570..cce2ee0a872 100644 --- a/src/stores/executionErrorStore.ts +++ b/src/stores/executionErrorStore.ts @@ -471,7 +471,7 @@ export const useExecutionErrorStore = defineStore('executionError', () => { jobId: string | undefined ) { if (nodeErrors && Object.keys(nodeErrors).length > 0) { - recordNodeErrors(nodeErrors, key) + recordNodeErrors(nodeErrors, key, jobId ?? null) return } const recordedJobId = diff --git a/src/stores/executionStore.test.ts b/src/stores/executionStore.test.ts index 51022bf75a0..394266ab4bf 100644 --- a/src/stores/executionStore.test.ts +++ b/src/stores/executionStore.test.ts @@ -1061,6 +1061,22 @@ describe('useExecutionStore - background workflow error routing', () => { expect(Object.keys(errorStore.lastNodeErrors ?? {})).toEqual(['1']) }) + it("keeps validation node errors that arrive before their job's empty submission response", () => { + store.registerJobWorkflowIdMapping('job-a', graphAId) + fireExecutionError('job-a', { + exception_message: cloudValidationMessage, + exception_type: 'ValidationError' + }) + + errorStore.recordSubmissionNodeErrors( + {}, + errorStore.runErrorKey(graphAId, workflowA.path), + 'job-a' + ) + + expect(Object.keys(errorStore.lastNodeErrors ?? {})).toEqual(['1']) + }) + it('routes a background service-level error to its own workflow', () => { callStoreJob('job-b', workflowB) fireExecutionError('job-b', { diff --git a/src/stores/executionStore.ts b/src/stores/executionStore.ts index aa042ac2a9d..d64f36a939c 100644 --- a/src/stores/executionStore.ts +++ b/src/stores/executionStore.ts @@ -1022,7 +1022,11 @@ export const useExecutionStore = defineStore('execution', () => { resetExecutionState(detail.prompt_id) if (result.kind === 'nodeErrors') { - executionErrorStore.recordNodeErrors(result.nodeErrors, runErrorKey) + executionErrorStore.recordNodeErrors( + result.nodeErrors, + runErrorKey, + detail.prompt_id + ) } else { executionErrorStore.recordPromptError(result.promptError, runErrorKey) } From ec424130f26a532268d793452e417a2133b54fb9 Mon Sep 17 00:00:00 2001 From: Vinh Trinh Date: Fri, 13 Nov 2026 08:11:38 -0800 Subject: [PATCH 10/13] refactor(execution): use the generated prompt_outputs_skipped type from ingest-types Regenerate @comfyorg/ingest-types from Cloud main (da9dafcd), projected with openapi-project -fe as the sync workflow does, and type the prompt_outputs_skipped payload with PromptOutputsSkippedData and PromptOutputsSkippedNodeError instead of a hand-written type. The regen also brings Cloud's billing budget endpoints, the billing handoff intent and amount_cents fields, and the cursor verified OAuth platform; the consent screen's icon map is now partial since there is no Cursor icon. --- .../fixtures/helpers/ExecutionHelper.ts | 11 +- browser_tests/tests/execution.spec.ts | 4 +- packages/api-client/src/ComfyApi.ts | 6 +- packages/api-client/src/executionTypes.ts | 7 - packages/ingest-types/src/index.ts | 40 ++ packages/ingest-types/src/types.gen.ts | 571 +++++++++++++++++- packages/ingest-types/src/zod.gen.ts | 261 +++++++- src/platform/cloud/oauth/OAuthConsentView.vue | 1 + src/platform/cloud/oauth/oauthApi.ts | 5 +- src/stores/executionStore.ts | 6 +- src/utils/executionErrorUtil.test.ts | 2 +- src/utils/executionErrorUtil.ts | 4 +- 12 files changed, 882 insertions(+), 36 deletions(-) diff --git a/browser_tests/fixtures/helpers/ExecutionHelper.ts b/browser_tests/fixtures/helpers/ExecutionHelper.ts index 318739580ba..2a827c7ee51 100644 --- a/browser_tests/fixtures/helpers/ExecutionHelper.ts +++ b/browser_tests/fixtures/helpers/ExecutionHelper.ts @@ -5,6 +5,10 @@ import type { PromptFailureResponse } from '@comfyorg/api-client/types' import type { NodeProgressState } from '@comfyorg/api-client/executionTypes' +import type { + PromptOutputsSkippedFrame, + PromptOutputsSkippedNodeError +} from '@comfyorg/ingest-types' import type { RawJobListItem } from '@comfyorg/api-client/jobTypes' import type { ComfyPage } from '@e2e/fixtures/ComfyPage' import { createMockJob } from '@e2e/fixtures/helpers/AssetsHelper' @@ -256,12 +260,15 @@ export class ExecutionHelper { } /** Send `prompt_outputs_skipped` WS event for outputs Cloud skipped. */ - outputsSkipped(jobId: string, nodeErrors: Record): void { + outputsSkipped( + jobId: string, + nodeErrors: Record + ): void { this.requireWs().send( JSON.stringify({ type: 'prompt_outputs_skipped', data: { prompt_id: jobId, node_errors: nodeErrors } - }) + } satisfies PromptOutputsSkippedFrame) ) } diff --git a/browser_tests/tests/execution.spec.ts b/browser_tests/tests/execution.spec.ts index 2ebd15270d5..822f9ebca27 100644 --- a/browser_tests/tests/execution.spec.ts +++ b/browser_tests/tests/execution.spec.ts @@ -1,6 +1,7 @@ import { mergeTests } from '@playwright/test' import type { NodeError } from '@comfyorg/api-client/types' +import type { PromptOutputsSkippedNodeError } from '@comfyorg/ingest-types' import { comfyExpect as expect, comfyPageFixture @@ -25,7 +26,8 @@ type PromptRequestBody = { prompt?: Record } -function buildPreviewAnyValidationError(): NodeError { +function buildPreviewAnyValidationError(): NodeError & + PromptOutputsSkippedNodeError { return { class_type: 'PreviewAny', dependent_outputs: [VALIDATION_ERROR_NODE_ID], diff --git a/packages/api-client/src/ComfyApi.ts b/packages/api-client/src/ComfyApi.ts index ee13cd914dc..7ade7e770f2 100644 --- a/packages/api-client/src/ComfyApi.ts +++ b/packages/api-client/src/ComfyApi.ts @@ -4,7 +4,8 @@ import type { GetI18nResponse, ModelDownloadData, ModelFile, - PostAssetsFromWorkflowResponse + PostAssetsFromWorkflowResponse, + PromptOutputsSkippedData } from '@comfyorg/ingest-types' import { zGetEmbeddingsResponse, @@ -48,7 +49,6 @@ import type { ProgressStateWsMessage, ProgressTextWsMessage, ProgressWsMessage, - PromptOutputsSkippedWsMessage, StatusWsMessage, StatusWsMessageStatus } from './executionTypes' @@ -206,7 +206,7 @@ interface BackendApiCalls { execution_error: ExecutionErrorWsMessage execution_interrupted: ExecutionInterruptedWsMessage execution_cached: ExecutionCachedWsMessage - prompt_outputs_skipped: PromptOutputsSkippedWsMessage + prompt_outputs_skipped: PromptOutputsSkippedData logs: LogsWsMessage /** Binary preview/progress data */ b_preview: Blob diff --git a/packages/api-client/src/executionTypes.ts b/packages/api-client/src/executionTypes.ts index 1500265f2c1..22639644394 100644 --- a/packages/api-client/src/executionTypes.ts +++ b/packages/api-client/src/executionTypes.ts @@ -3,7 +3,6 @@ import type { PromptInfo } from '@comfyorg/ingest-types' import { z } from 'zod' import { zNodeId } from '@comfyorg/graph-model/workflowSchema' import type { TaskStatus } from './taskSchema' -import type { NodeError } from './types' import { resultItemType } from './resultItemTypeSchema' export type JobId = string @@ -112,12 +111,6 @@ export interface ExecutionErrorWsMessage extends ExecutionWsMessageBase { current_inputs?: unknown current_outputs?: unknown } -/** A node error as Cloud relays it: an entry in `errors` may be a bare string. */ -export type RelayedNodeError = Omit & { errors: unknown[] } -export interface PromptOutputsSkippedWsMessage { - prompt_id: JobId - node_errors: Record -} export interface ProgressTextWsMessage { nodeId: NodeId text: string diff --git a/packages/ingest-types/src/index.ts b/packages/ingest-types/src/index.ts index d3504a55ba7..0dd5d9e4aba 100644 --- a/packages/ingest-types/src/index.ts +++ b/packages/ingest-types/src/index.ts @@ -229,6 +229,17 @@ export type { BillingStatus, BillingStatusResponse, BillingTaxId, + Budget, + BudgetAlert, + BudgetChange, + BudgetCreateRequest, + BudgetHistory, + BudgetList, + BudgetMode, + BudgetRepeat, + BudgetScopeKind, + BudgetUpdateRequest, + BudgetWriteResult, BulkRevokeApiKeysResponse, BulkRevokeWorkspaceMemberApiKeysData, BulkRevokeWorkspaceMemberApiKeysError, @@ -373,6 +384,11 @@ export type { CreateAssetFromHashResponses, CreateAssetResponse, CreateAssetResponses, + CreateBillingBudgetData, + CreateBillingBudgetError, + CreateBillingBudgetErrors, + CreateBillingBudgetResponse, + CreateBillingBudgetResponses, CreateBillingHandoffData, CreateBillingHandoffError, CreateBillingHandoffErrors, @@ -491,6 +507,11 @@ export type { DeleteAssetErrors, DeleteAssetResponse, DeleteAssetResponses, + DeleteBillingBudgetData, + DeleteBillingBudgetError, + DeleteBillingBudgetErrors, + DeleteBillingBudgetResponse, + DeleteBillingBudgetResponses, DeleteCccItemData, DeleteCccItemError, DeleteCccItemErrors, @@ -671,6 +692,11 @@ export type { GetBillingBalanceErrors, GetBillingBalanceResponse, GetBillingBalanceResponses, + GetBillingBudgetHistoryData, + GetBillingBudgetHistoryError, + GetBillingBudgetHistoryErrors, + GetBillingBudgetHistoryResponse, + GetBillingBudgetHistoryResponses, GetBillingCapabilitiesData, GetBillingCapabilitiesError, GetBillingCapabilitiesErrors, @@ -1211,6 +1237,11 @@ export type { ListAssetsResponse2, ListAssetsResponses, ListAssetsResponseWritable, + ListBillingBudgetsData, + ListBillingBudgetsError, + ListBillingBudgetsErrors, + ListBillingBudgetsResponse, + ListBillingBudgetsResponses, ListCccAdminItemsData, ListCccAdminItemsError, ListCccAdminItemsErrors, @@ -1435,6 +1466,10 @@ export type { PreviousPlan, PromptErrorResponse, PromptInfo, + PromptOutputsSkippedData, + PromptOutputsSkippedFrame, + PromptOutputsSkippedNodeError, + PromptOutputsSkippedValidationError, PromptRequest, PromptResponse, ProviderCatalogResponse, @@ -1670,6 +1705,11 @@ export type { UpdateAssetErrors, UpdateAssetResponse, UpdateAssetResponses, + UpdateBillingBudgetData, + UpdateBillingBudgetError, + UpdateBillingBudgetErrors, + UpdateBillingBudgetResponse, + UpdateBillingBudgetResponses, UpdateBillingCompanyDetailsData, UpdateBillingCompanyDetailsError, UpdateBillingCompanyDetailsErrors, diff --git a/packages/ingest-types/src/types.gen.ts b/packages/ingest-types/src/types.gen.ts index ab21494e438..14b97e1b35a 100644 --- a/packages/ingest-types/src/types.gen.ts +++ b/packages/ingest-types/src/types.gen.ts @@ -3002,7 +3002,7 @@ export type BillingEvent = { */ member_user_id?: string /** - * Event-specific parameters + * Event-specific parameters. On a usage row, `credits_used` is what the row cost in credits. A `cloud_workflow_executed` (GPU run) row carries it when the usage ledger holds a charge for the run. Absent means the charge is unknown (a run from before the ledger began, an unpriced row, or the ledger could not be read); it must not be read as a free run. */ params?: { [key: string]: unknown @@ -3044,10 +3044,18 @@ export type BillingEventsResponse = { * Asks for a one-time handoff that signs a billing receiver tab in as the caller. */ export type BillingHandoffCreateRequest = { + /** + * Credit amount the top-up checkout opens with, in cents. Whole dollars within the manual top-up limits (`min_topup_cents` to `max_topup_cents` on GET /api/billing/balance). Allowed only with intent top-up, else 400 INVALID_REQUEST; omitted, billing-web uses its default. Sent in the entry URL's query after intent. Not a credential; the checkout validates the amount again. + */ + amount_cents?: number /** * Version of the issuing app, for logs. */ client_version: string + /** + * Page the receiver opens after the exchange: top-up opens the credit checkout, subscription the plan checkout, none the receiver's billing home. Only billing_web accepts one; platform answers 400 INVALID_REQUEST. Sent in the entry URL's query, never its fragment. It is not a credential and grants nothing. + */ + intent?: 'top-up' | 'subscription' /** * Billing app that will exchange the handoff; its origin is the only one the exchange accepts. */ @@ -3067,7 +3075,7 @@ export type BillingHandoffCreateRequest = { */ export type BillingHandoffCreateResponse = { /** - * The receiver's handoff page with the token in the fragment. Open it, never display it. + * The receiver's handoff page, with the intent and amount_cents (if any) in the query and the token in the fragment. Open it, never display it. */ entry_url: string /** @@ -3468,7 +3476,7 @@ export type BillingStatusResponse = { */ cancel_at?: string /** - * When the current billing period began. Together with renewal_date it is the range for "current billing period" views; render the pair as received rather than deriving one from the other. Present exactly when renewal_date is: omitted for a canceled plan, a never-subscribed workspace and a free plan with no subscription. + * When the current subscription term began. Together with renewal_date it is the term the plan renews over (a year on an annual plan); render the pair as received rather than deriving one from the other. It is not the window usage and budgets are counted over: use usage_period_start and usage_period_end for that. Present exactly when renewal_date is: omitted for a canceled plan, a never-subscribed workspace and a free plan with no subscription. */ current_period_start?: string /** @@ -3550,7 +3558,7 @@ export type BillingStatusResponse = { */ previous_plan?: PreviousPlan /** - * When the current billing period ends and the next one begins: the end of the period current_period_start begins. + * When the current subscription term ends and the next one begins: the end of the term current_period_start begins. */ renewal_date?: string renewal_invoice?: RenewalInvoice @@ -3585,6 +3593,14 @@ export type BillingStatusResponse = { * The team credit stop the workspace is currently subscribed to, for per-credit Team plans (BE-1254). Lets clients tell apart team subscriptions, which all share subscription_tier=TEAM. Always present; null for personal plans (use subscription_tier to distinguish those) and for legacy team plans without a credit stop. */ team_credit_stop: TeamCreditStopSummary | null + /** + * End (exclusive) of the period usage_period_start begins, and when a budget's spend next resets. Not the renewal date: on an annual plan it is the next monthly anniversary, and for a subscription set to cancel it is never later than the cancellation. + */ + usage_period_end?: string + /** + * Start of the billing period that current-period usage views and workspace budgets are counted over. Together with usage_period_end it answers "which range is this period's usage?"; request usage for exactly this pair so the usage page and a budget's spend show the same number. On an annual plan it is the monthly anniversary, so it must not be read as the plan's renewal term (that is current_period_start and renewal_date). On a monthly plan the two pairs usually agree, but render each as received: they are resolved separately and can differ for a subscription whose stored period is missing or out of date. Present exactly when usage_period_end is: omitted when the workspace has no subscription, or its subscription is scheduled, ended, or canceled and past its end. + */ + usage_period_start?: string } /** @@ -3604,6 +3620,181 @@ export type BillingTaxId = { value: string } +/** + * A budget with its spend in the workspace's current billing period. Amounts come in credits and in micro-USD; a client shows credits as received and never converts. + * + */ +export type Budget = { + /** + * The percentages of the limit at which an alert is sent, ascending. + */ + alert_percents: Array + /** + * Alerts sent for the budget in the current period. Always `[]` until alerting ships. + */ + alerts: Array + /** + * User id that created the budget. + */ + created_by: string + /** + * End of the last billing period the budget applies to; null when it repeats indefinitely. + */ + ends_at: string | null + id: string + /** + * The limit in credits, rounded to the nearest credit. + */ + limit_credits: number + /** + * The limit as stored, in micro-USD of list value. + */ + limit_micro_usd: number + mode: BudgetMode + /** + * Whole percent of the limit spent, rounded down, so 100 means the limit is reached. It can exceed 100. + * + */ + percent_used: number + repeat: BudgetRepeat + /** + * When spend next resets to 0: the end of the current billing period. Null when the workspace has no billing period. + * + */ + resets_at: string | null + /** + * The workspace id, the member's user id, the API key's prefix or the deployment id. + */ + scope_id: string + scope_kind: BudgetScopeKind + /** + * When the totals behind spent_micro_usd were last written. Shows how fresh the spend is: a deployment's usage arrives hourly. Null when the scope has spent nothing this period. + * + */ + spend_updated_at: string | null + /** + * spent_micro_usd in credits, rounded to the nearest credit. + */ + spent_credits: number + /** + * What the scope has spent since the current billing period began: the charged usage the usage page counts for the same range. A member budget counts session spend only; spend through the member's API keys counts toward the key. 0 when the workspace has no billing period. + * + */ + spent_micro_usd: number + /** + * User id that last changed the budget. + */ + updated_by: string +} + +export type BudgetAlert = { + percent: number + sent_at: string + status: string +} + +export type BudgetChange = { + action: 'created' | 'updated' | 'archived' | 'downgraded' + /** + * User id that made the change, or `system` for one the platform made. + */ + actor_user_id: string + /** + * The budget's settings after the change; null for `archived`. + */ + after: { + [key: string]: unknown + } | null + /** + * The budget's settings before the change; null for `created`. + */ + before: { + [key: string]: unknown + } | null + changed_at: string +} + +export type BudgetCreateRequest = { + /** + * Ascending, no repeats. Defaults to [50, 80, 100]. + */ + alert_percents?: Array + /** + * Required with `repeat: until`, and must be in the future; refused with any other repeat. + */ + ends_at?: string + /** + * The limit in credits. Send exactly one of limit_credits and limit_micro_usd. + */ + limit_credits?: number + /** + * The limit in micro-USD. Send exactly one of limit_credits and limit_micro_usd. + */ + limit_micro_usd?: number + mode: BudgetMode + /** + * Defaults to current_period. + */ + repeat?: BudgetRepeat + /** + * The workspace id (for `workspace`, it must be this workspace), the member's user id, the API key's prefix or the deployment id. + * + */ + scope_id: string + scope_kind: BudgetScopeKind +} + +export type BudgetHistory = { + changes: Array +} + +export type BudgetList = { + budgets: Array +} + +/** + * `soft` alerts at its thresholds and never refuses spend. `hard` also refuses spend once the limit is reached; Enterprise plans only. + * + */ +export type BudgetMode = 'hard' | 'soft' + +/** + * How long a budget applies. `current_period`: until the current billing period ends. `until`: through the period holding `ends_at`. `indefinitely`: every period, with no end. + * + */ +export type BudgetRepeat = 'current_period' | 'until' | 'indefinitely' + +/** + * What a budget limits. + */ +export type BudgetScopeKind = 'workspace' | 'member' | 'api_key' | 'deployment' + +export type BudgetUpdateRequest = { + /** + * Ascending, no repeats. + */ + alert_percents?: Array + /** + * With `repeat: until`, or alone (which means the same): the new end, in the future. Refused with any other repeat. + * + */ + ends_at?: string + /** + * The new limit in credits. Send at most one of limit_credits and limit_micro_usd. + */ + limit_credits?: number + /** + * The new limit in micro-USD. Send at most one of limit_credits and limit_micro_usd. + */ + limit_micro_usd?: number + mode?: BudgetMode + repeat?: BudgetRepeat +} + +export type BudgetWriteResult = { + budget: Budget +} + /** * Response after bulk-revoking API keys for a workspace member. */ @@ -6940,7 +7131,7 @@ export type OAuthConsentChallengeWorkspace = { /** * The platform this authorization code will be delivered to, when the * request's validated redirect_uri is one of a known platform's own OAuth - * callbacks (ChatGPT, Claude). Derived server-side ONLY from the + * callbacks (ChatGPT, Claude, Cursor). Derived server-side ONLY from the * redirect_uri this request was byte-matched against at GET time — * never from the registrant-supplied client_name — against a * version-controlled registry of exact callbacks and anchored callback @@ -6948,8 +7139,10 @@ export type OAuthConsentChallengeWorkspace = { * clients; omitted for first-party clients and for any redirect that is * not a registered platform callback. It verifies the destination * platform, NOT that the registrant is that platform's own app (any - * connector on the platform can hold such a callback), so consumers - * should label it by `display_name` and still show the redirect host. + * connector on the platform can hold such a callback, and any local + * process can listen on Cursor's loopback callback or claim its + * `cursor://` scheme), so consumers should label it by `display_name` + * and still show the redirect host. * `client_display_name` is unchanged and remains registrant-supplied. * */ @@ -6961,7 +7154,7 @@ export type OAuthConsentVerifiedClient = { /** * Stable identifier of the verified platform. */ - platform: 'chatgpt' | 'claude' + platform: 'chatgpt' | 'claude' | 'cursor' } /** @@ -7732,6 +7925,74 @@ export type PromptInfo = { } } +/** + * The `data` of a prompt_outputs_skipped WebSocket event. Sent when ComfyUI accepts a Cloud job's prompt but rejects some nodes: ComfyUI skips the outputs that depend on them and runs the rest, and the job keeps running. The inference server sends it to the user's channel (services/inference/server/services/joborchestrator/prompt_validation.go). Every string taken from ComfyUI has its lists of allowed values or file names replaced ("is not a valid value", "[list omitted]") and is capped at 512 characters. + */ +export type PromptOutputsSkippedData = { + /** + * The rejected nodes, keyed by node id, in the shape ComfyUI's /prompt returns. At most 50 nodes, the lowest ids kept, and 64 KiB as JSON. + */ + node_errors: { + [key: string]: PromptOutputsSkippedNodeError + } + /** + * The Cloud job id. + */ + prompt_id: string +} + +/** + * Server-to-client prompt_outputs_skipped frame on /ws. ComfyUI skipped some of a Cloud job's outputs because nodes failed validation. + */ +export type PromptOutputsSkippedFrame = { + data: PromptOutputsSkippedData + type: 'prompt_outputs_skipped' +} + +/** + * One rejected node in a prompt_outputs_skipped event. + */ +export type PromptOutputsSkippedNodeError = { + /** + * The node's type. Empty when ComfyUI sent none. + */ + class_type: string + /** + * The ids of the output nodes ComfyUI skipped because of this node, at most 50. Only ids ComfyUI sent as strings are kept; any other entry is dropped. + */ + dependent_outputs: Array + /** + * Why ComfyUI rejected the node, at most 10. A custom node's validator may report a bare string, which is sent as that string. Can be empty when the size cap left no room for the node's errors. + */ + errors: Array +} + +/** + * One validation error as ComfyUI reports it, with tracebacks and every other field removed. type, message and details are each present only when ComfyUI sent them as strings. + */ +export type PromptOutputsSkippedValidationError = { + details?: string + /** + * Only the keys the editor reads, each present when ComfyUI sent it. A list or object value becomes the string "[list omitted]". + */ + extra_info?: { + /** + * The input the error belongs to. + */ + input_name?: string | number | boolean + /** + * The type the node received. + */ + received_type?: string | number | boolean + /** + * The value the node received. + */ + received_value?: string | number | boolean + } + message?: string + type?: string +} + /** * Request body for submitting a ComfyUI workflow prompt for execution. */ @@ -12711,7 +12972,7 @@ export type CreateBillingHandoffData = { export type CreateBillingHandoffErrors = { /** - * `INVALID_REQUEST` + * `INVALID_REQUEST`, or `workspace_id_invalid`: X-Comfy-Workspace-ID or ?workspace_id= names another workspace than the body */ 400: ErrorResponse /** @@ -13307,6 +13568,294 @@ export type GetBillingBalanceResponses = { export type GetBillingBalanceResponse = GetBillingBalanceResponses[keyof GetBillingBalanceResponses] +export type ListBillingBudgetsData = { + body?: never + path?: never + query?: never + url: '/api/billing/budgets' +} + +export type ListBillingBudgetsErrors = { + /** + * `code` is `workspace_id_invalid`: the `X-Comfy-Workspace-ID` header or `workspace_id` query value is malformed, or conflicts with another value or with the workspace the credential resolves to. Answered only while `web_session_enabled` is on for the user. See the `WebSessionAuth` scheme. + */ + 400: ErrorResponse + /** + * No valid credential, or an `Authorization` header, `X-API-Key` header or `?token=` next to the session cookie that could not be read, which is refused rather than answered with the session. `code` is `UNAUTHORIZED`. + */ + 401: ErrorResponse + /** + * A refused request. For a web session, `code` is `workspace_access_denied` (the selected workspace is unknown, deleted, or the user is not a member; the three look the same), `no_workspace_access` (the account has no personal workspace and is a member of no live workspace), `origin_not_allowed` or `cross_site_request`; see the `WebSessionAuth` scheme. For any credential, `sso_required` means an SSO organization holds the account (its email is on the organization's verified domains) and the credential is not an SSO sign-in, or the workspace is an SSO organization's and the account is not on its domains or the credential is not an SSO sign-in; `organization_id`, when present, names the organization to sign in with. `account_outside_organization` means the workspace is an SSO organization's and the account is on none of its domains, so no sign-in admits it; `organization_id` names the workspace's organization. `personal_workspace_disabled` means the workspace is the account's personal one and an SSO organization holds the account, so it cannot use it; `organization_id` names that organization. `FORBIDDEN` is the route's own authorization check failing, such as an unverified email. On `GET /api/billing/churnkey/auth`, `NOT_ORIGINAL_OWNER` means the caller is not the workspace's creator; it is returned only when the rollout mode is `creator`. A credential this route does not take gets AuthTypeNotAllowedError instead, and so does the session while `web_session_enabled` is off for the user, unless the operation says it takes the session whatever `web_session_enabled` says. + */ + 403: ForbiddenError + /** + * Internal server error + */ + 500: ErrorResponse + /** + * `budgets_unavailable`: budgets are not available in this environment. + */ + 503: ErrorResponse +} + +export type ListBillingBudgetsError = + ListBillingBudgetsErrors[keyof ListBillingBudgetsErrors] + +export type ListBillingBudgetsResponses = { + /** + * Success + */ + 200: BudgetList +} + +export type ListBillingBudgetsResponse = + ListBillingBudgetsResponses[keyof ListBillingBudgetsResponses] + +export type CreateBillingBudgetData = { + body: BudgetCreateRequest + path?: never + query?: never + url: '/api/billing/budgets' +} + +export type CreateBillingBudgetErrors = { + /** + * `INVALID_REQUEST` (the body is not a JSON object), `invalid_budget` + * (unknown `scope_kind` or `mode`, no `scope_id`, a limit that is not + * positive, both or neither limit fields, bad `alert_percents`, + * `until` without a future `ends_at`, or `ends_at` with another + * `repeat`), or `workspace_id_invalid` (see SessionWorkspaceIDInvalid). + * + */ + 400: ErrorResponse + /** + * No valid credential, or an `Authorization` header, `X-API-Key` header or `?token=` next to the session cookie that could not be read, which is refused rather than answered with the session. `code` is `UNAUTHORIZED`. + */ + 401: ErrorResponse + /** + * `not_workspace_owner` (the caller is a member, not an owner), + * `plan_not_enterprise` (`mode: hard` on a plan without hard caps), + * `WORKSPACE_BLOCKED`, `api_key_not_allowed` (the request was made + * with an API key; budgets are changed from a signed-in session + * only), `INSUFFICIENT_SCOPE` (an OAuth session without the billing + * write scope; sent with a `WWW-Authenticate` insufficient_scope + * challenge), `FORBIDDEN` (the caller is no longer + * a member of the workspace, or a deployment budget was asked for + * with a credential that cannot be used to check the deployment; + * sign in again), or a session refusal (see SessionWriteForbidden). + * + */ + 403: ForbiddenError + /** + * `scope_not_found`: the member, API key or deployment is not in + * this workspace. A deployment id must be the canonical lower-case + * `dep-` form. + * + */ + 404: ErrorResponse + /** + * `budget_exists` (the scope already has a live budget) or + * `no_billing_period` (`repeat: current_period` on a workspace with + * no open paid subscription term). + * + */ + 409: ErrorResponse + /** + * Internal server error + */ + 500: ErrorResponse + /** + * `budgets_unavailable` (budgets are not available in this + * environment) or `deployment_check_unavailable` (the deployment + * service could not be asked about a deployment scope; retry). + * + */ + 503: ErrorResponse +} + +export type CreateBillingBudgetError = + CreateBillingBudgetErrors[keyof CreateBillingBudgetErrors] + +export type CreateBillingBudgetResponses = { + /** + * The new budget + */ + 201: BudgetWriteResult +} + +export type CreateBillingBudgetResponse = + CreateBillingBudgetResponses[keyof CreateBillingBudgetResponses] + +export type DeleteBillingBudgetData = { + body?: never + path: { + /** + * Budget id (`bud_…`). + */ + id: string + } + query?: never + url: '/api/billing/budgets/{id}' +} + +export type DeleteBillingBudgetErrors = { + /** + * `code` is `workspace_id_invalid`: the `X-Comfy-Workspace-ID` header or `workspace_id` query value is malformed, or conflicts with another value or with the workspace the credential resolves to. Answered only while `web_session_enabled` is on for the user. See the `WebSessionAuth` scheme. + */ + 400: ErrorResponse + /** + * No valid credential, or an `Authorization` header, `X-API-Key` header or `?token=` next to the session cookie that could not be read, which is refused rather than answered with the session. `code` is `UNAUTHORIZED`. + */ + 401: ErrorResponse + /** + * `not_workspace_owner`, `api_key_not_allowed` (the request was made with an API key), `INSUFFICIENT_SCOPE`, `FORBIDDEN` (the caller is no longer a member of the workspace), or a session refusal (see SessionWriteForbidden). + */ + 403: ForbiddenError + /** + * `budget_not_found`: unknown or already archived budget id. + */ + 404: ErrorResponse + /** + * Internal server error + */ + 500: ErrorResponse + /** + * `budgets_unavailable`: budgets are not available in this environment. + */ + 503: ErrorResponse +} + +export type DeleteBillingBudgetError = + DeleteBillingBudgetErrors[keyof DeleteBillingBudgetErrors] + +export type DeleteBillingBudgetResponses = { + /** + * Archived + */ + 204: void +} + +export type DeleteBillingBudgetResponse = + DeleteBillingBudgetResponses[keyof DeleteBillingBudgetResponses] + +export type UpdateBillingBudgetData = { + body: BudgetUpdateRequest + path: { + /** + * Budget id (`bud_…`). + */ + id: string + } + query?: never + url: '/api/billing/budgets/{id}' +} + +export type UpdateBillingBudgetErrors = { + /** + * `INVALID_REQUEST` (the body is not a JSON object), `invalid_budget` + * (as on create), or `workspace_id_invalid` (see + * SessionWorkspaceIDInvalid). + * + */ + 400: ErrorResponse + /** + * No valid credential, or an `Authorization` header, `X-API-Key` header or `?token=` next to the session cookie that could not be read, which is refused rather than answered with the session. `code` is `UNAUTHORIZED`. + */ + 401: ErrorResponse + /** + * `not_workspace_owner`, `plan_not_enterprise` (changing a soft + * budget to hard on a plan without hard caps), `WORKSPACE_BLOCKED`, + * `api_key_not_allowed` (the request was made with an API key), + * `INSUFFICIENT_SCOPE` (sent with a `WWW-Authenticate` + * insufficient_scope challenge), `FORBIDDEN` (the caller is no + * longer a member of the workspace), or a session refusal (see + * SessionWriteForbidden). + * + */ + 403: ForbiddenError + /** + * `budget_not_found`: unknown or archived budget id. + */ + 404: ErrorResponse + /** + * `no_billing_period`: `repeat: current_period` on a workspace with no open paid subscription term. + */ + 409: ErrorResponse + /** + * Internal server error + */ + 500: ErrorResponse + /** + * `budgets_unavailable`: budgets are not available in this environment. + */ + 503: ErrorResponse +} + +export type UpdateBillingBudgetError = + UpdateBillingBudgetErrors[keyof UpdateBillingBudgetErrors] + +export type UpdateBillingBudgetResponses = { + /** + * The budget after the change + */ + 200: BudgetWriteResult +} + +export type UpdateBillingBudgetResponse = + UpdateBillingBudgetResponses[keyof UpdateBillingBudgetResponses] + +export type GetBillingBudgetHistoryData = { + body?: never + path: { + /** + * Budget id (`bud_…`). + */ + id: string + } + query?: never + url: '/api/billing/budgets/{id}/history' +} + +export type GetBillingBudgetHistoryErrors = { + /** + * `code` is `workspace_id_invalid`: the `X-Comfy-Workspace-ID` header or `workspace_id` query value is malformed, or conflicts with another value or with the workspace the credential resolves to. Answered only while `web_session_enabled` is on for the user. See the `WebSessionAuth` scheme. + */ + 400: ErrorResponse + /** + * No valid credential, or an `Authorization` header, `X-API-Key` header or `?token=` next to the session cookie that could not be read, which is refused rather than answered with the session. `code` is `UNAUTHORIZED`. + */ + 401: ErrorResponse + /** + * `not_workspace_owner`, `FORBIDDEN` (the caller is no longer a member of the workspace), or a session refusal (see SessionForbidden). + */ + 403: ForbiddenError + /** + * `budget_not_found`: unknown or archived budget id. + */ + 404: ErrorResponse + /** + * Internal server error + */ + 500: ErrorResponse + /** + * `budgets_unavailable`: budgets are not available in this environment. + */ + 503: ErrorResponse +} + +export type GetBillingBudgetHistoryError = + GetBillingBudgetHistoryErrors[keyof GetBillingBudgetHistoryErrors] + +export type GetBillingBudgetHistoryResponses = { + /** + * Success + */ + 200: BudgetHistory +} + +export type GetBillingBudgetHistoryResponse = + GetBillingBudgetHistoryResponses[keyof GetBillingBudgetHistoryResponses] + export type GetBillingCapabilitiesData = { body?: never path?: never @@ -23207,6 +23756,10 @@ export type GetOAuthAuthorizeErrors = { * Invalid authorize request (pre-redirect failure — unknown client, redirect mismatch, malformed params). Content-negotiated; browser navigations (Accept includes text/html without application/json) receive a self-contained HTML error page instead of JSON. Or, always as JSON, `code` `workspace_id_invalid` (see SessionWorkspaceIDInvalid) for a token or API key whose workspace selector is malformed or names another workspace than its own, while `web_session_enabled` is on for its user. */ 400: ErrorResponse + /** + * `code` `login_required`: a resume request (`oauth_request_id` present) that is not a browser top-level navigation (Accept does not prefer text/html, as with the consent page's fetch) and has no signed-in session, or one whose email is unverified while email verification is on. The request stays open, so the client sends the user to sign in and resumes it. A browser navigation in the same state gets the 302 to login instead. + */ + 401: ErrorResponse /** * OAuth disabled */ diff --git a/packages/ingest-types/src/zod.gen.ts b/packages/ingest-types/src/zod.gen.ts index 3c54aa71ad0..2e6bfefa6b6 100644 --- a/packages/ingest-types/src/zod.gen.ts +++ b/packages/ingest-types/src/zod.gen.ts @@ -1578,7 +1578,13 @@ export const zBillingEventsResponse = z.object({ * Asks for a one-time handoff that signs a billing receiver tab in as the caller. */ export const zBillingHandoffCreateRequest = z.object({ + amount_cents: z.coerce + .bigint() + .gte(BigInt(500)) + .lte(BigInt(250000)) + .optional(), client_version: z.string().max(64), + intent: z.enum(['top-up', 'subscription']).optional(), receiver: z.enum(['billing_web', 'platform']), surface: z.enum(['local_web', 'desktop']), workspace_id: z.string().min(1) @@ -1679,6 +1685,165 @@ export const zBillingCompanyDetailsUpdateRequest = z.object({ tax_id: zBillingTaxId.optional() }) +export const zBudgetAlert = z.object({ + percent: z.int(), + sent_at: z.iso.datetime(), + status: z.string() +}) + +export const zBudgetChange = z.object({ + action: z.enum(['created', 'updated', 'archived', 'downgraded']), + actor_user_id: z.string(), + after: z.record(z.string(), z.unknown()).nullable(), + before: z.record(z.string(), z.unknown()).nullable(), + changed_at: z.iso.datetime() +}) + +export const zBudgetHistory = z.object({ + changes: z.array(zBudgetChange) +}) + +/** + * `soft` alerts at its thresholds and never refuses spend. `hard` also refuses spend once the limit is reached; Enterprise plans only. + * + */ +export const zBudgetMode = z.enum(['hard', 'soft']) + +/** + * How long a budget applies. `current_period`: until the current billing period ends. `until`: through the period holding `ends_at`. `indefinitely`: every period, with no end. + * + */ +export const zBudgetRepeat = z.enum(['current_period', 'until', 'indefinitely']) + +/** + * What a budget limits. + */ +export const zBudgetScopeKind = z.enum([ + 'workspace', + 'member', + 'api_key', + 'deployment' +]) + +/** + * A budget with its spend in the workspace's current billing period. Amounts come in credits and in micro-USD; a client shows credits as received and never converts. + * + */ +export const zBudget = z.object({ + alert_percents: z.array(z.int()), + alerts: z.array(zBudgetAlert), + created_by: z.string(), + ends_at: z.iso.datetime().nullable(), + id: z.string(), + limit_credits: z.coerce + .bigint() + .min(BigInt('-9223372036854775808'), { + error: 'Invalid value: Expected int64 to be >= -9223372036854775808' + }) + .max(BigInt('9223372036854775807'), { + error: 'Invalid value: Expected int64 to be <= 9223372036854775807' + }), + limit_micro_usd: z.coerce + .bigint() + .min(BigInt('-9223372036854775808'), { + error: 'Invalid value: Expected int64 to be >= -9223372036854775808' + }) + .max(BigInt('9223372036854775807'), { + error: 'Invalid value: Expected int64 to be <= 9223372036854775807' + }), + mode: zBudgetMode, + percent_used: z.coerce + .bigint() + .min(BigInt('-9223372036854775808'), { + error: 'Invalid value: Expected int64 to be >= -9223372036854775808' + }) + .max(BigInt('9223372036854775807'), { + error: 'Invalid value: Expected int64 to be <= 9223372036854775807' + }), + repeat: zBudgetRepeat, + resets_at: z.iso.datetime().nullable(), + scope_id: z.string(), + scope_kind: zBudgetScopeKind, + spend_updated_at: z.iso.datetime().nullable(), + spent_credits: z.coerce + .bigint() + .min(BigInt('-9223372036854775808'), { + error: 'Invalid value: Expected int64 to be >= -9223372036854775808' + }) + .max(BigInt('9223372036854775807'), { + error: 'Invalid value: Expected int64 to be <= 9223372036854775807' + }), + spent_micro_usd: z.coerce + .bigint() + .min(BigInt('-9223372036854775808'), { + error: 'Invalid value: Expected int64 to be >= -9223372036854775808' + }) + .max(BigInt('9223372036854775807'), { + error: 'Invalid value: Expected int64 to be <= 9223372036854775807' + }), + updated_by: z.string() +}) + +export const zBudgetCreateRequest = z.object({ + alert_percents: z.array(z.int().gte(1).lte(100)).min(1).max(5).optional(), + ends_at: z.iso.datetime().optional(), + limit_credits: z.coerce + .bigint() + .min(BigInt('-9223372036854775808'), { + error: 'Invalid value: Expected int64 to be >= -9223372036854775808' + }) + .max(BigInt('9223372036854775807'), { + error: 'Invalid value: Expected int64 to be <= 9223372036854775807' + }) + .optional(), + limit_micro_usd: z.coerce + .bigint() + .min(BigInt('-9223372036854775808'), { + error: 'Invalid value: Expected int64 to be >= -9223372036854775808' + }) + .max(BigInt('9223372036854775807'), { + error: 'Invalid value: Expected int64 to be <= 9223372036854775807' + }) + .optional(), + mode: zBudgetMode, + repeat: zBudgetRepeat.optional(), + scope_id: z.string(), + scope_kind: zBudgetScopeKind +}) + +export const zBudgetList = z.object({ + budgets: z.array(zBudget) +}) + +export const zBudgetUpdateRequest = z.object({ + alert_percents: z.array(z.int().gte(1).lte(100)).min(1).max(5).optional(), + ends_at: z.iso.datetime().optional(), + limit_credits: z.coerce + .bigint() + .min(BigInt('-9223372036854775808'), { + error: 'Invalid value: Expected int64 to be >= -9223372036854775808' + }) + .max(BigInt('9223372036854775807'), { + error: 'Invalid value: Expected int64 to be <= 9223372036854775807' + }) + .optional(), + limit_micro_usd: z.coerce + .bigint() + .min(BigInt('-9223372036854775808'), { + error: 'Invalid value: Expected int64 to be >= -9223372036854775808' + }) + .max(BigInt('9223372036854775807'), { + error: 'Invalid value: Expected int64 to be <= 9223372036854775807' + }) + .optional(), + mode: zBudgetMode.optional(), + repeat: zBudgetRepeat.optional() +}) + +export const zBudgetWriteResult = z.object({ + budget: zBudget +}) + /** * Response after bulk-revoking API keys for a workspace member. */ @@ -3828,7 +3993,7 @@ export const zOAuthConsentChallengeWorkspace = z.object({ /** * The platform this authorization code will be delivered to, when the * request's validated redirect_uri is one of a known platform's own OAuth - * callbacks (ChatGPT, Claude). Derived server-side ONLY from the + * callbacks (ChatGPT, Claude, Cursor). Derived server-side ONLY from the * redirect_uri this request was byte-matched against at GET time — * never from the registrant-supplied client_name — against a * version-controlled registry of exact callbacks and anchored callback @@ -3836,14 +4001,16 @@ export const zOAuthConsentChallengeWorkspace = z.object({ * clients; omitted for first-party clients and for any redirect that is * not a registered platform callback. It verifies the destination * platform, NOT that the registrant is that platform's own app (any - * connector on the platform can hold such a callback), so consumers - * should label it by `display_name` and still show the redirect host. + * connector on the platform can hold such a callback, and any local + * process can listen on Cursor's loopback callback or claim its + * `cursor://` scheme), so consumers should label it by `display_name` + * and still show the redirect host. * `client_display_name` is unchanged and remains registrant-supplied. * */ export const zOAuthConsentVerifiedClient = z.object({ display_name: z.string(), - platform: z.enum(['chatgpt', 'claude']) + platform: z.enum(['chatgpt', 'claude', 'cursor']) }) /** @@ -4174,6 +4341,47 @@ export const zPromptInfo = z.object({ .optional() }) +/** + * One validation error as ComfyUI reports it, with tracebacks and every other field removed. type, message and details are each present only when ComfyUI sent them as strings. + */ +export const zPromptOutputsSkippedValidationError = z.object({ + details: z.string().optional(), + extra_info: z + .object({ + input_name: z.union([z.string(), z.number(), z.boolean()]).optional(), + received_type: z.union([z.string(), z.number(), z.boolean()]).optional(), + received_value: z.union([z.string(), z.number(), z.boolean()]).optional() + }) + .optional(), + message: z.string().optional(), + type: z.string().optional() +}) + +/** + * One rejected node in a prompt_outputs_skipped event. + */ +export const zPromptOutputsSkippedNodeError = z.object({ + class_type: z.string(), + dependent_outputs: z.array(z.string()), + errors: z.array(z.union([z.string(), zPromptOutputsSkippedValidationError])) +}) + +/** + * The `data` of a prompt_outputs_skipped WebSocket event. Sent when ComfyUI accepts a Cloud job's prompt but rejects some nodes: ComfyUI skips the outputs that depend on them and runs the rest, and the job keeps running. The inference server sends it to the user's channel (services/inference/server/services/joborchestrator/prompt_validation.go). Every string taken from ComfyUI has its lists of allowed values or file names replaced ("is not a valid value", "[list omitted]") and is capped at 512 characters. + */ +export const zPromptOutputsSkippedData = z.object({ + node_errors: z.record(z.string(), zPromptOutputsSkippedNodeError), + prompt_id: z.string() +}) + +/** + * Server-to-client prompt_outputs_skipped frame on /ws. ComfyUI skipped some of a Cloud job's outputs because nodes failed validation. + */ +export const zPromptOutputsSkippedFrame = z.object({ + data: zPromptOutputsSkippedData, + type: z.enum(['prompt_outputs_skipped']) +}) + /** * Request body for submitting a ComfyUI workflow prompt for execution. */ @@ -5167,7 +5375,9 @@ export const zBillingStatusResponse = z.object({ subscription_state: zSubscriptionState.optional(), subscription_status: z.enum(['active', 'ended', 'canceled']).optional(), subscription_tier: zSubscriptionTier.optional(), - team_credit_stop: zTeamCreditStopSummary.nullable() + team_credit_stop: zTeamCreditStopSummary.nullable(), + usage_period_end: z.iso.datetime().optional(), + usage_period_start: z.iso.datetime().optional() }) /** @@ -6768,6 +6978,47 @@ export const zGetBillingAutoReloadPreviewResponse = zAutoReloadPreview */ export const zGetBillingBalanceResponse = zBillingBalanceResponse +/** + * Success + */ +export const zListBillingBudgetsResponse = zBudgetList + +export const zCreateBillingBudgetBody = zBudgetCreateRequest + +/** + * The new budget + */ +export const zCreateBillingBudgetResponse = zBudgetWriteResult + +export const zDeleteBillingBudgetPath = z.object({ + id: z.string() +}) + +/** + * Archived + */ +export const zDeleteBillingBudgetResponse = z.void() + +export const zUpdateBillingBudgetBody = zBudgetUpdateRequest + +export const zUpdateBillingBudgetPath = z.object({ + id: z.string() +}) + +/** + * The budget after the change + */ +export const zUpdateBillingBudgetResponse = zBudgetWriteResult + +export const zGetBillingBudgetHistoryPath = z.object({ + id: z.string() +}) + +/** + * Success + */ +export const zGetBillingBudgetHistoryResponse = zBudgetHistory + /** * Effective billing capabilities */ diff --git a/src/platform/cloud/oauth/OAuthConsentView.vue b/src/platform/cloud/oauth/OAuthConsentView.vue index e98e81e605e..c57913d0fa4 100644 --- a/src/platform/cloud/oauth/OAuthConsentView.vue +++ b/src/platform/cloud/oauth/OAuthConsentView.vue @@ -39,6 +39,7 @@ data-testid="client-verified" >