From 2b9816cfa5030eacb52d525f4462afb5a8b5436b Mon Sep 17 00:00:00 2001 From: Abhimanyu Yadav <122007096+Abhi1992002@users.noreply.github.com> Date: Thu, 4 Dec 2025 20:43:13 +0530 Subject: [PATCH] fix(frontend): ensure node selection state is set before copying in context menu (#11535) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes an issue where copying a node via the context menu dialog fails on the first attempt in a new session. The problem occurs because the node selection state update and the copy operation happen in quick succession, causing a race condition where `copySelectedNodes()` reads the store before the selection state is properly updated. ### Checklist 📋 - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: - [x] Start a new browser session (or clear storage) - [x] Open the flow editor - [x] Right-click on a node and select "Copy Node" from the context menu - [x] Verify the node is successfully copied on the first attempt --- .../FlowEditor/nodes/CustomNode/components/NodeContextMenu.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/CustomNode/components/NodeContextMenu.tsx b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/CustomNode/components/NodeContextMenu.tsx index 3aefb81d91..6e482122f6 100644 --- a/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/CustomNode/components/NodeContextMenu.tsx +++ b/autogpt_platform/frontend/src/app/(platform)/build/components/FlowEditor/nodes/CustomNode/components/NodeContextMenu.tsx @@ -28,6 +28,7 @@ export const NodeContextMenu = ({ })), })); + useCopyPasteStore.getState().copySelectedNodes(); useCopyPasteStore.getState().pasteNodes(); };