mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-02 12:11:58 +00:00
Integrate the existing node replacement functionality into the Errors Tab, allowing users to replace missing nodes directly from the side panel without opening the modal dialog. New components: - SwapNodesCard: container with guidance label and grouped rows - SwapNodeGroupRow: per-type replacement row with expand/collapse, node instance list, locate button, and replace action Bug fixes discovered during implementation: - Fix stale canvas rendering after replacement by calling onNodeAdded to refresh VueNodeData (bypassed by replaceWithMapping) - Guard initializeVueNodeLayout against duplicate layout creation - Fix missing node list being overwritten by incomplete server 400 response — replaced with full graph rescan via useMissingNodeScan - Add removeMissingNodesByType to prune replaced types from error list Cleanup: - Remove dead code: buildMissingNodeHint, createMissingNodeTypeFromError
28 lines
961 B
TypeScript
28 lines
961 B
TypeScript
import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
|
|
|
|
/**
|
|
* Extracts the custom node registry ID (cnr_id or aux_id) from a raw
|
|
* properties bag.
|
|
*
|
|
* @param properties - The properties object to inspect
|
|
* @returns The cnrId string, or undefined if not found
|
|
*/
|
|
export function getCnrIdFromProperties(
|
|
properties: Record<string, unknown> | undefined | null
|
|
): string | undefined {
|
|
if (typeof properties?.cnr_id === 'string') return properties.cnr_id
|
|
if (typeof properties?.aux_id === 'string') return properties.aux_id
|
|
return undefined
|
|
}
|
|
|
|
/**
|
|
* Extracts the custom node registry ID (cnr_id or aux_id) from a node's properties.
|
|
* Returns undefined if neither property is present.
|
|
*
|
|
* @param node - The graph node to inspect
|
|
* @returns The cnrId string, or undefined if not found
|
|
*/
|
|
export function getCnrIdFromNode(node: LGraphNode): string | undefined {
|
|
return getCnrIdFromProperties(node.properties as Record<string, unknown>)
|
|
}
|