@lunora/studio 1.0.0-alpha.53 → 1.0.0-alpha.55

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 (135) hide show
  1. package/dist/index.d.ts +680 -780
  2. package/dist/index.js +8 -8
  3. package/dist/mount.d.ts +10 -10
  4. package/dist/mount.js +1 -1
  5. package/dist/packem_chunks/ApiTab.js +1 -1
  6. package/dist/packem_chunks/AuditPanel.js +2 -2
  7. package/dist/packem_chunks/ExportImportPanel.js +2 -2
  8. package/dist/packem_chunks/FileBrowser.js +3 -3
  9. package/dist/packem_chunks/FunctionRunner.js +1 -1
  10. package/dist/packem_chunks/FunctionStatsPanel.js +2 -2
  11. package/dist/packem_chunks/HealthPanel.js +2 -2
  12. package/dist/packem_chunks/InsightsPanel.js +2 -2
  13. package/dist/packem_chunks/LogsPanel.js +81 -53
  14. package/dist/packem_chunks/MailPanel.js +1 -1
  15. package/dist/packem_chunks/MetricsPanel.js +392 -7
  16. package/dist/packem_chunks/MigrationsPanel.js +2 -2
  17. package/dist/packem_chunks/PitrPanel.js +1 -1
  18. package/dist/packem_chunks/SchemaViewer.js +2 -2
  19. package/dist/packem_chunks/SecurityAdvisorPanel.js +2 -2
  20. package/dist/packem_chunks/SettingsPanel.js +3 -3
  21. package/dist/packem_chunks/SqlEditorPanel.js +1 -1
  22. package/dist/packem_chunks/TableEditor.js +2 -2
  23. package/dist/packem_chunks/agents-panel.js +2 -2
  24. package/dist/packem_chunks/analytics-panel.js +1 -1
  25. package/dist/packem_chunks/auth-config-panel.js +1 -1
  26. package/dist/packem_chunks/auth-sessions-panel.js +1 -1
  27. package/dist/packem_chunks/containers-panel.js +2 -2
  28. package/dist/packem_chunks/dashboards-panel.js +2 -2
  29. package/dist/packem_chunks/fanout-panel.js +2 -2
  30. package/dist/packem_chunks/flags-panel.js +2 -2
  31. package/dist/packem_chunks/issues-panel.js +2 -2
  32. package/dist/packem_chunks/kv-browser.js +2 -2
  33. package/dist/packem_chunks/log-drains-panel.js +2 -2
  34. package/dist/packem_chunks/organizations-panel.js +1 -1
  35. package/dist/packem_chunks/payments-panel.js +2 -2
  36. package/dist/packem_chunks/permissions-panel.js +2 -2
  37. package/dist/packem_chunks/queues-panel.js +2 -2
  38. package/dist/packem_chunks/rls-panel.js +2 -2
  39. package/dist/packem_chunks/schedule-panel.js +2 -2
  40. package/dist/packem_chunks/storage-rules-panel.js +2 -2
  41. package/dist/packem_chunks/subscriptions-panel.js +2 -2
  42. package/dist/packem_chunks/traces-panel.js +734 -0
  43. package/dist/packem_chunks/users-panel.js +1 -1
  44. package/dist/packem_chunks/vector-browser.js +1 -1
  45. package/dist/packem_chunks/workflows-panel.js +2 -2
  46. package/dist/packem_shared/{ADMIN_FUNCTIONS-DNeyYtUN.js → ADMIN_FUNCTIONS-C6TEeUiJ.js} +2 -0
  47. package/dist/packem_shared/{ApiDocsPanel-_aEZxAMX.js → ApiDocsPanel-CcC6ucbp.js} +1 -1
  48. package/dist/packem_shared/{DataBrowser-C8hejnub.js → DataBrowser-BuFEPTiv.js} +1 -1
  49. package/dist/packem_shared/{GlobalDataBrowser-f5Ll2AQK.js → GlobalDataBrowser-D8h1fTL1.js} +1 -1
  50. package/dist/packem_shared/{HomePanel-Ye8PaqQL.js → HomePanel-2I1YZm0A.js} +3 -3
  51. package/dist/packem_shared/{ScheduledJobs-dHMgnJbx.js → ScheduledJobs-Cz5Tr-M6.js} +1 -1
  52. package/dist/packem_shared/{Studio-BNGjxLVo.js → Studio-CCJBI2wP.js} +2 -2
  53. package/dist/packem_shared/{StudioApp-K9dn1Q9d.js → StudioApp-Daeqxw2h.js} +1 -1
  54. package/dist/packem_shared/{advisor-view-Cx21PS_T.js → advisor-view-1RaDWED7.js} +1 -1
  55. package/dist/packem_shared/app.d-C-kxb-1T.d.ts +254 -0
  56. package/dist/packem_shared/{card-DURq3ElK.js → card-F2vH_aj2.js} +1 -1
  57. package/dist/packem_shared/{cf-links-BZfRdxSE.js → cf-links-SIbyi4Y1.js} +1 -1
  58. package/dist/packem_shared/{home-panel-D62G8108.js → home-panel-DHHUtnKU.js} +2 -2
  59. package/dist/packem_shared/log-fields-jEH83H2G.js +18 -0
  60. package/dist/packem_shared/{studio-Cd21fp4v.js → studio-0479nrrm.js} +551 -524
  61. package/dist/standalone/{chunk-SDQE2IUJ.js → chunk-3W4CSGDO.js} +1 -1
  62. package/dist/standalone/{chunk-FFVSSWU2.js → chunk-4AZYW2PI.js} +1 -1
  63. package/dist/standalone/{chunk-ZQQ3MFEQ.js → chunk-4F72YCTU.js} +1 -1
  64. package/dist/standalone/{chunk-IZN4TYMN.js → chunk-5IGHDPEP.js} +1 -1
  65. package/dist/standalone/{chunk-T7FHIJ2T.js → chunk-6LLFTVEI.js} +1 -1
  66. package/dist/standalone/{chunk-JPILGFXT.js → chunk-7YGTGBP7.js} +1 -1
  67. package/dist/standalone/{chunk-OETK333R.js → chunk-AE3AKGOW.js} +1 -1
  68. package/dist/standalone/{chunk-TO6D2PJC.js → chunk-CHNXZYAC.js} +1 -1
  69. package/dist/standalone/{chunk-R2MAZ2OH.js → chunk-CW7LZ4SR.js} +1 -1
  70. package/dist/standalone/{chunk-WUFVFVHJ.js → chunk-D73WYMRU.js} +1 -1
  71. package/dist/standalone/{chunk-YFZ27MEC.js → chunk-DVBY6YQK.js} +1 -1
  72. package/dist/standalone/chunk-EBTLTGG3.js +1 -0
  73. package/dist/standalone/chunk-EIZG4GOM.js +1 -0
  74. package/dist/standalone/{chunk-DMFVDMUJ.js → chunk-EPDC422O.js} +1 -1
  75. package/dist/standalone/{chunk-ISOUWAPB.js → chunk-FBGC3RSU.js} +1 -1
  76. package/dist/standalone/{chunk-LUP4YTBS.js → chunk-FDWXYXOM.js} +1 -1
  77. package/dist/standalone/{chunk-XXAW7V4T.js → chunk-FPKTXKPE.js} +1 -1
  78. package/dist/standalone/{chunk-AITOCPML.js → chunk-FQUNSQLG.js} +1 -1
  79. package/dist/standalone/{chunk-HRHG4HOZ.js → chunk-FXNS5NBY.js} +1 -1
  80. package/dist/standalone/{chunk-3GVA2ROQ.js → chunk-G4GGGHEV.js} +1 -1
  81. package/dist/standalone/{chunk-C4QK2DJN.js → chunk-G5CMK5GY.js} +1 -1
  82. package/dist/standalone/{chunk-GPQX3AEO.js → chunk-G5RC7USY.js} +1 -1
  83. package/dist/standalone/{chunk-PWKD5FTM.js → chunk-GVFODXW2.js} +1 -1
  84. package/dist/standalone/{chunk-MDTNVR3G.js → chunk-HNIDN3RX.js} +1 -1
  85. package/dist/standalone/{chunk-XXXNY3DK.js → chunk-IKVZUVHJ.js} +1 -1
  86. package/dist/standalone/{chunk-3C3CU2DS.js → chunk-JGCRBFFO.js} +1 -1
  87. package/dist/standalone/chunk-JHR3HKT5.js +3 -0
  88. package/dist/standalone/{chunk-WXUUGXDV.js → chunk-JQPHZL2A.js} +1 -1
  89. package/dist/standalone/{chunk-CRY26DNY.js → chunk-LJE6PGHD.js} +1 -1
  90. package/dist/standalone/{chunk-5JB7FDCA.js → chunk-LTCX3QOE.js} +1 -1
  91. package/dist/standalone/{chunk-ALL4U2C5.js → chunk-MWH5LBNF.js} +1 -1
  92. package/dist/standalone/{chunk-CZGILAZI.js → chunk-N5FMEYSL.js} +1 -1
  93. package/dist/standalone/chunk-N7SVJOHN.js +1 -0
  94. package/dist/standalone/{chunk-7KSXHCUD.js → chunk-NAFKYFBZ.js} +1 -1
  95. package/dist/standalone/{chunk-3XBP6RRG.js → chunk-OVSBLTAA.js} +1 -1
  96. package/dist/standalone/chunk-OXHHSUXO.js +1 -0
  97. package/dist/standalone/chunk-PIB7VUVM.js +1 -0
  98. package/dist/standalone/{chunk-IC7XYSER.js → chunk-Q3X7IMLF.js} +1 -1
  99. package/dist/standalone/{chunk-LAK5VSPI.js → chunk-QVIPA6UJ.js} +1 -1
  100. package/dist/standalone/{chunk-NXAKNU3L.js → chunk-RCSULEDU.js} +1 -1
  101. package/dist/standalone/{chunk-6TMEOFZC.js → chunk-RDA4VTHI.js} +1 -1
  102. package/dist/standalone/{chunk-VY6AI3RI.js → chunk-RG4HLPM2.js} +1 -1
  103. package/dist/standalone/{chunk-LOYE7OU2.js → chunk-S2G7OH5T.js} +1 -1
  104. package/dist/standalone/{chunk-7N5KFSSB.js → chunk-SP7GSPKX.js} +1 -1
  105. package/dist/standalone/{chunk-W6JKUZKD.js → chunk-SPACAIAR.js} +1 -1
  106. package/dist/standalone/{chunk-X4QFAAZ5.js → chunk-SWMBBYJU.js} +1 -1
  107. package/dist/standalone/{chunk-HZKFL2M7.js → chunk-TTEEPVCN.js} +1 -1
  108. package/dist/standalone/{chunk-SXAFEREK.js → chunk-VC2VDAUO.js} +1 -1
  109. package/dist/standalone/{chunk-USYCKPUK.js → chunk-VQ3YOUZB.js} +1 -1
  110. package/dist/standalone/chunk-VXM5H542.js +4 -0
  111. package/dist/standalone/{chunk-3MAQAOUA.js → chunk-W7ND56KZ.js} +1 -1
  112. package/dist/standalone/{chunk-43F677PE.js → chunk-WA3DGSC2.js} +1 -1
  113. package/dist/standalone/{chunk-75LPCQ77.js → chunk-WCLFE2ZB.js} +1 -1
  114. package/dist/standalone/{chunk-EEWKIQUE.js → chunk-WOYQG5AM.js} +1 -1
  115. package/dist/standalone/{chunk-JM7XBQVK.js → chunk-XCNYUUD6.js} +1 -1
  116. package/dist/standalone/{chunk-ZVT4GJEI.js → chunk-XG4TZSP4.js} +1 -1
  117. package/dist/standalone/{chunk-A3ZJACVT.js → chunk-XZWFP2GI.js} +1 -1
  118. package/dist/standalone/chunk-YNSFQKMM.js +1 -0
  119. package/dist/standalone/{chunk-CODD62OJ.js → chunk-YRE6TGXH.js} +1 -1
  120. package/dist/standalone/{chunk-S7RKDQPS.js → chunk-YS7NUMAN.js} +1 -1
  121. package/dist/standalone/{chunk-IEKK5GO6.js → chunk-ZUTFDG76.js} +1 -1
  122. package/dist/standalone/{chunk-22C6COGE.js → chunk-ZXLEXF4X.js} +2 -2
  123. package/dist/standalone/studio.js +1 -1
  124. package/dist/styles.css +2 -2
  125. package/package.json +8 -8
  126. package/dist/packem_shared/app.d-CGdOmLTm.d.ts +0 -300
  127. package/dist/standalone/chunk-G7ZBM54M.js +0 -1
  128. package/dist/standalone/chunk-I7Y7ST5Y.js +0 -1
  129. package/dist/standalone/chunk-KJJ3WM6H.js +0 -4
  130. package/dist/standalone/chunk-LT7IG26L.js +0 -1
  131. package/dist/standalone/chunk-TC4KPQJ7.js +0 -3
  132. package/dist/standalone/chunk-WI7GWFEG.js +0 -1
  133. /package/dist/standalone/{chunk-ITQKVEP7.js → chunk-5XO36X4C.js} +0 -0
  134. /package/dist/standalone/{chunk-TQ36RWOP.js → chunk-IYHPYY4A.js} +0 -0
  135. /package/dist/standalone/{chunk-SEU5V7I6.js → chunk-Y572GMZE.js} +0 -0
@@ -0,0 +1,734 @@
1
+ import { c } from 'react/compiler-runtime';
2
+ import { useState, useEffect } from 'react';
3
+ import { f as formatLogFields } from '../packem_shared/log-fields-jEH83H2G.js';
4
+ import { E as ErrorAlert } from '../packem_shared/error-alert-vIPQoN3Y.js';
5
+ import { L as LiveError } from '../packem_shared/live-status-FZ0psC1z.js';
6
+ import { ShardInput } from '../packem_shared/ShardInput-CZnpHILL.js';
7
+ import { B as Badge } from '../packem_shared/badge-B2PKA1-5.js';
8
+ import { E as EmptyState } from '../packem_shared/empty-state-DY_oe0k6.js';
9
+ import { I as Input } from '../packem_shared/input-XH4r1Pt1.js';
10
+ import { u as useAdminQuery } from '../packem_shared/use-admin-query-BGJ010yZ.js';
11
+ import useDebounced from '../packem_shared/useDebounced-Dxncpg6z.js';
12
+ import { useT } from '../packem_shared/DEFAULT_LOCALE-CiX4W7Kr.js';
13
+ import { ADMIN_FUNCTIONS } from '../packem_shared/ADMIN_FUNCTIONS-C6TEeUiJ.js';
14
+ import { i as formatTimestamp } from '../packem_shared/internal-zwBoOv24.js';
15
+ import { r as recordShard } from '../packem_shared/shard-history-AxiJ1WPP.js';
16
+ import { c as cn } from '../packem_shared/utils-B05Dmz_H.js';
17
+ import { jsxDEV } from 'react/jsx-dev-runtime';
18
+
19
+ const MIN_BAR_PERCENT = 0.5;
20
+ const clampPercent = (value) => Math.min(100, Math.max(0, value));
21
+ const spanBar = (span, traceDurationMs) => {
22
+ if (!Number.isFinite(traceDurationMs) || traceDurationMs <= 0) {
23
+ return {
24
+ leftPercent: 0,
25
+ widthPercent: 100
26
+ };
27
+ }
28
+ const leftPercent = clampPercent(span.offsetMs / traceDurationMs * 100);
29
+ const rawWidth = span.durationMs / traceDurationMs * 100;
30
+ const widthPercent = Math.max(MIN_BAR_PERCENT, Math.min(clampPercent(rawWidth), 100 - leftPercent));
31
+ return {
32
+ leftPercent,
33
+ widthPercent
34
+ };
35
+ };
36
+ const filterTraces = (traces, search) => {
37
+ const needle = search.trim().toLowerCase();
38
+ if (needle === "") {
39
+ return [...traces];
40
+ }
41
+ return traces.filter((trace) => trace.rootName.toLowerCase().includes(needle) || trace.functionPath.toLowerCase().includes(needle));
42
+ };
43
+ const formatSpanDuration = (durationMs) => {
44
+ if (!Number.isFinite(durationMs)) {
45
+ return "—";
46
+ }
47
+ return durationMs > 0 && durationMs < 1 ? `${durationMs.toFixed(2)}ms` : `${String(Math.round(durationMs))}ms`;
48
+ };
49
+
50
+ const INDENT_PER_DEPTH = 14;
51
+ const tracesOf = (result) => Array.isArray(result?.traces) ? result.traces : [];
52
+ const SpanRow = (t0) => {
53
+ const $ = c(50);
54
+ const {
55
+ span,
56
+ traceDurationMs
57
+ } = t0;
58
+ const t = useT();
59
+ let t1;
60
+ if ($[0] !== span || $[1] !== traceDurationMs) {
61
+ t1 = spanBar(span, traceDurationMs);
62
+ $[0] = span;
63
+ $[1] = traceDurationMs;
64
+ $[2] = t1;
65
+ } else {
66
+ t1 = $[2];
67
+ }
68
+ const {
69
+ leftPercent,
70
+ widthPercent
71
+ } = t1;
72
+ let t2;
73
+ if ($[3] !== span.attributes) {
74
+ t2 = formatLogFields(span.attributes);
75
+ $[3] = span.attributes;
76
+ $[4] = t2;
77
+ } else {
78
+ t2 = $[4];
79
+ }
80
+ const attributes = t2;
81
+ const t3 = span.depth * INDENT_PER_DEPTH;
82
+ let t4;
83
+ if ($[5] !== t3) {
84
+ t4 = {
85
+ paddingLeft: t3
86
+ };
87
+ $[5] = t3;
88
+ $[6] = t4;
89
+ } else {
90
+ t4 = $[6];
91
+ }
92
+ const nameStyle = t4;
93
+ const t5 = `${String(leftPercent)}%`;
94
+ const t6 = `${String(widthPercent)}%`;
95
+ let t7;
96
+ if ($[7] !== t5 || $[8] !== t6) {
97
+ t7 = {
98
+ left: t5,
99
+ width: t6
100
+ };
101
+ $[7] = t5;
102
+ $[8] = t6;
103
+ $[9] = t7;
104
+ } else {
105
+ t7 = $[9];
106
+ }
107
+ const barStyle = t7;
108
+ const t8 = span.depth;
109
+ let t9;
110
+ if ($[10] !== span.ok || $[11] !== t) {
111
+ t9 = span.ok ? null : /* @__PURE__ */ jsxDEV("span", {
112
+ "aria-label": t("Errored span"),
113
+ className: "mr-1 text-destructive",
114
+ "data-testid": "tr-span-error",
115
+ role: "img",
116
+ children: "●"
117
+ }, void 0, false);
118
+ $[10] = span.ok;
119
+ $[11] = t;
120
+ $[12] = t9;
121
+ } else {
122
+ t9 = $[12];
123
+ }
124
+ let t10;
125
+ if ($[13] !== nameStyle || $[14] !== span.name || $[15] !== t9) {
126
+ t10 = /* @__PURE__ */ jsxDEV("span", {
127
+ className: "w-56 shrink-0 truncate",
128
+ role: "gridcell",
129
+ style: nameStyle,
130
+ title: span.name,
131
+ children: [t9, span.name]
132
+ }, void 0, true);
133
+ $[13] = nameStyle;
134
+ $[14] = span.name;
135
+ $[15] = t9;
136
+ $[16] = t10;
137
+ } else {
138
+ t10 = $[16];
139
+ }
140
+ let t11;
141
+ if ($[17] !== span.durationMs || $[18] !== span.offsetMs || $[19] !== t) {
142
+ t11 = t("starts {offset} in, runs {duration}", {
143
+ duration: formatSpanDuration(span.durationMs),
144
+ offset: formatSpanDuration(span.offsetMs)
145
+ });
146
+ $[17] = span.durationMs;
147
+ $[18] = span.offsetMs;
148
+ $[19] = t;
149
+ $[20] = t11;
150
+ } else {
151
+ t11 = $[20];
152
+ }
153
+ const t12 = span.ok ? "bg-primary/70" : "bg-destructive";
154
+ let t13;
155
+ if ($[21] !== t12) {
156
+ t13 = cn("absolute inset-y-0 rounded-sm", t12);
157
+ $[21] = t12;
158
+ $[22] = t13;
159
+ } else {
160
+ t13 = $[22];
161
+ }
162
+ let t14;
163
+ if ($[23] !== barStyle || $[24] !== leftPercent || $[25] !== t13 || $[26] !== widthPercent) {
164
+ t14 = /* @__PURE__ */ jsxDEV("span", {
165
+ className: t13,
166
+ "data-left": leftPercent,
167
+ "data-testid": "tr-span-bar",
168
+ "data-width": widthPercent,
169
+ style: barStyle
170
+ }, void 0, false);
171
+ $[23] = barStyle;
172
+ $[24] = leftPercent;
173
+ $[25] = t13;
174
+ $[26] = widthPercent;
175
+ $[27] = t14;
176
+ } else {
177
+ t14 = $[27];
178
+ }
179
+ let t15;
180
+ if ($[28] !== t11 || $[29] !== t14) {
181
+ t15 = /* @__PURE__ */ jsxDEV("span", {
182
+ "aria-label": t11,
183
+ className: "relative h-3 flex-1 overflow-hidden rounded-sm bg-muted",
184
+ role: "gridcell",
185
+ children: t14
186
+ }, void 0, false);
187
+ $[28] = t11;
188
+ $[29] = t14;
189
+ $[30] = t15;
190
+ } else {
191
+ t15 = $[30];
192
+ }
193
+ let t16;
194
+ if ($[31] !== span.durationMs) {
195
+ t16 = formatSpanDuration(span.durationMs);
196
+ $[31] = span.durationMs;
197
+ $[32] = t16;
198
+ } else {
199
+ t16 = $[32];
200
+ }
201
+ let t17;
202
+ if ($[33] !== t16) {
203
+ t17 = /* @__PURE__ */ jsxDEV("span", {
204
+ className: "w-16 shrink-0 text-right tabular-nums text-muted-foreground",
205
+ role: "gridcell",
206
+ children: t16
207
+ }, void 0, false);
208
+ $[33] = t16;
209
+ $[34] = t17;
210
+ } else {
211
+ t17 = $[34];
212
+ }
213
+ let t18;
214
+ if ($[35] !== span.error) {
215
+ t18 = span.error === void 0 ? null : /* @__PURE__ */ jsxDEV("span", {
216
+ className: "text-destructive",
217
+ "data-testid": "tr-span-error-message",
218
+ title: span.error.message,
219
+ children: `${span.error.type}: ${span.error.message}`
220
+ }, void 0, false);
221
+ $[35] = span.error;
222
+ $[36] = t18;
223
+ } else {
224
+ t18 = $[36];
225
+ }
226
+ let t19;
227
+ if ($[37] !== t18) {
228
+ t19 = /* @__PURE__ */ jsxDEV("span", {
229
+ className: "w-64 shrink-0 truncate text-muted-foreground",
230
+ role: "gridcell",
231
+ children: t18
232
+ }, void 0, false);
233
+ $[37] = t18;
234
+ $[38] = t19;
235
+ } else {
236
+ t19 = $[38];
237
+ }
238
+ let t20;
239
+ if ($[39] !== attributes) {
240
+ t20 = attributes === "" ? null : /* @__PURE__ */ jsxDEV("span", {
241
+ "data-testid": "tr-span-attributes",
242
+ title: attributes,
243
+ children: attributes
244
+ }, void 0, false);
245
+ $[39] = attributes;
246
+ $[40] = t20;
247
+ } else {
248
+ t20 = $[40];
249
+ }
250
+ let t21;
251
+ if ($[41] !== t20) {
252
+ t21 = /* @__PURE__ */ jsxDEV("span", {
253
+ className: "w-64 shrink-0 truncate text-muted-foreground",
254
+ role: "gridcell",
255
+ children: t20
256
+ }, void 0, false);
257
+ $[41] = t20;
258
+ $[42] = t21;
259
+ } else {
260
+ t21 = $[42];
261
+ }
262
+ let t22;
263
+ if ($[43] !== span.depth || $[44] !== t10 || $[45] !== t15 || $[46] !== t17 || $[47] !== t19 || $[48] !== t21) {
264
+ t22 = /* @__PURE__ */ jsxDEV("div", {
265
+ className: "flex items-center gap-2 border-b border-border px-3 py-1.5 font-mono text-xs last:border-b-0 hover:bg-muted/50",
266
+ "data-depth": t8,
267
+ "data-testid": "tr-span-row",
268
+ role: "row",
269
+ children: [t10, t15, t17, t19, t21]
270
+ }, void 0, true);
271
+ $[43] = span.depth;
272
+ $[44] = t10;
273
+ $[45] = t15;
274
+ $[46] = t17;
275
+ $[47] = t19;
276
+ $[48] = t21;
277
+ $[49] = t22;
278
+ } else {
279
+ t22 = $[49];
280
+ }
281
+ return t22;
282
+ };
283
+ const TraceRow = (t0) => {
284
+ const $ = c(50);
285
+ const {
286
+ expanded,
287
+ onToggle,
288
+ trace
289
+ } = t0;
290
+ const t = useT();
291
+ let t1;
292
+ if ($[0] !== onToggle || $[1] !== trace.traceId) {
293
+ t1 = () => {
294
+ onToggle(trace.traceId);
295
+ };
296
+ $[0] = onToggle;
297
+ $[1] = trace.traceId;
298
+ $[2] = t1;
299
+ } else {
300
+ t1 = $[2];
301
+ }
302
+ const onClick = t1;
303
+ const t2 = `tr-row-${trace.traceId}`;
304
+ const t3 = `tr-waterfall-${trace.traceId}`;
305
+ const t4 = `tr-toggle-${trace.traceId}`;
306
+ const t5 = expanded ? "▾" : "▸";
307
+ let t6;
308
+ if ($[3] !== t5) {
309
+ t6 = /* @__PURE__ */ jsxDEV("span", {
310
+ "aria-hidden": "true",
311
+ className: "w-3 shrink-0 text-xs text-muted-foreground",
312
+ children: t5
313
+ }, void 0, false);
314
+ $[3] = t5;
315
+ $[4] = t6;
316
+ } else {
317
+ t6 = $[4];
318
+ }
319
+ let t7;
320
+ if ($[5] !== trace.rootName) {
321
+ t7 = /* @__PURE__ */ jsxDEV("span", {
322
+ className: "w-56 shrink-0 truncate text-sm font-medium",
323
+ title: trace.rootName,
324
+ children: trace.rootName
325
+ }, void 0, false);
326
+ $[5] = trace.rootName;
327
+ $[6] = t7;
328
+ } else {
329
+ t7 = $[6];
330
+ }
331
+ let t8;
332
+ if ($[7] !== trace.functionPath) {
333
+ t8 = /* @__PURE__ */ jsxDEV("span", {
334
+ className: "w-48 shrink-0 truncate font-mono text-xs text-muted-foreground",
335
+ title: trace.functionPath,
336
+ children: trace.functionPath
337
+ }, void 0, false);
338
+ $[7] = trace.functionPath;
339
+ $[8] = t8;
340
+ } else {
341
+ t8 = $[8];
342
+ }
343
+ let t9;
344
+ if ($[9] !== trace.durationMs) {
345
+ t9 = formatSpanDuration(trace.durationMs);
346
+ $[9] = trace.durationMs;
347
+ $[10] = t9;
348
+ } else {
349
+ t9 = $[10];
350
+ }
351
+ let t10;
352
+ if ($[11] !== t9) {
353
+ t10 = /* @__PURE__ */ jsxDEV("span", {
354
+ className: "w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",
355
+ children: t9
356
+ }, void 0, false);
357
+ $[11] = t9;
358
+ $[12] = t10;
359
+ } else {
360
+ t10 = $[12];
361
+ }
362
+ let t11;
363
+ if ($[13] !== t || $[14] !== trace.spans.length) {
364
+ t11 = t("{count} spans", {
365
+ count: trace.spans.length
366
+ });
367
+ $[13] = t;
368
+ $[14] = trace.spans.length;
369
+ $[15] = t11;
370
+ } else {
371
+ t11 = $[15];
372
+ }
373
+ let t12;
374
+ if ($[16] !== t11) {
375
+ t12 = /* @__PURE__ */ jsxDEV("span", {
376
+ className: "w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",
377
+ children: t11
378
+ }, void 0, false);
379
+ $[16] = t11;
380
+ $[17] = t12;
381
+ } else {
382
+ t12 = $[17];
383
+ }
384
+ const t13 = trace.ok ? "secondary" : "destructive";
385
+ let t14;
386
+ if ($[18] !== t || $[19] !== trace.ok) {
387
+ t14 = trace.ok ? t("ok") : t("error");
388
+ $[18] = t;
389
+ $[19] = trace.ok;
390
+ $[20] = t14;
391
+ } else {
392
+ t14 = $[20];
393
+ }
394
+ let t15;
395
+ if ($[21] !== t13 || $[22] !== t14) {
396
+ t15 = /* @__PURE__ */ jsxDEV("span", {
397
+ className: "shrink-0",
398
+ children: /* @__PURE__ */ jsxDEV(Badge, {
399
+ variant: t13,
400
+ children: t14
401
+ }, void 0, false)
402
+ }, void 0, false);
403
+ $[21] = t13;
404
+ $[22] = t14;
405
+ $[23] = t15;
406
+ } else {
407
+ t15 = $[23];
408
+ }
409
+ let t16;
410
+ if ($[24] !== trace.startTs) {
411
+ t16 = formatTimestamp(trace.startTs);
412
+ $[24] = trace.startTs;
413
+ $[25] = t16;
414
+ } else {
415
+ t16 = $[25];
416
+ }
417
+ let t17;
418
+ if ($[26] !== t16) {
419
+ t17 = /* @__PURE__ */ jsxDEV("span", {
420
+ className: "flex-1 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",
421
+ children: t16
422
+ }, void 0, false);
423
+ $[26] = t16;
424
+ $[27] = t17;
425
+ } else {
426
+ t17 = $[27];
427
+ }
428
+ let t18;
429
+ if ($[28] !== expanded || $[29] !== onClick || $[30] !== t10 || $[31] !== t12 || $[32] !== t15 || $[33] !== t17 || $[34] !== t3 || $[35] !== t4 || $[36] !== t6 || $[37] !== t7 || $[38] !== t8) {
430
+ t18 = /* @__PURE__ */ jsxDEV("button", {
431
+ "aria-controls": t3,
432
+ "aria-expanded": expanded,
433
+ className: "flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50",
434
+ "data-testid": t4,
435
+ onClick,
436
+ type: "button",
437
+ children: [t6, t7, t8, t10, t12, t15, t17]
438
+ }, void 0, true);
439
+ $[28] = expanded;
440
+ $[29] = onClick;
441
+ $[30] = t10;
442
+ $[31] = t12;
443
+ $[32] = t15;
444
+ $[33] = t17;
445
+ $[34] = t3;
446
+ $[35] = t4;
447
+ $[36] = t6;
448
+ $[37] = t7;
449
+ $[38] = t8;
450
+ $[39] = t18;
451
+ } else {
452
+ t18 = $[39];
453
+ }
454
+ let t19;
455
+ if ($[40] !== expanded || $[41] !== t || $[42] !== trace.durationMs || $[43] !== trace.spans || $[44] !== trace.traceId) {
456
+ t19 = expanded && /* @__PURE__ */ jsxDEV("div", {
457
+ "aria-label": t("Trace waterfall"),
458
+ className: "bg-muted/20",
459
+ "data-testid": `tr-waterfall-${trace.traceId}`,
460
+ id: `tr-waterfall-${trace.traceId}`,
461
+ role: "grid",
462
+ children: trace.spans.map((span) => /* @__PURE__ */ jsxDEV(SpanRow, {
463
+ span,
464
+ traceDurationMs: trace.durationMs
465
+ }, span.spanId, false))
466
+ }, void 0, false);
467
+ $[40] = expanded;
468
+ $[41] = t;
469
+ $[42] = trace.durationMs;
470
+ $[43] = trace.spans;
471
+ $[44] = trace.traceId;
472
+ $[45] = t19;
473
+ } else {
474
+ t19 = $[45];
475
+ }
476
+ let t20;
477
+ if ($[46] !== t18 || $[47] !== t19 || $[48] !== t2) {
478
+ t20 = /* @__PURE__ */ jsxDEV("div", {
479
+ className: "border-b border-border last:border-b-0",
480
+ "data-testid": t2,
481
+ children: [t18, t19]
482
+ }, void 0, true);
483
+ $[46] = t18;
484
+ $[47] = t19;
485
+ $[48] = t2;
486
+ $[49] = t20;
487
+ } else {
488
+ t20 = $[49];
489
+ }
490
+ return t20;
491
+ };
492
+ const TracesPanel = (t0) => {
493
+ const $ = c(43);
494
+ const {
495
+ initialShardKey
496
+ } = t0;
497
+ const t = useT();
498
+ const [shardKey, setShardKey] = useState(initialShardKey ?? "");
499
+ const [search, setSearch] = useState("");
500
+ const [expanded, setExpanded] = useState(_temp);
501
+ let t1;
502
+ if ($[0] !== shardKey) {
503
+ t1 = shardKey.trim();
504
+ $[0] = shardKey;
505
+ $[1] = t1;
506
+ } else {
507
+ t1 = $[1];
508
+ }
509
+ const debouncedShard = useDebounced(t1, 400);
510
+ let t2;
511
+ if ($[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
512
+ t2 = {};
513
+ $[2] = t2;
514
+ } else {
515
+ t2 = $[2];
516
+ }
517
+ let t3;
518
+ if ($[3] !== debouncedShard) {
519
+ t3 = {
520
+ live: true,
521
+ shardKey: debouncedShard
522
+ };
523
+ $[3] = debouncedShard;
524
+ $[4] = t3;
525
+ } else {
526
+ t3 = $[4];
527
+ }
528
+ const {
529
+ data,
530
+ error,
531
+ errorSource,
532
+ isLoading,
533
+ liveError
534
+ } = useAdminQuery(ADMIN_FUNCTIONS.getTraces, t2, t3);
535
+ let t4;
536
+ let t5;
537
+ if ($[5] !== data || $[6] !== debouncedShard) {
538
+ t4 = () => {
539
+ if (data !== void 0) {
540
+ recordShard(debouncedShard);
541
+ }
542
+ };
543
+ t5 = [data, debouncedShard];
544
+ $[5] = data;
545
+ $[6] = debouncedShard;
546
+ $[7] = t4;
547
+ $[8] = t5;
548
+ } else {
549
+ t4 = $[7];
550
+ t5 = $[8];
551
+ }
552
+ useEffect(t4, t5);
553
+ let t6;
554
+ if ($[9] !== data || $[10] !== error || $[11] !== errorSource || $[12] !== expanded || $[13] !== isLoading || $[14] !== liveError || $[15] !== search || $[16] !== shardKey || $[17] !== t) {
555
+ const traces = tracesOf(data);
556
+ const total = data?.total ?? traces.length;
557
+ const truncated = total > traces.length;
558
+ const filtered = filterTraces(traces, search);
559
+ let t7;
560
+ if ($[19] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
561
+ t7 = (event) => {
562
+ setSearch(event.target.value);
563
+ };
564
+ $[19] = t7;
565
+ } else {
566
+ t7 = $[19];
567
+ }
568
+ const onSearchChange = t7;
569
+ let t8;
570
+ if ($[20] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
571
+ t8 = (traceId) => {
572
+ setExpanded((previous) => {
573
+ const next = new Set(previous);
574
+ if (next.has(traceId)) {
575
+ next.delete(traceId);
576
+ } else {
577
+ next.add(traceId);
578
+ }
579
+ return next;
580
+ });
581
+ };
582
+ $[20] = t8;
583
+ } else {
584
+ t8 = $[20];
585
+ }
586
+ const onToggle = t8;
587
+ const showEmpty = error === null && filtered.length === 0 && !isLoading;
588
+ let t9;
589
+ if ($[21] !== shardKey) {
590
+ t9 = /* @__PURE__ */ jsxDEV(ShardInput, {
591
+ onChange: setShardKey,
592
+ testId: "tr-shard-input",
593
+ value: shardKey
594
+ }, void 0, false);
595
+ $[21] = shardKey;
596
+ $[22] = t9;
597
+ } else {
598
+ t9 = $[22];
599
+ }
600
+ let t10;
601
+ if ($[23] !== t) {
602
+ t10 = t("Search traces");
603
+ $[23] = t;
604
+ $[24] = t10;
605
+ } else {
606
+ t10 = $[24];
607
+ }
608
+ let t11;
609
+ if ($[25] !== t) {
610
+ t11 = t("search trace or function");
611
+ $[25] = t;
612
+ $[26] = t11;
613
+ } else {
614
+ t11 = $[26];
615
+ }
616
+ let t12;
617
+ if ($[27] !== search || $[28] !== t10 || $[29] !== t11) {
618
+ t12 = /* @__PURE__ */ jsxDEV(Input, {
619
+ "aria-label": t10,
620
+ className: "h-8 w-56",
621
+ "data-testid": "tr-search",
622
+ onChange: onSearchChange,
623
+ placeholder: t11,
624
+ value: search
625
+ }, void 0, false);
626
+ $[27] = search;
627
+ $[28] = t10;
628
+ $[29] = t11;
629
+ $[30] = t12;
630
+ } else {
631
+ t12 = $[30];
632
+ }
633
+ let t13;
634
+ if ($[31] !== liveError) {
635
+ t13 = /* @__PURE__ */ jsxDEV(LiveError, {
636
+ message: liveError,
637
+ prefix: "tr"
638
+ }, void 0, false);
639
+ $[31] = liveError;
640
+ $[32] = t13;
641
+ } else {
642
+ t13 = $[32];
643
+ }
644
+ let t14;
645
+ if ($[33] !== t12 || $[34] !== t13 || $[35] !== t9) {
646
+ t14 = /* @__PURE__ */ jsxDEV("div", {
647
+ className: "flex flex-wrap items-center gap-2",
648
+ children: [t9, t12, t13]
649
+ }, void 0, true);
650
+ $[33] = t12;
651
+ $[34] = t13;
652
+ $[35] = t9;
653
+ $[36] = t14;
654
+ } else {
655
+ t14 = $[36];
656
+ }
657
+ let t15;
658
+ if ($[37] !== error || $[38] !== errorSource) {
659
+ t15 = error !== null && /* @__PURE__ */ jsxDEV(ErrorAlert, {
660
+ error: errorSource,
661
+ testId: "tr-error"
662
+ }, void 0, false);
663
+ $[37] = error;
664
+ $[38] = errorSource;
665
+ $[39] = t15;
666
+ } else {
667
+ t15 = $[39];
668
+ }
669
+ let t16;
670
+ if ($[40] !== showEmpty || $[41] !== t) {
671
+ t16 = showEmpty && /* @__PURE__ */ jsxDEV(EmptyState, {
672
+ description: t("Traces recorded with ctx.trace show up here as your app handles traffic. The span buffer resets when the shard hibernates."),
673
+ icon: /* @__PURE__ */ jsxDEV("svg", {
674
+ "aria-hidden": "true",
675
+ fill: "none",
676
+ stroke: "currentColor",
677
+ strokeLinecap: "round",
678
+ strokeLinejoin: "round",
679
+ strokeWidth: 1.6,
680
+ viewBox: "0 0 24 24",
681
+ children: /* @__PURE__ */ jsxDEV("path", {
682
+ d: "M4 6h10M7 12h13M10 18h7"
683
+ }, void 0, false)
684
+ }, void 0, false),
685
+ testId: "tr-empty",
686
+ title: t("No traces")
687
+ }, void 0, false);
688
+ $[40] = showEmpty;
689
+ $[41] = t;
690
+ $[42] = t16;
691
+ } else {
692
+ t16 = $[42];
693
+ }
694
+ t6 = /* @__PURE__ */ jsxDEV("div", {
695
+ className: "flex flex-col gap-4",
696
+ "data-testid": "lunora-traces-panel",
697
+ children: [t14, t15, t16, error === null && truncated && /* @__PURE__ */ jsxDEV("p", {
698
+ className: "text-xs text-muted-foreground",
699
+ "data-testid": "tr-truncated",
700
+ children: t("Showing the {shown} most recent of {total} traces in the buffer.", {
701
+ shown: traces.length,
702
+ total
703
+ })
704
+ }, void 0, false), error === null && filtered.length > 0 && /* @__PURE__ */ jsxDEV("div", {
705
+ "aria-label": t("Recent traces"),
706
+ className: "overflow-hidden rounded-xl border border-border shadow-xs",
707
+ "data-testid": "tr-list",
708
+ children: filtered.map((trace) => /* @__PURE__ */ jsxDEV(TraceRow, {
709
+ expanded: expanded.has(trace.traceId),
710
+ onToggle,
711
+ trace
712
+ }, trace.traceId, false))
713
+ }, void 0, false)]
714
+ }, void 0, true);
715
+ $[9] = data;
716
+ $[10] = error;
717
+ $[11] = errorSource;
718
+ $[12] = expanded;
719
+ $[13] = isLoading;
720
+ $[14] = liveError;
721
+ $[15] = search;
722
+ $[16] = shardKey;
723
+ $[17] = t;
724
+ $[18] = t6;
725
+ } else {
726
+ t6 = $[18];
727
+ }
728
+ return t6;
729
+ };
730
+ function _temp() {
731
+ return /* @__PURE__ */ new Set();
732
+ }
733
+
734
+ export { TracesPanel };