@jive-sh/workflow-platform 0.7.0 → 1.1.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 +70 -435
- package/component/_generated/api.ts +72 -0
- package/component/_generated/component.ts +629 -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 +756 -0
- package/component/errors.ts +66 -0
- package/component/events.ts +17 -0
- package/component/notes.ts +19 -0
- package/component/places.ts +136 -0
- package/component/retention.ts +205 -0
- package/component/runEngine.ts +25 -0
- package/component/schema.ts +135 -0
- package/component/steps.ts +188 -0
- package/component/store.ts +513 -0
- package/component/tasks.ts +290 -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 +117 -0
- package/dist/definition/workflow.js.map +1 -0
- package/dist/graph.js +310 -9
- package/dist/graph.js.map +1 -1
- package/dist/index.js +7 -196
- 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 +262 -0
- package/src/graph.ts +352 -19
- package/src/index.ts +8 -238
- package/worker/directory-file-store.ts +42 -0
- package/worker/index.ts +12 -0
- package/worker/platform-client.ts +144 -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 -148
- package/dist/dashboard/drilldown.js +0 -47
- 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/run-doing-words.js +0 -29
- package/dist/dashboard/run-doing-words.js.map +0 -1
- package/dist/dashboard/setting-words.js +0 -18
- package/dist/dashboard/setting-words.js.map +0 -1
- package/dist/dashboard/spending-words.js +0 -24
- 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 -79
- 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/retention.js +0 -59
- package/dist/retention.js.map +0 -1
- package/dist/settings.js +0 -88
- package/dist/settings.js.map +0 -1
- package/dist/spending-limit.js +0 -82
- 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-times.js +0 -114
- package/dist/step-times.js.map +0 -1
- package/dist/step-usage.js +0 -19
- package/dist/step-usage.js.map +0 -1
- package/dist/steps.js +0 -1205
- package/dist/steps.js.map +0 -1
- package/dist/storage/agent-claims.js +0 -3
- package/dist/storage/agent-claims.js.map +0 -1
- package/dist/storage/budgets.js +0 -121
- package/dist/storage/budgets.js.map +0 -1
- package/dist/storage/engine-records.js +0 -91
- 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 -901
- 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 -30
- package/dist/storage/task-store.js.map +0 -1
- package/dist/system-workflows.js +0 -54
- package/dist/system-workflows.js.map +0 -1
- package/dist/tasks.js +0 -500
- 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 -117
- 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 -39
- package/dist/views/step-graph.js.map +0 -1
- package/dist/views/workflows-view.js +0 -236
- package/dist/views/workflows-view.js.map +0 -1
- package/src/budget-states.ts +0 -54
- 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 -148
- package/src/dashboard/drilldown.ts +0 -70
- package/src/dashboard/index.tsx +0 -4
- package/src/dashboard/limits-and-runs.tsx +0 -191
- package/src/dashboard/machine-controls.tsx +0 -53
- package/src/dashboard/queue-bar.tsx +0 -62
- package/src/dashboard/queue-chart.tsx +0 -149
- package/src/dashboard/queue-lines.ts +0 -87
- package/src/dashboard/queue-table.ts +0 -37
- package/src/dashboard/run-doing-words.ts +0 -41
- package/src/dashboard/setting-words.ts +0 -30
- package/src/dashboard/spending-limit-control.tsx +0 -47
- package/src/dashboard/spending-words.ts +0 -32
- package/src/dashboard/time-distribution.tsx +0 -61
- package/src/dashboard/workflow-dag.tsx +0 -322
- package/src/dashboard/workflow-drilldown.tsx +0 -31
- package/src/dashboard/workflows-dashboard.tsx +0 -532
- package/src/failure.ts +0 -36
- package/src/keep-running.ts +0 -85
- package/src/outside-failure.ts +0 -39
- package/src/pick-wakes.ts +0 -182
- package/src/project.ts +0 -127
- package/src/queue-counts.ts +0 -64
- package/src/reasons.ts +0 -30
- package/src/retention.ts +0 -90
- package/src/settings.ts +0 -171
- package/src/spending-limit.ts +0 -139
- package/src/step-files.ts +0 -208
- package/src/step-meter.ts +0 -120
- package/src/step-times.ts +0 -151
- package/src/step-usage.ts +0 -23
- package/src/steps.ts +0 -1616
- package/src/storage/agent-claims.ts +0 -63
- package/src/storage/budgets.ts +0 -152
- package/src/storage/engine-records.ts +0 -119
- 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 -1022
- package/src/storage/step-records.ts +0 -358
- package/src/storage/storage-error.ts +0 -35
- package/src/storage/task-store.ts +0 -235
- package/src/system-workflows.ts +0 -70
- package/src/tasks.ts +0 -586
- package/src/views/format.ts +0 -40
- package/src/views/runs-now.ts +0 -188
- package/src/views/step-funnel.ts +0 -163
- package/src/views/step-graph.ts +0 -77
- package/src/views/workflows-view.ts +0 -484
- package/src/workflow-dag.test.tsx +0 -89
- package/src/workflow-page.test.tsx +0 -170
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A STEP'S INHERITED SETTINGS IN THE WORDS ITS BOX SHOWS (`settings.ts`): the value, and where it is set, so nothing about
|
|
3
|
-
* either is told by colour or by position alone. "keeps 7 days, at least 10,000 runs (set on the app)", "keeps 30 days (set on
|
|
4
|
-
* this step), at least 10,000 runs (set on the app)", "model claude-opus-5-5 (set on this step)". Pure, with no React, so a
|
|
5
|
-
* test reads it without a page.
|
|
6
|
-
*/
|
|
7
|
-
import type { Effective, SetOn } from '../settings';
|
|
8
|
-
|
|
9
|
-
/** Where a setting is set, in words, as the box of step `here.step` on `here.workflow`'s page says it. Pure. */
|
|
10
|
-
export const setOnWords = (setOn: SetOn, here: { readonly workflow: string; readonly step: string | null }): string =>
|
|
11
|
-
setOn.kind === 'platform default' ? "the platform's default"
|
|
12
|
-
: setOn.kind === 'app' ? 'set on the app'
|
|
13
|
-
: setOn.kind === 'workflow' ? (here.step === null && setOn.workflow === here.workflow ? 'set on this workflow' : `set on ${setOn.workflow}`)
|
|
14
|
-
: setOn.workflow === here.workflow && setOn.step === here.step ? 'set on this step'
|
|
15
|
-
: `set on its step ${setOn.step} in ${setOn.workflow}`;
|
|
16
|
-
|
|
17
|
-
const plural = (n: number, one: string, many: string) => `${n.toLocaleString('en-US')} ${n === 1 ? one : many}`;
|
|
18
|
-
|
|
19
|
-
/** How long a step's records are kept and the fewest of its runs kept however old, and where each is set: once where both are set in one place. Pure. */
|
|
20
|
-
export const retentionWords = (kept: { readonly days: Effective<number>; readonly atLeastRuns: Effective<number> }, here: { readonly workflow: string; readonly step: string | null }): string => {
|
|
21
|
-
const days = `keeps ${plural(kept.days.value, 'day', 'days')}`;
|
|
22
|
-
const runs = `at least ${plural(kept.atLeastRuns.value, 'run', 'runs')}`;
|
|
23
|
-
const daysOn = setOnWords(kept.days.setOn, here);
|
|
24
|
-
const runsOn = setOnWords(kept.atLeastRuns.setOn, here);
|
|
25
|
-
return daysOn === runsOn ? `${days}, ${runs} (${daysOn})` : `${days} (${daysOn}), ${runs} (${runsOn})`;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
/** The model a step's agents run on, and where that is set; none set says so, since such a step fails before its agent. Pure. */
|
|
29
|
-
export const modelWords = (model: Effective<string | null>, here: { readonly workflow: string; readonly step: string | null }): string =>
|
|
30
|
-
model.value === null ? `no model set (${setOnWords(model.setOn, here)}): its agent steps fail until one is` : `model ${model.value} (${setOnWords(model.setOn, here)})`;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* THE SPENDING LIMIT ON THE PAGE (`spending-limit.ts`): what it is set to with − and +, the week's reading against it, whether
|
|
5
|
-
* it withholds every agent, and whether the reading is stale, each in words (`spending-words.ts`). A click shows at once, as
|
|
6
|
-
* asked, until the page's next reading says the same; a failed one says why.
|
|
7
|
-
*/
|
|
8
|
-
import { useEffect, useState } from 'react';
|
|
9
|
-
import type { SpendingLimitState } from '../spending-limit';
|
|
10
|
-
import { spendingSettingWords, spendingStaleWords, spendingVerdictWords } from './spending-words';
|
|
11
|
-
|
|
12
|
-
export interface SpendingLimitControlProps {
|
|
13
|
-
readonly spending: SpendingLimitState;
|
|
14
|
-
readonly now: number;
|
|
15
|
-
/** Stores a new limit, a whole percent from 0 to 100; with none the limit shows without buttons. */
|
|
16
|
-
readonly setSpendingLimit?: (weekPercent: number) => Promise<void>;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const WHY = 'While the newest good reading of the week is at or past this percent, no run of any workflow is given an agent, and a run holding one ends before its next agent call, its task back in its queue. A failed or late reading never lifts it.';
|
|
20
|
-
|
|
21
|
-
export function SpendingLimitControl({ spending, now, setSpendingLimit }: SpendingLimitControlProps) {
|
|
22
|
-
const [asked, setAsked] = useState<number | null>(null);
|
|
23
|
-
const [failed, setFailed] = useState<string | null>(null);
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
if (asked !== null && asked === spending.limitPercent && spending.setAt !== null) setAsked(null);
|
|
26
|
-
}, [asked, spending.limitPercent, spending.setAt]);
|
|
27
|
-
const shown = asked === null ? spending.limitPercent : asked;
|
|
28
|
-
const set = (to: number) => {
|
|
29
|
-
if (setSpendingLimit === undefined) return;
|
|
30
|
-
setAsked(to);
|
|
31
|
-
setFailed(null);
|
|
32
|
-
setSpendingLimit(to).catch((e: unknown) => { setAsked(null); setFailed(e instanceof Error ? e.message : String(e)); });
|
|
33
|
-
};
|
|
34
|
-
const stale = spendingStaleWords(spending, now);
|
|
35
|
-
return (
|
|
36
|
-
<div className="wp-spending">
|
|
37
|
-
<span className="wp-limit" title={WHY}>
|
|
38
|
-
{setSpendingLimit === undefined ? null : <button type="button" aria-label="Lower the spending limit" disabled={shown <= 0} onClick={() => set(shown - 1)}>−</button>}
|
|
39
|
-
<span>{spendingSettingWords({ limitPercent: shown, setAt: asked === null ? spending.setAt : now })}</span>
|
|
40
|
-
{setSpendingLimit === undefined ? null : <button type="button" aria-label="Raise the spending limit" disabled={shown >= 100} onClick={() => set(shown + 1)}>+</button>}
|
|
41
|
-
{failed === null ? null : <span className="wp-bad">not saved: {failed}</span>}
|
|
42
|
-
</span>
|
|
43
|
-
<p className={spending.holds ? 'wp-line wp-bad' : 'wp-line'}>{spendingVerdictWords(spending, now)}</p>
|
|
44
|
-
{stale === null ? null : <p className="wp-line wp-bad">{stale}</p>}
|
|
45
|
-
</div>
|
|
46
|
-
);
|
|
47
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* THE SPENDING LIMIT IN WORDS (`spending-limit.ts`): what it is set to, the week's reading against it, and whether it holds.
|
|
3
|
-
* Each state is said in words, first in its line; a colour on the page only repeats it. Pure, with no React and no JSX, so a
|
|
4
|
-
* test reads it without a page.
|
|
5
|
-
*/
|
|
6
|
-
import type { SpendingLimitState } from '../spending-limit';
|
|
7
|
-
import { percentCut, whenAgo } from '../views/format';
|
|
8
|
-
|
|
9
|
-
/** What the limit is set to: "agents stop at 95% of the week (the default)". */
|
|
10
|
-
export const spendingSettingWords = (s: Pick<SpendingLimitState, 'limitPercent' | 'setAt'>): string =>
|
|
11
|
-
`Spending limit: agents stop at ${s.limitPercent}% of the week${s.setAt === null ? ' (the default)' : ''}`;
|
|
12
|
-
|
|
13
|
-
/** The week's reading against the limit, and whether it withholds every agent. */
|
|
14
|
-
export const spendingVerdictWords = (s: SpendingLimitState, now: number): string => {
|
|
15
|
-
if (s.reading === null) {
|
|
16
|
-
return s.failedSince === null
|
|
17
|
-
? "Holds nothing: there is no reading of the week's use yet."
|
|
18
|
-
: `Holds nothing: there is no good reading of the week's use yet; the newest read failed at ${whenAgo(s.failedSince.at, now)}: ${s.failedSince.error}`;
|
|
19
|
-
}
|
|
20
|
-
const reading = `the week's use is ${percentCut(s.reading.usedPercent)}, read ${whenAgo(s.reading.readAt, now)}`;
|
|
21
|
-
return s.holds
|
|
22
|
-
? `Withholding every agent: ${reading}, at or past the limit. No run is given one, and a run holding one ends before its next agent call, its task back in its queue, until a reading is below ${s.limitPercent}%.`
|
|
23
|
-
: `Holds nothing: ${reading}, below the limit.`;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/** Why the reading is stale and what the limit does meanwhile; none while it is current. */
|
|
27
|
-
export const spendingStaleWords = (s: SpendingLimitState, now: number): string | null => {
|
|
28
|
-
if (!s.stale) return null;
|
|
29
|
-
return s.failedSince === null
|
|
30
|
-
? "The reading is stale: none came since. The limit keeps that reading's verdict until a new one."
|
|
31
|
-
: `The reading is stale: the newest read failed at ${whenAgo(s.failedSince.at, now)} (${s.failedSince.error}). The limit keeps the last good reading's verdict until a read succeeds.`;
|
|
32
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ONE STEP'S TIME DISTRIBUTION, AS A CONTINUOUS BAR GRAPH (`step-times.ts`). Alex, 2026-11-21: "one point is (time taken,
|
|
5
|
-
* number of tasks with that time taken). a distribution is a continuous bar graph"; the axis "linear".
|
|
6
|
-
*
|
|
7
|
-
* x is time taken, linear from 0 to the slowest task's time; y is how many tasks took that time. One bar per pixel column of
|
|
8
|
-
* the chart, edge to edge: the finest the screen can show, so nothing visible is lost; no smoothing and no fitted curve. n,
|
|
9
|
-
* the median and the 90th percentile are said in words, computed from every value, and the median and the 90th percentile
|
|
10
|
-
* are marked on the x axis by shapes the words name (▲ and ◆), never by colour.
|
|
11
|
-
*/
|
|
12
|
-
import { duration } from '../views/format';
|
|
13
|
-
|
|
14
|
-
/** The chart's width in px: a step box's inner width (`dashboard.css` `.wp-node`), one bar per pixel column of it. */
|
|
15
|
-
export const CHART_WIDTH = 230;
|
|
16
|
-
const BARS_HEIGHT = 44;
|
|
17
|
-
|
|
18
|
-
/** A time in words, to a tenth of a second under 10 s: "0.4 s", "42 s", "3 min 5 s". */
|
|
19
|
-
export const timeWords = (seconds: number): string => (seconds < 10 ? `${(Math.round(seconds * 10) / 10).toFixed(1)} s` : duration(seconds));
|
|
20
|
-
|
|
21
|
-
/** The value at fraction `q` of sorted `values` (the nearest rank: no value is invented between two). Pure. */
|
|
22
|
-
export const quantile = (sorted: ReadonlyArray<number>, q: number): number =>
|
|
23
|
-
sorted.length === 0 ? 0 : sorted[Math.min(sorted.length - 1, Math.max(0, Math.ceil(q * sorted.length) - 1))]!;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* THE BARS: how many values fall in each of `columns` equal slices of 0 to the largest value, the slowest in the last. Every
|
|
27
|
-
* value is counted in exactly one. Pure.
|
|
28
|
-
*/
|
|
29
|
-
export const barCounts = (values: ReadonlyArray<number>, columns: number): ReadonlyArray<number> => {
|
|
30
|
-
const counts = new Array<number>(columns).fill(0);
|
|
31
|
-
const slowest = values.reduce((m, v) => Math.max(m, v), 0);
|
|
32
|
-
for (const v of values) counts[slowest === 0 ? 0 : Math.min(columns - 1, Math.floor((v / slowest) * columns))]! += 1;
|
|
33
|
-
return counts;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export function TimeDistribution({ values }: { readonly values: ReadonlyArray<number> }) {
|
|
37
|
-
const sorted = [...values].sort((a, b) => a - b);
|
|
38
|
-
const slowest = sorted[sorted.length - 1] ?? 0;
|
|
39
|
-
const counts = barCounts(sorted, CHART_WIDTH);
|
|
40
|
-
const most = Math.max(1, ...counts);
|
|
41
|
-
const median = quantile(sorted, 0.5);
|
|
42
|
-
const p90 = quantile(sorted, 0.9);
|
|
43
|
-
const x = (v: number) => (slowest === 0 ? 0 : Math.min(CHART_WIDTH - 1, Math.floor((v / slowest) * CHART_WIDTH)) + 0.5);
|
|
44
|
-
const said = `${sorted.length.toLocaleString('en-US')} tasks, median ${timeWords(median)}, 90th percentile ${timeWords(p90)}, slowest ${timeWords(slowest)}`;
|
|
45
|
-
return (
|
|
46
|
-
<figure className="wp-times" aria-label={`Time taken: ${said}`}>
|
|
47
|
-
<p className="wp-times-words">n {sorted.length.toLocaleString('en-US')} · ▲ median {timeWords(median)}</p>
|
|
48
|
-
<p className="wp-times-words">◆ p90 {timeWords(p90)}</p>
|
|
49
|
-
<svg width={CHART_WIDTH} height={BARS_HEIGHT + 26} role="img" aria-hidden="true">
|
|
50
|
-
{counts.map((n, i) => (n === 0 ? null : <rect key={i} x={i} y={BARS_HEIGHT - (n / most) * BARS_HEIGHT} width={1} height={(n / most) * BARS_HEIGHT} fill="var(--wp-fg)" />))}
|
|
51
|
-
<line x1={0} x2={CHART_WIDTH} y1={BARS_HEIGHT + 0.5} y2={BARS_HEIGHT + 0.5} stroke="var(--wp-dim)" strokeWidth="1" />
|
|
52
|
-
<path d={`M${x(median)},${BARS_HEIGHT + 2} l4,7 h-8 z`} fill="var(--wp-fg)" />
|
|
53
|
-
<path d={`M${x(p90)},${BARS_HEIGHT + 2} l4,4 l-4,4 l-4,-4 z`} fill="none" stroke="var(--wp-fg)" strokeWidth="1.2" />
|
|
54
|
-
<text x={0} y={BARS_HEIGHT + 22} fontSize="9.5" fill="var(--wp-dim)">0</text>
|
|
55
|
-
<text x={CHART_WIDTH / 2} y={BARS_HEIGHT + 22} fontSize="9.5" fill="var(--wp-dim)" textAnchor="middle">{timeWords(slowest / 2)}</text>
|
|
56
|
-
<text x={CHART_WIDTH} y={BARS_HEIGHT + 22} fontSize="9.5" fill="var(--wp-dim)" textAnchor="end">{timeWords(slowest)}</text>
|
|
57
|
-
</svg>
|
|
58
|
-
<figcaption className="wp-times-axis">across: time taken · up: tasks</figcaption>
|
|
59
|
-
</figure>
|
|
60
|
-
);
|
|
61
|
-
}
|
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ONE WORKFLOW'S STEPS AS A DAG, the one drawing of a workflow at every depth, the top included: each step a box with its
|
|
5
|
-
* name as its heading, the run's start and end small boxes of their own, laid out by ELK's layered algorithm (`elkjs`, which
|
|
6
|
-
* the host page brings, as it brings React) so every forward arrow points down. Edges are routed orthogonally around the
|
|
7
|
-
* boxes, each with its condition and the window's runs beside its own line and its arrowhead at its target; an edge back to
|
|
8
|
-
* an earlier step is routed apart by ELK as a feedback edge, dashed. What a box shows under its heading is the page's
|
|
9
|
-
* (`WorkflowsDashboard`): a step that is a workflow, that workflow's tasks, runs and limits; any other, its own calls.
|
|
10
|
-
*
|
|
11
|
-
* The graph is the workflow's declared one, or for a workflow that declares none its steps in their declared order
|
|
12
|
-
* (`views/step-graph.ts` `inOrder`), so every workflow has one.
|
|
13
|
-
*
|
|
14
|
-
* Steps that feed no other step and that no step feeds, two or more whose lines from the run's start and to its end read
|
|
15
|
-
* the same, are drawn in a grid under the graph with those lines said once in words (`standAloneSteps`): Upkeep's 26 such
|
|
16
|
-
* steps drew 52 lines that all said "on its own trigger" and "what it finishes leaves here", in a row 6,146 px wide.
|
|
17
|
-
*
|
|
18
|
-
* Chosen over dagre (`@dagrejs/dagre`): ELK routes edges around nodes and places labels beside their own edges, and routes
|
|
19
|
-
* feedback edges apart; dagre does none of those, and its edges and labels cross nodes.
|
|
20
|
-
*/
|
|
21
|
-
import ELK, { type ElkNode } from 'elkjs/lib/elk.bundled.js';
|
|
22
|
-
import { useEffect, useLayoutEffect, useRef, useState, type CSSProperties, type ReactNode } from 'react';
|
|
23
|
-
import { A_STEP_FAILS, RUN_ENDS, RUN_STARTS } from '../graph';
|
|
24
|
-
import type { GraphEdge, WorkflowGraph } from '../views/step-graph';
|
|
25
|
-
|
|
26
|
-
/** A step box's width; an end's; each box's height is measured from what it shows. */
|
|
27
|
-
const NODE_WIDTH = 250;
|
|
28
|
-
const END_WIDTH = 96;
|
|
29
|
-
const LABEL_LINE = 13;
|
|
30
|
-
/** An edge label's lines are wrapped at this many characters, so a long condition stays beside its own line. */
|
|
31
|
-
const LABEL_CHARS = 22;
|
|
32
|
-
const charWidth = 6.1;
|
|
33
|
-
|
|
34
|
-
const isEnd = (name: string) => name === RUN_STARTS || name === RUN_ENDS || name === A_STEP_FAILS;
|
|
35
|
-
|
|
36
|
-
/** An edge's label: its condition and how many runs took it in the window, wrapped into lines; none with neither. Pure. */
|
|
37
|
-
export const edgeLabelLines = (e: Pick<GraphEdge, 'when' | 'runs'>): ReadonlyArray<string> => {
|
|
38
|
-
const text = [e.when, e.runs === 0 ? '' : `${e.runs.toLocaleString('en-US')} run${e.runs === 1 ? '' : 's'}`].filter((t) => t !== '').join(' · ');
|
|
39
|
-
const lines: string[] = [];
|
|
40
|
-
for (const word of text.split(' ').filter((w) => w !== '')) {
|
|
41
|
-
const last = lines[lines.length - 1];
|
|
42
|
-
if (last !== undefined && last.length + 1 + word.length <= LABEL_CHARS) lines[lines.length - 1] = `${last} ${word}`;
|
|
43
|
-
else lines.push(word);
|
|
44
|
-
}
|
|
45
|
-
return lines;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* The boxes a graph draws, in the order ELK is given them, which decides which edges go against the flow: the run's start,
|
|
50
|
-
* then each step by how few edges reach it from the start (ties, and steps no edge reaches, in their declared order), then
|
|
51
|
-
* the ends. In declared order alone, Decompile's Pick, declared before the claim step every run takes first, was drawn above
|
|
52
|
-
* the run's start. Pure.
|
|
53
|
-
*/
|
|
54
|
-
export const graphBoxes = (graph: Pick<WorkflowGraph, 'steps' | 'edges'>): ReadonlyArray<string> => {
|
|
55
|
-
const names = graph.steps.map((s) => s.name);
|
|
56
|
-
const depth = new Map<string, number>([[RUN_STARTS, 0]]);
|
|
57
|
-
for (let frontier = [RUN_STARTS], d = 1; frontier.length > 0; d += 1) {
|
|
58
|
-
frontier = graph.edges.filter((e) => frontier.includes(e.from) && !depth.has(e.to)).map((e) => e.to);
|
|
59
|
-
for (const to of frontier) depth.set(to, d);
|
|
60
|
-
}
|
|
61
|
-
const byFlow = [...names].sort((a, b) => (depth.get(a) ?? Infinity) - (depth.get(b) ?? Infinity) || names.indexOf(a) - names.indexOf(b));
|
|
62
|
-
return [RUN_STARTS, ...(graph.edges.some((e) => e.from === A_STEP_FAILS) ? [A_STEP_FAILS] : []), ...byFlow, RUN_ENDS];
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
/** Steps drawn in a grid without lines: each one's only lines are one from the run's start and one to its end, labelled as given. */
|
|
66
|
-
export interface StandAloneSteps {
|
|
67
|
-
readonly steps: ReadonlyArray<string>;
|
|
68
|
-
readonly into: ReadonlyArray<string>;
|
|
69
|
-
readonly outOf: ReadonlyArray<string>;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* A graph's steps that feed no other step and that no step feeds, grouped by the labels of their two lines, each group of
|
|
74
|
-
* two or more to be drawn in a grid; and the graph left to lay out, without them. A step on its own keeps its lines, and so
|
|
75
|
-
* does one whose lines read differently from every other's (Repair names' two steps, each with its own condition). Pure.
|
|
76
|
-
*/
|
|
77
|
-
export const standAloneSteps = (graph: Pick<WorkflowGraph, 'steps' | 'edges'>): { readonly grids: ReadonlyArray<StandAloneSteps>; readonly drawn: Pick<WorkflowGraph, 'steps' | 'edges'> } => {
|
|
78
|
-
const groups = new Map<string, { readonly steps: string[]; readonly into: ReadonlyArray<string>; readonly outOf: ReadonlyArray<string> }>();
|
|
79
|
-
for (const { name } of graph.steps) {
|
|
80
|
-
const touching = graph.edges.filter((e) => e.from === name || e.to === name);
|
|
81
|
-
const into = touching.find((e) => e.from === RUN_STARTS);
|
|
82
|
-
const outOf = touching.find((e) => e.to === RUN_ENDS);
|
|
83
|
-
if (touching.length !== 2 || into === undefined || outOf === undefined) continue;
|
|
84
|
-
const labels = { into: edgeLabelLines(into), outOf: edgeLabelLines(outOf) };
|
|
85
|
-
const key = JSON.stringify(labels);
|
|
86
|
-
const group = groups.get(key);
|
|
87
|
-
if (group === undefined) groups.set(key, { steps: [name], ...labels });
|
|
88
|
-
else group.steps.push(name);
|
|
89
|
-
}
|
|
90
|
-
const grids = [...groups.values()].filter((g) => g.steps.length >= 2);
|
|
91
|
-
const apart = new Set(grids.flatMap((g) => g.steps));
|
|
92
|
-
return {
|
|
93
|
-
grids,
|
|
94
|
-
drawn: { steps: graph.steps.filter((s) => !apart.has(s.name)), edges: graph.edges.filter((e) => !apart.has(e.from) && !apart.has(e.to)) },
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
/** What a grid of steps says in place of their lines: "These 26 steps feed no other step… Into each: on its own trigger." Pure. */
|
|
99
|
-
export const standAloneWords = (grid: StandAloneSteps): string => {
|
|
100
|
-
const into = grid.into.join(' ');
|
|
101
|
-
const outOf = grid.outOf.join(' ');
|
|
102
|
-
return [
|
|
103
|
-
`These ${grid.steps.length} steps feed no other step and no step feeds them, so they are drawn without lines.`,
|
|
104
|
-
...(into === '' ? [] : [`Into each from the run's start: ${into}.`]),
|
|
105
|
-
...(outOf === '' ? [] : [`Out of each to the run's end: ${outOf}.`]),
|
|
106
|
-
].join(' ');
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
/** The edges drawn: those whose two ends are boxes. Pure. */
|
|
110
|
-
export const graphEdges = (graph: Pick<WorkflowGraph, 'steps' | 'edges'>): ReadonlyArray<GraphEdge> => {
|
|
111
|
-
const boxes = new Set(graphBoxes(graph));
|
|
112
|
-
return graph.edges.filter((e) => boxes.has(e.from) && boxes.has(e.to));
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
/** What ELK is asked to lay out, given each box's measured height. Pure, so a test lays a graph out without a page. */
|
|
116
|
-
export const layoutRequest = (input: { readonly graph: Pick<WorkflowGraph, 'steps' | 'edges'>; readonly heightOf: (box: string) => number }): ElkNode => {
|
|
117
|
-
const edges = graphEdges(input.graph);
|
|
118
|
-
return {
|
|
119
|
-
id: 'steps',
|
|
120
|
-
layoutOptions: {
|
|
121
|
-
'elk.algorithm': 'layered',
|
|
122
|
-
'elk.direction': 'DOWN',
|
|
123
|
-
'elk.edgeRouting': 'ORTHOGONAL',
|
|
124
|
-
'elk.layered.feedbackEdges': 'true',
|
|
125
|
-
// The declared order decides which edges go against the flow: only one to an earlier step.
|
|
126
|
-
'elk.layered.cycleBreaking.strategy': 'MODEL_ORDER',
|
|
127
|
-
'elk.layered.considerModelOrder.strategy': 'NODES_AND_EDGES',
|
|
128
|
-
// Placed to keep edges short and straight: half the width of the default placement on Decompile's 37 edges (2026-11-21).
|
|
129
|
-
'elk.layered.nodePlacement.strategy': 'NETWORK_SIMPLEX',
|
|
130
|
-
'elk.layered.spacing.nodeNodeBetweenLayers': '56',
|
|
131
|
-
'elk.spacing.nodeNode': '30',
|
|
132
|
-
'elk.spacing.edgeNode': '16',
|
|
133
|
-
'elk.spacing.edgeEdge': '10',
|
|
134
|
-
'elk.spacing.edgeLabel': '4',
|
|
135
|
-
'elk.layered.edgeLabels.sideSelection': 'SMART_DOWN',
|
|
136
|
-
'elk.padding': '[top=12,left=12,bottom=12,right=12]',
|
|
137
|
-
},
|
|
138
|
-
children: graphBoxes(input.graph).map((name) => ({ id: name, width: isEnd(name) ? END_WIDTH : NODE_WIDTH, height: input.heightOf(name) })),
|
|
139
|
-
edges: edges.map((e, i) => {
|
|
140
|
-
const lines = edgeLabelLines(e);
|
|
141
|
-
return {
|
|
142
|
-
id: `edge-${i}`, sources: [e.from], targets: [e.to],
|
|
143
|
-
labels: lines.length === 0 ? [] : [{ id: `label-${i}`, text: lines.join('\n'), width: Math.ceil(Math.max(...lines.map((l) => l.length)) * charWidth) + 10, height: lines.length * LABEL_LINE + 4 }],
|
|
144
|
-
};
|
|
145
|
-
}),
|
|
146
|
-
};
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
export interface Laid {
|
|
150
|
-
readonly boxes: ReadonlyMap<string, { readonly x: number; readonly y: number; readonly h: number }>;
|
|
151
|
-
readonly edges: ReadonlyArray<{ readonly edge: GraphEdge; readonly back: boolean; readonly points: ReadonlyArray<{ readonly x: number; readonly y: number }>; readonly label: { readonly x: number; readonly y: number; readonly w: number; readonly lines: ReadonlyArray<string> } | null }>;
|
|
152
|
-
readonly width: number;
|
|
153
|
-
readonly height: number;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const elk = new ELK();
|
|
157
|
-
|
|
158
|
-
/** The layout of a graph's boxes and edges, given each box's height. */
|
|
159
|
-
export const layOut = async (input: { readonly graph: Pick<WorkflowGraph, 'steps' | 'edges'>; readonly heightOf: (box: string) => number }): Promise<Laid> => {
|
|
160
|
-
const drawn = graphEdges(input.graph);
|
|
161
|
-
const laid = await elk.layout(layoutRequest(input));
|
|
162
|
-
const boxes = new Map((laid.children ?? []).map((c) => [c.id, { x: c.x ?? 0, y: c.y ?? 0, h: c.height ?? 0 }]));
|
|
163
|
-
const edges = (laid.edges ?? []).map((e, i) => {
|
|
164
|
-
const s = e.sections?.[0];
|
|
165
|
-
const label = e.labels?.[0];
|
|
166
|
-
const points = s === undefined ? [] : [s.startPoint, ...(s.bendPoints ?? []), s.endPoint];
|
|
167
|
-
const from = boxes.get(drawn[i]!.from), to = boxes.get(drawn[i]!.to);
|
|
168
|
-
return {
|
|
169
|
-
edge: drawn[i]!,
|
|
170
|
-
back: from !== undefined && to !== undefined && to.y < from.y,
|
|
171
|
-
points,
|
|
172
|
-
label: label === undefined || label.x === undefined || label.y === undefined ? null : { x: label.x, y: label.y, w: label.width ?? 0, lines: edgeLabelLines(drawn[i]!) },
|
|
173
|
-
};
|
|
174
|
-
});
|
|
175
|
-
return { boxes, edges, width: laid.width ?? 0, height: laid.height ?? 0 };
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
/** What one step's box shows: where its heading links (none for a step that is no workflow) and what is under it. */
|
|
179
|
-
export interface StepBox {
|
|
180
|
-
readonly href: string | null;
|
|
181
|
-
readonly title: string;
|
|
182
|
-
readonly body: ReactNode;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
export interface WorkflowDagProps {
|
|
186
|
-
readonly graph: WorkflowGraph;
|
|
187
|
-
/** A step's box, by the step's name. */
|
|
188
|
-
readonly box: (step: string) => StepBox;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/** A step's box: its name, a link to its workflow where it is one, and what the page shows under it. */
|
|
192
|
-
function StepBoxView({ name, box, style }: { readonly name: string; readonly box: StepBox; readonly style?: CSSProperties }) {
|
|
193
|
-
return (
|
|
194
|
-
<div data-step={name} className="wp-node" style={style}>
|
|
195
|
-
{box.href === null ? <span className="wp-node-name" title={box.title}>{name}</span> : <a className="wp-node-name" href={box.href} title={box.title}>{name} ›</a>}
|
|
196
|
-
{box.body}
|
|
197
|
-
</div>
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
export function WorkflowDag({ graph: whole, box }: WorkflowDagProps) {
|
|
202
|
-
const { grids, drawn: graph } = standAloneSteps(whole);
|
|
203
|
-
const boxes = graphBoxes(graph);
|
|
204
|
-
// Each box's height, measured as drawn, then the layout from them; laid out again whenever a height or the edges change.
|
|
205
|
-
const map = useRef<HTMLDivElement>(null);
|
|
206
|
-
const [heights, setHeights] = useState<string>('');
|
|
207
|
-
const [laid, setLaid] = useState<Laid | null>(null);
|
|
208
|
-
const [failed, setFailed] = useState<string | null>(null);
|
|
209
|
-
useLayoutEffect(() => {
|
|
210
|
-
const el = map.current;
|
|
211
|
-
if (el === null) return;
|
|
212
|
-
const measure = () => setHeights(JSON.stringify([...el.querySelectorAll('[data-step]')].map((n) => [n.getAttribute('data-step'), Math.ceil(n.getBoundingClientRect().height)])));
|
|
213
|
-
measure();
|
|
214
|
-
const watch = new ResizeObserver(measure);
|
|
215
|
-
for (const n of el.querySelectorAll('[data-step]')) watch.observe(n);
|
|
216
|
-
return () => watch.disconnect();
|
|
217
|
-
}, [boxes.join('\u0000')]);
|
|
218
|
-
const edgesKey = JSON.stringify(graph.edges.map((e) => [e.from, e.to, e.when, e.runs]));
|
|
219
|
-
useEffect(() => {
|
|
220
|
-
if (heights === '') return;
|
|
221
|
-
const h = new Map(JSON.parse(heights) as Array<[string, number]>);
|
|
222
|
-
let current = true;
|
|
223
|
-
layOut({ graph, heightOf: (name) => h.get(name) ?? 60 })
|
|
224
|
-
.then((l) => { if (current) { setLaid(l); setFailed(null); } })
|
|
225
|
-
.catch((e: unknown) => { if (current) setFailed(e instanceof Error ? e.message : String(e)); });
|
|
226
|
-
return () => { current = false; };
|
|
227
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- `graph` is read through `edgesKey` and `heights`.
|
|
228
|
-
}, [heights, edgesKey]);
|
|
229
|
-
// Opened at the run's start, once: a graph wider than its box opened at its left edge showed nothing on a phone.
|
|
230
|
-
const scrollBox = useRef<HTMLDivElement>(null);
|
|
231
|
-
const opened = useRef(false);
|
|
232
|
-
useEffect(() => {
|
|
233
|
-
const el = scrollBox.current;
|
|
234
|
-
const start = laid?.boxes.get(RUN_STARTS);
|
|
235
|
-
if (laid === null || opened.current || el === null || start === undefined) return;
|
|
236
|
-
opened.current = true;
|
|
237
|
-
if (el.clientWidth < laid.width) el.scrollLeft = Math.max(0, start.x + END_WIDTH / 2 - el.clientWidth / 2);
|
|
238
|
-
}, [laid]);
|
|
239
|
-
// The frame's width, so a graph wider than it says so in words: Upkeep's 28 steps were 6,146 px wide in a 1,026 px frame.
|
|
240
|
-
// A graph whose every step is in a grid has no frame.
|
|
241
|
-
const framed = graph.steps.length > 0;
|
|
242
|
-
const [frameWidth, setFrameWidth] = useState<number | null>(null);
|
|
243
|
-
useLayoutEffect(() => {
|
|
244
|
-
const el = scrollBox.current;
|
|
245
|
-
if (el === null) return;
|
|
246
|
-
const measure = () => setFrameWidth(el.clientWidth);
|
|
247
|
-
measure();
|
|
248
|
-
const watch = new ResizeObserver(measure);
|
|
249
|
-
watch.observe(el);
|
|
250
|
-
return () => watch.disconnect();
|
|
251
|
-
}, [framed]);
|
|
252
|
-
const wider = laid !== null && frameWidth !== null && frameWidth < laid.width;
|
|
253
|
-
/**
|
|
254
|
-
* EVERY BOX REACHABLE WITH ANY POINTER: the frame scrolls sideways inside itself, but a mouse wheel scrolls only down and
|
|
255
|
-
* an overlay scrollbar is hidden until one scrolls, so a mouse drag on its background (not on a box, whose text can be
|
|
256
|
-
* selected) scrolls it too. A touch scrolls it natively.
|
|
257
|
-
*/
|
|
258
|
-
const drag = useRef<{ readonly pointer: number; readonly x: number; readonly scrollLeft: number } | null>(null);
|
|
259
|
-
const onBackground = (target: EventTarget | null): boolean => target instanceof Element && target.closest('.wp-node') === null;
|
|
260
|
-
|
|
261
|
-
return (
|
|
262
|
-
<div className="wp-dag-wrap">
|
|
263
|
-
{failed === null ? null : <p className="wp-line wp-bad">The steps could not be laid out: {failed}</p>}
|
|
264
|
-
{wider ? <p className="wp-line wp-mut">Wider than this frame: scroll it sideways, drag its background, or click it and use the arrow keys.</p> : null}
|
|
265
|
-
{!framed ? null : <div ref={scrollBox} className="wp-dag-scroll" tabIndex={0} role="region" aria-label="The workflow's steps"
|
|
266
|
-
onPointerDown={(e) => {
|
|
267
|
-
if (e.pointerType !== 'mouse' || e.button !== 0 || !onBackground(e.target)) return;
|
|
268
|
-
drag.current = { pointer: e.pointerId, x: e.clientX, scrollLeft: e.currentTarget.scrollLeft };
|
|
269
|
-
e.currentTarget.setPointerCapture(e.pointerId);
|
|
270
|
-
e.preventDefault();
|
|
271
|
-
}}
|
|
272
|
-
onPointerMove={(e) => {
|
|
273
|
-
const d = drag.current;
|
|
274
|
-
if (d !== null && d.pointer === e.pointerId) e.currentTarget.scrollLeft = d.scrollLeft - (e.clientX - d.x);
|
|
275
|
-
}}
|
|
276
|
-
onPointerUp={(e) => { if (drag.current?.pointer === e.pointerId) drag.current = null; }}
|
|
277
|
-
onPointerCancel={() => { drag.current = null; }}>
|
|
278
|
-
<div ref={map} className="wp-dag" style={{ width: laid === null ? undefined : laid.width, height: laid === null ? undefined : laid.height }}>
|
|
279
|
-
{laid === null ? null : (
|
|
280
|
-
<svg className="wp-dag-edges" width={laid.width} height={laid.height} aria-hidden="true">
|
|
281
|
-
<defs>
|
|
282
|
-
<marker id="wp-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="10" markerHeight="10" markerUnits="userSpaceOnUse" orient="auto">
|
|
283
|
-
<path d="M0,0 L10,5 L0,10 z" fill="var(--wp-edge)" />
|
|
284
|
-
</marker>
|
|
285
|
-
</defs>
|
|
286
|
-
{laid.edges.map(({ edge, back, points }) => (
|
|
287
|
-
<polyline key={`${edge.from}>${edge.to}`} points={points.map((p) => `${p.x},${p.y}`).join(' ')} fill="none" stroke="var(--wp-edge)"
|
|
288
|
-
strokeWidth={edge.runs === 0 ? 1.1 : 1.6} strokeDasharray={back ? '7 4' : undefined} markerEnd="url(#wp-arrow)" />
|
|
289
|
-
))}
|
|
290
|
-
{laid.edges.map(({ edge, label }) => (label === null ? null : (
|
|
291
|
-
<g key={`label:${edge.from}>${edge.to}`}>
|
|
292
|
-
<rect x={label.x} y={label.y} width={label.w} height={label.lines.length * LABEL_LINE + 4} rx={3} fill="var(--wp-bg)" stroke="var(--wp-edge)" strokeWidth="0.6" />
|
|
293
|
-
<text x={label.x + 5} y={label.y + 12} fontSize="10.5" fill="var(--wp-fg)">
|
|
294
|
-
{label.lines.map((line, i) => <tspan key={i} x={label.x + 5} dy={i === 0 ? 0 : LABEL_LINE}>{line}</tspan>)}
|
|
295
|
-
<title>{`${edge.from} → ${edge.to}`}</title>
|
|
296
|
-
</text>
|
|
297
|
-
</g>
|
|
298
|
-
)))}
|
|
299
|
-
</svg>
|
|
300
|
-
)}
|
|
301
|
-
{boxes.map((name) => {
|
|
302
|
-
const at = laid?.boxes.get(name);
|
|
303
|
-
const style = at === undefined ? { position: 'absolute' as const, left: 0, top: 0, visibility: 'hidden' as const } : { position: 'absolute' as const, left: at.x, top: at.y };
|
|
304
|
-
if (isEnd(name)) return <div key={name} data-step={name} className="wp-node wp-node-end" style={style}>{name}</div>;
|
|
305
|
-
return <StepBoxView key={name} name={name} box={box(name)} style={style} />;
|
|
306
|
-
})}
|
|
307
|
-
</div>
|
|
308
|
-
</div>}
|
|
309
|
-
{grids.map((grid) => (
|
|
310
|
-
<div key={grid.steps.join('\u0000')} data-stand-alone-steps>
|
|
311
|
-
<p className="wp-line wp-mut">{standAloneWords(grid)}</p>
|
|
312
|
-
<div className="wp-dag-grid" role="list" aria-label="Steps that feed no other step">
|
|
313
|
-
{grid.steps.map((name) => <div key={name} role="listitem"><StepBoxView name={name} box={box(name)} /></div>)}
|
|
314
|
-
</div>
|
|
315
|
-
</div>
|
|
316
|
-
))}
|
|
317
|
-
{whole.undeclared.length === 0 ? null : (
|
|
318
|
-
<p className="wp-line wp-bad">Taken but not declared: {whole.undeclared.map((e) => `${e.from} → ${e.to} (${e.runs})`).join('; ')}</p>
|
|
319
|
-
)}
|
|
320
|
-
</div>
|
|
321
|
-
);
|
|
322
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* WHERE A PAGE IS, AND WHAT IT SHOWS (`drilldown.ts`). Alex, 2026-11-21: "i need to know what workflow I'm looking at and see
|
|
5
|
-
* a breadcrumb back to the top level workflow". Two elements, the same at every depth: the path from the top-level workflow
|
|
6
|
-
* down to this one, every part but the last a link, labelled as the path; and below it the page's title, the workflow
|
|
7
|
-
* opened, by name. A workflow's own steps are its graph's boxes (`workflow-dag.tsx`), each step that is a workflow a link
|
|
8
|
-
* one level down.
|
|
9
|
-
*/
|
|
10
|
-
import { Fragment, type ReactNode } from 'react';
|
|
11
|
-
import type { Crumb } from './drilldown';
|
|
12
|
-
|
|
13
|
-
/** The path opened, top first: every part but the last a link to its level, the last this page, said and not linked. */
|
|
14
|
-
export function Breadcrumb({ crumbs, hrefOf }: { readonly crumbs: ReadonlyArray<Crumb>; readonly hrefOf: (path: ReadonlyArray<string>) => string }) {
|
|
15
|
-
return (
|
|
16
|
-
<nav className="wp-crumbs" aria-label="Path from the top-level workflow">
|
|
17
|
-
<span className="wp-crumbs-label">Path:</span>
|
|
18
|
-
{crumbs.map((c, i) => (
|
|
19
|
-
<Fragment key={c.path.join('/')}>
|
|
20
|
-
{i === 0 ? null : <span className="wp-crumb-sep" aria-hidden="true">›</span>}
|
|
21
|
-
{i === crumbs.length - 1 ? <span className="wp-crumb-here" aria-current="page">{c.name}</span> : <a href={hrefOf(c.path)}>{c.name}</a>}
|
|
22
|
-
</Fragment>
|
|
23
|
-
))}
|
|
24
|
-
</nav>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** The page's title: the workflow it shows, by name; `after` follows it (its source's link). */
|
|
29
|
-
export function WorkflowTitle({ name, after }: { readonly name: string; readonly after?: ReactNode }) {
|
|
30
|
-
return <h2 className="wp-title">Workflow: {name}{after}</h2>;
|
|
31
|
-
}
|