@lincyaw/aegis-ui 0.11.0 → 0.12.1
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/dist/agent/ask/AskPanel.cjs +1 -1
- package/dist/agent/ask/AskPanel.cjs.map +1 -1
- package/dist/agent/ask/AskPanel.js +25 -25
- package/dist/agent/ask/AskPanel.js.map +1 -1
- package/dist/components/ui/Button.cjs.map +1 -1
- package/dist/components/ui/Button.d.ts +4 -2
- package/dist/components/ui/Button.js.map +1 -1
- package/dist/components/ui/CheckGrid.cjs +1 -1
- package/dist/components/ui/CheckGrid.cjs.map +1 -1
- package/dist/components/ui/CheckGrid.js +18 -17
- package/dist/components/ui/CheckGrid.js.map +1 -1
- package/dist/components/ui/CodeEditor.cjs +1 -1
- package/dist/components/ui/CodeEditor.cjs.map +1 -1
- package/dist/components/ui/CodeEditor.js +95 -87
- package/dist/components/ui/CodeEditor.js.map +1 -1
- package/dist/components/ui/CommandInvocationCard.cjs +1 -1
- package/dist/components/ui/CommandInvocationCard.cjs.map +1 -1
- package/dist/components/ui/CommandInvocationCard.js +10 -10
- package/dist/components/ui/CommandInvocationCard.js.map +1 -1
- package/dist/components/ui/DangerZone.cjs +1 -1
- package/dist/components/ui/DangerZone.cjs.map +1 -1
- package/dist/components/ui/DangerZone.js +12 -12
- package/dist/components/ui/DangerZone.js.map +1 -1
- package/dist/components/ui/DataList.cjs +1 -1
- package/dist/components/ui/DataList.cjs.map +1 -1
- package/dist/components/ui/DataList.js +4 -3
- package/dist/components/ui/DataList.js.map +1 -1
- package/dist/components/ui/DataTable.cjs +1 -1
- package/dist/components/ui/DataTable.cjs.map +1 -1
- package/dist/components/ui/DataTable.d.ts +2 -1
- package/dist/components/ui/DataTable.js +125 -108
- package/dist/components/ui/DataTable.js.map +1 -1
- package/dist/components/ui/DiffViewer.cjs +1 -1
- package/dist/components/ui/DiffViewer.cjs.map +1 -1
- package/dist/components/ui/DiffViewer.js +29 -25
- package/dist/components/ui/DiffViewer.js.map +1 -1
- package/dist/components/ui/DropdownMenu.cjs.map +1 -1
- package/dist/components/ui/DropdownMenu.d.ts +1 -0
- package/dist/components/ui/DropdownMenu.js.map +1 -1
- package/dist/components/ui/FileDropzone.cjs +1 -1
- package/dist/components/ui/FileDropzone.cjs.map +1 -1
- package/dist/components/ui/FileDropzone.js +12 -12
- package/dist/components/ui/FileDropzone.js.map +1 -1
- package/dist/components/ui/FilePreview.cjs +1 -1
- package/dist/components/ui/FilePreview.cjs.map +1 -1
- package/dist/components/ui/FilePreview.js +16 -13
- package/dist/components/ui/FilePreview.js.map +1 -1
- package/dist/components/ui/ParetoChart.cjs +1 -1
- package/dist/components/ui/ParetoChart.cjs.map +1 -1
- package/dist/components/ui/ParetoChart.js +247 -212
- package/dist/components/ui/ParetoChart.js.map +1 -1
- package/dist/components/ui/QueryAutocomplete.cjs +1 -1
- package/dist/components/ui/QueryAutocomplete.cjs.map +1 -1
- package/dist/components/ui/QueryAutocomplete.d.ts +4 -1
- package/dist/components/ui/QueryAutocomplete.js +136 -123
- package/dist/components/ui/QueryAutocomplete.js.map +1 -1
- package/dist/components/ui/RankBar.cjs +1 -1
- package/dist/components/ui/RankBar.cjs.map +1 -1
- package/dist/components/ui/RankBar.js +9 -9
- package/dist/components/ui/RankBar.js.map +1 -1
- package/dist/components/ui/ReplayStepStrip.cjs +1 -1
- package/dist/components/ui/ReplayStepStrip.cjs.map +1 -1
- package/dist/components/ui/ReplayStepStrip.d.ts +6 -3
- package/dist/components/ui/ReplayStepStrip.js +71 -61
- package/dist/components/ui/ReplayStepStrip.js.map +1 -1
- package/dist/components/ui/ServiceMap.cjs +1 -1
- package/dist/components/ui/ServiceMap.cjs.map +1 -1
- package/dist/components/ui/ServiceMap.d.ts +9 -1
- package/dist/components/ui/ServiceMap.js +335 -268
- package/dist/components/ui/ServiceMap.js.map +1 -1
- package/dist/components/ui/SparkLine.cjs +1 -1
- package/dist/components/ui/SparkLine.cjs.map +1 -1
- package/dist/components/ui/SparkLine.d.ts +5 -2
- package/dist/components/ui/SparkLine.js +33 -29
- package/dist/components/ui/SparkLine.js.map +1 -1
- package/dist/components/ui/TableOfContents.cjs +1 -1
- package/dist/components/ui/TableOfContents.cjs.map +1 -1
- package/dist/components/ui/TableOfContents.js +16 -19
- package/dist/components/ui/TableOfContents.js.map +1 -1
- package/dist/components/ui/Tabs.cjs +2 -2
- package/dist/components/ui/Tabs.cjs.map +1 -1
- package/dist/components/ui/Tabs.js +107 -87
- package/dist/components/ui/Tabs.js.map +1 -1
- package/dist/components/ui/TimeRangePicker.cjs +1 -1
- package/dist/components/ui/TimeRangePicker.cjs.map +1 -1
- package/dist/components/ui/TimeRangePicker.d.ts +12 -1
- package/dist/components/ui/TimeRangePicker.js +69 -63
- package/dist/components/ui/TimeRangePicker.js.map +1 -1
- package/dist/components/ui/Timeline.cjs.map +1 -1
- package/dist/components/ui/Timeline.d.ts +4 -4
- package/dist/components/ui/Timeline.js.map +1 -1
- package/dist/components/ui/TimelineChart.cjs +2 -2
- package/dist/components/ui/TimelineChart.cjs.map +1 -1
- package/dist/components/ui/TimelineChart.d.ts +1 -0
- package/dist/components/ui/TimelineChart.js +131 -137
- package/dist/components/ui/TimelineChart.js.map +1 -1
- package/dist/components/ui/TraceTree.cjs +1 -1
- package/dist/components/ui/TraceTree.cjs.map +1 -1
- package/dist/components/ui/TraceTree.d.ts +4 -0
- package/dist/components/ui/TraceTree.js +88 -87
- package/dist/components/ui/TraceTree.js.map +1 -1
- package/dist/components/ui/TrajectoryStep.cjs +2 -1
- package/dist/components/ui/TrajectoryStep.cjs.map +1 -1
- package/dist/components/ui/TrajectoryStep.js +64 -43
- package/dist/components/ui/TrajectoryStep.js.map +1 -1
- package/dist/components/ui/useColumnWidths.cjs +1 -1
- package/dist/components/ui/useColumnWidths.cjs.map +1 -1
- package/dist/components/ui/useColumnWidths.d.ts +6 -1
- package/dist/components/ui/useColumnWidths.js +139 -123
- package/dist/components/ui/useColumnWidths.js.map +1 -1
- package/dist/layouts/shell/AegisShell.cjs +1 -1
- package/dist/layouts/shell/AegisShell.cjs.map +1 -1
- package/dist/layouts/shell/AegisShell.js +33 -34
- package/dist/layouts/shell/AegisShell.js.map +1 -1
- package/dist/lib/breakAtSeparators.cjs +2 -0
- package/dist/lib/breakAtSeparators.cjs.map +1 -0
- package/dist/lib/breakAtSeparators.d.ts +6 -0
- package/dist/lib/breakAtSeparators.js +10 -0
- package/dist/lib/breakAtSeparators.js.map +1 -0
- package/dist/locale/strings.cjs +1 -1
- package/dist/locale/strings.cjs.map +1 -1
- package/dist/locale/strings.d.ts +6 -0
- package/dist/locale/strings.js +27 -19
- package/dist/locale/strings.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/theme/antdTheme.cjs +1 -1
- package/dist/theme/antdTheme.cjs.map +1 -1
- package/dist/theme/antdTheme.js +50 -29
- package/dist/theme/antdTheme.js.map +1 -1
- package/dist/transports/agentm/AgentmChannelProvider.cjs +1 -1
- package/dist/transports/agentm/AgentmChannelProvider.cjs.map +1 -1
- package/dist/transports/agentm/AgentmChannelProvider.js +66 -61
- package/dist/transports/agentm/AgentmChannelProvider.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import { jsxs as w, jsx as o, Fragment as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { Tooltip as
|
|
4
|
-
import { usePrimitiveSurface as
|
|
5
|
-
import { useResizable as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import { jsxs as w, jsx as o, Fragment as fe } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as H, useId as ue, useMemo as V, useState as X, useEffect as ge } from "react";
|
|
3
|
+
import { Tooltip as _e } from "antd";
|
|
4
|
+
import { usePrimitiveSurface as we } from "../../agent/core/usePrimitiveSurface.js";
|
|
5
|
+
import { useResizable as be } from "../../hooks/useResizable.js";
|
|
6
|
+
import { breakAtSeparators as ve } from "../../lib/breakAtSeparators.js";
|
|
7
|
+
import { formatDuration as A } from "../../lib/format.js";
|
|
8
|
+
import { Chip as Me } from "./Chip.js";
|
|
9
|
+
import { StatusDot as Ne } from "./StatusDot.js";
|
|
9
10
|
/* empty css */
|
|
10
|
-
import { DefaultLink as
|
|
11
|
-
import { statusTone as
|
|
12
|
-
import { useStrings as
|
|
13
|
-
const
|
|
14
|
-
function
|
|
11
|
+
import { DefaultLink as ke } from "./linkComponent.js";
|
|
12
|
+
import { statusTone as Se } from "./traceStatus.js";
|
|
13
|
+
import { useStrings as Ee } from "../../locale/useStrings.js";
|
|
14
|
+
const ye = 180, Ie = 700, xe = 320;
|
|
15
|
+
function D(n) {
|
|
15
16
|
return n.startMs !== void 0 && n.durationMs !== void 0;
|
|
16
17
|
}
|
|
17
|
-
function
|
|
18
|
+
function Y(n) {
|
|
18
19
|
n.every((c) => c.span.startMs !== void 0) && n.sort((c, i) => (c.span.startMs ?? 0) - (i.span.startMs ?? 0));
|
|
19
20
|
}
|
|
20
|
-
function
|
|
21
|
+
function Ae(n) {
|
|
21
22
|
const c = /* @__PURE__ */ new Map();
|
|
22
23
|
n.forEach((s) => {
|
|
23
24
|
c.set(s.id, { span: s, parent: null, children: [], depth: 0 });
|
|
@@ -27,13 +28,13 @@ function Ie(n) {
|
|
|
27
28
|
const h = s.span.parentId, l = h ? c.get(h) : void 0;
|
|
28
29
|
l ? (s.parent = l, l.children.push(s)) : i.push(s);
|
|
29
30
|
});
|
|
30
|
-
const p = /* @__PURE__ */ new Set(),
|
|
31
|
+
const p = /* @__PURE__ */ new Set(), f = (s, h) => {
|
|
31
32
|
p.add(s), s.depth = h, s.children.forEach((l) => {
|
|
32
|
-
|
|
33
|
+
f(l, h + 1);
|
|
33
34
|
});
|
|
34
35
|
};
|
|
35
36
|
i.forEach((s) => {
|
|
36
|
-
|
|
37
|
+
f(s, 0);
|
|
37
38
|
}), c.forEach((s) => {
|
|
38
39
|
if (p.has(s))
|
|
39
40
|
return;
|
|
@@ -42,74 +43,74 @@ function Ie(n) {
|
|
|
42
43
|
for (; l.parent !== null && !h.has(l); )
|
|
43
44
|
h.add(l), l = l.parent;
|
|
44
45
|
const d = l;
|
|
45
|
-
d.parent !== null && (d.parent.children = d.parent.children.filter((N) => N !== d), d.parent = null), i.push(d),
|
|
46
|
+
d.parent !== null && (d.parent.children = d.parent.children.filter((N) => N !== d), d.parent = null), i.push(d), f(d, 0);
|
|
46
47
|
});
|
|
47
48
|
const b = (s) => {
|
|
48
|
-
|
|
49
|
+
Y(s.children), s.children.forEach(b);
|
|
49
50
|
};
|
|
50
|
-
return
|
|
51
|
+
return Y(i), i.forEach(b), i;
|
|
51
52
|
}
|
|
52
|
-
function
|
|
53
|
-
return n.forEach((p,
|
|
54
|
-
i.push({ node: p, position:
|
|
53
|
+
function G(n, c, i = []) {
|
|
54
|
+
return n.forEach((p, f) => {
|
|
55
|
+
i.push({ node: p, position: f + 1, siblings: n.length }), c.has(p.span.id) || G(p.children, c, i);
|
|
55
56
|
}), i;
|
|
56
57
|
}
|
|
57
|
-
function
|
|
58
|
+
function We({
|
|
58
59
|
spans: n,
|
|
59
60
|
selectedId: c,
|
|
60
61
|
onSelect: i,
|
|
61
62
|
defaultCollapsedDepth: p = Number.POSITIVE_INFINITY,
|
|
62
|
-
ariaLabel:
|
|
63
|
-
linkComponent: b =
|
|
63
|
+
ariaLabel: f,
|
|
64
|
+
linkComponent: b = ke,
|
|
64
65
|
className: s,
|
|
65
66
|
style: h,
|
|
66
67
|
surface: l,
|
|
67
68
|
nameColumnWidth: d,
|
|
68
|
-
defaultNameColumnWidth: N =
|
|
69
|
+
defaultNameColumnWidth: N = xe,
|
|
69
70
|
onNameColumnWidthChange: C,
|
|
70
71
|
persistKey: T,
|
|
71
|
-
wrapName:
|
|
72
|
+
wrapName: R = !1
|
|
72
73
|
}) {
|
|
73
|
-
const
|
|
74
|
-
const t =
|
|
74
|
+
const L = H(null), F = H(null), J = we(l, n, "tree", L), k = Ee(), Q = ue(), { roots: S, traceDuration: K, traceStart: $, timed: E } = V(() => {
|
|
75
|
+
const t = Ae(n), a = n.filter(D), r = a.length ? Math.min(...a.map((e) => e.startMs)) : 0, m = a.length ? Math.max(...a.map((e) => e.startMs + e.durationMs)) : 1;
|
|
75
76
|
return {
|
|
76
77
|
roots: t,
|
|
77
78
|
traceStart: r,
|
|
78
79
|
traceDuration: Math.max(m - r, 1),
|
|
79
80
|
timed: a.length > 0
|
|
80
81
|
};
|
|
81
|
-
}, [n]), [v,
|
|
82
|
+
}, [n]), [v, Z] = X(() => {
|
|
82
83
|
const t = /* @__PURE__ */ new Set(), a = (r) => {
|
|
83
84
|
r.depth >= p && r.children.length > 0 && t.add(r.span.id), r.children.forEach(a);
|
|
84
85
|
};
|
|
85
86
|
return S.forEach(a), t;
|
|
86
|
-
}), [
|
|
87
|
+
}), [ee, j] = X(void 0), u = V(() => G(S, v), [S, v]), z = (t) => t === void 0 ? -1 : u.findIndex((a) => a.node.span.id === t), O = z(ee), te = O >= 0 ? O : Math.max(z(c), 0), re = T !== void 0 ? `aegis-trace-tree-name-w:${T}` : void 0, {
|
|
87
88
|
width: y,
|
|
88
|
-
handleProps:
|
|
89
|
-
isDragging:
|
|
90
|
-
} =
|
|
89
|
+
handleProps: ae,
|
|
90
|
+
isDragging: se
|
|
91
|
+
} = be({
|
|
91
92
|
initialWidth: N,
|
|
92
|
-
minWidth:
|
|
93
|
-
maxWidth:
|
|
93
|
+
minWidth: ye,
|
|
94
|
+
maxWidth: Ie,
|
|
94
95
|
side: "left",
|
|
95
|
-
persistKey:
|
|
96
|
-
}),
|
|
97
|
-
|
|
96
|
+
persistKey: re
|
|
97
|
+
}), ie = d ?? y;
|
|
98
|
+
ge(() => {
|
|
98
99
|
d === void 0 && C?.(y);
|
|
99
100
|
}, [y, d, C]);
|
|
100
101
|
const I = (t) => {
|
|
101
|
-
|
|
102
|
+
Z((a) => {
|
|
102
103
|
const r = new Set(a);
|
|
103
104
|
return r.has(t) ? r.delete(t) : r.add(t), r;
|
|
104
105
|
});
|
|
105
106
|
}, g = (t) => {
|
|
106
|
-
if (t < 0 || t >=
|
|
107
|
+
if (t < 0 || t >= u.length)
|
|
107
108
|
return;
|
|
108
|
-
|
|
109
|
+
j(u[t].node.span.id), F.current?.querySelectorAll(
|
|
109
110
|
':scope > [role="treeitem"]'
|
|
110
111
|
)[t]?.focus();
|
|
111
|
-
},
|
|
112
|
-
const { node: r } =
|
|
112
|
+
}, ne = (t, a) => {
|
|
113
|
+
const { node: r } = u[a], m = r.children.length > 0, e = m && !v.has(r.span.id);
|
|
113
114
|
switch (t.key) {
|
|
114
115
|
case "ArrowDown":
|
|
115
116
|
g(a + 1);
|
|
@@ -121,7 +122,7 @@ function Oe({
|
|
|
121
122
|
g(0);
|
|
122
123
|
break;
|
|
123
124
|
case "End":
|
|
124
|
-
g(
|
|
125
|
+
g(u.length - 1);
|
|
125
126
|
break;
|
|
126
127
|
case "ArrowRight":
|
|
127
128
|
e ? g(a + 1) : m && I(r.span.id);
|
|
@@ -131,7 +132,7 @@ function Oe({
|
|
|
131
132
|
I(r.span.id);
|
|
132
133
|
else if (r.parent !== null) {
|
|
133
134
|
const _ = r.parent;
|
|
134
|
-
g(
|
|
135
|
+
g(u.findIndex((M) => M.node === _));
|
|
135
136
|
}
|
|
136
137
|
break;
|
|
137
138
|
case "Enter":
|
|
@@ -144,64 +145,64 @@ function Oe({
|
|
|
144
145
|
return;
|
|
145
146
|
}
|
|
146
147
|
t.preventDefault();
|
|
147
|
-
},
|
|
148
|
+
}, oe = (t, a) => {
|
|
148
149
|
if (t.target instanceof Element && t.target.closest("[data-trace-tree-caret]") !== null) {
|
|
149
150
|
I(a.span.id);
|
|
150
151
|
return;
|
|
151
152
|
}
|
|
152
153
|
(t.ctrlKey || t.metaKey || t.shiftKey) && t.target instanceof Element && t.target.closest(".aegis-trace-tree__name a") !== null || i?.(a.span);
|
|
153
|
-
},
|
|
154
|
+
}, ce = [
|
|
154
155
|
"aegis-trace-tree",
|
|
155
|
-
|
|
156
|
-
|
|
156
|
+
se ? "aegis-trace-tree--dragging" : "",
|
|
157
|
+
R ? "aegis-trace-tree--wrap" : "",
|
|
157
158
|
E ? "" : "aegis-trace-tree--untimed",
|
|
158
159
|
s ?? ""
|
|
159
|
-
].filter(Boolean).join(" "),
|
|
160
|
+
].filter(Boolean).join(" "), le = {
|
|
160
161
|
...h,
|
|
161
|
-
"--aegis-trace-tree-name-w": `${String(
|
|
162
|
+
"--aegis-trace-tree-name-w": `${String(ie)}px`
|
|
162
163
|
};
|
|
163
|
-
return /* @__PURE__ */ w("div", { ref:
|
|
164
|
+
return /* @__PURE__ */ w("div", { ref: L, className: ce, style: le, ...J, children: [
|
|
164
165
|
/* @__PURE__ */ o(
|
|
165
166
|
"div",
|
|
166
167
|
{
|
|
167
|
-
ref:
|
|
168
|
+
ref: F,
|
|
168
169
|
className: "aegis-trace-tree__rows",
|
|
169
170
|
role: "tree",
|
|
170
|
-
"aria-label":
|
|
171
|
-
children:
|
|
172
|
-
const e = t.span, _ = t.children.length > 0, M = v.has(e.id),
|
|
171
|
+
"aria-label": f ?? k.traceSpans,
|
|
172
|
+
children: u.map(({ node: t, position: a, siblings: r }, m) => {
|
|
173
|
+
const e = t.span, _ = t.children.length > 0, M = v.has(e.id), P = c === e.id, de = [
|
|
173
174
|
"aegis-trace-tree__row",
|
|
174
175
|
e.muted ? "aegis-trace-tree__row--muted" : "",
|
|
175
|
-
|
|
176
|
+
P ? "aegis-trace-tree__row--selected" : "",
|
|
176
177
|
e.status === "error" ? "aegis-trace-tree__row--error" : ""
|
|
177
|
-
].filter(Boolean).join(" "),
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
) : "",
|
|
178
|
+
].filter(Boolean).join(" "), he = D(e) ? k.traceSpanTiming(
|
|
179
|
+
A(e.startMs - $),
|
|
180
|
+
A(e.durationMs)
|
|
181
|
+
) : "", pe = e.kind ?? "", B = [he, pe].filter(Boolean).join(" · "), W = `${Q}-note-${String(m)}`, q = e.note !== void 0 && e.note !== null, U = R ? ve(e.name) : e.name, me = /* @__PURE__ */ w("div", { className: "aegis-trace-tree__tooltip", children: [
|
|
181
182
|
/* @__PURE__ */ o("div", { className: "aegis-trace-tree__tooltip-name", children: e.name }),
|
|
182
|
-
|
|
183
|
+
B && /* @__PURE__ */ o("div", { className: "aegis-trace-tree__tooltip-meta", children: B })
|
|
183
184
|
] });
|
|
184
185
|
return /* @__PURE__ */ w(
|
|
185
186
|
"div",
|
|
186
187
|
{
|
|
187
|
-
className:
|
|
188
|
+
className: de,
|
|
188
189
|
role: "treeitem",
|
|
189
190
|
"aria-label": e.ariaLabel,
|
|
190
|
-
"aria-describedby":
|
|
191
|
+
"aria-describedby": q ? W : void 0,
|
|
191
192
|
"aria-level": t.depth + 1,
|
|
192
193
|
"aria-posinset": a,
|
|
193
194
|
"aria-setsize": r,
|
|
194
195
|
"aria-expanded": _ ? !M : void 0,
|
|
195
|
-
"aria-selected":
|
|
196
|
-
tabIndex: m ===
|
|
196
|
+
"aria-selected": P ? !0 : void 0,
|
|
197
|
+
tabIndex: m === te ? 0 : -1,
|
|
197
198
|
onClick: (x) => {
|
|
198
|
-
|
|
199
|
+
oe(x, t);
|
|
199
200
|
},
|
|
200
201
|
onKeyDown: (x) => {
|
|
201
|
-
|
|
202
|
+
ne(x, m);
|
|
202
203
|
},
|
|
203
204
|
onFocus: () => {
|
|
204
|
-
|
|
205
|
+
j(e.id);
|
|
205
206
|
},
|
|
206
207
|
children: [
|
|
207
208
|
/* @__PURE__ */ w(
|
|
@@ -221,30 +222,30 @@ function Oe({
|
|
|
221
222
|
children: _ ? M ? "▸" : "▾" : null
|
|
222
223
|
}
|
|
223
224
|
),
|
|
224
|
-
/* @__PURE__ */ o(
|
|
225
|
-
e.kind ? /* @__PURE__ */ o(
|
|
225
|
+
/* @__PURE__ */ o(Ne, { tone: Se(e.status), size: 6 }),
|
|
226
|
+
e.kind ? /* @__PURE__ */ o(Me, { tone: "ghost", className: "aegis-trace-tree__kind", children: e.kind }) : null,
|
|
226
227
|
/* @__PURE__ */ o(
|
|
227
|
-
|
|
228
|
+
_e,
|
|
228
229
|
{
|
|
229
230
|
placement: "topLeft",
|
|
230
231
|
mouseEnterDelay: 0.3,
|
|
231
232
|
styles: { root: { maxWidth: "var(--tooltip-max-width)" } },
|
|
232
|
-
title:
|
|
233
|
-
children: /* @__PURE__ */ o("span", { className: "aegis-trace-tree__name", children: e.to === void 0 ?
|
|
233
|
+
title: me,
|
|
234
|
+
children: /* @__PURE__ */ o("span", { className: "aegis-trace-tree__name", children: e.to === void 0 ? U : /* @__PURE__ */ o(
|
|
234
235
|
b,
|
|
235
236
|
{
|
|
236
237
|
to: e.to,
|
|
237
238
|
className: "aegis-trace-tree__link",
|
|
238
239
|
tabIndex: -1,
|
|
239
|
-
children:
|
|
240
|
+
children: U
|
|
240
241
|
}
|
|
241
242
|
) })
|
|
242
243
|
}
|
|
243
244
|
),
|
|
244
|
-
|
|
245
|
+
q ? /* @__PURE__ */ o(
|
|
245
246
|
"span",
|
|
246
247
|
{
|
|
247
|
-
id:
|
|
248
|
+
id: W,
|
|
248
249
|
className: "aegis-trace-tree__note",
|
|
249
250
|
"aria-hidden": "true",
|
|
250
251
|
children: e.note
|
|
@@ -253,7 +254,7 @@ function Oe({
|
|
|
253
254
|
]
|
|
254
255
|
}
|
|
255
256
|
),
|
|
256
|
-
E && /* @__PURE__ */ w(
|
|
257
|
+
E && /* @__PURE__ */ w(fe, { children: [
|
|
257
258
|
/* @__PURE__ */ o(
|
|
258
259
|
"span",
|
|
259
260
|
{
|
|
@@ -266,19 +267,19 @@ function Oe({
|
|
|
266
267
|
{
|
|
267
268
|
className: "aegis-trace-tree__bar-track",
|
|
268
269
|
"aria-hidden": "true",
|
|
269
|
-
children:
|
|
270
|
+
children: D(e) && /* @__PURE__ */ o(
|
|
270
271
|
"span",
|
|
271
272
|
{
|
|
272
273
|
className: "aegis-trace-tree__bar",
|
|
273
274
|
style: {
|
|
274
|
-
left: `${((e.startMs -
|
|
275
|
-
width: `${Math.max(e.durationMs /
|
|
275
|
+
left: `${((e.startMs - $) / K * 100).toString()}%`,
|
|
276
|
+
width: `${Math.max(e.durationMs / K * 100, 0.5).toString()}%`
|
|
276
277
|
}
|
|
277
278
|
}
|
|
278
279
|
)
|
|
279
280
|
}
|
|
280
281
|
),
|
|
281
|
-
/* @__PURE__ */ o("div", { className: "aegis-trace-tree__duration", children: e.durationMs !== void 0 &&
|
|
282
|
+
/* @__PURE__ */ o("div", { className: "aegis-trace-tree__duration", children: e.durationMs !== void 0 && A(e.durationMs) })
|
|
282
283
|
] })
|
|
283
284
|
]
|
|
284
285
|
},
|
|
@@ -290,7 +291,7 @@ function Oe({
|
|
|
290
291
|
E && /* @__PURE__ */ o(
|
|
291
292
|
"div",
|
|
292
293
|
{
|
|
293
|
-
...
|
|
294
|
+
...ae,
|
|
294
295
|
className: "aegis-trace-tree__handle",
|
|
295
296
|
"aria-label": k.resizeNameColumn
|
|
296
297
|
}
|
|
@@ -298,6 +299,6 @@ function Oe({
|
|
|
298
299
|
] });
|
|
299
300
|
}
|
|
300
301
|
export {
|
|
301
|
-
|
|
302
|
+
We as TraceTree
|
|
302
303
|
};
|
|
303
304
|
//# sourceMappingURL=TraceTree.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TraceTree.js","sources":["../../../src/components/ui/TraceTree.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { Tooltip } from 'antd';\n\nimport {\n type PrimitiveSurface,\n usePrimitiveSurface,\n} from '../../agent/core/usePrimitiveSurface';\nimport { useResizable } from '../../hooks/useResizable';\nimport type { ChartColor } from '../../lib/chart';\nimport { formatDuration } from '../../lib/format';\nimport { useStrings } from '../../locale';\nimport { Chip } from './Chip';\nimport { StatusDot } from './StatusDot';\nimport './TraceTree.css';\nimport { DefaultLink, type LinkComponent } from './linkComponent';\nimport { statusTone } from './traceStatus';\n\nexport type TraceTreeSurface = PrimitiveSurface<TraceSpan[]>;\n\nexport interface TraceSpan {\n id: string;\n parentId?: string | null;\n name: string;\n /**\n * Milliseconds since trace start. Leave `startMs` and `durationMs` out for a\n * span whose time is not recorded: its row draws no bar, and siblings that are\n * not all timed keep the order they are given in.\n */\n startMs?: number;\n durationMs?: number;\n status?: 'ok' | 'error' | 'unset';\n /**\n * The span's category: a chip on the left of its `TraceTree` row, and,\n * without `color`, the colour of its `TimelineChart` bar (one per kind).\n */\n kind?: string;\n /**\n * The colour of its `TimelineChart` bar. Set it from a stable key when\n * `kind` is translated, so the colour does not follow the language.\n */\n color?: ChartColor;\n /** Drawn at the end of the span's `TimelineChart` bar. */\n badge?: ReactNode;\n /**\n * Drawn at the end of the span's name in its `TraceTree` row, e.g. a change\n * mark or a count. It is the row's accessible description, not part of its\n * name. Give a Chip in it `inverted` while the span is selected.\n */\n note?: ReactNode;\n /**\n * Draws the span's `TraceTree` row in muted ink, e.g. for a span that only\n * the trace it is compared with has.\n */\n muted?: boolean;\n /** The accessible name of the span's `TraceTree` row. Default: the row's text. */\n ariaLabel?: string;\n /**\n * Makes the span's name in its `TraceTree` row a link to this\n * destination. The row stays the tree's tab stop: the link is not a tab\n * stop, and Enter on the row follows it.\n */\n to?: string;\n /** Free-form attributes — only used by the inspector pane, not by the row itself. */\n attrs?: Record<string, unknown>;\n}\n\ninterface TimedSpan extends TraceSpan {\n startMs: number;\n durationMs: number;\n}\n\ninterface TraceTreeProps {\n /**\n * The spans in any order. A span whose `parentId` names no span is a root;\n * spans whose parents form a cycle are cut at one span of the cycle, which\n * becomes a root.\n */\n spans: TraceSpan[];\n selectedId?: string;\n onSelect?: (span: TraceSpan) => void;\n /**\n * Rows at this depth or deeper start collapsed when they have children.\n * Roots are depth 0, so `0` shows only the roots and `1` the roots and\n * their children. Applies to the spans present when the tree mounts.\n * Default: every row expanded.\n */\n defaultCollapsedDepth?: number;\n /** The tree's accessible name. Default: the locale's `traceSpans`. */\n ariaLabel?: string;\n /** Renders the names of spans with `to`. Defaults to an `<a href>`; routed apps pass their Link adapter. */\n linkComponent?: LinkComponent;\n className?: string;\n style?: CSSProperties;\n surface?: TraceTreeSurface;\n nameColumnWidth?: number;\n defaultNameColumnWidth?: number;\n onNameColumnWidthChange?: (w: number) => void;\n persistKey?: string;\n wrapName?: boolean;\n}\n\ninterface Node {\n span: TraceSpan;\n parent: Node | null;\n children: Node[];\n depth: number;\n}\n\ninterface VisibleRow {\n node: Node;\n /** 1-based position among its siblings. */\n position: number;\n siblings: number;\n}\n\nconst NAME_COL_MIN = 180;\nconst NAME_COL_MAX = 700;\nconst NAME_COL_DEFAULT = 320;\n\nfunction isTimed(span: TraceSpan): span is TimedSpan {\n return span.startMs !== undefined && span.durationMs !== undefined;\n}\n\nfunction sortByStart(nodes: Node[]): void {\n if (nodes.every((n) => n.span.startMs !== undefined)) {\n nodes.sort((a, b) => (a.span.startMs ?? 0) - (b.span.startMs ?? 0));\n }\n}\n\nfunction buildForest(spans: TraceSpan[]): Node[] {\n const byId = new Map<string, Node>();\n spans.forEach((span) => {\n byId.set(span.id, { span, parent: null, children: [], depth: 0 });\n });\n const roots: Node[] = [];\n byId.forEach((node) => {\n const pid = node.span.parentId;\n const parent = pid ? byId.get(pid) : undefined;\n if (parent) {\n node.parent = parent;\n parent.children.push(node);\n } else {\n roots.push(node);\n }\n });\n\n const placed = new Set<Node>();\n const place = (node: Node, depth: number): void => {\n placed.add(node);\n node.depth = depth;\n node.children.forEach((child) => {\n place(child, depth + 1);\n });\n };\n roots.forEach((root) => {\n place(root, 0);\n });\n // A span no root reaches hangs below a cycle of parents. Climbing from it\n // comes back round to a span on the cycle, which becomes a root.\n byId.forEach((node) => {\n if (placed.has(node)) {\n return;\n }\n const climbed = new Set<Node>();\n let onCycle = node;\n while (onCycle.parent !== null && !climbed.has(onCycle)) {\n climbed.add(onCycle);\n onCycle = onCycle.parent;\n }\n const cut = onCycle;\n if (cut.parent !== null) {\n cut.parent.children = cut.parent.children.filter((c) => c !== cut);\n cut.parent = null;\n }\n roots.push(cut);\n place(cut, 0);\n });\n\n const sortRec = (n: Node): void => {\n sortByStart(n.children);\n n.children.forEach(sortRec);\n };\n sortByStart(roots);\n roots.forEach(sortRec);\n return roots;\n}\n\nfunction flatten(\n nodes: Node[],\n collapsed: Set<string>,\n out: VisibleRow[] = [],\n): VisibleRow[] {\n nodes.forEach((node, index) => {\n out.push({ node, position: index + 1, siblings: nodes.length });\n if (!collapsed.has(node.span.id)) {\n flatten(node.children, collapsed, out);\n }\n });\n return out;\n}\n\nexport function TraceTree({\n spans,\n selectedId,\n onSelect,\n defaultCollapsedDepth = Number.POSITIVE_INFINITY,\n ariaLabel,\n linkComponent: Link = DefaultLink,\n className,\n style,\n surface,\n nameColumnWidth,\n defaultNameColumnWidth = NAME_COL_DEFAULT,\n onNameColumnWidthChange,\n persistKey,\n wrapName = false,\n}: TraceTreeProps) {\n const wrapRef = useRef<HTMLDivElement>(null);\n const treeRef = useRef<HTMLDivElement>(null);\n const agentAttrs = usePrimitiveSurface(surface, spans, 'tree', wrapRef);\n const strings = useStrings();\n const idPrefix = useId();\n const { roots, traceDuration, traceStart, timed } = useMemo(() => {\n const r = buildForest(spans);\n const timedSpans = spans.filter(isTimed);\n const start = timedSpans.length\n ? Math.min(...timedSpans.map((s) => s.startMs))\n : 0;\n const end = timedSpans.length\n ? Math.max(...timedSpans.map((s) => s.startMs + s.durationMs))\n : 1;\n return {\n roots: r,\n traceStart: start,\n traceDuration: Math.max(end - start, 1),\n timed: timedSpans.length > 0,\n };\n }, [spans]);\n\n const [collapsed, setCollapsed] = useState<Set<string>>(() => {\n const init = new Set<string>();\n const walk = (n: Node): void => {\n if (n.depth >= defaultCollapsedDepth && n.children.length > 0) {\n init.add(n.span.id);\n }\n n.children.forEach(walk);\n };\n roots.forEach(walk);\n return init;\n });\n const [focusedId, setFocusedId] = useState<string | undefined>(undefined);\n\n const visible = useMemo(() => flatten(roots, collapsed), [roots, collapsed]);\n\n // One tab stop: the row last focused, else the selected row, else the first.\n const rowIndexOf = (id: string | undefined): number =>\n id === undefined ? -1 : visible.findIndex((r) => r.node.span.id === id);\n const focusedIndex = rowIndexOf(focusedId);\n const tabStopIndex =\n focusedIndex >= 0 ? focusedIndex : Math.max(rowIndexOf(selectedId), 0);\n\n const resizePersistKey =\n persistKey !== undefined\n ? `aegis-trace-tree-name-w:${persistKey}`\n : undefined;\n\n const {\n width: internalWidth,\n handleProps,\n isDragging,\n } = useResizable({\n initialWidth: defaultNameColumnWidth,\n minWidth: NAME_COL_MIN,\n maxWidth: NAME_COL_MAX,\n side: 'left',\n persistKey: resizePersistKey,\n });\n\n const effectiveWidth = nameColumnWidth ?? internalWidth;\n\n useEffect(() => {\n if (nameColumnWidth === undefined) {\n onNameColumnWidthChange?.(internalWidth);\n }\n }, [internalWidth, nameColumnWidth, onNameColumnWidthChange]);\n\n const toggle = (id: string): void => {\n setCollapsed((prev) => {\n const next = new Set(prev);\n if (next.has(id)) {\n next.delete(id);\n } else {\n next.add(id);\n }\n return next;\n });\n };\n\n const focusRow = (index: number): void => {\n if (index < 0 || index >= visible.length) {\n return;\n }\n setFocusedId(visible[index].node.span.id);\n const row = treeRef.current?.querySelectorAll<HTMLElement>(\n ':scope > [role=\"treeitem\"]',\n )[index];\n row?.focus();\n };\n\n const handleRowKeyDown = (\n event: KeyboardEvent<HTMLDivElement>,\n index: number,\n ): void => {\n const { node } = visible[index];\n const expandable = node.children.length > 0;\n const expanded = expandable && !collapsed.has(node.span.id);\n switch (event.key) {\n case 'ArrowDown':\n focusRow(index + 1);\n break;\n case 'ArrowUp':\n focusRow(index - 1);\n break;\n case 'Home':\n focusRow(0);\n break;\n case 'End':\n focusRow(visible.length - 1);\n break;\n case 'ArrowRight':\n if (expanded) {\n focusRow(index + 1);\n } else if (expandable) {\n toggle(node.span.id);\n }\n break;\n case 'ArrowLeft':\n if (expanded) {\n toggle(node.span.id);\n } else if (node.parent !== null) {\n const parent = node.parent;\n focusRow(visible.findIndex((r) => r.node === parent));\n }\n break;\n // The link's click reaches the row, which selects it too.\n case 'Enter':\n if (node.span.to !== undefined) {\n event.currentTarget\n .querySelector<HTMLElement>('.aegis-trace-tree__name a')\n ?.click();\n } else {\n onSelect?.(node.span);\n }\n break;\n case ' ':\n onSelect?.(node.span);\n break;\n default:\n return;\n }\n event.preventDefault();\n };\n\n const handleRowClick = (event: MouseEvent<HTMLDivElement>, node: Node) => {\n if (\n event.target instanceof Element &&\n event.target.closest('[data-trace-tree-caret]') !== null\n ) {\n toggle(node.span.id);\n return;\n }\n // A modified click opens the name's link elsewhere and leaves this\n // page's selection alone.\n if (\n (event.ctrlKey || event.metaKey || event.shiftKey) &&\n event.target instanceof Element &&\n event.target.closest('.aegis-trace-tree__name a') !== null\n ) {\n return;\n }\n onSelect?.(node.span);\n };\n\n const cls = [\n 'aegis-trace-tree',\n isDragging ? 'aegis-trace-tree--dragging' : '',\n wrapName ? 'aegis-trace-tree--wrap' : '',\n timed ? '' : 'aegis-trace-tree--untimed',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ');\n\n const rootStyle = {\n ...style,\n '--aegis-trace-tree-name-w': `${String(effectiveWidth)}px`,\n } as CSSProperties;\n\n return (\n <div ref={wrapRef} className={cls} style={rootStyle} {...agentAttrs}>\n <div\n ref={treeRef}\n className=\"aegis-trace-tree__rows\"\n role=\"tree\"\n aria-label={ariaLabel ?? strings.traceSpans}\n >\n {visible.map(({ node, position, siblings }, index) => {\n const span = node.span;\n const hasChildren = node.children.length > 0;\n const isCollapsed = collapsed.has(span.id);\n const isSelected = selectedId === span.id;\n const rowCls = [\n 'aegis-trace-tree__row',\n span.muted ? 'aegis-trace-tree__row--muted' : '',\n isSelected ? 'aegis-trace-tree__row--selected' : '',\n span.status === 'error' ? 'aegis-trace-tree__row--error' : '',\n ]\n .filter(Boolean)\n .join(' ');\n\n const timing = isTimed(span)\n ? strings.traceSpanTiming(\n formatDuration(span.startMs - traceStart),\n formatDuration(span.durationMs),\n )\n : '';\n const kind = span.kind ?? '';\n const meta = [timing, kind].filter(Boolean).join(' · ');\n const noteId = `${idPrefix}-note-${String(index)}`;\n const hasNote = span.note !== undefined && span.note !== null;\n const tooltipContent = (\n <div className=\"aegis-trace-tree__tooltip\">\n <div className=\"aegis-trace-tree__tooltip-name\">{span.name}</div>\n {meta && (\n <div className=\"aegis-trace-tree__tooltip-meta\">{meta}</div>\n )}\n </div>\n );\n\n return (\n <div\n key={span.id}\n className={rowCls}\n role=\"treeitem\"\n aria-label={span.ariaLabel}\n aria-describedby={hasNote ? noteId : undefined}\n aria-level={node.depth + 1}\n aria-posinset={position}\n aria-setsize={siblings}\n aria-expanded={hasChildren ? !isCollapsed : undefined}\n aria-selected={isSelected ? true : undefined}\n tabIndex={index === tabStopIndex ? 0 : -1}\n onClick={(event) => {\n handleRowClick(event, node);\n }}\n onKeyDown={(event) => {\n handleRowKeyDown(event, index);\n }}\n onFocus={() => {\n setFocusedId(span.id);\n }}\n >\n <div\n className=\"aegis-trace-tree__label\"\n style={\n {\n '--depth': node.depth,\n } as CSSProperties\n }\n >\n <span\n className={\n hasChildren\n ? 'aegis-trace-tree__caret'\n : 'aegis-trace-tree__caret aegis-trace-tree__caret--leaf'\n }\n aria-hidden=\"true\"\n data-trace-tree-caret={hasChildren ? '' : undefined}\n >\n {hasChildren ? (isCollapsed ? '▸' : '▾') : null}\n </span>\n <StatusDot tone={statusTone(span.status)} size={6} />\n {span.kind ? (\n <Chip tone=\"ghost\" className=\"aegis-trace-tree__kind\">\n {span.kind}\n </Chip>\n ) : null}\n <Tooltip\n placement=\"topLeft\"\n mouseEnterDelay={0.3}\n styles={{ root: { maxWidth: 'var(--tooltip-max-width)' } }}\n title={tooltipContent}\n >\n <span className=\"aegis-trace-tree__name\">\n {span.to === undefined ? (\n span.name\n ) : (\n <Link\n to={span.to}\n className=\"aegis-trace-tree__link\"\n tabIndex={-1}\n >\n {span.name}\n </Link>\n )}\n </span>\n </Tooltip>\n {hasNote ? (\n <span\n id={noteId}\n className=\"aegis-trace-tree__note\"\n aria-hidden=\"true\"\n >\n {span.note}\n </span>\n ) : null}\n </div>\n {timed && (\n <>\n <span\n className=\"aegis-trace-tree__gutter\"\n aria-hidden=\"true\"\n />\n <div\n className=\"aegis-trace-tree__bar-track\"\n aria-hidden=\"true\"\n >\n {isTimed(span) && (\n <span\n className=\"aegis-trace-tree__bar\"\n style={{\n left: `${(((span.startMs - traceStart) / traceDuration) * 100).toString()}%`,\n width: `${Math.max((span.durationMs / traceDuration) * 100, 0.5).toString()}%`,\n }}\n />\n )}\n </div>\n <div className=\"aegis-trace-tree__duration\">\n {span.durationMs !== undefined &&\n formatDuration(span.durationMs)}\n </div>\n </>\n )}\n </div>\n );\n })}\n </div>\n {timed && (\n <div\n {...handleProps}\n className=\"aegis-trace-tree__handle\"\n aria-label={strings.resizeNameColumn}\n />\n )}\n </div>\n );\n}\n"],"names":["NAME_COL_MIN","NAME_COL_MAX","NAME_COL_DEFAULT","isTimed","span","sortByStart","nodes","n","a","b","buildForest","spans","byId","roots","node","pid","parent","placed","place","depth","child","root","climbed","onCycle","cut","c","sortRec","flatten","collapsed","out","index","TraceTree","selectedId","onSelect","defaultCollapsedDepth","ariaLabel","Link","DefaultLink","className","style","surface","nameColumnWidth","defaultNameColumnWidth","onNameColumnWidthChange","persistKey","wrapName","wrapRef","useRef","treeRef","agentAttrs","usePrimitiveSurface","strings","useStrings","idPrefix","useId","traceDuration","traceStart","timed","useMemo","r","timedSpans","start","s","end","setCollapsed","useState","init","walk","focusedId","setFocusedId","visible","rowIndexOf","id","focusedIndex","tabStopIndex","resizePersistKey","internalWidth","handleProps","isDragging","useResizable","effectiveWidth","useEffect","toggle","prev","next","focusRow","handleRowKeyDown","event","expandable","expanded","handleRowClick","cls","rootStyle","jsxs","jsx","position","siblings","hasChildren","isCollapsed","isSelected","rowCls","timing","formatDuration","kind","meta","noteId","hasNote","toolt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,gBAAA,EAAA,CACF;AAAA,cAAA;AAAA,YAAA;AAAA,YApGGA,EAAK;AAAA,UAAA;AAAA,QAwGhB,CAAC;AAAA,MAAA;AAAA,IAAA;AAAA,IAEFqD,KACC,gBAAAqC;AAAA,MAAC;AAAA,MAAA;AAAA,QACE,GAAGjB;AAAA,QACJ,WAAU;AAAA,QACV,cAAY1B,EAAQ;AAAA,MAAA;AAAA,IAAA;AAAA,EACtB,GAEJ;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"TraceTree.js","sources":["../../../src/components/ui/TraceTree.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { Tooltip } from 'antd';\n\nimport {\n type PrimitiveSurface,\n usePrimitiveSurface,\n} from '../../agent/core/usePrimitiveSurface';\nimport { useResizable } from '../../hooks/useResizable';\nimport { breakAtSeparators } from '../../lib/breakAtSeparators';\nimport type { ChartColor } from '../../lib/chart';\nimport { formatDuration } from '../../lib/format';\nimport { useStrings } from '../../locale';\nimport { Chip } from './Chip';\nimport { StatusDot } from './StatusDot';\nimport './TraceTree.css';\nimport { DefaultLink, type LinkComponent } from './linkComponent';\nimport { statusTone } from './traceStatus';\n\nexport type TraceTreeSurface = PrimitiveSurface<TraceSpan[]>;\n\nexport interface TraceSpan {\n id: string;\n parentId?: string | null;\n name: string;\n /**\n * Milliseconds since trace start. Leave `startMs` and `durationMs` out for a\n * span whose time is not recorded: its row draws no bar, and siblings that are\n * not all timed keep the order they are given in.\n */\n startMs?: number;\n durationMs?: number;\n status?: 'ok' | 'error' | 'unset';\n /**\n * The span's category: a chip on the left of its `TraceTree` row, and,\n * without `color`, the colour of its `TimelineChart` bar (one per kind).\n */\n kind?: string;\n /**\n * The colour of its `TimelineChart` bar. Set it from a stable key when\n * `kind` is translated, so the colour does not follow the language.\n */\n color?: ChartColor;\n /** Drawn at the end of the span's `TimelineChart` bar. */\n badge?: ReactNode;\n /**\n * Drawn at the end of the span's name in its `TraceTree` row, e.g. a change\n * mark or a count. It is the row's accessible description, not part of its\n * name. Give a Chip in it `inverted` while the span is selected.\n */\n note?: ReactNode;\n /**\n * Draws the span's `TraceTree` row in muted ink, e.g. for a span that only\n * the trace it is compared with has.\n */\n muted?: boolean;\n /** The accessible name of the span's `TraceTree` row. Default: the row's text. */\n ariaLabel?: string;\n /**\n * Makes the span's name in its `TraceTree` row a link to this\n * destination. The row stays the tree's tab stop: the link is not a tab\n * stop, and Enter on the row follows it.\n */\n to?: string;\n /** Free-form attributes — only used by the inspector pane, not by the row itself. */\n attrs?: Record<string, unknown>;\n}\n\ninterface TimedSpan extends TraceSpan {\n startMs: number;\n durationMs: number;\n}\n\ninterface TraceTreeProps {\n /**\n * The spans in any order. A span whose `parentId` names no span is a root;\n * spans whose parents form a cycle are cut at one span of the cycle, which\n * becomes a root.\n */\n spans: TraceSpan[];\n selectedId?: string;\n onSelect?: (span: TraceSpan) => void;\n /**\n * Rows at this depth or deeper start collapsed when they have children.\n * Roots are depth 0, so `0` shows only the roots and `1` the roots and\n * their children. Applies to the spans present when the tree mounts.\n * Default: every row expanded.\n */\n defaultCollapsedDepth?: number;\n /** The tree's accessible name. Default: the locale's `traceSpans`. */\n ariaLabel?: string;\n /** Renders the names of spans with `to`. Defaults to an `<a href>`; routed apps pass their Link adapter. */\n linkComponent?: LinkComponent;\n className?: string;\n style?: CSSProperties;\n surface?: TraceTreeSurface;\n nameColumnWidth?: number;\n defaultNameColumnWidth?: number;\n onNameColumnWidthChange?: (w: number) => void;\n persistKey?: string;\n /**\n * Wraps a long name over lines instead of truncating it: between words and\n * after `_ . - / :`, and inside a word only when it cannot fit a line.\n */\n wrapName?: boolean;\n}\n\ninterface Node {\n span: TraceSpan;\n parent: Node | null;\n children: Node[];\n depth: number;\n}\n\ninterface VisibleRow {\n node: Node;\n /** 1-based position among its siblings. */\n position: number;\n siblings: number;\n}\n\nconst NAME_COL_MIN = 180;\nconst NAME_COL_MAX = 700;\nconst NAME_COL_DEFAULT = 320;\n\nfunction isTimed(span: TraceSpan): span is TimedSpan {\n return span.startMs !== undefined && span.durationMs !== undefined;\n}\n\nfunction sortByStart(nodes: Node[]): void {\n if (nodes.every((n) => n.span.startMs !== undefined)) {\n nodes.sort((a, b) => (a.span.startMs ?? 0) - (b.span.startMs ?? 0));\n }\n}\n\nfunction buildForest(spans: TraceSpan[]): Node[] {\n const byId = new Map<string, Node>();\n spans.forEach((span) => {\n byId.set(span.id, { span, parent: null, children: [], depth: 0 });\n });\n const roots: Node[] = [];\n byId.forEach((node) => {\n const pid = node.span.parentId;\n const parent = pid ? byId.get(pid) : undefined;\n if (parent) {\n node.parent = parent;\n parent.children.push(node);\n } else {\n roots.push(node);\n }\n });\n\n const placed = new Set<Node>();\n const place = (node: Node, depth: number): void => {\n placed.add(node);\n node.depth = depth;\n node.children.forEach((child) => {\n place(child, depth + 1);\n });\n };\n roots.forEach((root) => {\n place(root, 0);\n });\n // A span no root reaches hangs below a cycle of parents. Climbing from it\n // comes back round to a span on the cycle, which becomes a root.\n byId.forEach((node) => {\n if (placed.has(node)) {\n return;\n }\n const climbed = new Set<Node>();\n let onCycle = node;\n while (onCycle.parent !== null && !climbed.has(onCycle)) {\n climbed.add(onCycle);\n onCycle = onCycle.parent;\n }\n const cut = onCycle;\n if (cut.parent !== null) {\n cut.parent.children = cut.parent.children.filter((c) => c !== cut);\n cut.parent = null;\n }\n roots.push(cut);\n place(cut, 0);\n });\n\n const sortRec = (n: Node): void => {\n sortByStart(n.children);\n n.children.forEach(sortRec);\n };\n sortByStart(roots);\n roots.forEach(sortRec);\n return roots;\n}\n\nfunction flatten(\n nodes: Node[],\n collapsed: Set<string>,\n out: VisibleRow[] = [],\n): VisibleRow[] {\n nodes.forEach((node, index) => {\n out.push({ node, position: index + 1, siblings: nodes.length });\n if (!collapsed.has(node.span.id)) {\n flatten(node.children, collapsed, out);\n }\n });\n return out;\n}\n\nexport function TraceTree({\n spans,\n selectedId,\n onSelect,\n defaultCollapsedDepth = Number.POSITIVE_INFINITY,\n ariaLabel,\n linkComponent: Link = DefaultLink,\n className,\n style,\n surface,\n nameColumnWidth,\n defaultNameColumnWidth = NAME_COL_DEFAULT,\n onNameColumnWidthChange,\n persistKey,\n wrapName = false,\n}: TraceTreeProps) {\n const wrapRef = useRef<HTMLDivElement>(null);\n const treeRef = useRef<HTMLDivElement>(null);\n const agentAttrs = usePrimitiveSurface(surface, spans, 'tree', wrapRef);\n const strings = useStrings();\n const idPrefix = useId();\n const { roots, traceDuration, traceStart, timed } = useMemo(() => {\n const r = buildForest(spans);\n const timedSpans = spans.filter(isTimed);\n const start = timedSpans.length\n ? Math.min(...timedSpans.map((s) => s.startMs))\n : 0;\n const end = timedSpans.length\n ? Math.max(...timedSpans.map((s) => s.startMs + s.durationMs))\n : 1;\n return {\n roots: r,\n traceStart: start,\n traceDuration: Math.max(end - start, 1),\n timed: timedSpans.length > 0,\n };\n }, [spans]);\n\n const [collapsed, setCollapsed] = useState<Set<string>>(() => {\n const init = new Set<string>();\n const walk = (n: Node): void => {\n if (n.depth >= defaultCollapsedDepth && n.children.length > 0) {\n init.add(n.span.id);\n }\n n.children.forEach(walk);\n };\n roots.forEach(walk);\n return init;\n });\n const [focusedId, setFocusedId] = useState<string | undefined>(undefined);\n\n const visible = useMemo(() => flatten(roots, collapsed), [roots, collapsed]);\n\n // One tab stop: the row last focused, else the selected row, else the first.\n const rowIndexOf = (id: string | undefined): number =>\n id === undefined ? -1 : visible.findIndex((r) => r.node.span.id === id);\n const focusedIndex = rowIndexOf(focusedId);\n const tabStopIndex =\n focusedIndex >= 0 ? focusedIndex : Math.max(rowIndexOf(selectedId), 0);\n\n const resizePersistKey =\n persistKey !== undefined\n ? `aegis-trace-tree-name-w:${persistKey}`\n : undefined;\n\n const {\n width: internalWidth,\n handleProps,\n isDragging,\n } = useResizable({\n initialWidth: defaultNameColumnWidth,\n minWidth: NAME_COL_MIN,\n maxWidth: NAME_COL_MAX,\n side: 'left',\n persistKey: resizePersistKey,\n });\n\n const effectiveWidth = nameColumnWidth ?? internalWidth;\n\n useEffect(() => {\n if (nameColumnWidth === undefined) {\n onNameColumnWidthChange?.(internalWidth);\n }\n }, [internalWidth, nameColumnWidth, onNameColumnWidthChange]);\n\n const toggle = (id: string): void => {\n setCollapsed((prev) => {\n const next = new Set(prev);\n if (next.has(id)) {\n next.delete(id);\n } else {\n next.add(id);\n }\n return next;\n });\n };\n\n const focusRow = (index: number): void => {\n if (index < 0 || index >= visible.length) {\n return;\n }\n setFocusedId(visible[index].node.span.id);\n const row = treeRef.current?.querySelectorAll<HTMLElement>(\n ':scope > [role=\"treeitem\"]',\n )[index];\n row?.focus();\n };\n\n const handleRowKeyDown = (\n event: KeyboardEvent<HTMLDivElement>,\n index: number,\n ): void => {\n const { node } = visible[index];\n const expandable = node.children.length > 0;\n const expanded = expandable && !collapsed.has(node.span.id);\n switch (event.key) {\n case 'ArrowDown':\n focusRow(index + 1);\n break;\n case 'ArrowUp':\n focusRow(index - 1);\n break;\n case 'Home':\n focusRow(0);\n break;\n case 'End':\n focusRow(visible.length - 1);\n break;\n case 'ArrowRight':\n if (expanded) {\n focusRow(index + 1);\n } else if (expandable) {\n toggle(node.span.id);\n }\n break;\n case 'ArrowLeft':\n if (expanded) {\n toggle(node.span.id);\n } else if (node.parent !== null) {\n const parent = node.parent;\n focusRow(visible.findIndex((r) => r.node === parent));\n }\n break;\n // The link's click reaches the row, which selects it too.\n case 'Enter':\n if (node.span.to !== undefined) {\n event.currentTarget\n .querySelector<HTMLElement>('.aegis-trace-tree__name a')\n ?.click();\n } else {\n onSelect?.(node.span);\n }\n break;\n case ' ':\n onSelect?.(node.span);\n break;\n default:\n return;\n }\n event.preventDefault();\n };\n\n const handleRowClick = (event: MouseEvent<HTMLDivElement>, node: Node) => {\n if (\n event.target instanceof Element &&\n event.target.closest('[data-trace-tree-caret]') !== null\n ) {\n toggle(node.span.id);\n return;\n }\n // A modified click opens the name's link elsewhere and leaves this\n // page's selection alone.\n if (\n (event.ctrlKey || event.metaKey || event.shiftKey) &&\n event.target instanceof Element &&\n event.target.closest('.aegis-trace-tree__name a') !== null\n ) {\n return;\n }\n onSelect?.(node.span);\n };\n\n const cls = [\n 'aegis-trace-tree',\n isDragging ? 'aegis-trace-tree--dragging' : '',\n wrapName ? 'aegis-trace-tree--wrap' : '',\n timed ? '' : 'aegis-trace-tree--untimed',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ');\n\n const rootStyle = {\n ...style,\n '--aegis-trace-tree-name-w': `${String(effectiveWidth)}px`,\n } as CSSProperties;\n\n return (\n <div ref={wrapRef} className={cls} style={rootStyle} {...agentAttrs}>\n <div\n ref={treeRef}\n className=\"aegis-trace-tree__rows\"\n role=\"tree\"\n aria-label={ariaLabel ?? strings.traceSpans}\n >\n {visible.map(({ node, position, siblings }, index) => {\n const span = node.span;\n const hasChildren = node.children.length > 0;\n const isCollapsed = collapsed.has(span.id);\n const isSelected = selectedId === span.id;\n const rowCls = [\n 'aegis-trace-tree__row',\n span.muted ? 'aegis-trace-tree__row--muted' : '',\n isSelected ? 'aegis-trace-tree__row--selected' : '',\n span.status === 'error' ? 'aegis-trace-tree__row--error' : '',\n ]\n .filter(Boolean)\n .join(' ');\n\n const timing = isTimed(span)\n ? strings.traceSpanTiming(\n formatDuration(span.startMs - traceStart),\n formatDuration(span.durationMs),\n )\n : '';\n const kind = span.kind ?? '';\n const meta = [timing, kind].filter(Boolean).join(' · ');\n const noteId = `${idPrefix}-note-${String(index)}`;\n const hasNote = span.note !== undefined && span.note !== null;\n const name = wrapName ? breakAtSeparators(span.name) : span.name;\n const tooltipContent = (\n <div className=\"aegis-trace-tree__tooltip\">\n <div className=\"aegis-trace-tree__tooltip-name\">{span.name}</div>\n {meta && (\n <div className=\"aegis-trace-tree__tooltip-meta\">{meta}</div>\n )}\n </div>\n );\n\n return (\n <div\n key={span.id}\n className={rowCls}\n role=\"treeitem\"\n aria-label={span.ariaLabel}\n aria-describedby={hasNote ? noteId : undefined}\n aria-level={node.depth + 1}\n aria-posinset={position}\n aria-setsize={siblings}\n aria-expanded={hasChildren ? !isCollapsed : undefined}\n aria-selected={isSelected ? true : undefined}\n tabIndex={index === tabStopIndex ? 0 : -1}\n onClick={(event) => {\n handleRowClick(event, node);\n }}\n onKeyDown={(event) => {\n handleRowKeyDown(event, index);\n }}\n onFocus={() => {\n setFocusedId(span.id);\n }}\n >\n <div\n className=\"aegis-trace-tree__label\"\n style={\n {\n '--depth': node.depth,\n } as CSSProperties\n }\n >\n <span\n className={\n hasChildren\n ? 'aegis-trace-tree__caret'\n : 'aegis-trace-tree__caret aegis-trace-tree__caret--leaf'\n }\n aria-hidden=\"true\"\n data-trace-tree-caret={hasChildren ? '' : undefined}\n >\n {hasChildren ? (isCollapsed ? '▸' : '▾') : null}\n </span>\n <StatusDot tone={statusTone(span.status)} size={6} />\n {span.kind ? (\n <Chip tone=\"ghost\" className=\"aegis-trace-tree__kind\">\n {span.kind}\n </Chip>\n ) : null}\n <Tooltip\n placement=\"topLeft\"\n mouseEnterDelay={0.3}\n styles={{ root: { maxWidth: 'var(--tooltip-max-width)' } }}\n title={tooltipContent}\n >\n <span className=\"aegis-trace-tree__name\">\n {span.to === undefined ? (\n name\n ) : (\n <Link\n to={span.to}\n className=\"aegis-trace-tree__link\"\n tabIndex={-1}\n >\n {name}\n </Link>\n )}\n </span>\n </Tooltip>\n {hasNote ? (\n <span\n id={noteId}\n className=\"aegis-trace-tree__note\"\n aria-hidden=\"true\"\n >\n {span.note}\n </span>\n ) : null}\n </div>\n {timed && (\n <>\n <span\n className=\"aegis-trace-tree__gutter\"\n aria-hidden=\"true\"\n />\n <div\n className=\"aegis-trace-tree__bar-track\"\n aria-hidden=\"true\"\n >\n {isTimed(span) && (\n <span\n className=\"aegis-trace-tree__bar\"\n style={{\n left: `${(((span.startMs - traceStart) / traceDuration) * 100).toString()}%`,\n width: `${Math.max((span.durationMs / traceDuration) * 100, 0.5).toString()}%`,\n }}\n />\n )}\n </div>\n <div className=\"aegis-trace-tree__duration\">\n {span.durationMs !== undefined &&\n formatDuration(span.durationMs)}\n </div>\n </>\n )}\n </div>\n );\n })}\n </div>\n {timed && (\n <div\n {...handleProps}\n className=\"aegis-trace-tree__handle\"\n aria-label={strings.resizeNameColumn}\n />\n )}\n </div>\n );\n}\n"],"names":["NAME_COL_MIN","NAME_COL_MAX","NAME_COL_DEFAULT","isTimed","span","sortByStart","nodes","n","a","b","buildForest","spans","byId","roots","node","pid","parent","placed","place","depth","child","root","climbed","onCycle","cut","c","sortRec","flatten","collapsed","out","index","TraceTree","selectedId","onSelect","defaultCollapsedDepth","ariaLabel","Link","DefaultLink","className","style","surface","nameColumnWidth","defaultNameColumnWidth","onNameColumnWidthChange","persistKey","wrapName","wrapRef","useRef","treeRef","agentAttrs","usePrimitiveSurface","strings","useStrings","idPrefix","useId","traceDuration","traceStart","timed","useMemo","r","timedSpans","start","s","end","setCollapsed","useState","init","walk","focusedId","setFocusedId","visible","rowIndexOf","id","focusedIndex","tabStopIndex","resizePersistKey","internalWidth","handleProps","isDragging","useResizable","effectiveWidth","useEffect","toggle","prev","next","focusRow","handleRowKeyDown","event","expandable","expanded","handleRowClick","cls","rootStyle","jsxs","jsx","position","siblings","hasChildren","isCollapsed","isSelected","rowCls","timing","formatDuration","kind","meta","noteId","hasNote","name","breakAtSeparators","tooltipContent","StatusDot","statusTone","Chip","Tooltip","Fragment"],"mappings":";;;;;;;;;;;;;AAmIA,MAAMA,KAAe,KACfC,KAAe,KACfC,KAAmB;AAEzB,SAASC,EAAQC,GAAoC;AACnD,SAAOA,EAAK,YAAY,UAAaA,EAAK,eAAe;AAC3D;AAEA,SAASC,EAAYC,GAAqB;AACxC,EAAIA,EAAM,MAAM,CAACC,MAAMA,EAAE,KAAK,YAAY,MAAS,KACjDD,EAAM,KAAK,CAACE,GAAGC,OAAOD,EAAE,KAAK,WAAW,MAAMC,EAAE,KAAK,WAAW,EAA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 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),v=require("react"),y=require("../../agent/core/usePrimitiveSurface.cjs"),N=require("../../lib/format.cjs"),C=require("./Chip.cjs"),x=require("./Markdown.cjs"),j=require("./MetricLabel.cjs"),M=require("./StatusDot.cjs"),$=require("./ToolCallCard.cjs");;/* empty css */const T=require("../../locale/useStrings.cjs");function a({label:e,children:i}){return s.jsxs("div",{className:"aegis-step__section",children:[s.jsx(j.MetricLabel,{size:"xs",children:e}),s.jsx("div",{className:"aegis-step__section-body",children:i})]})}const q=/^(`{3,}|~{3,})/,w=["\\*\\*","__","\\*","_"].map(e=>new RegExp(`(^|[\\s([{"'])${e}(\\S(?:.*?\\S)?)${e}(?=[.,;:!?)\\]}"']*(?:\\s|$))`,"g")),m="",E=/`([^`]+)`/g,k=new RegExp(`${m}(\\d+)${m}`);function R(e){const i=e.trim().split(`
|
|
2
|
+
`),c=q.exec(i[0])?.[1];if(c!==void 0){const n=new RegExp(`^\\s*${c[0]}{${String(c.length)},}\\s*$`),t=i.findIndex((r,u)=>u>0&&n.test(r)),p=i.slice(1,t===-1?void 0:t).find(r=>r.trim()!=="");return p===void 0?void 0:s.jsx("code",{className:"aegis-step__action-code",children:p.trim()})}const l=[],d=i[0].replace(/^(#+|>|[-*+]|\d+\.)\s+/,"").replace(E,(n,t)=>(l.push(t),`${m}${String(l.length-1)}${m}`));return w.reduce((n,t)=>n.replace(t,"$1$2"),d.replace(/\[([^\]]*)\]\([^)]*\)/g,"$1")).split(k).map((n,t)=>t%2===1?s.jsx("code",{className:"aegis-step__action-code",children:l[Number(n)]},t):n)}function A({data:e,defaultExpanded:i=!1,className:c,surface:l}){const d=v.useRef(null),_=y.usePrimitiveSurface(l,e,"detail",d),n=T.useStrings(),[t,p]=v.useState(i),r=[...e.toolCall?[e.toolCall]:[],...e.toolCalls??[]],u=e.sections??[],b=e.summary??(e.action?R(e.action):void 0),h=[e.thought,e.action,e.observation].some(Boolean)||r.length>0||u.length>0,S=e.actionType==="tool_call"?"ink":e.actionType==="internal"?"ghost":"default",f=["aegis-step",t?"aegis-step--expanded":"",c??""].filter(Boolean).join(" ");return s.jsxs("article",{ref:d,className:f,..._,children:[s.jsxs("button",{type:"button",className:"aegis-step__head",onClick:()=>h&&p(o=>!o),disabled:!h,"aria-expanded":t,children:[s.jsxs("div",{className:"aegis-step__head-left",children:[s.jsx("span",{className:"aegis-step__number",children:String(e.step).padStart(2,"0")}),e.actionType?s.jsx(C.Chip,{tone:S,children:n.trajectoryActionType(e.actionType)}):s.jsx(M.StatusDot,{size:6}),b&&s.jsx("span",{className:"aegis-step__action-preview",children:b})]}),s.jsxs("div",{className:"aegis-step__head-right",children:[e.durationMs!==void 0&&s.jsx(j.MetricLabel,{size:"xs",className:"aegis-step__meta-number",children:N.formatDuration(e.durationMs)}),e.timestamp&&s.jsx(j.MetricLabel,{size:"xs",className:"aegis-step__meta-number",children:e.timestamp}),h&&s.jsx("span",{className:"aegis-step__chevron","aria-hidden":"true",children:t?"▾":"▸"})]})]}),t&&h&&s.jsxs("div",{className:"aegis-step__body",children:[e.thought&&s.jsx(a,{label:n.trajectoryThought,children:s.jsx(x.Markdown,{children:e.thought})}),e.action&&s.jsx(a,{label:n.trajectoryAction,children:s.jsx(x.Markdown,{children:e.action})}),u.map((o,g)=>s.jsx(a,{label:o.label,children:o.format==="text"?s.jsx("pre",{className:"aegis-step__text",children:o.text}):s.jsx(x.Markdown,{children:o.text})},g)),r.length>0&&s.jsx(a,{label:n.trajectoryTool,children:s.jsx("div",{className:"aegis-step__tools",children:r.map((o,g)=>s.jsx($.ToolCallCard,{data:o},g))})}),e.observation&&s.jsx(a,{label:n.trajectoryObservation,children:s.jsx(x.Markdown,{children:e.observation})})]})]})}exports.TrajectoryStep=A;
|
|
2
3
|
//# sourceMappingURL=TrajectoryStep.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TrajectoryStep.cjs","sources":["../../../src/components/ui/TrajectoryStep.tsx"],"sourcesContent":["import { type ReactNode, useRef, useState } from 'react';\n\nimport {\n type PrimitiveSurface,\n usePrimitiveSurface,\n} from '../../agent/core/usePrimitiveSurface';\nimport { formatDuration } from '../../lib/format';\nimport { useStrings } from '../../locale';\nimport { Chip } from './Chip';\nimport { Markdown } from './Markdown';\nimport { MetricLabel } from './MetricLabel';\nimport { StatusDot } from './StatusDot';\nimport { ToolCallCard, type ToolCallData } from './ToolCallCard';\nimport './TrajectoryStep.css';\n\n/** A labelled text of a step beyond its thought, action and observation. */\nexport interface TrajectoryStepSection {\n label: string;\n text: string;\n /** `text` keeps the text as recorded, preformatted and scrolling past a cap. */\n format?: 'markdown' | 'text';\n}\n\nexport interface TrajectoryStepData {\n step: number;\n timestamp?: string;\n durationMs?: number;\n /** The head's one-line preview; defaults to `action`. */\n summary?: string;\n thought?: string;\n action?: string;\n actionType?: 'tool_call' | 'message' | 'internal';\n toolCall?: ToolCallData;\n /** Further calls of the step, each a card after `toolCall`. */\n toolCalls?: ToolCallData[];\n observation?: string;\n /** Shown after the thought and action, before the tool calls. */\n sections?: TrajectoryStepSection[];\n}\n\nexport type TrajectoryStepSurface = PrimitiveSurface<TrajectoryStepData>;\n\ninterface TrajectoryStepProps {\n data: TrajectoryStepData;\n defaultExpanded?: boolean;\n className?: string;\n surface?: TrajectoryStepSurface;\n}\n\nfunction StepSection({\n label,\n children,\n}: {\n label: string;\n children: ReactNode;\n}) {\n return (\n <div className=\"aegis-step__section\">\n <MetricLabel size=\"xs\" className=\"aegis-step__section-label\">\n {label}\n </MetricLabel>\n <div className=\"aegis-step__section-body\">{children}</div>\n </div>\n );\n}\n\nexport function TrajectoryStep({\n data,\n defaultExpanded = false,\n className,\n surface,\n}: TrajectoryStepProps) {\n const wrapRef = useRef<HTMLElement>(null);\n const agentAttrs = usePrimitiveSurface(surface, data, 'detail', wrapRef);\n const strings = useStrings();\n const [expanded, setExpanded] = useState(defaultExpanded);\n\n const toolCalls = [\n ...(data.toolCall ? [data.toolCall] : []),\n ...(data.toolCalls ?? []),\n ];\n const sections = data.sections ?? [];\n const summary = data.summary ?? data.action;\n const hasBody =\n [data.thought, data.action, data.observation].some(Boolean) ||\n toolCalls.length > 0 ||\n sections.length > 0;\n\n const actionTone =\n data.actionType === 'tool_call'\n ? 'ink'\n : data.actionType === 'internal'\n ? 'ghost'\n : 'default';\n\n const cls = [\n 'aegis-step',\n expanded ? 'aegis-step--expanded' : '',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ');\n\n return (\n <article ref={wrapRef} className={cls} {...agentAttrs}>\n <button\n type=\"button\"\n className=\"aegis-step__head\"\n onClick={() => hasBody && setExpanded((e) => !e)}\n disabled={!hasBody}\n aria-expanded={expanded}\n >\n <div className=\"aegis-step__head-left\">\n <span className=\"aegis-step__number\">\n {String(data.step).padStart(2, '0')}\n </span>\n {data.actionType ? (\n <Chip tone={actionTone}>\n {strings.trajectoryActionType(data.actionType)}\n </Chip>\n ) : (\n <StatusDot size={6} />\n )}\n {summary && (\n <span className=\"aegis-step__action-preview\">{summary}</span>\n )}\n </div>\n <div className=\"aegis-step__head-right\">\n {data.durationMs !== undefined && (\n <MetricLabel size=\"xs\" className=\"aegis-step__meta-number\">\n {formatDuration(data.durationMs)}\n </MetricLabel>\n )}\n {data.timestamp && (\n <MetricLabel size=\"xs\" className=\"aegis-step__meta-number\">\n {data.timestamp}\n </MetricLabel>\n )}\n {hasBody && (\n <span className=\"aegis-step__chevron\" aria-hidden=\"true\">\n {expanded ? '▾' : '▸'}\n </span>\n )}\n </div>\n </button>\n\n {expanded && hasBody && (\n <div className=\"aegis-step__body\">\n {data.thought && (\n <StepSection label={strings.trajectoryThought}>\n <Markdown>{data.thought}</Markdown>\n </StepSection>\n )}\n {data.action && (\n <StepSection label={strings.trajectoryAction}>\n <Markdown>{data.action}</Markdown>\n </StepSection>\n )}\n {sections.map((section, index) => (\n <StepSection key={index} label={section.label}>\n {section.format === 'text' ? (\n <pre className=\"aegis-step__text\">{section.text}</pre>\n ) : (\n <Markdown>{section.text}</Markdown>\n )}\n </StepSection>\n ))}\n {toolCalls.length > 0 && (\n <StepSection label={strings.trajectoryTool}>\n <div className=\"aegis-step__tools\">\n {toolCalls.map((call, index) => (\n <ToolCallCard key={index} data={call} />\n ))}\n </div>\n </StepSection>\n )}\n {data.observation && (\n <StepSection label={strings.trajectoryObservation}>\n <Markdown>{data.observation}</Markdown>\n </StepSection>\n )}\n </div>\n )}\n </article>\n );\n}\n"],"names":["StepSection","label","children","jsxs","jsx","MetricLabel","TrajectoryStep","data","defaultExpanded","className","surface","wrapRef","useRef","agentAttrs","usePrimitiveSurface","strings","useStrings","expanded","setExpanded","useState","toolCalls","sections","summary","hasBody","actionTone","cls","e","Chip","StatusDot","formatDuration","Markdown","section","index","call","ToolCallCard"],"mappings":"mcAiDA,SAASA,EAAY,CACnB,MAAAC,EACA,SAAAC,CACF,EAGG,CACD,OACEC,EAAAA,KAAC,MAAA,CAAI,UAAU,sBACb,SAAA,CAAAC,MAACC,EAAAA,YAAA,CAAY,KAAK,KAAK,UAAU,4BAC9B,SAAAJ,EACH,EACAG,EAAAA,IAAC,MAAA,CAAI,UAAU,2BAA4B,SAAAF,CAAA,CAAS,CAAA,EACtD,CAEJ,CAEO,SAASI,EAAe,CAC7B,KAAAC,EACA,gBAAAC,EAAkB,GAClB,UAAAC,EACA,QAAAC,CACF,EAAwB,CACtB,MAAMC,EAAUC,EAAAA,OAAoB,IAAI,EAClCC,EAAaC,EAAAA,oBAAoBJ,EAASH,EAAM,SAAUI,CAAO,EACjEI,EAAUC,EAAAA,WAAA,EACV,CAACC,EAAUC,CAAW,EAAIC,EAAAA,SAASX,CAAe,EAElDY,EAAY,CAChB,GAAIb,EAAK,SAAW,CAACA,EAAK,QAAQ,EAAI,CAAA,EACtC,GAAIA,EAAK,WAA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ryStep.cjs","sources":["../../../src/components/ui/TrajectoryStep.tsx"],"sourcesContent":["import { type ReactNode, useRef, useState } from 'react';\n\nimport {\n type PrimitiveSurface,\n usePrimitiveSurface,\n} from '../../agent/core/usePrimitiveSurface';\nimport { formatDuration } from '../../lib/format';\nimport { useStrings } from '../../locale';\nimport { Chip } from './Chip';\nimport { Markdown } from './Markdown';\nimport { MetricLabel } from './MetricLabel';\nimport { StatusDot } from './StatusDot';\nimport { ToolCallCard, type ToolCallData } from './ToolCallCard';\nimport './TrajectoryStep.css';\n\n/** A labelled text of a step beyond its thought, action and observation. */\nexport interface TrajectoryStepSection {\n label: string;\n text: string;\n /** `text` keeps the text as recorded, preformatted and scrolling past a cap. */\n format?: 'markdown' | 'text';\n}\n\nexport interface TrajectoryStepData {\n step: number;\n timestamp?: string;\n durationMs?: number;\n /** The head's one-line preview; defaults to `action`. */\n summary?: string;\n thought?: string;\n action?: string;\n actionType?: 'tool_call' | 'message' | 'internal';\n toolCall?: ToolCallData;\n /** Further calls of the step, each a card after `toolCall`. */\n toolCalls?: ToolCallData[];\n observation?: string;\n /** Shown after the thought and action, before the tool calls. */\n sections?: TrajectoryStepSection[];\n}\n\nexport type TrajectoryStepSurface = PrimitiveSurface<TrajectoryStepData>;\n\ninterface TrajectoryStepProps {\n data: TrajectoryStepData;\n defaultExpanded?: boolean;\n className?: string;\n surface?: TrajectoryStepSurface;\n}\n\nfunction StepSection({\n label,\n children,\n}: {\n label: string;\n children: ReactNode;\n}) {\n return (\n <div className=\"aegis-step__section\">\n <MetricLabel size=\"xs\">{label}</MetricLabel>\n <div className=\"aegis-step__section-body\">{children}</div>\n </div>\n );\n}\n\nconst FENCE = /^(`{3,}|~{3,})/;\n\n// A delimiter run opens after whitespace or an opening bracket or quote and\n// closes before whitespace or trailing punctuation, so the underscores in\n// snake_case and src/__init__.py stay as they are.\nconst EMPHASIS = ['\\\\*\\\\*', '__', '\\\\*', '_'].map(\n (delimiter) =>\n new RegExp(\n `(^|[\\\\s([{\"'])${delimiter}(\\\\S(?:.*?\\\\S)?)${delimiter}(?=[.,;:!?)\\\\]}\"']*(?:\\\\s|$))`,\n 'g',\n ),\n);\n\n// Stands in for a code span while the syntax around it is removed, so\n// emphasis or a link may wrap code and the code itself is left alone.\nconst CODE_MARK = '\\uE000';\nconst CODE_SPAN = /`([^`]+)`/g;\nconst MARKED_CODE = new RegExp(`${CODE_MARK}(\\\\d+)${CODE_MARK}`);\n\n/**\n * The first line of an action written in Markdown, as the head shows it.\n * A heading, quote or list marker is dropped; a link gives way to its text,\n * and `**`, `__`, `*` and `_` emphasis to the text it wraps; a code span is\n * set in the code face. An action that opens with a fenced code block shows\n * the block's first line of code, in the code face, and nothing when the\n * block is empty.\n */\nfunction actionPreview(markdown: string): ReactNode {\n const lines = markdown.trim().split('\\n');\n const fence = FENCE.exec(lines[0])?.[1];\n if (fence !== undefined) {\n const close = new RegExp(`^\\\\s*${fence[0]}{${String(fence.length)},}\\\\s*$`);\n const end = lines.findIndex((line, index) => index > 0 && close.test(line));\n const code = lines\n .slice(1, end === -1 ? undefined : end)\n .find((line) => line.trim() !== '');\n return code === undefined ? undefined : (\n <code className=\"aegis-step__action-code\">{code.trim()}</code>\n );\n }\n const codes: string[] = [];\n const masked = lines[0]\n .replace(/^(#+|>|[-*+]|\\d+\\.)\\s+/, '')\n .replace(CODE_SPAN, (_span, code: string) => {\n codes.push(code);\n return `${CODE_MARK}${String(codes.length - 1)}${CODE_MARK}`;\n });\n const text = EMPHASIS.reduce(\n (current, pattern) => current.replace(pattern, '$1$2'),\n masked.replace(/\\[([^\\]]*)\\]\\([^)]*\\)/g, '$1'),\n );\n return text.split(MARKED_CODE).map((part, index) =>\n index % 2 === 1 ? (\n <code key={index} className=\"aegis-step__action-code\">\n {codes[Number(part)]}\n </code>\n ) : (\n part\n ),\n );\n}\n\nexport function TrajectoryStep({\n data,\n defaultExpanded = false,\n className,\n surface,\n}: TrajectoryStepProps) {\n const wrapRef = useRef<HTMLElement>(null);\n const agentAttrs = usePrimitiveSurface(surface, data, 'detail', wrapRef);\n const strings = useStrings();\n const [expanded, setExpanded] = useState(defaultExpanded);\n\n const toolCalls = [\n ...(data.toolCall ? [data.toolCall] : []),\n ...(data.toolCalls ?? []),\n ];\n const sections = data.sections ?? [];\n const summary =\n data.summary ?? (data.action ? actionPreview(data.action) : undefined);\n const hasBody =\n [data.thought, data.action, data.observation].some(Boolean) ||\n toolCalls.length > 0 ||\n sections.length > 0;\n\n const actionTone =\n data.actionType === 'tool_call'\n ? 'ink'\n : data.actionType === 'internal'\n ? 'ghost'\n : 'default';\n\n const cls = [\n 'aegis-step',\n expanded ? 'aegis-step--expanded' : '',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ');\n\n return (\n <article ref={wrapRef} className={cls} {...agentAttrs}>\n <button\n type=\"button\"\n className=\"aegis-step__head\"\n onClick={() => hasBody && setExpanded((e) => !e)}\n disabled={!hasBody}\n aria-expanded={expanded}\n >\n <div className=\"aegis-step__head-left\">\n <span className=\"aegis-step__number\">\n {String(data.step).padStart(2, '0')}\n </span>\n {data.actionType ? (\n <Chip tone={actionTone}>\n {strings.trajectoryActionType(data.actionType)}\n </Chip>\n ) : (\n <StatusDot size={6} />\n )}\n {summary && (\n <span className=\"aegis-step__action-preview\">{summary}</span>\n )}\n </div>\n <div className=\"aegis-step__head-right\">\n {data.durationMs !== undefined && (\n <MetricLabel size=\"xs\" className=\"aegis-step__meta-number\">\n {formatDuration(data.durationMs)}\n </MetricLabel>\n )}\n {data.timestamp && (\n <MetricLabel size=\"xs\" className=\"aegis-step__meta-number\">\n {data.timestamp}\n </MetricLabel>\n )}\n {hasBody && (\n <span className=\"aegis-step__chevron\" aria-hidden=\"true\">\n {expanded ? '▾' : '▸'}\n </span>\n )}\n </div>\n </button>\n\n {expanded && hasBody && (\n <div className=\"aegis-step__body\">\n {data.thought && (\n <StepSection label={strings.trajectoryThought}>\n <Markdown>{data.thought}</Markdown>\n </StepSection>\n )}\n {data.action && (\n <StepSection label={strings.trajectoryAction}>\n <Markdown>{data.action}</Markdown>\n </StepSection>\n )}\n {sections.map((section, index) => (\n <StepSection key={index} label={section.label}>\n {section.format === 'text' ? (\n <pre className=\"aegis-step__text\">{section.text}</pre>\n ) : (\n <Markdown>{section.text}</Markdown>\n )}\n </StepSection>\n ))}\n {toolCalls.length > 0 && (\n <StepSection label={strings.trajectoryTool}>\n <div className=\"aegis-step__tools\">\n {toolCalls.map((call, index) => (\n <ToolCallCard key={index} data={call} />\n ))}\n </div>\n </StepSection>\n )}\n {data.observation && (\n <StepSection label={strings.trajectoryObservation}>\n <Markdown>{data.observation}</Markdown>\n </StepSection>\n )}\n </div>\n )}\n </article>\n );\n}\n"],"names":["StepSection","label","children","jsxs","jsx","MetricLabel","FENCE","EMPHASIS","delimiter","CODE_MARK","CODE_SPAN","MARKED_CODE","actionPreview","markdown","lines","fence","close","end","line","index","code","codes","masked","_span","current","pattern","part","TrajectoryStep","data","defaultExpanded","className","surface","wrapRef","useRef","agentAttrs","usePrimitiveSurface","strings","useStrings","expanded","setExpanded","useState","toolCalls","sections","summary","hasBody","actionTone","cls","e","Chip","StatusDot","formatDuration","Markdown","section","call","ToolCallCard"],"mappings":"mcAiDA,SAASA,EAAY,CACnB,MAAAC,EACA,SAAAC,CACF,EAGG,CACD,OACEC,EAAAA,KAAC,MAAA,CAAI,UAAU,sBACb,SAAA,CAAAC,EAAAA,IAACC,EAAAA,YAAA,CAAY,KAAK,KAAM,SAAAJ,EAAM,EAC9BG,EAAAA,IAAC,MAAA,CAAI,UAAU,2BAA4B,SAAAF,CAAA,CAAS,CAAA,EACtD,CAEJ,CAEA,MAAMI,EAAQ,iBAKRC,EAAW,CAAC,SAAU,KAAM,MAAO,GAAG,EAAE,IAC3CC,GACC,IAAI,OACF,iBAAiBA,CAAS,mBAAmBA,CAAS,gCACtD,GAAA,CAEN,EAIMC,EAAY,IACZC,EAAY,aACZC,EAAc,IAAI,OAAO,GAAGF,CAAS,SAASA,CAAS,EAAE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