From a913adc39f70961111af70b6ae4d5339eaf742ae Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com> Date: Thu, 12 Jun 2025 14:55:49 -0300 Subject: [PATCH] fix: paste edges between components selected even if edges are not selected (#8497) * Added pasting the edges between components selected as well * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- src/frontend/src/stores/flowStore.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/frontend/src/stores/flowStore.ts b/src/frontend/src/stores/flowStore.ts index fb7d75334..1dacfa3fc 100644 --- a/src/frontend/src/stores/flowStore.ts +++ b/src/frontend/src/stores/flowStore.ts @@ -385,6 +385,21 @@ const useFlowStore = create((set, get) => ({ track("Component Connection Deleted", { edgeId }); }, paste: (selection, position) => { + // Collect IDs of nodes in the selection + const selectedNodeIds = new Set(selection.nodes.map((node) => node.id)); + // Find existing edges in the flow that connect nodes within the selection + const existingEdgesToCopy = get().edges.filter((edge) => { + return ( + selectedNodeIds.has(edge.source) && + selectedNodeIds.has(edge.target) && + !selection.edges.some((selEdge) => selEdge.id === edge.id) + ); + }); + // Add these edges to the selection's edges + if (existingEdgesToCopy.length > 0) { + selection.edges = selection.edges.concat(existingEdgesToCopy); + } + if ( selection.nodes.some((node) => node.data.type === "ChatInput") && checkChatInput(get().nodes)