1+ import { LGraphNode } from '@comfyorg/litegraph'
2+ import { NodeProperty } from '@comfyorg/litegraph/dist/LGraphNode'
3+ import { groupBy } from 'lodash'
14import { computed , onMounted } from 'vue'
25
36import { useWorkflowPacks } from '@/composables/nodePack/useWorkflowPacks'
7+ import { app } from '@/scripts/app'
48import { useComfyManagerStore } from '@/stores/comfyManagerStore'
9+ import { useNodeDefStore } from '@/stores/nodeDefStore'
510import type { components } from '@/types/comfyRegistryTypes'
611
712/**
@@ -10,6 +15,7 @@ import type { components } from '@/types/comfyRegistryTypes'
1015 * Automatically fetches workflow pack data when initialized
1116 */
1217export const useMissingNodes = ( ) => {
18+ const nodeDefStore = useNodeDefStore ( )
1319 const comfyManagerStore = useComfyManagerStore ( )
1420 const { workflowPacks, isLoading, error, startFetchWorkflowPacks } =
1521 useWorkflowPacks ( )
@@ -24,6 +30,36 @@ export const useMissingNodes = () => {
2430 return filterMissingPacks ( workflowPacks . value )
2531 } )
2632
33+ /**
34+ * Check if a pack is the ComfyUI builtin node pack (nodes that come pre-installed)
35+ * @param packId - The id of the pack to check
36+ * @returns True if the pack is the comfy-core pack, false otherwise
37+ */
38+ const isCorePack = ( packId : NodeProperty ) => {
39+ return packId === 'comfy-core'
40+ }
41+
42+ /**
43+ * Check if a node is a missing core node
44+ * A missing core node is a node that is in the workflow and originates from
45+ * the comfy-core pack (pre-installed) but not registered in the node def
46+ * store (the node def was not found on the server)
47+ * @param node - The node to check
48+ * @returns True if the node is a missing core node, false otherwise
49+ */
50+ const isMissingCoreNode = ( node : LGraphNode ) => {
51+ const packId = node . properties ?. cnr_id
52+ if ( packId === undefined || ! isCorePack ( packId ) ) return false
53+ const nodeName = node . type
54+ const isRegisteredNodeDef = ! ! nodeDefStore . nodeDefsByName [ nodeName ]
55+ return ! isRegisteredNodeDef
56+ }
57+
58+ const missingCoreNodes = computed < Record < string , LGraphNode [ ] > > ( ( ) => {
59+ const missingNodes = app . graph . nodes . filter ( isMissingCoreNode )
60+ return groupBy ( missingNodes , ( node ) => String ( node . properties ?. ver || '' ) )
61+ } )
62+
2763 // Automatically fetch workflow pack data when composable is used
2864 onMounted ( async ( ) => {
2965 if ( ! workflowPacks . value . length && ! isLoading . value ) {
@@ -33,6 +69,7 @@ export const useMissingNodes = () => {
3369
3470 return {
3571 missingNodePacks,
72+ missingCoreNodes,
3673 isLoading,
3774 error
3875 }
0 commit comments