Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions apps/sim/executor/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const EDGE = {
LOOP_CONTINUE: 'loop_continue',
LOOP_CONTINUE_ALT: 'loop-continue-source',
LOOP_EXIT: 'loop_exit',
PARALLEL_EXIT: 'parallel_exit',
ERROR: 'error',
SOURCE: 'source',
DEFAULT: 'default',
Expand Down Expand Up @@ -88,6 +89,16 @@ export const PARALLEL = {
SUFFIX: '₎',
},

SENTINEL: {
PREFIX: 'parallel-',
START_SUFFIX: '-sentinel-start',
END_SUFFIX: '-sentinel-end',
START_TYPE: 'start' as SentinelType,
END_TYPE: 'end' as SentinelType,
START_NAME_PREFIX: 'Parallel Start',
END_NAME_PREFIX: 'Parallel End',
},

DEFAULT_COUNT: 1,
} as const

Expand Down
13 changes: 11 additions & 2 deletions apps/sim/executor/dag/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ import { createLogger } from '@sim/logger'
import { EdgeConstructor } from '@/executor/dag/construction/edges'
import { LoopConstructor } from '@/executor/dag/construction/loops'
import { NodeConstructor } from '@/executor/dag/construction/nodes'
import { ParallelConstructor } from '@/executor/dag/construction/parallels'
import { PathConstructor } from '@/executor/dag/construction/paths'
import type { DAGEdge, NodeMetadata } from '@/executor/dag/types'
import { buildSentinelStartId, extractBaseBlockId } from '@/executor/utils/subflow-utils'
import {
buildParallelSentinelStartId,
buildSentinelStartId,
extractBaseBlockId,
} from '@/executor/utils/subflow-utils'
import type {
SerializedBlock,
SerializedLoop,
Expand All @@ -31,6 +36,7 @@ export interface DAG {
export class DAGBuilder {
private pathConstructor = new PathConstructor()
private loopConstructor = new LoopConstructor()
private parallelConstructor = new ParallelConstructor()
private nodeConstructor = new NodeConstructor()
private edgeConstructor = new EdgeConstructor()

Expand All @@ -50,6 +56,7 @@ export class DAGBuilder {
const reachableBlocks = this.pathConstructor.execute(workflow, triggerBlockId)

this.loopConstructor.execute(dag, reachableBlocks)
this.parallelConstructor.execute(dag, reachableBlocks)

const { blocksInLoops, blocksInParallels, pauseTriggerMapping } = this.nodeConstructor.execute(
workflow,
Expand Down Expand Up @@ -135,7 +142,9 @@ export class DAGBuilder {
)
}

const sentinelStartNode = dag.nodes.get(buildSentinelStartId(id))
const sentinelStartId =
type === 'Loop' ? buildSentinelStartId(id) : buildParallelSentinelStartId(id)
const sentinelStartNode = dag.nodes.get(sentinelStartId)
if (!sentinelStartNode) return

const hasConnections = Array.from(sentinelStartNode.outgoingEdges.values()).some((edge) =>
Expand Down
Loading
Loading