MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / getUniqueNodeLabel

Function getUniqueNodeLabel

packages/agentflow/src/core/utils/nodeFactory.ts:42–55  ·  view source on GitHub ↗
(nodeData: Pick<NodeData, 'name' | 'type' | 'label'>, nodes: FlowNode[])

Source from the content-addressed store, hash-verified

40 * Accepts both NodeDataSchema (from API) and NodeData (canvas nodes).
41 */
42export function getUniqueNodeLabel(nodeData: Pick<NodeData, 'name' | 'type' | 'label'>, nodes: FlowNode[]): string {
43 if (nodeData.type === 'StickyNote') return nodeData.label
44 if (nodeData.name === 'startAgentflow') return nodeData.label
45
46 let suffix = 0
47 let baseId = `${nodeData.name}_${suffix}`
48
49 while (nodes.some((node) => node.id === baseId)) {
50 suffix += 1
51 baseId = `${nodeData.name}_${suffix}`
52 }
53
54 return `${nodeData.label} ${suffix}`
55}
56
57/**
58 * Initialize default values for node parameters.

Callers 3

useFlowHandlersFunction · 0.90
useDragAndDropFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected