@jive-sh/workflow-platform 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -15
- package/dist/cpu-limit/limiter.js +54 -11
- package/dist/cpu-limit/limiter.js.map +1 -1
- package/dist/index.js +44 -39
- package/dist/index.js.map +1 -1
- package/dist/keep-running.js +5 -5
- package/dist/keep-running.js.map +1 -1
- package/dist/pick-wakes.js +7 -1
- package/dist/pick-wakes.js.map +1 -1
- package/dist/queue-counts.js +47 -0
- package/dist/queue-counts.js.map +1 -0
- package/dist/steps.js +75 -18
- package/dist/steps.js.map +1 -1
- package/dist/storage/budgets.js +14 -0
- package/dist/storage/budgets.js.map +1 -1
- package/dist/storage/sqlite-store.js +68 -15
- package/dist/storage/sqlite-store.js.map +1 -1
- package/dist/views/workflow-flows.js +53 -0
- package/dist/views/workflow-flows.js.map +1 -0
- package/dist/views/workflows-view.js +81 -55
- package/dist/views/workflows-view.js.map +1 -1
- package/package.json +1 -1
- package/src/cpu-limit/limiter.ts +61 -11
- package/src/dashboard/dashboard.css +78 -0
- package/src/dashboard/index.tsx +3 -0
- package/src/dashboard/queue-chart.tsx +137 -0
- package/src/dashboard/step-graph.tsx +98 -0
- package/src/dashboard/workflow-dag.tsx +256 -0
- package/src/dashboard/workflows-dashboard.tsx +313 -0
- package/src/index.ts +46 -39
- package/src/keep-running.ts +5 -7
- package/src/pick-wakes.ts +9 -2
- package/src/queue-counts.ts +61 -0
- package/src/steps.ts +83 -26
- package/src/storage/budgets.ts +13 -0
- package/src/storage/sqlite-store.ts +82 -18
- package/src/storage/step-records.ts +6 -5
- package/src/storage/task-store.ts +32 -0
- package/src/views/workflow-flows.ts +97 -0
- package/src/views/workflows-view.ts +148 -82
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* THE PROJECT'S WORKFLOWS AS A DAG, laid out by ELK's layered algorithm (`elkjs`, which the host page brings, as it brings
|
|
5
|
+
* React): each workflow one node, in layers in topological order of the forward edges, so every forward arrow points down;
|
|
6
|
+
* each stage's layers kept together (ELK's partitions, one per stage in the project's order) and shown as a band named in
|
|
7
|
+
* a gutter on the left that no edge enters. Edges are routed orthogonally around the nodes, each with its label beside its
|
|
8
|
+
* own line and its arrowhead at its target. A send-back, the only edge against the flow, is routed apart by ELK as a feedback
|
|
9
|
+
* edge, dashed and labelled "sends back". Workflows no work flows to or from are listed under their stages below the map.
|
|
10
|
+
*
|
|
11
|
+
* Chosen over dagre (`@dagrejs/dagre`): ELK routes edges around nodes and places labels beside their own edges, lays out
|
|
12
|
+
* partitions in order and routes feedback edges apart; dagre does none of those, and its edges and labels cross nodes.
|
|
13
|
+
*/
|
|
14
|
+
import ELK, { type ElkNode } from 'elkjs/lib/elk.bundled.js';
|
|
15
|
+
import { useEffect, useLayoutEffect, useRef, useState, type CSSProperties, type ReactNode } from 'react';
|
|
16
|
+
import type { WorkflowFlow } from '../views/workflow-flows';
|
|
17
|
+
import type { WorkflowView, WorkflowsView } from '../views/workflows-view';
|
|
18
|
+
|
|
19
|
+
/** What starts a workflow's runs, in words. */
|
|
20
|
+
const startsLine = (w: WorkflowView): string =>
|
|
21
|
+
w.startsOn.kind === 'queue' ? 'runs on its queue'
|
|
22
|
+
: w.startsOn.kind === 'inputs' ? `runs when its inputs change: ${w.startsOn.says}`
|
|
23
|
+
: 'runs on a timer or a request';
|
|
24
|
+
|
|
25
|
+
/** A queue's progress as a bar: done, running, queued and the rest, each segment lighter or darker than its neighbours. */
|
|
26
|
+
function QueueBar({ queue }: { readonly queue: NonNullable<WorkflowView['queue']> }) {
|
|
27
|
+
const rest = queue.waiting + queue.stuck + queue.held;
|
|
28
|
+
const total = Math.max(1, queue.done + queue.running + queue.queued + rest);
|
|
29
|
+
const segments = [
|
|
30
|
+
{ n: queue.done, cls: 'wp-seg-done' },
|
|
31
|
+
{ n: queue.running, cls: 'wp-seg-running' },
|
|
32
|
+
{ n: queue.queued, cls: 'wp-seg-queued' },
|
|
33
|
+
{ n: rest, cls: 'wp-seg-rest' },
|
|
34
|
+
];
|
|
35
|
+
const words = [
|
|
36
|
+
`${queue.queued.toLocaleString('en-US')} queued`,
|
|
37
|
+
`${queue.running.toLocaleString('en-US')} running`,
|
|
38
|
+
`${queue.done.toLocaleString('en-US')} done`,
|
|
39
|
+
...(['waiting', 'stuck', 'held'] as const).filter((b) => queue[b] > 0).map((b) => `${queue[b].toLocaleString('en-US')} ${b}`),
|
|
40
|
+
];
|
|
41
|
+
return (
|
|
42
|
+
<div className="wp-queue">
|
|
43
|
+
<div className="wp-bar" role="img" aria-label={words.join(', ')}>
|
|
44
|
+
{segments.map((s) => (s.n === 0 ? null : <span key={s.cls} className={s.cls} style={{ width: `${(100 * s.n) / total}%` }} />))}
|
|
45
|
+
</div>
|
|
46
|
+
<div className="wp-queue-words">{words.join(' · ')}</div>
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** An edge's label: what it is, and along a wait how many wait. */
|
|
52
|
+
const flowLabel = (f: WorkflowFlow): string => (f.kind === 'waits on' ? `${f.waiting.toLocaleString('en-US')} wait on it` : f.kind);
|
|
53
|
+
/** An edge's line: solid feeds, dashed sends back, dotted gives input, dash-dot waits on. */
|
|
54
|
+
const DASH: Readonly<Record<WorkflowFlow['kind'], string | undefined>> = { feeds: undefined, 'sends back': '7 4', 'gives input': '1.5 3.5', 'waits on': '7 3 1.5 3' };
|
|
55
|
+
|
|
56
|
+
/** The node's width; its height is measured from what it shows. */
|
|
57
|
+
const NODE_WIDTH = 250;
|
|
58
|
+
/** The left gutter the stages are named in. */
|
|
59
|
+
const GUTTER = 150;
|
|
60
|
+
const LABEL_HEIGHT = 15;
|
|
61
|
+
const labelWidth = (text: string) => Math.ceil(text.length * 6.3) + 10;
|
|
62
|
+
|
|
63
|
+
interface Laid {
|
|
64
|
+
readonly nodes: ReadonlyMap<string, { readonly x: number; readonly y: number; readonly h: number }>;
|
|
65
|
+
readonly edges: ReadonlyArray<{ readonly flow: WorkflowFlow; readonly points: ReadonlyArray<{ readonly x: number; readonly y: number }>; readonly label: { readonly x: number; readonly y: number; readonly w: number } | null }>;
|
|
66
|
+
readonly width: number;
|
|
67
|
+
readonly height: number;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const elk = new ELK();
|
|
71
|
+
|
|
72
|
+
/** The layout of the linked workflows, given each node's height. */
|
|
73
|
+
const layOut = async (input: {
|
|
74
|
+
/** In pipeline order: by stage, then by depth through forward edges within it. */
|
|
75
|
+
readonly workflows: ReadonlyArray<{ readonly name: string; readonly stage: number; readonly height: number }>;
|
|
76
|
+
readonly flows: ReadonlyArray<WorkflowFlow>;
|
|
77
|
+
}): Promise<Laid> => {
|
|
78
|
+
const asked: ElkNode = {
|
|
79
|
+
id: 'workflows',
|
|
80
|
+
layoutOptions: {
|
|
81
|
+
'elk.algorithm': 'layered',
|
|
82
|
+
'elk.direction': 'DOWN',
|
|
83
|
+
'elk.edgeRouting': 'ORTHOGONAL',
|
|
84
|
+
'elk.partitioning.activate': 'true',
|
|
85
|
+
// One layering for all, so every stage's layers come before the next stage's; laid out apart, unconnected groups sat side by side.
|
|
86
|
+
'elk.separateConnectedComponents': 'false',
|
|
87
|
+
'elk.layered.feedbackEdges': 'true',
|
|
88
|
+
// The platform's pipeline order decides which edges go against the flow: only one to a workflow earlier in it, a
|
|
89
|
+
// send-back. Left to itself, ELK kept Retry near-misses' send-back as forward and drew Decompile's feed going up.
|
|
90
|
+
'elk.layered.cycleBreaking.strategy': 'MODEL_ORDER',
|
|
91
|
+
'elk.layered.considerModelOrder.strategy': 'NODES_AND_EDGES',
|
|
92
|
+
'elk.layered.spacing.nodeNodeBetweenLayers': '64',
|
|
93
|
+
'elk.spacing.nodeNode': '36',
|
|
94
|
+
'elk.spacing.edgeNode': '18',
|
|
95
|
+
'elk.spacing.edgeEdge': '12',
|
|
96
|
+
'elk.spacing.edgeLabel': '4',
|
|
97
|
+
'elk.layered.edgeLabels.sideSelection': 'SMART_DOWN',
|
|
98
|
+
'elk.padding': `[top=34,left=${GUTTER},bottom=16,right=16]`,
|
|
99
|
+
},
|
|
100
|
+
children: input.workflows.map((w) => ({ id: w.name, width: NODE_WIDTH, height: w.height, layoutOptions: { 'elk.partitioning.partition': String(w.stage) } })),
|
|
101
|
+
edges: input.flows.map((f, i) => ({ id: `edge-${i}`, sources: [f.from], targets: [f.to], labels: [{ id: `label-${i}`, text: flowLabel(f), width: labelWidth(flowLabel(f)), height: LABEL_HEIGHT }] })),
|
|
102
|
+
};
|
|
103
|
+
const graph = await elk.layout(asked);
|
|
104
|
+
const nodes = new Map((graph.children ?? []).map((c) => [c.id, { x: c.x ?? 0, y: c.y ?? 0, h: c.height ?? 0 }]));
|
|
105
|
+
const edges = (graph.edges ?? []).map((e, i) => {
|
|
106
|
+
const s = e.sections?.[0];
|
|
107
|
+
const label = e.labels?.[0];
|
|
108
|
+
return {
|
|
109
|
+
flow: input.flows[i]!,
|
|
110
|
+
points: s === undefined ? [] : [s.startPoint, ...(s.bendPoints ?? []), s.endPoint],
|
|
111
|
+
label: label === undefined || label.x === undefined || label.y === undefined ? null : { x: label.x, y: label.y, w: label.width ?? 0 },
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
return { nodes, edges, width: graph.width ?? 0, height: graph.height ?? 0 };
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export interface WorkflowDagProps {
|
|
118
|
+
readonly view: WorkflowsView;
|
|
119
|
+
readonly phaseLabel: (phase: string) => string;
|
|
120
|
+
/** A stage's figures, beside its name. */
|
|
121
|
+
readonly phaseLine: (phase: string) => ReactNode;
|
|
122
|
+
/** A node's runs and agents now, with its limit controls. */
|
|
123
|
+
readonly nodeStatus: (w: WorkflowView) => ReactNode;
|
|
124
|
+
/** A node's link to its definition. */
|
|
125
|
+
readonly nodeHref: (w: WorkflowView) => string;
|
|
126
|
+
/** The open node's steps, graph and costs. */
|
|
127
|
+
readonly detail: (w: WorkflowView) => ReactNode;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function Node({ w, flows, open, setOpen, nodeStatus, nodeHref, style }: { readonly w: WorkflowView; readonly flows: ReadonlyArray<WorkflowFlow>; readonly open: boolean; readonly setOpen: (open: boolean) => void; readonly nodeStatus: (w: WorkflowView) => ReactNode; readonly nodeHref: (w: WorkflowView) => string; readonly style?: CSSProperties }) {
|
|
131
|
+
const into = flows.filter((f) => f.to === w.name);
|
|
132
|
+
const out = flows.filter((f) => f.from === w.name);
|
|
133
|
+
const word = (f: WorkflowFlow) => (f.kind === 'feeds' ? '' : f.kind === 'waits on' ? ` (${f.waiting.toLocaleString('en-US')} waiting)` : ` (${f.kind})`);
|
|
134
|
+
return (
|
|
135
|
+
<div data-workflow={w.name} className={open ? 'wp-node wp-node-open' : 'wp-node'} style={style}>
|
|
136
|
+
<div className="wp-node-head">
|
|
137
|
+
<button type="button" className="wp-node-name" aria-expanded={open} onClick={() => setOpen(!open)} title={w.description}>{open ? '▾' : '▸'} {w.name}</button>
|
|
138
|
+
<a className="wp-mut" href={nodeHref(w)} title="Its definition">source</a>
|
|
139
|
+
</div>
|
|
140
|
+
<div className="wp-node-what" title={w.description}>{w.description}</div>
|
|
141
|
+
<div className="wp-node-starts wp-mut" title={startsLine(w)}>{startsLine(w)}</div>
|
|
142
|
+
{into.length === 0 && out.length === 0 ? null : (
|
|
143
|
+
<div className="wp-node-flows wp-mut">
|
|
144
|
+
{into.length === 0 ? null : <span>from {into.map((f) => `${f.from}${word(f)}`).join(', ')}</span>}
|
|
145
|
+
{out.length === 0 ? null : <span>to {out.map((f) => `${f.to}${word(f)}`).join(', ')}</span>}
|
|
146
|
+
</div>
|
|
147
|
+
)}
|
|
148
|
+
{w.queue === null ? null : <QueueBar queue={w.queue} />}
|
|
149
|
+
<div className="wp-node-status">{nodeStatus(w)}</div>
|
|
150
|
+
</div>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export function WorkflowDag({ view, phaseLabel, phaseLine, nodeStatus, nodeHref, detail }: WorkflowDagProps) {
|
|
155
|
+
const [open, setOpenName] = useState<string | null>(null);
|
|
156
|
+
const all = view.groups.flatMap((g) => g.workflows);
|
|
157
|
+
const linkedNames = new Set(view.flows.flatMap((f) => [f.from, f.to]));
|
|
158
|
+
const linked = all.filter((w) => linkedNames.has(w.name));
|
|
159
|
+
const stageOf = new Map(view.groups.map((g, i) => [g.phase, i]));
|
|
160
|
+
const openWorkflow = all.find((w) => w.name === open) ?? null;
|
|
161
|
+
const panel = useRef<HTMLDivElement>(null);
|
|
162
|
+
const setOpen = (name: string) => (on: boolean) => setOpenName(on ? name : null);
|
|
163
|
+
useEffect(() => { if (open !== null) panel.current?.scrollIntoView({ block: 'nearest', behavior: 'smooth' }); }, [open]);
|
|
164
|
+
|
|
165
|
+
// Each node's height, measured as drawn, then the layout from them; laid out again whenever a height or the flows change.
|
|
166
|
+
const map = useRef<HTMLDivElement>(null);
|
|
167
|
+
const [heights, setHeights] = useState<string>('');
|
|
168
|
+
const [laid, setLaid] = useState<Laid | null>(null);
|
|
169
|
+
const [failed, setFailed] = useState<string | null>(null);
|
|
170
|
+
useLayoutEffect(() => {
|
|
171
|
+
const el = map.current;
|
|
172
|
+
if (el === null) return;
|
|
173
|
+
const measure = () => setHeights(JSON.stringify([...el.querySelectorAll('[data-workflow]')].map((n) => [n.getAttribute('data-workflow'), Math.ceil(n.getBoundingClientRect().height)])));
|
|
174
|
+
measure();
|
|
175
|
+
const watch = new ResizeObserver(measure);
|
|
176
|
+
for (const n of el.querySelectorAll('[data-workflow]')) watch.observe(n);
|
|
177
|
+
return () => watch.disconnect();
|
|
178
|
+
}, [view.at, linked.length]);
|
|
179
|
+
const flowsKey = JSON.stringify(view.flows.map((f) => [f.from, f.to, f.kind, flowLabel(f)]));
|
|
180
|
+
useEffect(() => {
|
|
181
|
+
if (heights === '') return;
|
|
182
|
+
const h = new Map(JSON.parse(heights) as Array<[string, number]>);
|
|
183
|
+
let current = true;
|
|
184
|
+
const inOrder = [...linked].sort((a, b) => a.place.stage - b.place.stage || a.place.depth - b.place.depth || a.name.localeCompare(b.name));
|
|
185
|
+
layOut({ workflows: inOrder.map((w) => ({ name: w.name, stage: stageOf.get(w.phase) ?? 0, height: h.get(w.name) ?? 120 })), flows: view.flows })
|
|
186
|
+
.then((l) => { if (current) { setLaid(l); setFailed(null); } })
|
|
187
|
+
.catch((e: unknown) => { if (current) setFailed(e instanceof Error ? e.message : String(e)); });
|
|
188
|
+
return () => { current = false; };
|
|
189
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- `linked` and `stageOf` follow `heights` and `flowsKey`.
|
|
190
|
+
}, [heights, flowsKey]);
|
|
191
|
+
|
|
192
|
+
// Each stage's band: from the top of its first node to the bottom of its last.
|
|
193
|
+
const bands = laid === null ? [] : view.groups.flatMap((g) => {
|
|
194
|
+
const ys = linked.filter((w) => w.phase === g.phase).flatMap((w) => { const n = laid.nodes.get(w.name); return n === undefined ? [] : [{ top: n.y, bottom: n.y + n.h }]; });
|
|
195
|
+
return ys.length === 0 ? [] : [{ phase: g.phase, top: Math.min(...ys.map((y) => y.top)) - 24, bottom: Math.max(...ys.map((y) => y.bottom)) + 14 }];
|
|
196
|
+
});
|
|
197
|
+
const unlinked = view.groups.map((g) => ({ phase: g.phase, workflows: g.workflows.filter((w) => !linkedNames.has(w.name)) })).filter((g) => g.workflows.length > 0);
|
|
198
|
+
|
|
199
|
+
return (
|
|
200
|
+
<div className="wp-dag-wrap">
|
|
201
|
+
<p className="wp-line wp-mut">
|
|
202
|
+
Each box is one workflow; open one for its steps. Arrows point the way work goes, down the page: a solid arrow feeds the next
|
|
203
|
+
workflow's tasks; dashed, “sends back”, returns work to an earlier one. Each stage is a band, named on the left.
|
|
204
|
+
</p>
|
|
205
|
+
{failed === null ? null : <p className="wp-line wp-bad">The map could not be laid out: {failed}</p>}
|
|
206
|
+
<div className="wp-dag-scroll">
|
|
207
|
+
<div ref={map} className="wp-dag" style={{ width: laid === null ? undefined : laid.width, height: laid === null ? undefined : laid.height }}>
|
|
208
|
+
{laid === null ? null : (
|
|
209
|
+
<svg className="wp-dag-edges" width={laid.width} height={laid.height} aria-hidden="true">
|
|
210
|
+
<defs>
|
|
211
|
+
<marker id="wp-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="11" markerHeight="11" markerUnits="userSpaceOnUse" orient="auto">
|
|
212
|
+
<path d="M0,0 L10,5 L0,10 z" fill="var(--wp-edge)" />
|
|
213
|
+
</marker>
|
|
214
|
+
</defs>
|
|
215
|
+
{bands.map((b, i) => (
|
|
216
|
+
<g key={b.phase}>
|
|
217
|
+
<rect x={0} y={b.top} width={laid.width} height={b.bottom - b.top} fill={i % 2 === 0 ? 'var(--wp-band)' : 'transparent'} />
|
|
218
|
+
<foreignObject x={6} y={b.top + 6} width={GUTTER - 16} height={Math.max(40, b.bottom - b.top - 12)}>
|
|
219
|
+
<div className="wp-band-name">{phaseLabel(b.phase)}<span className="wp-mut"> · {phaseLine(b.phase)}</span></div>
|
|
220
|
+
</foreignObject>
|
|
221
|
+
</g>
|
|
222
|
+
))}
|
|
223
|
+
{laid.edges.map(({ flow, points }) => (
|
|
224
|
+
<polyline key={`${flow.from}>${flow.to}`} points={points.map((p) => `${p.x},${p.y}`).join(' ')} fill="none" stroke="var(--wp-edge)"
|
|
225
|
+
strokeWidth={flow.kind === 'feeds' ? 1.8 : 1.5} strokeDasharray={DASH[flow.kind]} markerEnd="url(#wp-arrow)" />
|
|
226
|
+
))}
|
|
227
|
+
{laid.edges.map(({ flow, label }) => (label === null ? null : (
|
|
228
|
+
<g key={`label:${flow.from}>${flow.to}`}>
|
|
229
|
+
<rect x={label.x} y={label.y} width={label.w} height={LABEL_HEIGHT} rx={3} fill="var(--wp-bg)" stroke="var(--wp-edge)" strokeWidth="0.7" />
|
|
230
|
+
<text x={label.x + 5} y={label.y + 11} fontSize="10.5" fill="var(--wp-fg)">{flowLabel(flow)}{flow.why === null ? null : <title>{flow.why}</title>}</text>
|
|
231
|
+
</g>
|
|
232
|
+
)))}
|
|
233
|
+
</svg>
|
|
234
|
+
)}
|
|
235
|
+
{linked.map((w) => {
|
|
236
|
+
const at = laid?.nodes.get(w.name);
|
|
237
|
+
return (
|
|
238
|
+
<Node key={w.name} w={w} flows={view.flows} open={open === w.name} setOpen={setOpen(w.name)} nodeStatus={nodeStatus} nodeHref={nodeHref}
|
|
239
|
+
style={at === undefined ? { position: 'absolute', left: 0, top: 0, visibility: 'hidden' } : { position: 'absolute', left: at.x, top: at.y }} />
|
|
240
|
+
);
|
|
241
|
+
})}
|
|
242
|
+
</div>
|
|
243
|
+
</div>
|
|
244
|
+
{openWorkflow === null || !linkedNames.has(openWorkflow.name) ? null : <div ref={panel} className="wp-node-detail">{detail(openWorkflow)}</div>}
|
|
245
|
+
{unlinked.map((g) => (
|
|
246
|
+
<section key={g.phase} className="wp-stage">
|
|
247
|
+
<h2 className="wp-h2">{phaseLabel(g.phase)}: workflows no work flows to or from<span className="wp-mut"> · {phaseLine(g.phase)}</span></h2>
|
|
248
|
+
<div className="wp-nodes">
|
|
249
|
+
{g.workflows.map((w) => <Node key={w.name} w={w} flows={view.flows} open={open === w.name} setOpen={setOpen(w.name)} nodeStatus={nodeStatus} nodeHref={nodeHref} />)}
|
|
250
|
+
</div>
|
|
251
|
+
{openWorkflow !== null && openWorkflow.phase === g.phase && !linkedNames.has(openWorkflow.name) ? <div ref={panel} className="wp-node-detail">{detail(openWorkflow)}</div> : null}
|
|
252
|
+
</section>
|
|
253
|
+
))}
|
|
254
|
+
</div>
|
|
255
|
+
);
|
|
256
|
+
}
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* THE GENERIC VIEW OF A PROJECT'S WORKFLOWS: each queue over time, and every workflow a box on one map, with its queue, its
|
|
5
|
+
* runs now and its limits. An opened workflow shows its steps (what each cost and where its runs are now, what a waiting
|
|
6
|
+
* one waits on), its step graph with the window's runs on each edge, and where its runs stopped and why. It reads the
|
|
7
|
+
* platform's two readings (`views/workflows-view.ts`: every workflow at each poll, one workflow's figures when it is
|
|
8
|
+
* opened) and runs now (`views/runs-now.ts`); a project plugs its own panels in around it (`header`, `panels`,
|
|
9
|
+
* `phaseSummary`). Uses React and the layout library the map names, which the host page brings.
|
|
10
|
+
*/
|
|
11
|
+
import { Fragment, useEffect, useState, type ReactNode } from 'react';
|
|
12
|
+
import type { PhaseRunsNow, StepRunsNow, WorkflowRunsNow } from '../views/runs-now';
|
|
13
|
+
import type { StepFunnel } from '../views/step-funnel';
|
|
14
|
+
import type { WorkflowGraph } from '../views/step-graph';
|
|
15
|
+
import type { SourceLink, StepCost, WorkflowFigures, WorkflowView, WorkflowsView } from '../views/workflows-view';
|
|
16
|
+
import { compact, duration, localTime, whenAgo } from '../views/format';
|
|
17
|
+
import { QueueChart } from './queue-chart';
|
|
18
|
+
import { StepGraph } from './step-graph';
|
|
19
|
+
import { WorkflowDag } from './workflow-dag';
|
|
20
|
+
|
|
21
|
+
/** What the page is given at each poll, all of it read at the request: every workflow, and where runs are now. */
|
|
22
|
+
export interface WorkflowsPageData {
|
|
23
|
+
readonly view: WorkflowsView;
|
|
24
|
+
readonly runsNow: ReadonlyArray<PhaseRunsNow>;
|
|
25
|
+
/** The one CPU limit and the newest reading of what the project used (`CpuLimit`). */
|
|
26
|
+
readonly cpu: { readonly limit: number; readonly use: { readonly at: number; readonly cores: number; readonly held: number; readonly waiting: number } | null };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type WorkflowLimits = NonNullable<WorkflowView['limits']>;
|
|
30
|
+
|
|
31
|
+
/** Which of a workflow's two limits a control sets. */
|
|
32
|
+
export type LimitName = 'runs' | 'agents';
|
|
33
|
+
|
|
34
|
+
/** Stores one of a workflow's limits: a whole number, or none for the run limit's default (its agents' limit). The project's own route. */
|
|
35
|
+
export type SetLimit = (r: { readonly workflow: string; readonly limit: LimitName; readonly value: number | null }) => Promise<void>;
|
|
36
|
+
|
|
37
|
+
/** Where the project stands against its one CPU limit, in words. */
|
|
38
|
+
const cpuLine = (cpu: WorkflowsPageData['cpu'], now: number): string =>
|
|
39
|
+
cpu.use === null
|
|
40
|
+
? `CPU limit: ${cpu.limit} cores; no reading of what the project uses yet.`
|
|
41
|
+
: `CPU: the project used ${cpu.use.cores.toFixed(1)} of its ${cpu.limit}-core limit at ${whenAgo(cpu.use.at, now)}; ${cpu.use.held} slot${cpu.use.held === 1 ? '' : 's'} held, ${cpu.use.waiting} waiting.`;
|
|
42
|
+
|
|
43
|
+
export interface WorkflowsDashboardProps {
|
|
44
|
+
readonly data: WorkflowsPageData | null;
|
|
45
|
+
/** Why the data could not be read, if it could not; the last data read stays shown. */
|
|
46
|
+
readonly error: string | null;
|
|
47
|
+
/** Where one workflow's figures are read from when it is opened (`WorkflowFigures`): the project's route for them. */
|
|
48
|
+
readonly figuresUrl: (workflow: string) => string;
|
|
49
|
+
/** Where a definition's link goes: the project's source viewer. */
|
|
50
|
+
readonly sourceHref: (source: SourceLink) => string;
|
|
51
|
+
/** The project's own lines above everything: its title, its status. */
|
|
52
|
+
readonly header?: ReactNode;
|
|
53
|
+
/** The project's own panels, between the header and the workflows. */
|
|
54
|
+
readonly panels?: ReactNode;
|
|
55
|
+
/** The project's name for one phase, in its own words; the phase's key where it gives none. */
|
|
56
|
+
readonly phaseLabel?: (phase: string) => string;
|
|
57
|
+
/** The project's figures for one phase, on its heading line. */
|
|
58
|
+
readonly phaseSummary?: (phase: string) => ReactNode;
|
|
59
|
+
/** How the page sets a limit; with none the limits show without controls. */
|
|
60
|
+
readonly setLimit?: SetLimit;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Polls a JSON route one request at a time, the next asked for when this one has answered. */
|
|
64
|
+
export const usePolledJson = <A,>(url: string, everyMs: number): { readonly data: A | null; readonly error: string | null } => {
|
|
65
|
+
const [data, setData] = useState<A | null>(null);
|
|
66
|
+
const [error, setError] = useState<string | null>(null);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
let alive = true;
|
|
69
|
+
let next: ReturnType<typeof setTimeout> | undefined;
|
|
70
|
+
const tick = async () => {
|
|
71
|
+
try {
|
|
72
|
+
const r = await fetch(url, { cache: 'no-store' });
|
|
73
|
+
if (!r.ok) throw new Error(`${r.status} ${(await r.text()).slice(0, 200)}`);
|
|
74
|
+
const body = (await r.json()) as A;
|
|
75
|
+
if (alive) { setData(body); setError(null); }
|
|
76
|
+
} catch (e) {
|
|
77
|
+
if (alive) setError(e instanceof Error ? e.message : String(e));
|
|
78
|
+
}
|
|
79
|
+
if (alive) next = setTimeout(() => void tick(), everyMs);
|
|
80
|
+
};
|
|
81
|
+
void tick();
|
|
82
|
+
return () => { alive = false; clearTimeout(next); };
|
|
83
|
+
}, [url, everyMs]);
|
|
84
|
+
return { data, error };
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const costCells = (c: StepCost | null, agent: boolean): ReactNode => (
|
|
88
|
+
<>
|
|
89
|
+
<td className="wp-r">{c === null ? '' : c.calls.toLocaleString('en-US')}</td>
|
|
90
|
+
<td className={c !== null && c.failed > 0 ? 'wp-r wp-bad' : 'wp-r'}>{c === null || c.failed === 0 ? '' : c.failed.toLocaleString('en-US')}</td>
|
|
91
|
+
<td className="wp-r">{c === null ? '' : duration(c.seconds)}</td>
|
|
92
|
+
<td className="wp-r">{c === null || !agent ? '' : `${compact(c.inputTokens)} / ${compact(c.outputTokens)}`}</td>
|
|
93
|
+
<td className="wp-r">{c === null ? '' : duration(c.cpuSeconds)}</td>
|
|
94
|
+
<td className="wp-r">{c === null || c.items === 0 ? '' : c.items.toLocaleString('en-US')}</td>
|
|
95
|
+
</>
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
/** Where a step's runs are now, in words: "2 in it", "1 waiting after it since 5:04 AM · 3 min ago". */
|
|
99
|
+
const nowCell = (s: StepRunsNow | undefined, now: number): string => {
|
|
100
|
+
if (s === undefined) return '';
|
|
101
|
+
const parts = [
|
|
102
|
+
...(s.inStep > 0 ? [`${s.inStep} in it`] : []),
|
|
103
|
+
...(s.waitingAfter > 0 ? [`${s.waitingAfter} after it${s.waitingSince === null ? '' : `, since ${whenAgo(s.waitingSince, now)}`}`] : []),
|
|
104
|
+
];
|
|
105
|
+
return parts.join(', ');
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
function StepsTable({ workflow, usesAgents, runs, now }: { readonly workflow: WorkflowFigures; readonly usesAgents: boolean; readonly runs: WorkflowRunsNow | undefined; readonly now: number }) {
|
|
109
|
+
const runsOf = (step: string) => runs?.steps.find((s) => s.step === step);
|
|
110
|
+
return (
|
|
111
|
+
<div className="wp-tablewrap"><table className="wp-table">
|
|
112
|
+
<thead>
|
|
113
|
+
<tr>
|
|
114
|
+
<th>step</th><th title="Uses an agent">agent</th><th>runs now</th>
|
|
115
|
+
<th className="wp-r">calls</th><th className="wp-r">failed</th><th className="wp-r">time</th>
|
|
116
|
+
<th className="wp-r" title="Input tokens, fresh and cached / output tokens">tokens in / out</th>
|
|
117
|
+
<th className="wp-r" title="Its own and its processes' CPU">CPU</th><th className="wp-r">items</th>
|
|
118
|
+
<th title="How its records ended, commonest first; the rest in the hover">ended</th>
|
|
119
|
+
</tr>
|
|
120
|
+
</thead>
|
|
121
|
+
<tbody>
|
|
122
|
+
{workflow.steps.map((s) => {
|
|
123
|
+
const at = runsOf(s.name);
|
|
124
|
+
return (
|
|
125
|
+
<Fragment key={s.name}>
|
|
126
|
+
<tr>
|
|
127
|
+
<td title={s.description} className={s.declared ? '' : 'wp-bad'}>{s.name}{s.declared ? '' : ' (not declared)'}</td>
|
|
128
|
+
<td>{s.agent ? '✓' : ''}</td>
|
|
129
|
+
<td className="wp-mut">{nowCell(at, now)}</td>
|
|
130
|
+
{costCells(s.cost, s.agent)}
|
|
131
|
+
<td className="wp-mut" title={s.endings.map((e) => `${e.records} ${e.outcome}: ${e.reason}`).join('\n')}>{s.endings.length === 0 ? '' : `${s.endings[0]!.reason} (${s.endings[0]!.records})`}</td>
|
|
132
|
+
</tr>
|
|
133
|
+
{at?.waitingOn === null || at?.waitingOn === undefined ? null : (
|
|
134
|
+
<tr><td /><td /><td colSpan={8} className="wp-mut">waits: {at.waitingOn}</td></tr>
|
|
135
|
+
)}
|
|
136
|
+
</Fragment>
|
|
137
|
+
);
|
|
138
|
+
})}
|
|
139
|
+
<tr className="wp-total">
|
|
140
|
+
<td>total</td><td /><td className="wp-mut">{runs === undefined || runs.runs === 0 ? '' : `${runs.runs} run${runs.runs === 1 ? '' : 's'}`}</td>
|
|
141
|
+
{costCells(workflow.total, usesAgents)}
|
|
142
|
+
<td />
|
|
143
|
+
</tr>
|
|
144
|
+
</tbody>
|
|
145
|
+
</table></div>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function FunnelTable({ funnel }: { readonly funnel: StepFunnel }) {
|
|
150
|
+
if (funnel.runs === 0) return <p className="wp-line wp-mut">No run began since {localTime(funnel.since)}.</p>;
|
|
151
|
+
return (
|
|
152
|
+
<>
|
|
153
|
+
<p className="wp-line">
|
|
154
|
+
{funnel.runs.toLocaleString('en-US')} run{funnel.runs === 1 ? '' : 's'} began since {localTime(funnel.since)}, {funnel.going.toLocaleString('en-US')} still going.
|
|
155
|
+
</p>
|
|
156
|
+
<div className="wp-tablewrap"><table className="wp-table">
|
|
157
|
+
<thead><tr><th>step</th><th className="wp-r">reached</th><th className="wp-r">stopped here</th><th className="wp-r">finished here</th><th className="wp-r">median time</th></tr></thead>
|
|
158
|
+
<tbody>
|
|
159
|
+
{funnel.steps.map((s) => (
|
|
160
|
+
<tr key={s.step} className={s.noneGotPast ? 'wp-bad' : ''}>
|
|
161
|
+
<td>{s.step}{s.noneGotPast ? ' (none got past)' : ''}</td>
|
|
162
|
+
<td className="wp-r">{s.reached.toLocaleString('en-US')}</td>
|
|
163
|
+
<td className="wp-r">{s.stopped === 0 ? '' : s.stopped.toLocaleString('en-US')}</td>
|
|
164
|
+
<td className="wp-r">{s.finished === 0 ? '' : s.finished.toLocaleString('en-US')}</td>
|
|
165
|
+
<td className="wp-r">{s.medianSeconds === null ? '' : duration(s.medianSeconds)}</td>
|
|
166
|
+
</tr>
|
|
167
|
+
))}
|
|
168
|
+
</tbody>
|
|
169
|
+
</table></div>
|
|
170
|
+
{funnel.mostStopped === null ? null : (
|
|
171
|
+
<p className="wp-line">
|
|
172
|
+
Most stopped at {funnel.mostStopped.step} ({funnel.mostStopped.stopped.toLocaleString('en-US')}):{' '}
|
|
173
|
+
{funnel.mostStopped.reasons.map((r) => `${r.reason} (${r.runs})`).join('; ')}
|
|
174
|
+
{funnel.mostStopped.otherRuns > 0 ? `; ${funnel.mostStopped.otherRuns} for other reasons` : ''}.
|
|
175
|
+
</p>
|
|
176
|
+
)}
|
|
177
|
+
</>
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** A figure to two places, or "none" where there was nothing to divide by. */
|
|
182
|
+
const per = (n: number | null): string => (n === null ? 'none' : n === 0 ? '0' : n < 0.01 ? n.toPrecision(2) : n.toFixed(n >= 10 ? 0 : 2));
|
|
183
|
+
|
|
184
|
+
/** What its runs finished over the window, per run, per million tokens and per compile, with the window before beside it. */
|
|
185
|
+
const yieldLine = (w: WorkflowFigures, finishedWord: string | null): string => {
|
|
186
|
+
const { now, before } = w.yields;
|
|
187
|
+
const word = finishedWord ?? 'finished';
|
|
188
|
+
const trend = now.finished === before.finished ? 'the same as' : now.finished > before.finished ? 'up from' : 'down from';
|
|
189
|
+
return `${now.finished.toLocaleString('en-US')} ${word} in ${now.runs.toLocaleString('en-US')} runs, ${trend} ${before.finished.toLocaleString('en-US')} in the ${before.runs.toLocaleString('en-US')} before: `
|
|
190
|
+
+ `${per(now.perRun)} a run, ${per(now.perMillionTokens)} per million tokens, ${per(now.perCompile)} a compile (before: ${per(before.perRun)}, ${per(before.perMillionTokens)}, ${per(before.perCompile)}).`;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
/** What a run of it costs: the median run's time, tokens, CPU (its processes' part) and compiles, and its costliest run. */
|
|
194
|
+
const runCostLine = (w: WorkflowFigures): string => {
|
|
195
|
+
const c = w.runCosts;
|
|
196
|
+
if (c.median === null) return 'No run ended in the window.';
|
|
197
|
+
const tokens = c.median.tokens === 0 ? '' : `, ${compact(c.median.tokens)} tokens`;
|
|
198
|
+
const compiles = c.median.compiles === 0 ? '' : `, ${compact(c.median.compiles)} compiles`;
|
|
199
|
+
const costliest = c.costliest === null ? '' : `; costliest ${duration(c.costliest.cpuSeconds)} of CPU, started ${localTime(c.costliest.started)}`;
|
|
200
|
+
return `A run costs ${duration(c.median.seconds)}${tokens}, ${duration(c.median.cpuSeconds)} of CPU (${duration(c.median.childCpuSeconds)} in its processes)${compiles}, the median of ${c.runs.toLocaleString('en-US')} runs${costliest}.`;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
/** What each limit sets, said on its control. */
|
|
204
|
+
const LIMIT_WORDS: Readonly<Record<LimitName, { readonly unit: (n: number) => string; readonly says: string }>> = {
|
|
205
|
+
runs: { unit: (n) => `run${n === 1 ? '' : 's'}`, says: 'Run limit: how many runs of it may go at once, however they start; at 0 none starts. With none set: its agents\' limit where it has one, else no limit.' },
|
|
206
|
+
agents: { unit: (n) => `agent${n === 1 ? '' : 's'}`, says: 'Agents\' limit: how many of its runs may be in an agent step at once. A run at an agent step with none free waits there; at 0 none goes past its first agent step.' },
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* ONE LIMIT AND ITS BUTTONS. A click shows at once, as asked, until the page's next reading says the same; a failed one says
|
|
211
|
+
* why. A run limit set can go back to its default.
|
|
212
|
+
*/
|
|
213
|
+
function LimitControl({ workflow, limit, value, isDefault, setLimit }: { readonly workflow: string; readonly limit: LimitName; readonly value: number | null; readonly isDefault: boolean; readonly setLimit: SetLimit | undefined }) {
|
|
214
|
+
const [asked, setAsked] = useState<{ readonly value: number | null } | null>(null);
|
|
215
|
+
const [failed, setFailed] = useState<string | null>(null);
|
|
216
|
+
useEffect(() => {
|
|
217
|
+
if (asked !== null && (asked.value === null ? isDefault : asked.value === value && !isDefault)) setAsked(null);
|
|
218
|
+
}, [asked, value, isDefault]);
|
|
219
|
+
const words = LIMIT_WORDS[limit];
|
|
220
|
+
const shown = asked === null || asked.value === null ? value : asked.value;
|
|
221
|
+
const set = (next: number | null) => {
|
|
222
|
+
if (setLimit === undefined) return;
|
|
223
|
+
setAsked({ value: next });
|
|
224
|
+
setFailed(null);
|
|
225
|
+
setLimit({ workflow, limit, value: next }).catch((e: unknown) => { setAsked(null); setFailed(e instanceof Error ? e.message : String(e)); });
|
|
226
|
+
};
|
|
227
|
+
return (
|
|
228
|
+
<span className="wp-limit" title={words.says} onClick={(e) => e.preventDefault()}>
|
|
229
|
+
{setLimit === undefined ? null : <button type="button" aria-label={`Lower the ${limit === 'runs' ? 'run limit' : 'agents\' limit'} of ${workflow}`} disabled={shown === 0} onClick={() => set(shown === null ? 0 : shown - 1)}>−</button>}
|
|
230
|
+
<span className={shown === 0 ? 'wp-bad' : 'wp-mut'}>{shown === null ? 'runs: no limit' : `${shown} ${words.unit(shown)}`}{limit === 'runs' && isDefault && shown !== null && asked === null ? ' (default)' : ''}</span>
|
|
231
|
+
{setLimit === undefined ? null : <button type="button" aria-label={`Raise the ${limit === 'runs' ? 'run limit' : 'agents\' limit'} of ${workflow}`} onClick={() => set(shown === null ? 1 : shown + 1)}>+</button>}
|
|
232
|
+
{setLimit === undefined || limit !== 'runs' || isDefault ? null : <button type="button" aria-label={`Put the run limit of ${workflow} back to its default`} onClick={() => set(null)}>default</button>}
|
|
233
|
+
{failed === null ? null : <span className="wp-bad">not saved: {failed}</span>}
|
|
234
|
+
</span>
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** A workflow's runs and agents now, and its limits with their controls: what its node shows below its queue. */
|
|
239
|
+
function WorkflowStatus({ workflow, runs, limits, setLimit }: { readonly workflow: WorkflowView; readonly runs: WorkflowRunsNow | undefined; readonly limits: WorkflowLimits | null; readonly setLimit: SetLimit | undefined }) {
|
|
240
|
+
const going = runs?.runs ?? 0;
|
|
241
|
+
return (
|
|
242
|
+
<>
|
|
243
|
+
<span className={going === 0 ? 'wp-mut' : ''}>{going === 0 ? 'no run going' : `${going} run${going === 1 ? '' : 's'} going`}</span>
|
|
244
|
+
{workflow.usesAgents ? <span className="wp-count" title="Its runs in an agent step now">{runs?.onAgents ?? 0} on agents</span> : null}
|
|
245
|
+
{limits === null ? null : (
|
|
246
|
+
<>
|
|
247
|
+
<LimitControl workflow={workflow.name} limit="runs" value={limits.runs} isDefault={!limits.runsSet} setLimit={setLimit} />
|
|
248
|
+
{limits.agents === null ? null : <LimitControl workflow={workflow.name} limit="agents" value={limits.agents} isDefault={false} setLimit={setLimit} />}
|
|
249
|
+
</>
|
|
250
|
+
)}
|
|
251
|
+
</>
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** How often an open workflow's figures are read again. */
|
|
256
|
+
const FIGURES_EVERY_MS = 15_000;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* An open workflow: what it gave and cost, its steps, its step graph and where its runs stopped, read from its own records
|
|
260
|
+
* while it is open. The figures of the workflow opened before it are never shown under this one's name.
|
|
261
|
+
*/
|
|
262
|
+
function WorkflowDetail({ workflow, runs, now, figuresUrl }: { readonly workflow: WorkflowView; readonly runs: WorkflowRunsNow | undefined; readonly now: number; readonly figuresUrl: (workflow: string) => string }) {
|
|
263
|
+
const read = usePolledJson<WorkflowFigures>(figuresUrl(workflow.name), FIGURES_EVERY_MS);
|
|
264
|
+
const figures = read.data !== null && read.data.workflow === workflow.name ? read.data : null;
|
|
265
|
+
return (
|
|
266
|
+
<>
|
|
267
|
+
<h3 className="wp-h3">{workflow.name}: its steps</h3>
|
|
268
|
+
{figures === null ? <p className={read.error === null ? 'wp-line wp-mut' : 'wp-line wp-bad'}>{read.error === null ? 'Reading its figures…' : `Its figures could not be read: ${read.error}`}</p> : (
|
|
269
|
+
<>
|
|
270
|
+
<p className="wp-line wp-mut">Its figures over the last {figures.hours} h, read {whenAgo(figures.at, now)}.</p>
|
|
271
|
+
{workflow.item === null ? null : <p className="wp-line">{yieldLine(figures, workflow.finishedWord)}</p>}
|
|
272
|
+
<p className="wp-line">{runCostLine(figures)}</p>
|
|
273
|
+
<StepsTable workflow={figures} usesAgents={workflow.usesAgents} runs={runs} now={now} />
|
|
274
|
+
<h4 className="wp-h4">Step graph</h4>
|
|
275
|
+
<StepGraph graph={figures.graph} />
|
|
276
|
+
<h4 className="wp-h4">Where runs stopped</h4>
|
|
277
|
+
<FunnelTable funnel={figures.funnel} />
|
|
278
|
+
</>
|
|
279
|
+
)}
|
|
280
|
+
</>
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export function WorkflowsDashboard({ data, error, figuresUrl, sourceHref, header, panels, phaseLabel, phaseSummary, setLimit }: WorkflowsDashboardProps) {
|
|
285
|
+
const now = Date.now() / 1000;
|
|
286
|
+
return (
|
|
287
|
+
<div className="wp-page">
|
|
288
|
+
{header}
|
|
289
|
+
<p className={error === null ? 'wp-line wp-mut' : 'wp-line wp-bad'}>
|
|
290
|
+
{error !== null ? `The workflows could not be read: ${error}` : data === null ? 'Reading the workflows…' : `Read from the records ${whenAgo(data.view.at, now)}.`}
|
|
291
|
+
</p>
|
|
292
|
+
{data === null ? null : <p className={data.cpu.use !== null && data.cpu.use.cores > data.cpu.limit ? 'wp-line wp-bad' : 'wp-line'}>{cpuLine(data.cpu, now)}</p>}
|
|
293
|
+
{panels}
|
|
294
|
+
{data === null ? null : <QueueChart view={data.view} />}
|
|
295
|
+
{data === null ? null : (() => {
|
|
296
|
+
const runsOf = (w: WorkflowView) => data.runsNow.find((p) => p.phase === w.phase)?.workflows.find((r) => r.workflow === w.name);
|
|
297
|
+
return (
|
|
298
|
+
<WorkflowDag
|
|
299
|
+
view={data.view}
|
|
300
|
+
phaseLabel={(phase) => (phaseLabel === undefined ? phase : phaseLabel(phase))}
|
|
301
|
+
phaseLine={(phase) => {
|
|
302
|
+
const p = data.runsNow.find((r) => r.phase === phase);
|
|
303
|
+
return <>{p === undefined ? 0 : p.runs} running, {p === undefined ? 0 : p.onAgents} on agents{phaseSummary === undefined ? null : <> · {phaseSummary(phase)}</>}</>;
|
|
304
|
+
}}
|
|
305
|
+
nodeStatus={(w) => <WorkflowStatus workflow={w} runs={runsOf(w)} limits={w.limits} setLimit={setLimit} />}
|
|
306
|
+
nodeHref={(w) => sourceHref(w.source)}
|
|
307
|
+
detail={(w) => <WorkflowDetail workflow={w} runs={runsOf(w)} now={now} figuresUrl={figuresUrl} />}
|
|
308
|
+
/>
|
|
309
|
+
);
|
|
310
|
+
})()}
|
|
311
|
+
</div>
|
|
312
|
+
);
|
|
313
|
+
}
|