Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix(workflow): clear loop/iteration metadata when pasting node outside container (#29983)

lifc6c271539572
diff --git a/web/app/components/workflow/hooks/use-nodes-interactions.ts b/web/app/components/workflow/hooks/use-nodes-interactions.ts
index cd35d2310f9..8de86edecbe 100644
--- a/web/app/components/workflow/hooks/use-nodes-interactions.ts
+++ b/web/app/components/workflow/hooks/use-nodes-interactions.ts
@@ -1822,6 +1822,8 @@ export const useNodesInteractions = () => {
else {
// single node paste
const selectedNode = nodes.find(node => node.selected)
+ let pastedToNestedBlock = false
+
if (selectedNode) {
const commonNestedDisallowPasteNodes = [
// end node only can be placed outermost layer
@@ -1849,10 +1851,24 @@ export const useNodesInteractions = () => {
}
// set position base on parent node
newNode.position = getNestedNodePosition(newNode, selectedNode)
+
// update parent children array like native add
parentChildrenToAppend.push({ parentId: selectedNode.id, childId: newNode.id, childType: newNode.data.type })
+
+ pastedToNestedBlock = true
}
}
+
+ // Clear loop/iteration metadata when pasting outside nested blocks (fixes #29835)
+ // This ensures nodes copied from inside Loop/Iteration are properly independent
+ // when pasted outside
+ if (!pastedToNestedBlock) {
+ newNode.data.isInLoop = false
+ newNode.data.loop_id = undefined
+ newNode.data.isInIteration = false
+ newNode.data.iteration_id = undefined
+ newNode.parentId = undefined
+ }
}
idMapping[nodeToPaste.id] = newNode.id