LCOV - code coverage report
Current view: top level - src/platform/workflowErrors/nodeReplacement - missingNodeScan.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 94.4 % 18 17
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import { LiteGraph } from '@/lib/litegraph/src/litegraph'
       2              : import type { LGraph } from '@/lib/litegraph/src/litegraph'
       3              : import { LGraphEventMode } from '@comfyorg/graph-model/globalEnums'
       4              : import { useNodeReplacementStore } from '@/platform/workflowErrors/nodeReplacement/nodeReplacementStore'
       5              : import { useExecutionErrorStore } from '@/stores/executionErrorStore'
       6              : import { useMissingNodesErrorStore } from '@/platform/workflowErrors/nodeReplacement/missingNodesErrorStore'
       7              : import type { MissingNodeType } from '@/platform/workflowErrors/nodeReplacement/types'
       8              : import {
       9              :   collectAllNodes,
      10              :   getExecutionIdByNode
      11              : } from '@/utils/graphTraversalUtil'
      12              : import { getCnrIdFromNode } from '@/platform/workflowErrors/nodeReplacement/cnrIdUtil'
      13              : 
      14              : /** Scan the live graph for unregistered node types and build a full MissingNodeType list. */
      15            1 : function scanMissingNodes(rootGraph: LGraph): MissingNodeType[] {
      16            1 :   const nodeReplacementStore = useNodeReplacementStore()
      17            1 :   const missingNodeTypes: MissingNodeType[] = []
      18              : 
      19            1 :   const allNodes = collectAllNodes(rootGraph)
      20              : 
      21            1 :   for (const node of allNodes) {
      22            1 :     if (
      23              :       node.mode === LGraphEventMode.NEVER ||
      24              :       node.mode === LGraphEventMode.BYPASS
      25              :     )
      26            0 :       continue
      27              : 
      28            1 :     const originalType = node.last_serialization?.type ?? node.type
      29              : 
      30            1 :     if (originalType in LiteGraph.registered_node_types) continue
      31              : 
      32            1 :     const cnrId = getCnrIdFromNode(node)
      33            1 :     const replacement = nodeReplacementStore.getReplacementFor(originalType)
      34            1 :     const executionId = getExecutionIdByNode(rootGraph, node)
      35              : 
      36            1 :     missingNodeTypes.push({
      37              :       type: originalType,
      38              :       nodeId: executionId ?? String(node.id),
      39              :       cnrId,
      40              :       isReplaceable: replacement !== null,
      41              :       replacement: replacement ?? undefined
      42              :     })
      43              :   }
      44              : 
      45            1 :   return missingNodeTypes
      46              : }
      47              : 
      48              : /** Re-scan the graph for missing nodes and update the error store. */
      49            1 : export function rescanAndSurfaceMissingNodes(rootGraph: LGraph): void {
      50            1 :   const types = scanMissingNodes(rootGraph)
      51            1 :   if (useMissingNodesErrorStore().surfaceMissingNodes(types)) {
      52            1 :     useExecutionErrorStore().showErrorOverlay()
      53              :   }
      54              : }
        

Generated by: LCOV version 2.0-1