Browse Source

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 <noreply@anthropic.com>
handoff-20260429-1057
shrimbly 5 months ago
parent
commit
486a7b139a
  1. 9
      src/store/workflowStore.ts

9
src/store/workflowStore.ts

@ -1457,6 +1457,15 @@ export const useWorkflowStore = create<WorkflowStore>((set, get) => ({
return edge;
});
// Deduplicate edges by ID (keep the last occurrence, which is the most recent)
const edgeById = new Map<string, WorkflowEdge>();
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;

Loading…
Cancel
Save