diff --git a/frontend/src/lib/components/FlowStatusViewerInner.svelte b/frontend/src/lib/components/FlowStatusViewerInner.svelte
index 2843418b5f..70784fc223 100644
--- a/frontend/src/lib/components/FlowStatusViewerInner.svelte
+++ b/frontend/src/lib/components/FlowStatusViewerInner.svelte
@@ -2189,6 +2189,7 @@
outerDivClass={fillHeight ? '' : 'max-h-[1200px]'}
success={jobId != undefined && isSuccess(job?.['success'])}
flowModuleStates={localModuleStates}
+ runDone={job?.type === 'CompletedJob'}
bind:expandedSubflows
onSelect={(e) => {
if (rightColumnSelect != 'node_definition' && rightColumnSelect != 'tracing') {
diff --git a/frontend/src/lib/components/flows/map/FlowModuleSchemaItem.svelte b/frontend/src/lib/components/flows/map/FlowModuleSchemaItem.svelte
index f88dd941b4..96ca59b0c3 100644
--- a/frontend/src/lib/components/flows/map/FlowModuleSchemaItem.svelte
+++ b/frontend/src/lib/components/flows/map/FlowModuleSchemaItem.svelte
@@ -4,16 +4,7 @@
import Popover from '$lib/components/Popover.svelte'
import DropdownV2 from '$lib/components/DropdownV2.svelte'
import { classNames, type Item, type StateStore } from '$lib/utils'
- import {
- EllipsisVertical,
- Pin,
- X,
- Play,
- Loader2,
- TriangleAlert,
- Maximize2,
- RefreshCw
- } from 'lucide-svelte'
+ import { EllipsisVertical, Pin, X, Play, Loader2, TriangleAlert, Maximize2 } from 'lucide-svelte'
import type { StepSettingView } from '../flowStepSettings'
import { createEventDispatcher, getContext, untrack } from 'svelte'
import { fade } from 'svelte/transition'
@@ -73,8 +64,6 @@
path?: string
nodeState?: FlowNodeState
retries?: number | undefined
- /** On a collapsed subflow in a run, how many steps inside it were retried. */
- retriedInside?: number
/** In a run, the attempts the retry badge picks from. */
attempts?: RetryAttempts | undefined
warningMessage?: string | undefined
@@ -109,7 +98,6 @@
path = '',
nodeState,
retries = undefined,
- retriedInside = 0,
attempts = undefined,
warningMessage = undefined,
editMode = false,
@@ -307,32 +295,6 @@
class={classNames('absolute z-0 rounded-md outline-offset-0', colorClasses.outline)}
style={`width: 275px; height: 34px;`}
>
- {#if !editMode && retriedInside > 0}
-
-
-
-
- {/if}
+ {:else}
+
+ {/if}
{/snippet}
{/if}
diff --git a/frontend/src/lib/components/graph/FlowGraphV2.svelte b/frontend/src/lib/components/graph/FlowGraphV2.svelte
index 0507ec3455..6db7624cd5 100644
--- a/frontend/src/lib/components/graph/FlowGraphV2.svelte
+++ b/frontend/src/lib/components/graph/FlowGraphV2.svelte
@@ -176,6 +176,8 @@
isRunning?: boolean
individualStepTests?: boolean
flowJob?: Job | undefined
+ /** The run the graph shows has finished, so a step without a state never ran. */
+ runDone?: boolean
showJobStatus?: boolean
suspendStatus?: Record
noteMode?: boolean
@@ -293,6 +295,7 @@
onHideJobStatus = undefined,
individualStepTests = false,
flowJob = undefined,
+ runDone = false,
showJobStatus = false,
suspendStatus = {},
flowHasChanged = false,
@@ -397,6 +400,7 @@
})
$effect(() => {
flowRunStatus.showsRun = flowModuleStates !== undefined
+ flowRunStatus.runDone = runDone
})
$effect(() => {
// Each step's state object is replaced rather than mutated, so reading the top level
diff --git a/frontend/src/lib/components/graph/flowRunStatus.svelte.ts b/frontend/src/lib/components/graph/flowRunStatus.svelte.ts
index 777d2580f0..39886c5737 100644
--- a/frontend/src/lib/components/graph/flowRunStatus.svelte.ts
+++ b/frontend/src/lib/components/graph/flowRunStatus.svelte.ts
@@ -19,11 +19,21 @@ export class FlowRunStatus {
suspendStatus = $state.raw({})
/** Whether the graph draws a run, as opposed to a flow definition with no run states. */
showsRun = $state(false)
+ /** The run has finished, so a step with no state never ran rather than not yet. */
+ runDone = $state(false)
getModuleState(id: string | undefined): GraphModuleState | undefined {
return id == undefined ? undefined : this.#moduleStates.get(id)
}
+ /** A step the finished run never reached. Undecided while the run goes on, since a step not
+ * reached yet may still run. */
+ didNotRun(id: string): boolean {
+ if (!this.runDone) return false
+ const state = this.getModuleState(id)
+ return !state || state.type === 'WaitingForPriorSteps' || !!state.skipped
+ }
+
/** Steps inside the subflow step `id`, at any depth, that were retried in the shown attempt. */
retriedStepsInside(id: string): number {
const prefix = (id.startsWith('subflow:') ? id : 'subflow:' + id) + ':'
diff --git a/frontend/src/lib/components/graph/graphBuilder.svelte.ts b/frontend/src/lib/components/graph/graphBuilder.svelte.ts
index 677a3ad1a1..2147fbf874 100644
--- a/frontend/src/lib/components/graph/graphBuilder.svelte.ts
+++ b/frontend/src/lib/components/graph/graphBuilder.svelte.ts
@@ -172,6 +172,10 @@ export type ModuleN = {
isOwner: boolean
assets: AssetWithAltAccessType[] | undefined
moduleAction: ModuleActionInfo | undefined
+ isErrorHandler?: boolean
+ /** A loop whose iterations may have run an error handler: its flow has one (each iteration
+ * runs a copy), or a subflow step sits inside it. */
+ mayRunErrorHandler?: boolean
}
}
@@ -516,9 +520,17 @@ export function graphBuilder(
// In the editor the error handler is configured from its own header button, so its graph node
// is only a marker of the last run: inert, dismissable, and never selectable. Everywhere else
// (run view, viewers) it stays a regular step card.
+ function loopMayRunErrorHandler(module: FlowModule, prefix: string | undefined) {
+ const body = 'modules' in module.value ? module.value.modules : []
+ return (
+ !!failureModulesByPrefix[prefix == undefined ? '' : 'subflow:' + prefix] ||
+ getAllModules(body).some((m) => m.value.type === 'flow')
+ )
+ }
+
function addFailureNode(module: FlowModule) {
if (!extra.editMode) {
- return addNode(module)
+ return addNode(module, { isErrorHandler: true })
}
nodes.push({
@@ -545,6 +557,7 @@ export function graphBuilder(
)
const parents: { [key: string]: string[] } = {}
+ const handlerTargets: Record = {}
//
function detectCycle(nodeId: string, visited: Set, currentPath: Set): boolean {
@@ -587,6 +600,7 @@ export function graphBuilder(
subModules?: FlowModule[]
currentItems?: FlowStructureNode[]
disableMoveIds?: string[]
+ handler?: true
}
) {
parents[targetId] = [...(parents[targetId] ?? []), sourceId]
@@ -629,7 +643,8 @@ export function graphBuilder(
disableAi: extra.disableAi,
isOwner: extra.isOwner,
insertable: extra.insertable && !options?.disableInsert && prefix == undefined,
- shouldOffsetInsertBtnDueToAssetNode: nodeIdsWithOutputAssets.has(sourceId)
+ shouldOffsetInsertBtnDueToAssetNode: nodeIdsWithOutputAssets.has(sourceId),
+ handler: options?.handler
},
selectable: false
})
@@ -707,7 +722,12 @@ export function graphBuilder(
simplifiedTriggerView: boolean,
prefix: string | undefined,
disableMoveIds: string[] = [],
- parentIndex?: string
+ parentIndex?: string,
+ // Node an error handler's output goes to when one of these steps fails: the enclosing
+ // loop or branch-all collects it as that iteration's entry, a branch-one passes it
+ // through, and otherwise it is the end of the flow drawn (Result, or an expanded
+ // subflow's end).
+ handlerTarget?: string
) {
// For subflow prefix rewriting, clone modules into moduleMap with prefixed IDs
// (avoid mutating reactive originals which would trigger state_unsafe_mutation in $derived)
@@ -826,7 +846,8 @@ export function graphBuilder(
simplifiedTriggerView,
prefix,
localDisableMoveIds,
- parentIndex
+ parentIndex,
+ handlerTarget
)
previousId = endId
@@ -861,6 +882,9 @@ export function graphBuilder(
const module = moduleMap.get(item.id)
if (!module) return
const localDisableMoveIds = [...disableMoveIds, module.id]
+ if (handlerTarget) {
+ handlerTargets[module.id] = handlerTarget
+ }
// Inter-module edge: connect previous → current (expanded subflows handle their own)
if (index > 0 && previousId && expandedSubflows[module.id] == undefined) {
@@ -945,7 +969,10 @@ export function graphBuilder(
false,
prefix,
localDisableMoveIds,
- parentIndex ? `${parentIndex}-${index}-${branchIndex}` : `${index}-${branchIndex}`
+ parentIndex
+ ? `${parentIndex}-${index}-${branchIndex}`
+ : `${index}-${branchIndex}`,
+ endNode.id
)
})
}
@@ -953,7 +980,7 @@ export function graphBuilder(
previousId = endNode.id
} else if (module.value.type === 'forloopflow') {
if (!simplifiedTriggerView) {
- addNode(module)
+ addNode(module, { mayRunErrorHandler: loopMayRunErrorHandler(module, prefix) })
}
const startNode: NodeLayout = {
@@ -1004,12 +1031,13 @@ export function graphBuilder(
localDisableMoveIds,
parentIndex
? `${parentIndex}-${index}-${selectedIterIndex ?? '?'}`
- : `${index}-${selectedIterIndex ?? '?'}`
+ : `${index}-${selectedIterIndex ?? '?'}`,
+ endNode.id
)
previousId = endNode.id
} else if (module.value.type === 'whileloopflow') {
- addNode(module)
+ addNode(module, { mayRunErrorHandler: loopMayRunErrorHandler(module, prefix) })
const startNode: NodeLayout = {
id: `${module.id}-start`,
@@ -1043,7 +1071,8 @@ export function graphBuilder(
localDisableMoveIds,
parentIndex
? `${parentIndex}-${index}-${selectedIterIndex ?? '?'}`
- : `${index}-${selectedIterIndex ?? '?'}`
+ : `${index}-${selectedIterIndex ?? '?'}`,
+ endNode.id
)
previousId = endNode.id
@@ -1059,6 +1088,9 @@ export function graphBuilder(
type: 'branchOneEnd'
}
nodes.push(endNode)
+ // The handler's output is the branch-one's result, which ends the flow unless the
+ // branch-one continues on error.
+ const branchHandlerTarget = module.continue_on_error ? endNode.id : handlerTarget
const defaultBranch: NodeLayout = {
id: `${module.id}-branch-default`,
@@ -1089,7 +1121,8 @@ export function graphBuilder(
false,
prefix,
localDisableMoveIds,
- parentIndex ? `${parentIndex}-${index}` : index.toString()
+ parentIndex ? `${parentIndex}-${index}` : index.toString(),
+ branchHandlerTarget
)
module.value.branches.forEach((branch, branchIndex) => {
@@ -1124,7 +1157,8 @@ export function graphBuilder(
false,
prefix,
localDisableMoveIds,
- parentIndex ? `${parentIndex}-${index}` : index.toString()
+ parentIndex ? `${parentIndex}-${index}` : index.toString(),
+ branchHandlerTarget
)
})
@@ -1203,7 +1237,9 @@ export function graphBuilder(
endNode,
false,
subflowPrefix,
- localDisableMoveIds
+ localDisableMoveIds,
+ undefined,
+ endId
)
previousId = endNode.id
@@ -1236,7 +1272,17 @@ export function graphBuilder(
if (simplifiableFlow?.simplifiedFlow === true && triggerNode) {
processModules(topLevelItems, undefined, triggerNode, undefined, true, undefined)
} else {
- processModules(topLevelItems, undefined, inputNode, resultNode, false, undefined)
+ processModules(
+ topLevelItems,
+ undefined,
+ inputNode,
+ resultNode,
+ false,
+ undefined,
+ [],
+ undefined,
+ resultNode.id
+ )
}
// Before the failure markers: the preprocessor can be the step that failed, and a marker is
@@ -1271,7 +1317,34 @@ export function graphBuilder(
return
}
addFailureNode({ ...module, id })
- addEdge(parentId, id, undefined, undefined, { type: 'empty' })
+ // An expanded subflow step failed as a whole, so its marker hangs off the subflow's end.
+ const anchor = expandedSubflows[parentId] ? `${parentId}-subflow-end` : parentId
+ addEdge(anchor, id, undefined, undefined, { type: 'empty', handler: true })
+ const target = handlerTargets[parentId]
+ // The failure went to the handler, so the step's own way out was not taken, even where
+ // it leads to a node with no run state of its own (a loop or branch end). A loop or
+ // branch that failed as a whole leaves through its end node. Where the way out leads to
+ // the handler's own target, the handler's edge replaces it: drawn both, they read as
+ // two paths into that node.
+ const exits = [anchor, `${anchor}-end`]
+ for (const edge of edges) {
+ if (exits.includes(edge.source) && edge.target !== id) {
+ edge.data = { ...edge.data, bypassed: edge.target === target ? 'replaced' : true }
+ }
+ }
+ // The step's own edge stays: the steps after it are still part of the flow, and their
+ // state shows they did not run. Kept out of `parents`, which the layout reads: an edge
+ // leaving a branch for Result would pull Result into that branch's group.
+ if (target) {
+ edges.push({
+ id: `edge:${id}->${target}`,
+ source: id,
+ target,
+ type: 'empty',
+ data: { handler: true },
+ selectable: false
+ })
+ }
})
if (failureModule && !extra.flowModuleStates) {
@@ -1322,6 +1395,14 @@ export function graphBuilder(
}
}
+ // Static, so it never invalidates the edge set; the renderer reads run state on its own.
+ const stepIds = new Set(nodes.filter((n) => n.type === 'module').map((n) => n.id))
+ for (const edge of edges) {
+ if (edge.type !== 'edge' && edge.type !== 'empty') continue
+ const steps = [edge.source, edge.target].filter((id) => stepIds.has(id))
+ if (steps.length) edge.data = { ...edge.data, steps }
+ }
+
return { nodes: Object.fromEntries(nodes.map((n) => [n.id, n])), edges }
} catch (e) {
return {
diff --git a/frontend/src/lib/components/graph/graphBuilder.test.ts b/frontend/src/lib/components/graph/graphBuilder.test.ts
index 18380cc234..f0f8f962eb 100644
--- a/frontend/src/lib/components/graph/graphBuilder.test.ts
+++ b/frontend/src/lib/components/graph/graphBuilder.test.ts
@@ -18,51 +18,119 @@ const script = (id: string): FlowModule => ({
value: { type: 'rawscript', language: 'bun', content: '', input_transforms: {} }
})
+const ran = (parent_module: string) =>
+ ({ type: 'Success', args: {}, parent_module }) as GraphModuleState
+
+function build(
+ modules: FlowModule[],
+ flowModuleStates: Record,
+ expandedSubflows: Record = {}
+) {
+ return graphBuilder(
+ buildStructureTree(modules, []),
+ modules,
+ {
+ disableAi: true,
+ insertable: false,
+ flowModuleStates,
+ testModuleStates: undefined,
+ selectedId: undefined,
+ path: undefined,
+ newFlow: false,
+ cache: false,
+ earlyStop: false,
+ editMode: false,
+ isOwner: false,
+ isRunning: false,
+ individualStepTests: false,
+ showJobStatus: true,
+ flowHasChanged: false,
+ chatInputEnabled: false
+ },
+ script('failure'),
+ undefined,
+ {} as any,
+ true,
+ false,
+ undefined,
+ undefined,
+ undefined,
+ expandedSubflows,
+ false,
+ new Set()
+ )
+}
+
+const hasEdge = (edges: { source: string; target: string }[], source: string, target: string) =>
+ edges.some((e) => e.source === source && e.target === target)
+
describe('graphBuilder error handler markers', () => {
it("anchors an expanded subflow's error handler to the subflow step that failed", () => {
const modules: FlowModule[] = [
{ id: 'sub', value: { type: 'flow', path: 'u/admin/child', input_transforms: {} } }
]
- const ran = (parent_module: string) =>
- ({ type: 'Success', args: {}, parent_module }) as GraphModuleState
- const { nodes, edges } = graphBuilder(
- buildStructureTree(modules, []),
+ const { nodes, edges } = build(
modules,
- {
- disableAi: true,
- insertable: false,
- flowModuleStates: { 'subflow:sub:failure': ran('bad') },
- testModuleStates: undefined,
- selectedId: undefined,
- path: undefined,
- newFlow: false,
- cache: false,
- earlyStop: false,
- editMode: false,
- isOwner: false,
- isRunning: false,
- individualStepTests: false,
- showJobStatus: true,
- flowHasChanged: false,
- chatInputEnabled: false
- },
- undefined,
- undefined,
- {} as any,
- true,
- false,
- undefined,
- undefined,
- undefined,
- { sub: { modules: [script('bad')], failureModule: script('failure') } },
- false,
- new Set()
+ { 'subflow:sub:failure': ran('bad') },
+ { sub: { modules: [script('bad')], failureModule: script('failure') } }
)
expect(nodes['subflow:sub:failure']).toBeDefined()
- expect(
- edges.some((e) => e.source === 'subflow:sub:bad' && e.target === 'subflow:sub:failure')
- ).toBe(true)
+ expect(hasEdge(edges, 'subflow:sub:bad', 'subflow:sub:failure')).toBe(true)
+ expect(hasEdge(edges, 'subflow:sub:failure', 'sub-subflow-end')).toBe(true)
+ })
+
+ // The engine runs the handler in the innermost loop iteration or branch-all branch, whose
+ // result is one entry of that node's array; a branch-one hands its branch's result through.
+ it('leads the handler to the node that receives its output', () => {
+ const modules: FlowModule[] = [
+ {
+ id: 'loop',
+ value: {
+ type: 'forloopflow',
+ iterator: { type: 'javascript', expr: '[1]' },
+ skip_failures: false,
+ modules: [script('s')]
+ }
+ },
+ { id: 'bo', value: { type: 'branchone', default: [script('d')], branches: [] } },
+ {
+ id: 'boc',
+ continue_on_error: true,
+ value: { type: 'branchone', default: [script('e')], branches: [] }
+ }
+ ]
+ const { edges } = build(modules, {
+ 'failure-0-0': ran('s'),
+ 'failure-1': ran('d'),
+ 'failure-2': ran('e')
+ })
+
+ expect(hasEdge(edges, 'failure-0-0', 'loop-end')).toBe(true)
+ expect(hasEdge(edges, 'failure-1', 'Result')).toBe(true)
+ expect(hasEdge(edges, 'failure-2', 'boc-end')).toBe(true)
+ })
+
+ // Drawn both, the step's own exit and the handler's edge read as two paths into one node.
+ it("marks the failed step's way out as not taken, hidden where the handler replaces it", () => {
+ const loop = (id: string, inner: string): FlowModule => ({
+ id,
+ value: {
+ type: 'forloopflow',
+ iterator: { type: 'javascript', expr: '[1]' },
+ skip_failures: false,
+ modules: [script(inner)]
+ }
+ })
+ const bypassed = (edges: any[], source: string, target: string) =>
+ edges.find((e) => e.source === source && e.target === target)?.data?.bypassed
+
+ const inner = build([loop('loop', 's')], { 'failure-0-0': ran('s') }).edges
+ expect(bypassed(inner, 's', 'loop-end')).toBe('replaced')
+
+ // A loop that failed as a whole leaves through its end node.
+ const whole = build([loop('loop', 's'), script('next')], { failure: ran('loop') }).edges
+ expect(bypassed(whole, 'loop-end', 'next')).toBe(true)
})
})
diff --git a/frontend/src/lib/components/graph/nestedErrorHandlers.ts b/frontend/src/lib/components/graph/nestedErrorHandlers.ts
new file mode 100644
index 0000000000..e37804f521
--- /dev/null
+++ b/frontend/src/lib/components/graph/nestedErrorHandlers.ts
@@ -0,0 +1,88 @@
+import { JobService, type Job } from '$lib/gen'
+import { getAllModules } from '../flows/flowExplorer'
+
+// A finished job's tree never changes, so its count is kept for the page's life; a running
+// one, or one whose walk failed, is asked again next time.
+const finishedCounts = new Map>()
+
+// A run graph can hold many loops and subflows: their walks share these slots so opening a run
+// never sends more than a few job requests at once.
+const MAX_REQUESTS = 4
+let inFlight = 0
+const waiting: (() => void)[] = []
+
+async function getJob(workspace: string, id: string): Promise {
+ if (inFlight >= MAX_REQUESTS) await new Promise((resolve) => waiting.push(resolve))
+ inFlight++
+ try {
+ return await JobService.getJob({ workspace, id, noLogs: true, noCode: true })
+ } finally {
+ inFlight--
+ waiting.shift()?.()
+ }
+}
+
+/**
+ * Error handlers that ran anywhere under a flow job: its own, and those of every subflow,
+ * loop iteration and branch below it. Each iteration and branch is its own flow job carrying a
+ * copy of the handler, so the walk visits them all, unless no handler can exist below.
+ */
+export function countErrorHandlersUnder(workspace: string, jobId: string): Promise {
+ const cached = finishedCounts.get(jobId)
+ if (cached) return cached
+ const count = getJob(workspace, jobId).then(async (job) => {
+ const n = await countIn(workspace, job)
+ if (job.type !== 'CompletedJob') forget(jobId, count)
+ return n
+ })
+ count.catch(() => forget(jobId, count))
+ finishedCounts.set(jobId, count)
+ return count
+}
+
+function forget(jobId: string, count: Promise) {
+ if (finishedCounts.get(jobId) === count) finishedCounts.delete(jobId)
+}
+
+async function countIn(workspace: string, job: Job): Promise {
+ const status = job.flow_status
+ if (!status) return 0
+ const own = status.failure_module?.job ? 1 : 0
+ const flow = job.raw_flow
+ // Iterations and branches only carry this flow's handler, so without one, and without a
+ // subflow of its own, nothing below can have run a handler.
+ const modules = flow ? getAllModules(flow.modules) : []
+ if (!flow?.failure_module && !modules.some((m) => m.value.type === 'flow')) return own
+ const types = new Map(flow?.modules.map((m) => [m.id, m.value.type]) ?? [])
+ const children: string[] = []
+ for (const mod of status.modules) {
+ if (mod.flow_jobs?.length) {
+ // Failed iterations and branches only, as in `firstIterationWithHandler`.
+ children.push(...mod.flow_jobs.filter((_, i) => mod.flow_jobs_success?.[i] === false))
+ } else if (mod.job) {
+ // A script step has no flow below it; only these run a flow job of their own.
+ const type = mod.id ? types.get(mod.id) : undefined
+ if (type === 'flow' || type === 'branchone') children.push(mod.job)
+ }
+ }
+ const counts = await Promise.all(children.map((id) => countErrorHandlersUnder(workspace, id)))
+ return counts.reduce((a, b) => a + b, own)
+}
+
+/**
+ * The first failed iteration of a loop that ran an error handler. Only failed iterations are
+ * asked: a loop of thousands of successful iterations would otherwise cost a request each. A
+ * handler that recovered leaves its iteration a success, so it shows only once that iteration
+ * is opened.
+ */
+export async function firstIterationWithHandler(
+ workspace: string,
+ iterations: string[],
+ success: (boolean | undefined)[] | undefined
+): Promise {
+ for (let i = 0; i < iterations.length; i++) {
+ if (success?.[i] !== false) continue
+ if ((await countErrorHandlersUnder(workspace, iterations[i])) > 0) return i
+ }
+ return undefined
+}
diff --git a/frontend/src/lib/components/graph/renderers/edges/BaseEdge.svelte b/frontend/src/lib/components/graph/renderers/edges/BaseEdge.svelte
index 5678621062..53293ba82e 100644
--- a/frontend/src/lib/components/graph/renderers/edges/BaseEdge.svelte
+++ b/frontend/src/lib/components/graph/renderers/edges/BaseEdge.svelte
@@ -12,6 +12,7 @@
import { getGraphContext } from '../../graphContext'
import { getFlowRunStatusContext } from '../../flowRunStatus.svelte'
import { GROUP_TOP_PADDING } from '$lib/components/graph/compoundLayout'
+ import { edgeRunClass } from './edgeRunClass'
const { useDataflow, showAssets, moveManager } = getGraphContext()
const flowRunStatus = getFlowRunStatusContext()
@@ -42,6 +43,8 @@
disableMoveIds: string[]
isOwner: boolean
shouldOffsetInsertBtnDueToAssetNode?: boolean
+ steps?: string[]
+ bypassed?: true | 'replaced'
}
} = $props()
@@ -78,6 +81,7 @@
)
let flowJob: Job | undefined = $derived(flowRunStatus?.flowJob)
+ let runClass = $derived(edgeRunClass(flowRunStatus, data))
let suspendStatus: Record | undefined = $derived(
flowRunStatus?.suspendStatus
)
@@ -267,7 +271,7 @@
diff --git a/frontend/src/lib/components/graph/renderers/edges/edgeRunClass.test.ts b/frontend/src/lib/components/graph/renderers/edges/edgeRunClass.test.ts
new file mode 100644
index 0000000000..1086ab7164
--- /dev/null
+++ b/frontend/src/lib/components/graph/renderers/edges/edgeRunClass.test.ts
@@ -0,0 +1,22 @@
+import { describe, it, expect } from 'vitest'
+import { edgeRunClass } from './edgeRunClass'
+import type { FlowRunStatus } from '../../flowRunStatus.svelte'
+
+const status = (notRun: string[] = []) =>
+ ({
+ showsRun: true,
+ didNotRun: (id: string) => notRun.includes(id)
+ }) as unknown as FlowRunStatus
+
+describe('edgeRunClass', () => {
+ it("draws a handler's edge plain, even next to a step that did not run", () => {
+ expect(edgeRunClass(status(['a']), { handler: true, steps: ['a'] })).toBe('')
+ })
+
+ it('hides a replaced exit and fades a bypassed one or one through a step that did not run', () => {
+ expect(edgeRunClass(status(), { bypassed: 'replaced' })).toBe('hidden')
+ expect(edgeRunClass(status(), { bypassed: true })).toContain('dasharray')
+ expect(edgeRunClass(status(['b']), { steps: ['a', 'b'] })).toContain('dasharray')
+ expect(edgeRunClass(status(), { steps: ['a', 'b'] })).toBe('')
+ })
+})
diff --git a/frontend/src/lib/components/graph/renderers/edges/edgeRunClass.ts b/frontend/src/lib/components/graph/renderers/edges/edgeRunClass.ts
new file mode 100644
index 0000000000..83e0834675
--- /dev/null
+++ b/frontend/src/lib/components/graph/renderers/edges/edgeRunClass.ts
@@ -0,0 +1,21 @@
+import type { FlowRunStatus } from '../../flowRunStatus.svelte'
+
+const NOT_RUN = '[stroke-dasharray:4_4] opacity-50'
+
+export type EdgeRunData = {
+ /** An edge into or out of an error handler that ran: always part of the path the run took. */
+ handler?: true
+ /** The steps at either end of the edge. */
+ steps?: string[]
+ /** The edge leaves a step whose failure an error handler took; `replaced` when the handler's
+ * edge leads to the same node. */
+ bypassed?: true | 'replaced'
+}
+
+/** How a run draws an edge: a path the run did not take (through a step the finished run never
+ * reached, or out of a step whose failure went to the handler) faded and dashed, the rest plain. */
+export function edgeRunClass(status: FlowRunStatus | undefined, data: EdgeRunData): string {
+ if (!status?.showsRun || data.handler) return ''
+ if (data.bypassed) return data.bypassed === 'replaced' ? 'hidden' : NOT_RUN
+ return data.steps?.some((id) => status.didNotRun(id)) ? NOT_RUN : ''
+}
diff --git a/frontend/src/lib/components/graph/renderers/nodes/ModuleNode.svelte b/frontend/src/lib/components/graph/renderers/nodes/ModuleNode.svelte
index 256166d30e..2e2539fa8d 100644
--- a/frontend/src/lib/components/graph/renderers/nodes/ModuleNode.svelte
+++ b/frontend/src/lib/components/graph/renderers/nodes/ModuleNode.svelte
@@ -1,16 +1,29 @@