fix(editor): Ignore unconnected nodes when executing workflow (#14683)

This commit is contained in:
Csaba Tuncsik
2025-04-23 09:40:46 +02:00
committed by GitHub
parent 749f130d4f
commit f743915cc9
2 changed files with 29 additions and 15 deletions

View File

@@ -259,14 +259,28 @@ describe('useWorkflowsStore', () => {
});
describe('nodesIssuesExist', () => {
it('should return true when a node has issues', () => {
it('should return true when a node has issues and connected', () => {
workflowsStore.workflow.nodes = [
{ name: 'Node1', issues: { error: ['Error message'] } },
{ name: 'Node2' },
] as unknown as IWorkflowDb['nodes'];
workflowsStore.workflow.connections = {
Node1: { main: [[{ node: 'Node2' } as IConnection]] },
};
const hasIssues = workflowsStore.nodesIssuesExist;
expect(hasIssues).toBe(true);
});
it('should return false when node has issues but it is not connected', () => {
workflowsStore.workflow.nodes = [
{ name: 'Node1', issues: { error: ['Error message'] } },
{ name: 'Node2' },
] as unknown as IWorkflowDb['nodes'];
const hasIssues = workflowsStore.nodesIssuesExist;
expect(hasIssues).toBe(true);
expect(hasIssues).toBe(false);
});
it('should return false when no nodes have issues', () => {
@@ -275,6 +289,10 @@ describe('useWorkflowsStore', () => {
{ name: 'Node2' },
] as unknown as IWorkflowDb['nodes'];
workflowsStore.workflow.connections = {
Node1: { main: [[{ node: 'Node2' } as IConnection]] },
};
const hasIssues = workflowsStore.nodesIssuesExist;
expect(hasIssues).toBe(false);
});

View File

@@ -256,19 +256,15 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
}, {});
});
const nodesIssuesExist = computed(() => {
for (const node of workflow.value.nodes) {
const isNodeDisabled = node.disabled === true;
const noNodeIssues = node.issues === undefined || Object.keys(node.issues).length === 0;
if (isNodeDisabled || noNodeIssues) {
continue;
}
return true;
}
return false;
});
const nodesIssuesExist = computed(() =>
workflow.value.nodes.some((node) => {
const nodeHasIssues = !!Object.keys(node.issues ?? {}).length;
const isConnected =
Object.keys(outgoingConnectionsByNodeName(node.name)).length > 0 ||
Object.keys(incomingConnectionsByNodeName(node.name)).length > 0;
return !node.disabled && isConnected && nodeHasIssues;
}),
);
const pinnedWorkflowData = computed(() => workflow.value.pinData);