From ac3bd5161c434a2b32186003ed01a58f4a16da8e Mon Sep 17 00:00:00 2001 From: hjlarry Date: Fri, 10 Oct 2025 13:26:55 +0800 Subject: [PATCH] keep the previous private property when import node data --- .../collaboration/core/collaboration-manager.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/web/app/components/workflow/collaboration/core/collaboration-manager.ts b/web/app/components/workflow/collaboration/core/collaboration-manager.ts index 39750d9d7d..afc7580f45 100644 --- a/web/app/components/workflow/collaboration/core/collaboration-manager.ts +++ b/web/app/components/workflow/collaboration/core/collaboration-manager.ts @@ -724,9 +724,9 @@ export class CollaborationManager { } requestAnimationFrame(() => { - // Get ReactFlow's native setters, not the collaborative ones const state = this.reactFlowStore.getState() const previousNodes: Node[] = state.getNodes() + const previousNodeMap = new Map(previousNodes.map(node => [node.id, node])) const selectedIds = new Set( previousNodes .filter(node => node.data?.selected) @@ -742,6 +742,16 @@ export class CollaborationManager { ...(node.data || {}), }, } + // Keep the previous node's private data properties (starting with _) + const previousNode = previousNodeMap.get(clonedNode.id) + if (previousNode?.data) { + Object.entries(previousNode.data) + .filter(([key]) => key.startsWith('_')) + .forEach(([key, value]) => { + if (!(key in clonedNode.data)) + clonedNode.data[key] = value + }) + } if (selectedIds.has(clonedNode.id)) clonedNode.data.selected = true