fix: preserve flow content when renaming a flow#5801
fix: preserve flow content when renaming a flow#5801hztBUAA wants to merge 1 commit intoFlowiseAI:mainfrom
Conversation
The FlowListMenu rename and category update functions had two issues: 1. The rename dialog was not closed after a successful rename, leaving the user in an ambiguous state. 2. Both saveFlowRename and saveFlowCategory used the useApi hook to call updateChatflow. The useApi hook's internal error handling calls ErrorContext.setError(), which causes the parent Chatflows page to render an ErrorBoundary instead of the flow list. By using chatflowsApi.updateChatflow directly, errors are properly caught in the local try/catch without polluting the page-level error state. 3. Both functions unnecessarily included the entire chatflow object in the update request body. Only the changed field (name or category) needs to be sent. 4. Added optional chaining on error.response?.data to prevent crashes when the error object lacks a response property.
Summary of ChangesHello @hztBUAA, 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 where renaming or updating a flow's category would cause the flow overview to appear empty due to an issue with how API errors were propagated. The changes involve refactoring the API call mechanism to handle errors locally, optimizing the data sent in update requests, and enhancing the robustness of error message extraction, thereby ensuring the UI remains stable and responsive during these operations. 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 effectively addresses the reported bug where renaming a flow caused the overview to appear empty. The changes correctly remove the useApi hook to prevent page-level error state pollution, ensure the rename dialog closes on success, and optimize API calls by sending only changed fields. The addition of optional chaining for error handling is a good practice.
I am having trouble creating individual review comments. Click here to see my feedback.
packages/ui/src/ui-component/button/FlowListMenu.jsx (178-183)
The updateBody object was created but only the name property was used in the updateChatflow call. This was unnecessary and has been correctly removed, simplifying the code.
packages/ui/src/ui-component/button/FlowListMenu.jsx (195)
The addition of optional chaining (?.) to error.response?.data is a good practice. It prevents potential crashes if error.response is undefined or null, improving the robustness of error handling.
packages/ui/src/ui-component/button/FlowListMenu.jsx (230-232)
Similar to the saveFlowRename function, the updateBody object was created but only the category property was used. Its removal simplifies the code and makes the API call more direct.
packages/ui/src/ui-component/button/FlowListMenu.jsx (238)
The addition of optional chaining (?.) to error.response?.data is a good practice. It prevents potential crashes if error.response is undefined or null, improving the robustness of error handling.
|
Thanks for the review and feedback. I am following up on this PR now and will either push the requested changes or reply point-by-point shortly. |
|
Quick follow-up: I am reviewing the feedback and will update this PR shortly. |
Summary
Fixes #5736 - Renaming a flow from the list view caused the flow overview to appear empty.
Root cause:
saveFlowRenameandsaveFlowCategoryinFlowListMenuused theuseApihook to callupdateChatflow. TheuseApihook's internal error handling callsErrorContext.setError(), which shares state with the parent Chatflows page. If the update triggered any error (even transient), it would cause the page to render anErrorBoundaryinstead of the flow list, making it appear empty.Changes:
chatflowsApi.updateChatflowdirectly instead of throughuseApi, so errors are caught locally in try/catch without polluting the page-level error statesetFlowDialogOpen(false)) — previously it stayed open after confirming{ name }or{ category }) in the request body — previously the entirechatflowobject was unnecessarily includederror.response?.datato prevent crashes when the error lacks a response propertyTest plan