Skip to content

Commit 3637171

Browse files
committed
fix(useWorkflowActions): prevent multiple start nodes in workflow
Add validation to check for existing start node before creating a new one to maintain workflow integrity
1 parent 17ce8aa commit 3637171

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/lib/src/hooks/useWorkflowActions.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ export function useWorkflowActions(workflowState, historyCallback) {
7373

7474
// Add start node
7575
const addStartNode = useCallback((options = {}) => {
76+
// Check if a start node already exists
77+
const existingStartNode = nodes.find(node => node.type === 'start');
78+
if (existingStartNode) {
79+
console.warn('A start node already exists. Only one start node is allowed per workflow.');
80+
return null;
81+
}
82+
7683
const position = options.position || getDefaultPosition(nodes);
7784
const newNode = createStartNode({ ...options, position, existingNodes: nodes });
7885
return addNodeToWorkflow(newNode);

0 commit comments

Comments
 (0)