mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-02-15 01:05:13 -05:00
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.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user