@jive-sh/workflow-platform 0.3.3 → 0.5.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.
Files changed (61) hide show
  1. package/README.md +68 -23
  2. package/dist/dashboard/agent-usage.js +25 -0
  3. package/dist/dashboard/agent-usage.js.map +1 -0
  4. package/dist/dashboard/drilldown.js +16 -0
  5. package/dist/dashboard/drilldown.js.map +1 -0
  6. package/dist/dashboard/queue-lines.js +44 -0
  7. package/dist/dashboard/queue-lines.js.map +1 -0
  8. package/dist/index.js +8 -6
  9. package/dist/index.js.map +1 -1
  10. package/dist/keep-running.js +1 -1
  11. package/dist/keep-running.js.map +1 -1
  12. package/dist/pick-wakes.js +4 -4
  13. package/dist/pick-wakes.js.map +1 -1
  14. package/dist/queue-counts.js +7 -9
  15. package/dist/queue-counts.js.map +1 -1
  16. package/dist/steps.js +157 -41
  17. package/dist/steps.js.map +1 -1
  18. package/dist/storage/sqlite-store.js +117 -38
  19. package/dist/storage/sqlite-store.js.map +1 -1
  20. package/dist/storage/task-store.js +14 -1
  21. package/dist/storage/task-store.js.map +1 -1
  22. package/dist/tasks.js +215 -267
  23. package/dist/tasks.js.map +1 -1
  24. package/dist/views/runs-now.js +3 -2
  25. package/dist/views/runs-now.js.map +1 -1
  26. package/dist/views/step-funnel.js +1 -1
  27. package/dist/views/step-funnel.js.map +1 -1
  28. package/dist/views/step-graph.js +1 -1
  29. package/dist/views/step-graph.js.map +1 -1
  30. package/dist/views/workflow-flows.js +2 -2
  31. package/dist/views/workflow-flows.js.map +1 -1
  32. package/dist/views/workflows-view.js +83 -17
  33. package/dist/views/workflows-view.js.map +1 -1
  34. package/package.json +1 -1
  35. package/src/dashboard/agent-usage-line.tsx +28 -0
  36. package/src/dashboard/agent-usage.ts +48 -0
  37. package/src/dashboard/dashboard.css +70 -29
  38. package/src/dashboard/drilldown.ts +43 -0
  39. package/src/dashboard/index.tsx +1 -0
  40. package/src/dashboard/machine-controls.tsx +53 -0
  41. package/src/dashboard/queue-bar.tsx +43 -0
  42. package/src/dashboard/queue-chart.tsx +89 -76
  43. package/src/dashboard/queue-lines.ts +87 -0
  44. package/src/dashboard/step-graph.tsx +18 -10
  45. package/src/dashboard/workflow-dag.tsx +31 -103
  46. package/src/dashboard/workflow-drilldown.tsx +89 -0
  47. package/src/dashboard/workflows-dashboard.tsx +117 -42
  48. package/src/index.ts +11 -9
  49. package/src/keep-running.ts +3 -3
  50. package/src/pick-wakes.ts +14 -9
  51. package/src/queue-counts.ts +10 -14
  52. package/src/steps.ts +213 -52
  53. package/src/storage/sqlite-store.ts +126 -39
  54. package/src/storage/step-records.ts +14 -3
  55. package/src/storage/task-store.ts +97 -22
  56. package/src/tasks.ts +235 -301
  57. package/src/views/runs-now.ts +5 -4
  58. package/src/views/step-funnel.ts +2 -2
  59. package/src/views/step-graph.ts +4 -4
  60. package/src/views/workflow-flows.ts +7 -7
  61. package/src/views/workflows-view.ts +117 -35
@@ -1,8 +1,8 @@
1
1
  'use client';
2
2
 
3
3
  /**
4
- * ONE WORKFLOW'S DECLARED STEP GRAPH, DRAWN SMALL: its steps one under another in the order a run takes them, an agent step
5
- * marked "agent" in words, and every edge an arrow with a number. The numbers' list below says each edge's condition and
4
+ * ONE WORKFLOW'S DECLARED STEP GRAPH, DRAWN SMALL: its steps one under another in the order a run takes them, a step that
5
+ * does not run deterministically marked with how it runs, in words, a sub-workflow step a link to its workflow's own level, and every edge an arrow with a number. The numbers' list below says each edge's condition and
6
6
  * how many runs took it in the window. An edge to the next row goes straight down; any other runs in a lane of its own on
7
7
  * the right, so it crosses no step.
8
8
  */
@@ -20,12 +20,12 @@ export const stepRows = (graph: WorkflowGraph): ReadonlyArray<ReadonlyArray<stri
20
20
  [RUN_ENDS],
21
21
  ];
22
22
 
23
- export function StepGraph({ graph }: { readonly graph: WorkflowGraph }) {
23
+ export function StepGraph({ graph, hrefOfWorkflow }: { readonly graph: WorkflowGraph; readonly hrefOfWorkflow?: (workflow: string) => string }) {
24
24
  const box = useRef<HTMLDivElement>(null);
25
25
  const [paths, setPaths] = useState<ReadonlyArray<{ readonly key: string; readonly n: number; readonly d: string; readonly at: { readonly x: number; readonly y: number } }>>([]);
26
26
  const [size, setSize] = useState({ w: 0, h: 0 });
27
27
  const rows = stepRows(graph);
28
- const agent = new Set(graph.steps.filter((s) => s.agent).map((s) => s.name));
28
+ const declared = new Map(graph.steps.map((s) => [s.name, s]));
29
29
  useLayoutEffect(() => {
30
30
  const el = box.current;
31
31
  if (el === null) return;
@@ -76,12 +76,20 @@ export function StepGraph({ graph }: { readonly graph: WorkflowGraph }) {
76
76
  </svg>
77
77
  {rows.map((row) => (
78
78
  <div key={row.join('|')} className="wp-steps-row">
79
- {row.map((name) => (
80
- <span key={name} data-step={name} className={name === RUN_STARTS || name === RUN_ENDS || name === A_STEP_FAILS ? 'wp-step wp-step-end' : 'wp-step'}
81
- title={graph.steps.find((s) => s.name === name)?.description ?? name}>
82
- {name}{agent.has(name) ? <em> · agent</em> : null}
83
- </span>
84
- ))}
79
+ {row.map((name) => {
80
+ const step = declared.get(name);
81
+ const className = name === RUN_STARTS || name === RUN_ENDS || name === A_STEP_FAILS ? 'wp-step wp-step-end' : 'wp-step';
82
+ const title = step?.description ?? name;
83
+ // A sub-workflow step opens its workflow's own level, as its row in the list of steps does.
84
+ if (step !== undefined && step.workflow !== null && hrefOfWorkflow !== undefined) {
85
+ return <a key={name} data-step={name} className={`${className} wp-step-link`} href={hrefOfWorkflow(step.workflow)} title={title}>{name}<em> · sub-workflow, open ›</em></a>;
86
+ }
87
+ return (
88
+ <span key={name} data-step={name} className={className} title={title}>
89
+ {name}{step === undefined || step.runs === null || step.runs === 'deterministic' ? null : <em> · {step.runs}</em>}
90
+ </span>
91
+ );
92
+ })}
85
93
  </div>
86
94
  ))}
87
95
  </div>
@@ -6,7 +6,7 @@
6
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
7
  * a gutter on the left that no edge enters. Edges are routed orthogonally around the nodes, each with its label beside its
8
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.
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
10
  *
11
11
  * Chosen over dagre (`@dagrejs/dagre`): ELK routes edges around nodes and places labels beside their own edges, lays out
12
12
  * partitions in order and routes feedback edges apart; dagre does none of those, and its edges and labels cross nodes.
@@ -15,58 +15,7 @@ import ELK, { type ElkNode } from 'elkjs/lib/elk.bundled.js';
15
15
  import { useEffect, useLayoutEffect, useRef, useState, type CSSProperties, type ReactNode } from 'react';
16
16
  import type { WorkflowFlow } from '../views/workflow-flows';
17
17
  import type { WorkflowView, WorkflowsView } from '../views/workflows-view';
18
- import { queueSum } from './queue-table';
19
-
20
- /** What starts a workflow's runs, in words. */
21
- const startsLine = (w: WorkflowView): string =>
22
- w.startsOn.kind === 'queue' ? 'runs on its queue'
23
- : w.startsOn.kind === 'inputs' ? `runs when its inputs change: ${w.startsOn.says}`
24
- : 'runs on a timer or a request';
25
-
26
- /** A queue's progress as a bar: done, running, queued and the rest, each segment lighter or darker than its neighbours. */
27
- function QueueBar({ queue }: { readonly queue: NonNullable<WorkflowView['queue']> }) {
28
- const rest = queue.waiting + queue.stuck + queue.held;
29
- const total = Math.max(1, queue.done + queue.running + queue.queued + rest);
30
- const segments = [
31
- { n: queue.done, cls: 'wp-seg-done' },
32
- { n: queue.running, cls: 'wp-seg-running' },
33
- { n: queue.queued, cls: 'wp-seg-queued' },
34
- { n: rest, cls: 'wp-seg-rest' },
35
- ];
36
- const words = [
37
- `${queue.queued.toLocaleString('en-US')} queued`,
38
- `${queue.running.toLocaleString('en-US')} running`,
39
- `${queue.done.toLocaleString('en-US')} done`,
40
- ...(['waiting', 'stuck', 'held'] as const).filter((b) => queue[b] > 0).map((b) => `${queue[b].toLocaleString('en-US')} ${b}`),
41
- ];
42
- const sum = queueSum(queue);
43
- return (
44
- <div className="wp-queue">
45
- <div className="wp-bar" role="img" aria-label={words.join(', ')}>
46
- {segments.map((s) => (s.n === 0 ? null : <span key={s.cls} className={s.cls} style={{ width: `${(100 * s.n) / total}%` }} />))}
47
- </div>
48
- {/* Its tasks as a column addition (`queue-table.ts`): every category, one plus sign beside the last, a rule, the total. */}
49
- <table className="wp-sum">
50
- <tbody>
51
- {sum.addends.map((a, i) => (
52
- <tr key={a.category}>
53
- <td className="wp-sum-plus">{i === sum.addends.length - 1 ? '+' : ''}</td>
54
- <td className="wp-sum-n">{a.text}</td>
55
- <td className="wp-sum-label">{a.category}</td>
56
- </tr>
57
- ))}
58
- </tbody>
59
- <tfoot>
60
- <tr className="wp-sum-total">
61
- <td className="wp-sum-plus" />
62
- <td className="wp-sum-n">{sum.totalText}</td>
63
- <td className="wp-sum-label">total</td>
64
- </tr>
65
- </tfoot>
66
- </table>
67
- </div>
68
- );
69
- }
18
+ import { QueueBar } from './queue-bar';
70
19
 
71
20
  /** An edge's label: what it is, and along a wait how many wait. */
72
21
  const flowLabel = (f: WorkflowFlow): string => (f.kind === 'waits on' ? `${f.waiting.toLocaleString('en-US')} wait on it` : f.kind);
@@ -76,7 +25,7 @@ const DASH: Readonly<Record<WorkflowFlow['kind'], string | undefined>> = { feeds
76
25
  /** The node's width; its height is measured from what it shows. */
77
26
  const NODE_WIDTH = 250;
78
27
  /** The left gutter the stages are named in. */
79
- const GUTTER = 150;
28
+ const GUTTER = 104;
80
29
  const LABEL_HEIGHT = 15;
81
30
  const labelWidth = (text: string) => Math.ceil(text.length * 6.3) + 10;
82
31
 
@@ -137,56 +86,43 @@ const layOut = async (input: {
137
86
  export interface WorkflowDagProps {
138
87
  readonly view: WorkflowsView;
139
88
  readonly phaseLabel: (phase: string) => string;
140
- /** A stage's figures, beside its name. */
141
- readonly phaseLine: (phase: string) => ReactNode;
142
- /** A node's runs and agents now, with its limit controls. */
89
+ /** A box's runs and agents now, with its limit controls. */
143
90
  readonly nodeStatus: (w: WorkflowView) => ReactNode;
144
- /** A node's link to its definition. */
145
- readonly nodeHref: (w: WorkflowView) => string;
146
- /** The open node's steps, graph and costs. */
147
- readonly detail: (w: WorkflowView) => ReactNode;
91
+ /** The address of a workflow's own level, which its box's name opens. */
92
+ readonly hrefOfWorkflow: (workflow: string) => string;
148
93
  }
149
94
 
150
- 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 }) {
151
- const into = flows.filter((f) => f.to === w.name);
152
- const out = flows.filter((f) => f.from === w.name);
153
- const word = (f: WorkflowFlow) => (f.kind === 'feeds' ? '' : f.kind === 'waits on' ? ` (${f.waiting.toLocaleString('en-US')} waiting)` : ` (${f.kind})`);
95
+ function Node({ w, nodeStatus, href, style }: { readonly w: WorkflowView; readonly nodeStatus: (w: WorkflowView) => ReactNode; readonly href: string; readonly style?: CSSProperties }) {
154
96
  return (
155
- <div data-workflow={w.name} className={open ? 'wp-node wp-node-open' : 'wp-node'} style={style}>
156
- <div className="wp-node-head">
157
- <button type="button" className="wp-node-name" aria-expanded={open} onClick={() => setOpen(!open)} title={w.description}>{open ? '▾' : '▸'} {w.name}</button>
158
- <a className="wp-mut" href={nodeHref(w)} title="Its definition">source</a>
159
- </div>
160
- <div className="wp-node-what" title={w.description}>{w.description}</div>
161
- <div className="wp-node-starts wp-mut" title={startsLine(w)}>{startsLine(w)}</div>
162
- {into.length === 0 && out.length === 0 ? null : (
163
- <div className="wp-node-flows wp-mut">
164
- {into.length === 0 ? null : <span>from {into.map((f) => `${f.from}${word(f)}`).join(', ')}</span>}
165
- {out.length === 0 ? null : <span>to {out.map((f) => `${f.to}${word(f)}`).join(', ')}</span>}
166
- </div>
167
- )}
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>
168
99
  {w.queue === null ? null : <QueueBar queue={w.queue} />}
169
100
  <div className="wp-node-status">{nodeStatus(w)}</div>
170
101
  </div>
171
102
  );
172
103
  }
173
104
 
174
- export function WorkflowDag({ view, phaseLabel, phaseLine, nodeStatus, nodeHref, detail }: WorkflowDagProps) {
175
- const [open, setOpenName] = useState<string | null>(null);
105
+ export function WorkflowDag({ view, phaseLabel, nodeStatus, hrefOfWorkflow }: WorkflowDagProps) {
176
106
  const all = view.groups.flatMap((g) => g.workflows);
177
107
  const linkedNames = new Set(view.flows.flatMap((f) => [f.from, f.to]));
178
108
  const linked = all.filter((w) => linkedNames.has(w.name));
179
109
  const stageOf = new Map(view.groups.map((g, i) => [g.phase, i]));
180
- const openWorkflow = all.find((w) => w.name === open) ?? null;
181
- const panel = useRef<HTMLDivElement>(null);
182
- const setOpen = (name: string) => (on: boolean) => setOpenName(on ? name : null);
183
- useEffect(() => { if (open !== null) panel.current?.scrollIntoView({ block: 'nearest', behavior: 'smooth' }); }, [open]);
184
110
 
185
- // Each node's height, measured as drawn, then the layout from them; laid out again whenever a height or the flows change.
111
+ // Each box's height, measured as drawn, then the layout from them; laid out again whenever a height or the flows change.
186
112
  const map = useRef<HTMLDivElement>(null);
187
113
  const [heights, setHeights] = useState<string>('');
188
114
  const [laid, setLaid] = useState<Laid | null>(null);
189
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]);
190
126
  useLayoutEffect(() => {
191
127
  const el = map.current;
192
128
  if (el === null) return;
@@ -209,21 +145,23 @@ export function WorkflowDag({ view, phaseLabel, phaseLine, nodeStatus, nodeHref,
209
145
  // eslint-disable-next-line react-hooks/exhaustive-deps -- `linked` and `stageOf` follow `heights` and `flowsKey`.
210
146
  }, [heights, flowsKey]);
211
147
 
212
- // Each stage's band: from the top of its first node to the bottom of its last.
148
+ // Each stage's band: from the top of its first box to the bottom of its last.
213
149
  const bands = laid === null ? [] : view.groups.flatMap((g) => {
214
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 }]; });
215
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 }];
216
152
  });
217
- const unlinked = view.groups.map((g) => ({ phase: g.phase, workflows: g.workflows.filter((w) => !linkedNames.has(w.name)) })).filter((g) => g.workflows.length > 0);
153
+ if (linked.length === 0) return null;
154
+ const others = all.length - linked.length;
218
155
 
219
156
  return (
220
157
  <div className="wp-dag-wrap">
221
158
  <p className="wp-line wp-mut">
222
- 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
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
223
160
  workflow&apos;s tasks; dashed, &ldquo;sends back&rdquo;, 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.`}
224
162
  </p>
225
163
  {failed === null ? null : <p className="wp-line wp-bad">The map could not be laid out: {failed}</p>}
226
- <div className="wp-dag-scroll">
164
+ <div ref={scrollBox} className="wp-dag-scroll">
227
165
  <div ref={map} className="wp-dag" style={{ width: laid === null ? undefined : laid.width, height: laid === null ? undefined : laid.height }}>
228
166
  {laid === null ? null : (
229
167
  <svg className="wp-dag-edges" width={laid.width} height={laid.height} aria-hidden="true">
@@ -236,16 +174,16 @@ export function WorkflowDag({ view, phaseLabel, phaseLine, nodeStatus, nodeHref,
236
174
  <g key={b.phase}>
237
175
  <rect x={0} y={b.top} width={laid.width} height={b.bottom - b.top} fill={i % 2 === 0 ? 'var(--wp-band)' : 'transparent'} />
238
176
  <foreignObject x={6} y={b.top + 6} width={GUTTER - 16} height={Math.max(40, b.bottom - b.top - 12)}>
239
- <div className="wp-band-name">{phaseLabel(b.phase)}<span className="wp-mut"> · {phaseLine(b.phase)}</span></div>
177
+ <div className="wp-band-name">{phaseLabel(b.phase)}</div>
240
178
  </foreignObject>
241
179
  </g>
242
180
  ))}
243
181
  {laid.edges.map(({ flow, points }) => (
244
- <polyline key={`${flow.from}>${flow.to}`} points={points.map((p) => `${p.x},${p.y}`).join(' ')} fill="none" stroke="var(--wp-edge)"
182
+ <polyline key={`${flow.from}>${flow.to}>${flow.kind}`} points={points.map((p) => `${p.x},${p.y}`).join(' ')} fill="none" stroke="var(--wp-edge)"
245
183
  strokeWidth={flow.kind === 'feeds' ? 1.8 : 1.5} strokeDasharray={DASH[flow.kind]} markerEnd="url(#wp-arrow)" />
246
184
  ))}
247
185
  {laid.edges.map(({ flow, label }) => (label === null ? null : (
248
- <g key={`label:${flow.from}>${flow.to}`}>
186
+ <g key={`label:${flow.from}>${flow.to}>${flow.kind}`}>
249
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" />
250
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>
251
189
  </g>
@@ -255,22 +193,12 @@ export function WorkflowDag({ view, phaseLabel, phaseLine, nodeStatus, nodeHref,
255
193
  {linked.map((w) => {
256
194
  const at = laid?.nodes.get(w.name);
257
195
  return (
258
- <Node key={w.name} w={w} flows={view.flows} open={open === w.name} setOpen={setOpen(w.name)} nodeStatus={nodeStatus} nodeHref={nodeHref}
196
+ <Node key={w.name} w={w} nodeStatus={nodeStatus} href={hrefOfWorkflow(w.name)}
259
197
  style={at === undefined ? { position: 'absolute', left: 0, top: 0, visibility: 'hidden' } : { position: 'absolute', left: at.x, top: at.y }} />
260
198
  );
261
199
  })}
262
200
  </div>
263
201
  </div>
264
- {openWorkflow === null || !linkedNames.has(openWorkflow.name) ? null : <div ref={panel} className="wp-node-detail">{detail(openWorkflow)}</div>}
265
- {unlinked.map((g) => (
266
- <section key={g.phase} className="wp-stage">
267
- <h2 className="wp-h2">{phaseLabel(g.phase)}: workflows no work flows to or from<span className="wp-mut"> · {phaseLine(g.phase)}</span></h2>
268
- <div className="wp-nodes">
269
- {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} />)}
270
- </div>
271
- {openWorkflow !== null && openWorkflow.phase === g.phase && !linkedNames.has(openWorkflow.name) ? <div ref={panel} className="wp-node-detail">{detail(openWorkflow)}</div> : null}
272
- </section>
273
- ))}
274
202
  </div>
275
203
  );
276
204
  }
@@ -0,0 +1,89 @@
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 { 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']>): string => {
30
+ const sum = queueSum(queue);
31
+ return `${sum.addends.map((a) => `${a.text} ${a.category}`).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)}</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
+ }
@@ -1,29 +1,43 @@
1
1
  'use client';
2
2
 
3
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.
4
+ * THE GENERIC VIEW OF A PROJECT'S WORKFLOWS, A WORKFLOW AT A TIME (`drilldown.ts`): the page enters at the project's top
5
+ * workflow and opens one sub-workflow step at a time, a breadcrumb saying where it is. A workflow's view shows its tasks as
6
+ * an addition (queued + in progress + blocked + done), its runs and limits, its tasks over time, its own steps with their
7
+ * kinds, and, read from its own records while it is open, why its blocked tasks are blocked, what its steps cost, its step
8
+ * graph and where its runs stopped. At the top it also shows what the project gives of its machine and its agents'
9
+ * account: the CPU limit, the stop of everything, and usage. It reads the platform's two readings
10
+ * (`views/workflows-view.ts`) and runs now (`views/runs-now.ts`). Uses React, which the host page brings.
10
11
  */
11
12
  import { Fragment, useEffect, useState, type ReactNode } from 'react';
12
13
  import type { PhaseRunsNow, StepRunsNow, WorkflowRunsNow } from '../views/runs-now';
13
14
  import type { StepFunnel } from '../views/step-funnel';
14
15
  import type { WorkflowGraph } from '../views/step-graph';
15
- import type { SourceLink, StepCost, WorkflowFigures, WorkflowView, WorkflowsView } from '../views/workflows-view';
16
+ import type { SourceLink, StepCost, StepSummary, WorkflowFigures, WorkflowView, WorkflowsView } from '../views/workflows-view';
16
17
  import { compact, duration, localTime, whenAgo } from '../views/format';
18
+ import { drillLevel } from './drilldown';
19
+ import { QueueBar } from './queue-bar';
17
20
  import { QueueChart } from './queue-chart';
21
+ import { Breadcrumb, StepList } from './workflow-drilldown';
18
22
  import { StepGraph } from './step-graph';
19
23
  import { WorkflowDag } from './workflow-dag';
24
+ import { AgentUsageLine } from './agent-usage-line';
25
+ import type { AgentUsage } from './agent-usage';
26
+ import { MachineControls } from './machine-controls';
20
27
 
21
28
  /** What the page is given at each poll, all of it read at the request: every workflow, and where runs are now. */
22
29
  export interface WorkflowsPageData {
23
30
  readonly view: WorkflowsView;
24
31
  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 };
32
+ /**
33
+ * The one CPU limit and the newest reading of what the project used (`CpuLimit`); `threads`, how many the machine has,
34
+ * the most the limit can be set to.
35
+ */
36
+ readonly cpu: { readonly limit: number; readonly threads?: number; readonly use: { readonly at: number; readonly cores: number; readonly held: number; readonly waiting: number } | null };
37
+ /** When everything was stopped by hand, unix seconds; none, or absent, while the project runs. */
38
+ readonly stopped?: { readonly at: number } | null;
39
+ /** What the agents' account has used of its limits (`agent-usage.ts`); absent where the project reads none. */
40
+ readonly usage?: AgentUsage;
27
41
  }
28
42
 
29
43
  type WorkflowLimits = NonNullable<WorkflowView['limits']>;
@@ -33,6 +47,11 @@ export type LimitName = 'runs' | 'agents';
33
47
 
34
48
  /** 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
49
  export type SetLimit = (r: { readonly workflow: string; readonly limit: LimitName; readonly value: number | null }) => Promise<void>;
50
+ /** What starts a workflow's runs, in words. */
51
+ const startsLine = (w: WorkflowView): string =>
52
+ w.startsOn.kind === 'queue' ? 'Runs on its queue.'
53
+ : w.startsOn.kind === 'inputs' ? `Runs when its inputs change: ${w.startsOn.says}.`
54
+ : 'Runs on a timer or a request.';
36
55
 
37
56
  /** Where the project stands against its one CPU limit, in words. */
38
57
  const cpuLine = (cpu: WorkflowsPageData['cpu'], now: number): string =>
@@ -46,18 +65,25 @@ export interface WorkflowsDashboardProps {
46
65
  readonly error: string | null;
47
66
  /** Where one workflow's figures are read from when it is opened (`WorkflowFigures`): the project's route for them. */
48
67
  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. */
68
+ /** Where a definition's link goes, where the project has somewhere to show its source; with none, no link shows. */
69
+ readonly sourceHref?: (source: SourceLink) => string;
70
+ /** The project's own lines above everything: its title. */
52
71
  readonly header?: ReactNode;
53
- /** The project's own panels, between the header and the workflows. */
54
- readonly panels?: ReactNode;
55
72
  /** The project's name for one phase, in its own words; the phase's key where it gives none. */
56
73
  readonly phaseLabel?: (phase: string) => string;
57
- /** The project's figures for one phase, on its heading line. */
58
- readonly phaseSummary?: (phase: string) => ReactNode;
59
74
  /** How the page sets a limit; with none the limits show without controls. */
60
75
  readonly setLimit?: SetLimit;
76
+ /** Stores a new CPU limit; with none the limit shows without buttons (`machine-controls.tsx`). */
77
+ readonly setCpuLimit?: (limit: number) => Promise<void>;
78
+ /** Stops everything the project runs, and resumes it; with neither, no button shows. */
79
+ readonly stopEverything?: () => Promise<void>;
80
+ readonly resume?: () => Promise<void>;
81
+ /**
82
+ * THE DRILL-DOWN (`drilldown.ts`): the sub-workflow steps opened below the top workflow, top first, and each level's
83
+ * address, which the host page routes back here as `path`.
84
+ */
85
+ readonly path: ReadonlyArray<string>;
86
+ readonly hrefOf: (path: ReadonlyArray<string>) => string;
61
87
  }
62
88
 
63
89
  /** Polls a JSON route one request at a time, the next asked for when this one has answered. */
@@ -84,12 +110,12 @@ export const usePolledJson = <A,>(url: string, everyMs: number): { readonly data
84
110
  return { data, error };
85
111
  };
86
112
 
87
- const costCells = (c: StepCost | null, agent: boolean): ReactNode => (
113
+ const costCells = (c: StepCost | null, agentic: boolean): ReactNode => (
88
114
  <>
89
115
  <td className="wp-r">{c === null ? '' : c.calls.toLocaleString('en-US')}</td>
90
116
  <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
117
  <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>
118
+ <td className="wp-r">{c === null || !agentic ? '' : `${compact(c.inputTokens)} / ${compact(c.outputTokens)}`}</td>
93
119
  <td className="wp-r">{c === null ? '' : duration(c.cpuSeconds)}</td>
94
120
  <td className="wp-r">{c === null || c.items === 0 ? '' : c.items.toLocaleString('en-US')}</td>
95
121
  </>
@@ -111,7 +137,7 @@ function StepsTable({ workflow, usesAgents, runs, now }: { readonly workflow: Wo
111
137
  <div className="wp-tablewrap"><table className="wp-table">
112
138
  <thead>
113
139
  <tr>
114
- <th>step</th><th title="Uses an agent">agent</th><th>runs now</th>
140
+ <th>step</th><th title="Deterministic: code only. Agentic: an agent does it. Classification: a separate classifier model decides.">how it runs</th><th>runs now</th>
115
141
  <th className="wp-r">calls</th><th className="wp-r">failed</th><th className="wp-r">time</th>
116
142
  <th className="wp-r" title="Input tokens, fresh and cached / output tokens">tokens in / out</th>
117
143
  <th className="wp-r" title="Its own and its processes' CPU">CPU</th><th className="wp-r">items</th>
@@ -125,9 +151,9 @@ function StepsTable({ workflow, usesAgents, runs, now }: { readonly workflow: Wo
125
151
  <Fragment key={s.name}>
126
152
  <tr>
127
153
  <td title={s.description} className={s.declared ? '' : 'wp-bad'}>{s.name}{s.declared ? '' : ' (not declared)'}</td>
128
- <td>{s.agent ? '✓' : ''}</td>
154
+ <td>{s.runs ?? ''}</td>
129
155
  <td className="wp-mut">{nowCell(at, now)}</td>
130
- {costCells(s.cost, s.agent)}
156
+ {costCells(s.cost, s.runs === 'agentic')}
131
157
  <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
158
  </tr>
133
159
  {at?.waitingOn === null || at?.waitingOn === undefined ? null : (
@@ -259,7 +285,7 @@ const FIGURES_EVERY_MS = 15_000;
259
285
  * An open workflow: what it gave and cost, its steps, its step graph and where its runs stopped, read from its own records
260
286
  * while it is open. The figures of the workflow opened before it are never shown under this one's name.
261
287
  */
262
- function WorkflowDetail({ workflow, runs, now, figuresUrl }: { readonly workflow: WorkflowView; readonly runs: WorkflowRunsNow | undefined; readonly now: number; readonly figuresUrl: (workflow: string) => string }) {
288
+ function WorkflowDetail({ workflow, runs, now, figuresUrl, hrefOfWorkflow }: { readonly workflow: WorkflowView; readonly runs: WorkflowRunsNow | undefined; readonly now: number; readonly figuresUrl: (workflow: string) => string; readonly hrefOfWorkflow: (workflow: string) => string }) {
263
289
  const read = usePolledJson<WorkflowFigures>(figuresUrl(workflow.name), FIGURES_EVERY_MS);
264
290
  const figures = read.data !== null && read.data.workflow === workflow.name ? read.data : null;
265
291
  return (
@@ -268,11 +294,21 @@ function WorkflowDetail({ workflow, runs, now, figuresUrl }: { readonly workflow
268
294
  {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
295
  <>
270
296
  <p className="wp-line wp-mut">Its figures over the last {figures.hours} h, read {whenAgo(figures.at, now)}.</p>
297
+ {figures.blocked.length === 0 ? null : (
298
+ <>
299
+ <h4 className="wp-h4">Blocked, by reason</h4>
300
+ <table className="wp-reasons">
301
+ <tbody>
302
+ {figures.blocked.map((b) => <tr key={b.why}><td className="wp-r">{b.tasks.toLocaleString("en-US")}</td><td>{b.why}</td></tr>)}
303
+ </tbody>
304
+ </table>
305
+ </>
306
+ )}
271
307
  {workflow.item === null ? null : <p className="wp-line">{yieldLine(figures, workflow.finishedWord)}</p>}
272
308
  <p className="wp-line">{runCostLine(figures)}</p>
273
309
  <StepsTable workflow={figures} usesAgents={workflow.usesAgents} runs={runs} now={now} />
274
310
  <h4 className="wp-h4">Step graph</h4>
275
- <StepGraph graph={figures.graph} />
311
+ <div className="wp-tablewrap"><StepGraph graph={figures.graph} hrefOfWorkflow={hrefOfWorkflow} /></div>
276
312
  <h4 className="wp-h4">Where runs stopped</h4>
277
313
  <FunnelTable funnel={figures.funnel} />
278
314
  </>
@@ -281,8 +317,55 @@ function WorkflowDetail({ workflow, runs, now, figuresUrl }: { readonly workflow
281
317
  );
282
318
  }
283
319
 
284
- export function WorkflowsDashboard({ data, error, figuresUrl, sourceHref, header, panels, phaseLabel, phaseSummary, setLimit }: WorkflowsDashboardProps) {
320
+ /**
321
+ * ONE LEVEL OF THE DRILL-DOWN: the breadcrumb, then the workflow opened: what it is, its tasks as an addition, its runs and
322
+ * limits, and its own steps, each with its kind, a sub-workflow step a link one level down. Below the top, its figures too.
323
+ */
324
+ function DrillLevelView({ data, path, hrefOf, now, figuresUrl, sourceHref, phaseLabel, setLimit }: {
325
+ readonly data: WorkflowsPageData; readonly path: ReadonlyArray<string>; readonly hrefOf: (path: ReadonlyArray<string>) => string; readonly now: number;
326
+ readonly figuresUrl: (workflow: string) => string; readonly sourceHref: ((source: SourceLink) => string) | undefined; readonly phaseLabel: (phase: string) => string; readonly setLimit: SetLimit | undefined;
327
+ }) {
328
+ const level = drillLevel(data.view, path);
329
+ const all = data.view.groups.flatMap((g) => g.workflows);
330
+ const workflowOf = (name: string) => all.find((w) => w.name === name);
331
+ const runsOf = (name: string) => data.runsNow.flatMap((p) => p.workflows).find((r) => r.workflow === name);
332
+ const w = level.workflow;
333
+ const runs = w === null ? undefined : runsOf(w.name);
334
+ // At the top, each step is a workflow of one of the project's stages, which heads its steps.
335
+ const stageOf = (workflow: string | null) => (workflow === null ? null : workflowOf(workflow)?.phase ?? null);
336
+ return (
337
+ <section className="wp-drill">
338
+ {/* The breadcrumb is the title: its last part names the workflow opened. */}
339
+ <Breadcrumb crumbs={level.crumbs} hrefOf={hrefOf} after={w === null || sourceHref === undefined ? null : <a className="wp-mut wp-drill-source" href={sourceHref(w.source)}>source</a>} />
340
+ {level.notFound === null ? null : <p className="wp-line wp-bad">{level.name} has no sub-workflow step named {level.notFound}.</p>}
341
+ <p className="wp-line">{level.description}</p>
342
+ {w === null ? null : <p className="wp-line wp-mut">{startsLine(w)}</p>}
343
+ {w === null || w.queue === null ? null : <QueueBar queue={w.queue} />}
344
+ {w === null ? null : <div className="wp-node-status wp-drill-status"><WorkflowStatus workflow={w} runs={runs} limits={w.limits} setLimit={setLimit} /></div>}
345
+ {/* Its tasks over time: at the top a row for each step that has tasks; below it, the workflow opened and each such step of its own. */}
346
+ <QueueChart view={data.view} level={path.join("/")} rowWord={w === null ? "step" : "workflow"}
347
+ workflows={[...(w === null ? [] : [w]), ...level.steps.flatMap((s) => { const sub = s.workflow === null ? undefined : workflowOf(s.workflow); return sub === undefined || sub.name === w?.name ? [] : [sub]; })]} />
348
+ {/* At the top, the map of its steps: each workflow a box whose name opens it, with the arrows work takes between them. */}
349
+ {w !== null ? null : (
350
+ <>
351
+ <h3 className="wp-h3">Map</h3>
352
+ <WorkflowDag view={data.view} phaseLabel={phaseLabel} hrefOfWorkflow={(name) => hrefOf([name])}
353
+ nodeStatus={(node) => <WorkflowStatus workflow={node} runs={runsOf(node.name)} limits={node.limits} setLimit={setLimit} />} />
354
+ </>
355
+ )}
356
+ <h3 className="wp-h3">Steps</h3>
357
+ <StepList
358
+ steps={level.steps} path={level.crumbs[level.crumbs.length - 1]!.path} hrefOf={hrefOf} workflowOf={workflowOf} runsOf={runsOf} runs={runs}
359
+ {...(w === null ? { groupKey: (s: StepSummary) => stageOf(s.workflow), groupOf: (s: StepSummary) => { const stage = stageOf(s.workflow); return stage === null ? null : phaseLabel(stage); } } : {})}
360
+ />
361
+ {w === null ? null : <WorkflowDetail workflow={w} runs={runs} now={now} figuresUrl={figuresUrl} hrefOfWorkflow={(name) => hrefOf([...level.crumbs[level.crumbs.length - 1]!.path, name])} />}
362
+ </section>
363
+ );
364
+ }
365
+
366
+ export function WorkflowsDashboard({ data, error, figuresUrl, sourceHref, header, phaseLabel, setLimit, setCpuLimit, stopEverything, resume, path, hrefOf }: WorkflowsDashboardProps) {
285
367
  const now = Date.now() / 1000;
368
+ const atTheTop = path.length === 0;
286
369
  return (
287
370
  <div className="wp-page">
288
371
  {header}
@@ -290,24 +373,16 @@ export function WorkflowsDashboard({ data, error, figuresUrl, sourceHref, header
290
373
  {error !== null ? `The workflows could not be read: ${error}` : data === null ? 'Reading the workflows…' : `Read from the records ${whenAgo(data.view.at, now)}.`}
291
374
  </p>
292
375
  {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
- })()}
376
+ {/* Nothing a level decides is drawn before the first read: a server draws one page for every level's address. */}
377
+ {data === null || !atTheTop ? null : (
378
+ <>
379
+ <MachineControls cpu={data.cpu} stopped={data.stopped ?? null} now={now} {...(setCpuLimit === undefined ? {} : { setCpuLimit })} {...(stopEverything === undefined ? {} : { stopEverything })} {...(resume === undefined ? {} : { resume })} />
380
+ {data.usage === undefined ? null : <AgentUsageLine usage={data.usage} now={now} />}
381
+ </>
382
+ )}
383
+ {data === null ? null : (
384
+ <DrillLevelView data={data} path={path} hrefOf={hrefOf} now={now} figuresUrl={figuresUrl} sourceHref={sourceHref} phaseLabel={(phase) => (phaseLabel === undefined ? phase : phaseLabel(phase))} setLimit={setLimit} />
385
+ )}
311
386
  </div>
312
387
  );
313
388
  }