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:
Otto
2026-02-15 05:59:56 +00:00
parent 2be589c95f
commit e19b6e458f

View File

@@ -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);
}
}