Line data Source code
1 : import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
2 : import { useMissingMediaStore } from '@/platform/workflowErrors/missingMedia/missingMediaStore'
3 : import { useMissingModelStore } from '@/platform/workflowErrors/missingModel/missingModelStore'
4 : import { useMissingNodesErrorStore } from '@/platform/workflowErrors/nodeReplacement/missingNodesErrorStore'
5 : import { useExecutionErrorStore } from '@/stores/executionErrorStore'
6 : import type { NodeState } from '@comfyorg/graph-model/nodeState'
7 : import { locatorIdFromState } from '@/utils/graphTraversalUtil'
8 : import type { UUID } from '@/utils/uuid'
9 :
10 : /** Reads the error stores directly; `node.has_errors` is untracked and would latch. */
11 21628 : export function nodeHasError(
12 : state: NodeState,
13 : rootGraphId: UUID | undefined,
14 : node: LGraphNode | null
15 : ): boolean {
16 21628 : const executionErrorStore = useExecutionErrorStore()
17 21628 : const missingModelStore = useMissingModelStore()
18 21628 : const missingMediaStore = useMissingMediaStore()
19 :
20 21628 : const locatorId = locatorIdFromState(state, rootGraphId)
21 : const hasNodeScopedError =
22 : locatorId !== null &&
23 : !!(
24 : executionErrorStore.lastExecutionErrorNodeLocatorId === locatorId ||
25 : executionErrorStore.getNodeErrors(locatorId) ||
26 : missingModelStore.hasMissingModelOnNode(locatorId) ||
27 : missingMediaStore.hasMissingMediaOnNode(locatorId)
28 : )
29 21628 : if (hasNodeScopedError) return true
30 :
31 21628 : return (
32 : node !== null &&
33 : (executionErrorStore.isContainerWithInternalError(node) ||
34 : useMissingNodesErrorStore().isContainerWithMissingNode(node) ||
35 : missingModelStore.isContainerWithMissingModel(node) ||
36 : missingMediaStore.isContainerWithMissingMedia(node))
37 : )
38 : }
39 :
40 21268 : export function getNodeErrorSeverity(
41 : state: NodeState,
42 : rootGraphId: UUID | undefined,
43 : node: LGraphNode | null
44 : ): 'none' | 'missing' | 'error' {
45 21268 : const locator = locatorIdFromState(state, rootGraphId)
46 21268 : if (
47 : locator &&
48 : useExecutionErrorStore().blockingErrorNodeLocatorIds.has(locator)
49 : ) {
50 11 : return 'error'
51 : }
52 21268 : return nodeHasError(state, rootGraphId, node) ? 'missing' : 'none'
53 : }
|