From 5d8ba8f8ccd47c2304440a05af6c1c6047def8d8 Mon Sep 17 00:00:00 2001 From: zhsama Date: Fri, 30 Jan 2026 01:30:42 +0800 Subject: [PATCH] feat: Recursively delete nested children (sub-graph) when removing nodes --- .../workflow/hooks/use-nodes-interactions.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/web/app/components/workflow/hooks/use-nodes-interactions.ts b/web/app/components/workflow/hooks/use-nodes-interactions.ts index d73d4e2c38..deaded0ba3 100644 --- a/web/app/components/workflow/hooks/use-nodes-interactions.ts +++ b/web/app/components/workflow/hooks/use-nodes-interactions.ts @@ -1041,6 +1041,20 @@ export const useNodesInteractions = () => { } } + const nestedChildren = nodes.filter((node) => { + const parentNodeId = node.data.parent_node_id + if (parentNodeId === currentNode.id) + return true + if (!parentNodeId && node.id.startsWith(`${currentNode.id}_ext_`)) + return true + return false + }) + if (nestedChildren.length) { + nestedChildren.forEach((child) => { + handleNodeDelete(child.id) + }) + } + if (currentNode.data.type === BlockEnum.DataSource) { const { id } = currentNode const { ragPipelineVariables, setRagPipelineVariables } @@ -2278,7 +2292,6 @@ export const useNodesInteractions = () => { if (bundledNodes.length) { bundledNodes.forEach(node => handleNodeDelete(node.id)) - return }