From 486a7b139acded1461c8f4d53efacdeb68ec6f23 Mon Sep 17 00:00:00 2001 From: shrimbly Date: Fri, 20 Feb 2026 22:33:42 +1300 Subject: [PATCH] fix: deduplicate edges by ID during workflow load Saved workflows can contain multiple edges with the same ID (from repeated connections or migration normalization). React warns about duplicate keys and may render edges incorrectly. Deduplicate by keeping the last occurrence of each edge ID on load. Co-Authored-By: Claude Opus 4.6 --- src/store/workflowStore.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/store/workflowStore.ts b/src/store/workflowStore.ts index c018b2b4..e239a17c 100644 --- a/src/store/workflowStore.ts +++ b/src/store/workflowStore.ts @@ -1457,6 +1457,15 @@ export const useWorkflowStore = create((set, get) => ({ return edge; }); + // Deduplicate edges by ID (keep the last occurrence, which is the most recent) + const edgeById = new Map(); + for (const edge of workflow.edges) { + edgeById.set(edge.id, edge); + } + if (edgeById.size < workflow.edges.length) { + workflow.edges = Array.from(edgeById.values()); + } + // Look up saved config from localStorage (only if workflow has an ID) const configs = loadSaveConfigs(); const savedConfig = workflow.id ? configs[workflow.id] : null;