From e19b6e458f4ab3426ba12e2f04c07af912e0dbd7 Mon Sep 17 00:00:00 2001 From: Otto Date: Sun, 15 Feb 2026 05:59:56 +0000 Subject: [PATCH] fix: always clear edge store when loading new graph Moved setEdges([]) outside the graph?.links guard to prevent stale edges from persisting when loading a graph with no links. --- .../(platform)/build/components/FlowEditor/Flow/useFlow.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/Flow/useFlow.ts b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/Flow/useFlow.ts index cee2bd1416..f60de8fbde 100644 --- a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/Flow/useFlow.ts +++ b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/Flow/useFlow.ts @@ -137,13 +137,15 @@ export const useFlow = () => { // Links depend on nodes existing, so we must add nodes first useEffect(() => { if (customNodes.length > 0) { + // Clear both stores to prevent stale data from previous graphs useNodeStore.getState().setNodes([]); useNodeStore.getState().clearResolutionState(); + useEdgeStore.getState().setEdges([]); + addNodes(customNodes); // Only add links after nodes are in the store if (graph?.links) { - useEdgeStore.getState().setEdges([]); addLinks(graph.links); } }