fix: HumanInput node should unable to paste into container (#34077)

This commit is contained in:
非法操作 2026-03-25 17:22:21 +08:00 committed by GitHub
parent 7fbb1c96db
commit 0e6d97acf9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1820,21 +1820,26 @@ export const useNodesInteractions = () => {
newChildren.push(newLoopStartNode!)
}
else {
// single node paste
// Paste a single regular node. Loop/Iteration nodes are handled above.
const selectedNode = nodes.find(node => node.selected)
let pastedToNestedBlock = false
if (selectedNode) {
// Keep this list aligned with availableBlocksFilter(inContainer)
// in use-available-blocks.ts.
const commonNestedDisallowPasteNodes = [
// end node only can be placed outermost layer
BlockEnum.End,
BlockEnum.Iteration,
BlockEnum.Loop,
BlockEnum.DataSource,
BlockEnum.KnowledgeBase,
BlockEnum.HumanInput,
]
// handle disallow paste node
if (commonNestedDisallowPasteNodes.includes(nodeToPaste.data.type))
return
// handle paste to nested block
// If a Loop/Iteration container is selected, paste into it as a child.
if (selectedNode.data.type === BlockEnum.Iteration || selectedNode.data.type === BlockEnum.Loop) {
const isIteration = selectedNode.data.type === BlockEnum.Iteration
@ -1849,10 +1854,10 @@ export const useNodesInteractions = () => {
x: newNode.position.x,
y: newNode.position.y,
}
// set position base on parent node
// Rebase position into the selected container coordinate system.
newNode.position = getNestedNodePosition(newNode, selectedNode)
// update parent children array like native add
// Mirror native add behavior by appending parent._children.
parentChildrenToAppend.push({ parentId: selectedNode.id, childId: newNode.id, childType: newNode.data.type })
pastedToNestedBlock = true