Skip to content

fix: properly clean up child nodes when deleting Iteration Box#13913

Open
octo-patch wants to merge 2 commits intoinfiniflow:mainfrom
octo-patch:fix/issue-13889-iteration-node-deletion
Open

fix: properly clean up child nodes when deleting Iteration Box#13913
octo-patch wants to merge 2 commits intoinfiniflow:mainfrom
octo-patch:fix/issue-13889-iteration-node-deletion

Conversation

@octo-patch
Copy link
Copy Markdown
Contributor

Fixes #13889

Problem

When an Iteration Box container is deleted (via keyboard Delete/Backspace), child nodes inside it are not properly cleaned up. They remain in the underlying data structure and the exported JSON file, which causes workflow editing instability, inability to link/connect nodes, node/edge rendering failures, and browser console exceptions.

There is also a secondary bug in deleteIterationNodeById (toolbar delete button): the edge filter uses && instead of ||, so edges connected to child nodes are never removed.

Solution

Fix 1: use-before-delete.tsx — When keyboard deletion triggers handleBeforeDelete, explicitly collect all child nodes (nodes with parentId matching the deleted Iteration Box ID) and include them in toBeDeletedNodes.

Fix 2: store.tsdeleteIterationNodeById — Fixed the edge filter from && to ||:

// Before (always false — no edge has source === target):
!children.some((child) => edge.source === child.id && edge.target === child.id)
// After:
!children.some((child) => edge.source === child.id || edge.target === child.id)

Testing

  1. Create an agent workflow with an Iteration Box containing nodes inside.
  2. Select the Iteration Box and press Delete/Backspace — child nodes should also be removed.
  3. Export the workflow JSON and verify no orphaned child nodes remain.
  4. Use toolbar delete button on Iteration Box — verify no dangling edges remain.

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Apr 3, 2026
@yingfeng yingfeng requested a review from cike8899 April 3, 2026 03:47
@cike8899
Copy link
Copy Markdown
Contributor

cike8899 commented Apr 3, 2026

Which version are you using? I haven't been able to reproduce this problem in the latest code on the main branch. @octo-patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Nodes inside Iteration Box persist in export and cause rendering errors after deletion

2 participants