-
-
Notifications
You must be signed in to change notification settings - Fork 24.6k
fix: prevent duplicate chatflow creation on repeated save clicks #6553
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -217,6 +217,7 @@ const AgentflowCanvas = () => { | |
| } | ||
|
|
||
| const handleSaveFlow = (chatflowName) => { | ||
| if (createNewChatflowApi.loading) return | ||
| if (reactFlowInstance) { | ||
| const nodes = reactFlowInstance.getNodes().map((node) => { | ||
| const nodeData = cloneDeep(node.data) | ||
|
|
@@ -707,6 +708,7 @@ const AgentflowCanvas = () => { | |
| <CanvasHeader | ||
| chatflow={chatflow} | ||
| handleSaveFlow={handleSaveFlow} | ||
| isSaving={createNewChatflowApi.loading} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| handleDeleteFlow={handleDeleteFlow} | ||
| handleLoadFlow={handleLoadFlow} | ||
| isAgentCanvas={true} | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -209,6 +209,7 @@ const Canvas = () => { | |||||
| } | ||||||
|
|
||||||
| const handleSaveFlow = async (chatflowName) => { | ||||||
| if (createNewChatflowApi.loading) return | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the agentflow canvas, the guard here should also prevent concurrent saves when updating an existing flow. Since the update flow in this canvas involves checking if the chatflow has changed first, we should guard against
Suggested change
|
||||||
| if (reactFlowInstance) { | ||||||
| const nodes = reactFlowInstance.getNodes().map((node) => { | ||||||
| const nodeData = cloneDeep(node.data) | ||||||
|
|
@@ -574,6 +575,7 @@ const Canvas = () => { | |||||
| <CanvasHeader | ||||||
| chatflow={chatflow} | ||||||
| handleSaveFlow={handleSaveFlow} | ||||||
| isSaving={createNewChatflowApi.loading} | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
| handleDeleteFlow={handleDeleteFlow} | ||||||
| handleLoadFlow={handleLoadFlow} | ||||||
| isAgentCanvas={isAgentCanvas} | ||||||
|
|
||||||
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 current guard only checks
createNewChatflowApi.loading, which prevents duplicate requests when creating a new flow. However, if the user is updating an existing flow,updateChatflowApiis used instead. To prevent concurrent update requests, we should guard against both loading states.