@@ -15,11 +15,11 @@ export const useEdgeConnection = (edges, updateEdges, setHistoryState, nodes, wo
1515 // Determine edge type based on source and target node types
1616 const sourceNode = nodes . find ( node => node . id === connection . source ) ;
1717 const targetNode = nodes . find ( node => node . id === connection . target ) ;
18-
18+
1919 let edgeType = 'simple' ;
2020 let edgeClass = 'edge-simple edge-animated' ;
2121 let strokeColor = '#10b981' ; // success color
22-
22+
2323 // Determine edge styling based on node types and source handle
2424 if ( sourceNode ?. type === 'switch' ) {
2525 // Check if this is a default edge from a switch node
@@ -41,30 +41,30 @@ export const useEdgeConnection = (edges, updateEdges, setHistoryState, nodes, wo
4141 edgeClass = 'edge-simple edge-animated' ;
4242 strokeColor = '#10b981' ; // success color
4343 }
44-
44+
4545 // Create styled edge with proper configuration
4646 const newEdge = {
4747 ...connection ,
4848 id : `${ connection . source } -to-${ connection . target } ` ,
4949 type : 'default' ,
5050 className : edgeClass ,
51- style : {
51+ style : {
5252 strokeWidth : edgeType === 'end' ? 3 : 2 ,
5353 stroke : strokeColor
5454 } ,
55- data : {
55+ data : {
5656 type : edgeType ,
5757 sourceNodeType : sourceNode ?. type ,
5858 targetNodeType : targetNode ?. type
5959 } ,
60- labelStyle : {
61- fill : strokeColor ,
62- fontWeight : 500 ,
63- fontSize : '12px'
60+ labelStyle : {
61+ fill : strokeColor ,
62+ fontWeight : 500 ,
63+ fontSize : '12px'
6464 } ,
65- labelBgStyle : {
66- fill : 'white' ,
67- fillOpacity : 0.9
65+ labelBgStyle : {
66+ fill : 'white' ,
67+ fillOpacity : 0.9
6868 } ,
6969 labelBgPadding : [ 6 , 3 ] ,
7070 labelBgBorderRadius : 4 ,
@@ -75,27 +75,37 @@ export const useEdgeConnection = (edges, updateEdges, setHistoryState, nodes, wo
7575 color : strokeColor
7676 } ,
7777 } ;
78-
78+
7979 // Add label based on edge type
8080 if ( edgeType === 'condition' ) {
81- newEdge . label = 'condition' ;
81+ // Extract condition information from source node
82+ if ( connection . sourceHandle && connection . sourceHandle . startsWith ( 'condition-' ) ) {
83+ const conditionIndex = parseInt ( connection . sourceHandle . replace ( 'condition-' , '' ) ) ;
84+ const conditions = sourceNode ?. data ?. dataConditions || sourceNode ?. data ?. eventConditions || [ ] ;
85+ const condition = conditions [ conditionIndex ] ;
86+
87+ // Use condition name, eventRef, condition expression, or fallback to generic label
88+ newEdge . label = condition ?. name || condition ?. eventRef || condition ?. condition || `condition${ conditionIndex + 1 } ` ;
89+ } else {
90+ newEdge . label = 'condition' ;
91+ }
8292 } else if ( edgeType === 'default' ) {
8393 newEdge . label = 'default' ;
8494 } else if ( edgeType === 'end' ) {
8595 newEdge . label = 'end' ;
8696 } else {
8797 newEdge . label = `→ ${ targetNode ?. data ?. name || targetNode ?. data ?. label || 'next' } ` ;
8898 }
89-
99+
90100 const updatedEdges = addEdge ( newEdge , edges ) ;
91101 updateEdges ( updatedEdges ) ;
92-
102+
93103 // Update history if setHistoryState is provided
94104 if ( setHistoryState ) {
95105 setHistoryState ( { nodes, edges : updatedEdges , workflowMetadata } ) ;
96106 }
97107 } , [ edges , updateEdges , setHistoryState , nodes , workflowMetadata ] ) ;
98-
108+
99109 return onConnect ;
100110} ;
101111
0 commit comments