@pipelex/mthds-ui 0.38.0 → 0.40.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 +4 -2
- package/dist/chunk-7JZBXBZS.js +258 -0
- package/dist/chunk-7JZBXBZS.js.map +1 -0
- package/dist/{chunk-AGFLCOWW.js → chunk-HPARBH6K.js} +14 -197
- package/dist/chunk-HPARBH6K.js.map +1 -0
- package/dist/chunk-N2F62MW7.js +55 -0
- package/dist/chunk-N2F62MW7.js.map +1 -0
- package/dist/chunk-P6IGZVWE.js +155 -0
- package/dist/chunk-P6IGZVWE.js.map +1 -0
- package/dist/chunk-RU3CIXFC.js +1251 -0
- package/dist/chunk-RU3CIXFC.js.map +1 -0
- package/dist/form/brand/index.js.map +1 -1
- package/dist/form/react/index.d.ts +36 -3
- package/dist/form/react/index.js +45 -14
- package/dist/form/react/index.js.map +1 -1
- package/dist/graph/index.d.ts +19 -3
- package/dist/graph/index.js +20 -12
- package/dist/graph/react/index.d.ts +13 -13
- package/dist/graph/react/index.js +387 -560
- package/dist/graph/react/index.js.map +1 -1
- package/dist/graph/react/viewer/GraphToolbar.css +2 -107
- package/dist/graph/react/viewer/StyleMenu.css +109 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +20 -12
- package/dist/registryJoin-C6Wfkik-.d.ts +441 -0
- package/dist/standalone/graph-standalone.html +183 -178
- package/dist/standalone/graph-viewer.css +75 -70
- package/dist/standalone/graph-viewer.js +108 -108
- package/dist/static-graph/index.d.ts +1 -1
- package/dist/timeline/index.d.ts +240 -77
- package/dist/timeline/index.js +61 -3
- package/dist/timeline/react/RunTimeline.css +48 -0
- package/dist/timeline/react/index.d.ts +46 -4
- package/dist/timeline/react/index.js +774 -105
- package/dist/timeline/react/index.js.map +1 -1
- package/dist/timeline/react/styles/simple/SimpleProgress.css +354 -0
- package/dist/{types-DsrzH6gM.d.ts → types-DLAnYNoi.d.ts} +1 -1
- package/package.json +5 -3
- package/dist/chunk-AGFLCOWW.js.map +0 -1
- package/dist/chunk-ILZJIORT.js +0 -54
- package/dist/chunk-ILZJIORT.js.map +0 -1
- package/dist/chunk-JJG2TO7P.js +0 -473
- package/dist/chunk-JJG2TO7P.js.map +0 -1
- package/dist/progressSnapshot-VZ4PLul9.d.ts +0 -191
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
+
StyleMenu,
|
|
3
4
|
useSystemTheme
|
|
4
|
-
} from "../../chunk-
|
|
5
|
+
} from "../../chunk-7JZBXBZS.js";
|
|
6
|
+
import "../../chunk-N2F62MW7.js";
|
|
5
7
|
import {
|
|
6
8
|
INVOCATION_STATUS,
|
|
7
9
|
PROGRESS_MODE,
|
|
10
|
+
RUN_PROGRESS_STATUS,
|
|
11
|
+
SIMPLE_LINE_KIND,
|
|
12
|
+
SIMPLE_LINE_STATE,
|
|
13
|
+
SIMPLE_RUN_NOTE_REASON,
|
|
14
|
+
TIMELINE_STYLE,
|
|
15
|
+
TIMELINE_STYLES,
|
|
8
16
|
barFollowsClock,
|
|
17
|
+
buildSimpleProgress,
|
|
9
18
|
buildTimelineRows,
|
|
10
19
|
formatClockTime,
|
|
11
20
|
formatDuration,
|
|
@@ -15,10 +24,17 @@ import {
|
|
|
15
24
|
isRunEnded,
|
|
16
25
|
progressStreamKey,
|
|
17
26
|
readingClockMs,
|
|
27
|
+
resolveTimelineStyle,
|
|
28
|
+
resolveTimelineStyleMenu,
|
|
29
|
+
simpleProgressChanges,
|
|
18
30
|
snapshotTimes,
|
|
19
31
|
timelineTicks,
|
|
20
|
-
timelineWindowAt
|
|
21
|
-
|
|
32
|
+
timelineWindowAt,
|
|
33
|
+
timestampMs
|
|
34
|
+
} from "../../chunk-RU3CIXFC.js";
|
|
35
|
+
import {
|
|
36
|
+
outcomeLabel
|
|
37
|
+
} from "../../chunk-P6IGZVWE.js";
|
|
22
38
|
import {
|
|
23
39
|
getPaletteForTheme
|
|
24
40
|
} from "../../chunk-ENRYQOCO.js";
|
|
@@ -32,42 +48,14 @@ import {
|
|
|
32
48
|
|
|
33
49
|
// src/timeline/react/index.ts
|
|
34
50
|
import "./RunTimeline.css";
|
|
51
|
+
import "./styles/simple/SimpleProgress.css";
|
|
52
|
+
import "../../graph/react/viewer/StyleMenu.css";
|
|
35
53
|
|
|
36
54
|
// src/timeline/react/RunTimeline.tsx
|
|
55
|
+
import * as React4 from "react";
|
|
56
|
+
|
|
57
|
+
// src/timeline/react/readingClock.ts
|
|
37
58
|
import * as React from "react";
|
|
38
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
39
|
-
var CLOCK_TICK_MS = 250;
|
|
40
|
-
var TICK_RIGHT_ALIGN_PERCENT = 92;
|
|
41
|
-
var TICK_SPACING_PX = 64;
|
|
42
|
-
var DEFAULT_MAX_TICKS = 6;
|
|
43
|
-
function useTickBudget() {
|
|
44
|
-
const [budget, setBudget] = React.useState(DEFAULT_MAX_TICKS);
|
|
45
|
-
const observer = React.useRef(null);
|
|
46
|
-
const ref = React.useCallback((element) => {
|
|
47
|
-
var _a;
|
|
48
|
-
(_a = observer.current) == null ? void 0 : _a.disconnect();
|
|
49
|
-
observer.current = null;
|
|
50
|
-
if (!element || typeof ResizeObserver === "undefined") return;
|
|
51
|
-
observer.current = new ResizeObserver((entries) => {
|
|
52
|
-
var _a2, _b;
|
|
53
|
-
const width = (_b = (_a2 = entries[0]) == null ? void 0 : _a2.contentRect.width) != null ? _b : 0;
|
|
54
|
-
if (width > 0) setBudget(Math.max(1, Math.floor(width / TICK_SPACING_PX)));
|
|
55
|
-
});
|
|
56
|
-
observer.current.observe(element);
|
|
57
|
-
}, []);
|
|
58
|
-
return [ref, budget];
|
|
59
|
-
}
|
|
60
|
-
var EMPTY_EXPANSION = Object.freeze({});
|
|
61
|
-
var RUN_STATUS_WORD = {
|
|
62
|
-
pending: "Pending",
|
|
63
|
-
running: "Running",
|
|
64
|
-
succeeded: "Succeeded",
|
|
65
|
-
failed: "Failed",
|
|
66
|
-
canceled: "Canceled"
|
|
67
|
-
};
|
|
68
|
-
function wordFor(table, value) {
|
|
69
|
-
return Object.prototype.hasOwnProperty.call(table, value) ? table[value] : value;
|
|
70
|
-
}
|
|
71
59
|
function useHeldSnapshot(snapshot) {
|
|
72
60
|
const [state, setState] = React.useState({ given: snapshot, held: snapshot });
|
|
73
61
|
if (state.given !== snapshot) {
|
|
@@ -77,10 +65,15 @@ function useHeldSnapshot(snapshot) {
|
|
|
77
65
|
}
|
|
78
66
|
return state.held;
|
|
79
67
|
}
|
|
80
|
-
function useReadingClock(held, stream, now, live, followsClock) {
|
|
68
|
+
function useReadingClock(held, stream, { now, live, followsClock: followsClock2, tickMs }) {
|
|
81
69
|
const base = React.useMemo(() => readingClockMs(held, now), [held, now]);
|
|
82
|
-
const ticking = live && now === void 0 && base !== null && !isRunEnded(held.status) &&
|
|
83
|
-
const [clock, setClock] = React.useState({
|
|
70
|
+
const ticking = live && now === void 0 && base !== null && !isRunEnded(held.status) && followsClock2;
|
|
71
|
+
const [clock, setClock] = React.useState({
|
|
72
|
+
stream,
|
|
73
|
+
base,
|
|
74
|
+
ticking,
|
|
75
|
+
ms: base
|
|
76
|
+
});
|
|
84
77
|
let shown = clock;
|
|
85
78
|
if (clock.stream !== stream || clock.base !== base || clock.ticking !== ticking) {
|
|
86
79
|
const floor = ticking && clock.ticking && clock.stream === stream ? clock.ms : null;
|
|
@@ -98,11 +91,591 @@ function useReadingClock(held, stream, now, live, followsClock) {
|
|
|
98
91
|
setClock(
|
|
99
92
|
(state) => state.stream === stream && state.base === base && state.ticking && state.ms !== null ? __spreadProps(__spreadValues({}, state), { ms: state.ms + step }) : state
|
|
100
93
|
);
|
|
101
|
-
},
|
|
94
|
+
}, tickMs);
|
|
102
95
|
return () => window.clearInterval(timer);
|
|
103
|
-
}, [ticking, stream, base]);
|
|
96
|
+
}, [ticking, stream, base, tickMs]);
|
|
104
97
|
return { nowMs: ticking ? shown.ms : base, ticking };
|
|
105
98
|
}
|
|
99
|
+
|
|
100
|
+
// src/timeline/react/streamExpansion.ts
|
|
101
|
+
import * as React2 from "react";
|
|
102
|
+
var EMPTY_EXPANSION = Object.freeze({});
|
|
103
|
+
function useStreamExpansion(stream) {
|
|
104
|
+
const [state, setState] = React2.useState({ stream, expanded: EMPTY_EXPANSION });
|
|
105
|
+
const toggle = React2.useCallback(
|
|
106
|
+
(key, expanded) => {
|
|
107
|
+
setState((previous) => ({
|
|
108
|
+
stream,
|
|
109
|
+
expanded: __spreadProps(__spreadValues({}, previous.stream === stream ? previous.expanded : EMPTY_EXPANSION), {
|
|
110
|
+
[key]: expanded
|
|
111
|
+
})
|
|
112
|
+
}));
|
|
113
|
+
},
|
|
114
|
+
[stream]
|
|
115
|
+
);
|
|
116
|
+
return { expanded: state.stream === stream ? state.expanded : EMPTY_EXPANSION, toggle };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// src/timeline/react/styles/simple/SimpleProgressView.tsx
|
|
120
|
+
import * as React3 from "react";
|
|
121
|
+
|
|
122
|
+
// src/timeline/react/styles/simple/simpleProgressStrings.ts
|
|
123
|
+
function plural(count, one, many) {
|
|
124
|
+
return count === 1 ? one : many;
|
|
125
|
+
}
|
|
126
|
+
function withElapsed(phrase, elapsed) {
|
|
127
|
+
return elapsed === null ? phrase : `${phrase} \xB7 ${elapsed}`;
|
|
128
|
+
}
|
|
129
|
+
function itemCount(count, item) {
|
|
130
|
+
const noun = item != null ? item : "item";
|
|
131
|
+
return `${count} ${plural(count, noun, `${noun}s`)}`;
|
|
132
|
+
}
|
|
133
|
+
var DEFAULT_SIMPLE_PROGRESS_STRINGS = {
|
|
134
|
+
waiting: "Waiting to start",
|
|
135
|
+
working: (elapsed) => withElapsed("Working on it", elapsed),
|
|
136
|
+
done: (elapsed) => withElapsed("Done", elapsed),
|
|
137
|
+
failed: (where, elapsed) => withElapsed(where === null ? "Failed" : `Failed in ${where}`, elapsed),
|
|
138
|
+
canceled: (elapsed) => withElapsed("Canceled", elapsed),
|
|
139
|
+
nothingRecorded: "No progress was recorded",
|
|
140
|
+
dryRun: "Dry run",
|
|
141
|
+
checklistLabel: "Steps of the run",
|
|
142
|
+
together: "at the same time",
|
|
143
|
+
forEach: (item) => `for each ${item != null ? item : "item"}`,
|
|
144
|
+
outcomeTaken: (key) => `\u2192 ${key === null ? "Default" : outcomeLabel(key)}`,
|
|
145
|
+
branchFor: (key) => key === null ? "otherwise" : `if ${outcomeLabel(key)}`,
|
|
146
|
+
finishedBranches: (count) => `${count} done`,
|
|
147
|
+
now: "Now:",
|
|
148
|
+
batchCounts: (done, total, running, failed, skipped) => {
|
|
149
|
+
let text = `${done} of ${total} done`;
|
|
150
|
+
if (running > 0) text += ` \xB7 ${running} in progress`;
|
|
151
|
+
if (failed > 0) text += ` \xB7 ${failed} failed`;
|
|
152
|
+
if (skipped > 0) text += ` \xB7 ${skipped} skipped`;
|
|
153
|
+
return text;
|
|
154
|
+
},
|
|
155
|
+
tally: (tally) => {
|
|
156
|
+
const parts = [];
|
|
157
|
+
if (tally.done > 0) parts.push(`${tally.done} done`);
|
|
158
|
+
if (tally.running > 0) parts.push(`${tally.running} in progress`);
|
|
159
|
+
if (tally.failed > 0) parts.push(`${tally.failed} failed`);
|
|
160
|
+
if (tally.skipped > 0) parts.push(`${tally.skipped} skipped`);
|
|
161
|
+
if (tally.stopped > 0) parts.push(`${tally.stopped} stopped`);
|
|
162
|
+
return parts.length > 0 ? parts.join(", ") : "not started";
|
|
163
|
+
},
|
|
164
|
+
state: {
|
|
165
|
+
upcoming: "Not started",
|
|
166
|
+
running: "In progress",
|
|
167
|
+
done: "Done",
|
|
168
|
+
failed: "Failed",
|
|
169
|
+
skipped: "Skipped",
|
|
170
|
+
stopped: "Stopped",
|
|
171
|
+
notRun: "Not run"
|
|
172
|
+
},
|
|
173
|
+
tryingAgain: (attempt) => `Trying again (attempt ${attempt})`,
|
|
174
|
+
tryingAgainItems: (count, item) => `Trying again for ${itemCount(count, item)}`,
|
|
175
|
+
havingTrouble: (until) => until === null ? "Having trouble here. Still trying." : `Having trouble here. Still trying; the run fails if this lasts past ${until}.`,
|
|
176
|
+
havingTroubleItems: (count, item, until) => until === null ? `Having trouble with ${itemCount(count, item)}. Still trying.` : `Having trouble with ${itemCount(count, item)}. Still trying; the run fails if this lasts past ${until}.`,
|
|
177
|
+
unreachable: "Progress may be out of date: the run can't be reached right now.",
|
|
178
|
+
runTryingAgain: (attempt) => `The run is trying again (attempt ${attempt}).`,
|
|
179
|
+
runStuck: (until) => until === null ? "The run is having trouble. Still trying." : `The run is having trouble. Still trying; it fails if this lasts past ${until}.`,
|
|
180
|
+
details: "Details",
|
|
181
|
+
announceDone: (title) => `Done: ${title}.`,
|
|
182
|
+
announceFailed: (title) => `Failed: ${title}.`,
|
|
183
|
+
announceNow: (title) => `Now: ${title}.`,
|
|
184
|
+
announceEnd: (headline) => `${headline}.`,
|
|
185
|
+
expand: (title) => `Show the steps of ${title}`,
|
|
186
|
+
collapse: (title) => `Hide the steps of ${title}`,
|
|
187
|
+
duration: (ms) => ms < 1e3 ? "<1s" : formatDuration(ms),
|
|
188
|
+
elapsed: (ms) => ms < 1e3 ? "<1s" : formatDuration(Math.floor(ms / 1e3) * 1e3),
|
|
189
|
+
clockTime: (ms) => new Intl.DateTimeFormat(void 0, {
|
|
190
|
+
hour: "2-digit",
|
|
191
|
+
minute: "2-digit"
|
|
192
|
+
}).format(ms)
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
// src/timeline/react/styles/simple/SimpleProgressView.tsx
|
|
196
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
197
|
+
function StateMark({ state }) {
|
|
198
|
+
let shape = null;
|
|
199
|
+
switch (state) {
|
|
200
|
+
case SIMPLE_LINE_STATE.DONE:
|
|
201
|
+
shape = /* @__PURE__ */ jsx("path", { d: "M3.5 6.2 5.3 8l3.4-3.8", fill: "none", strokeWidth: "1.6" });
|
|
202
|
+
break;
|
|
203
|
+
case SIMPLE_LINE_STATE.FAILED:
|
|
204
|
+
shape = /* @__PURE__ */ jsx("path", { d: "M4 4l4 4M8 4l-4 4", fill: "none", strokeWidth: "1.6" });
|
|
205
|
+
break;
|
|
206
|
+
case SIMPLE_LINE_STATE.SKIPPED:
|
|
207
|
+
shape = /* @__PURE__ */ jsx("path", { d: "M3.8 6h4.4", fill: "none", strokeWidth: "1.4" });
|
|
208
|
+
break;
|
|
209
|
+
case SIMPLE_LINE_STATE.STOPPED:
|
|
210
|
+
shape = /* @__PURE__ */ jsx("rect", { x: "4", y: "4", width: "4", height: "4", rx: "0.5" });
|
|
211
|
+
break;
|
|
212
|
+
case SIMPLE_LINE_STATE.NOT_RUN:
|
|
213
|
+
shape = /* @__PURE__ */ jsx("path", { d: "M3.8 6h4.4", fill: "none", strokeWidth: "1.2" });
|
|
214
|
+
break;
|
|
215
|
+
default:
|
|
216
|
+
shape = null;
|
|
217
|
+
}
|
|
218
|
+
return /* @__PURE__ */ jsxs(
|
|
219
|
+
"svg",
|
|
220
|
+
{
|
|
221
|
+
className: `mthds-simple-progress-mark mthds-simple-progress-mark--${state}`,
|
|
222
|
+
viewBox: "0 0 12 12",
|
|
223
|
+
"aria-hidden": "true",
|
|
224
|
+
focusable: "false",
|
|
225
|
+
children: [
|
|
226
|
+
/* @__PURE__ */ jsx("circle", { className: "mthds-simple-progress-mark-ring", cx: "6", cy: "6", r: "5.2" }),
|
|
227
|
+
state === SIMPLE_LINE_STATE.RUNNING && /* @__PURE__ */ jsx("path", { className: "mthds-simple-progress-mark-arc", d: "M6 0.8a5.2 5.2 0 0 1 5.2 5.2" }),
|
|
228
|
+
shape
|
|
229
|
+
]
|
|
230
|
+
}
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
function Details({ label, children }) {
|
|
234
|
+
return /* @__PURE__ */ jsxs("details", { className: "mthds-simple-progress-details", children: [
|
|
235
|
+
/* @__PURE__ */ jsx("summary", { children: label }),
|
|
236
|
+
/* @__PURE__ */ jsx("div", { className: "mthds-simple-progress-details-body", children })
|
|
237
|
+
] });
|
|
238
|
+
}
|
|
239
|
+
function ProblemDetails({
|
|
240
|
+
problem,
|
|
241
|
+
strings
|
|
242
|
+
}) {
|
|
243
|
+
var _a;
|
|
244
|
+
const nextStep = (_a = problem.next_step) == null ? void 0 : _a.detail;
|
|
245
|
+
return /* @__PURE__ */ jsxs(Details, { label: strings.details, children: [
|
|
246
|
+
/* @__PURE__ */ jsx("p", { children: problem.detail }),
|
|
247
|
+
nextStep && /* @__PURE__ */ jsx("p", { children: nextStep })
|
|
248
|
+
] });
|
|
249
|
+
}
|
|
250
|
+
function untilOf(degradation, strings) {
|
|
251
|
+
const ms = timestampMs(degradation.ends_at);
|
|
252
|
+
return ms === null ? null : strings.clockTime(ms);
|
|
253
|
+
}
|
|
254
|
+
function Note({ tone, children }) {
|
|
255
|
+
return /* @__PURE__ */ jsx("div", { className: `mthds-simple-progress-note mthds-simple-progress-note--${tone}`, children });
|
|
256
|
+
}
|
|
257
|
+
function HealthNotes({
|
|
258
|
+
line,
|
|
259
|
+
item,
|
|
260
|
+
strings
|
|
261
|
+
}) {
|
|
262
|
+
const health = line.health;
|
|
263
|
+
if (!health) return null;
|
|
264
|
+
const notes = [];
|
|
265
|
+
if (health.problem) {
|
|
266
|
+
notes.push(
|
|
267
|
+
/* @__PURE__ */ jsxs(Note, { tone: "error", children: [
|
|
268
|
+
/* @__PURE__ */ jsx("p", { children: health.problem.title }),
|
|
269
|
+
/* @__PURE__ */ jsx(ProblemDetails, { problem: health.problem, strings })
|
|
270
|
+
] }, "problem")
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
if (health.retryingItems > 0) {
|
|
274
|
+
notes.push(
|
|
275
|
+
/* @__PURE__ */ jsx(Note, { tone: "warning", children: /* @__PURE__ */ jsx("p", { children: strings.tryingAgainItems(health.retryingItems, item) }) }, "retrying")
|
|
276
|
+
);
|
|
277
|
+
} else if (health.retryAttempt !== null) {
|
|
278
|
+
notes.push(
|
|
279
|
+
/* @__PURE__ */ jsx(Note, { tone: "warning", children: /* @__PURE__ */ jsx("p", { children: strings.tryingAgain(health.retryAttempt) }) }, "retrying")
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
if (health.degradation) {
|
|
283
|
+
const until = untilOf(health.degradation, strings);
|
|
284
|
+
notes.push(
|
|
285
|
+
/* @__PURE__ */ jsxs(Note, { tone: "warning", children: [
|
|
286
|
+
/* @__PURE__ */ jsx("p", { children: health.stuckItems > 0 ? strings.havingTroubleItems(health.stuckItems, item, until) : strings.havingTrouble(until) }),
|
|
287
|
+
/* @__PURE__ */ jsx(Details, { label: strings.details, children: /* @__PURE__ */ jsx("p", { children: health.degradation.message }) })
|
|
288
|
+
] }, "stuck")
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
return notes.length > 0 ? /* @__PURE__ */ jsx("div", { className: "mthds-simple-progress-notes", children: notes }) : null;
|
|
292
|
+
}
|
|
293
|
+
function BatchCounts({
|
|
294
|
+
line,
|
|
295
|
+
strings
|
|
296
|
+
}) {
|
|
297
|
+
const counts = line.counts;
|
|
298
|
+
if (!counts || counts.total <= 0) return null;
|
|
299
|
+
const share = (count) => `${Math.min(count, counts.total) / counts.total * 100}%`;
|
|
300
|
+
const skipped = Math.min(line.skippedItems, counts.done);
|
|
301
|
+
const finished = counts.done - skipped;
|
|
302
|
+
const text = strings.batchCounts(finished, counts.total, counts.running, counts.failed, skipped);
|
|
303
|
+
const segments = [
|
|
304
|
+
["done", finished],
|
|
305
|
+
["skipped", skipped],
|
|
306
|
+
["failed", counts.failed],
|
|
307
|
+
["running", counts.running]
|
|
308
|
+
];
|
|
309
|
+
return /* @__PURE__ */ jsxs("div", { className: "mthds-simple-progress-batch", children: [
|
|
310
|
+
/* @__PURE__ */ jsx(
|
|
311
|
+
"div",
|
|
312
|
+
{
|
|
313
|
+
className: "mthds-simple-progress-bar",
|
|
314
|
+
role: "progressbar",
|
|
315
|
+
"aria-valuemin": 0,
|
|
316
|
+
"aria-valuemax": counts.total,
|
|
317
|
+
"aria-valuenow": finished,
|
|
318
|
+
"aria-valuetext": text,
|
|
319
|
+
children: segments.map(
|
|
320
|
+
([name, count]) => count > 0 ? /* @__PURE__ */ jsx(
|
|
321
|
+
"span",
|
|
322
|
+
{
|
|
323
|
+
className: `mthds-simple-progress-bar-${name}`,
|
|
324
|
+
style: { width: share(count) }
|
|
325
|
+
},
|
|
326
|
+
name
|
|
327
|
+
) : null
|
|
328
|
+
)
|
|
329
|
+
}
|
|
330
|
+
),
|
|
331
|
+
/* @__PURE__ */ jsx("span", { className: "mthds-simple-progress-counts", "aria-hidden": "true", children: text })
|
|
332
|
+
] });
|
|
333
|
+
}
|
|
334
|
+
var TALLY_ORDER = [
|
|
335
|
+
SIMPLE_LINE_STATE.DONE,
|
|
336
|
+
SIMPLE_LINE_STATE.RUNNING,
|
|
337
|
+
SIMPLE_LINE_STATE.FAILED,
|
|
338
|
+
SIMPLE_LINE_STATE.SKIPPED,
|
|
339
|
+
SIMPLE_LINE_STATE.STOPPED
|
|
340
|
+
];
|
|
341
|
+
function Tally({ line, strings }) {
|
|
342
|
+
const tally = line.tally;
|
|
343
|
+
if (!tally) return null;
|
|
344
|
+
return /* @__PURE__ */ jsxs("span", { className: "mthds-simple-progress-tally", children: [
|
|
345
|
+
TALLY_ORDER.filter((state) => tally[state] > 0).map((state) => /* @__PURE__ */ jsxs("span", { className: "mthds-simple-progress-tally-entry", "aria-hidden": "true", children: [
|
|
346
|
+
/* @__PURE__ */ jsx(StateMark, { state }),
|
|
347
|
+
tally[state]
|
|
348
|
+
] }, state)),
|
|
349
|
+
/* @__PURE__ */ jsx("span", { className: "mthds-run-timeline-sr", children: `, ${strings.tally(tally)}` })
|
|
350
|
+
] });
|
|
351
|
+
}
|
|
352
|
+
function timeText(line, nowMs, strings) {
|
|
353
|
+
if (line.state === SIMPLE_LINE_STATE.SKIPPED || line.state === SIMPLE_LINE_STATE.STOPPED || line.state === SIMPLE_LINE_STATE.NOT_RUN) {
|
|
354
|
+
return strings.state[line.state];
|
|
355
|
+
}
|
|
356
|
+
const invocation = line.invocation;
|
|
357
|
+
if (!invocation || line.kind === SIMPLE_LINE_KIND.NOW) return null;
|
|
358
|
+
const times = invocationTimes(invocation);
|
|
359
|
+
if (times.startedMs === null) return null;
|
|
360
|
+
if (times.endedMs !== null) return strings.duration(times.endedMs - times.startedMs);
|
|
361
|
+
if (line.state === SIMPLE_LINE_STATE.RUNNING && nowMs !== null) {
|
|
362
|
+
return strings.elapsed(nowMs - times.startedMs);
|
|
363
|
+
}
|
|
364
|
+
return null;
|
|
365
|
+
}
|
|
366
|
+
function followsClock(line) {
|
|
367
|
+
return line.state === SIMPLE_LINE_STATE.RUNNING || line.children.some(followsClock);
|
|
368
|
+
}
|
|
369
|
+
function itemOfChild(parent, child) {
|
|
370
|
+
if (child.kind === SIMPLE_LINE_KIND.FOR_EACH) return child.forEachItem;
|
|
371
|
+
return parent.kind === SIMPLE_LINE_KIND.FOR_EACH ? parent.forEachItem : null;
|
|
372
|
+
}
|
|
373
|
+
var LineView = React3.memo(function LineView2({
|
|
374
|
+
line,
|
|
375
|
+
item,
|
|
376
|
+
nowMs,
|
|
377
|
+
onToggle,
|
|
378
|
+
strings
|
|
379
|
+
}) {
|
|
380
|
+
var _a;
|
|
381
|
+
const time = timeText(line, line.state === SIMPLE_LINE_STATE.RUNNING ? nowMs : null, strings);
|
|
382
|
+
const classes = [
|
|
383
|
+
"mthds-simple-progress-line",
|
|
384
|
+
`mthds-simple-progress-line--${line.state}`,
|
|
385
|
+
`mthds-simple-progress-line--${line.kind}`
|
|
386
|
+
].join(" ");
|
|
387
|
+
const title = line.kind === SIMPLE_LINE_KIND.FINISHED ? strings.finishedBranches((_a = line.foldedCount) != null ? _a : 0) : line.title;
|
|
388
|
+
return /* @__PURE__ */ jsxs("li", { className: classes, "data-key": line.key, "data-state": line.state, children: [
|
|
389
|
+
/* @__PURE__ */ jsxs("div", { className: "mthds-simple-progress-row", children: [
|
|
390
|
+
/* @__PURE__ */ jsx(StateMark, { state: line.state }),
|
|
391
|
+
/* @__PURE__ */ jsxs("span", { className: "mthds-simple-progress-title", children: [
|
|
392
|
+
line.kind === SIMPLE_LINE_KIND.NOW && /* @__PURE__ */ jsxs("span", { className: "mthds-simple-progress-now", children: [
|
|
393
|
+
strings.now,
|
|
394
|
+
" "
|
|
395
|
+
] }),
|
|
396
|
+
/* @__PURE__ */ jsx("span", { className: "mthds-simple-progress-name", children: title }),
|
|
397
|
+
line.kind === SIMPLE_LINE_KIND.FOR_EACH && /* @__PURE__ */ jsx("span", { className: "mthds-simple-progress-tag", children: ` \xB7 ${strings.forEach(line.forEachItem)}` }),
|
|
398
|
+
line.kind === SIMPLE_LINE_KIND.TOGETHER && /* @__PURE__ */ jsx("span", { className: "mthds-simple-progress-tag", children: ` \xB7 ${strings.together}` }),
|
|
399
|
+
line.outcome && /* @__PURE__ */ jsx("span", { className: "mthds-simple-progress-outcome", children: line.outcome.resolved ? strings.outcomeTaken(line.outcome.key) : strings.branchFor(line.outcome.key) }),
|
|
400
|
+
/* @__PURE__ */ jsx("span", { className: "mthds-run-timeline-sr", children: `, ${strings.state[line.state]}` })
|
|
401
|
+
] }),
|
|
402
|
+
/* @__PURE__ */ jsx(Tally, { line, strings }),
|
|
403
|
+
time !== null && /* @__PURE__ */ jsx("span", { className: "mthds-simple-progress-time", children: time }),
|
|
404
|
+
line.expandable ? /* @__PURE__ */ jsx(
|
|
405
|
+
"button",
|
|
406
|
+
{
|
|
407
|
+
type: "button",
|
|
408
|
+
className: "mthds-run-timeline-toggle mthds-simple-progress-toggle",
|
|
409
|
+
"aria-expanded": line.expanded,
|
|
410
|
+
"aria-label": line.expanded ? strings.collapse(title) : strings.expand(title),
|
|
411
|
+
onClick: () => onToggle(line.key, !line.expanded),
|
|
412
|
+
children: /* @__PURE__ */ jsx(
|
|
413
|
+
"svg",
|
|
414
|
+
{
|
|
415
|
+
className: "mthds-simple-progress-chevron",
|
|
416
|
+
viewBox: "0 0 12 12",
|
|
417
|
+
width: "12",
|
|
418
|
+
height: "12",
|
|
419
|
+
"aria-hidden": "true",
|
|
420
|
+
children: /* @__PURE__ */ jsx("path", { d: "M4.5 2.5 8 6l-3.5 3.5" })
|
|
421
|
+
}
|
|
422
|
+
)
|
|
423
|
+
}
|
|
424
|
+
) : /* @__PURE__ */ jsx("span", { className: "mthds-simple-progress-toggle-spacer", "aria-hidden": "true" })
|
|
425
|
+
] }),
|
|
426
|
+
/* @__PURE__ */ jsx(BatchCounts, { line, strings }),
|
|
427
|
+
/* @__PURE__ */ jsx(HealthNotes, { line, item, strings }),
|
|
428
|
+
line.expanded && line.children.length > 0 && /* @__PURE__ */ jsx("ol", { className: "mthds-simple-progress-lines mthds-simple-progress-lines--nested", children: line.children.map((child) => /* @__PURE__ */ jsx(
|
|
429
|
+
LineView2,
|
|
430
|
+
{
|
|
431
|
+
line: child,
|
|
432
|
+
item: itemOfChild(line, child),
|
|
433
|
+
nowMs: followsClock(child) ? nowMs : null,
|
|
434
|
+
onToggle,
|
|
435
|
+
strings
|
|
436
|
+
},
|
|
437
|
+
child.key
|
|
438
|
+
)) })
|
|
439
|
+
] });
|
|
440
|
+
});
|
|
441
|
+
function runElapsedMs(progress, times, nowMs) {
|
|
442
|
+
const recorded = times.recorded;
|
|
443
|
+
if (!recorded) return null;
|
|
444
|
+
if (progress.status === RUN_PROGRESS_STATUS.RUNNING && nowMs !== null) {
|
|
445
|
+
return Math.max(0, Math.max(nowMs, recorded.endMs) - recorded.startMs);
|
|
446
|
+
}
|
|
447
|
+
return recorded.endMs - recorded.startMs;
|
|
448
|
+
}
|
|
449
|
+
function findLine(lines, key) {
|
|
450
|
+
for (const line of lines) {
|
|
451
|
+
if (line.key === key) return line;
|
|
452
|
+
}
|
|
453
|
+
return null;
|
|
454
|
+
}
|
|
455
|
+
function headlineOf(progress, elapsedMs, strings) {
|
|
456
|
+
var _a, _b, _c, _d;
|
|
457
|
+
let elapsed = null;
|
|
458
|
+
if (elapsedMs !== null) {
|
|
459
|
+
elapsed = progress.status === RUN_PROGRESS_STATUS.RUNNING ? strings.elapsed(elapsedMs) : strings.duration(elapsedMs);
|
|
460
|
+
}
|
|
461
|
+
const nothing = progress.lines.length === 0;
|
|
462
|
+
switch (progress.status) {
|
|
463
|
+
case RUN_PROGRESS_STATUS.PENDING:
|
|
464
|
+
return strings.waiting;
|
|
465
|
+
case RUN_PROGRESS_STATUS.SUCCEEDED:
|
|
466
|
+
return strings.done(elapsed);
|
|
467
|
+
case RUN_PROGRESS_STATUS.FAILED: {
|
|
468
|
+
if (nothing && elapsedMs === null) return strings.nothingRecorded;
|
|
469
|
+
const key = (_b = (_a = progress.failure) == null ? void 0 : _a.lineKey) != null ? _b : null;
|
|
470
|
+
const where = key === null ? null : (_d = (_c = findLine(progress.lines, key)) == null ? void 0 : _c.title) != null ? _d : null;
|
|
471
|
+
return strings.failed(where, elapsed);
|
|
472
|
+
}
|
|
473
|
+
case RUN_PROGRESS_STATUS.CANCELED:
|
|
474
|
+
if (nothing && elapsedMs === null) return strings.nothingRecorded;
|
|
475
|
+
return strings.canceled(elapsed);
|
|
476
|
+
case RUN_PROGRESS_STATUS.RUNNING:
|
|
477
|
+
return strings.working(elapsed);
|
|
478
|
+
default: {
|
|
479
|
+
const status = progress.status;
|
|
480
|
+
return elapsed === null ? status : `${status} \xB7 ${elapsed}`;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
function RunNoteView({ note, strings }) {
|
|
485
|
+
const degradation = note.degradation;
|
|
486
|
+
if (note.reason === SIMPLE_RUN_NOTE_REASON.UNREACHABLE) {
|
|
487
|
+
return /* @__PURE__ */ jsx(Note, { tone: "warning", children: /* @__PURE__ */ jsx("p", { role: "status", children: strings.unreachable }) });
|
|
488
|
+
}
|
|
489
|
+
if (note.reason === SIMPLE_RUN_NOTE_REASON.STUCK) {
|
|
490
|
+
return /* @__PURE__ */ jsxs(Note, { tone: "warning", children: [
|
|
491
|
+
/* @__PURE__ */ jsx("p", { role: "status", children: strings.runStuck(untilOf(degradation, strings)) }),
|
|
492
|
+
/* @__PURE__ */ jsx(Details, { label: strings.details, children: /* @__PURE__ */ jsx("p", { children: degradation.message }) })
|
|
493
|
+
] });
|
|
494
|
+
}
|
|
495
|
+
return /* @__PURE__ */ jsx(Note, { tone: "warning", children: /* @__PURE__ */ jsx("p", { role: "status", children: degradation.message }) });
|
|
496
|
+
}
|
|
497
|
+
function useAnnouncement(progress, stream, headline, strings) {
|
|
498
|
+
const [state, setState] = React3.useState({ stream, progress, message: "" });
|
|
499
|
+
if (state.progress === progress) return state.message;
|
|
500
|
+
let message = "";
|
|
501
|
+
if (state.stream === stream) {
|
|
502
|
+
const change = simpleProgressChanges(state.progress, progress);
|
|
503
|
+
const parts = [
|
|
504
|
+
...change.done.map(strings.announceDone),
|
|
505
|
+
...change.failed.map(strings.announceFailed),
|
|
506
|
+
...change.runEnded ? [strings.announceEnd(headline)] : change.started.map(strings.announceNow)
|
|
507
|
+
];
|
|
508
|
+
message = parts.length > 0 ? parts.join(" ") : state.message;
|
|
509
|
+
}
|
|
510
|
+
setState({ stream, progress, message });
|
|
511
|
+
return message;
|
|
512
|
+
}
|
|
513
|
+
function SimpleProgressView({
|
|
514
|
+
held,
|
|
515
|
+
stream,
|
|
516
|
+
times,
|
|
517
|
+
nowMs,
|
|
518
|
+
ticking,
|
|
519
|
+
expanded,
|
|
520
|
+
onToggle: toggle,
|
|
521
|
+
pipeRegistry,
|
|
522
|
+
entryPipeRef,
|
|
523
|
+
wideParallelThreshold,
|
|
524
|
+
containerClassName,
|
|
525
|
+
containerStyle,
|
|
526
|
+
headerEnd,
|
|
527
|
+
strings = DEFAULT_SIMPLE_PROGRESS_STRINGS
|
|
528
|
+
}) {
|
|
529
|
+
const progress = React3.useMemo(
|
|
530
|
+
() => buildSimpleProgress(held, {
|
|
531
|
+
pipeRegistry,
|
|
532
|
+
entryPipeRef,
|
|
533
|
+
expanded,
|
|
534
|
+
wideParallelThreshold
|
|
535
|
+
}),
|
|
536
|
+
[held, pipeRegistry, entryPipeRef, expanded, wideParallelThreshold]
|
|
537
|
+
);
|
|
538
|
+
const headline = headlineOf(progress, runElapsedMs(progress, times, nowMs), strings);
|
|
539
|
+
const failure = progress.failure;
|
|
540
|
+
const announcement = useAnnouncement(progress, stream, headline, strings);
|
|
541
|
+
const classes = [
|
|
542
|
+
containerClassName,
|
|
543
|
+
"mthds-simple-progress",
|
|
544
|
+
ticking && "mthds-run-timeline--self-clocked"
|
|
545
|
+
].filter(Boolean).join(" ");
|
|
546
|
+
return /* @__PURE__ */ jsxs(
|
|
547
|
+
"section",
|
|
548
|
+
{
|
|
549
|
+
className: classes,
|
|
550
|
+
style: containerStyle,
|
|
551
|
+
"aria-label": "Run progress",
|
|
552
|
+
"data-run-status": held.status,
|
|
553
|
+
"data-version": held.version,
|
|
554
|
+
children: [
|
|
555
|
+
/* @__PURE__ */ jsxs("header", { className: "mthds-run-timeline-header", children: [
|
|
556
|
+
/* @__PURE__ */ jsx(
|
|
557
|
+
"p",
|
|
558
|
+
{
|
|
559
|
+
className: `mthds-simple-progress-headline mthds-simple-progress-headline--${held.status}`,
|
|
560
|
+
"data-testid": "run-timeline-status",
|
|
561
|
+
children: headline
|
|
562
|
+
}
|
|
563
|
+
),
|
|
564
|
+
held.mode === PROGRESS_MODE.DRY && /* @__PURE__ */ jsx("span", { className: "mthds-run-timeline-mode", children: strings.dryRun }),
|
|
565
|
+
headerEnd
|
|
566
|
+
] }),
|
|
567
|
+
/* @__PURE__ */ jsx("p", { className: "mthds-run-timeline-sr", "aria-live": "polite", children: announcement }),
|
|
568
|
+
progress.retryAttempt !== null && /* @__PURE__ */ jsx(Note, { tone: "warning", children: /* @__PURE__ */ jsx("p", { children: strings.runTryingAgain(progress.retryAttempt) }) }),
|
|
569
|
+
progress.runNote && /* @__PURE__ */ jsx(RunNoteView, { note: progress.runNote, strings }),
|
|
570
|
+
(failure == null ? void 0 : failure.problem) && !failure.shownOnLine && /* @__PURE__ */ jsxs(Note, { tone: "error", children: [
|
|
571
|
+
/* @__PURE__ */ jsx("p", { children: failure.problem.title }),
|
|
572
|
+
/* @__PURE__ */ jsx(ProblemDetails, { problem: failure.problem, strings })
|
|
573
|
+
] }),
|
|
574
|
+
progress.lines.length > 0 && /* @__PURE__ */ jsx("ol", { className: "mthds-simple-progress-lines", "aria-label": strings.checklistLabel, children: progress.lines.map((line) => /* @__PURE__ */ jsx(
|
|
575
|
+
LineView,
|
|
576
|
+
{
|
|
577
|
+
line,
|
|
578
|
+
item: line.forEachItem,
|
|
579
|
+
nowMs: followsClock(line) ? nowMs : null,
|
|
580
|
+
onToggle: toggle,
|
|
581
|
+
strings
|
|
582
|
+
},
|
|
583
|
+
line.key
|
|
584
|
+
)) })
|
|
585
|
+
]
|
|
586
|
+
}
|
|
587
|
+
);
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// src/timeline/react/TimelineStyleMenu.tsx
|
|
591
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
592
|
+
var ICON_PROPS = {
|
|
593
|
+
viewBox: "0 0 24 24",
|
|
594
|
+
width: 14,
|
|
595
|
+
height: 14,
|
|
596
|
+
fill: "none",
|
|
597
|
+
stroke: "currentColor",
|
|
598
|
+
strokeWidth: 2,
|
|
599
|
+
strokeLinecap: "round",
|
|
600
|
+
strokeLinejoin: "round"
|
|
601
|
+
};
|
|
602
|
+
var TIMELINE_STYLE_MENU_ENTRIES = {
|
|
603
|
+
// Bars of different lengths on a shared axis.
|
|
604
|
+
[TIMELINE_STYLE.DETAILED]: __spreadProps(__spreadValues({}, TIMELINE_STYLES[TIMELINE_STYLE.DETAILED]), {
|
|
605
|
+
icon: /* @__PURE__ */ jsxs2("svg", __spreadProps(__spreadValues({}, ICON_PROPS), { children: [
|
|
606
|
+
/* @__PURE__ */ jsx2("line", { x1: "3", y1: "3", x2: "3", y2: "21" }),
|
|
607
|
+
/* @__PURE__ */ jsx2("line", { x1: "7", y1: "6", x2: "15", y2: "6" }),
|
|
608
|
+
/* @__PURE__ */ jsx2("line", { x1: "10", y1: "12", x2: "20", y2: "12" }),
|
|
609
|
+
/* @__PURE__ */ jsx2("line", { x1: "7", y1: "18", x2: "13", y2: "18" })
|
|
610
|
+
] }))
|
|
611
|
+
}),
|
|
612
|
+
// A checklist: a check, then lines of words.
|
|
613
|
+
[TIMELINE_STYLE.SIMPLE]: __spreadProps(__spreadValues({}, TIMELINE_STYLES[TIMELINE_STYLE.SIMPLE]), {
|
|
614
|
+
icon: /* @__PURE__ */ jsxs2("svg", __spreadProps(__spreadValues({}, ICON_PROPS), { children: [
|
|
615
|
+
/* @__PURE__ */ jsx2("polyline", { points: "3 6 5 8 8 4" }),
|
|
616
|
+
/* @__PURE__ */ jsx2("line", { x1: "12", y1: "6", x2: "21", y2: "6" }),
|
|
617
|
+
/* @__PURE__ */ jsx2("circle", { cx: "5.5", cy: "12", r: "2" }),
|
|
618
|
+
/* @__PURE__ */ jsx2("line", { x1: "12", y1: "12", x2: "21", y2: "12" }),
|
|
619
|
+
/* @__PURE__ */ jsx2("circle", { cx: "5.5", cy: "18", r: "2" }),
|
|
620
|
+
/* @__PURE__ */ jsx2("line", { x1: "12", y1: "18", x2: "21", y2: "18" })
|
|
621
|
+
] }))
|
|
622
|
+
})
|
|
623
|
+
};
|
|
624
|
+
function timelineStyleMenuLabel(style) {
|
|
625
|
+
return `Timeline style: ${TIMELINE_STYLES[style].name} \u2014 choose how the run is drawn`;
|
|
626
|
+
}
|
|
627
|
+
function TimelineStyleMenu({ value, options, onChange, slotRef }) {
|
|
628
|
+
return /* @__PURE__ */ jsx2("div", { className: "mthds-run-timeline-header-end", ref: slotRef, children: /* @__PURE__ */ jsx2(
|
|
629
|
+
StyleMenu,
|
|
630
|
+
{
|
|
631
|
+
value,
|
|
632
|
+
options,
|
|
633
|
+
onChange,
|
|
634
|
+
placement: "down-end",
|
|
635
|
+
entries: TIMELINE_STYLE_MENU_ENTRIES,
|
|
636
|
+
menuLabel: "Timeline style",
|
|
637
|
+
buttonLabel: timelineStyleMenuLabel,
|
|
638
|
+
buttonClassName: "mthds-run-timeline-style-btn"
|
|
639
|
+
}
|
|
640
|
+
) });
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
// src/timeline/react/RunTimeline.tsx
|
|
644
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
645
|
+
var CLOCK_TICK_MS = {
|
|
646
|
+
[TIMELINE_STYLE.DETAILED]: 250,
|
|
647
|
+
[TIMELINE_STYLE.SIMPLE]: 1e3
|
|
648
|
+
};
|
|
649
|
+
var TICK_RIGHT_ALIGN_PERCENT = 92;
|
|
650
|
+
var TICK_SPACING_PX = 64;
|
|
651
|
+
var DEFAULT_MAX_TICKS = 6;
|
|
652
|
+
function useTickBudget() {
|
|
653
|
+
const [budget, setBudget] = React4.useState(DEFAULT_MAX_TICKS);
|
|
654
|
+
const observer = React4.useRef(null);
|
|
655
|
+
const ref = React4.useCallback((element) => {
|
|
656
|
+
var _a;
|
|
657
|
+
(_a = observer.current) == null ? void 0 : _a.disconnect();
|
|
658
|
+
observer.current = null;
|
|
659
|
+
if (!element || typeof ResizeObserver === "undefined") return;
|
|
660
|
+
observer.current = new ResizeObserver((entries) => {
|
|
661
|
+
var _a2, _b;
|
|
662
|
+
const width = (_b = (_a2 = entries[0]) == null ? void 0 : _a2.contentRect.width) != null ? _b : 0;
|
|
663
|
+
if (width > 0) setBudget(Math.max(1, Math.floor(width / TICK_SPACING_PX)));
|
|
664
|
+
});
|
|
665
|
+
observer.current.observe(element);
|
|
666
|
+
}, []);
|
|
667
|
+
return [ref, budget];
|
|
668
|
+
}
|
|
669
|
+
var RUN_STATUS_WORD = {
|
|
670
|
+
pending: "Pending",
|
|
671
|
+
running: "Running",
|
|
672
|
+
succeeded: "Succeeded",
|
|
673
|
+
failed: "Failed",
|
|
674
|
+
canceled: "Canceled"
|
|
675
|
+
};
|
|
676
|
+
function wordFor(table, value) {
|
|
677
|
+
return Object.prototype.hasOwnProperty.call(table, value) ? table[value] : value;
|
|
678
|
+
}
|
|
106
679
|
function batchCountsText(batch) {
|
|
107
680
|
const counts = batch.counts;
|
|
108
681
|
if (!counts) return null;
|
|
@@ -150,16 +723,16 @@ function rowTitle(row, times, bar) {
|
|
|
150
723
|
if (isRetried(invocation)) lines.push(`Tried ${invocation.attempts} times`);
|
|
151
724
|
if (invocation.last_failure) {
|
|
152
725
|
const at = times.failedMs;
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
);
|
|
726
|
+
const { title, detail } = invocation.last_failure.problem;
|
|
727
|
+
lines.push(`Last failure${at === null ? "" : ` at ${formatClockTime(at)}`}: ${title}`);
|
|
728
|
+
lines.push(detail);
|
|
156
729
|
}
|
|
157
730
|
if (invocation.degradation) lines.push(`Not progressing: ${invocation.degradation.message}`);
|
|
158
731
|
return lines.join("\n");
|
|
159
732
|
}
|
|
160
733
|
function BatchStrip({ batch }) {
|
|
161
734
|
if (batch.strip.length === 0) return null;
|
|
162
|
-
return /* @__PURE__ */
|
|
735
|
+
return /* @__PURE__ */ jsx3("span", { className: "mthds-run-timeline-strip", "aria-hidden": "true", children: batch.strip.map((cell) => /* @__PURE__ */ jsx3(
|
|
163
736
|
"span",
|
|
164
737
|
{
|
|
165
738
|
className: `mthds-run-timeline-strip-cell mthds-run-timeline-strip-cell--${cell.status}`,
|
|
@@ -179,7 +752,7 @@ function FailureTick({ atMs, startMs, endMs }) {
|
|
|
179
752
|
if (atMs === null || atMs < startMs || atMs > endMs) return null;
|
|
180
753
|
const span = endMs - startMs;
|
|
181
754
|
const percent = span > 0 ? (atMs - startMs) / span * 100 : 0;
|
|
182
|
-
return /* @__PURE__ */
|
|
755
|
+
return /* @__PURE__ */ jsx3(
|
|
183
756
|
"span",
|
|
184
757
|
{
|
|
185
758
|
className: "mthds-run-timeline-failure-tick",
|
|
@@ -188,7 +761,7 @@ function FailureTick({ atMs, startMs, endMs }) {
|
|
|
188
761
|
}
|
|
189
762
|
);
|
|
190
763
|
}
|
|
191
|
-
var TimelineRowView =
|
|
764
|
+
var TimelineRowView = React4.memo(function TimelineRowView2({
|
|
192
765
|
row,
|
|
193
766
|
times,
|
|
194
767
|
axis,
|
|
@@ -221,7 +794,7 @@ var TimelineRowView = React.memo(function TimelineRowView2({
|
|
|
221
794
|
if (batch) {
|
|
222
795
|
toggleLabel = batch.expanded ? `Collapse the ${batch.total} items of ${invocation.pipe_code}` : `Expand the ${batch.total} items of ${invocation.pipe_code}`;
|
|
223
796
|
}
|
|
224
|
-
return /* @__PURE__ */
|
|
797
|
+
return /* @__PURE__ */ jsxs3(
|
|
225
798
|
"li",
|
|
226
799
|
{
|
|
227
800
|
className: rowClasses,
|
|
@@ -229,13 +802,13 @@ var TimelineRowView = React.memo(function TimelineRowView2({
|
|
|
229
802
|
"data-status": status,
|
|
230
803
|
title: rowTitle(row, times, bar),
|
|
231
804
|
children: [
|
|
232
|
-
/* @__PURE__ */
|
|
805
|
+
/* @__PURE__ */ jsxs3(
|
|
233
806
|
"div",
|
|
234
807
|
{
|
|
235
808
|
className: "mthds-run-timeline-name",
|
|
236
809
|
style: { paddingLeft: `calc(${row.depth} * var(--mthds-run-timeline-indent))` },
|
|
237
810
|
children: [
|
|
238
|
-
batch ? /* @__PURE__ */
|
|
811
|
+
batch ? /* @__PURE__ */ jsx3(
|
|
239
812
|
"button",
|
|
240
813
|
{
|
|
241
814
|
type: "button",
|
|
@@ -243,17 +816,17 @@ var TimelineRowView = React.memo(function TimelineRowView2({
|
|
|
243
816
|
"aria-expanded": batch.expanded,
|
|
244
817
|
"aria-label": toggleLabel,
|
|
245
818
|
onClick: () => onToggleBatch(row.path, !batch.expanded),
|
|
246
|
-
children: /* @__PURE__ */
|
|
819
|
+
children: /* @__PURE__ */ jsx3("span", { "aria-hidden": "true", children: batch.expanded ? "\u25BE" : "\u25B8" })
|
|
247
820
|
}
|
|
248
|
-
) : /* @__PURE__ */
|
|
249
|
-
/* @__PURE__ */
|
|
250
|
-
/* @__PURE__ */
|
|
251
|
-
row.placeLabel && /* @__PURE__ */
|
|
252
|
-
/* @__PURE__ */
|
|
821
|
+
) : /* @__PURE__ */ jsx3("span", { className: "mthds-run-timeline-toggle-spacer", "aria-hidden": "true" }),
|
|
822
|
+
/* @__PURE__ */ jsx3("span", { className: "mthds-run-timeline-dot", "aria-hidden": "true" }),
|
|
823
|
+
/* @__PURE__ */ jsx3("span", { className: "mthds-run-timeline-code", children: invocation.pipe_code }),
|
|
824
|
+
row.placeLabel && /* @__PURE__ */ jsx3("span", { className: "mthds-run-timeline-place", children: row.placeLabel }),
|
|
825
|
+
/* @__PURE__ */ jsx3("span", { className: "mthds-run-timeline-sr", children: `, ${status}` })
|
|
253
826
|
]
|
|
254
827
|
}
|
|
255
828
|
),
|
|
256
|
-
/* @__PURE__ */
|
|
829
|
+
/* @__PURE__ */ jsx3("div", { className: "mthds-run-timeline-track", children: bar && axis && /* @__PURE__ */ jsxs3(
|
|
257
830
|
"span",
|
|
258
831
|
{
|
|
259
832
|
className: barClasses,
|
|
@@ -262,19 +835,19 @@ var TimelineRowView = React.memo(function TimelineRowView2({
|
|
|
262
835
|
width: axisShare(drawnEndMs - drawnStartMs)
|
|
263
836
|
},
|
|
264
837
|
children: [
|
|
265
|
-
batch && /* @__PURE__ */
|
|
266
|
-
/* @__PURE__ */
|
|
838
|
+
batch && /* @__PURE__ */ jsx3(BatchStrip, { batch }),
|
|
839
|
+
/* @__PURE__ */ jsx3(FailureTick, { atMs: times.failedMs, startMs: drawnStartMs, endMs: drawnEndMs })
|
|
267
840
|
]
|
|
268
841
|
}
|
|
269
842
|
) }),
|
|
270
|
-
/* @__PURE__ */
|
|
271
|
-
retried && /* @__PURE__ */
|
|
272
|
-
/* @__PURE__ */
|
|
843
|
+
/* @__PURE__ */ jsxs3("div", { className: "mthds-run-timeline-meta", children: [
|
|
844
|
+
retried && /* @__PURE__ */ jsxs3("span", { className: "mthds-run-timeline-badge mthds-run-timeline-badge--retry", children: [
|
|
845
|
+
/* @__PURE__ */ jsx3("span", { "aria-hidden": "true", children: "\u21BB " }),
|
|
273
846
|
retrying ? `attempt ${invocation.attempts}` : `${invocation.attempts} attempts`
|
|
274
847
|
] }),
|
|
275
|
-
invocation.degradation && /* @__PURE__ */
|
|
276
|
-
batch && !batch.expanded && batch.hiddenItemCount > 0 && /* @__PURE__ */
|
|
277
|
-
/* @__PURE__ */
|
|
848
|
+
invocation.degradation && /* @__PURE__ */ jsx3("span", { className: "mthds-run-timeline-badge mthds-run-timeline-badge--stuck", children: "stuck" }),
|
|
849
|
+
batch && !batch.expanded && batch.hiddenItemCount > 0 && /* @__PURE__ */ jsx3("span", { className: "mthds-run-timeline-sr", children: `, ${batch.hiddenItemCount} items hidden` }),
|
|
850
|
+
/* @__PURE__ */ jsx3("span", { className: "mthds-run-timeline-detail", children: rowDetailText(row, bar) })
|
|
278
851
|
] })
|
|
279
852
|
]
|
|
280
853
|
}
|
|
@@ -287,36 +860,138 @@ function RunTimeline({
|
|
|
287
860
|
paletteColors,
|
|
288
861
|
now,
|
|
289
862
|
live = true,
|
|
863
|
+
timelineStyle,
|
|
864
|
+
onTimelineStyleChange,
|
|
865
|
+
styleMenu,
|
|
866
|
+
pipeRegistry,
|
|
867
|
+
entryPipeRef,
|
|
290
868
|
wideBatchThreshold,
|
|
869
|
+
wideParallelThreshold,
|
|
291
870
|
className
|
|
292
871
|
}) {
|
|
293
872
|
const held = useHeldSnapshot(snapshot);
|
|
294
873
|
const streamKey = progressStreamKey(held);
|
|
295
874
|
const environmentTheme = useSystemTheme(theme === GRAPH_THEME_MODE.SYSTEM ? systemTheme : theme);
|
|
296
875
|
const resolvedTheme = theme === GRAPH_THEME_MODE.SYSTEM ? environmentTheme : theme;
|
|
297
|
-
const paletteStyle =
|
|
876
|
+
const paletteStyle = React4.useMemo(
|
|
298
877
|
() => __spreadValues(__spreadValues({}, getPaletteForTheme(resolvedTheme)), paletteColors),
|
|
299
878
|
[resolvedTheme, paletteColors]
|
|
300
879
|
);
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
880
|
+
const containerClassName = [
|
|
881
|
+
"mthds-run-timeline",
|
|
882
|
+
`mthds-run-timeline--${resolvedTheme}`,
|
|
883
|
+
className
|
|
884
|
+
].filter(Boolean).join(" ");
|
|
885
|
+
const externalStyle = resolveTimelineStyle(timelineStyle);
|
|
886
|
+
const [styleState, setStyleState] = React4.useState({
|
|
887
|
+
external: externalStyle,
|
|
888
|
+
active: externalStyle
|
|
889
|
+
});
|
|
890
|
+
if (styleState.external !== externalStyle) {
|
|
891
|
+
setStyleState({ external: externalStyle, active: externalStyle });
|
|
892
|
+
}
|
|
893
|
+
const activeStyle = styleState.external === externalStyle ? styleState.active : externalStyle;
|
|
894
|
+
const onTimelineStyleChangeRef = React4.useRef(onTimelineStyleChange);
|
|
895
|
+
onTimelineStyleChangeRef.current = onTimelineStyleChange;
|
|
896
|
+
const reportedStyleRef = React4.useRef(activeStyle);
|
|
897
|
+
React4.useEffect(() => {
|
|
898
|
+
var _a;
|
|
899
|
+
if (reportedStyleRef.current !== activeStyle) {
|
|
900
|
+
reportedStyleRef.current = activeStyle;
|
|
901
|
+
(_a = onTimelineStyleChangeRef.current) == null ? void 0 : _a.call(onTimelineStyleChangeRef, activeStyle);
|
|
902
|
+
}
|
|
903
|
+
}, [activeStyle]);
|
|
904
|
+
const styleMenuOptions = React4.useMemo(() => resolveTimelineStyleMenu(styleMenu), [styleMenu]);
|
|
905
|
+
const menuSlotRef = React4.useRef(null);
|
|
906
|
+
const refocusMenuRef = React4.useRef(false);
|
|
907
|
+
const chooseStyle = React4.useCallback((style) => {
|
|
908
|
+
refocusMenuRef.current = true;
|
|
909
|
+
setStyleState((state) => __spreadProps(__spreadValues({}, state), { active: style }));
|
|
910
|
+
}, []);
|
|
911
|
+
React4.useEffect(() => {
|
|
912
|
+
var _a, _b;
|
|
913
|
+
if (!refocusMenuRef.current) return;
|
|
914
|
+
refocusMenuRef.current = false;
|
|
915
|
+
(_b = (_a = menuSlotRef.current) == null ? void 0 : _a.querySelector("button")) == null ? void 0 : _b.focus();
|
|
916
|
+
}, [styleState]);
|
|
917
|
+
const headerEnd = styleMenuOptions.length > 0 ? /* @__PURE__ */ jsx3(
|
|
918
|
+
TimelineStyleMenu,
|
|
919
|
+
{
|
|
920
|
+
value: activeStyle,
|
|
921
|
+
options: styleMenuOptions,
|
|
922
|
+
onChange: chooseStyle,
|
|
923
|
+
slotRef: menuSlotRef
|
|
924
|
+
}
|
|
925
|
+
) : null;
|
|
926
|
+
const times = React4.useMemo(() => snapshotTimes(held), [held]);
|
|
927
|
+
const followsClock2 = React4.useMemo(
|
|
928
|
+
() => held.invocations.some(
|
|
929
|
+
(invocation) => barFollowsClock(invocation, times.invocations.get(invocation.path))
|
|
930
|
+
),
|
|
931
|
+
[held, times]
|
|
313
932
|
);
|
|
314
|
-
const
|
|
933
|
+
const clock = useReadingClock(held, streamKey, {
|
|
934
|
+
now,
|
|
935
|
+
live,
|
|
936
|
+
followsClock: followsClock2,
|
|
937
|
+
tickMs: CLOCK_TICK_MS[activeStyle]
|
|
938
|
+
});
|
|
939
|
+
const detailedExpansion = useStreamExpansion(streamKey);
|
|
940
|
+
const simpleExpansion = useStreamExpansion(streamKey);
|
|
941
|
+
const views = {
|
|
942
|
+
[TIMELINE_STYLE.SIMPLE]: () => /* @__PURE__ */ jsx3(
|
|
943
|
+
SimpleProgressView,
|
|
944
|
+
{
|
|
945
|
+
held,
|
|
946
|
+
stream: streamKey,
|
|
947
|
+
times,
|
|
948
|
+
nowMs: clock.nowMs,
|
|
949
|
+
ticking: clock.ticking,
|
|
950
|
+
expanded: simpleExpansion.expanded,
|
|
951
|
+
onToggle: simpleExpansion.toggle,
|
|
952
|
+
pipeRegistry,
|
|
953
|
+
entryPipeRef,
|
|
954
|
+
wideParallelThreshold,
|
|
955
|
+
containerClassName,
|
|
956
|
+
containerStyle: paletteStyle,
|
|
957
|
+
headerEnd
|
|
958
|
+
}
|
|
959
|
+
),
|
|
960
|
+
[TIMELINE_STYLE.DETAILED]: () => /* @__PURE__ */ jsx3(
|
|
961
|
+
DetailedTimeline,
|
|
962
|
+
{
|
|
963
|
+
held,
|
|
964
|
+
times,
|
|
965
|
+
nowMs: clock.nowMs,
|
|
966
|
+
ticking: clock.ticking,
|
|
967
|
+
expandedBatches: detailedExpansion.expanded,
|
|
968
|
+
onToggleBatch: detailedExpansion.toggle,
|
|
969
|
+
wideBatchThreshold,
|
|
970
|
+
containerClassName,
|
|
971
|
+
containerStyle: paletteStyle,
|
|
972
|
+
headerEnd
|
|
973
|
+
}
|
|
974
|
+
)
|
|
975
|
+
};
|
|
976
|
+
return views[activeStyle]();
|
|
977
|
+
}
|
|
978
|
+
function DetailedTimeline({
|
|
979
|
+
held,
|
|
980
|
+
times,
|
|
981
|
+
nowMs,
|
|
982
|
+
ticking,
|
|
983
|
+
expandedBatches,
|
|
984
|
+
onToggleBatch: toggleBatch,
|
|
985
|
+
wideBatchThreshold,
|
|
986
|
+
containerClassName,
|
|
987
|
+
containerStyle,
|
|
988
|
+
headerEnd
|
|
989
|
+
}) {
|
|
990
|
+
const rows = React4.useMemo(
|
|
315
991
|
() => buildTimelineRows(held, { expandedBatches, wideBatchThreshold }),
|
|
316
992
|
[held, expandedBatches, wideBatchThreshold]
|
|
317
993
|
);
|
|
318
|
-
const
|
|
319
|
-
const drawnRows = React.useMemo(
|
|
994
|
+
const drawnRows = React4.useMemo(
|
|
320
995
|
() => rows.map((row) => {
|
|
321
996
|
var _a;
|
|
322
997
|
const rowTimes = (_a = times.invocations.get(row.path)) != null ? _a : invocationTimes(row.invocation);
|
|
@@ -324,29 +999,22 @@ function RunTimeline({
|
|
|
324
999
|
}),
|
|
325
1000
|
[rows, times]
|
|
326
1001
|
);
|
|
327
|
-
const clockFollowed = drawnRows.some((drawn) => drawn.followsClock);
|
|
328
|
-
const { nowMs, ticking } = useReadingClock(held, streamKey, now, live, clockFollowed);
|
|
329
1002
|
const axis = timelineWindowAt(times, nowMs);
|
|
330
1003
|
const [axisTrackRef, tickBudget] = useTickBudget();
|
|
331
1004
|
const ticks = axis ? timelineTicks(axis, tickBudget) : [];
|
|
332
1005
|
const bodyStyle = axis ? { [AXIS_SPAN_VAR]: cssNumber(axis.endMs - axis.startMs) } : void 0;
|
|
333
|
-
const containerClasses = [
|
|
334
|
-
|
|
335
|
-
`mthds-run-timeline--${resolvedTheme}`,
|
|
336
|
-
ticking && "mthds-run-timeline--self-clocked",
|
|
337
|
-
className
|
|
338
|
-
].filter(Boolean).join(" ");
|
|
339
|
-
return /* @__PURE__ */ jsxs(
|
|
1006
|
+
const containerClasses = [containerClassName, ticking && "mthds-run-timeline--self-clocked"].filter(Boolean).join(" ");
|
|
1007
|
+
return /* @__PURE__ */ jsxs3(
|
|
340
1008
|
"section",
|
|
341
1009
|
{
|
|
342
1010
|
className: containerClasses,
|
|
343
|
-
style:
|
|
1011
|
+
style: containerStyle,
|
|
344
1012
|
"aria-label": "Run progress",
|
|
345
1013
|
"data-run-status": held.status,
|
|
346
1014
|
"data-version": held.version,
|
|
347
1015
|
children: [
|
|
348
|
-
/* @__PURE__ */
|
|
349
|
-
/* @__PURE__ */
|
|
1016
|
+
/* @__PURE__ */ jsxs3("header", { className: "mthds-run-timeline-header", children: [
|
|
1017
|
+
/* @__PURE__ */ jsx3(
|
|
350
1018
|
"span",
|
|
351
1019
|
{
|
|
352
1020
|
className: `mthds-run-timeline-status mthds-run-timeline-status--${held.status}`,
|
|
@@ -354,18 +1022,19 @@ function RunTimeline({
|
|
|
354
1022
|
children: wordFor(RUN_STATUS_WORD, held.status)
|
|
355
1023
|
}
|
|
356
1024
|
),
|
|
357
|
-
held.mode === PROGRESS_MODE.DRY && /* @__PURE__ */
|
|
358
|
-
/* @__PURE__ */
|
|
1025
|
+
held.mode === PROGRESS_MODE.DRY && /* @__PURE__ */ jsx3("span", { className: "mthds-run-timeline-mode", children: "Dry run" }),
|
|
1026
|
+
/* @__PURE__ */ jsx3("p", { className: "mthds-run-timeline-summary", "aria-live": "polite", children: held.summary }),
|
|
1027
|
+
headerEnd
|
|
359
1028
|
] }),
|
|
360
|
-
held.degradation && /* @__PURE__ */
|
|
1029
|
+
held.degradation && /* @__PURE__ */ jsx3("p", { className: "mthds-run-timeline-degradation", role: "status", children: held.degradation.message }),
|
|
361
1030
|
rows.length === 0 ? (
|
|
362
1031
|
// A run that ended with nothing to draw, failed or canceled before its
|
|
363
1032
|
// first invocation started, is waiting for nothing.
|
|
364
|
-
/* @__PURE__ */
|
|
365
|
-
) : /* @__PURE__ */
|
|
366
|
-
axis && /* @__PURE__ */
|
|
367
|
-
/* @__PURE__ */
|
|
368
|
-
/* @__PURE__ */
|
|
1033
|
+
/* @__PURE__ */ jsx3("p", { className: "mthds-run-timeline-empty", children: isRunEnded(held.status) ? "No progress was recorded." : "Nothing has started yet." })
|
|
1034
|
+
) : /* @__PURE__ */ jsxs3("div", { className: "mthds-run-timeline-body", style: bodyStyle, children: [
|
|
1035
|
+
axis && /* @__PURE__ */ jsxs3("div", { className: "mthds-run-timeline-axis", "aria-hidden": "true", children: [
|
|
1036
|
+
/* @__PURE__ */ jsx3("span", { className: "mthds-run-timeline-axis-spacer" }),
|
|
1037
|
+
/* @__PURE__ */ jsx3("span", { className: "mthds-run-timeline-axis-track", ref: axisTrackRef, children: ticks.map((tick) => /* @__PURE__ */ jsx3(
|
|
369
1038
|
"span",
|
|
370
1039
|
{
|
|
371
1040
|
className: [
|
|
@@ -378,15 +1047,15 @@ function RunTimeline({
|
|
|
378
1047
|
},
|
|
379
1048
|
tick.offsetMs
|
|
380
1049
|
)) }),
|
|
381
|
-
/* @__PURE__ */
|
|
1050
|
+
/* @__PURE__ */ jsx3("span", { className: "mthds-run-timeline-axis-spacer" })
|
|
382
1051
|
] }),
|
|
383
|
-
/* @__PURE__ */
|
|
1052
|
+
/* @__PURE__ */ jsx3("ol", { className: "mthds-run-timeline-rows", children: drawnRows.map(({ row, times: rowTimes, followsClock: followsClock2 }) => /* @__PURE__ */ jsx3(
|
|
384
1053
|
TimelineRowView,
|
|
385
1054
|
{
|
|
386
1055
|
row,
|
|
387
1056
|
times: rowTimes,
|
|
388
|
-
axis:
|
|
389
|
-
nowMs:
|
|
1057
|
+
axis: followsClock2 ? axis : times.recorded,
|
|
1058
|
+
nowMs: followsClock2 ? nowMs : null,
|
|
390
1059
|
onToggleBatch: toggleBatch
|
|
391
1060
|
},
|
|
392
1061
|
row.path
|