mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-04 20:50:06 +00:00
fix: don't use registry when only checking for presence of missing nodes (#6965)
Changes the client-side validation of whether a graph has missing nodes to use a simpler check (is the node name in the node defs from `/object_info`), rather than using the Comfy Node Registry API (api.comfy.org). The Registry API is still needed to get full metadata/info about missing nodes, but that can be deferred until the user actually needs that info. This also fixes an issue where a node you coded yourself locally which is neither a core node nor a node in the registry would be considered "missing." ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6965-fix-don-t-use-registry-when-only-checking-for-presence-of-missing-nodes-2b76d73d365081e7b8fbcb3f2a1c4502) by [Unito](https://www.unito.io)
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { unref } from 'vue'
|
||||
import type { MaybeRef } from 'vue'
|
||||
|
||||
import type {
|
||||
LGraph,
|
||||
LGraphNode,
|
||||
Subgraph
|
||||
} from '@/lib/litegraph/src/litegraph'
|
||||
import type { ComfyNodeDefImpl } from '@/stores/nodeDefStore'
|
||||
import { collectAllNodes } from '@/utils/graphTraversalUtil'
|
||||
|
||||
export type NodeDefLookup = Record<string, ComfyNodeDefImpl | undefined>
|
||||
|
||||
const isNodeMissingDefinition = (
|
||||
node: LGraphNode,
|
||||
nodeDefsByName: NodeDefLookup
|
||||
) => {
|
||||
const nodeName = node?.type
|
||||
if (!nodeName) return false
|
||||
return !nodeDefsByName[nodeName]
|
||||
}
|
||||
|
||||
export const collectMissingNodes = (
|
||||
graph: LGraph | Subgraph | null | undefined,
|
||||
nodeDefsByName: MaybeRef<NodeDefLookup>
|
||||
): LGraphNode[] => {
|
||||
if (!graph) return []
|
||||
const lookup = unref(nodeDefsByName)
|
||||
return collectAllNodes(graph, (node) => isNodeMissingDefinition(node, lookup))
|
||||
}
|
||||
|
||||
export const graphHasMissingNodes = (
|
||||
graph: LGraph | Subgraph | null | undefined,
|
||||
nodeDefsByName: MaybeRef<NodeDefLookup>
|
||||
) => {
|
||||
return collectMissingNodes(graph, nodeDefsByName).length > 0
|
||||
}
|
||||
Reference in New Issue
Block a user