@workflow/web 5.3.0 → 5.3.2
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 +11 -34
- package/build/client/assets/app-BHCSMHev.css +1 -0
- package/build/client/assets/{arrow-up-right-CNHh1bh2.js → arrow-up-right-DyaB_ak4.js} +1 -1
- package/build/client/assets/{entry.client-DDsh88VE.js → entry.client-xzxVCL3o.js} +1 -1
- package/build/client/assets/{highlighted-body-JLMTFACH-CWHg5f-6.js → highlighted-body-JLMTFACH-1yzOVKg0.js} +2 -2
- package/build/client/assets/{home-DZqYMSiD.js → home--wf0CrF6.js} +5 -3
- package/build/client/assets/{index-BS6T0Zjc.js → index-wl5l5E8H.js} +30 -25
- package/build/client/assets/manifest-7b81d8d4.js +1 -0
- package/build/client/assets/{mermaid-WFAXDIZX-BLO7Z8RE.js → mermaid-WFAXDIZX-CB__BxYb.js} +272 -2736
- package/build/client/assets/meta-9cjJ0pVb.js +6 -0
- package/build/client/assets/{root-wdKzRZGT.js → root-C1XwTNUK.js} +14 -8
- package/build/client/assets/root-C3ED6Dwc.css +1 -0
- package/build/client/assets/rpc-client-SbyXJdFV.js +2482 -0
- package/build/client/assets/{run-detail-DyXpnv9C.js → run-detail-2CnpdXm1.js} +426 -618
- package/build/client/assets/run-usage-C3aywyqa.js +33 -0
- package/build/client/assets/run-usage-DRV6lopZ.js +1261 -0
- package/build/client/assets/skeleton-DMLgjvZZ.js +94 -0
- package/build/client/assets/{url-state-DhOv2zv0.js → url-state-JAVaNZ_m.js} +79 -159
- package/build/client/assets/{zstd-browser-decoder-BNeg7hxG.js → zstd-browser-decoder-Z5736ep5.js} +2 -2
- package/build/server/assets/{app-CR0ndNHl.js → app-C4Vf0mu1.js} +2399 -494
- package/build/server/assets/{highlighted-body-JLMTFACH-j-e-XD1V.js → highlighted-body-JLMTFACH-CF_5tt3-.js} +1 -1
- package/build/server/assets/{index-BZ4PHwlc.js → index-BrYeW--s.js} +4 -4
- package/build/server/assets/{mermaid-WFAXDIZX-B19UvP0H.js → mermaid-WFAXDIZX-BHZz_uL6.js} +1 -1
- package/build/server/assets/{token-CPc7to8F.js → token-B94O3LuJ.js} +1 -1
- package/build/server/assets/{token-LLLE1g03.js → token-k0na1G9v.js} +2 -2
- package/build/server/assets/{token-util-CIYqGbhA.js → token-util-DFlzY9Hw.js} +2 -2
- package/build/server/assets/{token-util-D91uzxKb.js → token-util-DgTmPzWb.js} +1 -1
- package/build/server/assets/{wrapper-BKFP-Nku.js → wrapper-BEqyNEir.js} +2 -2
- package/build/server/assets/{zstd-browser-decoder-B228nPFT.js → zstd-browser-decoder-LnaKiDUZ.js} +1 -1
- package/build/server/index.js +1 -1
- package/handler.d.ts +9 -0
- package/handler.js +16 -2
- package/host-guard.js +179 -0
- package/package.json +8 -7
- package/server.d.ts +15 -1
- package/server.js +14 -1
- package/build/client/assets/app-BE8uqS_d.css +0 -1
- package/build/client/assets/manifest-f2e93220.js +0 -1
- package/build/client/assets/root-BBptRWmF.css +0 -1
|
@@ -0,0 +1,1261 @@
|
|
|
1
|
+
import { r as reactExports, j as jsxRuntimeExports, L as Link } from "./index-wl5l5E8H.js";
|
|
2
|
+
import { c as createLucideIcon, a as cn, u as useRowWindow, i as isSpanDimmedBySearch, b as ROW_HEIGHT_PX, T as Tooltip, d as TooltipTrigger, e as TooltipContent, g as getSpanDurationMs, f as isSpanErrored, h as isSpanCancelled, j as formatDurationPrecise, B as Button, C as ChevronRight } from "./mermaid-WFAXDIZX-CB__BxYb.js";
|
|
3
|
+
import { f as formatStepName, p as parseStepName, a as parseWorkflowName, C as Circle, b as CircleAlert, R as RotateCw, S as Skeleton } from "./skeleton-DMLgjvZZ.js";
|
|
4
|
+
import { A as ArrowUpRight } from "./arrow-up-right-DyaB_ak4.js";
|
|
5
|
+
/**
|
|
6
|
+
* @license lucide-react v0.575.0 - ISC
|
|
7
|
+
*
|
|
8
|
+
* This source code is licensed under the ISC license.
|
|
9
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
10
|
+
*/
|
|
11
|
+
const __iconNode = [
|
|
12
|
+
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
13
|
+
["path", { d: "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3", key: "1u773s" }],
|
|
14
|
+
["path", { d: "M12 17h.01", key: "p32p05" }]
|
|
15
|
+
];
|
|
16
|
+
const CircleQuestionMark = createLucideIcon("circle-question-mark", __iconNode);
|
|
17
|
+
const USAGE_DOCS_URL = "https://workflow-sdk.dev/docs/observability/usage";
|
|
18
|
+
const USAGE_SPANS_SHOWN = 5;
|
|
19
|
+
const RUN_USAGE_ENTITIES = [
|
|
20
|
+
"run",
|
|
21
|
+
"step",
|
|
22
|
+
"hook",
|
|
23
|
+
"stream"
|
|
24
|
+
];
|
|
25
|
+
const RUN_USAGE_RUN_EVENT_TYPES = [
|
|
26
|
+
"created",
|
|
27
|
+
"started",
|
|
28
|
+
"completed",
|
|
29
|
+
"failed",
|
|
30
|
+
"cancelled"
|
|
31
|
+
];
|
|
32
|
+
function plural(count, one, many) {
|
|
33
|
+
return `${count.toLocaleString("en-US")} ${count === 1 ? one : many}`;
|
|
34
|
+
}
|
|
35
|
+
function usageSpanLabel(span) {
|
|
36
|
+
var _a, _b;
|
|
37
|
+
if (span.kind === "step") {
|
|
38
|
+
return ((_a = parseStepName(span.name)) == null ? void 0 : _a.shortName) || span.name;
|
|
39
|
+
}
|
|
40
|
+
if (span.kind === "run") {
|
|
41
|
+
return ((_b = parseWorkflowName(span.name)) == null ? void 0 : _b.shortName) || span.name;
|
|
42
|
+
}
|
|
43
|
+
return span.name;
|
|
44
|
+
}
|
|
45
|
+
function formatUsageEvents(count) {
|
|
46
|
+
return plural(count, "event", "events");
|
|
47
|
+
}
|
|
48
|
+
function formatUsageBytes(bytes) {
|
|
49
|
+
const units = ["B", "KB", "MB", "GB", "TB"];
|
|
50
|
+
let value = Math.max(0, bytes);
|
|
51
|
+
let unit = 0;
|
|
52
|
+
while (value >= 1e3 && unit < units.length - 1) {
|
|
53
|
+
value /= 1e3;
|
|
54
|
+
unit++;
|
|
55
|
+
}
|
|
56
|
+
if (unit === 0)
|
|
57
|
+
return `${Math.round(value)} B`;
|
|
58
|
+
const digits = value >= 100 ? 0 : value >= 10 ? 1 : 2;
|
|
59
|
+
return `${Number(value.toFixed(digits))} ${units[unit]}`;
|
|
60
|
+
}
|
|
61
|
+
function formatUsageShare(share) {
|
|
62
|
+
if (share > 0 && share < 0.01)
|
|
63
|
+
return "<1%";
|
|
64
|
+
return `${Math.round(share * 100)}%`;
|
|
65
|
+
}
|
|
66
|
+
function formatCount(count, one, many) {
|
|
67
|
+
return plural(count, one, many);
|
|
68
|
+
}
|
|
69
|
+
function formatOtherSteps(steps) {
|
|
70
|
+
return `+ ${steps.toLocaleString("en-US")} other ${steps === 1 ? "step" : "steps"}`;
|
|
71
|
+
}
|
|
72
|
+
function formatDataWrittenHeading(usage) {
|
|
73
|
+
return usage.billed ? "Storage" : "Storage (local)";
|
|
74
|
+
}
|
|
75
|
+
function formatLocalDataWrittenNote(usage) {
|
|
76
|
+
if (usage.billed)
|
|
77
|
+
return null;
|
|
78
|
+
return "The bytes of the run's payloads as the SDK sent them, plus the bytes it wrote to streams, counted the way Vercel counts Data Written. It doesn't include QuickJS VM snapshots or a dynamic workflow's code.";
|
|
79
|
+
}
|
|
80
|
+
function formatUsageFooter(usage) {
|
|
81
|
+
return usage.billed ? "Not your final bill." : "Local runs aren't billed. Counted from this run's log in your local data directory.";
|
|
82
|
+
}
|
|
83
|
+
const RUN_EVENT_LABELS = {
|
|
84
|
+
created: "created",
|
|
85
|
+
started: "started",
|
|
86
|
+
completed: "completed",
|
|
87
|
+
failed: "failed",
|
|
88
|
+
cancelled: "cancelled"
|
|
89
|
+
};
|
|
90
|
+
function formatRunEventsLine(usage) {
|
|
91
|
+
const { events, byType } = usage.runEvents;
|
|
92
|
+
if (events <= 0)
|
|
93
|
+
return null;
|
|
94
|
+
const parts = RUN_USAGE_RUN_EVENT_TYPES.flatMap((type) => byType[type] > 0 ? [`${byType[type].toLocaleString("en-US")} ${RUN_EVENT_LABELS[type]}`] : []);
|
|
95
|
+
const known = RUN_USAGE_RUN_EVENT_TYPES.reduce((n, t) => n + byType[t], 0);
|
|
96
|
+
if (events > known) {
|
|
97
|
+
parts.push(`${(events - known).toLocaleString("en-US")} other`);
|
|
98
|
+
}
|
|
99
|
+
const sofar = usage.inProgress ? " so far" : "";
|
|
100
|
+
return `The run wrote ${formatUsageEvents(events)}${sofar}: ${parts.join(", ")}.`;
|
|
101
|
+
}
|
|
102
|
+
function formatDataPurgedNote(usage) {
|
|
103
|
+
if (!usage.dataPurged)
|
|
104
|
+
return null;
|
|
105
|
+
return usage.dataWritten.source === "saved-at-purge" ? "This run's data was deleted; sizes show what it wrote." : "This run's data was deleted before its sizes were kept; sizes show what is left.";
|
|
106
|
+
}
|
|
107
|
+
const USAGE_ROW_TYPES = [
|
|
108
|
+
"steps",
|
|
109
|
+
"hooks",
|
|
110
|
+
"attributes",
|
|
111
|
+
"sleeps",
|
|
112
|
+
"run",
|
|
113
|
+
"other"
|
|
114
|
+
];
|
|
115
|
+
const USAGE_ROW_TYPE_LABELS = {
|
|
116
|
+
steps: "Steps",
|
|
117
|
+
hooks: "Hooks",
|
|
118
|
+
attributes: "Attributes",
|
|
119
|
+
sleeps: "Sleeps",
|
|
120
|
+
run: "Run",
|
|
121
|
+
other: "Other events"
|
|
122
|
+
};
|
|
123
|
+
const SPAN_KIND_OF_ROW_TYPE = {
|
|
124
|
+
steps: "step",
|
|
125
|
+
hooks: "hook",
|
|
126
|
+
attributes: "attributes",
|
|
127
|
+
sleeps: "wait",
|
|
128
|
+
run: "run",
|
|
129
|
+
other: "other"
|
|
130
|
+
};
|
|
131
|
+
function usageRows(usage, limit = USAGE_SPANS_SHOWN) {
|
|
132
|
+
const runNote = formatRunEventsLine(usage) ?? void 0;
|
|
133
|
+
return USAGE_ROW_TYPES.flatMap((type) => {
|
|
134
|
+
const spans = usage.eventsBySpan.filter((span) => span.kind === SPAN_KIND_OF_ROW_TYPE[type]);
|
|
135
|
+
if (spans.length === 0)
|
|
136
|
+
return [];
|
|
137
|
+
const total = sumRows(spans);
|
|
138
|
+
const group = {
|
|
139
|
+
type,
|
|
140
|
+
key: type,
|
|
141
|
+
events: total.events,
|
|
142
|
+
share: total.share,
|
|
143
|
+
retries: total.retries,
|
|
144
|
+
calls: type === "hooks" ? spans.length : total.calls,
|
|
145
|
+
children: [],
|
|
146
|
+
otherChildren: null,
|
|
147
|
+
...type === "run" && runNote ? { note: runNote } : {}
|
|
148
|
+
};
|
|
149
|
+
if (type !== "steps" && type !== "hooks")
|
|
150
|
+
return [group];
|
|
151
|
+
const { shown, other } = collapseUsageSpans(spans, limit);
|
|
152
|
+
group.children = childRowsOf(shown);
|
|
153
|
+
group.otherChildren = other && {
|
|
154
|
+
key: `${type}:other`,
|
|
155
|
+
count: other.spans,
|
|
156
|
+
label: type === "steps" ? formatOtherSteps(other.spans) : `+ ${other.spans.toLocaleString("en-US")} other ${other.spans === 1 ? "hook" : "hooks"}`,
|
|
157
|
+
events: other.events,
|
|
158
|
+
share: other.share,
|
|
159
|
+
retries: other.retries,
|
|
160
|
+
calls: other.calls
|
|
161
|
+
};
|
|
162
|
+
return [group];
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
function sumRows(spans) {
|
|
166
|
+
return spans.reduce((sum, span) => ({
|
|
167
|
+
events: sum.events + span.events,
|
|
168
|
+
share: sum.share + span.share,
|
|
169
|
+
retries: sum.retries + span.retries,
|
|
170
|
+
calls: sum.calls + span.calls
|
|
171
|
+
}), { events: 0, share: 0, retries: 0, calls: 0 });
|
|
172
|
+
}
|
|
173
|
+
function childRowsOf(spans) {
|
|
174
|
+
const labels = spans.map((span) => usageSpanLabel(span));
|
|
175
|
+
const seen = /* @__PURE__ */ new Map();
|
|
176
|
+
for (const label of labels)
|
|
177
|
+
seen.set(label, (seen.get(label) ?? 0) + 1);
|
|
178
|
+
return spans.map((span, i) => ({
|
|
179
|
+
key: span.kind === "hook" ? span.id ?? span.name : span.name,
|
|
180
|
+
label: (seen.get(labels[i]) ?? 0) > 1 ? span.kind === "step" ? formatStepName(span.name) : `${labels[i]} (${span.id ?? span.name})` : labels[i],
|
|
181
|
+
events: span.events,
|
|
182
|
+
share: span.share,
|
|
183
|
+
retries: span.retries,
|
|
184
|
+
calls: span.calls
|
|
185
|
+
}));
|
|
186
|
+
}
|
|
187
|
+
function collapseUsageSpans(spans, limit = USAGE_SPANS_SHOWN) {
|
|
188
|
+
if (spans.length <= limit + 1)
|
|
189
|
+
return { shown: spans, other: null };
|
|
190
|
+
const rest = spans.slice(limit);
|
|
191
|
+
return {
|
|
192
|
+
shown: spans.slice(0, limit),
|
|
193
|
+
other: {
|
|
194
|
+
spans: rest.length,
|
|
195
|
+
events: rest.reduce((sum, span) => sum + span.events, 0),
|
|
196
|
+
share: rest.reduce((sum, span) => sum + span.share, 0),
|
|
197
|
+
retries: rest.reduce((sum, span) => sum + span.retries, 0),
|
|
198
|
+
calls: rest.reduce((sum, span) => sum + span.calls, 0)
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
const ELLIPSIS = "…";
|
|
203
|
+
const MIN_START = 3;
|
|
204
|
+
const MIN_END = 3;
|
|
205
|
+
const MIN_KEPT = MIN_START + MIN_END;
|
|
206
|
+
const graphemeSegmenter = typeof Intl !== "undefined" && "Segmenter" in Intl ? new Intl.Segmenter(void 0, { granularity: "grapheme" }) : null;
|
|
207
|
+
function toGraphemes(text) {
|
|
208
|
+
if (graphemeSegmenter) {
|
|
209
|
+
return [...graphemeSegmenter.segment(text)].map((s) => s.segment);
|
|
210
|
+
}
|
|
211
|
+
return Array.from(text);
|
|
212
|
+
}
|
|
213
|
+
function buildCandidate(graphemes, kept) {
|
|
214
|
+
if (kept <= 0) {
|
|
215
|
+
return {
|
|
216
|
+
prefixText: "",
|
|
217
|
+
prefixGraphemeCount: 0,
|
|
218
|
+
suffixText: "",
|
|
219
|
+
suffixGraphemeCount: 0,
|
|
220
|
+
text: ELLIPSIS,
|
|
221
|
+
truncated: true
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
const suffixGraphemeCount = kept >= MIN_KEPT ? Math.max(MIN_END, Math.floor(kept / 2)) : Math.floor(kept / 2);
|
|
225
|
+
const prefixGraphemeCount = kept - suffixGraphemeCount;
|
|
226
|
+
const prefixText = graphemes.slice(0, prefixGraphemeCount).join("");
|
|
227
|
+
const suffixText = suffixGraphemeCount > 0 ? graphemes.slice(-suffixGraphemeCount).join("") : "";
|
|
228
|
+
return {
|
|
229
|
+
prefixText,
|
|
230
|
+
prefixGraphemeCount,
|
|
231
|
+
suffixText,
|
|
232
|
+
suffixGraphemeCount,
|
|
233
|
+
text: prefixText + ELLIPSIS + suffixText,
|
|
234
|
+
truncated: true
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
function middleTruncate(graphemes, availableWidth, measure, fullWidth) {
|
|
238
|
+
const fullText = graphemes.join("");
|
|
239
|
+
const resolvedFullWidth = fullWidth ?? measure(fullText);
|
|
240
|
+
if (availableWidth <= 0 || graphemes.length === 0) {
|
|
241
|
+
return {
|
|
242
|
+
prefixText: fullText,
|
|
243
|
+
prefixGraphemeCount: graphemes.length,
|
|
244
|
+
suffixText: "",
|
|
245
|
+
suffixGraphemeCount: 0,
|
|
246
|
+
text: fullText,
|
|
247
|
+
truncated: false
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
if (resolvedFullWidth <= availableWidth) {
|
|
251
|
+
return {
|
|
252
|
+
prefixText: fullText,
|
|
253
|
+
prefixGraphemeCount: graphemes.length,
|
|
254
|
+
suffixText: "",
|
|
255
|
+
suffixGraphemeCount: 0,
|
|
256
|
+
text: fullText,
|
|
257
|
+
truncated: false
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
let lo = 0;
|
|
261
|
+
let hi = graphemes.length - 1;
|
|
262
|
+
let best = -1;
|
|
263
|
+
while (lo <= hi) {
|
|
264
|
+
const mid = lo + hi >>> 1;
|
|
265
|
+
const candidate = buildCandidate(graphemes, mid);
|
|
266
|
+
if (measure(candidate.text) <= availableWidth) {
|
|
267
|
+
best = mid;
|
|
268
|
+
lo = mid + 1;
|
|
269
|
+
} else {
|
|
270
|
+
hi = mid - 1;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
if (best === -1) {
|
|
274
|
+
return {
|
|
275
|
+
prefixText: "",
|
|
276
|
+
prefixGraphemeCount: 0,
|
|
277
|
+
suffixText: "",
|
|
278
|
+
suffixGraphemeCount: 0,
|
|
279
|
+
text: "",
|
|
280
|
+
truncated: true
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
return buildCandidate(graphemes, best);
|
|
284
|
+
}
|
|
285
|
+
function getMiddleTruncateCopyText({ prefixText, selectionEnd, selectionStart, suffixText, value }) {
|
|
286
|
+
const visibleText = prefixText + ELLIPSIS + suffixText;
|
|
287
|
+
if (selectionStart < 0 || selectionEnd > visibleText.length || selectionStart >= selectionEnd) {
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
if (selectionStart === 0 && selectionEnd === visibleText.length) {
|
|
291
|
+
return value;
|
|
292
|
+
}
|
|
293
|
+
const ellipsisStart = prefixText.length;
|
|
294
|
+
const ellipsisEnd = ellipsisStart + ELLIPSIS.length;
|
|
295
|
+
if (selectionStart > ellipsisStart || selectionEnd < ellipsisEnd) {
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
const originalGraphemes = toGraphemes(value);
|
|
299
|
+
const selectedPrefixGraphemeCount = toGraphemes(visibleText.slice(0, selectionStart)).length;
|
|
300
|
+
const selectedSuffixGraphemeCount = toGraphemes(visibleText.slice(ellipsisEnd, selectionEnd)).length;
|
|
301
|
+
const suffixStart = originalGraphemes.length - toGraphemes(suffixText).length;
|
|
302
|
+
return originalGraphemes.slice(selectedPrefixGraphemeCount, suffixStart + selectedSuffixGraphemeCount).join("");
|
|
303
|
+
}
|
|
304
|
+
function getMiddleTruncateCopyTextFromSelectionText({ prefixText, selectionText, suffixText, value }) {
|
|
305
|
+
const visibleText = prefixText + ELLIPSIS + suffixText;
|
|
306
|
+
const trimmedSelectionText = selectionText.trim();
|
|
307
|
+
if (!trimmedSelectionText) {
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
310
|
+
const leading = selectionText.slice(0, selectionText.length - selectionText.trimStart().length);
|
|
311
|
+
const trailing = selectionText.slice(selectionText.trimEnd().length);
|
|
312
|
+
if (trimmedSelectionText === visibleText) {
|
|
313
|
+
return leading + value + trailing;
|
|
314
|
+
}
|
|
315
|
+
if (!trimmedSelectionText.includes(ELLIPSIS)) {
|
|
316
|
+
return null;
|
|
317
|
+
}
|
|
318
|
+
const selectionStart = visibleText.indexOf(trimmedSelectionText);
|
|
319
|
+
if (selectionStart === -1) {
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
const selectionEnd = selectionStart + trimmedSelectionText.length;
|
|
323
|
+
const mappedText = getMiddleTruncateCopyText({
|
|
324
|
+
prefixText,
|
|
325
|
+
selectionEnd,
|
|
326
|
+
selectionStart,
|
|
327
|
+
suffixText,
|
|
328
|
+
value
|
|
329
|
+
});
|
|
330
|
+
return mappedText === null ? null : leading + mappedText + trailing;
|
|
331
|
+
}
|
|
332
|
+
const pendingMeasurements = /* @__PURE__ */ new Map();
|
|
333
|
+
let measurementFrame = 0;
|
|
334
|
+
function flushMeasurements() {
|
|
335
|
+
measurementFrame = 0;
|
|
336
|
+
const reads = [...pendingMeasurements.values()];
|
|
337
|
+
pendingMeasurements.clear();
|
|
338
|
+
const measures = reads.map((read) => read());
|
|
339
|
+
for (const measure of measures) {
|
|
340
|
+
measure == null ? void 0 : measure();
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
function scheduleMeasurement(key, { read, measure }) {
|
|
344
|
+
pendingMeasurements.set(key, () => {
|
|
345
|
+
const measurement = read();
|
|
346
|
+
return measurement === null ? null : () => measure(measurement);
|
|
347
|
+
});
|
|
348
|
+
if (measurementFrame === 0) {
|
|
349
|
+
measurementFrame = requestAnimationFrame(flushMeasurements);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
function cancelMeasurement(key) {
|
|
353
|
+
pendingMeasurements.delete(key);
|
|
354
|
+
if (pendingMeasurements.size === 0 && measurementFrame !== 0) {
|
|
355
|
+
cancelAnimationFrame(measurementFrame);
|
|
356
|
+
measurementFrame = 0;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
const useIsomorphicLayoutEffect = typeof window === "undefined" ? reactExports.useEffect : reactExports.useLayoutEffect;
|
|
360
|
+
function createFullState(value, graphemes) {
|
|
361
|
+
return {
|
|
362
|
+
displayText: value,
|
|
363
|
+
isTruncated: false,
|
|
364
|
+
prefixGraphemeCount: graphemes.length,
|
|
365
|
+
prefixText: value,
|
|
366
|
+
suffixGraphemeCount: 0,
|
|
367
|
+
suffixText: ""
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
function useMiddleTruncate(value) {
|
|
371
|
+
const graphemes = reactExports.useMemo(() => toGraphemes(value), [value]);
|
|
372
|
+
const fullState = reactExports.useMemo(() => createFullState(value, graphemes), [graphemes, value]);
|
|
373
|
+
const ref = reactExports.useRef(null);
|
|
374
|
+
const measureRef = reactExports.useRef(null);
|
|
375
|
+
const [state, setState] = reactExports.useState(() => fullState);
|
|
376
|
+
const measurementKeyRef = reactExports.useRef({});
|
|
377
|
+
const textMeasurementCacheRef = reactExports.useRef({
|
|
378
|
+
typography: "",
|
|
379
|
+
value,
|
|
380
|
+
widths: /* @__PURE__ */ new Map()
|
|
381
|
+
});
|
|
382
|
+
const lastMeasurementRef = reactExports.useRef(null);
|
|
383
|
+
const updateState = reactExports.useCallback((nextState) => {
|
|
384
|
+
setState((currentState) => {
|
|
385
|
+
if (currentState.displayText === nextState.displayText && currentState.isTruncated === nextState.isTruncated && currentState.prefixText === nextState.prefixText && currentState.prefixGraphemeCount === nextState.prefixGraphemeCount && currentState.suffixText === nextState.suffixText && currentState.suffixGraphemeCount === nextState.suffixGraphemeCount) {
|
|
386
|
+
return currentState;
|
|
387
|
+
}
|
|
388
|
+
return nextState;
|
|
389
|
+
});
|
|
390
|
+
}, []);
|
|
391
|
+
const readMeasurement = reactExports.useCallback(() => {
|
|
392
|
+
const el = ref.current;
|
|
393
|
+
const measureEl = measureRef.current;
|
|
394
|
+
if (!el || !measureEl)
|
|
395
|
+
return null;
|
|
396
|
+
const availableWidth = el.clientWidth;
|
|
397
|
+
const style = getComputedStyle(measureEl);
|
|
398
|
+
return {
|
|
399
|
+
availableWidth,
|
|
400
|
+
typography: [
|
|
401
|
+
style.fontFamily,
|
|
402
|
+
style.fontFeatureSettings,
|
|
403
|
+
style.fontKerning,
|
|
404
|
+
style.fontSize,
|
|
405
|
+
style.fontStretch,
|
|
406
|
+
style.fontStyle,
|
|
407
|
+
style.fontVariationSettings,
|
|
408
|
+
style.fontWeight,
|
|
409
|
+
style.letterSpacing,
|
|
410
|
+
style.textTransform
|
|
411
|
+
].join("\0")
|
|
412
|
+
};
|
|
413
|
+
}, []);
|
|
414
|
+
const recalculate = reactExports.useCallback(({ availableWidth, typography }) => {
|
|
415
|
+
const measureEl = measureRef.current;
|
|
416
|
+
if (!measureEl)
|
|
417
|
+
return;
|
|
418
|
+
const lastMeasurement = lastMeasurementRef.current;
|
|
419
|
+
if ((lastMeasurement == null ? void 0 : lastMeasurement.availableWidth) === availableWidth && lastMeasurement.typography === typography && lastMeasurement.value === value) {
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
lastMeasurementRef.current = {
|
|
423
|
+
availableWidth,
|
|
424
|
+
typography,
|
|
425
|
+
value
|
|
426
|
+
};
|
|
427
|
+
if (availableWidth <= 0) {
|
|
428
|
+
updateState(fullState);
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
const textMeasurementCache = textMeasurementCacheRef.current;
|
|
432
|
+
if (textMeasurementCache.typography !== typography || textMeasurementCache.value !== value) {
|
|
433
|
+
textMeasurementCache.typography = typography;
|
|
434
|
+
textMeasurementCache.value = value;
|
|
435
|
+
textMeasurementCache.widths.clear();
|
|
436
|
+
}
|
|
437
|
+
const measure = (text) => {
|
|
438
|
+
const cachedWidth = textMeasurementCache.widths.get(text);
|
|
439
|
+
if (cachedWidth !== void 0) {
|
|
440
|
+
return cachedWidth;
|
|
441
|
+
}
|
|
442
|
+
measureEl.textContent = text;
|
|
443
|
+
const width = measureEl.scrollWidth;
|
|
444
|
+
textMeasurementCache.widths.set(text, width);
|
|
445
|
+
return width;
|
|
446
|
+
};
|
|
447
|
+
const fullWidth = measure(value);
|
|
448
|
+
if (fullWidth <= availableWidth) {
|
|
449
|
+
updateState(fullState);
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
const result = middleTruncate(graphemes, availableWidth, measure, fullWidth);
|
|
453
|
+
updateState({
|
|
454
|
+
displayText: result.text,
|
|
455
|
+
isTruncated: result.truncated,
|
|
456
|
+
prefixGraphemeCount: result.prefixGraphemeCount,
|
|
457
|
+
prefixText: result.prefixText,
|
|
458
|
+
suffixGraphemeCount: result.suffixGraphemeCount,
|
|
459
|
+
suffixText: result.suffixText
|
|
460
|
+
});
|
|
461
|
+
}, [fullState, graphemes, updateState, value]);
|
|
462
|
+
useIsomorphicLayoutEffect(() => {
|
|
463
|
+
const measurement = readMeasurement();
|
|
464
|
+
if (measurement) {
|
|
465
|
+
recalculate(measurement);
|
|
466
|
+
}
|
|
467
|
+
}, [readMeasurement, recalculate]);
|
|
468
|
+
reactExports.useEffect(() => {
|
|
469
|
+
var _a;
|
|
470
|
+
const el = ref.current;
|
|
471
|
+
if (!el)
|
|
472
|
+
return;
|
|
473
|
+
const measurementKey = measurementKeyRef.current;
|
|
474
|
+
const scheduleRecalculation = () => {
|
|
475
|
+
scheduleMeasurement(measurementKey, {
|
|
476
|
+
read: readMeasurement,
|
|
477
|
+
measure: recalculate
|
|
478
|
+
});
|
|
479
|
+
};
|
|
480
|
+
const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(scheduleRecalculation) : null;
|
|
481
|
+
ro == null ? void 0 : ro.observe(el);
|
|
482
|
+
if (!ro) {
|
|
483
|
+
window.addEventListener("resize", scheduleRecalculation);
|
|
484
|
+
}
|
|
485
|
+
const onFontsLoaded = () => {
|
|
486
|
+
textMeasurementCacheRef.current.widths.clear();
|
|
487
|
+
lastMeasurementRef.current = null;
|
|
488
|
+
scheduleRecalculation();
|
|
489
|
+
};
|
|
490
|
+
const fontSet = "fonts" in document ? document.fonts : null;
|
|
491
|
+
(_a = fontSet == null ? void 0 : fontSet.addEventListener) == null ? void 0 : _a.call(fontSet, "loadingdone", onFontsLoaded);
|
|
492
|
+
return () => {
|
|
493
|
+
var _a2;
|
|
494
|
+
ro == null ? void 0 : ro.disconnect();
|
|
495
|
+
if (!ro) {
|
|
496
|
+
window.removeEventListener("resize", scheduleRecalculation);
|
|
497
|
+
}
|
|
498
|
+
cancelMeasurement(measurementKey);
|
|
499
|
+
(_a2 = fontSet == null ? void 0 : fontSet.removeEventListener) == null ? void 0 : _a2.call(fontSet, "loadingdone", onFontsLoaded);
|
|
500
|
+
};
|
|
501
|
+
}, [readMeasurement, recalculate]);
|
|
502
|
+
return {
|
|
503
|
+
ref,
|
|
504
|
+
measureRef,
|
|
505
|
+
displayText: state.displayText,
|
|
506
|
+
isTruncated: state.isTruncated,
|
|
507
|
+
prefixGraphemeCount: state.prefixGraphemeCount,
|
|
508
|
+
prefixText: state.prefixText,
|
|
509
|
+
suffixGraphemeCount: state.suffixGraphemeCount,
|
|
510
|
+
suffixText: state.suffixText
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
function getRangeOffsets(container, range) {
|
|
514
|
+
if (!container.contains(range.startContainer) || !container.contains(range.endContainer)) {
|
|
515
|
+
return null;
|
|
516
|
+
}
|
|
517
|
+
let startRange;
|
|
518
|
+
let endRange;
|
|
519
|
+
try {
|
|
520
|
+
startRange = document.createRange();
|
|
521
|
+
startRange.selectNodeContents(container);
|
|
522
|
+
startRange.setEnd(range.startContainer, range.startOffset);
|
|
523
|
+
endRange = document.createRange();
|
|
524
|
+
endRange.selectNodeContents(container);
|
|
525
|
+
endRange.setEnd(range.endContainer, range.endOffset);
|
|
526
|
+
} catch {
|
|
527
|
+
return null;
|
|
528
|
+
}
|
|
529
|
+
return {
|
|
530
|
+
end: endRange.toString().length,
|
|
531
|
+
start: startRange.toString().length
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
function MiddleTruncate({ value, className, onCopy: onCopyProp, ...props }) {
|
|
535
|
+
const { ref, measureRef, displayText, isTruncated, prefixText, suffixText } = useMiddleTruncate(value);
|
|
536
|
+
const visibleRef = reactExports.useRef(null);
|
|
537
|
+
const handleCopy = reactExports.useCallback((e) => {
|
|
538
|
+
onCopyProp == null ? void 0 : onCopyProp(e);
|
|
539
|
+
if (e.defaultPrevented || !isTruncated)
|
|
540
|
+
return;
|
|
541
|
+
const selection = window.getSelection();
|
|
542
|
+
if (!selection || selection.rangeCount === 0)
|
|
543
|
+
return;
|
|
544
|
+
const selectionText = selection.toString();
|
|
545
|
+
if (!selectionText)
|
|
546
|
+
return;
|
|
547
|
+
const range = selection.getRangeAt(0);
|
|
548
|
+
const visibleEl = visibleRef.current;
|
|
549
|
+
let copyText = null;
|
|
550
|
+
if (selectionText.includes(ELLIPSIS) && e.currentTarget.contains(range.startContainer) && e.currentTarget.contains(range.endContainer) && visibleEl) {
|
|
551
|
+
const offsets = getRangeOffsets(visibleEl, range);
|
|
552
|
+
if (offsets) {
|
|
553
|
+
copyText = getMiddleTruncateCopyText({
|
|
554
|
+
prefixText,
|
|
555
|
+
selectionEnd: offsets.end,
|
|
556
|
+
selectionStart: offsets.start,
|
|
557
|
+
suffixText,
|
|
558
|
+
value
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
copyText ?? (copyText = getMiddleTruncateCopyTextFromSelectionText({
|
|
563
|
+
prefixText,
|
|
564
|
+
selectionText,
|
|
565
|
+
suffixText,
|
|
566
|
+
value
|
|
567
|
+
}));
|
|
568
|
+
if (copyText === null)
|
|
569
|
+
return;
|
|
570
|
+
e.preventDefault();
|
|
571
|
+
e.clipboardData.setData("text/plain", copyText);
|
|
572
|
+
}, [onCopyProp, isTruncated, prefixText, suffixText, value]);
|
|
573
|
+
return jsxRuntimeExports.jsxs("span", { title: isTruncated ? value : void 0, ...props, ref, className: cn("relative inline-grid min-w-0 max-w-full overflow-hidden whitespace-nowrap", className), onCopy: handleCopy, children: [isTruncated && jsxRuntimeExports.jsx("span", { className: "sr-only select-none", children: value }), jsxRuntimeExports.jsx("span", { "aria-hidden": "true", className: "pointer-events-none col-start-1 row-start-1 invisible select-none whitespace-nowrap", children: value }), jsxRuntimeExports.jsx("span", { "aria-hidden": isTruncated || void 0, className: "col-start-1 row-start-1 min-w-0 overflow-hidden", ref: visibleRef, children: isTruncated ? jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("span", { children: prefixText }), jsxRuntimeExports.jsx("span", { children: ELLIPSIS }), jsxRuntimeExports.jsx("span", { children: suffixText })] }) : displayText }), jsxRuntimeExports.jsx("span", { "aria-hidden": "true", className: "pointer-events-none absolute left-0 top-0 inline-block invisible select-none whitespace-nowrap", ref: measureRef })] });
|
|
574
|
+
}
|
|
575
|
+
const WorkflowIcon = () => {
|
|
576
|
+
return jsxRuntimeExports.jsx("svg", { "aria-hidden": "true", "data-testid": "geist-icon", height: "16", strokeLinejoin: "round", viewBox: "0 0 16 16", width: "16", children: jsxRuntimeExports.jsx("path", { d: "M5.75 7L6.4209 7.33594L4.85254 10.4717C5.38789 10.771 5.75 11.3431 5.75 12V14C5.75 14.9665 4.96648 15.75 4 15.75H2C1.03352 15.75 0.25 14.9665 0.25 14V12C0.25 11.0335 1.03352 10.25 2 10.25H3.28711L5.0791 6.66504L5.75 7ZM14 10.25C14.9665 10.25 15.75 11.0335 15.75 12V14C15.75 14.9665 14.9665 15.75 14 15.75H12C11.1185 15.75 10.3909 15.098 10.2695 14.25H7V12.75H10.25V12C10.25 11.0335 11.0335 10.25 12 10.25H14ZM2 11.75C1.86192 11.75 1.75 11.8619 1.75 12V14C1.75 14.1381 1.86192 14.25 2 14.25H4C4.13808 14.25 4.25 14.1381 4.25 14V12C4.25 11.8619 4.13808 11.75 4 11.75H2ZM12 11.75C11.8619 11.75 11.75 11.8619 11.75 12V14C11.75 14.1381 11.8619 14.25 12 14.25H14C14.1381 14.25 14.25 14.1381 14.25 14V12C14.25 11.8619 14.1381 11.75 14 11.75H12ZM9 0.25C9.96649 0.25 10.75 1.03351 10.75 2V4C10.75 4.44642 10.5808 4.85197 10.3057 5.16113L12.2041 8.6416L10.8877 9.36035L8.91895 5.75H7C6.03351 5.75 5.25 4.96649 5.25 4V2C5.25 1.03351 6.03351 0.25 7 0.25H9ZM7 1.75C6.86193 1.75 6.75 1.86193 6.75 2V4C6.75 4.13807 6.86193 4.25 7 4.25H9C9.13807 4.25 9.25 4.13807 9.25 4V2C9.25 1.86193 9.13807 1.75 9 1.75H7Z", fill: "currentColor" }) });
|
|
577
|
+
};
|
|
578
|
+
const WebhookIcon = () => {
|
|
579
|
+
return jsxRuntimeExports.jsx("svg", { "aria-hidden": "true", "data-testid": "geist-icon", height: "16", strokeLinejoin: "round", viewBox: "0 0 16 16", width: "16", children: jsxRuntimeExports.jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M5.8349 3.24994C5.14454 4.44567 5.55423 5.97464 6.74996 6.665L7.39465 7.03721L7.02726 7.68466L5.14599 11C5.21289 11.1531 5.25 11.3222 5.25 11.5C5.25 12.1904 4.69036 12.75 4 12.75C3.30964 12.75 2.75 12.1904 2.75 11.5C2.75 10.8634 3.22584 10.338 3.84123 10.26L5.38944 7.5316C3.95909 6.30274 3.55857 4.19264 4.53586 2.49994C5.64043 0.586765 8.08679 -0.0687357 9.99996 1.03583C11.836 2.09584 12.5137 4.39156 11.5892 6.26591L10.4949 4.33754C10.4418 3.53274 10.0009 2.76843 9.24996 2.33487C8.05423 1.64452 6.52525 2.0542 5.8349 3.24994ZM9.146 4.99996C9.21289 4.84686 9.25 4.67776 9.25 4.5C9.25 3.80964 8.69036 3.25 8 3.25C7.30964 3.25 6.75 3.80964 6.75 4.5C6.75 5.13659 7.22586 5.66203 7.84127 5.74002L9.72266 9.05556L10.0956 9.71274L10.75 9.33493C11.9457 8.64458 13.4747 9.05427 14.165 10.25C14.8554 11.4457 14.4457 12.9747 13.25 13.6651C12.5047 14.0953 11.63 14.0983 10.9096 13.75H8.69252C9.85895 15.4685 12.1727 16.0191 14 14.9641C15.9131 13.8595 16.5686 11.4132 15.4641 9.5C14.4886 7.81038 12.4665 7.10169 10.6895 7.71998L9.146 4.99996ZM13.25 11.5C13.25 12.1904 12.6904 12.75 12 12.75C11.591 12.75 11.228 12.5536 10.9999 12.25H7.9298C7.57875 14.1006 5.95279 15.5 4 15.5C1.79086 15.5 0 13.7091 0 11.5C0 9.40018 1.61801 7.67826 3.67529 7.51299L2.58098 9.44147C1.92792 9.89251 1.5 10.6463 1.5 11.5C1.5 12.8807 2.61929 14 4 14C5.38071 14 6.5 12.8807 6.5 11.5V10.75H7.25H10.9999C11.228 10.4464 11.591 10.25 12 10.25C12.6904 10.25 13.25 10.8096 13.25 11.5Z", fill: "currentColor" }) });
|
|
580
|
+
};
|
|
581
|
+
const SleepIcon = () => {
|
|
582
|
+
return jsxRuntimeExports.jsx("svg", { "aria-hidden": "true", "data-testid": "geist-icon", height: "16", strokeLinejoin: "round", viewBox: "0 0 16 16", width: "16", children: jsxRuntimeExports.jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M7.25 1.25V2.03971C5.87928 2.18571 4.62678 2.72736 3.6089 3.54824L3.03033 2.96967L2.5 2.43934L1.43934 3.5L1.96967 4.03033L2.54824 4.6089C1.57979 5.80976 1 7.33717 1 9C1 12.866 4.13401 16 8 16C11.866 16 15 12.866 15 9C15 7.33717 14.4202 5.80976 13.4518 4.6089L14.0303 4.03033L14.5607 3.5L13.5 2.43934L12.9697 2.96967L12.3911 3.54824C11.3732 2.72736 10.1207 2.18571 8.75 2.03971V1.25H9.25H10V-0.25H9.25H8.75H7.25H6.75H6V1.25H6.75H7.25ZM2.5 9C2.5 5.96243 4.96243 3.5 8 3.5C11.0376 3.5 13.5 5.96243 13.5 9C13.5 12.0376 11.0376 14.5 8 14.5C4.96243 14.5 2.5 12.0376 2.5 9ZM8.75 6.75V6H7.25V6.75V9V9.75H8.75V9V6.75Z", fill: "currentColor" }) });
|
|
583
|
+
};
|
|
584
|
+
const StepForwardIcon = () => {
|
|
585
|
+
return jsxRuntimeExports.jsx("svg", { "aria-hidden": "true", "data-testid": "geist-icon", height: "16", strokeLinejoin: "round", viewBox: "0 0 16 16", width: "16", children: jsxRuntimeExports.jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M4.21969 12.5303L4.75002 13.0607L5.81068 12L5.28035 11.4697L1.81068 7.99999L5.28035 4.53032L5.81068 3.99999L4.75002 2.93933L4.21969 3.46966L0.39647 7.29289C0.00594562 7.68341 0.00594562 8.31658 0.39647 8.7071L4.21969 12.5303ZM11.7804 12.5303L11.25 13.0607L10.1894 12L10.7197 11.4697L14.1894 7.99999L10.7197 4.53032L10.1894 3.99999L11.25 2.93933L11.7804 3.46966L15.6036 7.29289C15.9941 7.68341 15.9941 8.31658 15.6036 8.7071L11.7804 12.5303Z", fill: "currentColor" }) });
|
|
586
|
+
};
|
|
587
|
+
const eventStyles = {
|
|
588
|
+
run: { icon: WorkflowIcon, className: "text-blue-900", label: "Workflow" },
|
|
589
|
+
step: { icon: StepForwardIcon, className: "text-green-900", label: "Step" },
|
|
590
|
+
hook: { icon: WebhookIcon, className: "text-gray-900", label: "Hook" },
|
|
591
|
+
sleep: { icon: SleepIcon, className: "text-gray-900", label: "Sleep" }
|
|
592
|
+
};
|
|
593
|
+
const defaultStyle = {
|
|
594
|
+
icon: Circle,
|
|
595
|
+
className: "text-gray-900",
|
|
596
|
+
label: "Event"
|
|
597
|
+
};
|
|
598
|
+
const ROW_HEIGHT_CLASS = "h-10";
|
|
599
|
+
function getEventStyle(resource, isErrored, isCancelled) {
|
|
600
|
+
const style = eventStyles[resource] ?? defaultStyle;
|
|
601
|
+
return {
|
|
602
|
+
icon: style.icon,
|
|
603
|
+
className: cn(isErrored ? "text-red-900" : isCancelled ? "text-gray-900" : style.className),
|
|
604
|
+
label: style.label
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
function ResourceIcon({ resource, isErrored = false, isCancelled = false }) {
|
|
608
|
+
const { icon: Icon, className, label } = getEventStyle(resource, isErrored, isCancelled);
|
|
609
|
+
return jsxRuntimeExports.jsxs(Tooltip, { delayDuration: 500, children: [jsxRuntimeExports.jsx(TooltipTrigger, { asChild: true, children: jsxRuntimeExports.jsx("span", { className: cn("shrink-0", className), children: jsxRuntimeExports.jsx(Icon, { className: "w-4 h-4" }) }) }), jsxRuntimeExports.jsx(TooltipContent, { side: "top", children: label })] });
|
|
610
|
+
}
|
|
611
|
+
const EventRow = ({ span, isSelected, isDimmed, onSelectSpan }) => {
|
|
612
|
+
const durationMs = getSpanDurationMs(span);
|
|
613
|
+
const isErrored = isSpanErrored(span);
|
|
614
|
+
const isCancelled = isSpanCancelled(span);
|
|
615
|
+
return jsxRuntimeExports.jsx("li", { className: cn("relative overflow-clip transition-opacity hover:bg-gray-100 aria-selected:bg-gray-100 aria-selected:hover:bg-gray-200", ROW_HEIGHT_CLASS, isDimmed && "opacity-35"), role: "treeitem", "aria-selected": isSelected, "aria-expanded": isSelected, "aria-level": 1, onClick: () => onSelectSpan(span.spanId), children: jsxRuntimeExports.jsxs("div", { className: "flex h-full min-w-0 items-center pl-4 pr-2", children: [jsxRuntimeExports.jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [jsxRuntimeExports.jsx(ResourceIcon, { resource: span.resource, isErrored, isCancelled }), jsxRuntimeExports.jsx("span", { className: "min-w-0 text-label-14", children: jsxRuntimeExports.jsx(MiddleTruncate, { value: span.name }) })] }), jsxRuntimeExports.jsx("div", { className: "ml-2 shrink-0", children: jsxRuntimeExports.jsx("span", { className: "text-label-14 text-gray-900 tabular-nums", children: formatDurationPrecise(durationMs) }) })] }) });
|
|
616
|
+
};
|
|
617
|
+
const EventList = ({ spans, activeSpanId, searchResult, onSelectSpan }) => {
|
|
618
|
+
const listRef = reactExports.useRef(null);
|
|
619
|
+
const { start, end } = useRowWindow(listRef, spans.length, ROW_HEIGHT_PX);
|
|
620
|
+
return jsxRuntimeExports.jsx("ul", { ref: listRef, id: "event-list", role: "tree", className: "block min-h-0 overflow-visible divide-y divide-gray-400 border-b border-gray-400", style: {
|
|
621
|
+
paddingTop: start * ROW_HEIGHT_PX,
|
|
622
|
+
paddingBottom: (spans.length - end) * ROW_HEIGHT_PX
|
|
623
|
+
}, children: spans.slice(start, end).map((span) => jsxRuntimeExports.jsx(EventRow, { span, isSelected: span.spanId === activeSpanId, isDimmed: isSpanDimmedBySearch(span.spanId, searchResult), onSelectSpan }, span.spanId)) });
|
|
624
|
+
};
|
|
625
|
+
const STORAGE_DOCS_URL = `${USAGE_DOCS_URL}#storage`;
|
|
626
|
+
function NewTabLink({
|
|
627
|
+
href,
|
|
628
|
+
className,
|
|
629
|
+
children,
|
|
630
|
+
label,
|
|
631
|
+
testId,
|
|
632
|
+
...rest
|
|
633
|
+
}) {
|
|
634
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
635
|
+
"a",
|
|
636
|
+
{
|
|
637
|
+
...rest,
|
|
638
|
+
href,
|
|
639
|
+
target: "_blank",
|
|
640
|
+
rel: "noopener noreferrer",
|
|
641
|
+
className,
|
|
642
|
+
"aria-label": label ? `${label} (opens in a new tab)` : void 0,
|
|
643
|
+
"data-testid": testId,
|
|
644
|
+
children: [
|
|
645
|
+
children,
|
|
646
|
+
!label && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
647
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
648
|
+
ArrowUpRight,
|
|
649
|
+
{
|
|
650
|
+
className: "ml-0.5 inline h-3.5 w-3.5 align-[-2px]",
|
|
651
|
+
"aria-hidden": "true"
|
|
652
|
+
}
|
|
653
|
+
),
|
|
654
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sr-only", children: " (opens in a new tab)" })
|
|
655
|
+
] })
|
|
656
|
+
]
|
|
657
|
+
}
|
|
658
|
+
);
|
|
659
|
+
}
|
|
660
|
+
function runUsagePath(runId) {
|
|
661
|
+
return `/run/${encodeURIComponent(runId)}/usage`;
|
|
662
|
+
}
|
|
663
|
+
function runPath(runId) {
|
|
664
|
+
return `/run/${encodeURIComponent(runId)}`;
|
|
665
|
+
}
|
|
666
|
+
const ENTITY_LABELS = {
|
|
667
|
+
run: "Run",
|
|
668
|
+
step: "Steps",
|
|
669
|
+
hook: "Hooks",
|
|
670
|
+
stream: "Streams"
|
|
671
|
+
};
|
|
672
|
+
const ROW_RESOURCE = {
|
|
673
|
+
steps: "step",
|
|
674
|
+
hooks: "hook",
|
|
675
|
+
attributes: "run",
|
|
676
|
+
sleeps: "sleep",
|
|
677
|
+
run: "run",
|
|
678
|
+
other: "event"
|
|
679
|
+
};
|
|
680
|
+
function RowIcon({ type }) {
|
|
681
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "flex h-[18px] shrink-0 items-center", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ResourceIcon, { resource: ROW_RESOURCE[type] }) });
|
|
682
|
+
}
|
|
683
|
+
function RetryBadge({
|
|
684
|
+
retries,
|
|
685
|
+
testId = "run-usage-retries"
|
|
686
|
+
}) {
|
|
687
|
+
if (retries <= 0) return null;
|
|
688
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
689
|
+
"span",
|
|
690
|
+
{
|
|
691
|
+
className: "inline-flex items-center whitespace-nowrap rounded-full border border-amber-400 bg-amber-100 px-2 text-label-12 leading-4 text-amber-900",
|
|
692
|
+
"data-testid": testId,
|
|
693
|
+
children: formatCount(retries, "retry", "retries")
|
|
694
|
+
}
|
|
695
|
+
);
|
|
696
|
+
}
|
|
697
|
+
function RowDetail({
|
|
698
|
+
children,
|
|
699
|
+
testId
|
|
700
|
+
}) {
|
|
701
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
702
|
+
"span",
|
|
703
|
+
{
|
|
704
|
+
className: "whitespace-nowrap font-sans text-label-12 text-gray-700",
|
|
705
|
+
"data-testid": testId,
|
|
706
|
+
children
|
|
707
|
+
}
|
|
708
|
+
);
|
|
709
|
+
}
|
|
710
|
+
function InlineRetryBadge({
|
|
711
|
+
retries,
|
|
712
|
+
className
|
|
713
|
+
}) {
|
|
714
|
+
if (retries <= 0) return null;
|
|
715
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: cn("mt-1 block @min-[520px]:hidden", className), children: /* @__PURE__ */ jsxRuntimeExports.jsx(RetryBadge, { retries, testId: "run-usage-retries-inline" }) });
|
|
716
|
+
}
|
|
717
|
+
function ShareBar({
|
|
718
|
+
share,
|
|
719
|
+
muted = false
|
|
720
|
+
}) {
|
|
721
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
722
|
+
"div",
|
|
723
|
+
{
|
|
724
|
+
className: "h-1.5 w-full min-w-16 rounded-full bg-gray-alpha-200",
|
|
725
|
+
"aria-hidden": "true",
|
|
726
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
727
|
+
"div",
|
|
728
|
+
{
|
|
729
|
+
className: cn(
|
|
730
|
+
"h-1.5 rounded-full",
|
|
731
|
+
muted ? "bg-gray-500" : "bg-blue-700"
|
|
732
|
+
),
|
|
733
|
+
style: { width: `${Math.max(0, Math.min(1, share)) * 100}%` }
|
|
734
|
+
}
|
|
735
|
+
)
|
|
736
|
+
}
|
|
737
|
+
);
|
|
738
|
+
}
|
|
739
|
+
function usageVisible(usage, isLocalBackend) {
|
|
740
|
+
return usage != null || usage === void 0 && isLocalBackend;
|
|
741
|
+
}
|
|
742
|
+
const UNAVAILABLE = "—";
|
|
743
|
+
function dataWrittenLabel(usage, isLocalBackend) {
|
|
744
|
+
if (usage) return formatDataWrittenHeading(usage);
|
|
745
|
+
return isLocalBackend ? "Storage (local)" : "Storage";
|
|
746
|
+
}
|
|
747
|
+
const failedMessage = (error) => `Failed to read this run’s usage: ${error.message}`;
|
|
748
|
+
function HeaderFigure({
|
|
749
|
+
to,
|
|
750
|
+
onUsagePage,
|
|
751
|
+
label,
|
|
752
|
+
title,
|
|
753
|
+
testId,
|
|
754
|
+
children
|
|
755
|
+
}) {
|
|
756
|
+
if (onUsagePage) {
|
|
757
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs", "data-testid": testId, title, children });
|
|
758
|
+
}
|
|
759
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
760
|
+
Link,
|
|
761
|
+
{
|
|
762
|
+
to,
|
|
763
|
+
className: "-my-1 inline-block min-w-6 rounded-sm py-1 text-left text-xs underline decoration-dotted underline-offset-2 text-gray-1000 hover:text-blue-900 focus-visible:outline-none focus-visible:shadow-[var(--ds-focus-ring)]",
|
|
764
|
+
"aria-label": label,
|
|
765
|
+
title,
|
|
766
|
+
"data-testid": testId,
|
|
767
|
+
children
|
|
768
|
+
}
|
|
769
|
+
);
|
|
770
|
+
}
|
|
771
|
+
function RunUsageHeaderStats({
|
|
772
|
+
runId,
|
|
773
|
+
usage,
|
|
774
|
+
error,
|
|
775
|
+
isLocalBackend,
|
|
776
|
+
onUsagePage = false
|
|
777
|
+
}) {
|
|
778
|
+
const failed = !usage && error !== null;
|
|
779
|
+
const failedTitle = failed ? failedMessage(error) : void 0;
|
|
780
|
+
const localNote = usage ? formatLocalDataWrittenNote(usage) : null;
|
|
781
|
+
const to = runUsagePath(runId);
|
|
782
|
+
const label = dataWrittenLabel(usage, isLocalBackend);
|
|
783
|
+
const events = usage ? usage.events.toLocaleString("en-US") : UNAVAILABLE;
|
|
784
|
+
const bytes = usage ? formatUsageBytes(usage.dataWritten.bytes) : UNAVAILABLE;
|
|
785
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
786
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
787
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-muted-foreground", children: "Events" }),
|
|
788
|
+
usage || failed ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
789
|
+
HeaderFigure,
|
|
790
|
+
{
|
|
791
|
+
to,
|
|
792
|
+
onUsagePage,
|
|
793
|
+
label: usage ? `${formatCount(usage.events, "event", "events")}, open usage` : "Events unavailable, open usage",
|
|
794
|
+
title: failedTitle,
|
|
795
|
+
testId: "run-usage-events",
|
|
796
|
+
children: events
|
|
797
|
+
}
|
|
798
|
+
) : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "w-[40px] h-[20px]" })
|
|
799
|
+
] }),
|
|
800
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
801
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
802
|
+
"div",
|
|
803
|
+
{
|
|
804
|
+
className: "text-xs text-muted-foreground flex items-center gap-1",
|
|
805
|
+
"data-testid": "run-usage-data-label",
|
|
806
|
+
children: [
|
|
807
|
+
label,
|
|
808
|
+
localNote && /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
809
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
810
|
+
NewTabLink,
|
|
811
|
+
{
|
|
812
|
+
href: STORAGE_DOCS_URL,
|
|
813
|
+
className: "-m-1.5 inline-flex rounded-sm p-1.5 text-muted-foreground hover:text-gray-1000 focus-visible:outline-none focus-visible:shadow-[var(--ds-focus-ring)]",
|
|
814
|
+
label: `How ${label} is counted`,
|
|
815
|
+
testId: "run-usage-data-help",
|
|
816
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(CircleQuestionMark, { className: "w-3 h-3", "aria-hidden": "true" })
|
|
817
|
+
}
|
|
818
|
+
) }),
|
|
819
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "max-w-xs", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: localNote }) })
|
|
820
|
+
] })
|
|
821
|
+
]
|
|
822
|
+
}
|
|
823
|
+
),
|
|
824
|
+
usage || failed ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
825
|
+
HeaderFigure,
|
|
826
|
+
{
|
|
827
|
+
to,
|
|
828
|
+
onUsagePage,
|
|
829
|
+
label: usage ? `${bytes} ${label.toLowerCase()}, open usage` : `${label} unavailable, open usage`,
|
|
830
|
+
title: failedTitle,
|
|
831
|
+
testId: "run-usage-data-written",
|
|
832
|
+
children: bytes
|
|
833
|
+
}
|
|
834
|
+
) : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "w-[50px] h-[20px]" })
|
|
835
|
+
] })
|
|
836
|
+
] });
|
|
837
|
+
}
|
|
838
|
+
function formatRunEventTypes(usage) {
|
|
839
|
+
const { events, byType } = usage.runEvents;
|
|
840
|
+
if (events <= 0) return null;
|
|
841
|
+
const parts = RUN_USAGE_RUN_EVENT_TYPES.flatMap(
|
|
842
|
+
(type) => byType[type] > 0 ? [`${byType[type].toLocaleString("en-US")} ${type}`] : []
|
|
843
|
+
);
|
|
844
|
+
const known = RUN_USAGE_RUN_EVENT_TYPES.reduce((n, t) => n + byType[t], 0);
|
|
845
|
+
if (events > known) {
|
|
846
|
+
parts.push(`${(events - known).toLocaleString("en-US")} other`);
|
|
847
|
+
}
|
|
848
|
+
return parts.join(", ");
|
|
849
|
+
}
|
|
850
|
+
const CELL = "py-2 pr-2 sm:pr-4";
|
|
851
|
+
const SHARE_CELL = "py-2 pr-0 @min-[520px]:pr-4";
|
|
852
|
+
const TABLE_HEAD_ROW = "text-label-12 text-gray-900 border-b border-gray-alpha-400";
|
|
853
|
+
function groupDetail(group) {
|
|
854
|
+
switch (group.type) {
|
|
855
|
+
case "steps":
|
|
856
|
+
return formatCount(group.calls, "call", "calls");
|
|
857
|
+
case "hooks":
|
|
858
|
+
return formatCount(group.calls, "hook", "hooks");
|
|
859
|
+
case "attributes":
|
|
860
|
+
return formatCount(group.calls, "write", "writes");
|
|
861
|
+
case "sleeps":
|
|
862
|
+
return formatCount(group.calls, "sleep", "sleeps");
|
|
863
|
+
default:
|
|
864
|
+
return null;
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
function BreakableLabel({ label }) {
|
|
868
|
+
const parts = label.split(new RegExp("(?<=[:/._-])"));
|
|
869
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: parts.map((part, i) => (
|
|
870
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: parts of one fixed label
|
|
871
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(reactExports.Fragment, { children: [
|
|
872
|
+
i > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("wbr", {}),
|
|
873
|
+
part
|
|
874
|
+
] }, i)
|
|
875
|
+
)) });
|
|
876
|
+
}
|
|
877
|
+
function CountCells({
|
|
878
|
+
row,
|
|
879
|
+
emphasis = false
|
|
880
|
+
}) {
|
|
881
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
882
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
883
|
+
"td",
|
|
884
|
+
{
|
|
885
|
+
className: cn(
|
|
886
|
+
CELL,
|
|
887
|
+
"text-right tabular-nums",
|
|
888
|
+
emphasis && "font-medium"
|
|
889
|
+
),
|
|
890
|
+
children: row.events.toLocaleString("en-US")
|
|
891
|
+
}
|
|
892
|
+
),
|
|
893
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: cn(CELL, "hidden @min-[520px]:table-cell"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(ShareBar, { share: row.share }) }),
|
|
894
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: cn(SHARE_CELL, "text-right tabular-nums text-gray-900"), children: formatUsageShare(row.share) }),
|
|
895
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "hidden py-2 @min-[520px]:table-cell", children: /* @__PURE__ */ jsxRuntimeExports.jsx(RetryBadge, { retries: row.retries }) })
|
|
896
|
+
] });
|
|
897
|
+
}
|
|
898
|
+
const TOGGLE = "-my-[3px] -ml-1 flex min-w-0 items-start gap-2 rounded-sm py-[3px] pl-1 pr-1 text-left focus-visible:outline-none focus-visible:shadow-[var(--ds-focus-ring)]";
|
|
899
|
+
function UsageGroup({
|
|
900
|
+
group,
|
|
901
|
+
usage,
|
|
902
|
+
idPrefix
|
|
903
|
+
}) {
|
|
904
|
+
const expandable = group.type === "steps" || group.type === "hooks";
|
|
905
|
+
const [expanded, setExpanded] = reactExports.useState(true);
|
|
906
|
+
const [showAll, setShowAll] = reactExports.useState(false);
|
|
907
|
+
const label = USAGE_ROW_TYPE_LABELS[group.type];
|
|
908
|
+
const detail = groupDetail(group);
|
|
909
|
+
const runEventTypes = group.type === "run" ? formatRunEventTypes(usage) : null;
|
|
910
|
+
const childrenId = `${idPrefix}-${group.type}`;
|
|
911
|
+
const shown = expandable && showAll ? usageRows(usage, Number.POSITIVE_INFINITY).find(
|
|
912
|
+
(g) => g.type === group.type
|
|
913
|
+
) ?? group : group;
|
|
914
|
+
const name = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
915
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(RowIcon, { type: group.type }),
|
|
916
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "flex min-w-0 flex-wrap items-baseline gap-x-2", children: [
|
|
917
|
+
runEventTypes ? (
|
|
918
|
+
// Just "Run"; its event types are its tooltip, on hover or focus.
|
|
919
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
920
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
921
|
+
"span",
|
|
922
|
+
{
|
|
923
|
+
tabIndex: 0,
|
|
924
|
+
className: "rounded-sm font-medium text-gray-1000 underline decoration-dotted underline-offset-2 focus-visible:outline-none focus-visible:shadow-[var(--ds-focus-ring)]",
|
|
925
|
+
"data-testid": "run-usage-type-label",
|
|
926
|
+
children: label
|
|
927
|
+
}
|
|
928
|
+
) }),
|
|
929
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { "data-testid": "run-usage-run-events", children: runEventTypes })
|
|
930
|
+
] })
|
|
931
|
+
) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
932
|
+
"span",
|
|
933
|
+
{
|
|
934
|
+
className: "font-medium text-gray-1000",
|
|
935
|
+
"data-testid": "run-usage-type-label",
|
|
936
|
+
children: label
|
|
937
|
+
}
|
|
938
|
+
),
|
|
939
|
+
detail && /* @__PURE__ */ jsxRuntimeExports.jsx(RowDetail, { testId: "run-usage-group-detail", children: detail })
|
|
940
|
+
] })
|
|
941
|
+
] });
|
|
942
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
943
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("tbody", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
944
|
+
"tr",
|
|
945
|
+
{
|
|
946
|
+
className: "border-b border-gray-alpha-200",
|
|
947
|
+
"data-testid": "run-usage-group",
|
|
948
|
+
"data-type": group.type,
|
|
949
|
+
children: [
|
|
950
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("td", { className: CELL, children: [
|
|
951
|
+
expandable ? /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
952
|
+
"button",
|
|
953
|
+
{
|
|
954
|
+
type: "button",
|
|
955
|
+
className: TOGGLE,
|
|
956
|
+
"aria-expanded": expanded,
|
|
957
|
+
"aria-controls": childrenId,
|
|
958
|
+
onClick: () => setExpanded((value) => !value),
|
|
959
|
+
"data-testid": "run-usage-toggle",
|
|
960
|
+
children: [
|
|
961
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "flex h-[18px] shrink-0 items-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
962
|
+
ChevronRight,
|
|
963
|
+
{
|
|
964
|
+
className: cn(
|
|
965
|
+
"h-4 w-4 text-gray-900 motion-safe:transition-transform",
|
|
966
|
+
expanded && "rotate-90"
|
|
967
|
+
),
|
|
968
|
+
"aria-hidden": "true"
|
|
969
|
+
}
|
|
970
|
+
) }),
|
|
971
|
+
name
|
|
972
|
+
]
|
|
973
|
+
}
|
|
974
|
+
) : (
|
|
975
|
+
// Lines up with the toggles' labels: a chevron's width in.
|
|
976
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex min-w-0 items-start gap-2 pl-6", children: name })
|
|
977
|
+
),
|
|
978
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(InlineRetryBadge, { retries: group.retries, className: "pl-12" })
|
|
979
|
+
] }),
|
|
980
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CountCells, { row: group, emphasis: true })
|
|
981
|
+
]
|
|
982
|
+
}
|
|
983
|
+
) }),
|
|
984
|
+
expandable && /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
985
|
+
"tbody",
|
|
986
|
+
{
|
|
987
|
+
id: childrenId,
|
|
988
|
+
hidden: !expanded,
|
|
989
|
+
"data-testid": "run-usage-children",
|
|
990
|
+
"data-type": group.type,
|
|
991
|
+
children: [
|
|
992
|
+
shown.children.map((child) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
993
|
+
"tr",
|
|
994
|
+
{
|
|
995
|
+
className: "border-b border-gray-alpha-200",
|
|
996
|
+
"data-testid": "run-usage-child",
|
|
997
|
+
"data-key": child.key,
|
|
998
|
+
children: [
|
|
999
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("td", { className: cn(CELL, "pl-12"), children: [
|
|
1000
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "flex min-w-0 flex-wrap items-baseline gap-x-2", children: [
|
|
1001
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1002
|
+
"span",
|
|
1003
|
+
{
|
|
1004
|
+
className: "min-w-0 font-mono text-gray-1000",
|
|
1005
|
+
title: child.label,
|
|
1006
|
+
"data-testid": "run-usage-child-label",
|
|
1007
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(BreakableLabel, { label: child.label })
|
|
1008
|
+
}
|
|
1009
|
+
),
|
|
1010
|
+
group.type === "steps" && /* @__PURE__ */ jsxRuntimeExports.jsx(RowDetail, { testId: "run-usage-calls", children: formatCount(child.calls, "call", "calls") })
|
|
1011
|
+
] }),
|
|
1012
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(InlineRetryBadge, { retries: child.retries })
|
|
1013
|
+
] }),
|
|
1014
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CountCells, { row: child })
|
|
1015
|
+
]
|
|
1016
|
+
},
|
|
1017
|
+
child.key
|
|
1018
|
+
)),
|
|
1019
|
+
shown.otherChildren && /* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { className: "border-b border-gray-alpha-200", children: [
|
|
1020
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("td", { className: cn(CELL, "pl-12"), children: [
|
|
1021
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1022
|
+
"button",
|
|
1023
|
+
{
|
|
1024
|
+
type: "button",
|
|
1025
|
+
className: "-my-[3px] rounded-sm py-[3px] text-gray-900 hover:text-gray-1000 underline decoration-dotted underline-offset-2 focus-visible:outline-none focus-visible:shadow-[var(--ds-focus-ring)]",
|
|
1026
|
+
onClick: () => setShowAll(true),
|
|
1027
|
+
children: shown.otherChildren.label
|
|
1028
|
+
}
|
|
1029
|
+
),
|
|
1030
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(InlineRetryBadge, { retries: shown.otherChildren.retries })
|
|
1031
|
+
] }),
|
|
1032
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CountCells, { row: shown.otherChildren })
|
|
1033
|
+
] })
|
|
1034
|
+
]
|
|
1035
|
+
}
|
|
1036
|
+
)
|
|
1037
|
+
] });
|
|
1038
|
+
}
|
|
1039
|
+
function UsageTable({ usage }) {
|
|
1040
|
+
const idPrefix = reactExports.useId();
|
|
1041
|
+
return (
|
|
1042
|
+
// A size container: its width, not the viewport's, decides whether the
|
|
1043
|
+
// bars and the retries column fit (side by side with the storage table
|
|
1044
|
+
// from lg, the table is narrower than the screen).
|
|
1045
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "@container overflow-x-auto", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("table", { className: "w-full text-copy-13", "data-testid": "run-usage-types", children: [
|
|
1046
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("thead", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { className: TABLE_HEAD_ROW, children: [
|
|
1047
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: cn(CELL, "text-left font-medium"), children: "Type" }),
|
|
1048
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: cn(CELL, "text-right font-medium"), children: "Events" }),
|
|
1049
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: cn(CELL, "hidden w-1/4 @min-[520px]:table-cell"), children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sr-only", children: "Share of Events" }) }),
|
|
1050
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: cn(SHARE_CELL, "text-right font-medium"), children: "Share" }),
|
|
1051
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "hidden py-2 text-left font-medium @min-[520px]:table-cell", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sr-only", children: "Retries" }) })
|
|
1052
|
+
] }) }),
|
|
1053
|
+
usageRows(usage).map((group) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1054
|
+
UsageGroup,
|
|
1055
|
+
{
|
|
1056
|
+
group,
|
|
1057
|
+
usage,
|
|
1058
|
+
idPrefix
|
|
1059
|
+
},
|
|
1060
|
+
group.key
|
|
1061
|
+
))
|
|
1062
|
+
] }) })
|
|
1063
|
+
);
|
|
1064
|
+
}
|
|
1065
|
+
function DataWrittenTable({ usage }) {
|
|
1066
|
+
const purgedNote = formatDataPurgedNote(usage);
|
|
1067
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-3", children: [
|
|
1068
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("table", { className: "w-full text-copy-13", "data-testid": "run-usage-data", children: [
|
|
1069
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("thead", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { className: TABLE_HEAD_ROW, children: [
|
|
1070
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1071
|
+
"th",
|
|
1072
|
+
{
|
|
1073
|
+
className: cn(CELL, "text-left font-medium"),
|
|
1074
|
+
"data-testid": "run-usage-data-heading",
|
|
1075
|
+
children: formatDataWrittenHeading(usage)
|
|
1076
|
+
}
|
|
1077
|
+
),
|
|
1078
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "py-2 text-right font-medium", children: "Size" })
|
|
1079
|
+
] }) }),
|
|
1080
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("tbody", { children: [
|
|
1081
|
+
RUN_USAGE_ENTITIES.filter(
|
|
1082
|
+
// Like the CLI: only the entities that wrote something.
|
|
1083
|
+
(entity) => usage.dataWritten.byEntity[entity] > 0
|
|
1084
|
+
).map((entity) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1085
|
+
"tr",
|
|
1086
|
+
{
|
|
1087
|
+
className: "border-b border-gray-alpha-200",
|
|
1088
|
+
"data-testid": "run-usage-entity",
|
|
1089
|
+
children: [
|
|
1090
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: cn(CELL, "text-gray-1000"), children: ENTITY_LABELS[entity] }),
|
|
1091
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "py-2 text-right tabular-nums", children: formatUsageBytes(usage.dataWritten.byEntity[entity]) })
|
|
1092
|
+
]
|
|
1093
|
+
},
|
|
1094
|
+
entity
|
|
1095
|
+
)),
|
|
1096
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { className: "font-medium", children: [
|
|
1097
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: cn(CELL, "text-gray-1000"), children: "Total" }),
|
|
1098
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1099
|
+
"td",
|
|
1100
|
+
{
|
|
1101
|
+
className: "py-2 text-right tabular-nums",
|
|
1102
|
+
"data-testid": "run-usage-total",
|
|
1103
|
+
children: formatUsageBytes(usage.dataWritten.bytes)
|
|
1104
|
+
}
|
|
1105
|
+
)
|
|
1106
|
+
] })
|
|
1107
|
+
] })
|
|
1108
|
+
] }),
|
|
1109
|
+
purgedNote && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1110
|
+
"p",
|
|
1111
|
+
{
|
|
1112
|
+
className: "text-copy-13 text-gray-900",
|
|
1113
|
+
"data-testid": "run-usage-purged-note",
|
|
1114
|
+
children: purgedNote
|
|
1115
|
+
}
|
|
1116
|
+
),
|
|
1117
|
+
usage.dataRetained && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { "data-testid": "run-usage-retained", children: [
|
|
1118
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-label-12 text-gray-900", children: "Data retained" }),
|
|
1119
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-copy-14 text-gray-1000", children: [
|
|
1120
|
+
formatUsageBytes(usage.dataRetained.byteMonths),
|
|
1121
|
+
"-months"
|
|
1122
|
+
] }),
|
|
1123
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-copy-13 text-gray-900", children: [
|
|
1124
|
+
"Storage × ",
|
|
1125
|
+
usage.dataRetained.retentionMonths,
|
|
1126
|
+
" month retention"
|
|
1127
|
+
] })
|
|
1128
|
+
] })
|
|
1129
|
+
] });
|
|
1130
|
+
}
|
|
1131
|
+
const USAGE_TABLES_LAYOUT = "grid grid-cols-1 gap-8 lg:grid-cols-[minmax(0,3fr)_minmax(0,2fr)] lg:gap-10";
|
|
1132
|
+
function UsageTables({ spans, data }) {
|
|
1133
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: USAGE_TABLES_LAYOUT, "data-testid": "run-usage-tables", children: [
|
|
1134
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("section", { "aria-labelledby": "run-usage-spans-heading", className: "min-w-0", children: [
|
|
1135
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h2", { id: "run-usage-spans-heading", className: "sr-only", children: "Events by type" }),
|
|
1136
|
+
spans
|
|
1137
|
+
] }),
|
|
1138
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("section", { "aria-labelledby": "run-usage-data-section", className: "min-w-0", children: [
|
|
1139
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h2", { id: "run-usage-data-section", className: "sr-only", children: "Storage" }),
|
|
1140
|
+
data
|
|
1141
|
+
] })
|
|
1142
|
+
] });
|
|
1143
|
+
}
|
|
1144
|
+
const skeletonRow = (key, widths) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1145
|
+
"div",
|
|
1146
|
+
{
|
|
1147
|
+
className: "flex h-[37px] items-center justify-between border-b border-gray-alpha-200",
|
|
1148
|
+
children: [
|
|
1149
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: cn("h-4", widths[0]) }),
|
|
1150
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: cn("h-4", widths[1]) })
|
|
1151
|
+
]
|
|
1152
|
+
},
|
|
1153
|
+
key
|
|
1154
|
+
);
|
|
1155
|
+
function RunUsagePageSkeleton() {
|
|
1156
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-6 pb-6 pt-2", "data-testid": "run-usage-skeleton", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1157
|
+
UsageTables,
|
|
1158
|
+
{
|
|
1159
|
+
spans: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
1160
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-[33px] items-center border-b border-gray-alpha-400", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-3 w-12" }) }),
|
|
1161
|
+
skeletonRow(0, ["w-28 ml-6", "w-10"]),
|
|
1162
|
+
[1, 2, 3].map((i) => skeletonRow(i, ["w-40 ml-12", "w-10"])),
|
|
1163
|
+
skeletonRow(4, ["w-28 ml-6", "w-10"]),
|
|
1164
|
+
skeletonRow(5, ["w-40 ml-12", "w-10"]),
|
|
1165
|
+
[6, 7, 8].map((i) => skeletonRow(i, ["w-24 ml-6", "w-10"]))
|
|
1166
|
+
] }),
|
|
1167
|
+
data: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
1168
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-[33px] items-center border-b border-gray-alpha-400", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-3 w-32" }) }),
|
|
1169
|
+
[0, 1, 2, 3, 4].map((i) => skeletonRow(i, ["w-16", "w-12"]))
|
|
1170
|
+
] })
|
|
1171
|
+
}
|
|
1172
|
+
) });
|
|
1173
|
+
}
|
|
1174
|
+
const FOOTER_LINK = "whitespace-nowrap rounded-sm py-1 text-blue-900 hover:underline focus-visible:outline-none focus-visible:shadow-[var(--ds-focus-ring)]";
|
|
1175
|
+
function UsageFooter({ usage }) {
|
|
1176
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("footer", { className: "text-copy-13 text-gray-900", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { "data-testid": "run-usage-footer-line", children: [
|
|
1177
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { "data-testid": "run-usage-footer", children: usage.billed ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium text-gray-1000", children: formatUsageFooter(usage) }) : formatUsageFooter(usage) }),
|
|
1178
|
+
" ",
|
|
1179
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(NewTabLink, { href: USAGE_DOCS_URL, className: FOOTER_LINK, children: "How usage is counted" })
|
|
1180
|
+
] }) });
|
|
1181
|
+
}
|
|
1182
|
+
function RunUsagePage({
|
|
1183
|
+
runId,
|
|
1184
|
+
usage,
|
|
1185
|
+
error,
|
|
1186
|
+
onRetry,
|
|
1187
|
+
retrying = false
|
|
1188
|
+
}) {
|
|
1189
|
+
if (usage === null) {
|
|
1190
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1191
|
+
"div",
|
|
1192
|
+
{
|
|
1193
|
+
className: "flex flex-col items-start gap-3 pb-6 pt-2",
|
|
1194
|
+
"data-testid": "run-usage-unsupported",
|
|
1195
|
+
children: [
|
|
1196
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-copy-14 text-gray-1000", children: "This page isn’t available for this backend." }),
|
|
1197
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1198
|
+
Link,
|
|
1199
|
+
{
|
|
1200
|
+
to: runPath(runId),
|
|
1201
|
+
className: "-my-[3px] inline-block rounded-sm py-[3px] text-copy-13 text-blue-900 hover:underline focus-visible:outline-none focus-visible:shadow-[var(--ds-focus-ring)]",
|
|
1202
|
+
children: "Back to run"
|
|
1203
|
+
}
|
|
1204
|
+
)
|
|
1205
|
+
]
|
|
1206
|
+
}
|
|
1207
|
+
);
|
|
1208
|
+
}
|
|
1209
|
+
if (!usage) {
|
|
1210
|
+
if (!error) return /* @__PURE__ */ jsxRuntimeExports.jsx(RunUsagePageSkeleton, {});
|
|
1211
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1212
|
+
"div",
|
|
1213
|
+
{
|
|
1214
|
+
className: "flex flex-col items-start gap-3 pb-6 pt-2",
|
|
1215
|
+
"data-testid": "run-usage-error",
|
|
1216
|
+
children: [
|
|
1217
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 text-copy-13 text-red-800", children: [
|
|
1218
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CircleAlert, { className: "h-4 w-4 shrink-0" }),
|
|
1219
|
+
failedMessage(error)
|
|
1220
|
+
] }),
|
|
1221
|
+
onRetry && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1222
|
+
Button,
|
|
1223
|
+
{
|
|
1224
|
+
variant: "secondary",
|
|
1225
|
+
size: "small",
|
|
1226
|
+
onClick: onRetry,
|
|
1227
|
+
loading: retrying,
|
|
1228
|
+
prefix: /* @__PURE__ */ jsxRuntimeExports.jsx(RotateCw, {}),
|
|
1229
|
+
children: "Try again"
|
|
1230
|
+
}
|
|
1231
|
+
)
|
|
1232
|
+
]
|
|
1233
|
+
}
|
|
1234
|
+
);
|
|
1235
|
+
}
|
|
1236
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-8 pb-6 pt-2", "data-testid": "run-usage-page", children: [
|
|
1237
|
+
error && /* @__PURE__ */ jsxRuntimeExports.jsxs("output", { className: "block text-copy-13 text-amber-800", children: [
|
|
1238
|
+
"Showing the last numbers read. Failed to refresh: ",
|
|
1239
|
+
error.message
|
|
1240
|
+
] }),
|
|
1241
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1242
|
+
UsageTables,
|
|
1243
|
+
{
|
|
1244
|
+
spans: usage.eventsBySpan.length > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx(UsageTable, { usage }) : /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-copy-13 text-gray-900", children: "This run has no events yet." }),
|
|
1245
|
+
data: /* @__PURE__ */ jsxRuntimeExports.jsx(DataWrittenTable, { usage })
|
|
1246
|
+
}
|
|
1247
|
+
),
|
|
1248
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(UsageFooter, { usage })
|
|
1249
|
+
] });
|
|
1250
|
+
}
|
|
1251
|
+
export {
|
|
1252
|
+
CircleQuestionMark as C,
|
|
1253
|
+
EventList as E,
|
|
1254
|
+
MiddleTruncate as M,
|
|
1255
|
+
RunUsagePage as R,
|
|
1256
|
+
ResourceIcon as a,
|
|
1257
|
+
runPath as b,
|
|
1258
|
+
RunUsageHeaderStats as c,
|
|
1259
|
+
runUsagePath as r,
|
|
1260
|
+
usageVisible as u
|
|
1261
|
+
};
|