Skip to content

feat(agentFlow): Fix duplicate node and add test cases for delete and duplicate nodes#5840

Merged
j-sanaa merged 11 commits intomainfrom
feat/agentflow-sdk-delete-and-duplicate-node
Feb 25, 2026
Merged

feat(agentFlow): Fix duplicate node and add test cases for delete and duplicate nodes#5840
j-sanaa merged 11 commits intomainfrom
feat/agentflow-sdk-delete-and-duplicate-node

Conversation

@j-sanaa
Copy link
Contributor

@j-sanaa j-sanaa commented Feb 24, 2026

NOTE: Bug where duplicate nodes are dragged together (shown in recording) will be resolved in a separate PR

Screen.Recording.2026-02-24.at.2.00.15.PM.mov

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 focuses on enhancing the Agentflow component by fixing a critical bug in node duplication, adding comprehensive test coverage for node operations, and improving the synchronization between the ReactFlow canvas and the AgentflowContext. These changes ensure data integrity, provide confidence in the stability of node operations, and improve the overall user experience by maintaining a consistent and up-to-date canvas.

Highlights

  • Bug Fix: Addressed a bug where node.data.id was not updated during node duplication, ensuring data consistency.
  • Test Coverage: Introduced new test cases for node deletion and duplication functionalities within the AgentflowContext.
  • Canvas Updates: Implemented a fix to ensure the canvas updates correctly after bidirectional sync refactoring when using clear() and addNode().
  • Code Improvements: Refactored state synchronization between ReactFlow and AgentflowContext using syncNodesFromReactFlow and syncEdgesFromReactFlow.
Changelog
  • Agentflow.tsx
    • Refactored state synchronization using syncNodesFromReactFlow and syncEdgesFromReactFlow.
    • Renamed onFlowChange, onSave, and onFlowGenerated props to _flow to avoid naming conflicts.
  • AgentflowContext.test.tsx
    • Added comprehensive test suite for deleteNode functionality, including tests for removing nodes, edges, and handling non-existent nodes.
    • Added comprehensive test suite for duplicateNode functionality, including tests for creating duplicates with unique IDs, preserving node data, and handling sequential duplications.
  • AgentflowContext.tsx
    • Added syncNodesFromReactFlow and syncEdgesFromReactFlow methods to synchronize ReactFlow state with the context.
    • Fixed a bug in duplicateNode where node.data.id was not updated, causing inconsistencies.
    • Implemented time-based unique IDs for duplicated nodes.
    • Implemented logic to offset the position of duplicated nodes by 50 pixels on both the x and y axes.
Activity
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces several valuable changes, including a fix for a bug in node duplication, the addition of comprehensive test cases for node deletion and duplication, and a refactoring of state synchronization logic. The fixes and tests significantly improve the robustness of the agent flow feature. I've identified a few areas for improvement, primarily concerning the reliability of unique ID generation and the robustness of the new tests. My detailed comments are below.

@j-sanaa
Copy link
Contributor Author

j-sanaa commented Feb 24, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces several valuable improvements. It fixes a bug in node duplication where the node.data.id was not updated, and makes the unique ID generation for duplicates more robust. It also refactors state synchronization between the React Flow canvas and the central context, which resolves an issue with clear() and addNode() not updating the canvas. The addition of comprehensive unit tests for deleteNode and duplicateNode is a great enhancement for maintainability. My feedback includes a suggestion to improve the performance of the new unique ID generation function and to remove an outdated comment in the new test file. Overall, this is a high-quality contribution.

j-sanaa and others added 3 commits February 24, 2026 14:52
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@j-sanaa j-sanaa marked this pull request as ready for review February 24, 2026 23:25
@jocelynlin-wd
Copy link
Contributor

the issue with duplicate node shown in the recording (identical node name and nodes are dragged together etc) will be handled in a separate PR

@j-sanaa j-sanaa merged commit df5507c into main Feb 25, 2026
7 checks passed
@j-sanaa j-sanaa deleted the feat/agentflow-sdk-delete-and-duplicate-node branch February 25, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants