-
- Notifications
You must be signed in to change notification settings - Fork 23.1k
fix: agentflow list refresh after deletion (Issue #5360) #5473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: agentflow list refresh after deletion (Issue #5360) #5473
Conversation
Root Cause: When deleting an Agentflow from the list view, updateFlowsApi.request() was called without pagination parameters. This caused the backend to return a plain array instead of the expected { data: [], total: 0 } format, leading to a TypeError when accessing .data.length. Solution: - Created refreshAgentflows callback that includes current pagination state - Passed callback through FlowListTable to FlowListMenu - Updated handleDelete to use callback instead of direct API call - Maintains backward compatibility for components without callback Fixes FlowiseAI#5360 Summary of ChangesHello @aibysid, 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 a critical bug in the Agentflow list view where deleting an item would lead to a UI error due to an unexpected API response format. The solution introduces a more robust and flexible refresh mechanism that correctly updates the list post-deletion, ensuring data consistency and a smoother user experience. It also improves error handling and maintains backward compatibility. Highlights
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
The pull request effectively addresses the issue of agentflow list refresh after deletion by introducing an onRefresh callback mechanism. This ensures that the list is properly updated, especially when dealing with paginated data, preventing TypeError issues. The changes are well-structured, passing the callback through components and updating the deletion logic to utilize it. The addition of more detailed error logging is also a good improvement for maintainability.
| if (getAllAgentflows.data) { | ||
| try { | ||
| const agentflows = getAllAgentflows.data?.data | ||
| setTotal(getAllAgentflows.data?.total) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The setTotal call here might not correctly reflect the total number of items when getAllAgentflows.data is a plain array. According to the root cause, the backend might return a plain array instead of an object with data and total properties. If getAllAgentflows.data is a plain array, getAllAgentflows.data?.total will be undefined, leading to an incorrect total count for pagination. You should adjust this line to use the length of flowsArray if getAllAgentflows.data is an array, or getAllAgentflows.data?.total otherwise.
| setTotal(getAllAgentflows.data?.total) | |
| setTotal(Array.isArray(getAllAgentflows.data) ? getAllAgentflows.data.length : getAllAgentflows.data?.total) |
| console.error('❌ Error processing agentflows data:', e) | ||
| console.error('Data that caused error:', getAllAgentflows.data) | ||
| console.error('Error stack:', e.stack) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| @aibysid thank you so much for all the PR! We'll get these reviewed ASAP! |
Root Cause:
When deleting an Agentflow from the list view, updateFlowsApi.request() was called without pagination parameters. This caused the backend to return a plain array instead of the expected { data: [], total: 0 } format, leading to a TypeError when accessing .data.length.
Solution:
Note : This change is backward compatible will not break existing delete functionality cheers !
Fixes #5360