@workflow/web 5.3.1 → 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.
Files changed (39) hide show
  1. package/README.md +11 -34
  2. package/build/client/assets/app-BHCSMHev.css +1 -0
  3. package/build/client/assets/{arrow-up-right-CNHh1bh2.js → arrow-up-right-DyaB_ak4.js} +1 -1
  4. package/build/client/assets/{entry.client-DDsh88VE.js → entry.client-xzxVCL3o.js} +1 -1
  5. package/build/client/assets/{highlighted-body-JLMTFACH-CWHg5f-6.js → highlighted-body-JLMTFACH-1yzOVKg0.js} +2 -2
  6. package/build/client/assets/{home-DZqYMSiD.js → home--wf0CrF6.js} +5 -3
  7. package/build/client/assets/{index-BS6T0Zjc.js → index-wl5l5E8H.js} +30 -25
  8. package/build/client/assets/manifest-7b81d8d4.js +1 -0
  9. package/build/client/assets/{mermaid-WFAXDIZX-BLO7Z8RE.js → mermaid-WFAXDIZX-CB__BxYb.js} +272 -2736
  10. package/build/client/assets/meta-9cjJ0pVb.js +6 -0
  11. package/build/client/assets/{root-wdKzRZGT.js → root-C1XwTNUK.js} +14 -8
  12. package/build/client/assets/root-C3ED6Dwc.css +1 -0
  13. package/build/client/assets/rpc-client-SbyXJdFV.js +2482 -0
  14. package/build/client/assets/{run-detail-DyXpnv9C.js → run-detail-2CnpdXm1.js} +426 -618
  15. package/build/client/assets/run-usage-C3aywyqa.js +33 -0
  16. package/build/client/assets/run-usage-DRV6lopZ.js +1261 -0
  17. package/build/client/assets/skeleton-DMLgjvZZ.js +94 -0
  18. package/build/client/assets/{url-state-DhOv2zv0.js → url-state-JAVaNZ_m.js} +79 -159
  19. package/build/client/assets/{zstd-browser-decoder-BNeg7hxG.js → zstd-browser-decoder-Z5736ep5.js} +2 -2
  20. package/build/server/assets/{app-CNGxG3wL.js → app-C4Vf0mu1.js} +2256 -470
  21. package/build/server/assets/{highlighted-body-JLMTFACH-Bj8JsfUl.js → highlighted-body-JLMTFACH-CF_5tt3-.js} +1 -1
  22. package/build/server/assets/{index-DGn_6xEN.js → index-BrYeW--s.js} +4 -4
  23. package/build/server/assets/{mermaid-WFAXDIZX-C_v93dNU.js → mermaid-WFAXDIZX-BHZz_uL6.js} +1 -1
  24. package/build/server/assets/{token-b1ZjKN2Q.js → token-B94O3LuJ.js} +1 -1
  25. package/build/server/assets/{token-5fcfNNDG.js → token-k0na1G9v.js} +2 -2
  26. package/build/server/assets/{token-util-BJhEZw83.js → token-util-DFlzY9Hw.js} +2 -2
  27. package/build/server/assets/{token-util-spPPOelu.js → token-util-DgTmPzWb.js} +1 -1
  28. package/build/server/assets/{wrapper-Cc-ChiPM.js → wrapper-BEqyNEir.js} +2 -2
  29. package/build/server/assets/{zstd-browser-decoder-y4X_FyMk.js → zstd-browser-decoder-LnaKiDUZ.js} +1 -1
  30. package/build/server/index.js +1 -1
  31. package/handler.d.ts +9 -0
  32. package/handler.js +16 -2
  33. package/host-guard.js +179 -0
  34. package/package.json +8 -7
  35. package/server.d.ts +15 -1
  36. package/server.js +14 -1
  37. package/build/client/assets/app-BE8uqS_d.css +0 -1
  38. package/build/client/assets/manifest-f2e93220.js +0 -1
  39. package/build/client/assets/root-BBptRWmF.css +0 -1
@@ -1,7 +1,10 @@
1
- import { r as reactExports, j as jsxRuntimeExports, A as useNavigate, z as Link, w as withComponentProps, D as useParams, B as useSearchParams } from "./index-BS6T0Zjc.js";
2
- import { _ as parseStepName, y as parseWorkflowName, $ as findStartHookCreation, t as ChevronUp, X, C as CircleAlert, a0 as Circle, B as CircleX, a1 as Wrench, a2 as ErrorCard, a3 as format, R as ResolveHookModal, Y as ErrorBoundary, u as unwrapOrThrow, W as WorkflowWebAPIError, N as unwrapServerActionResult, a4 as useInfiniteList, h as getErrorMessage, A as Alert, c as AlertTitle, e as AlertDescription, L as DialogPortal, M as DialogOverlay, a5 as createDialogScope, G as Dialog, a6 as DialogTrigger, H as DialogContent, J as DialogTitle, K as DialogDescription, I as DialogClose, a7 as LIVE_UPDATE_INTERVAL_MS$1, a8 as LAYOUT, P as useOptimisticSearchParams, a9 as wakeUpRun, r as resumeHook, d as getErrorTitle, a as Skeleton$1, aa as RunActionsButtons, z as StatusBadge, i as CopyableText, b as RelativeTime, T as Tabs, Q as TabsList, U as TabsTrigger, V as TabsContent, ab as cancelRun, ac as recreateRun } from "./url-state-DhOv2zv0.js";
3
- import { c as createLucideIcon, Q as isSlotEventId, U as classifyEntityEvent, X as TERMINAL_EVENT_CLASSES, Y as isSealedNoopEvent$1, Z as formatDurationPrecise, $ as isStepEventType, a0 as isWaitEventType, a1 as isHookLifecycleEventType, a2 as isEncryptedMarker, a3 as isTerminalStepEventType, a4 as isRunCreationEvent, e as cn, a5 as CopyButton, a6 as CopyableDataBlock, a7 as CollapsibleRoot, a8 as CollapsibleTrigger, a9 as CollapsibleContent, N as cva, aa as RESERVED_ATTRIBUTE_KEY_PREFIX, T as Tooltip, a as TooltipTrigger, ab as IconButton, b as TooltipContent, J as ChevronDown, B as Button, ac as Lock, ad as getEventDataRefFields, ae as Collapsible, af as Skeleton, ag as DecryptClickContext, ah as DataInspector, ai as serializeForClipboard, aj as useRowWindow, ak as isSpanDimmedBySearch, al as ROW_HEIGHT_PX, am as getSpanDurationMs, an as isSpanErrored, ao as isSpanCancelled, ap as TooltipProvider, aq as TimestampTooltip, ar as ContextCardProvider, as as es, at as Ui, C as Check, au as RunClickContext, av as StreamClickContext, aw as isExpiredMarker, ax as isDoStreamStep, ay as extractConversation, az as EncryptedDataBlock, j as Spinner, aA as hasEncryptedFields, h as useToast, aB as useSidebarDataOptional, aC as isTerminalWorkflowRunStatus, aD as useActiveSpan, aE as useSidebarData, aF as ActiveSpanProvider, aG as useReducedMotion, aH as searchSpans, aI as computeRootBounds, aJ as computeTimeMarkers, aK as clampViewportToRoot, aL as getHighResInMs, aM as scrollRowIntoView, aN as TIMELINE_PADDING_PX, aO as Minimap, aP as Timeline, aQ as TimelineHeader, aR as wheelZoomScaleFactor, aS as wheelDeltaToPixels, aT as SidebarDataProvider, aU as hydrateResourceIOAsync, aV as createStateResolver, aW as deriveRunPayloadKeys, aX as decodePayloadWithKey, aY as stateSourceId, aZ as getWebRevivers, a_ as fetchHook, m as fetchEvents, M as fetchRun, a$ as fetchStep, b0 as hydrateResourceIO, b1 as fetchStreams, b2 as apiBase, b3 as fetchEvent, b4 as fetchEventsByCorrelationId, w as createContextScope, n as useComposedRefs, y as composeEventHandlers, b5 as buttonVariants, b6 as Slot, l as ChevronRight, b7 as isEncryptedData, b8 as hydrateData, b9 as decrypt, ba as getStreamImageType, bb as SerializationFormat, u as useServerConfig, bc as getEncryptionKeyForRun, t as toast, bd as StreamViewerSkeleton, be as StreamViewer } from "./mermaid-WFAXDIZX-BLO7Z8RE.js";
4
- import { A as ArrowUpRight } from "./arrow-up-right-CNHh1bh2.js";
1
+ import { j as jsxRuntimeExports, r as reactExports, L as Link, B as useNavigate, E as useOutlet, w as withComponentProps, G as useParams, C as useSearchParams } from "./index-wl5l5E8H.js";
2
+ import { U as findStartHookCreation, q as ChevronUp, X, x as CircleX, V as Wrench, Y as ErrorCard, _ as format, R as ResolveHookModal, Q as ErrorBoundary, u as unwrapOrThrow, W as WorkflowWebAPIError, K as unwrapServerActionResult, $ as useInfiniteList, e as getErrorMessage, A as Alert, b as AlertTitle, d as AlertDescription, I as DialogPortal, J as DialogOverlay, a0 as createDialogScope, z as Dialog, a1 as DialogTrigger, B as DialogContent, G as DialogTitle, H as DialogDescription, F as DialogClose, a2 as LIVE_UPDATE_INTERVAL_MS$1, a3 as LAYOUT, a4 as tabsListClassName, a5 as tabsTriggerClassName, M as useOptimisticSearchParams, a6 as wakeUpRun, r as resumeHook, c as getErrorTitle, a7 as RunActionsButtons, w as StatusBadge, C as CopyableText, a as RelativeTime, T as Tabs, N as TabsList, O as TabsTrigger, P as TabsContent, a8 as cancelRun, a9 as recreateRun } from "./url-state-JAVaNZ_m.js";
3
+ import { c as createLucideIcon, Q as isSlotEventId, U as classifyEntityEvent, X as TERMINAL_EVENT_CLASSES, Y as isSealedNoopEvent$1, j as formatDurationPrecise, Z as isStepEventType, $ as isWaitEventType, a0 as isHookLifecycleEventType, a1 as isEncryptedMarker, a2 as isTerminalStepEventType, a3 as isRunCreationEvent, a as cn, a4 as CopyButton, a5 as CopyableDataBlock, a6 as CollapsibleRoot, a7 as CollapsibleTrigger, a8 as CollapsibleContent, O as cva, a9 as RESERVED_ATTRIBUTE_KEY_PREFIX, T as Tooltip, d as TooltipTrigger, aa as IconButton, e as TooltipContent, L as ChevronDown, B as Button, ab as Lock, ac as getEventDataRefFields, ad as Collapsible, ae as Skeleton, af as DecryptClickContext, ag as DataInspector, ah as serializeForClipboard, ai as TooltipProvider, aj as TimestampTooltip, ak as ContextCardProvider, al as es, am as Ui, n as Check, an as RunClickContext, ao as StreamClickContext, ap as isExpiredMarker, aq as isDoStreamStep, ar as extractConversation, as as EncryptedDataBlock, S as Spinner, at as hasEncryptedFields, m as useToast, au as useSidebarDataOptional, av as isTerminalWorkflowRunStatus, aw as useActiveSpan, ax as useSidebarData, ay as ActiveSpanProvider, az as useReducedMotion, aA as searchSpans, aB as computeRootBounds, aC as computeTimeMarkers, aD as clampViewportToRoot, aE as getHighResInMs, aF as scrollRowIntoView, aG as TIMELINE_PADDING_PX, b as ROW_HEIGHT_PX, aH as Minimap, aI as Timeline, aJ as TimelineHeader, aK as wheelZoomScaleFactor, aL as wheelDeltaToPixels, aM as SidebarDataProvider, aN as hydrateResourceIOAsync, aO as createStateResolver, aP as deriveRunPayloadKeys, aQ as decodePayloadWithKey, aR as stateSourceId, aS as getWebRevivers, aT as hydrateResourceIO, y as createContextScope, p as useComposedRefs, A as composeEventHandlers, aU as buttonVariants, aV as Slot, C as ChevronRight, aW as isEncryptedData, aX as hydrateData, aY as decrypt, aZ as getStreamImageType, a_ as SerializationFormat, t as toast, a$ as StreamViewerSkeleton, b0 as StreamViewer } from "./mermaid-WFAXDIZX-CB__BxYb.js";
4
+ import { p as parseStepName, a as parseWorkflowName, b as CircleAlert, S as Skeleton$1 } from "./skeleton-DMLgjvZZ.js";
5
+ import { M as MiddleTruncate, a as ResourceIcon, E as EventList, r as runUsagePath, b as runPath, c as RunUsageHeaderStats, C as CircleQuestionMark, u as usageVisible } from "./run-usage-DRV6lopZ.js";
6
+ import { A as ArrowUpRight } from "./arrow-up-right-DyaB_ak4.js";
7
+ import { d as fetchHook, a as fetchEvents, b as fetchRun, e as fetchStep, g as fetchStreams, h as apiBase, i as fetchEvent, j as fetchEventsByCorrelationId, k as fetchRunUsage, u as useServerConfig, l as getEncryptionKeyForRun } from "./rpc-client-SbyXJdFV.js";
5
8
  /**
6
9
  * @license lucide-react v0.575.0 - ISC
7
10
  *
@@ -9,12 +12,12 @@ import { A as ArrowUpRight } from "./arrow-up-right-CNHh1bh2.js";
9
12
  * See the LICENSE file in the root directory of this source tree.
10
13
  */
11
14
  const __iconNode$9 = [
12
- ["path", { d: "M10 6h8", key: "zvc2xc" }],
13
- ["path", { d: "M12 16h6", key: "yi5mkt" }],
14
15
  ["path", { d: "M3 3v16a2 2 0 0 0 2 2h16", key: "c24i48" }],
15
- ["path", { d: "M8 11h7", key: "wz2hg0" }]
16
+ ["path", { d: "M18 17V9", key: "2bz60n" }],
17
+ ["path", { d: "M13 17V5", key: "1frdt8" }],
18
+ ["path", { d: "M8 17v-3", key: "17ska0" }]
16
19
  ];
17
- const ChartGantt = createLucideIcon("chart-gantt", __iconNode$9);
20
+ const ChartColumn = createLucideIcon("chart-column", __iconNode$9);
18
21
  /**
19
22
  * @license lucide-react v0.575.0 - ISC
20
23
  *
@@ -22,11 +25,12 @@ const ChartGantt = createLucideIcon("chart-gantt", __iconNode$9);
22
25
  * See the LICENSE file in the root directory of this source tree.
23
26
  */
24
27
  const __iconNode$8 = [
25
- ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
26
- ["path", { d: "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3", key: "1u773s" }],
27
- ["path", { d: "M12 17h.01", key: "p32p05" }]
28
+ ["path", { d: "M10 6h8", key: "zvc2xc" }],
29
+ ["path", { d: "M12 16h6", key: "yi5mkt" }],
30
+ ["path", { d: "M3 3v16a2 2 0 0 0 2 2h16", key: "c24i48" }],
31
+ ["path", { d: "M8 11h7", key: "wz2hg0" }]
28
32
  ];
29
- const CircleQuestionMark = createLucideIcon("circle-question-mark", __iconNode$8);
33
+ const ChartGantt = createLucideIcon("chart-gantt", __iconNode$8);
30
34
  /**
31
35
  * @license lucide-react v0.575.0 - ISC
32
36
  *
@@ -1001,379 +1005,6 @@ function buildTrace(run, events, now, { isCompleteHistory = false, getStepAttrib
1001
1005
  duplicateEventIds
1002
1006
  };
1003
1007
  }
1004
- const ELLIPSIS = "…";
1005
- const MIN_START = 3;
1006
- const MIN_END = 3;
1007
- const MIN_KEPT = MIN_START + MIN_END;
1008
- const graphemeSegmenter = typeof Intl !== "undefined" && "Segmenter" in Intl ? new Intl.Segmenter(void 0, { granularity: "grapheme" }) : null;
1009
- function toGraphemes(text) {
1010
- if (graphemeSegmenter) {
1011
- return [...graphemeSegmenter.segment(text)].map((s) => s.segment);
1012
- }
1013
- return Array.from(text);
1014
- }
1015
- function buildCandidate(graphemes, kept) {
1016
- if (kept <= 0) {
1017
- return {
1018
- prefixText: "",
1019
- prefixGraphemeCount: 0,
1020
- suffixText: "",
1021
- suffixGraphemeCount: 0,
1022
- text: ELLIPSIS,
1023
- truncated: true
1024
- };
1025
- }
1026
- const suffixGraphemeCount = kept >= MIN_KEPT ? Math.max(MIN_END, Math.floor(kept / 2)) : Math.floor(kept / 2);
1027
- const prefixGraphemeCount = kept - suffixGraphemeCount;
1028
- const prefixText = graphemes.slice(0, prefixGraphemeCount).join("");
1029
- const suffixText = suffixGraphemeCount > 0 ? graphemes.slice(-suffixGraphemeCount).join("") : "";
1030
- return {
1031
- prefixText,
1032
- prefixGraphemeCount,
1033
- suffixText,
1034
- suffixGraphemeCount,
1035
- text: prefixText + ELLIPSIS + suffixText,
1036
- truncated: true
1037
- };
1038
- }
1039
- function middleTruncate(graphemes, availableWidth, measure, fullWidth) {
1040
- const fullText = graphemes.join("");
1041
- const resolvedFullWidth = fullWidth ?? measure(fullText);
1042
- if (availableWidth <= 0 || graphemes.length === 0) {
1043
- return {
1044
- prefixText: fullText,
1045
- prefixGraphemeCount: graphemes.length,
1046
- suffixText: "",
1047
- suffixGraphemeCount: 0,
1048
- text: fullText,
1049
- truncated: false
1050
- };
1051
- }
1052
- if (resolvedFullWidth <= availableWidth) {
1053
- return {
1054
- prefixText: fullText,
1055
- prefixGraphemeCount: graphemes.length,
1056
- suffixText: "",
1057
- suffixGraphemeCount: 0,
1058
- text: fullText,
1059
- truncated: false
1060
- };
1061
- }
1062
- let lo = 0;
1063
- let hi = graphemes.length - 1;
1064
- let best = -1;
1065
- while (lo <= hi) {
1066
- const mid = lo + hi >>> 1;
1067
- const candidate = buildCandidate(graphemes, mid);
1068
- if (measure(candidate.text) <= availableWidth) {
1069
- best = mid;
1070
- lo = mid + 1;
1071
- } else {
1072
- hi = mid - 1;
1073
- }
1074
- }
1075
- if (best === -1) {
1076
- return {
1077
- prefixText: "",
1078
- prefixGraphemeCount: 0,
1079
- suffixText: "",
1080
- suffixGraphemeCount: 0,
1081
- text: "",
1082
- truncated: true
1083
- };
1084
- }
1085
- return buildCandidate(graphemes, best);
1086
- }
1087
- function getMiddleTruncateCopyText({ prefixText, selectionEnd, selectionStart, suffixText, value }) {
1088
- const visibleText = prefixText + ELLIPSIS + suffixText;
1089
- if (selectionStart < 0 || selectionEnd > visibleText.length || selectionStart >= selectionEnd) {
1090
- return null;
1091
- }
1092
- if (selectionStart === 0 && selectionEnd === visibleText.length) {
1093
- return value;
1094
- }
1095
- const ellipsisStart = prefixText.length;
1096
- const ellipsisEnd = ellipsisStart + ELLIPSIS.length;
1097
- if (selectionStart > ellipsisStart || selectionEnd < ellipsisEnd) {
1098
- return null;
1099
- }
1100
- const originalGraphemes = toGraphemes(value);
1101
- const selectedPrefixGraphemeCount = toGraphemes(visibleText.slice(0, selectionStart)).length;
1102
- const selectedSuffixGraphemeCount = toGraphemes(visibleText.slice(ellipsisEnd, selectionEnd)).length;
1103
- const suffixStart = originalGraphemes.length - toGraphemes(suffixText).length;
1104
- return originalGraphemes.slice(selectedPrefixGraphemeCount, suffixStart + selectedSuffixGraphemeCount).join("");
1105
- }
1106
- function getMiddleTruncateCopyTextFromSelectionText({ prefixText, selectionText, suffixText, value }) {
1107
- const visibleText = prefixText + ELLIPSIS + suffixText;
1108
- const trimmedSelectionText = selectionText.trim();
1109
- if (!trimmedSelectionText) {
1110
- return null;
1111
- }
1112
- const leading = selectionText.slice(0, selectionText.length - selectionText.trimStart().length);
1113
- const trailing = selectionText.slice(selectionText.trimEnd().length);
1114
- if (trimmedSelectionText === visibleText) {
1115
- return leading + value + trailing;
1116
- }
1117
- if (!trimmedSelectionText.includes(ELLIPSIS)) {
1118
- return null;
1119
- }
1120
- const selectionStart = visibleText.indexOf(trimmedSelectionText);
1121
- if (selectionStart === -1) {
1122
- return null;
1123
- }
1124
- const selectionEnd = selectionStart + trimmedSelectionText.length;
1125
- const mappedText = getMiddleTruncateCopyText({
1126
- prefixText,
1127
- selectionEnd,
1128
- selectionStart,
1129
- suffixText,
1130
- value
1131
- });
1132
- return mappedText === null ? null : leading + mappedText + trailing;
1133
- }
1134
- const pendingMeasurements = /* @__PURE__ */ new Map();
1135
- let measurementFrame = 0;
1136
- function flushMeasurements() {
1137
- measurementFrame = 0;
1138
- const reads = [...pendingMeasurements.values()];
1139
- pendingMeasurements.clear();
1140
- const measures = reads.map((read) => read());
1141
- for (const measure of measures) {
1142
- measure == null ? void 0 : measure();
1143
- }
1144
- }
1145
- function scheduleMeasurement(key, { read, measure }) {
1146
- pendingMeasurements.set(key, () => {
1147
- const measurement = read();
1148
- return measurement === null ? null : () => measure(measurement);
1149
- });
1150
- if (measurementFrame === 0) {
1151
- measurementFrame = requestAnimationFrame(flushMeasurements);
1152
- }
1153
- }
1154
- function cancelMeasurement(key) {
1155
- pendingMeasurements.delete(key);
1156
- if (pendingMeasurements.size === 0 && measurementFrame !== 0) {
1157
- cancelAnimationFrame(measurementFrame);
1158
- measurementFrame = 0;
1159
- }
1160
- }
1161
- const useIsomorphicLayoutEffect = typeof window === "undefined" ? reactExports.useEffect : reactExports.useLayoutEffect;
1162
- function createFullState(value, graphemes) {
1163
- return {
1164
- displayText: value,
1165
- isTruncated: false,
1166
- prefixGraphemeCount: graphemes.length,
1167
- prefixText: value,
1168
- suffixGraphemeCount: 0,
1169
- suffixText: ""
1170
- };
1171
- }
1172
- function useMiddleTruncate(value) {
1173
- const graphemes = reactExports.useMemo(() => toGraphemes(value), [value]);
1174
- const fullState = reactExports.useMemo(() => createFullState(value, graphemes), [graphemes, value]);
1175
- const ref = reactExports.useRef(null);
1176
- const measureRef = reactExports.useRef(null);
1177
- const [state, setState] = reactExports.useState(() => fullState);
1178
- const measurementKeyRef = reactExports.useRef({});
1179
- const textMeasurementCacheRef = reactExports.useRef({
1180
- typography: "",
1181
- value,
1182
- widths: /* @__PURE__ */ new Map()
1183
- });
1184
- const lastMeasurementRef = reactExports.useRef(null);
1185
- const updateState = reactExports.useCallback((nextState) => {
1186
- setState((currentState) => {
1187
- 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) {
1188
- return currentState;
1189
- }
1190
- return nextState;
1191
- });
1192
- }, []);
1193
- const readMeasurement = reactExports.useCallback(() => {
1194
- const el = ref.current;
1195
- const measureEl = measureRef.current;
1196
- if (!el || !measureEl)
1197
- return null;
1198
- const availableWidth = el.clientWidth;
1199
- const style = getComputedStyle(measureEl);
1200
- return {
1201
- availableWidth,
1202
- typography: [
1203
- style.fontFamily,
1204
- style.fontFeatureSettings,
1205
- style.fontKerning,
1206
- style.fontSize,
1207
- style.fontStretch,
1208
- style.fontStyle,
1209
- style.fontVariationSettings,
1210
- style.fontWeight,
1211
- style.letterSpacing,
1212
- style.textTransform
1213
- ].join("\0")
1214
- };
1215
- }, []);
1216
- const recalculate = reactExports.useCallback(({ availableWidth, typography }) => {
1217
- const measureEl = measureRef.current;
1218
- if (!measureEl)
1219
- return;
1220
- const lastMeasurement = lastMeasurementRef.current;
1221
- if ((lastMeasurement == null ? void 0 : lastMeasurement.availableWidth) === availableWidth && lastMeasurement.typography === typography && lastMeasurement.value === value) {
1222
- return;
1223
- }
1224
- lastMeasurementRef.current = {
1225
- availableWidth,
1226
- typography,
1227
- value
1228
- };
1229
- if (availableWidth <= 0) {
1230
- updateState(fullState);
1231
- return;
1232
- }
1233
- const textMeasurementCache = textMeasurementCacheRef.current;
1234
- if (textMeasurementCache.typography !== typography || textMeasurementCache.value !== value) {
1235
- textMeasurementCache.typography = typography;
1236
- textMeasurementCache.value = value;
1237
- textMeasurementCache.widths.clear();
1238
- }
1239
- const measure = (text) => {
1240
- const cachedWidth = textMeasurementCache.widths.get(text);
1241
- if (cachedWidth !== void 0) {
1242
- return cachedWidth;
1243
- }
1244
- measureEl.textContent = text;
1245
- const width = measureEl.scrollWidth;
1246
- textMeasurementCache.widths.set(text, width);
1247
- return width;
1248
- };
1249
- const fullWidth = measure(value);
1250
- if (fullWidth <= availableWidth) {
1251
- updateState(fullState);
1252
- return;
1253
- }
1254
- const result = middleTruncate(graphemes, availableWidth, measure, fullWidth);
1255
- updateState({
1256
- displayText: result.text,
1257
- isTruncated: result.truncated,
1258
- prefixGraphemeCount: result.prefixGraphemeCount,
1259
- prefixText: result.prefixText,
1260
- suffixGraphemeCount: result.suffixGraphemeCount,
1261
- suffixText: result.suffixText
1262
- });
1263
- }, [fullState, graphemes, updateState, value]);
1264
- useIsomorphicLayoutEffect(() => {
1265
- const measurement = readMeasurement();
1266
- if (measurement) {
1267
- recalculate(measurement);
1268
- }
1269
- }, [readMeasurement, recalculate]);
1270
- reactExports.useEffect(() => {
1271
- var _a;
1272
- const el = ref.current;
1273
- if (!el)
1274
- return;
1275
- const measurementKey = measurementKeyRef.current;
1276
- const scheduleRecalculation = () => {
1277
- scheduleMeasurement(measurementKey, {
1278
- read: readMeasurement,
1279
- measure: recalculate
1280
- });
1281
- };
1282
- const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(scheduleRecalculation) : null;
1283
- ro == null ? void 0 : ro.observe(el);
1284
- if (!ro) {
1285
- window.addEventListener("resize", scheduleRecalculation);
1286
- }
1287
- const onFontsLoaded = () => {
1288
- textMeasurementCacheRef.current.widths.clear();
1289
- lastMeasurementRef.current = null;
1290
- scheduleRecalculation();
1291
- };
1292
- const fontSet = "fonts" in document ? document.fonts : null;
1293
- (_a = fontSet == null ? void 0 : fontSet.addEventListener) == null ? void 0 : _a.call(fontSet, "loadingdone", onFontsLoaded);
1294
- return () => {
1295
- var _a2;
1296
- ro == null ? void 0 : ro.disconnect();
1297
- if (!ro) {
1298
- window.removeEventListener("resize", scheduleRecalculation);
1299
- }
1300
- cancelMeasurement(measurementKey);
1301
- (_a2 = fontSet == null ? void 0 : fontSet.removeEventListener) == null ? void 0 : _a2.call(fontSet, "loadingdone", onFontsLoaded);
1302
- };
1303
- }, [readMeasurement, recalculate]);
1304
- return {
1305
- ref,
1306
- measureRef,
1307
- displayText: state.displayText,
1308
- isTruncated: state.isTruncated,
1309
- prefixGraphemeCount: state.prefixGraphemeCount,
1310
- prefixText: state.prefixText,
1311
- suffixGraphemeCount: state.suffixGraphemeCount,
1312
- suffixText: state.suffixText
1313
- };
1314
- }
1315
- function getRangeOffsets(container, range) {
1316
- if (!container.contains(range.startContainer) || !container.contains(range.endContainer)) {
1317
- return null;
1318
- }
1319
- let startRange;
1320
- let endRange;
1321
- try {
1322
- startRange = document.createRange();
1323
- startRange.selectNodeContents(container);
1324
- startRange.setEnd(range.startContainer, range.startOffset);
1325
- endRange = document.createRange();
1326
- endRange.selectNodeContents(container);
1327
- endRange.setEnd(range.endContainer, range.endOffset);
1328
- } catch {
1329
- return null;
1330
- }
1331
- return {
1332
- end: endRange.toString().length,
1333
- start: startRange.toString().length
1334
- };
1335
- }
1336
- function MiddleTruncate({ value, className, onCopy: onCopyProp, ...props }) {
1337
- const { ref, measureRef, displayText, isTruncated, prefixText, suffixText } = useMiddleTruncate(value);
1338
- const visibleRef = reactExports.useRef(null);
1339
- const handleCopy = reactExports.useCallback((e) => {
1340
- onCopyProp == null ? void 0 : onCopyProp(e);
1341
- if (e.defaultPrevented || !isTruncated)
1342
- return;
1343
- const selection = window.getSelection();
1344
- if (!selection || selection.rangeCount === 0)
1345
- return;
1346
- const selectionText = selection.toString();
1347
- if (!selectionText)
1348
- return;
1349
- const range = selection.getRangeAt(0);
1350
- const visibleEl = visibleRef.current;
1351
- let copyText = null;
1352
- if (selectionText.includes(ELLIPSIS) && e.currentTarget.contains(range.startContainer) && e.currentTarget.contains(range.endContainer) && visibleEl) {
1353
- const offsets = getRangeOffsets(visibleEl, range);
1354
- if (offsets) {
1355
- copyText = getMiddleTruncateCopyText({
1356
- prefixText,
1357
- selectionEnd: offsets.end,
1358
- selectionStart: offsets.start,
1359
- suffixText,
1360
- value
1361
- });
1362
- }
1363
- }
1364
- copyText ?? (copyText = getMiddleTruncateCopyTextFromSelectionText({
1365
- prefixText,
1366
- selectionText,
1367
- suffixText,
1368
- value
1369
- }));
1370
- if (copyText === null)
1371
- return;
1372
- e.preventDefault();
1373
- e.clipboardData.setData("text/plain", copyText);
1374
- }, [onCopyProp, isTruncated, prefixText, suffixText, value]);
1375
- 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 })] });
1376
- }
1377
1008
  function isReservedAttributeKey(key) {
1378
1009
  return key.startsWith(RESERVED_ATTRIBUTE_KEY_PREFIX);
1379
1010
  }
@@ -1918,56 +1549,6 @@ function EventListToolbar({ query, hint: hint2, onQueryChange }) {
1918
1549
  const shownHint = paused ? hint2 : null;
1919
1550
  return jsxRuntimeExports.jsxs("div", { className: "shrink-0", children: [jsxRuntimeExports.jsx(SearchInput, { name: "event-list-search", label: "Search events", placeholder: "Search by step ID, wait ID, hook ID, or event ID…", "aria-describedby": hintId, value: query, onValueChange: handleQueryChange, className: "pl-[34px]" }), jsxRuntimeExports.jsx("div", { id: hintId, "aria-live": "polite", children: shownHint ? jsxRuntimeExports.jsxs("div", { className: "flex h-8 items-center gap-1.5 bg-gray-100 pl-[34px] pr-2 text-label-13 text-gray-1000", children: [jsxRuntimeExports.jsx(Info, { className: "h-3.5 w-3.5 shrink-0 text-gray-900" }), jsxRuntimeExports.jsx("span", { className: "min-w-0 truncate", children: shownHint })] }) : null })] });
1920
1551
  }
1921
- const WorkflowIcon = () => {
1922
- 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" }) });
1923
- };
1924
- const WebhookIcon = () => {
1925
- 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" }) });
1926
- };
1927
- const SleepIcon = () => {
1928
- 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" }) });
1929
- };
1930
- const StepForwardIcon = () => {
1931
- 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" }) });
1932
- };
1933
- const eventStyles = {
1934
- run: { icon: WorkflowIcon, className: "text-blue-900", label: "Workflow" },
1935
- step: { icon: StepForwardIcon, className: "text-green-900", label: "Step" },
1936
- hook: { icon: WebhookIcon, className: "text-gray-900", label: "Hook" },
1937
- sleep: { icon: SleepIcon, className: "text-gray-900", label: "Sleep" }
1938
- };
1939
- const defaultStyle = {
1940
- icon: Circle,
1941
- className: "text-gray-900",
1942
- label: "Event"
1943
- };
1944
- const ROW_HEIGHT_CLASS = "h-10";
1945
- function getEventStyle(resource, isErrored, isCancelled) {
1946
- const style = eventStyles[resource] ?? defaultStyle;
1947
- return {
1948
- icon: style.icon,
1949
- className: cn(isErrored ? "text-red-900" : isCancelled ? "text-gray-900" : style.className),
1950
- label: style.label
1951
- };
1952
- }
1953
- function ResourceIcon({ resource, isErrored = false, isCancelled = false }) {
1954
- const { icon: Icon, className, label } = getEventStyle(resource, isErrored, isCancelled);
1955
- 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 })] });
1956
- }
1957
- const EventRow$1 = ({ span, isSelected, isDimmed, onSelectSpan }) => {
1958
- const durationMs = getSpanDurationMs(span);
1959
- const isErrored = isSpanErrored(span);
1960
- const isCancelled = isSpanCancelled(span);
1961
- 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) }) })] }) });
1962
- };
1963
- const EventList = ({ spans, activeSpanId, searchResult, onSelectSpan }) => {
1964
- const listRef = reactExports.useRef(null);
1965
- const { start, end } = useRowWindow(listRef, spans.length, ROW_HEIGHT_PX);
1966
- 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: {
1967
- paddingTop: start * ROW_HEIGHT_PX,
1968
- paddingBottom: (spans.length - end) * ROW_HEIGHT_PX
1969
- }, children: spans.slice(start, end).map((span) => jsxRuntimeExports.jsx(EventRow$1, { span, isSelected: span.spanId === activeSpanId, isDimmed: isSpanDimmedBySearch(span.spanId, searchResult), onSelectSpan }, span.spanId)) });
1970
- };
1971
1552
  function EventNoticeTooltip({ notice, children }) {
1972
1553
  if (!notice)
1973
1554
  return children;
@@ -4866,6 +4447,88 @@ function useCancellationReason(env, runId, status, events) {
4866
4447
  }, [env, runId, status, loadedReason]);
4867
4448
  return loadedReason ?? terminalReason;
4868
4449
  }
4450
+ const RUN_USAGE_REFRESH_INTERVAL_MS = 5e3;
4451
+ const SLOW_READ_BACKOFF = 10;
4452
+ function useRunUsage(env, runId, {
4453
+ enabled = true,
4454
+ live = false,
4455
+ refreshInterval = RUN_USAGE_REFRESH_INTERVAL_MS
4456
+ } = {}) {
4457
+ const [usage, setUsage] = reactExports.useState(void 0);
4458
+ const [loading, setLoading] = reactExports.useState(false);
4459
+ const [error, setError] = reactExports.useState(null);
4460
+ const latestRef = reactExports.useRef(0);
4461
+ const lastReadMsRef = reactExports.useRef(0);
4462
+ const inFlightRef = reactExports.useRef(0);
4463
+ const mountedRef = reactExports.useRef(true);
4464
+ reactExports.useEffect(() => {
4465
+ mountedRef.current = true;
4466
+ return () => {
4467
+ mountedRef.current = false;
4468
+ };
4469
+ }, []);
4470
+ const read = reactExports.useCallback(async () => {
4471
+ const seq = ++latestRef.current;
4472
+ const startedAt = Date.now();
4473
+ const isCurrent = () => mountedRef.current && seq === latestRef.current;
4474
+ inFlightRef.current++;
4475
+ setLoading(true);
4476
+ try {
4477
+ const result = await unwrapOrThrow(fetchRunUsage(env, runId));
4478
+ if (isCurrent()) {
4479
+ setUsage(result);
4480
+ setError(null);
4481
+ }
4482
+ } catch (err) {
4483
+ if (isCurrent()) {
4484
+ setError(err instanceof Error ? err : new Error(String(err)));
4485
+ }
4486
+ } finally {
4487
+ lastReadMsRef.current = Date.now() - startedAt;
4488
+ inFlightRef.current--;
4489
+ if (isCurrent()) setLoading(false);
4490
+ }
4491
+ }, [env, runId]);
4492
+ reactExports.useEffect(() => {
4493
+ setUsage(void 0);
4494
+ setError(null);
4495
+ }, [runId]);
4496
+ reactExports.useEffect(() => {
4497
+ if (!enabled) return;
4498
+ void read();
4499
+ }, [enabled, read]);
4500
+ const wasLiveRef = reactExports.useRef(live);
4501
+ reactExports.useEffect(() => {
4502
+ const wasLive = wasLiveRef.current;
4503
+ wasLiveRef.current = live;
4504
+ if (enabled && wasLive && !live) void read();
4505
+ }, [enabled, live, read]);
4506
+ const unsupported = usage === null;
4507
+ const polling = live || (usage == null ? void 0 : usage.inProgress) === true;
4508
+ reactExports.useEffect(() => {
4509
+ if (!enabled || !polling || unsupported) return;
4510
+ if (!refreshInterval || refreshInterval <= 0) return;
4511
+ let cancelled = false;
4512
+ let timer;
4513
+ const schedule = () => {
4514
+ const delay = Math.max(
4515
+ refreshInterval,
4516
+ SLOW_READ_BACKOFF * lastReadMsRef.current
4517
+ );
4518
+ timer = setTimeout(async () => {
4519
+ if (cancelled) return;
4520
+ if (inFlightRef.current === 0) await read();
4521
+ if (!cancelled) schedule();
4522
+ }, delay);
4523
+ };
4524
+ schedule();
4525
+ return () => {
4526
+ cancelled = true;
4527
+ clearTimeout(timer);
4528
+ };
4529
+ }, [enabled, polling, unsupported, refreshInterval, read]);
4530
+ return { usage, loading, error, refresh: read };
4531
+ }
4869
4532
  const FRAME_HEADER_SIZE = 4;
4870
4533
  const ENCRYPTED_PLACEHOLDER = "[Encrypted]";
4871
4534
  const POLL_INTERVAL_MS = 3e3;
@@ -5236,6 +4899,70 @@ function LiveStatus({ hasError, errorMessage }) {
5236
4899
  ({
5237
4900
  ...LAYOUT
5238
4901
  });
4902
+ const RUN_TABS = [
4903
+ { value: "trace", label: "Trace" },
4904
+ { value: "events", label: "Events" },
4905
+ { value: "streams", label: "Streams" }
4906
+ ];
4907
+ function focusRunViewItem(root, item) {
4908
+ const target = root == null ? void 0 : root.querySelector(
4909
+ `[data-run-view-item="${item}"]:is([aria-current="page"], [data-state="active"])`
4910
+ );
4911
+ if (!(target instanceof HTMLElement)) return false;
4912
+ target.focus();
4913
+ return true;
4914
+ }
4915
+ function runTabPath(runId, tab) {
4916
+ return `${runPath(runId)}?tab=${tab}`;
4917
+ }
4918
+ function UsageNavLink({
4919
+ runId,
4920
+ current = false,
4921
+ onNavigate
4922
+ }) {
4923
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
4924
+ Link,
4925
+ {
4926
+ to: runUsagePath(runId),
4927
+ className: cn(tabsTriggerClassName, "gap-2"),
4928
+ "aria-current": current ? "page" : void 0,
4929
+ "data-testid": "run-usage-nav-link",
4930
+ "data-run-view-item": "usage",
4931
+ onClick: () => onNavigate == null ? void 0 : onNavigate("usage"),
4932
+ children: [
4933
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ChartColumn, { className: "h-4 w-4", "aria-hidden": "true" }),
4934
+ "Usage"
4935
+ ]
4936
+ }
4937
+ );
4938
+ }
4939
+ const RUN_VIEW_ROW_CLASS = cn(
4940
+ tabsListClassName,
4941
+ "mb-4 max-w-full flex-none max-sm:[&_svg]:hidden"
4942
+ );
4943
+ function RunViewNav({
4944
+ runId,
4945
+ showUsage,
4946
+ onNavigate
4947
+ }) {
4948
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("nav", { "aria-label": "Run views", className: RUN_VIEW_ROW_CLASS, children: [
4949
+ RUN_TABS.map((tab) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
4950
+ Link,
4951
+ {
4952
+ to: runTabPath(runId, tab.value),
4953
+ className: cn(tabsTriggerClassName, "gap-2"),
4954
+ "data-run-view-item": tab.value,
4955
+ onClick: () => onNavigate == null ? void 0 : onNavigate(tab.value),
4956
+ children: [
4957
+ /* @__PURE__ */ jsxRuntimeExports.jsx(List, { className: "h-4 w-4", "aria-hidden": "true" }),
4958
+ tab.label
4959
+ ]
4960
+ },
4961
+ tab.value
4962
+ )),
4963
+ showUsage && /* @__PURE__ */ jsxRuntimeExports.jsx(UsageNavLink, { runId, current: true, onNavigate })
4964
+ ] });
4965
+ }
5239
4966
  function RunDetailView({
5240
4967
  runId,
5241
4968
  selectedId: _selectedId
@@ -5249,8 +4976,8 @@ function RunDetailView({
5249
4976
  const [showCancelDialog, setShowCancelDialog] = reactExports.useState(false);
5250
4977
  const [showRerunDialog, setShowRerunDialog] = reactExports.useState(false);
5251
4978
  const env = reactExports.useMemo(() => ({}), []);
5252
- const rawTab = searchParams.get("tab") || "trace";
5253
- const activeTab = rawTab === "graph" ? "trace" : rawTab;
4979
+ const rawTab = searchParams.get("tab");
4980
+ const activeTab = rawTab === "events" || rawTab === "streams" ? rawTab : "trace";
5254
4981
  const selectedStreamId = searchParams.get("streamId");
5255
4982
  const initialSelectedSpanId = searchParams.get("spanId") ?? void 0;
5256
4983
  const setActiveTab = reactExports.useCallback(
@@ -5317,7 +5044,7 @@ function RunDetailView({
5317
5044
  },
5318
5045
  [env, stateHydrator]
5319
5046
  );
5320
- serverConfig.backendId === "local" || serverConfig.backendId === "@workflow/world-local";
5047
+ const isLocalBackend = serverConfig.backendId === "local" || serverConfig.backendId === "@workflow/world-local";
5321
5048
  const {
5322
5049
  run: runData,
5323
5050
  events: allEvents,
@@ -5392,6 +5119,23 @@ function RunDetailView({
5392
5119
  hasEncryptedData
5393
5120
  ]
5394
5121
  );
5122
+ const runIsLive = Boolean(run.status) && !isTerminalWorkflowRunStatus(run.status);
5123
+ const runUsageState = useRunUsage(env, runId, { live: runIsLive });
5124
+ const { usage: runUsage, error: runUsageError } = runUsageState;
5125
+ const showUsage = usageVisible(runUsage, isLocalBackend);
5126
+ const usageContext = { runId, usage: runUsageState };
5127
+ const usagePage = useOutlet(usageContext);
5128
+ const viewRootRef = reactExports.useRef(null);
5129
+ const pendingRowFocus = reactExports.useRef(null);
5130
+ const focusRowItemAfterNavigation = reactExports.useCallback((item) => {
5131
+ pendingRowFocus.current = item;
5132
+ }, []);
5133
+ reactExports.useEffect(() => {
5134
+ const item = pendingRowFocus.current;
5135
+ if (item && focusRunViewItem(viewRootRef.current, item)) {
5136
+ pendingRowFocus.current = null;
5137
+ }
5138
+ });
5395
5139
  const {
5396
5140
  streams,
5397
5141
  loading: streamsLoading,
@@ -5486,196 +5230,260 @@ function RunDetailView({
5486
5230
  /* @__PURE__ */ jsxRuntimeExports.jsx(AlertDialogAction, { onClick: handleConfirmRerun, children: "Replay Run" })
5487
5231
  ] })
5488
5232
  ] }) }),
5489
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col h-[calc(100vh-97px)]", children: [
5490
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-none space-y-4", children: [
5491
- /* @__PURE__ */ jsxRuntimeExports.jsx(Breadcrumb, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(BreadcrumbList, { children: [
5492
- /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbItem, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbLink, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Link, { to: "/", children: "Runs" }) }) }),
5493
- /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbSeparator, {}),
5494
- /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbItem, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbPage, { className: "font-mono text-xs", children: runId }) })
5495
- ] }) }),
5496
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4 p-6 border rounded-lg", children: [
5497
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start justify-between", children: [
5498
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("h1", { className: "text-xl font-semibold", children: workflowName ? workflowName : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton$1, { className: "w-[260px] h-[28px]" }) }) }),
5499
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
5500
- /* @__PURE__ */ jsxRuntimeExports.jsx(LiveStatus, { hasError, errorMessage }),
5501
- /* @__PURE__ */ jsxRuntimeExports.jsx(
5502
- RunActionsButtons,
5503
- {
5504
- env,
5505
- runId,
5506
- runStatus: run.status,
5507
- events: allEvents,
5508
- eventsLoading: loading,
5509
- loading,
5510
- replayDisabledReason: isDynamicRun ? "Dynamic runs cannot be replayed as a new run." : void 0,
5511
- onRerunClick: handleRerunClick,
5512
- onCancelClick: handleCancelClick,
5513
- callbacks: { onSuccess: update }
5514
- }
5515
- )
5516
- ] })
5517
- ] }),
5518
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-8", children: [
5519
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
5520
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-muted-foreground", children: "Status" }),
5521
- run.status ? /* @__PURE__ */ jsxRuntimeExports.jsx(
5522
- StatusBadge,
5523
- {
5524
- status: run.status,
5525
- context: { error: run.error, cancelReason }
5526
- }
5527
- ) : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton$1, { className: "w-[55px] h-[24px]" })
5528
- ] }),
5529
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
5530
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-muted-foreground", children: "Duration" }),
5531
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs", children: run.runId ? run.startedAt ? (() => {
5532
- const ms = (run.completedAt ? new Date(run.completedAt).getTime() : Date.now()) - new Date(run.startedAt).getTime();
5533
- const seconds = Math.floor(ms / 1e3);
5534
- if (seconds < 60) return `${seconds}s`;
5535
- const minutes = Math.floor(seconds / 60);
5536
- const remainingSeconds = seconds % 60;
5537
- if (minutes < 60) {
5538
- return remainingSeconds > 0 ? `${minutes}m ${remainingSeconds}s` : `${minutes}m`;
5539
- }
5540
- const hours = Math.floor(minutes / 60);
5541
- const remainingMinutes = minutes % 60;
5542
- return remainingMinutes > 0 ? `${hours}h ${remainingMinutes}m` : `${hours}h`;
5543
- })() : "-" : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton$1, { className: "w-[60px] h-[20px]" }) })
5544
- ] }),
5545
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
5546
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-muted-foreground", children: "Run ID" }),
5547
- run.runId ? /* @__PURE__ */ jsxRuntimeExports.jsx(CopyableText, { text: run.runId, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs mt-0.5 font-mono", children: run.runId }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton$1, { className: "w-[280px] h-[20px]" })
5548
- ] }),
5549
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
5550
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-muted-foreground", children: "Queued" }),
5551
- run.createdAt ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs", children: /* @__PURE__ */ jsxRuntimeExports.jsx(RelativeTime, { date: run.createdAt }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton$1, { className: "w-[110px] h-[20px]" })
5552
- ] }),
5553
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
5554
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-muted-foreground", children: "Started" }),
5555
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs", children: run.runId ? run.startedAt ? /* @__PURE__ */ jsxRuntimeExports.jsx(RelativeTime, { date: run.startedAt }) : "-" : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton$1, { className: "w-[110px] h-[20px]" }) })
5556
- ] }),
5557
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
5558
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-muted-foreground", children: "Completed" }),
5559
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs", children: run.runId ? run.completedAt ? /* @__PURE__ */ jsxRuntimeExports.jsx(RelativeTime, { date: run.completedAt }) : "-" : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton$1, { className: "w-[110px] h-[20px]" }) })
5560
- ] }),
5561
- run.expiredAt != null && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
5562
- /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
5563
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-muted-foreground cursor-help flex items-center gap-1", children: [
5564
- "Expired",
5565
- /* @__PURE__ */ jsxRuntimeExports.jsx(CircleQuestionMark, { className: "w-3 h-3" })
5566
- ] }) }),
5567
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: "The storage data for this run has expired and is no longer available." }) })
5568
- ] }),
5569
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs", children: /* @__PURE__ */ jsxRuntimeExports.jsx(RelativeTime, { date: run.expiredAt }) })
5570
- ] })
5571
- ] })
5572
- ] }),
5573
- /* @__PURE__ */ jsxRuntimeExports.jsx(RunLimitGuidanceAlert, { run: runData })
5574
- ] }),
5575
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-4 flex-1 flex flex-col min-h-0", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
5576
- Tabs,
5577
- {
5578
- value: activeTab,
5579
- onValueChange: (v) => setActiveTab(v),
5580
- className: "flex-1 flex flex-col min-h-0",
5581
- children: [
5582
- /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsList, { className: "mb-4 flex-none", children: [
5583
- /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsTrigger, { value: "trace", className: "gap-2", children: [
5584
- /* @__PURE__ */ jsxRuntimeExports.jsx(List, { className: "h-4 w-4" }),
5585
- "Trace"
5586
- ] }),
5587
- false,
5588
- /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsTrigger, { value: "events", className: "gap-2", children: [
5589
- /* @__PURE__ */ jsxRuntimeExports.jsx(List, { className: "h-4 w-4" }),
5590
- "Events"
5233
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
5234
+ "div",
5235
+ {
5236
+ ref: viewRootRef,
5237
+ className: usagePage ? "flex flex-col" : "flex flex-col h-[calc(100vh-97px)]",
5238
+ children: [
5239
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-none space-y-4", children: [
5240
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Breadcrumb, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(BreadcrumbList, { children: [
5241
+ /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbItem, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbLink, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Link, { to: "/", children: "Runs" }) }) }),
5242
+ /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbSeparator, {}),
5243
+ /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbItem, { children: usagePage ? /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbLink, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Link, { to: runPath(runId), className: "font-mono text-xs", children: runId }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbPage, { className: "font-mono text-xs", children: runId }) }),
5244
+ usagePage && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
5245
+ /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbSeparator, {}),
5246
+ /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbItem, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbPage, { children: "Usage" }) })
5247
+ ] })
5248
+ ] }) }),
5249
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4 p-6 border rounded-lg", children: [
5250
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap items-start justify-between gap-x-4 gap-y-2", children: [
5251
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("h1", { className: "text-xl font-semibold", children: workflowName ? workflowName : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton$1, { className: "w-[260px] h-[28px]" }) }) }),
5252
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
5253
+ /* @__PURE__ */ jsxRuntimeExports.jsx(LiveStatus, { hasError, errorMessage }),
5254
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
5255
+ RunActionsButtons,
5256
+ {
5257
+ env,
5258
+ runId,
5259
+ runStatus: run.status,
5260
+ events: allEvents,
5261
+ eventsLoading: loading,
5262
+ loading,
5263
+ replayDisabledReason: isDynamicRun ? "Dynamic runs cannot be replayed as a new run." : void 0,
5264
+ onRerunClick: handleRerunClick,
5265
+ onCancelClick: handleCancelClick,
5266
+ callbacks: { onSuccess: update }
5267
+ }
5268
+ )
5269
+ ] })
5591
5270
  ] }),
5592
- /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsTrigger, { value: "streams", className: "gap-2", children: [
5593
- /* @__PURE__ */ jsxRuntimeExports.jsx(List, { className: "h-4 w-4" }),
5594
- "Streams"
5271
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap items-start gap-x-8 gap-y-4", children: [
5272
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
5273
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-muted-foreground", children: "Status" }),
5274
+ run.status ? /* @__PURE__ */ jsxRuntimeExports.jsx(
5275
+ StatusBadge,
5276
+ {
5277
+ status: run.status,
5278
+ context: { error: run.error, cancelReason }
5279
+ }
5280
+ ) : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton$1, { className: "w-[55px] h-[24px]" })
5281
+ ] }),
5282
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
5283
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-muted-foreground", children: "Duration" }),
5284
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs", children: run.runId ? run.startedAt ? (() => {
5285
+ const ms = (run.completedAt ? new Date(run.completedAt).getTime() : Date.now()) - new Date(run.startedAt).getTime();
5286
+ const seconds = Math.floor(ms / 1e3);
5287
+ if (seconds < 60) return `${seconds}s`;
5288
+ const minutes = Math.floor(seconds / 60);
5289
+ const remainingSeconds = seconds % 60;
5290
+ if (minutes < 60) {
5291
+ return remainingSeconds > 0 ? `${minutes}m ${remainingSeconds}s` : `${minutes}m`;
5292
+ }
5293
+ const hours = Math.floor(minutes / 60);
5294
+ const remainingMinutes = minutes % 60;
5295
+ return remainingMinutes > 0 ? `${hours}h ${remainingMinutes}m` : `${hours}h`;
5296
+ })() : "-" : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton$1, { className: "w-[60px] h-[20px]" }) })
5297
+ ] }),
5298
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
5299
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-muted-foreground", children: "Run ID" }),
5300
+ run.runId ? /* @__PURE__ */ jsxRuntimeExports.jsx(CopyableText, { text: run.runId, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs mt-0.5 font-mono", children: run.runId }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton$1, { className: "w-[280px] h-[20px]" })
5301
+ ] }),
5302
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
5303
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-muted-foreground", children: "Queued" }),
5304
+ run.createdAt ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs", children: /* @__PURE__ */ jsxRuntimeExports.jsx(RelativeTime, { date: run.createdAt }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton$1, { className: "w-[110px] h-[20px]" })
5305
+ ] }),
5306
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
5307
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-muted-foreground", children: "Started" }),
5308
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs", children: run.runId ? run.startedAt ? /* @__PURE__ */ jsxRuntimeExports.jsx(RelativeTime, { date: run.startedAt }) : "-" : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton$1, { className: "w-[110px] h-[20px]" }) })
5309
+ ] }),
5310
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
5311
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-muted-foreground", children: "Completed" }),
5312
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs", children: run.runId ? run.completedAt ? /* @__PURE__ */ jsxRuntimeExports.jsx(RelativeTime, { date: run.completedAt }) : "-" : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton$1, { className: "w-[110px] h-[20px]" }) })
5313
+ ] }),
5314
+ showUsage && /* @__PURE__ */ jsxRuntimeExports.jsx(
5315
+ RunUsageHeaderStats,
5316
+ {
5317
+ runId,
5318
+ usage: runUsage ?? void 0,
5319
+ error: runUsageError,
5320
+ isLocalBackend,
5321
+ onUsagePage: usagePage != null
5322
+ }
5323
+ ),
5324
+ run.expiredAt != null && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
5325
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
5326
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-muted-foreground cursor-help flex items-center gap-1", children: [
5327
+ "Expired",
5328
+ /* @__PURE__ */ jsxRuntimeExports.jsx(CircleQuestionMark, { className: "w-3 h-3" })
5329
+ ] }) }),
5330
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: "The storage data for this run has expired and is no longer available." }) })
5331
+ ] }),
5332
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs", children: /* @__PURE__ */ jsxRuntimeExports.jsx(RelativeTime, { date: run.expiredAt }) })
5333
+ ] })
5595
5334
  ] })
5596
5335
  ] }),
5597
- /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "trace", className: "mt-0 flex-1 min-h-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary, { title: "Failed to load trace viewer", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative h-full -mx-6 bg-background-100 border-t border-gray-alpha-400 overflow-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
5598
- TraceViewer,
5599
- {
5600
- run,
5601
- events: allEvents ?? [],
5602
- loading,
5603
- sidebarData,
5604
- onLoadMore: loadMoreTraceData,
5605
- hasMore: hasMoreTraceData,
5606
- isLoadingMore: isLoadingMoreTraceData,
5607
- initialSelectedSpanId
5608
- }
5609
- ) }) }) }),
5610
- /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "events", className: "mt-0 flex-1 min-h-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary, { title: "Failed to load events list", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative h-full -mx-6 bg-background-100 border-t border-gray-alpha-400 overflow-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
5611
- RunEventsTab,
5336
+ /* @__PURE__ */ jsxRuntimeExports.jsx(RunLimitGuidanceAlert, { run: runData })
5337
+ ] }),
5338
+ usagePage ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-4", children: [
5339
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
5340
+ RunViewNav,
5612
5341
  {
5613
- env,
5614
5342
  runId,
5615
- run,
5616
- onLoadEventData: handleLoadEventData,
5617
- encryptionKey: encryptionKey ?? void 0,
5618
- sortOrder: eventsSortOrder,
5619
- onSortOrderChange: setEventsSortOrder,
5620
- onDecrypt: handleDecrypt,
5621
- isDecrypting,
5622
- onViewInTrace: (spanId) => updateSearchParams({ tab: "trace", spanId })
5343
+ showUsage,
5344
+ onNavigate: focusRowItemAfterNavigation
5623
5345
  }
5624
- ) }) }) }),
5625
- /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "streams", className: "mt-0 flex-1 min-h-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary, { title: "Failed to load stream data", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative -mx-6 flex h-full min-h-0 overflow-hidden border-t border-gray-alpha-400 bg-background-100", children: [
5626
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex w-[340px] shrink-0 flex-col border-r border-gray-alpha-400 bg-background-100", children: [
5627
- /* @__PURE__ */ jsxRuntimeExports.jsx(
5628
- "div",
5346
+ ),
5347
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary, { title: "Failed to load run usage", children: usagePage })
5348
+ ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-4 flex-1 flex flex-col min-h-0", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
5349
+ Tabs,
5350
+ {
5351
+ value: activeTab,
5352
+ onValueChange: (v) => setActiveTab(v),
5353
+ className: "flex-1 flex flex-col min-h-0",
5354
+ children: [
5355
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: RUN_VIEW_ROW_CLASS, children: [
5356
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsList, { className: "h-auto border-0 bg-transparent p-0", children: [
5357
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
5358
+ TabsTrigger,
5359
+ {
5360
+ value: "trace",
5361
+ className: "gap-2",
5362
+ "data-run-view-item": "trace",
5363
+ children: [
5364
+ /* @__PURE__ */ jsxRuntimeExports.jsx(List, { className: "h-4 w-4" }),
5365
+ "Trace"
5366
+ ]
5367
+ }
5368
+ ),
5369
+ false,
5370
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
5371
+ TabsTrigger,
5372
+ {
5373
+ value: "events",
5374
+ className: "gap-2",
5375
+ "data-run-view-item": "events",
5376
+ children: [
5377
+ /* @__PURE__ */ jsxRuntimeExports.jsx(List, { className: "h-4 w-4" }),
5378
+ "Events"
5379
+ ]
5380
+ }
5381
+ ),
5382
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
5383
+ TabsTrigger,
5384
+ {
5385
+ value: "streams",
5386
+ className: "gap-2",
5387
+ "data-run-view-item": "streams",
5388
+ children: [
5389
+ /* @__PURE__ */ jsxRuntimeExports.jsx(List, { className: "h-4 w-4" }),
5390
+ "Streams"
5391
+ ]
5392
+ }
5393
+ )
5394
+ ] }),
5395
+ showUsage && /* @__PURE__ */ jsxRuntimeExports.jsx(
5396
+ UsageNavLink,
5397
+ {
5398
+ runId,
5399
+ onNavigate: focusRowItemAfterNavigation
5400
+ }
5401
+ )
5402
+ ] }),
5403
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "trace", className: "mt-0 flex-1 min-h-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary, { title: "Failed to load trace viewer", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative h-full -mx-6 bg-background-100 border-t border-gray-alpha-400 overflow-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
5404
+ TraceViewer,
5629
5405
  {
5630
- "aria-hidden": "true",
5631
- className: "h-10 min-h-10 border-b border-gray-alpha-400"
5406
+ run,
5407
+ events: allEvents ?? [],
5408
+ loading,
5409
+ sidebarData,
5410
+ onLoadMore: loadMoreTraceData,
5411
+ hasMore: hasMoreTraceData,
5412
+ isLoadingMore: isLoadingMoreTraceData,
5413
+ initialSelectedSpanId
5632
5414
  }
5633
- ),
5634
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "min-h-0 flex-1 divide-y divide-gray-400 overflow-y-auto", children: streamsLoading ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col divide-y divide-gray-400", children: [
5635
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-10 min-h-10 items-center pl-4 pr-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton$1, { className: "h-3.5 w-24" }) }),
5636
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-10 min-h-10 items-center pl-4 pr-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton$1, { className: "h-3.5 w-32" }) }),
5637
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-10 min-h-10 items-center pl-4 pr-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton$1, { className: "h-3.5 w-20" }) })
5638
- ] }) : streamsError ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-4 py-2 text-label-12 text-red-900", children: streamsError.message }) : streams.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-10 min-h-10 items-center px-4 text-label-12 text-gray-900", children: "No streams found for this run" }) : streams.map((streamId) => /* @__PURE__ */ jsxRuntimeExports.jsx(
5639
- "button",
5640
- {
5641
- type: "button",
5642
- onClick: () => setSelectedStreamId(streamId),
5643
- className: `flex h-10 min-h-10 w-full min-w-0 items-center truncate pl-4 pr-2 text-left text-label-14 transition-colors ${selectedStreamId === streamId ? "bg-gray-100 text-gray-1000 hover:bg-gray-200 active:bg-gray-200" : "bg-transparent text-gray-900 hover:bg-gray-100 hover:text-gray-1000 focus-visible:bg-gray-100 focus-visible:text-gray-1000"}`,
5644
- title: streamId,
5645
- children: streamId
5646
- },
5647
- streamId
5648
- )) })
5649
- ] }),
5650
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex min-w-0 flex-1 flex-col overflow-hidden bg-background-100", children: streamsLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx(StreamViewerSkeleton, {}) }) : selectedStreamId ? (streamError == null ? void 0 : streamError.includes("encrypted")) && !encryptionKey ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-full items-center justify-center p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center gap-3 text-center", children: [
5651
- /* @__PURE__ */ jsxRuntimeExports.jsx(Lock, { className: "h-8 w-8 text-gray-700" }),
5652
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [
5653
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-label-14 font-medium text-gray-1000", children: "Encrypted Stream" }),
5654
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-label-12 text-gray-900", children: "Decrypt this stream to view its chunks." })
5655
- ] }),
5656
- /* @__PURE__ */ jsxRuntimeExports.jsx(
5657
- DecryptButton,
5415
+ ) }) }) }),
5416
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "events", className: "mt-0 flex-1 min-h-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary, { title: "Failed to load events list", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative h-full -mx-6 bg-background-100 border-t border-gray-alpha-400 overflow-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
5417
+ RunEventsTab,
5658
5418
  {
5659
- onClick: handleDecrypt,
5660
- loading: isDecrypting
5419
+ env,
5420
+ runId,
5421
+ run,
5422
+ onLoadEventData: handleLoadEventData,
5423
+ encryptionKey: encryptionKey ?? void 0,
5424
+ sortOrder: eventsSortOrder,
5425
+ onSortOrderChange: setEventsSortOrder,
5426
+ onDecrypt: handleDecrypt,
5427
+ isDecrypting,
5428
+ onViewInTrace: (spanId) => updateSearchParams({ tab: "trace", spanId })
5661
5429
  }
5662
- )
5663
- ] }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
5664
- StreamViewer,
5665
- {
5666
- streamId: selectedStreamId,
5667
- chunks: streamChunks,
5668
- isLive: streamIsLive,
5669
- isLoading: streamIsInitialLoading,
5670
- error: (streamError == null ? void 0 : streamError.includes("encrypted")) ? null : streamError
5671
- }
5672
- ) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-label-14 text-gray-600", children: streams.length > 0 ? "Select a stream to view its data" : "No streams available" }) }) })
5673
- ] }) }) }),
5674
- false
5675
- ]
5676
- }
5677
- ) })
5678
- ] })
5430
+ ) }) }) }),
5431
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "streams", className: "mt-0 flex-1 min-h-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary, { title: "Failed to load stream data", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative -mx-6 flex h-full min-h-0 overflow-hidden border-t border-gray-alpha-400 bg-background-100", children: [
5432
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex w-[340px] shrink-0 flex-col border-r border-gray-alpha-400 bg-background-100", children: [
5433
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
5434
+ "div",
5435
+ {
5436
+ "aria-hidden": "true",
5437
+ className: "h-10 min-h-10 border-b border-gray-alpha-400"
5438
+ }
5439
+ ),
5440
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "min-h-0 flex-1 divide-y divide-gray-400 overflow-y-auto", children: streamsLoading ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col divide-y divide-gray-400", children: [
5441
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-10 min-h-10 items-center pl-4 pr-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton$1, { className: "h-3.5 w-24" }) }),
5442
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-10 min-h-10 items-center pl-4 pr-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton$1, { className: "h-3.5 w-32" }) }),
5443
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-10 min-h-10 items-center pl-4 pr-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton$1, { className: "h-3.5 w-20" }) })
5444
+ ] }) : streamsError ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-4 py-2 text-label-12 text-red-900", children: streamsError.message }) : streams.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-10 min-h-10 items-center px-4 text-label-12 text-gray-900", children: "No streams found for this run" }) : streams.map((streamId) => /* @__PURE__ */ jsxRuntimeExports.jsx(
5445
+ "button",
5446
+ {
5447
+ type: "button",
5448
+ onClick: () => setSelectedStreamId(streamId),
5449
+ className: `flex h-10 min-h-10 w-full min-w-0 items-center truncate pl-4 pr-2 text-left text-label-14 transition-colors ${selectedStreamId === streamId ? "bg-gray-100 text-gray-1000 hover:bg-gray-200 active:bg-gray-200" : "bg-transparent text-gray-900 hover:bg-gray-100 hover:text-gray-1000 focus-visible:bg-gray-100 focus-visible:text-gray-1000"}`,
5450
+ title: streamId,
5451
+ children: streamId
5452
+ },
5453
+ streamId
5454
+ )) })
5455
+ ] }),
5456
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex min-w-0 flex-1 flex-col overflow-hidden bg-background-100", children: streamsLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx(StreamViewerSkeleton, {}) }) : selectedStreamId ? (streamError == null ? void 0 : streamError.includes("encrypted")) && !encryptionKey ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-full items-center justify-center p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center gap-3 text-center", children: [
5457
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Lock, { className: "h-8 w-8 text-gray-700" }),
5458
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [
5459
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-label-14 font-medium text-gray-1000", children: "Encrypted Stream" }),
5460
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-label-12 text-gray-900", children: "Decrypt this stream to view its chunks." })
5461
+ ] }),
5462
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
5463
+ DecryptButton,
5464
+ {
5465
+ onClick: handleDecrypt,
5466
+ loading: isDecrypting
5467
+ }
5468
+ )
5469
+ ] }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
5470
+ StreamViewer,
5471
+ {
5472
+ streamId: selectedStreamId,
5473
+ chunks: streamChunks,
5474
+ isLive: streamIsLive,
5475
+ isLoading: streamIsInitialLoading,
5476
+ error: (streamError == null ? void 0 : streamError.includes("encrypted")) ? null : streamError
5477
+ }
5478
+ ) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-label-14 text-gray-600", children: streams.length > 0 ? "Select a stream to view its data" : "No streams available" }) }) })
5479
+ ] }) }) }),
5480
+ false
5481
+ ]
5482
+ }
5483
+ ) })
5484
+ ]
5485
+ }
5486
+ )
5679
5487
  ] });
5680
5488
  }
5681
5489
  const runDetail = withComponentProps(function RunDetailPage() {