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

Function AgentFlowNode

packages/ui/src/views/agentflowsv2/AgentFlowNode.jsx:61–705  ·  view source on GitHub ↗
({ data })

Source from the content-addressed store, hash-verified

59// ===========================|| CANVAS NODE ||=========================== //
60
61const AgentFlowNode = ({ data }) => {
62 const theme = useTheme()
63 const customization = useSelector((state) => state.customization)
64 const canvas = useSelector((state) => state.canvas)
65 const ref = useRef(null)
66 const updateNodeInternals = useUpdateNodeInternals()
67 // eslint-disable-next-line
68 const [position, setPosition] = useState(0)
69 const [isHovered, setIsHovered] = useState(false)
70 const [warningMessage, setWarningMessage] = useState('')
71 const { deleteNode, duplicateNode } = useContext(flowContext)
72 const [showInfoDialog, setShowInfoDialog] = useState(false)
73 const [infoDialogProps, setInfoDialogProps] = useState({})
74
75 const defaultColor = '#666666' // fallback color if data.color is not present
76 const nodeColor = data.color || defaultColor
77
78 // Get different shades of the color based on state
79 const getStateColor = () => {
80 if (data.selected) return nodeColor
81 if (isHovered) return alpha(nodeColor, 0.8)
82 return alpha(nodeColor, 0.5)
83 }
84
85 const getOutputAnchors = () => {
86 return data.outputAnchors ?? []
87 }
88
89 const getAnchorPosition = (index) => {
90 const currentHeight = ref.current?.clientHeight || 0
91 const spacing = currentHeight / (getOutputAnchors().length + 1)
92 const position = spacing * (index + 1)
93
94 // Update node internals when we get a non-zero position
95 if (position > 0) {
96 updateNodeInternals(data.id)
97 }
98
99 return position
100 }
101
102 const getMinimumHeight = () => {
103 const outputCount = getOutputAnchors().length
104 // Use exactly 60px as minimum height
105 return Math.max(60, outputCount * 20 + 40)
106 }
107
108 const getBackgroundColor = () => {
109 if (customization.isDarkMode) {
110 return isHovered ? darken(nodeColor, 0.7) : darken(nodeColor, 0.8)
111 }
112 return isHovered ? lighten(nodeColor, 0.8) : lighten(nodeColor, 0.9)
113 }
114
115 const getStatusBackgroundColor = (status) => {
116 switch (status) {
117 case 'ERROR':
118 return theme.palette.error.dark

Callers

nothing calls this directly

Calls 15

useUpdateNodeInternalsFunction · 0.90
duplicateNodeFunction · 0.85
deleteNodeFunction · 0.85
nodeVersionEmptyMessageFunction · 0.70
nodeOutdatedMessageFunction · 0.70
getStateColorFunction · 0.70
getMinimumHeightFunction · 0.70
getBackgroundColorFunction · 0.70
getStatusBackgroundColorFunction · 0.70
renderIconFunction · 0.70
getBuiltInOpenAIToolIconFunction · 0.70
getBuiltInGeminiToolIconFunction · 0.70

Tested by

no test coverage detected