@jive-sh/workflow-platform 0.6.2 → 0.7.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 +189 -42
- package/dist/budget-states.js +1 -1
- package/dist/budget-states.js.map +1 -1
- package/dist/dashboard/dashboard.css +42 -28
- package/dist/dashboard/drilldown.js +35 -4
- package/dist/dashboard/drilldown.js.map +1 -1
- package/dist/dashboard/run-doing-words.js +29 -0
- package/dist/dashboard/run-doing-words.js.map +1 -0
- package/dist/dashboard/setting-words.js +18 -0
- package/dist/dashboard/setting-words.js.map +1 -0
- package/dist/dashboard/spending-words.js +2 -10
- package/dist/dashboard/spending-words.js.map +1 -1
- package/dist/index.js +76 -13
- package/dist/index.js.map +1 -1
- package/dist/keep-running.js +4 -2
- package/dist/keep-running.js.map +1 -1
- package/dist/pick-wakes.js +2 -2
- package/dist/retention.js +59 -0
- package/dist/retention.js.map +1 -0
- package/dist/settings.js +88 -0
- package/dist/settings.js.map +1 -0
- package/dist/spending-limit.js +15 -21
- package/dist/spending-limit.js.map +1 -1
- package/dist/step-times.js +114 -0
- package/dist/step-times.js.map +1 -0
- package/dist/steps.js +399 -114
- package/dist/steps.js.map +1 -1
- package/dist/storage/agent-claims.js +3 -0
- package/dist/storage/agent-claims.js.map +1 -0
- package/dist/storage/budgets.js +40 -4
- package/dist/storage/budgets.js.map +1 -1
- package/dist/storage/engine-records.js +26 -10
- package/dist/storage/engine-records.js.map +1 -1
- package/dist/storage/sqlite-store.js +198 -20
- package/dist/storage/sqlite-store.js.map +1 -1
- package/dist/storage/task-store.js +11 -5
- package/dist/storage/task-store.js.map +1 -1
- package/dist/system-workflows.js +54 -0
- package/dist/system-workflows.js.map +1 -0
- package/dist/tasks.js +72 -29
- package/dist/tasks.js.map +1 -1
- package/dist/views/runs-now.js +80 -38
- package/dist/views/runs-now.js.map +1 -1
- package/dist/views/step-graph.js +6 -1
- package/dist/views/step-graph.js.map +1 -1
- package/dist/views/workflows-view.js +29 -23
- package/dist/views/workflows-view.js.map +1 -1
- package/package.json +1 -1
- package/src/budget-states.ts +2 -3
- package/src/dashboard/dashboard.css +42 -28
- package/src/dashboard/drilldown.ts +32 -5
- package/src/dashboard/index.tsx +1 -1
- package/src/dashboard/limits-and-runs.tsx +191 -0
- package/src/dashboard/queue-bar.tsx +30 -11
- package/src/dashboard/queue-chart.tsx +1 -2
- package/src/dashboard/run-doing-words.ts +41 -0
- package/src/dashboard/setting-words.ts +30 -0
- package/src/dashboard/spending-limit-control.tsx +5 -8
- package/src/dashboard/spending-words.ts +5 -23
- package/src/dashboard/time-distribution.tsx +61 -0
- package/src/dashboard/workflow-dag.tsx +247 -129
- package/src/dashboard/workflow-drilldown.tsx +13 -71
- package/src/dashboard/workflows-dashboard.tsx +345 -227
- package/src/index.ts +86 -16
- package/src/keep-running.ts +6 -4
- package/src/pick-wakes.ts +2 -2
- package/src/project.ts +12 -0
- package/src/retention.ts +90 -0
- package/src/settings.ts +171 -0
- package/src/spending-limit.ts +25 -42
- package/src/step-times.ts +151 -0
- package/src/steps.ts +512 -135
- package/src/storage/agent-claims.ts +63 -0
- package/src/storage/budgets.ts +43 -4
- package/src/storage/engine-records.ts +28 -11
- package/src/storage/sqlite-store.ts +225 -32
- package/src/storage/step-records.ts +59 -7
- package/src/storage/task-store.ts +29 -29
- package/src/system-workflows.ts +70 -0
- package/src/tasks.ts +69 -30
- package/src/views/runs-now.ts +119 -51
- package/src/views/step-graph.ts +11 -2
- package/src/views/workflows-view.ts +80 -39
- package/src/workflow-dag.test.tsx +89 -0
- package/src/workflow-page.test.tsx +170 -0
- package/dist/views/workflow-flows.js +0 -53
- package/dist/views/workflow-flows.js.map +0 -1
- package/src/dashboard/step-graph.tsx +0 -106
- package/src/views/workflow-flows.ts +0 -97
|
@@ -2,35 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
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.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
5
|
+
* workflow and opens one sub-workflow step at a time, a breadcrumb saying where it is. Alex, 2026-11-21: "a workflow is a
|
|
6
|
+
* workflow. stop building bespoke pages". So every workflow, at every depth, the top included, gets one page with the same
|
|
7
|
+
* sections, in the same order, whatever kind of workflow it is (`WorkflowPage`): its tasks as an addition with its runs and
|
|
8
|
+
* limits, its steps as a graph (`workflow-dag.tsx`), its tasks over time, why its tasks are blocked or need an agent,
|
|
9
|
+
* what its runs gave and cost, and where its runs stopped. A section with nothing to show says so in a line.
|
|
10
|
+
*
|
|
11
|
+
* Above it, the same on every page: what the project gives of its machine and its agents' account (the CPU limit, the stop
|
|
12
|
+
* of everything, the spending limit and usage). It reads the platform's two readings (`views/workflows-view.ts`) and runs
|
|
13
|
+
* now (`views/runs-now.ts`). Uses React, which the host page brings.
|
|
11
14
|
*/
|
|
12
15
|
import { Fragment, useEffect, useState, type ReactNode } from 'react';
|
|
13
|
-
import type {
|
|
16
|
+
import type { StepRunsNow, WorkflowRunsNow } from '../views/runs-now';
|
|
14
17
|
import type { StepFunnel } from '../views/step-funnel';
|
|
15
|
-
import type {
|
|
16
|
-
import type {
|
|
18
|
+
import type { SourceLink, StepCost, StepSummary, StepView, WorkflowFigures, WorkflowView, WorkflowsView } from '../views/workflows-view';
|
|
19
|
+
import type { StepTimes } from '../step-times';
|
|
20
|
+
import { TimeDistribution } from './time-distribution';
|
|
17
21
|
import { compact, duration, localTime, whenAgo } from '../views/format';
|
|
18
|
-
import { drillLevel } from './drilldown';
|
|
22
|
+
import { drillLevel, kindWords, workflowsUnder, type DrillLevel } from './drilldown';
|
|
19
23
|
import { QueueBar } from './queue-bar';
|
|
20
24
|
import { QueueChart } from './queue-chart';
|
|
21
|
-
import { Breadcrumb,
|
|
22
|
-
import {
|
|
23
|
-
import { WorkflowDag } from './workflow-dag';
|
|
25
|
+
import { Breadcrumb, WorkflowTitle } from './workflow-drilldown';
|
|
26
|
+
import { WorkflowDag, type StepBox } from './workflow-dag';
|
|
24
27
|
import { AgentUsageLine } from './agent-usage-line';
|
|
25
28
|
import type { AgentUsage } from './agent-usage';
|
|
26
29
|
import { MachineControls } from './machine-controls';
|
|
27
30
|
import { SpendingLimitControl } from './spending-limit-control';
|
|
28
|
-
import {
|
|
31
|
+
import { modelWords } from './setting-words';
|
|
32
|
+
import { LimitControl, LimitLines, RetentionLines, RunsLines, type LimitName, type SetLimit, type SetSetting } from './limits-and-runs';
|
|
33
|
+
|
|
34
|
+
export type { LimitName, SetLimit, SetSetting };
|
|
35
|
+
import { runsGoingWords } from './run-doing-words';
|
|
29
36
|
|
|
30
37
|
/** What the page is given at each poll, all of it read at the request: every workflow, and where runs are now. */
|
|
31
38
|
export interface WorkflowsPageData {
|
|
32
39
|
readonly view: WorkflowsView;
|
|
33
|
-
readonly runsNow: ReadonlyArray<
|
|
40
|
+
readonly runsNow: ReadonlyArray<WorkflowRunsNow>;
|
|
34
41
|
/**
|
|
35
42
|
* The one CPU limit and the newest reading of what the project used (`CpuLimit`); `threads`, how many the machine has,
|
|
36
43
|
* the most the limit can be set to.
|
|
@@ -44,14 +51,10 @@ export interface WorkflowsPageData {
|
|
|
44
51
|
|
|
45
52
|
type WorkflowLimits = NonNullable<WorkflowView['limits']>;
|
|
46
53
|
|
|
47
|
-
/** Which of a workflow's two limits a control sets. */
|
|
48
|
-
export type LimitName = 'runs' | 'agents';
|
|
49
|
-
|
|
50
|
-
/** 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. */
|
|
51
|
-
export type SetLimit = (r: { readonly workflow: string; readonly limit: LimitName; readonly value: number | null }) => Promise<void>;
|
|
52
54
|
/** What starts a workflow's runs, in words. */
|
|
53
55
|
const startsLine = (w: WorkflowView): string =>
|
|
54
56
|
w.startsOn.kind === 'a step' ? `Runs as a step of ${w.startsOn.of.join(', ')}.`
|
|
57
|
+
: w.startsOn.kind === 'its steps' ? 'Each of its steps is a workflow that runs on its own trigger.'
|
|
55
58
|
: w.startsOn.kind === 'queue' ? 'Runs on its queue.'
|
|
56
59
|
: w.startsOn.kind === 'inputs' ? `Runs when its inputs change: ${w.startsOn.says}.`
|
|
57
60
|
: 'Runs on a timer or a request.';
|
|
@@ -68,14 +71,16 @@ export interface WorkflowsDashboardProps {
|
|
|
68
71
|
readonly error: string | null;
|
|
69
72
|
/** Where one workflow's figures are read from when it is opened (`WorkflowFigures`): the project's route for them. */
|
|
70
73
|
readonly figuresUrl: (workflow: string) => string;
|
|
74
|
+
/** Where one workflow's step times are read from (`StepTimes`); with none, no step shows its time distribution. */
|
|
75
|
+
readonly timesUrl?: (workflow: string) => string;
|
|
71
76
|
/** Where a definition's link goes, where the project has somewhere to show its source; with none, no link shows. */
|
|
72
77
|
readonly sourceHref?: (source: SourceLink) => string;
|
|
73
78
|
/** The project's own lines above everything: its title. */
|
|
74
79
|
readonly header?: ReactNode;
|
|
75
|
-
/** The project's name for one phase, in its own words; the phase's key where it gives none. */
|
|
76
|
-
readonly phaseLabel?: (phase: string) => string;
|
|
77
80
|
/** How the page sets a limit; with none the limits show without controls. */
|
|
78
81
|
readonly setLimit?: SetLimit;
|
|
82
|
+
/** How the page sets a retention setting at a level; with none the settings show without controls. */
|
|
83
|
+
readonly setSetting?: SetSetting;
|
|
79
84
|
/** Stores a new CPU limit; with none the limit shows without buttons (`machine-controls.tsx`). */
|
|
80
85
|
readonly setCpuLimit?: (limit: number) => Promise<void>;
|
|
81
86
|
/** Stops everything the project runs, and resumes it; with neither, no button shows. */
|
|
@@ -92,10 +97,12 @@ export interface WorkflowsDashboardProps {
|
|
|
92
97
|
}
|
|
93
98
|
|
|
94
99
|
/** Polls a JSON route one request at a time, the next asked for when this one has answered. */
|
|
95
|
-
export const usePolledJson = <A,>(url: string, everyMs: number): { readonly data: A | null; readonly error: string | null } => {
|
|
100
|
+
export const usePolledJson = <A,>(url: string | null, everyMs: number): { readonly data: A | null; readonly error: string | null } => {
|
|
96
101
|
const [data, setData] = useState<A | null>(null);
|
|
97
102
|
const [error, setError] = useState<string | null>(null);
|
|
98
103
|
useEffect(() => {
|
|
104
|
+
// No address, nothing to read: a part of the page the project gives no route for.
|
|
105
|
+
if (url === null) return;
|
|
99
106
|
let alive = true;
|
|
100
107
|
let next: ReturnType<typeof setTimeout> | undefined;
|
|
101
108
|
const tick = async () => {
|
|
@@ -115,70 +122,61 @@ export const usePolledJson = <A,>(url: string, everyMs: number): { readonly data
|
|
|
115
122
|
return { data, error };
|
|
116
123
|
};
|
|
117
124
|
|
|
118
|
-
const costCells = (c: StepCost | null, agentic: boolean): ReactNode => (
|
|
119
|
-
<>
|
|
120
|
-
<td className="wp-r">{c === null ? '' : c.calls.toLocaleString('en-US')}</td>
|
|
121
|
-
<td className={c !== null && c.failed > 0 ? 'wp-r wp-bad' : 'wp-r'}>{c === null || c.failed === 0 ? '' : c.failed.toLocaleString('en-US')}</td>
|
|
122
|
-
<td className="wp-r">{c === null ? '' : duration(c.seconds)}</td>
|
|
123
|
-
<td className="wp-r">{c === null || !agentic ? '' : `${compact(c.inputTokens)} / ${compact(c.outputTokens)}`}</td>
|
|
124
|
-
<td className="wp-r">{c === null ? '' : duration(c.cpuSeconds)}</td>
|
|
125
|
-
<td className="wp-r">{c === null || c.items === 0 ? '' : c.items.toLocaleString('en-US')}</td>
|
|
126
|
-
</>
|
|
127
|
-
);
|
|
128
|
-
|
|
129
125
|
/** Where a step's runs are now, in words: "2 in it", "1 waiting after it since 5:04 AM · 3 min ago". */
|
|
130
|
-
const
|
|
126
|
+
const nowWords = (s: StepRunsNow | undefined, now: number): string => {
|
|
131
127
|
if (s === undefined) return '';
|
|
132
|
-
|
|
133
|
-
...(s.inStep > 0 ? [`${s.inStep} in it`] : []),
|
|
128
|
+
return [
|
|
129
|
+
...(s.inStep > 0 ? [`${s.inStep} run${s.inStep === 1 ? '' : 's'} in it`] : []),
|
|
134
130
|
...(s.waitingAfter > 0 ? [`${s.waitingAfter} after it${s.waitingSince === null ? '' : `, since ${whenAgo(s.waitingSince, now)}`}`] : []),
|
|
135
|
-
];
|
|
136
|
-
return parts.join(', ');
|
|
131
|
+
].join(', ');
|
|
137
132
|
};
|
|
138
133
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
134
|
+
/** What a step's calls cost in the window, in words: time, tokens (an agent step's), CPU, compiles and items. */
|
|
135
|
+
const costWords = (c: StepCost, agentic: boolean): string => [
|
|
136
|
+
duration(c.seconds),
|
|
137
|
+
...(agentic ? [`${compact(c.inputTokens)} / ${compact(c.outputTokens)} tokens`] : []),
|
|
138
|
+
`${duration(c.cpuSeconds)} CPU`,
|
|
139
|
+
...(c.compiles === 0 ? [] : [`${compact(c.compiles)} compiles`]),
|
|
140
|
+
...(c.items === 0 ? [] : [`${c.items.toLocaleString('en-US')} item${c.items === 1 ? '' : 's'}`]),
|
|
141
|
+
].join(' · ');
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* A STEP'S OWN CALLS AS AN ADDITION, from its step records in the window (`StepCost`): in progress (its records still
|
|
145
|
+
* open), failed, and done (ended without failing), adding up to its calls. Nothing records a task's status at a step, so
|
|
146
|
+
* a step that is no workflow shows its calls, never its workflow's tasks. Pure.
|
|
147
|
+
*/
|
|
148
|
+
export const stepCalls = (c: StepCost): Readonly<Record<string, number>> => ({ 'in progress': c.open, failed: c.failed, done: c.calls - c.open - c.failed });
|
|
149
|
+
|
|
150
|
+
/** What its runs finished over the window, per run, per million tokens and per compile, with the window before beside it. */
|
|
151
|
+
const yieldLine = (w: WorkflowFigures, finishedWord: string | null): string => {
|
|
152
|
+
const { now, before } = w.yields;
|
|
153
|
+
if (now.runs === 0 && before.runs === 0) return `No run of its own in the last ${2 * w.hours} h.`;
|
|
154
|
+
const word = finishedWord ?? 'finished';
|
|
155
|
+
const trend = now.finished === before.finished ? 'the same as' : now.finished > before.finished ? 'up from' : 'down from';
|
|
156
|
+
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: `
|
|
157
|
+
+ `${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)}).`;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
/** A figure to two places, or "none" where there was nothing to divide by. */
|
|
161
|
+
const per = (n: number | null): string => (n === null ? 'none' : n === 0 ? '0' : n < 0.01 ? n.toPrecision(2) : n.toFixed(n >= 10 ? 0 : 2));
|
|
162
|
+
|
|
163
|
+
/** What a run of it costs: the median run's time, tokens, CPU (its processes' part) and compiles, and its costliest run. */
|
|
164
|
+
const runCostLine = (w: WorkflowFigures): string => {
|
|
165
|
+
const c = w.runCosts;
|
|
166
|
+
if (c.median === null) return 'No run of its own ended in the window.';
|
|
167
|
+
const tokens = c.median.tokens === 0 ? '' : `, ${compact(c.median.tokens)} tokens`;
|
|
168
|
+
const compiles = c.median.compiles === 0 ? '' : `, ${compact(c.median.compiles)} compiles`;
|
|
169
|
+
const costliest = c.costliest === null ? '' : `; costliest ${duration(c.costliest.cpuSeconds)} of CPU, started ${localTime(c.costliest.started)}`;
|
|
170
|
+
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}.`;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
/** Its steps' calls added up, in words. */
|
|
174
|
+
const totalLine = (w: WorkflowFigures, usesAgents: boolean): string =>
|
|
175
|
+
w.total.calls === 0 ? `No step of its own was called in the last ${w.hours} h.`
|
|
176
|
+
: `Its steps in all, last ${w.hours} h: ${w.total.calls.toLocaleString('en-US')} calls, ${w.total.failed.toLocaleString('en-US')} failed, ${costWords(w.total, usesAgents)}.`;
|
|
179
177
|
|
|
180
178
|
function FunnelTable({ funnel }: { readonly funnel: StepFunnel }) {
|
|
181
|
-
if (funnel.runs === 0) return <p className="wp-line wp-mut">No run began since {localTime(funnel.since)}.</p>;
|
|
179
|
+
if (funnel.runs === 0) return <p className="wp-line wp-mut">No run of its own began since {localTime(funnel.since)}.</p>;
|
|
182
180
|
return (
|
|
183
181
|
<>
|
|
184
182
|
<p className="wp-line">
|
|
@@ -209,206 +207,326 @@ function FunnelTable({ funnel }: { readonly funnel: StepFunnel }) {
|
|
|
209
207
|
);
|
|
210
208
|
}
|
|
211
209
|
|
|
212
|
-
/** A
|
|
213
|
-
|
|
210
|
+
/** A workflow's runs and agents now, and its limits with their controls: what its box shows below its tasks. */
|
|
211
|
+
function WorkflowStatus({ workflow, runs, limits, setLimit }: { readonly workflow: WorkflowView; readonly runs: WorkflowRunsNow | undefined; readonly limits: WorkflowLimits | null; readonly setLimit: SetLimit | undefined }) {
|
|
212
|
+
const going = runs?.runs ?? 0;
|
|
213
|
+
const words = runsGoingWords({ runs: going, doing: runs?.doing ?? [], usesAgents: workflow.usesAgents, agentsLimit: limits?.agents ?? null });
|
|
214
|
+
return (
|
|
215
|
+
<div className="wp-node-status">
|
|
216
|
+
<span className={going === 0 ? 'wp-mut' : ''} title="Each run going counted once, by its newest step record, read through a sub-workflow step to the run it started">{words}</span>
|
|
217
|
+
{limits === null ? null : (
|
|
218
|
+
<>
|
|
219
|
+
<LimitControl workflow={workflow.name} limit="runs" value={limits.runs} isSet={limits.runsSet} setLimit={setLimit} />
|
|
220
|
+
{limits.agents === null ? null : <LimitControl workflow={workflow.name} limit="agents" value={limits.agents} isSet setLimit={setLimit} />}
|
|
221
|
+
</>
|
|
222
|
+
)}
|
|
223
|
+
</div>
|
|
224
|
+
);
|
|
225
|
+
}
|
|
214
226
|
|
|
215
|
-
/**
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
227
|
+
/**
|
|
228
|
+
* The workflow whose tasks a workflow's box shows: its own where it records them; for one made of workflows, its main step's
|
|
229
|
+
* (`StartsOn` `mainStep`), counted under that step's own workflow; none for any other.
|
|
230
|
+
*/
|
|
231
|
+
const tasksShownOf = (w: WorkflowView, workflowOf: (name: string) => WorkflowView | undefined): WorkflowView | null => {
|
|
232
|
+
if (w.queue !== null) return w;
|
|
233
|
+
const main = w.startsOn.kind === 'its steps' && w.startsOn.mainStep !== null ? workflowOf(w.startsOn.mainStep) : undefined;
|
|
234
|
+
return main !== undefined && main.queue !== null ? main : null;
|
|
222
235
|
};
|
|
223
236
|
|
|
224
|
-
/**
|
|
225
|
-
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
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}.`;
|
|
232
|
-
};
|
|
237
|
+
/** A workflow's tasks as an addition, a main step's named in its total ("tasks in Decompile"); or a line saying it records none. */
|
|
238
|
+
function Tasks({ workflow, workflowOf }: { readonly workflow: WorkflowView; readonly workflowOf: (name: string) => WorkflowView | undefined }) {
|
|
239
|
+
const shown = tasksShownOf(workflow, workflowOf);
|
|
240
|
+
return shown === null || shown.queue === null
|
|
241
|
+
? <p className="wp-line wp-mut">{noTasksWhy(workflow)}</p>
|
|
242
|
+
: <QueueBar queue={shown.queue} queuedNeedingAnAgent={shown.queuedNeedingAnAgent} totalLabel={shown === workflow ? 'total' : `tasks in ${shown.name}`} />;
|
|
243
|
+
}
|
|
233
244
|
|
|
234
|
-
/**
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
245
|
+
/** Why a workflow has no tasks of its own to count, in a line: they are other workflows', each counted once, under its own. */
|
|
246
|
+
export const noTasksWhy = (w: Pick<WorkflowView, 'startsOn'>): string =>
|
|
247
|
+
w.startsOn.kind === 'its steps' ? "Its tasks are its steps', each counted under its own workflow."
|
|
248
|
+
: w.startsOn.kind === 'a step' ? `Its tasks are ${w.startsOn.of.join(' and ')}'s, passing through it.`
|
|
249
|
+
: 'It records no tasks.';
|
|
239
250
|
|
|
240
251
|
/**
|
|
241
|
-
*
|
|
242
|
-
*
|
|
252
|
+
* A STEP'S CALLS IN THE WINDOW AS AN ADDITION (`stepCalls`): a step's own on its workflow's page, and on the page of a workflow
|
|
253
|
+
* run as a step of another, that workflow's calls of it, its tasks passing through. The one drawing of both.
|
|
243
254
|
*/
|
|
244
|
-
function
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
255
|
+
export function CallsBar({ cost, hours }: { readonly cost: StepCost; readonly hours: number }) {
|
|
256
|
+
return <QueueBar queue={stepCalls(cost)} queuedNeedingAnAgent={null} counts="calls" totalLabel={`calls, ${hours} h`} />;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/** What its Pick does with its tasks marked as needing an agent, in words. */
|
|
260
|
+
const needingAnAgentLine = (passedOverBecause: string | null): string =>
|
|
261
|
+
passedOverBecause === null
|
|
262
|
+
? 'Each ended a run at an agent step when no agent was free for it. An agent is free now, so its Pick takes them in their queue\'s order again.'
|
|
263
|
+
: `Each ended a run at an agent step when no agent was free for it. Its Pick passes over them now, because ${passedOverBecause}, and takes them in their queue's order once an agent is free.`;
|
|
264
|
+
|
|
265
|
+
/** One step's box under its heading: a step that is a workflow shows that workflow's tasks and status; any other, its own calls. */
|
|
266
|
+
function StepBody({ workflow, workflowOf, step, sub, subRuns, view, runsNow, hours, now, setLimit, setSetting, timing }: {
|
|
267
|
+
/** The workflow whose page draws it. */
|
|
268
|
+
readonly workflow: string;
|
|
269
|
+
readonly workflowOf: (name: string) => WorkflowView | undefined;
|
|
270
|
+
readonly step: StepSummary; readonly sub: WorkflowView | undefined; readonly subRuns: WorkflowRunsNow | undefined;
|
|
271
|
+
readonly view: StepView | undefined; readonly runsNow: StepRunsNow | undefined; readonly hours: number; readonly now: number; readonly setLimit: SetLimit | undefined; readonly setSetting: SetSetting | undefined;
|
|
272
|
+
/** Its time distribution (`StepTimesPart`); none until its times are read. */
|
|
273
|
+
readonly timing: ReactNode;
|
|
274
|
+
}) {
|
|
275
|
+
// What it is and what it does, in words a phone shows: its kind, then its description, never only a hover.
|
|
276
|
+
const kind = <><span className="wp-kind">{kindWords(step)}</span><p className="wp-node-what">{step.description}</p></>;
|
|
277
|
+
// What it inherits or sets (`settings.ts`): how long its records are kept and, where it uses an agent, the model, each with where it is set.
|
|
278
|
+
const here = { workflow, step: step.name };
|
|
279
|
+
const settings = (
|
|
280
|
+
<div className="wp-node-settings">
|
|
281
|
+
<RetentionLines level={{ kind: 'step', workflow, step: step.name }} settings={step.retention} setSetting={setSetting} />
|
|
282
|
+
{step.model === null ? null : <div className={step.model.value === null ? 'wp-bad' : undefined}>{modelWords(step.model, here)}</div>}
|
|
283
|
+
</div>
|
|
284
|
+
);
|
|
285
|
+
const cost = view?.cost ?? null;
|
|
286
|
+
const at = nowWords(runsNow, now);
|
|
287
|
+
// The bar: a workflow step's own tasks where its workflow records them; otherwise this workflow's calls of the step, from
|
|
288
|
+
// its own step records, which a workflow run as a step on this workflow's item records too (its tasks passing through it).
|
|
289
|
+
const bar = sub !== undefined && tasksShownOf(sub, workflowOf) !== null ? <Tasks workflow={sub} workflowOf={workflowOf} />
|
|
290
|
+
: cost !== null ? <CallsBar cost={cost} hours={hours} />
|
|
291
|
+
: <p className="wp-line wp-mut">{sub === undefined || sub.startsOn.kind === 'a step' ? `No call in the last ${hours} h.` : noTasksWhy(sub)}</p>;
|
|
258
292
|
return (
|
|
259
|
-
|
|
260
|
-
{
|
|
261
|
-
|
|
262
|
-
{
|
|
263
|
-
{
|
|
264
|
-
|
|
265
|
-
|
|
293
|
+
<>
|
|
294
|
+
{kind}
|
|
295
|
+
{settings}
|
|
296
|
+
{bar}
|
|
297
|
+
{sub !== undefined ? <WorkflowStatus workflow={sub} runs={subRuns} limits={sub.limits} setLimit={setLimit} /> : (
|
|
298
|
+
<div className="wp-node-status">
|
|
299
|
+
<span className={at === '' ? 'wp-mut' : ''}>{at === '' ? 'no run in it' : at}</span>
|
|
300
|
+
{runsNow?.waitingOn === null || runsNow?.waitingOn === undefined ? null : <span>waits: {runsNow.waitingOn}</span>}
|
|
301
|
+
</div>
|
|
302
|
+
)}
|
|
303
|
+
{cost === null ? null : <div className="wp-node-status wp-mut">{costWords(cost, step.runs === 'agentic')}</div>}
|
|
304
|
+
{view === undefined || view.endings.length === 0 ? null : (
|
|
305
|
+
<div className="wp-node-status wp-mut" title={view.endings.map((e) => `${e.records} ${e.outcome}: ${e.reason}`).join('\n')}>
|
|
306
|
+
ended: {view.endings[0]!.reason} ({view.endings[0]!.records})
|
|
307
|
+
</div>
|
|
308
|
+
)}
|
|
309
|
+
{timing}
|
|
310
|
+
</>
|
|
266
311
|
);
|
|
267
312
|
}
|
|
268
313
|
|
|
269
|
-
/**
|
|
270
|
-
|
|
271
|
-
|
|
314
|
+
/** What one of the platform's own workflows is, in words (`system-workflows.ts`): what the app may change of it and what it may not. */
|
|
315
|
+
export const SYSTEM_WORKFLOW_WORDS = 'Part of the platform: the app sets its schedule, its run limit and the settings it inherits; its steps change only with the platform.';
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* THE PLATFORM'S OWN WORKFLOWS, on a top-level page, apart from the app's: each by name, said in words to be the
|
|
319
|
+
* platform's, with how long its steps' records are kept and where that is set, and its runs and run limit.
|
|
320
|
+
*/
|
|
321
|
+
function PlatformWorkflows({ workflows, runsOf, hrefOf, setLimit, setSetting }: { readonly workflows: ReadonlyArray<WorkflowView>; readonly runsOf: (name: string) => WorkflowRunsNow | undefined; readonly hrefOf: (path: ReadonlyArray<string>) => string; readonly setLimit: SetLimit | undefined; readonly setSetting: SetSetting | undefined }) {
|
|
272
322
|
return (
|
|
273
323
|
<>
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
<
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
)}
|
|
324
|
+
{workflows.map((w) => (
|
|
325
|
+
<div key={w.name} className="wp-passing" data-system-workflow={w.name}>
|
|
326
|
+
<p className="wp-line"><a href={hrefOf([w.name])}>{w.name}</a>: {w.description}</p>
|
|
327
|
+
<p className="wp-line wp-mut">{SYSTEM_WORKFLOW_WORDS}</p>
|
|
328
|
+
<RunsLines workflow={w} runs={runsOf(w.name)} />
|
|
329
|
+
<LimitLines workflow={w} setLimit={setLimit} setSetting={setSetting} />
|
|
330
|
+
</div>
|
|
331
|
+
))}
|
|
282
332
|
</>
|
|
283
333
|
);
|
|
284
334
|
}
|
|
285
335
|
|
|
286
|
-
/**
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
: `Each ended a run at an agent step when no agent could be had. Its Pick passes over them now, because ${passedOverBecause}, and takes them in their queue's order once an agent can be had.`;
|
|
336
|
+
/** One of the page's sections: a heading, and what it shows or a line saying why it shows nothing. */
|
|
337
|
+
function Section({ name, children }: { readonly name: string; readonly children: ReactNode }) {
|
|
338
|
+
return <section className="wp-section" data-section={name}><h3 className="wp-h3">{name}</h3>{children}</section>;
|
|
339
|
+
}
|
|
291
340
|
|
|
292
|
-
|
|
293
|
-
|
|
341
|
+
export interface WorkflowPageProps {
|
|
342
|
+
readonly data: WorkflowsPageData;
|
|
343
|
+
/** The opened workflow's figures as last read, and why they could not be read, if they could not. */
|
|
344
|
+
readonly figures: { readonly data: WorkflowFigures | null; readonly error: string | null };
|
|
345
|
+
readonly path: ReadonlyArray<string>;
|
|
346
|
+
readonly hrefOf: (path: ReadonlyArray<string>) => string;
|
|
347
|
+
readonly now: number;
|
|
348
|
+
readonly sourceHref?: ((source: SourceLink) => string) | undefined;
|
|
349
|
+
readonly setLimit?: SetLimit | undefined;
|
|
350
|
+
readonly setSetting?: SetSetting | undefined;
|
|
351
|
+
/** Its steps' times as last read (`step-times.ts`), and why they could not be read; absent where the project gives none. */
|
|
352
|
+
readonly times?: { readonly data: StepTimes | null; readonly error: string | null } | undefined;
|
|
353
|
+
}
|
|
294
354
|
|
|
295
355
|
/**
|
|
296
|
-
*
|
|
297
|
-
*
|
|
356
|
+
* ONE STEP'S TIME DISTRIBUTION IN ITS BOX: over the current version of its workflow, every task's value; before the first task
|
|
357
|
+
* of a new version, the previous version's, said to be that. None until the times are first read.
|
|
298
358
|
*/
|
|
299
|
-
function
|
|
300
|
-
const
|
|
301
|
-
|
|
359
|
+
function StepTimesPart({ step, times, now }: { readonly step: string; readonly times: StepTimes; readonly now: number }) {
|
|
360
|
+
const current = times.steps.find((s) => s.step === step)?.values ?? [];
|
|
361
|
+
if (current.length > 0) return <TimeDistribution values={current} />;
|
|
362
|
+
if (times.previous === null) {
|
|
363
|
+
return <p className="wp-line wp-mut">{times.steps.some((s) => s.values.length > 0) ? 'No task has left this step in this version yet.' : `No runs of this version yet, since ${localTime(times.since, now)}.`}</p>;
|
|
364
|
+
}
|
|
365
|
+
const before = times.previous.steps.find((s) => s.step === step)?.values ?? [];
|
|
302
366
|
return (
|
|
303
367
|
<>
|
|
304
|
-
<
|
|
305
|
-
{
|
|
306
|
-
<>
|
|
307
|
-
<p className="wp-line wp-mut">Its figures over the last {figures.hours} h, read {whenAgo(figures.at, now)}.</p>
|
|
308
|
-
{figures.blocked.length === 0 ? null : (
|
|
309
|
-
<>
|
|
310
|
-
<h4 className="wp-h4">Blocked, by reason</h4>
|
|
311
|
-
<table className="wp-reasons">
|
|
312
|
-
<tbody>
|
|
313
|
-
{figures.blocked.map((b) => <tr key={b.why}><td className="wp-r">{b.tasks.toLocaleString("en-US")}</td><td>{b.why}</td></tr>)}
|
|
314
|
-
</tbody>
|
|
315
|
-
</table>
|
|
316
|
-
</>
|
|
317
|
-
)}
|
|
318
|
-
{figures.needingAnAgent.reasons.length === 0 ? null : (
|
|
319
|
-
<>
|
|
320
|
-
<h4 className="wp-h4">Queued, needing an agent</h4>
|
|
321
|
-
<p className={figures.needingAnAgent.passedOverBecause === null ? 'wp-line' : 'wp-line wp-bad'}>{needingAnAgentLine(figures.needingAnAgent.passedOverBecause)}</p>
|
|
322
|
-
<table className="wp-reasons">
|
|
323
|
-
<tbody>
|
|
324
|
-
{figures.needingAnAgent.reasons.map((b) => <tr key={b.why}><td className="wp-r">{b.tasks.toLocaleString("en-US")}</td><td>{b.why}</td></tr>)}
|
|
325
|
-
</tbody>
|
|
326
|
-
</table>
|
|
327
|
-
</>
|
|
328
|
-
)}
|
|
329
|
-
{workflow.item === null ? null : <p className="wp-line">{yieldLine(figures, workflow.finishedWord)}</p>}
|
|
330
|
-
<p className="wp-line">{runCostLine(figures)}</p>
|
|
331
|
-
<StepsTable workflow={figures} usesAgents={workflow.usesAgents} runs={runs} now={now} />
|
|
332
|
-
<h4 className="wp-h4">Step graph</h4>
|
|
333
|
-
<div className="wp-tablewrap"><StepGraph graph={figures.graph} hrefOfWorkflow={hrefOfWorkflow} /></div>
|
|
334
|
-
<h4 className="wp-h4">Where runs stopped</h4>
|
|
335
|
-
<FunnelTable funnel={figures.funnel} />
|
|
336
|
-
</>
|
|
337
|
-
)}
|
|
368
|
+
<p className="wp-line wp-mut">No runs of this version yet, since {localTime(times.since, now)}. The previous version{before.length === 0 ? ' had no task leave this step.' : ':'}</p>
|
|
369
|
+
{before.length === 0 ? null : <TimeDistribution values={before} />}
|
|
338
370
|
</>
|
|
339
371
|
);
|
|
340
372
|
}
|
|
341
373
|
|
|
342
374
|
/**
|
|
343
|
-
* ONE
|
|
344
|
-
*
|
|
375
|
+
* ONE WORKFLOW'S PAGE, THE SAME FOR EVERY WORKFLOW AT EVERY DEPTH: the breadcrumb, then the workflow opened and each of its
|
|
376
|
+
* sections in one order. Nothing here asks what kind of workflow it is; what differs is only what its records hold.
|
|
345
377
|
*/
|
|
346
|
-
function
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
}) {
|
|
350
|
-
const level = drillLevel(data.view, path);
|
|
351
|
-
const all = data.view.groups.flatMap((g) => g.workflows);
|
|
378
|
+
export function WorkflowPage({ data, figures: read, path, hrefOf, now, sourceHref, setLimit, setSetting, times }: WorkflowPageProps) {
|
|
379
|
+
const level: DrillLevel = drillLevel(data.view, path);
|
|
380
|
+
const all = data.view.workflows;
|
|
352
381
|
const workflowOf = (name: string) => all.find((w) => w.name === name);
|
|
353
|
-
const runsOf = (name: string) => data.runsNow.
|
|
382
|
+
const runsOf = (name: string) => data.runsNow.find((r) => r.workflow === name);
|
|
383
|
+
const here = level.crumbs[level.crumbs.length - 1]!.path;
|
|
354
384
|
const w = level.workflow;
|
|
355
|
-
const
|
|
356
|
-
//
|
|
357
|
-
const
|
|
385
|
+
const figures = read.data !== null && read.data.workflow === level.name ? read.data : null;
|
|
386
|
+
// The figures of the workflow opened before this one are never shown under this one's name.
|
|
387
|
+
const withFigures = (show: (f: WorkflowFigures) => ReactNode): ReactNode => (figures !== null ? show(figures)
|
|
388
|
+
: <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>);
|
|
389
|
+
const others = [data.view.top.name, ...data.view.outermost].filter((name) => name !== level.name);
|
|
390
|
+
const box = (f: WorkflowFigures) => (name: string): StepBox => {
|
|
391
|
+
const step = level.steps.find((s) => s.name === name);
|
|
392
|
+
const sub = step?.workflow === null || step?.workflow === undefined ? undefined : workflowOf(step.workflow);
|
|
393
|
+
return {
|
|
394
|
+
href: sub === undefined ? null : hrefOf([...here, name]),
|
|
395
|
+
title: sub === undefined ? name : `Open ${sub.name}`,
|
|
396
|
+
body: step === undefined ? null : (
|
|
397
|
+
<StepBody workflow={level.name} workflowOf={workflowOf} step={step} sub={sub} subRuns={sub === undefined ? undefined : runsOf(sub.name)} view={f.steps.find((s) => s.name === name)}
|
|
398
|
+
runsNow={w === null ? undefined : runsOf(w.name)?.steps.find((s) => s.step === name)} hours={f.hours} now={now} setLimit={setLimit} setSetting={setSetting}
|
|
399
|
+
timing={times?.data === null || times?.data === undefined ? null : <StepTimesPart step={name} times={times.data} now={now} />} />
|
|
400
|
+
),
|
|
401
|
+
};
|
|
402
|
+
};
|
|
358
403
|
return (
|
|
359
404
|
<section className="wp-drill">
|
|
360
|
-
{/*
|
|
361
|
-
<Breadcrumb crumbs={level.crumbs} hrefOf={hrefOf}
|
|
405
|
+
{/* Where it is, then what it is: the path from the top-level workflow, and the workflow this page shows. */}
|
|
406
|
+
<Breadcrumb crumbs={level.crumbs} hrefOf={hrefOf} />
|
|
407
|
+
<WorkflowTitle name={level.name} after={w === null || sourceHref === undefined ? null : <a className="wp-mut wp-drill-source" href={sourceHref(w.source)}>source</a>} />
|
|
362
408
|
{level.notFound === null ? null : <p className="wp-line wp-bad">{level.name} has no sub-workflow step named {level.notFound}.</p>}
|
|
409
|
+
{/* On a top-level workflow's page, the other top-level workflows: each a top of its own, never this one. */}
|
|
410
|
+
{level.crumbs.length !== 1 || others.length === 0 ? null : (
|
|
411
|
+
<p className="wp-line wp-others">Other top-level workflows: {others.map((name, i) => <Fragment key={name}>{i === 0 ? '' : ', '}<a href={hrefOf(name === data.view.top.name ? [] : [name])}>{name}</a></Fragment>)}</p>
|
|
412
|
+
)}
|
|
363
413
|
<p className="wp-line">{level.description}</p>
|
|
414
|
+
{w === null || !w.system ? null : <p className="wp-line">{SYSTEM_WORKFLOW_WORDS}</p>}
|
|
364
415
|
{w === null ? null : <p className="wp-line wp-mut">{startsLine(w)}</p>}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
416
|
+
<Section name="Tasks">
|
|
417
|
+
{w === null ? <p className="wp-line wp-mut">It is not declared, so it records nothing.</p> : (
|
|
418
|
+
<>
|
|
419
|
+
{/* Its own tasks; or, run as a step of another, that workflow's tasks passing through it, the bar its box shows there. */}
|
|
420
|
+
{tasksShownOf(w, workflowOf) !== null ? <Tasks workflow={w} workflowOf={workflowOf} /> : withFigures((f) => f.passingThrough.length === 0 ? <Tasks workflow={w} workflowOf={workflowOf} /> : f.passingThrough.map((p) => (
|
|
421
|
+
<div key={`${p.workflow}>${p.step}`} className="wp-passing">
|
|
422
|
+
<p className="wp-line">{p.workflow}'s tasks at its step {p.step}, last {f.hours} h:</p>
|
|
423
|
+
{p.cost === null ? <p className="wp-line wp-mut">None reached it.</p> : <CallsBar cost={p.cost} hours={f.hours} />}
|
|
424
|
+
</div>
|
|
425
|
+
)))}
|
|
426
|
+
</>
|
|
427
|
+
)}
|
|
428
|
+
</Section>
|
|
429
|
+
<Section name="Runs">
|
|
430
|
+
{w === null ? <p className="wp-line wp-mut">It is not declared, so it has no runs.</p> : <RunsLines workflow={w} runs={runsOf(w.name)} />}
|
|
431
|
+
</Section>
|
|
432
|
+
<Section name="Limits">
|
|
433
|
+
{w === null ? <p className="wp-line wp-mut">It is not declared, so it has no limits.</p> : <LimitLines workflow={w} setLimit={setLimit} setSetting={setSetting} />}
|
|
434
|
+
</Section>
|
|
435
|
+
<Section name="Steps">
|
|
436
|
+
{level.steps.length === 0 ? <p className="wp-line wp-mut">It declares no steps.</p> : withFigures((f) => (
|
|
437
|
+
<>
|
|
438
|
+
<WorkflowDag graph={f.graph} box={box(f)} />
|
|
439
|
+
<p className="wp-line wp-mut">{totalLine(f, w?.usesAgents ?? false)}</p>
|
|
440
|
+
{f.steps.every((s) => s.declared) ? null : (
|
|
441
|
+
<p className="wp-line wp-bad">Named by its records, no longer declared: {f.steps.filter((s) => !s.declared).map((s) => `${s.name} (${s.cost?.calls ?? 0} calls)`).join('; ')}</p>
|
|
442
|
+
)}
|
|
443
|
+
</>
|
|
444
|
+
))}
|
|
445
|
+
</Section>
|
|
446
|
+
<Section name="Tasks over time">
|
|
447
|
+
{/* The workflow opened and every workflow under it, at any depth. */}
|
|
448
|
+
<QueueChart view={data.view} level={path.join('/')} rowWord="workflow" workflows={w === null ? [] : workflowsUnder(data.view, w.name)} />
|
|
449
|
+
</Section>
|
|
450
|
+
<Section name="Blocked, by reason">
|
|
451
|
+
{withFigures((f) => f.blocked.length === 0 ? <p className="wp-line wp-mut">None of its tasks is blocked.</p> : (
|
|
452
|
+
<table className="wp-reasons">
|
|
453
|
+
<tbody>{f.blocked.map((b) => <tr key={b.why}><td className="wp-r">{b.tasks.toLocaleString('en-US')}</td><td>{b.why}</td></tr>)}</tbody>
|
|
454
|
+
</table>
|
|
455
|
+
))}
|
|
456
|
+
</Section>
|
|
457
|
+
<Section name="Queued, needing an agent">
|
|
458
|
+
{withFigures((f) => f.needingAnAgent.reasons.length === 0 ? <p className="wp-line wp-mut">None of its queued tasks needs an agent.</p> : (
|
|
459
|
+
<>
|
|
460
|
+
<p className={f.needingAnAgent.passedOverBecause === null ? 'wp-line' : 'wp-line wp-bad'}>{needingAnAgentLine(f.needingAnAgent.passedOverBecause)}</p>
|
|
461
|
+
<table className="wp-reasons">
|
|
462
|
+
<tbody>{f.needingAnAgent.reasons.map((b) => <tr key={b.why}><td className="wp-r">{b.tasks.toLocaleString('en-US')}</td><td>{b.why}</td></tr>)}</tbody>
|
|
463
|
+
</table>
|
|
464
|
+
</>
|
|
465
|
+
))}
|
|
466
|
+
</Section>
|
|
467
|
+
<Section name="What its runs gave">
|
|
468
|
+
{withFigures((f) => (
|
|
469
|
+
<>
|
|
470
|
+
<p className="wp-line wp-mut">Its figures over the last {f.hours} h, read {whenAgo(f.at, now)}.</p>
|
|
471
|
+
<p className="wp-line">{yieldLine(f, w?.finishedWord ?? null)}</p>
|
|
472
|
+
<p className="wp-line">{runCostLine(f)}</p>
|
|
473
|
+
</>
|
|
474
|
+
))}
|
|
475
|
+
</Section>
|
|
476
|
+
<Section name="Where runs stopped">{withFigures((f) => <FunnelTable funnel={f.funnel} />)}</Section>
|
|
477
|
+
{/* On an app's top-level page, the platform's own workflows, apart from the app's: like the other top-level
|
|
478
|
+
workflows' line, no section of the workflow's own page, so every workflow's page keeps the same sections. */}
|
|
479
|
+
{level.crumbs.length !== 1 || w?.system === true || data.view.system.length === 0 ? null : (
|
|
480
|
+
<div className="wp-section" data-platform-workflows="">
|
|
481
|
+
<h3 className="wp-h3">Platform workflows</h3>
|
|
482
|
+
<PlatformWorkflows workflows={data.view.system.flatMap((name) => all.filter((x) => x.name === name))} runsOf={runsOf} hrefOf={hrefOf} setLimit={setLimit} setSetting={setSetting} />
|
|
483
|
+
</div>
|
|
377
484
|
)}
|
|
378
|
-
<h3 className="wp-h3">Steps</h3>
|
|
379
|
-
<StepList
|
|
380
|
-
steps={level.steps} path={level.crumbs[level.crumbs.length - 1]!.path} hrefOf={hrefOf} workflowOf={workflowOf} runsOf={runsOf} runs={runs}
|
|
381
|
-
{...(w === null ? { groupKey: (s: StepSummary) => stageOf(s.workflow), groupOf: (s: StepSummary) => { const stage = stageOf(s.workflow); return stage === null ? null : phaseLabel(stage); } } : {})}
|
|
382
|
-
/>
|
|
383
|
-
{w === null ? null : <WorkflowDetail workflow={w} runs={runs} now={now} figuresUrl={figuresUrl} hrefOfWorkflow={(name) => hrefOf([...level.crumbs[level.crumbs.length - 1]!.path, name])} />}
|
|
384
485
|
</section>
|
|
385
486
|
);
|
|
386
487
|
}
|
|
387
488
|
|
|
388
|
-
|
|
489
|
+
/** How often an open workflow's figures are read again. */
|
|
490
|
+
const FIGURES_EVERY_MS = 15_000;
|
|
491
|
+
|
|
492
|
+
/** How often an open workflow's step times are read again: they change as tasks leave steps, a minute is soon enough. */
|
|
493
|
+
const TIMES_EVERY_MS = 60_000;
|
|
494
|
+
|
|
495
|
+
/** The opened workflow's figures, read from its own records while it is open, and its steps' times where the project gives them. */
|
|
496
|
+
function PolledWorkflowPage(props: Omit<WorkflowPageProps, 'figures' | 'times'> & { readonly figuresUrl: (workflow: string) => string; readonly timesUrl: ((workflow: string) => string) | undefined }) {
|
|
497
|
+
const opened = drillLevel(props.data.view, props.path).name;
|
|
498
|
+
const figures = usePolledJson<WorkflowFigures>(props.figuresUrl(opened), FIGURES_EVERY_MS);
|
|
499
|
+
const times = usePolledJson<StepTimes>(props.timesUrl === undefined ? null : props.timesUrl(opened), TIMES_EVERY_MS);
|
|
500
|
+
// Times of the workflow opened before this one are never shown under this one's name.
|
|
501
|
+
const own = times.data !== null && times.data.workflow === opened ? times : { data: null, error: times.error };
|
|
502
|
+
return <WorkflowPage {...props} figures={figures} {...(props.timesUrl === undefined ? {} : { times: own })} />;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
export function WorkflowsDashboard({ data, error, figuresUrl, timesUrl, sourceHref, header, setLimit, setSetting, setCpuLimit, stopEverything, resume, setSpendingLimit, path, hrefOf }: WorkflowsDashboardProps) {
|
|
389
506
|
const now = Date.now() / 1000;
|
|
390
|
-
const atTheTop = path.length === 0;
|
|
391
507
|
return (
|
|
392
508
|
<div className="wp-page">
|
|
393
509
|
{header}
|
|
394
510
|
<p className={error === null ? 'wp-line wp-mut' : 'wp-line wp-bad'}>
|
|
395
511
|
{error !== null ? `The workflows could not be read: ${error}` : data === null ? 'Reading the workflows…' : `Read from the records ${whenAgo(data.view.at, now)}.`}
|
|
396
512
|
</p>
|
|
397
|
-
{
|
|
398
|
-
{
|
|
399
|
-
{data === null || data.view.spending === null ? null : (
|
|
400
|
-
<SpendingLimitControl spending={data.view.spending} held={heldSteps(data.runsNow)} now={now} {...(setSpendingLimit === undefined ? {} : { setSpendingLimit })} />
|
|
401
|
-
)}
|
|
402
|
-
{/* Nothing a level decides is drawn before the first read: a server draws one page for every level's address. */}
|
|
403
|
-
{data === null || !atTheTop ? null : (
|
|
513
|
+
{/* What the project gives of its machine and its agents' account: the same on every page. Nothing is drawn before the first read. */}
|
|
514
|
+
{data === null ? null : (
|
|
404
515
|
<>
|
|
516
|
+
<p className={data.cpu.use !== null && data.cpu.use.cores > data.cpu.limit ? 'wp-line wp-bad' : 'wp-line'}>{cpuLine(data.cpu, now)}</p>
|
|
517
|
+
{data.view.spending === null ? null : (
|
|
518
|
+
<SpendingLimitControl spending={data.view.spending} now={now} {...(setSpendingLimit === undefined ? {} : { setSpendingLimit })} />
|
|
519
|
+
)}
|
|
405
520
|
<MachineControls cpu={data.cpu} stopped={data.stopped ?? null} now={now} {...(setCpuLimit === undefined ? {} : { setCpuLimit })} {...(stopEverything === undefined ? {} : { stopEverything })} {...(resume === undefined ? {} : { resume })} />
|
|
406
521
|
{data.usage === undefined ? null : <AgentUsageLine usage={data.usage} now={now} />}
|
|
522
|
+
{/* The app's own retention settings, above every workflow's: the same on every page. */}
|
|
523
|
+
<div className="wp-app-settings" data-app-settings="">
|
|
524
|
+
<p className="wp-line">The app's records, for every workflow that sets none of its own:</p>
|
|
525
|
+
<RetentionLines level={{ kind: 'app' }} settings={data.view.appRetention} setSetting={setSetting} />
|
|
526
|
+
</div>
|
|
527
|
+
<PolledWorkflowPage data={data} path={path} hrefOf={hrefOf} now={now} figuresUrl={figuresUrl} timesUrl={timesUrl} sourceHref={sourceHref} setLimit={setLimit} setSetting={setSetting} />
|
|
407
528
|
</>
|
|
408
529
|
)}
|
|
409
|
-
{data === null ? null : (
|
|
410
|
-
<DrillLevelView data={data} path={path} hrefOf={hrefOf} now={now} figuresUrl={figuresUrl} sourceHref={sourceHref} phaseLabel={(phase) => (phaseLabel === undefined ? phase : phaseLabel(phase))} setLimit={setLimit} />
|
|
411
|
-
)}
|
|
412
530
|
</div>
|
|
413
531
|
);
|
|
414
532
|
}
|