feat(agentflow): wire functionality to edit nodes#5786
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 introduces a significant new feature allowing users to edit the properties of individual nodes within the Agentflow canvas. This is achieved through a new Highlights
Changelog
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
The pull request introduces node editing functionality, including a new dialog and toolbar actions. The implementation is functional but contains a critical issue in Agentflow.tsx where a circular update loop is created between local and global states. There are also several unused variables and minor cleanup opportunities in the new hooks and components.
| const { openEditDialog } = useAgentflowContext() | ||
| const { availableNodes } = useFlowNodes() | ||
| const ref = useRef<HTMLDivElement>(null) |
There was a problem hiding this comment.
The variables openEditDialog and availableNodes are destructured from their respective hooks but are not used within this component. They should be removed to keep the component clean.
| const { openEditDialog } = useAgentflowContext() | |
| const { availableNodes } = useFlowNodes() | |
| const ref = useRef<HTMLDivElement>(null) | |
| const ref = useRef<HTMLDivElement>(null) |
packages/agentflow/src/features/canvas/hooks/useOpenNodeEditor.ts
Outdated
Show resolved
Hide resolved
packages/agentflow/src/features/canvas/hooks/useOpenNodeEditor.ts
Outdated
Show resolved
Hide resolved
packages/agentflow/src/features/canvas/hooks/useOpenNodeEditor.ts
Outdated
Show resolved
Hide resolved
|
/gemini review |
There was a problem hiding this comment.
Code Review
The pull request successfully implements the node editing functionality, including the UI triggers (double-click and toolbar icon) and the underlying state management. The refactoring of inputs to inputValues correctly distinguishes between parameter definitions and user-provided data. However, there are some concerns regarding state management practices, specifically direct prop mutation in the StickyNote component and the brittle synchronization logic in the main Agentflow component. Addressing these will improve the stability and maintainability of the application.
packages/agentflow/src/features/canvas/hooks/useOpenNodeEditor.ts
Outdated
Show resolved
Hide resolved
packages/agentflow/src/features/canvas/hooks/useOpenNodeEditor.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Code Review
This pull request successfully implements the node editing functionality, including a new edit dialog, a toolbar button, and double-click support. The refactoring of inputs to inputValues to separate input definitions from their values is a great improvement for code clarity. I've identified a few areas for improvement: a complex state synchronization logic in Agentflow.tsx that could be simplified, a direct state mutation in StickyNote.tsx, and a potential UI flicker in the EditNodeDialog due to a removed cleanup function. Addressing these points will improve the robustness and maintainability of the new feature.
I am having trouble creating individual review comments. Click here to see my feedback.
packages/agentflow/src/Agentflow.tsx (78-119)
The current implementation for synchronizing state between React Flow's internal state (useNodesState, useEdgesState) and the AgentflowContext is quite complex. Using refs (syncingToContext, syncingFromContext) and setTimeout to prevent circular updates can be brittle and hard to maintain. A more robust and standard approach with React Flow is to use a single source of truth. The AgentflowContext should be the single source of truth for nodes and edges. The AgentflowCanvas component can then consume this state directly without needing its own local state via useNodesState/useEdgesState. Changes from React Flow (like node drags) can be dispatched to the context reducer using the onNodesChange and onEdgesChange callbacks combined with applyNodeChanges and applyEdgeChanges helpers from React Flow. This would eliminate the need for the complex two-way sync logic and make the state management more predictable.
packages/agentflow/src/features/canvas/containers/StickyNote.tsx (60-64)
The onChange handler directly mutates the data.inputValues property of the data prop. This is an anti-pattern in React and can lead to unpredictable rendering. Instead, you should treat props as immutable and use a state update function to propagate changes. You can use the updateNodeData function from useAgentflowContext to correctly update the node's data in the central store. You'll need to import useAgentflowContext and get updateNodeData from it.
onChange={(e) => {
if (inputParam) {
updateNodeData(data.id, {
inputValues: {
...data.inputValues,
[inputParam.name]: e.target.value
}
})
}
}}
packages/agentflow/src/features/node-editor/EditNodeDialog.tsx (68-71)
This cleanup function was useful for resetting the dialog's state. Its removal could lead to a UI flicker where old data is briefly shown when opening the dialog for a new node. I'd recommend keeping this cleanup logic to ensure the dialog always starts with a fresh state. You might also consider resetting nodeName here for completeness.
Screen.Recording.2026-02-20.at.10.44.41.AM.mov