AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
feat(autogpt_builder) Add logic for node disconnection (#7386)
Aarushib89609fd16be
diff --git a/rnd/autogpt_builder/src/components/Flow.tsx b/rnd/autogpt_builder/src/components/Flow.tsxindex a2d5ebf352..de37c89f55 100644--- a/rnd/autogpt_builder/src/components/Flow.tsx+++ b/rnd/autogpt_builder/src/components/Flow.tsx@@ -137,6 +137,30 @@ const FlowEditor: React.FC<{ flowID?: string; className?: string }> = ({[setEdges, setNodes]);+ const onEdgesDelete = useCallback(+ (edgesToDelete: Edge[]) => {+ setNodes((nds) =>+ nds.map((node) => ({+ ...node,+ data: {+ ...node.data,+ connections: node.data.connections.filter(+ (conn: any) =>+ !edgesToDelete.some(+ (edge) =>+ edge.source === conn.source &&+ edge.target === conn.target &&+ edge.sourceHandle === conn.sourceHandle &&+ edge.targetHandle === conn.targetHandle+ )+ ),+ },+ }))+ );+ },+ [setNodes]+);+const addNode = (blockId: string, nodeType: string) => {const nodeSchema = availableNodes.find(node => node.id === blockId);if (!nodeSchema) {@@ -433,6 +457,7 @@ const FlowEditor: React.FC<{ flowID?: string; className?: string }> = ({onEdgesChange={onEdgesChange}onConnect={onConnect}nodeTypes={nodeTypes}+ onEdgesDelete={onEdgesDelete}><div style={{ position: 'absolute', right: 10, zIndex: 4 }}><Input