diff --git a/invokeai/frontend/web/src/features/nodes/hooks/useCopyPaste.ts b/invokeai/frontend/web/src/features/nodes/hooks/useCopyPaste.ts index 32db806cde0..2a2bfde904c 100644 --- a/invokeai/frontend/web/src/features/nodes/hooks/useCopyPaste.ts +++ b/invokeai/frontend/web/src/features/nodes/hooks/useCopyPaste.ts @@ -59,17 +59,19 @@ const pasteSelection = (withEdgesToCopiedNodes?: boolean) => { for (const edge of copiedEdges) { if (edge.source === node.id) { edge.source = id; - edge.id = edge.id.replace(node.data.id, id); - } - if (edge.target === node.id) { + } else if (edge.target === node.id) { edge.target = id; - edge.id = edge.id.replace(node.data.id, id); } } node.id = id; node.data.id = id; }); + copiedEdges.forEach((edge) => { + // Copied edges need a fresh id too + edge.id = uuidv4(); + }); + const nodeChanges: NodeChange[] = []; const edgeChanges: EdgeChange[] = []; // Deselect existing nodes