-
-
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
Open
aibysid
wants to merge
1
commit into
FlowiseAI:main
Choose a base branch
from
aibysid:fix/issue-5360-agentflow-delete-refresh
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,6 +68,10 @@ const Agentflows = () => { | |
| getAllAgentflows.request(nextView === 'v2' ? 'AGENTFLOW' : 'MULTIAGENT', params) | ||
| } | ||
|
|
||
| const refreshAgentflows = () => { | ||
| refresh(currentPage, pageLimit, agentflowVersion) | ||
| } | ||
|
|
||
| const handleChange = (event, nextView) => { | ||
| if (nextView === null) return | ||
| localStorage.setItem('flowDisplayStyle', nextView) | ||
|
|
@@ -138,21 +142,27 @@ const Agentflows = () => { | |
| setTotal(getAllAgentflows.data?.total) | ||
| const images = {} | ||
| const icons = {} | ||
| for (let i = 0; i < agentflows.length; i += 1) { | ||
| const flowDataStr = agentflows[i].flowData | ||
|
|
||
| // Safety check: handle both array and object response formats | ||
| const flowsArray = Array.isArray(getAllAgentflows.data) | ||
| ? getAllAgentflows.data | ||
| : (agentflows || []) | ||
|
|
||
| for (let i = 0; i < flowsArray.length; i += 1) { | ||
| const flowDataStr = flowsArray[i].flowData | ||
| const flowData = JSON.parse(flowDataStr) | ||
| const nodes = flowData.nodes || [] | ||
| images[agentflows[i].id] = [] | ||
| icons[agentflows[i].id] = [] | ||
| images[flowsArray[i].id] = [] | ||
| icons[flowsArray[i].id] = [] | ||
| for (let j = 0; j < nodes.length; j += 1) { | ||
| if (nodes[j].data.name === 'stickyNote' || nodes[j].data.name === 'stickyNoteAgentflow') continue | ||
| const foundIcon = AGENTFLOW_ICONS.find((icon) => icon.name === nodes[j].data.name) | ||
| if (foundIcon) { | ||
| icons[agentflows[i].id].push(foundIcon) | ||
| icons[flowsArray[i].id].push(foundIcon) | ||
| } else { | ||
| const imageSrc = `${baseURL}/api/v1/node-icon/${nodes[j].data.name}` | ||
| if (!images[agentflows[i].id].some((img) => img.imageSrc === imageSrc)) { | ||
| images[agentflows[i].id].push({ | ||
| if (!images[flowsArray[i].id].some((img) => img.imageSrc === imageSrc)) { | ||
| images[flowsArray[i].id].push({ | ||
| imageSrc, | ||
| label: nodes[j].data.label | ||
| }) | ||
|
|
@@ -163,7 +173,9 @@ const Agentflows = () => { | |
| setImages(images) | ||
| setIcons(icons) | ||
| } catch (e) { | ||
| console.error(e) | ||
| console.error('❌ Error processing agentflows data:', e) | ||
| console.error('Data that caused error:', getAllAgentflows.data) | ||
| console.error('Error stack:', e.stack) | ||
|
Comment on lines
+176
to
+178
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. |
||
| } | ||
| } | ||
| }, [getAllAgentflows.data]) | ||
|
|
@@ -324,6 +336,7 @@ const Agentflows = () => { | |
| isLoading={isLoading} | ||
| filterFunction={filterFlows} | ||
| updateFlowsApi={getAllAgentflows} | ||
| onRefresh={refreshAgentflows} | ||
| setError={setError} | ||
| /> | ||
| )} | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
setTotalcall here might not correctly reflect the total number of items whengetAllAgentflows.datais a plain array. According to the root cause, the backend might return a plain array instead of an object withdataandtotalproperties. IfgetAllAgentflows.datais a plain array,getAllAgentflows.data?.totalwill beundefined, leading to an incorrect total count for pagination. You should adjust this line to use the length offlowsArrayifgetAllAgentflows.datais an array, orgetAllAgentflows.data?.totalotherwise.