Skip to content

Commit c4f7686

Browse files
[backport cloud/1.32] [bugfix] Fix execute button incorrectly disabled on empty workflows (#6776)
Backport of #6774 to `cloud/1.32` Automatically created by backport workflow. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6776-backport-cloud-1-32-bugfix-Fix-execute-button-incorrectly-disabled-on-empty-workflows-2b16d73d36508115936aed57d1474bf5) by [Unito](https://www.unito.io) Co-authored-by: Jin Yi <[email protected]>
1 parent 14d94da commit c4f7686

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/workbench/extensions/manager/composables/nodePack/useWorkflowPacks.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ export const useWorkflowPacks = (options: UseNodePacksOptions = {}) => {
114114
const getWorkflowPacks = async () => {
115115
if (!app.graph) return []
116116
const allNodes = collectAllNodes(app.graph)
117-
if (!allNodes.length) return []
117+
if (!allNodes.length) {
118+
workflowPacks.value = []
119+
return []
120+
}
118121
const packs = await Promise.all(allNodes.map(workflowNodeToPack))
119122
workflowPacks.value = packs.filter((pack) => pack !== undefined)
120123
}

tests-ui/tests/composables/useMissingNodes.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,32 @@ describe('useMissingNodes', () => {
277277
// Should update missing packs (2 missing since pack-3 is installed)
278278
expect(missingNodePacks.value).toHaveLength(2)
279279
})
280+
281+
it('clears missing nodes when switching to empty workflow', async () => {
282+
const workflowPacksRef = ref(mockWorkflowPacks)
283+
mockUseWorkflowPacks.mockReturnValue({
284+
workflowPacks: workflowPacksRef,
285+
isLoading: ref(false),
286+
error: ref(null),
287+
startFetchWorkflowPacks: mockStartFetchWorkflowPacks,
288+
isReady: ref(true),
289+
filterWorkflowPack: vi.fn()
290+
})
291+
292+
const { hasMissingNodes, missingNodePacks } = useMissingNodes()
293+
294+
// Should have missing nodes initially (2 missing since pack-3 is installed)
295+
expect(missingNodePacks.value).toHaveLength(2)
296+
expect(hasMissingNodes.value).toBe(true)
297+
298+
// Switch to empty workflow (simulates creating a new empty workflow)
299+
workflowPacksRef.value = []
300+
await nextTick()
301+
302+
// Should clear missing nodes
303+
expect(missingNodePacks.value).toHaveLength(0)
304+
expect(hasMissingNodes.value).toBe(false)
305+
})
280306
})
281307

282308
describe('missing core nodes detection', () => {

0 commit comments

Comments
 (0)