mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-11-29 08:06:46 +00:00
feat: lead the run graph's error handler to the node that receives its output (#12516)
* fix: show retries, subflow error handlers and empty branches in the run graph Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: keep stale and preprocessor retries off other steps, show empty-branch note only on success Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: list retry attempts in the graph node panel, align approval page with brand guidelines Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: isolate retry attempt viewers and mount one list per view Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: give retry attempt viewers their own loop selection scope Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: mark a denied or timed-out approval on its own step in the run graph Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: show a recovered subflow as the failed step its parent records Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: lead the run graph's error handler to the node that receives its output Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: end a continuing branch-one's handler edge at the branch-one Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: hang the error handler of a denied approval from the approval step Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor: draw the handler edge on the same path instead of bowing around the column Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: pick a retried step's attempt on the graph, as a loop's iteration Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: clear a subflow's step states when switching attempts, keep the retry line for the preprocessor and error handler Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: one step settings bar with the attempt picker in its menu * fix: keep a nested attempt pick, open loop and branch settings from the bar * feat: show how many steps were retried inside a collapsed subflow Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: expand a subflow from its retried-inside line Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: use the design-system button for the retried-inside line Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: mark error handlers and the path a run took in the run graph Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: count error handlers only where one can have run, a few requests at a time Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: skip successful iterations when counting a subflow's error handlers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: draw the run's path plain and dashed, with a dashed outline on steps that did not run Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: show retry and error handler counts together under a collapsed subflow, drop the not-run outline Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Guilhem Lemouel <guilhemlemouel@gmail.com> Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
This commit is contained in:
co-authored by
Claude Opus 5.5
Guilhem Lemouel
Ruben Fiszel
parent
5819ced95b
commit
6ec19f0fe5
@@ -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') {
|
||||
|
||||
@@ -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;`}
|
||||
></div>
|
||||
{#if !editMode && retriedInside > 0}
|
||||
<!-- Left of the settings bar, which is this step's own policy: this is what happened inside. -->
|
||||
<div
|
||||
transition:fade|local={{ duration: 200 }}
|
||||
class="nodrag nopan absolute -left-1 top-[calc(100%+3px)] z-10"
|
||||
>
|
||||
<Button
|
||||
variant="subtle"
|
||||
unifiedSize="2xs"
|
||||
title="Expand to see the retried steps"
|
||||
disabled={!maximizeSubflow}
|
||||
btnClasses="gap-1 text-2xs text-secondary"
|
||||
onClick={(e) => {
|
||||
e?.preventDefault()
|
||||
maximizeSubflow?.()
|
||||
}}
|
||||
on:pointerdown={(e) => {
|
||||
e.stopPropagation()
|
||||
e.preventDefault()
|
||||
}}
|
||||
>
|
||||
<RefreshCw size={12} class="text-orange-500" />
|
||||
{retriedInside} step{retriedInside === 1 ? '' : 's'} retried inside
|
||||
</Button>
|
||||
</div>
|
||||
{/if}
|
||||
<div
|
||||
class="absolute text-sm {editMode
|
||||
? 'right-2'
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
import type { ModuleActionInfo } from '$lib/components/flows/flowDiff'
|
||||
import { getGraphContext } from '$lib/components/graph/graphContext'
|
||||
import { nextMock } from '../flowMock'
|
||||
import { Bug } from 'lucide-svelte'
|
||||
|
||||
interface Props {
|
||||
moduleId: string
|
||||
@@ -29,7 +30,6 @@
|
||||
nodeState?: FlowNodeState
|
||||
duration_ms?: number | undefined
|
||||
retries?: number | undefined
|
||||
retriedInside?: number
|
||||
flowJobs:
|
||||
| {
|
||||
flowJobs: string[]
|
||||
@@ -64,6 +64,8 @@
|
||||
isOwner?: boolean
|
||||
maximizeSubflow?: () => void
|
||||
menuItems?: Item[]
|
||||
/** The step is the flow's error handler, drawn in a run with the bug icon its header button uses. */
|
||||
errorHandler?: boolean
|
||||
}
|
||||
|
||||
let {
|
||||
@@ -79,7 +81,6 @@
|
||||
nodeState,
|
||||
duration_ms = undefined,
|
||||
retries = undefined,
|
||||
retriedInside = 0,
|
||||
flowJobs,
|
||||
attempts = undefined,
|
||||
editMode = false,
|
||||
@@ -91,7 +92,8 @@
|
||||
flowJob,
|
||||
isOwner = false,
|
||||
maximizeSubflow,
|
||||
menuItems = undefined
|
||||
menuItems = undefined,
|
||||
errorHandler = false
|
||||
}: Props = $props()
|
||||
|
||||
const { selectionManager, moveManager } = getGraphContext()
|
||||
@@ -279,7 +281,6 @@
|
||||
{:else}
|
||||
<FlowModuleSchemaItem
|
||||
{retries}
|
||||
{retriedInside}
|
||||
attempts={attempts && !insertable
|
||||
? {
|
||||
jobs: attempts.flowJobs,
|
||||
@@ -331,7 +332,11 @@
|
||||
: mod.value.type === 'script'
|
||||
? 14
|
||||
: 16}
|
||||
<FlowModuleIcon module={mod} {size} />
|
||||
{#if errorHandler}
|
||||
<Bug size={16} class="text-red-400 dark:text-red-500" />
|
||||
{:else}
|
||||
<FlowModuleIcon module={mod} {size} />
|
||||
{/if}
|
||||
{/snippet}
|
||||
</FlowModuleSchemaItem>
|
||||
{/if}
|
||||
|
||||
@@ -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<string, { job: Job; nb: number }>
|
||||
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
|
||||
|
||||
@@ -19,11 +19,21 @@ export class FlowRunStatus {
|
||||
suspendStatus = $state.raw<SuspendStatus>({})
|
||||
/** 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) + ':'
|
||||
|
||||
@@ -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<string, string> = {}
|
||||
|
||||
//
|
||||
function detectCycle(nodeId: string, visited: Set<string>, currentPath: Set<string>): 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 {
|
||||
|
||||
@@ -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<string, GraphModuleState>,
|
||||
expandedSubflows: Record<string, any> = {}
|
||||
) {
|
||||
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)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -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<string, Promise<number>>()
|
||||
|
||||
// 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<Job> {
|
||||
if (inFlight >= MAX_REQUESTS) await new Promise<void>((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<number> {
|
||||
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<number>) {
|
||||
if (finishedCounts.get(jobId) === count) finishedCounts.delete(jobId)
|
||||
}
|
||||
|
||||
async function countIn(workspace: string, job: Job): Promise<number> {
|
||||
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<number | undefined> {
|
||||
for (let i = 0; i < iterations.length; i++) {
|
||||
if (success?.[i] !== false) continue
|
||||
if ((await countErrorHandlersUnder(workspace, iterations[i])) > 0) return i
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
@@ -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<string, { job: Job; nb: number }> | undefined = $derived(
|
||||
flowRunStatus?.suspendStatus
|
||||
)
|
||||
@@ -267,7 +271,7 @@
|
||||
<BaseEdge
|
||||
path={completeEdge}
|
||||
{markerEnd}
|
||||
class={$useDataflow || groupBoundary ? 'hidden' : isAdjacentToDragged ? 'opacity-30' : ''}
|
||||
class={$useDataflow || groupBoundary ? 'hidden' : isAdjacentToDragged ? 'opacity-30' : runClass}
|
||||
interactionWidth={0}
|
||||
style={undefined}
|
||||
label={undefined}
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
import { getBezierPath, BaseEdge, type Position } from '@xyflow/svelte'
|
||||
import { twMerge } from 'tailwind-merge'
|
||||
import { getGraphContext } from '../../graphContext'
|
||||
import { getFlowRunStatusContext } from '../../flowRunStatus.svelte'
|
||||
import type { EdgeRunData } from './edgeRunClass'
|
||||
import { edgeRunClass } from './edgeRunClass'
|
||||
|
||||
interface Props {
|
||||
sourceX: number
|
||||
@@ -11,7 +14,7 @@
|
||||
targetY: number
|
||||
targetPosition: Position
|
||||
markerEnd?: string | undefined
|
||||
data?: { class?: string }
|
||||
data?: { class?: string } & EdgeRunData
|
||||
}
|
||||
|
||||
let {
|
||||
@@ -26,6 +29,9 @@
|
||||
}: Props = $props()
|
||||
|
||||
const { useDataflow } = getGraphContext()
|
||||
const flowRunStatus = getFlowRunStatusContext()
|
||||
|
||||
let runClass = $derived(edgeRunClass(flowRunStatus, data))
|
||||
|
||||
let [edgePath] = $derived(
|
||||
getBezierPath({
|
||||
@@ -43,6 +49,6 @@
|
||||
<BaseEdge
|
||||
path={edgePath}
|
||||
{markerEnd}
|
||||
class={twMerge($useDataflow ? 'hidden' : '', 'pointer-events-none', data.class ?? '')}
|
||||
class={twMerge($useDataflow ? 'hidden' : '', 'pointer-events-none', data.class ?? '', runClass)}
|
||||
interactionWidth={0}
|
||||
/>
|
||||
|
||||
@@ -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('')
|
||||
})
|
||||
})
|
||||
@@ -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 : ''
|
||||
}
|
||||
@@ -1,16 +1,29 @@
|
||||
<script lang="ts">
|
||||
import MapItem from '$lib/components/flows/map/MapItem.svelte'
|
||||
import { GitBranchPlus, Move, Copy, Trash2, StickyNote, PictureInPicture2 } from 'lucide-svelte'
|
||||
import {
|
||||
GitBranchPlus,
|
||||
Move,
|
||||
Copy,
|
||||
Trash2,
|
||||
StickyNote,
|
||||
PictureInPicture2,
|
||||
Bug,
|
||||
RefreshCw
|
||||
} from 'lucide-svelte'
|
||||
import DropdownV2 from '$lib/components/DropdownV2.svelte'
|
||||
import NodeWrapper from './NodeWrapper.svelte'
|
||||
import AiDecisionNodeBranch from './AiDecisionNodeBranch.svelte'
|
||||
import type { ModuleN } from '../../graphBuilder.svelte'
|
||||
import { jobToGraphModuleState } from '$lib/components/modulesTest.svelte'
|
||||
import { getNoteEditorContext } from '../../noteEditor.svelte'
|
||||
import { isMac, type Item } from '$lib/utils'
|
||||
import { getContext } from 'svelte'
|
||||
import { getContext, untrack } from 'svelte'
|
||||
import { getGraphContext } from '../../graphContext'
|
||||
import { getFlowRunStatusContext } from '../../flowRunStatus.svelte'
|
||||
import { waitingRequest } from '$lib/components/agentRequest'
|
||||
import { Button } from '$lib/components/common'
|
||||
import { workspaceStore } from '$lib/stores'
|
||||
import { countErrorHandlersUnder, firstIterationWithHandler } from '../../nestedErrorHandlers'
|
||||
|
||||
interface Props {
|
||||
data: ModuleN['data']
|
||||
@@ -99,6 +112,86 @@
|
||||
: (undefined as any)
|
||||
)
|
||||
|
||||
let subflowPath = $derived(
|
||||
data.module?.value?.type == 'flow' && 'path' in data.module.value
|
||||
? (data.module.value['path'] as string | undefined)
|
||||
: undefined
|
||||
)
|
||||
|
||||
function expandSubflow() {
|
||||
if (subflowPath) data.eventHandlers.expandSubflow(data.id, subflowPath)
|
||||
}
|
||||
|
||||
// The walk below only re-runs when the step's jobs change: `state` is a new object on
|
||||
// every status update. A step still running has no count yet, as its jobs are still changing.
|
||||
let handlerCountKey = $derived(
|
||||
!data.editMode && (state?.type === 'Success' || state?.type === 'Failure')
|
||||
? [state.job_id, state.selectedForloopIndex, ...(state.flow_jobs ?? [])].join(',')
|
||||
: undefined
|
||||
)
|
||||
|
||||
/** Something that happened inside a step the graph does not draw, and how to reveal it. */
|
||||
type InsideMark = { count: number; label: string; title: string; reveal: () => void }
|
||||
|
||||
/**
|
||||
* Error handlers that ran inside this step but that the graph does not draw: anywhere in a
|
||||
* collapsed subflow, or in a loop's other iterations while the one shown draws none. The
|
||||
* selected iteration's own handlers are drawn, and nested steps report theirs.
|
||||
*/
|
||||
let hiddenErrorHandlers = $derived.by((): Promise<InsideMark | undefined> | undefined => {
|
||||
const workspace = $workspaceStore
|
||||
if (!handlerCountKey || !workspace) return undefined
|
||||
const s = untrack(() => state)
|
||||
if (!s) return undefined
|
||||
const valueType = data.module?.value?.type
|
||||
if (valueType === 'flow' && s.job_id && subflowPath) {
|
||||
return countErrorHandlersUnder(workspace, s.job_id).then(
|
||||
(count) =>
|
||||
count > 0
|
||||
? {
|
||||
count,
|
||||
label: `${count} error handler${count > 1 ? 's' : ''} ran`,
|
||||
title: 'Expand the subflow',
|
||||
reveal: expandSubflow
|
||||
}
|
||||
: undefined,
|
||||
() => undefined
|
||||
)
|
||||
}
|
||||
const iterations = s.flow_jobs
|
||||
const isLoop = valueType === 'forloopflow' || valueType === 'whileloopflow'
|
||||
if (isLoop && data.mayRunErrorHandler && iterations?.length) {
|
||||
const index = s.selectedForloopIndex ?? 0
|
||||
const shown = index >= 0 ? index : iterations.length - 1
|
||||
const success = s.flow_jobs_success
|
||||
return countErrorHandlersUnder(workspace, iterations[shown])
|
||||
.then(async (count) =>
|
||||
// The iteration on screen already draws a handler: pointing at the others would
|
||||
// keep the reader clicking through iterations.
|
||||
count > 0 ? undefined : await firstIterationWithHandler(workspace, iterations, success)
|
||||
)
|
||||
.then(
|
||||
(first) =>
|
||||
first === undefined
|
||||
? undefined
|
||||
: {
|
||||
count: 1,
|
||||
label: `Error handler ran in iteration ${first + 1}`,
|
||||
title: 'Show that iteration',
|
||||
reveal: () =>
|
||||
data.eventHandlers.selectedIteration({
|
||||
id: iterations[first],
|
||||
index: first,
|
||||
manuallySet: true,
|
||||
moduleId: data.id
|
||||
})
|
||||
},
|
||||
() => undefined
|
||||
)
|
||||
}
|
||||
return undefined
|
||||
})
|
||||
|
||||
let attempts = $derived.by(() => {
|
||||
const jobs = state?.attempt_jobs
|
||||
if (!jobs?.length) return undefined
|
||||
@@ -111,11 +204,20 @@
|
||||
})
|
||||
|
||||
// An expanded subflow is drawn as its steps instead of this node, each with its own bar.
|
||||
let retriedInside = $derived(
|
||||
flowRunStatus?.showsRun && !data.editMode && data.module?.value?.type === 'flow'
|
||||
? flowRunStatus.retriedStepsInside(data.id)
|
||||
: 0
|
||||
)
|
||||
let retriedInside = $derived.by((): InsideMark | undefined => {
|
||||
const count =
|
||||
flowRunStatus?.showsRun && !data.editMode && data.module?.value?.type === 'flow'
|
||||
? flowRunStatus.retriedStepsInside(data.id)
|
||||
: 0
|
||||
return count > 0
|
||||
? {
|
||||
count,
|
||||
label: `${count} step${count === 1 ? '' : 's'} retried inside`,
|
||||
title: 'Expand to see the retried steps',
|
||||
reveal: expandSubflow
|
||||
}
|
||||
: undefined
|
||||
})
|
||||
|
||||
let type = $derived.by(() => {
|
||||
let typ = state?.type
|
||||
@@ -217,7 +319,6 @@
|
||||
nodeState={state?.skipped ? '_Skipped' : type}
|
||||
duration_ms={state?.duration_ms}
|
||||
retries={state?.retries}
|
||||
{retriedInside}
|
||||
{flowJobs}
|
||||
{attempts}
|
||||
on:delete={(e) => {
|
||||
@@ -245,19 +346,18 @@
|
||||
onEditInput={data.eventHandlers.editInput}
|
||||
flowJob={flowRunStatus?.flowJob}
|
||||
isOwner={data.isOwner}
|
||||
errorHandler={data.isErrorHandler}
|
||||
maximizeSubflow={data.module?.value?.type == 'flow' && 'path' in data.module.value
|
||||
? () => {
|
||||
const path =
|
||||
data.module?.value && 'path' in data.module.value
|
||||
? (data.module.value['path'] as string)
|
||||
: undefined
|
||||
if (path) {
|
||||
data.eventHandlers.expandSubflow(data.id, path)
|
||||
}
|
||||
}
|
||||
? expandSubflow
|
||||
: undefined}
|
||||
/>
|
||||
|
||||
{#await hiddenErrorHandlers}
|
||||
{@render insideBar(retriedInside, undefined)}
|
||||
{:then handlers}
|
||||
{@render insideBar(retriedInside, handlers)}
|
||||
{/await}
|
||||
|
||||
{#if (data.module?.value?.type === 'branchall' || data.module?.value?.type === 'branchone') && data.insertable}
|
||||
<div class="absolute -bottom-10 left-1/2 transform -translate-x-1/2 z-10 flex gap-1">
|
||||
<button
|
||||
@@ -276,3 +376,72 @@
|
||||
{/if}
|
||||
{/snippet}
|
||||
</NodeWrapper>
|
||||
|
||||
<!-- Left of the settings bar, which is this step's own policy: this is what happened inside. -->
|
||||
{#snippet insideBar(retried: InsideMark | undefined, handlers: InsideMark | undefined)}
|
||||
{#if retried || handlers}
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div
|
||||
class="nodrag nopan absolute -left-1 top-[calc(100%+3px)] z-10"
|
||||
onpointerdown={(e) => e.stopPropagation()}
|
||||
>
|
||||
{#if retried && handlers}
|
||||
<!-- Both at once: their counts side by side, each way in from the menu. -->
|
||||
<DropdownV2
|
||||
placement="bottom-start"
|
||||
usePointerDownOutside
|
||||
fixedHeight={false}
|
||||
items={[
|
||||
{
|
||||
displayName: retried.label,
|
||||
icon: RefreshCw,
|
||||
iconColor: '#f97316',
|
||||
action: retried.reveal
|
||||
},
|
||||
{
|
||||
displayName: handlers.label,
|
||||
icon: Bug,
|
||||
iconColor: '#f87171',
|
||||
action: handlers.reveal
|
||||
}
|
||||
]}
|
||||
>
|
||||
{#snippet buttonReplacement()}
|
||||
<Button
|
||||
nonCaptureEvent
|
||||
variant="subtle"
|
||||
unifiedSize="2xs"
|
||||
btnClasses="gap-2 text-2xs text-secondary"
|
||||
title="{retried.label}, {handlers.label}"
|
||||
>
|
||||
<span class="flex items-center gap-0.5">
|
||||
<RefreshCw size={12} class="text-orange-500" />{retried.count}
|
||||
</span>
|
||||
<span class="flex items-center gap-0.5">
|
||||
<Bug size={12} class="text-red-400 dark:text-red-500" />{handlers.count}
|
||||
</span>
|
||||
</Button>
|
||||
{/snippet}
|
||||
</DropdownV2>
|
||||
{:else}
|
||||
{@const mark = (retried ?? handlers)!}
|
||||
<Button
|
||||
variant="subtle"
|
||||
unifiedSize="2xs"
|
||||
startIcon={{
|
||||
icon: retried ? RefreshCw : Bug,
|
||||
classes: retried ? 'text-orange-500' : 'text-red-400 dark:text-red-500'
|
||||
}}
|
||||
btnClasses="text-2xs text-secondary gap-1"
|
||||
title={mark.title}
|
||||
onClick={(e) => {
|
||||
e?.stopPropagation()
|
||||
mark.reveal()
|
||||
}}
|
||||
>
|
||||
{mark.label}
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{/snippet}
|
||||
|
||||
Reference in New Issue
Block a user