From 17be4879580bc486a73c43bc8d803cfb1e584802 Mon Sep 17 00:00:00 2001 From: Fu Diwei Date: Tue, 24 Jun 2025 20:26:01 +0800 Subject: [PATCH] fix: #815 --- ui/src/domain/workflow.ts | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/ui/src/domain/workflow.ts b/ui/src/domain/workflow.ts index 5304fe77..d37a16f5 100644 --- a/ui/src/domain/workflow.ts +++ b/ui/src/domain/workflow.ts @@ -544,6 +544,41 @@ export const cloneNode = (sourceNode: WorkflowNode, { withCopySuffix, nodeIdMap } } break; + + case WorkflowNodeType.Condition: + { + const stack = [] as Expr[]; + + const expr = (draft.config as WorkflowNodeConfigForCondition).expression; + if (expr) { + stack.push(expr); + + while (stack.length > 0) { + const n = stack.pop()!; + + if ("left" in n) { + stack.push(n.left); + + if ("selector" in n.left) { + const prevNodeId = n.left.selector.id; + if (nodeIdMap.has(prevNodeId)) { + n.left.selector.id = nodeIdMap.get(prevNodeId)!; + } + } + } + + if ("right" in n) { + stack.push(n.right); + } + } + + draft.config = { + ...draft.config, + expression: expr, + } as WorkflowNodeConfigForCondition; + } + } + break; } }