@jive-sh/workflow-platform 0.6.3 → 1.0.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 +66 -295
- package/component/_generated/api.ts +72 -0
- package/component/_generated/component.ts +621 -0
- package/component/_generated/dataModel.ts +60 -0
- package/component/_generated/server.ts +169 -0
- package/component/convex.config.ts +3 -0
- package/component/engine.ts +755 -0
- package/component/errors.ts +66 -0
- package/component/events.ts +17 -0
- package/component/notes.ts +13 -0
- package/component/places.ts +136 -0
- package/component/retention.ts +205 -0
- package/component/runEngine.ts +25 -0
- package/component/schema.ts +132 -0
- package/component/steps.ts +188 -0
- package/component/store.ts +512 -0
- package/component/tasks.ts +289 -0
- package/component/worker.ts +109 -0
- package/component/workflows.ts +83 -0
- package/dist/definition/agent-runner.js +9 -0
- package/dist/definition/agent-runner.js.map +1 -0
- package/dist/definition/file-store.js +9 -0
- package/dist/definition/file-store.js.map +1 -0
- package/dist/definition/program-build.js +10 -0
- package/dist/definition/program-build.js.map +1 -0
- package/dist/definition/step.js +1 -0
- package/dist/definition/step.js.map +1 -0
- package/dist/definition/task-schema.js +5 -0
- package/dist/definition/task-schema.js.map +1 -0
- package/dist/definition/tasks.js +9 -0
- package/dist/definition/tasks.js.map +1 -0
- package/dist/definition/workflow.js +111 -0
- package/dist/definition/workflow.js.map +1 -0
- package/dist/graph.js +301 -9
- package/dist/graph.js.map +1 -1
- package/dist/index.js +7 -133
- package/dist/index.js.map +1 -1
- package/package.json +9 -4
- package/src/definition/agent-runner.ts +59 -0
- package/src/definition/file-store.ts +20 -0
- package/src/definition/program-build.ts +30 -0
- package/src/definition/step.ts +106 -0
- package/src/definition/task-schema.ts +15 -0
- package/src/definition/tasks.ts +43 -0
- package/src/definition/workflow.ts +255 -0
- package/src/graph.ts +341 -19
- package/src/index.ts +8 -168
- package/worker/directory-file-store.ts +42 -0
- package/worker/index.ts +12 -0
- package/worker/platform-client.ts +138 -0
- package/worker/step-meter.ts +80 -0
- package/worker/worker-tasks.ts +27 -0
- package/worker/worker.test.ts +200 -0
- package/worker/worker.ts +240 -0
- package/dist/budget-states.js +0 -30
- package/dist/budget-states.js.map +0 -1
- package/dist/cpu-limit/limiter.js +0 -839
- package/dist/cpu-limit/limiter.js.map +0 -1
- package/dist/cpu-limit/use.js +0 -139
- package/dist/cpu-limit/use.js.map +0 -1
- package/dist/dashboard/agent-usage.js +0 -25
- package/dist/dashboard/agent-usage.js.map +0 -1
- package/dist/dashboard/dashboard.css +0 -134
- package/dist/dashboard/drilldown.js +0 -16
- package/dist/dashboard/drilldown.js.map +0 -1
- package/dist/dashboard/queue-lines.js +0 -44
- package/dist/dashboard/queue-lines.js.map +0 -1
- package/dist/dashboard/queue-table.js +0 -16
- package/dist/dashboard/queue-table.js.map +0 -1
- package/dist/dashboard/spending-words.js +0 -32
- package/dist/dashboard/spending-words.js.map +0 -1
- package/dist/failure.js +0 -35
- package/dist/failure.js.map +0 -1
- package/dist/keep-running.js +0 -77
- package/dist/keep-running.js.map +0 -1
- package/dist/outside-failure.js +0 -31
- package/dist/outside-failure.js.map +0 -1
- package/dist/pick-wakes.js +0 -125
- package/dist/pick-wakes.js.map +0 -1
- package/dist/project.js +0 -1
- package/dist/project.js.map +0 -1
- package/dist/queue-counts.js +0 -51
- package/dist/queue-counts.js.map +0 -1
- package/dist/reasons.js +0 -33
- package/dist/reasons.js.map +0 -1
- package/dist/spending-limit.js +0 -88
- package/dist/spending-limit.js.map +0 -1
- package/dist/step-files.js +0 -200
- package/dist/step-files.js.map +0 -1
- package/dist/step-meter.js +0 -97
- package/dist/step-meter.js.map +0 -1
- package/dist/step-usage.js +0 -19
- package/dist/step-usage.js.map +0 -1
- package/dist/steps.js +0 -920
- package/dist/steps.js.map +0 -1
- package/dist/storage/budgets.js +0 -85
- package/dist/storage/budgets.js.map +0 -1
- package/dist/storage/engine-records.js +0 -75
- package/dist/storage/engine-records.js.map +0 -1
- package/dist/storage/engine-storage.js +0 -67
- package/dist/storage/engine-storage.js.map +0 -1
- package/dist/storage/input-records.js +0 -12
- package/dist/storage/input-records.js.map +0 -1
- package/dist/storage/move-store.js +0 -251
- package/dist/storage/move-store.js.map +0 -1
- package/dist/storage/sqlite-store.js +0 -723
- package/dist/storage/sqlite-store.js.map +0 -1
- package/dist/storage/step-records.js +0 -11
- package/dist/storage/step-records.js.map +0 -1
- package/dist/storage/storage-error.js +0 -19
- package/dist/storage/storage-error.js.map +0 -1
- package/dist/storage/task-store.js +0 -24
- package/dist/storage/task-store.js.map +0 -1
- package/dist/tasks.js +0 -475
- package/dist/tasks.js.map +0 -1
- package/dist/views/format.js +0 -37
- package/dist/views/format.js.map +0 -1
- package/dist/views/runs-now.js +0 -75
- package/dist/views/runs-now.js.map +0 -1
- package/dist/views/step-funnel.js +0 -98
- package/dist/views/step-funnel.js.map +0 -1
- package/dist/views/step-graph.js +0 -34
- package/dist/views/step-graph.js.map +0 -1
- package/dist/views/workflow-flows.js +0 -53
- package/dist/views/workflow-flows.js.map +0 -1
- package/dist/views/workflows-view.js +0 -230
- package/dist/views/workflows-view.js.map +0 -1
- package/src/budget-states.ts +0 -55
- package/src/cpu-limit/limiter.ts +0 -935
- package/src/cpu-limit/use.ts +0 -166
- package/src/dashboard/agent-usage-line.tsx +0 -28
- package/src/dashboard/agent-usage.ts +0 -48
- package/src/dashboard/dashboard.css +0 -134
- package/src/dashboard/drilldown.ts +0 -43
- package/src/dashboard/index.tsx +0 -4
- package/src/dashboard/machine-controls.tsx +0 -53
- package/src/dashboard/queue-bar.tsx +0 -43
- package/src/dashboard/queue-chart.tsx +0 -150
- package/src/dashboard/queue-lines.ts +0 -87
- package/src/dashboard/queue-table.ts +0 -37
- package/src/dashboard/spending-limit-control.tsx +0 -50
- package/src/dashboard/spending-words.ts +0 -50
- package/src/dashboard/step-graph.tsx +0 -106
- package/src/dashboard/workflow-dag.tsx +0 -204
- package/src/dashboard/workflow-drilldown.tsx +0 -89
- package/src/dashboard/workflows-dashboard.tsx +0 -414
- package/src/failure.ts +0 -36
- package/src/keep-running.ts +0 -83
- package/src/outside-failure.ts +0 -39
- package/src/pick-wakes.ts +0 -182
- package/src/project.ts +0 -115
- package/src/queue-counts.ts +0 -64
- package/src/reasons.ts +0 -30
- package/src/spending-limit.ts +0 -156
- package/src/step-files.ts +0 -208
- package/src/step-meter.ts +0 -120
- package/src/step-usage.ts +0 -23
- package/src/steps.ts +0 -1239
- package/src/storage/budgets.ts +0 -113
- package/src/storage/engine-records.ts +0 -102
- package/src/storage/engine-storage.ts +0 -82
- package/src/storage/input-records.ts +0 -43
- package/src/storage/move-store.ts +0 -265
- package/src/storage/sqlite-store.ts +0 -829
- package/src/storage/step-records.ts +0 -306
- package/src/storage/storage-error.ts +0 -35
- package/src/storage/task-store.ts +0 -235
- package/src/tasks.ts +0 -561
- package/src/views/format.ts +0 -40
- package/src/views/runs-now.ts +0 -120
- package/src/views/step-funnel.ts +0 -163
- package/src/views/step-graph.ts +0 -68
- package/src/views/workflow-flows.ts +0 -97
- package/src/views/workflows-view.ts +0 -443
|
@@ -1,204 +0,0 @@
|
|
|
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". A box's name opens that workflow's own level. Workflows no work flows to or from are not drawn: the list of steps under the map has them.
|
|
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
|
-
import { QueueBar } from './queue-bar';
|
|
19
|
-
|
|
20
|
-
/** An edge's label: what it is, and along a wait how many wait. */
|
|
21
|
-
const flowLabel = (f: WorkflowFlow): string => (f.kind === 'waits on' ? `${f.waiting.toLocaleString('en-US')} wait on it` : f.kind);
|
|
22
|
-
/** An edge's line: solid feeds, dashed sends back, dotted gives input, dash-dot waits on. */
|
|
23
|
-
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' };
|
|
24
|
-
|
|
25
|
-
/** The node's width; its height is measured from what it shows. */
|
|
26
|
-
const NODE_WIDTH = 250;
|
|
27
|
-
/** The left gutter the stages are named in. */
|
|
28
|
-
const GUTTER = 104;
|
|
29
|
-
const LABEL_HEIGHT = 15;
|
|
30
|
-
const labelWidth = (text: string) => Math.ceil(text.length * 6.3) + 10;
|
|
31
|
-
|
|
32
|
-
interface Laid {
|
|
33
|
-
readonly nodes: ReadonlyMap<string, { readonly x: number; readonly y: number; readonly h: number }>;
|
|
34
|
-
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 }>;
|
|
35
|
-
readonly width: number;
|
|
36
|
-
readonly height: number;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const elk = new ELK();
|
|
40
|
-
|
|
41
|
-
/** The layout of the linked workflows, given each node's height. */
|
|
42
|
-
const layOut = async (input: {
|
|
43
|
-
/** In pipeline order: by stage, then by depth through forward edges within it. */
|
|
44
|
-
readonly workflows: ReadonlyArray<{ readonly name: string; readonly stage: number; readonly height: number }>;
|
|
45
|
-
readonly flows: ReadonlyArray<WorkflowFlow>;
|
|
46
|
-
}): Promise<Laid> => {
|
|
47
|
-
const asked: ElkNode = {
|
|
48
|
-
id: 'workflows',
|
|
49
|
-
layoutOptions: {
|
|
50
|
-
'elk.algorithm': 'layered',
|
|
51
|
-
'elk.direction': 'DOWN',
|
|
52
|
-
'elk.edgeRouting': 'ORTHOGONAL',
|
|
53
|
-
'elk.partitioning.activate': 'true',
|
|
54
|
-
// One layering for all, so every stage's layers come before the next stage's; laid out apart, unconnected groups sat side by side.
|
|
55
|
-
'elk.separateConnectedComponents': 'false',
|
|
56
|
-
'elk.layered.feedbackEdges': 'true',
|
|
57
|
-
// The platform's pipeline order decides which edges go against the flow: only one to a workflow earlier in it, a
|
|
58
|
-
// send-back. Left to itself, ELK kept Retry near-misses' send-back as forward and drew Decompile's feed going up.
|
|
59
|
-
'elk.layered.cycleBreaking.strategy': 'MODEL_ORDER',
|
|
60
|
-
'elk.layered.considerModelOrder.strategy': 'NODES_AND_EDGES',
|
|
61
|
-
'elk.layered.spacing.nodeNodeBetweenLayers': '64',
|
|
62
|
-
'elk.spacing.nodeNode': '36',
|
|
63
|
-
'elk.spacing.edgeNode': '18',
|
|
64
|
-
'elk.spacing.edgeEdge': '12',
|
|
65
|
-
'elk.spacing.edgeLabel': '4',
|
|
66
|
-
'elk.layered.edgeLabels.sideSelection': 'SMART_DOWN',
|
|
67
|
-
'elk.padding': `[top=34,left=${GUTTER},bottom=16,right=16]`,
|
|
68
|
-
},
|
|
69
|
-
children: input.workflows.map((w) => ({ id: w.name, width: NODE_WIDTH, height: w.height, layoutOptions: { 'elk.partitioning.partition': String(w.stage) } })),
|
|
70
|
-
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 }] })),
|
|
71
|
-
};
|
|
72
|
-
const graph = await elk.layout(asked);
|
|
73
|
-
const nodes = new Map((graph.children ?? []).map((c) => [c.id, { x: c.x ?? 0, y: c.y ?? 0, h: c.height ?? 0 }]));
|
|
74
|
-
const edges = (graph.edges ?? []).map((e, i) => {
|
|
75
|
-
const s = e.sections?.[0];
|
|
76
|
-
const label = e.labels?.[0];
|
|
77
|
-
return {
|
|
78
|
-
flow: input.flows[i]!,
|
|
79
|
-
points: s === undefined ? [] : [s.startPoint, ...(s.bendPoints ?? []), s.endPoint],
|
|
80
|
-
label: label === undefined || label.x === undefined || label.y === undefined ? null : { x: label.x, y: label.y, w: label.width ?? 0 },
|
|
81
|
-
};
|
|
82
|
-
});
|
|
83
|
-
return { nodes, edges, width: graph.width ?? 0, height: graph.height ?? 0 };
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export interface WorkflowDagProps {
|
|
87
|
-
readonly view: WorkflowsView;
|
|
88
|
-
readonly phaseLabel: (phase: string) => string;
|
|
89
|
-
/** A box's runs and agents now, with its limit controls. */
|
|
90
|
-
readonly nodeStatus: (w: WorkflowView) => ReactNode;
|
|
91
|
-
/** The address of a workflow's own level, which its box's name opens. */
|
|
92
|
-
readonly hrefOfWorkflow: (workflow: string) => string;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function Node({ w, nodeStatus, href, style }: { readonly w: WorkflowView; readonly nodeStatus: (w: WorkflowView) => ReactNode; readonly href: string; readonly style?: CSSProperties }) {
|
|
96
|
-
return (
|
|
97
|
-
<div data-workflow={w.name} className="wp-node" style={style}>
|
|
98
|
-
<a className="wp-node-name" href={href} title={`Open ${w.name}: ${w.description}`}>{w.name} ›</a>
|
|
99
|
-
{w.queue === null ? null : <QueueBar queue={w.queue} queuedNeedingAnAgent={w.queuedNeedingAnAgent} />}
|
|
100
|
-
<div className="wp-node-status">{nodeStatus(w)}</div>
|
|
101
|
-
</div>
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export function WorkflowDag({ view, phaseLabel, nodeStatus, hrefOfWorkflow }: WorkflowDagProps) {
|
|
106
|
-
const all = view.groups.flatMap((g) => g.workflows);
|
|
107
|
-
const linkedNames = new Set(view.flows.flatMap((f) => [f.from, f.to]));
|
|
108
|
-
const linked = all.filter((w) => linkedNames.has(w.name));
|
|
109
|
-
const stageOf = new Map(view.groups.map((g, i) => [g.phase, i]));
|
|
110
|
-
|
|
111
|
-
// Each box's height, measured as drawn, then the layout from them; laid out again whenever a height or the flows change.
|
|
112
|
-
const map = useRef<HTMLDivElement>(null);
|
|
113
|
-
const [heights, setHeights] = useState<string>('');
|
|
114
|
-
const [laid, setLaid] = useState<Laid | null>(null);
|
|
115
|
-
const [failed, setFailed] = useState<string | null>(null);
|
|
116
|
-
// Opened at its first box: on a phone the box shows one box across, and a map opened at its left edge showed none.
|
|
117
|
-
const scrollBox = useRef<HTMLDivElement>(null);
|
|
118
|
-
const opened = useRef(false);
|
|
119
|
-
useEffect(() => {
|
|
120
|
-
if (laid === null || opened.current || scrollBox.current === null) return;
|
|
121
|
-
const first = [...laid.nodes.values()].sort((a, b) => a.y - b.y || a.x - b.x)[0];
|
|
122
|
-
if (first === undefined) return;
|
|
123
|
-
opened.current = true;
|
|
124
|
-
if (scrollBox.current.clientWidth < laid.width) scrollBox.current.scrollLeft = Math.max(0, first.x - 12);
|
|
125
|
-
}, [laid]);
|
|
126
|
-
useLayoutEffect(() => {
|
|
127
|
-
const el = map.current;
|
|
128
|
-
if (el === null) return;
|
|
129
|
-
const measure = () => setHeights(JSON.stringify([...el.querySelectorAll('[data-workflow]')].map((n) => [n.getAttribute('data-workflow'), Math.ceil(n.getBoundingClientRect().height)])));
|
|
130
|
-
measure();
|
|
131
|
-
const watch = new ResizeObserver(measure);
|
|
132
|
-
for (const n of el.querySelectorAll('[data-workflow]')) watch.observe(n);
|
|
133
|
-
return () => watch.disconnect();
|
|
134
|
-
}, [view.at, linked.length]);
|
|
135
|
-
const flowsKey = JSON.stringify(view.flows.map((f) => [f.from, f.to, f.kind, flowLabel(f)]));
|
|
136
|
-
useEffect(() => {
|
|
137
|
-
if (heights === '') return;
|
|
138
|
-
const h = new Map(JSON.parse(heights) as Array<[string, number]>);
|
|
139
|
-
let current = true;
|
|
140
|
-
const inOrder = [...linked].sort((a, b) => a.place.stage - b.place.stage || a.place.depth - b.place.depth || a.name.localeCompare(b.name));
|
|
141
|
-
layOut({ workflows: inOrder.map((w) => ({ name: w.name, stage: stageOf.get(w.phase) ?? 0, height: h.get(w.name) ?? 120 })), flows: view.flows })
|
|
142
|
-
.then((l) => { if (current) { setLaid(l); setFailed(null); } })
|
|
143
|
-
.catch((e: unknown) => { if (current) setFailed(e instanceof Error ? e.message : String(e)); });
|
|
144
|
-
return () => { current = false; };
|
|
145
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- `linked` and `stageOf` follow `heights` and `flowsKey`.
|
|
146
|
-
}, [heights, flowsKey]);
|
|
147
|
-
|
|
148
|
-
// Each stage's band: from the top of its first box to the bottom of its last.
|
|
149
|
-
const bands = laid === null ? [] : view.groups.flatMap((g) => {
|
|
150
|
-
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 }]; });
|
|
151
|
-
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 }];
|
|
152
|
-
});
|
|
153
|
-
if (linked.length === 0) return null;
|
|
154
|
-
const others = all.length - linked.length;
|
|
155
|
-
|
|
156
|
-
return (
|
|
157
|
-
<div className="wp-dag-wrap">
|
|
158
|
-
<p className="wp-line wp-mut">
|
|
159
|
-
Each box is one workflow; its name opens it. Arrows point the way work goes, down the page: a solid arrow feeds the next
|
|
160
|
-
workflow's tasks; dashed, “sends back”, returns work to an earlier one. Each stage is a band, named on the left.
|
|
161
|
-
{others === 0 ? null : ` The ${others.toLocaleString('en-US')} workflow${others === 1 ? '' : 's'} no work flows to or from ${others === 1 ? 'is' : 'are'} in the list of steps below.`}
|
|
162
|
-
</p>
|
|
163
|
-
{failed === null ? null : <p className="wp-line wp-bad">The map could not be laid out: {failed}</p>}
|
|
164
|
-
<div ref={scrollBox} className="wp-dag-scroll">
|
|
165
|
-
<div ref={map} className="wp-dag" style={{ width: laid === null ? undefined : laid.width, height: laid === null ? undefined : laid.height }}>
|
|
166
|
-
{laid === null ? null : (
|
|
167
|
-
<svg className="wp-dag-edges" width={laid.width} height={laid.height} aria-hidden="true">
|
|
168
|
-
<defs>
|
|
169
|
-
<marker id="wp-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="11" markerHeight="11" markerUnits="userSpaceOnUse" orient="auto">
|
|
170
|
-
<path d="M0,0 L10,5 L0,10 z" fill="var(--wp-edge)" />
|
|
171
|
-
</marker>
|
|
172
|
-
</defs>
|
|
173
|
-
{bands.map((b, i) => (
|
|
174
|
-
<g key={b.phase}>
|
|
175
|
-
<rect x={0} y={b.top} width={laid.width} height={b.bottom - b.top} fill={i % 2 === 0 ? 'var(--wp-band)' : 'transparent'} />
|
|
176
|
-
<foreignObject x={6} y={b.top + 6} width={GUTTER - 16} height={Math.max(40, b.bottom - b.top - 12)}>
|
|
177
|
-
<div className="wp-band-name">{phaseLabel(b.phase)}</div>
|
|
178
|
-
</foreignObject>
|
|
179
|
-
</g>
|
|
180
|
-
))}
|
|
181
|
-
{laid.edges.map(({ flow, points }) => (
|
|
182
|
-
<polyline key={`${flow.from}>${flow.to}>${flow.kind}`} points={points.map((p) => `${p.x},${p.y}`).join(' ')} fill="none" stroke="var(--wp-edge)"
|
|
183
|
-
strokeWidth={flow.kind === 'feeds' ? 1.8 : 1.5} strokeDasharray={DASH[flow.kind]} markerEnd="url(#wp-arrow)" />
|
|
184
|
-
))}
|
|
185
|
-
{laid.edges.map(({ flow, label }) => (label === null ? null : (
|
|
186
|
-
<g key={`label:${flow.from}>${flow.to}>${flow.kind}`}>
|
|
187
|
-
<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" />
|
|
188
|
-
<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>
|
|
189
|
-
</g>
|
|
190
|
-
)))}
|
|
191
|
-
</svg>
|
|
192
|
-
)}
|
|
193
|
-
{linked.map((w) => {
|
|
194
|
-
const at = laid?.nodes.get(w.name);
|
|
195
|
-
return (
|
|
196
|
-
<Node key={w.name} w={w} nodeStatus={nodeStatus} href={hrefOfWorkflow(w.name)}
|
|
197
|
-
style={at === undefined ? { position: 'absolute', left: 0, top: 0, visibility: 'hidden' } : { position: 'absolute', left: at.x, top: at.y }} />
|
|
198
|
-
);
|
|
199
|
-
})}
|
|
200
|
-
</div>
|
|
201
|
-
</div>
|
|
202
|
-
</div>
|
|
203
|
-
);
|
|
204
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* THE DRILL-DOWN'S TWO PARTS: the breadcrumb of the workflows opened, each a link back up, and one workflow's own steps,
|
|
5
|
-
* each with its kind in words, a sub-workflow step a link that opens that workflow's view (`drilldown.ts`).
|
|
6
|
-
*/
|
|
7
|
-
import { Fragment, type ReactNode } from 'react';
|
|
8
|
-
import type { StepRunsNow, WorkflowRunsNow } from '../views/runs-now';
|
|
9
|
-
import type { StepSummary, WorkflowView } from '../views/workflows-view';
|
|
10
|
-
import { kindWords, type Crumb } from './drilldown';
|
|
11
|
-
import { addendLabel, queueSum } from './queue-table';
|
|
12
|
-
|
|
13
|
-
/** The path opened, top first: every part but the last a link to its level, the last the page's title; `after` follows it. */
|
|
14
|
-
export function Breadcrumb({ crumbs, hrefOf, after }: { readonly crumbs: ReadonlyArray<Crumb>; readonly hrefOf: (path: ReadonlyArray<string>) => string; readonly after?: ReactNode }) {
|
|
15
|
-
return (
|
|
16
|
-
<nav className="wp-crumbs" aria-label="Workflows opened, top first">
|
|
17
|
-
{crumbs.map((c, i) => (
|
|
18
|
-
<Fragment key={c.path.join('/')}>
|
|
19
|
-
{i === 0 ? null : <span className="wp-crumb-sep" aria-hidden="true">›</span>}
|
|
20
|
-
{i === crumbs.length - 1 ? <span className="wp-crumb-here" aria-current="page">{c.name}</span> : <a href={hrefOf(c.path)}>{c.name}</a>}
|
|
21
|
-
</Fragment>
|
|
22
|
-
))}
|
|
23
|
-
{after}
|
|
24
|
-
</nav>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** A sub-workflow's tasks on one line, as an addition: every category, then their total. */
|
|
29
|
-
const tasksLine = (queue: NonNullable<WorkflowView['queue']>, queuedNeedingAnAgent: WorkflowView['queuedNeedingAnAgent']): string => {
|
|
30
|
-
const sum = queueSum(queue, queuedNeedingAnAgent);
|
|
31
|
-
return `${sum.addends.map((a) => `${a.text} ${addendLabel(a)}`).join(' + ')} = ${sum.totalText}`;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/** A sub-workflow's runs now against its run limit, in words. */
|
|
35
|
-
const runsLine = (w: WorkflowView, runs: WorkflowRunsNow | undefined): string => {
|
|
36
|
-
const going = runs?.runs ?? 0;
|
|
37
|
-
const limit = w.limits === null ? '' : w.limits.runs === null ? ', no run limit' : `, run limit ${w.limits.runs}`;
|
|
38
|
-
return `${going === 0 ? 'no run going' : `${going} run${going === 1 ? '' : 's'} going`}${limit}`;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
/** Where runs are in a step now, in words; nothing with none. */
|
|
42
|
-
const inStepLine = (s: StepRunsNow | undefined): string | null => {
|
|
43
|
-
if (s === undefined || (s.inStep === 0 && s.waitingAfter === 0)) return null;
|
|
44
|
-
return [...(s.inStep > 0 ? [`${s.inStep} run${s.inStep === 1 ? '' : 's'} in it now`] : []), ...(s.waitingAfter > 0 ? [`${s.waitingAfter} just past it`] : [])].join(', ');
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export interface StepListProps {
|
|
48
|
-
readonly steps: ReadonlyArray<StepSummary>;
|
|
49
|
-
/** The path of the level these steps belong to. */
|
|
50
|
-
readonly path: ReadonlyArray<string>;
|
|
51
|
-
readonly hrefOf: (path: ReadonlyArray<string>) => string;
|
|
52
|
-
/** A sub-workflow step's workflow, for its tasks and runs. */
|
|
53
|
-
readonly workflowOf: (name: string) => WorkflowView | undefined;
|
|
54
|
-
readonly runsOf: (workflow: string) => WorkflowRunsNow | undefined;
|
|
55
|
-
/** This level's own runs, by step; none at the top. */
|
|
56
|
-
readonly runs: WorkflowRunsNow | undefined;
|
|
57
|
-
/** A heading the steps under it share (a stage of the project); none where the level has none. */
|
|
58
|
-
readonly groupOf?: (step: StepSummary) => ReactNode | null;
|
|
59
|
-
readonly groupKey?: (step: StepSummary) => string | null;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export function StepList({ steps, path, hrefOf, workflowOf, runsOf, runs, groupOf, groupKey }: StepListProps) {
|
|
63
|
-
if (steps.length === 0) return <p className="wp-line wp-mut">It declares no steps.</p>;
|
|
64
|
-
return (
|
|
65
|
-
<ol className="wp-drill-steps">
|
|
66
|
-
{steps.map((s, i) => {
|
|
67
|
-
const sub = s.workflow === null ? undefined : workflowOf(s.workflow);
|
|
68
|
-
const group = groupKey?.(s) ?? null;
|
|
69
|
-
const newGroup = group !== null && (i === 0 || groupKey?.(steps[i - 1]!) !== group);
|
|
70
|
-
const inStep = inStepLine(runs?.steps.find((r) => r.step === s.name));
|
|
71
|
-
return (
|
|
72
|
-
<Fragment key={s.name}>
|
|
73
|
-
{newGroup ? <li className="wp-drill-group">{groupOf?.(s)}</li> : null}
|
|
74
|
-
<li className="wp-drill-step">
|
|
75
|
-
<div className="wp-drill-head">
|
|
76
|
-
{sub === undefined ? <span className="wp-drill-name">{s.name}</span> : <a className="wp-drill-name" href={hrefOf([...path, s.name])}>{s.name} ›</a>}
|
|
77
|
-
<span className="wp-kind">{kindWords(s)}</span>
|
|
78
|
-
</div>
|
|
79
|
-
<div className="wp-drill-what wp-mut">{s.description}</div>
|
|
80
|
-
{sub === undefined || sub.queue === null ? null : <div className="wp-drill-figures">{tasksLine(sub.queue, sub.queuedNeedingAnAgent)}</div>}
|
|
81
|
-
{sub === undefined ? null : <div className="wp-drill-figures wp-mut">{runsLine(sub, runsOf(sub.name))}</div>}
|
|
82
|
-
{inStep === null ? null : <div className="wp-drill-figures">{inStep}</div>}
|
|
83
|
-
</li>
|
|
84
|
-
</Fragment>
|
|
85
|
-
);
|
|
86
|
-
})}
|
|
87
|
-
</ol>
|
|
88
|
-
);
|
|
89
|
-
}
|