@ -533,39 +533,36 @@ export const useWorkflowStore = create<WorkflowStore>((set, get) => ({
} ,
} ,
onConnect : ( connection : Connection , edgeDataOverrides? : Record < string , unknown > ) = > {
onConnect : ( connection : Connection , edgeDataOverrides? : Record < string , unknown > ) = > {
set ( ( state ) = > ( {
set ( ( state ) = > {
edges : addEdge (
( ( ) = > {
const baseData = buildConnectionEdgeData ( connection , state . nodes , state . edges ) ;
const baseData = buildConnectionEdgeData ( connection , state . nodes , state . edges ) ;
return {
const newEdge = {
. . . connection ,
. . . connection ,
id : ` edge- ${ connection . source } - ${ connection . target } - ${ connection . sourceHandle || "default" } - ${ connection . targetHandle || "default" } ` ,
id : ` edge- ${ connection . source } - ${ connection . target } - ${ connection . sourceHandle || "default" } - ${ connection . targetHandle || "default" } ` ,
data : edgeDataOverrides ? { . . . baseData , . . . edgeDataOverrides } : baseData ,
data : edgeDataOverrides ? { . . . baseData , . . . edgeDataOverrides } : baseData ,
} ;
} ;
} ) ( ) ,
// Cast needed: React Flow's Edge<T> types data as T | undefined, but addEdge expects data to be defined
state . edges
return {
) ,
edges : addEdge ( newEdge , state . edges as never ) as WorkflowEdge [ ] ,
hasUnsavedChanges : true ,
hasUnsavedChanges : true ,
} ) ) ;
} ;
} ) ;
get ( ) . incrementManualChangeCount ( ) ;
get ( ) . incrementManualChangeCount ( ) ;
} ,
} ,
addEdgeWithType : ( connection : Connection , edgeType : string , edgeDataOverrides? : Record < string , unknown > ) = > {
addEdgeWithType : ( connection : Connection , edgeType : string , edgeDataOverrides? : Record < string , unknown > ) = > {
set ( ( state ) = > ( {
set ( ( state ) = > {
edges : addEdge (
( ( ) = > {
const baseData = buildConnectionEdgeData ( connection , state . nodes , state . edges ) ;
const baseData = buildConnectionEdgeData ( connection , state . nodes , state . edges ) ;
return {
const newEdge = {
. . . connection ,
. . . connection ,
id : ` edge- ${ connection . source } - ${ connection . target } - ${ connection . sourceHandle || "default" } - ${ connection . targetHandle || "default" } ` ,
id : ` edge- ${ connection . source } - ${ connection . target } - ${ connection . sourceHandle || "default" } - ${ connection . targetHandle || "default" } ` ,
type : edgeType ,
type : edgeType ,
data : edgeDataOverrides ? { . . . baseData , . . . edgeDataOverrides } : baseData ,
data : edgeDataOverrides ? { . . . baseData , . . . edgeDataOverrides } : baseData ,
} ;
} ;
} ) ( ) ,
return {
state . edges
edges : addEdge ( newEdge , state . edges as never ) as WorkflowEdge [ ] ,
) ,
hasUnsavedChanges : true ,
hasUnsavedChanges : true ,
} ) ) ;
} ;
} ) ;
} ,
} ,
removeEdge : ( edgeId : string ) = > {
removeEdge : ( edgeId : string ) = > {