@@ -20,7 +20,10 @@ import {
2020 TriggerUtils ,
2121} from '@/lib/workflows/triggers/triggers'
2222import { useCurrentWorkflow } from '@/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-current-workflow'
23- import { updateActiveBlockRefCount } from '@/app/workspace/[workspaceId]/w/[workflowId]/utils/workflow-execution-utils'
23+ import {
24+ markOutgoingEdgesFromOutput ,
25+ updateActiveBlockRefCount ,
26+ } from '@/app/workspace/[workspaceId]/w/[workflowId]/utils/workflow-execution-utils'
2427import { getBlock } from '@/blocks'
2528import type { SerializableExecutionState } from '@/executor/execution/types'
2629import type {
@@ -63,7 +66,7 @@ interface DebugValidationResult {
6366interface BlockEventHandlerConfig {
6467 workflowId ?: string
6568 executionIdRef : { current : string }
66- workflowEdges : Array < { id : string ; target : string ; sourceHandle ?: string | null } >
69+ workflowEdges : Array < { id : string ; source : string ; target : string ; sourceHandle ?: string | null } >
6770 activeBlocksSet : Set < string >
6871 activeBlockRefCounts : Map < string , number >
6972 accumulatedBlockLogs : BlockLog [ ]
@@ -335,13 +338,9 @@ export function useWorkflowExecution() {
335338 setActiveBlocks ( workflowId , new Set ( activeBlocksSet ) )
336339 }
337340
338- const markIncomingEdges = ( blockId : string ) => {
341+ const markOutgoingEdges = ( blockId : string , output : Record < string , any > | undefined ) => {
339342 if ( ! workflowId ) return
340- const incomingEdges = workflowEdges . filter ( ( edge ) => edge . target === blockId )
341- incomingEdges . forEach ( ( edge ) => {
342- const status = edge . sourceHandle === 'error' ? 'error' : 'success'
343- setEdgeRunStatus ( workflowId , edge . id , status )
344- } )
343+ markOutgoingEdgesFromOutput ( blockId , output , workflowEdges , workflowId , setEdgeRunStatus )
345344 }
346345
347346 const isContainerBlockType = ( blockType ?: string ) => {
@@ -460,7 +459,6 @@ export function useWorkflowExecution() {
460459 const onBlockStarted = ( data : BlockStartedData ) => {
461460 if ( isStaleExecution ( ) ) return
462461 updateActiveBlocks ( data . blockId , true )
463- markIncomingEdges ( data . blockId )
464462
465463 if ( ! includeStartConsoleEntry || ! workflowId ) return
466464
@@ -487,6 +485,7 @@ export function useWorkflowExecution() {
487485 if ( isStaleExecution ( ) ) return
488486 updateActiveBlocks ( data . blockId , false )
489487 if ( workflowId ) setBlockRunStatus ( workflowId , data . blockId , 'success' )
488+ markOutgoingEdges ( data . blockId , data . output as Record < string , any > | undefined )
490489 executedBlockIds . add ( data . blockId )
491490 accumulatedBlockStates . set ( data . blockId , {
492491 output : data . output ,
@@ -505,7 +504,9 @@ export function useWorkflowExecution() {
505504 }
506505
507506 if ( isContainerBlockType ( data . blockType ) && ! data . iterationContainerId ) {
508- return
507+ const output = data . output as Record < string , any > | undefined
508+ const isEmptySubflow = Array . isArray ( output ?. results ) && output . results . length === 0
509+ if ( ! isEmptySubflow ) return
509510 }
510511
511512 accumulatedBlockLogs . push ( createBlockLogEntry ( data , { success : true , output : data . output } ) )
@@ -527,6 +528,7 @@ export function useWorkflowExecution() {
527528 if ( isStaleExecution ( ) ) return
528529 updateActiveBlocks ( data . blockId , false )
529530 if ( workflowId ) setBlockRunStatus ( workflowId , data . blockId , 'error' )
531+ markOutgoingEdges ( data . blockId , { error : data . error } )
530532
531533 executedBlockIds . add ( data . blockId )
532534 accumulatedBlockStates . set ( data . blockId , {
0 commit comments