Fix(agentflow): fix duplicate and drag bug and make behavior similar to v2#5850
Fix(agentflow): fix duplicate and drag bug and make behavior similar to v2#5850
Conversation
Summary of ChangesHello @j-sanaa, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses critical bugs and enhances the core node management features within Agentflow, specifically focusing on duplication and deletion. The changes ensure that duplicating nodes results in properly configured, uniquely identified, and correctly positioned new nodes, while deleting nodes now includes comprehensive cleanup of connected inputs and all child nodes. These updates aim to provide a more stable and intuitive user experience, aligning the behavior with the expected functionality of v2. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces significant improvements to node deletion and duplication functionality in Agentflow. The deleteNode function now correctly handles child nodes and cleans up connections, while duplicateNode has been enhanced to better match v2 behavior, including improved positioning, ID and label generation, and proper handling of connections on duplicated nodes. A comprehensive set of tests has been added to cover these new behaviors.
My review focuses on improving the robustness of the new logic. I've identified a couple of areas where the implementation could be more resilient to edge cases, particularly in how connection strings are parsed and how labels for duplicated nodes are generated. The proposed suggestions aim to make these functions more reliable.
packages/agentflow/src/infrastructure/store/AgentflowContext.tsx
Outdated
Show resolved
Hide resolved
| id: newNodeId | ||
| ...clonedNode.data, | ||
| id: newNodeId, | ||
| label: clonedNode.data.label + ` (${newNodeId.split('_').pop()})` |
There was a problem hiding this comment.
When duplicating a node that has already been duplicated, the label generation will append another suffix, resulting in labels like My Node (1) (2). It would be more robust to first strip any existing suffix from the original label before appending the new one.
| label: clonedNode.data.label + ` (${newNodeId.split('_').pop()})` | |
| label: clonedNode.data.label.replace(/\s\(\d+\)$/, '') + ` (${newNodeId.split('_').pop()})` |
There was a problem hiding this comment.
The original v2 implementation has suffix added to the original label and the same behavior is mirrored in agentflow sdk


Before changefix:
Before.fix.mov
After fix
After.fix.mov