@@ -11,6 +11,7 @@ import { extractAndPersistCustomTools } from '@/lib/workflows/persistence/custom
1111import { loadWorkflowFromNormalizedTables } from '@/lib/workflows/persistence/utils'
1212import { isValidKey } from '@/lib/workflows/sanitization/key-validation'
1313import { validateWorkflowState } from '@/lib/workflows/sanitization/validation'
14+ import { TriggerUtils } from '@/lib/workflows/triggers/triggers'
1415import { getAllBlocks , getBlock } from '@/blocks/registry'
1516import type { SubBlockConfig } from '@/blocks/types'
1617import { EDGE , normalizeName } from '@/executor/constants'
@@ -62,6 +63,8 @@ type SkippedItemType =
6263 | 'invalid_subflow_parent'
6364 | 'nested_subflow_not_allowed'
6465 | 'duplicate_block_name'
66+ | 'duplicate_trigger'
67+ | 'duplicate_single_instance_block'
6568
6669/**
6770 * Represents an item that was skipped during operation application
@@ -1775,6 +1778,34 @@ function applyOperationsToWorkflowState(
17751778 break
17761779 }
17771780
1781+ const triggerIssue = TriggerUtils . getTriggerAdditionIssue ( modifiedState . blocks , params . type )
1782+ if ( triggerIssue ) {
1783+ logSkippedItem ( skippedItems , {
1784+ type : 'duplicate_trigger' ,
1785+ operationType : 'add' ,
1786+ blockId : block_id ,
1787+ reason : `Cannot add ${ triggerIssue . triggerName } - a workflow can only have one` ,
1788+ details : { requestedType : params . type , issue : triggerIssue . issue } ,
1789+ } )
1790+ break
1791+ }
1792+
1793+ // Check single-instance block constraints (e.g., Response block)
1794+ const singleInstanceIssue = TriggerUtils . getSingleInstanceBlockIssue (
1795+ modifiedState . blocks ,
1796+ params . type
1797+ )
1798+ if ( singleInstanceIssue ) {
1799+ logSkippedItem ( skippedItems , {
1800+ type : 'duplicate_single_instance_block' ,
1801+ operationType : 'add' ,
1802+ blockId : block_id ,
1803+ reason : `Cannot add ${ singleInstanceIssue . blockName } - a workflow can only have one` ,
1804+ details : { requestedType : params . type } ,
1805+ } )
1806+ break
1807+ }
1808+
17781809 // Create new block with proper structure
17791810 const newBlock = createBlockFromParams (
17801811 block_id ,
0 commit comments