@motiadev/plugin-observability 0.15.6-beta.174 → 0.16.0-beta.176

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/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { c } from "react/compiler-runtime";
2
- import { Fragment, forwardRef, memo, useEffect, useRef, useState } from "react";
2
+ import { Fragment, forwardRef, memo, useEffect, useMemo, useRef, useState } from "react";
3
3
  import { Badge, Button, Input, LevelDot, Sidebar, cn } from "@motiadev/ui";
4
4
  import { Check, Copy, GanttChartSquare, MessageCircle, Minus, Package, Plus, Radio, ScrollText, Search, Trash, X } from "lucide-react";
5
5
  import { create } from "zustand";
@@ -9,14 +9,23 @@ import * as PopoverPrimitive from "@radix-ui/react-popover";
9
9
  import ReactJson from "react18-json-view";
10
10
  import "react18-json-view/src/dark.css";
11
11
  import "react18-json-view/src/style.css";
12
+ import { useVirtualizer } from "@tanstack/react-virtual";
12
13
  import { formatDistanceToNow } from "date-fns";
13
14
 
14
15
  //#region src/stores/use-observability-store.ts
15
16
  const useObservabilityStore = create()((set) => ({
17
+ traceGroups: [],
18
+ traces: [],
16
19
  selectedTraceGroupId: "",
17
20
  selectedTraceId: void 0,
18
21
  search: "",
19
- selectTraceGroupId: (groupId) => set({ selectedTraceGroupId: groupId }),
22
+ setTraceGroups: (groups) => {
23
+ set({ traceGroups: Array.isArray(groups) ? groups : [] });
24
+ },
25
+ setTraces: (traces) => {
26
+ set({ traces: Array.isArray(traces) ? traces : [] });
27
+ },
28
+ selectTraceGroupId: (groupId$1) => set({ selectedTraceGroupId: groupId$1 }),
20
29
  selectTraceId: (traceId) => set({ selectedTraceId: traceId }),
21
30
  setSearch: (search) => set({ search }),
22
31
  clearTraces: () => {
@@ -32,8 +41,8 @@ const SearchBar = memo(() => {
32
41
  for (let $i = 0; $i < 24; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
33
42
  $[0] = "0d378097fa8da23c1a1ca72ef31fe4b19f0c9bbeda9092deafe087d58425242d";
34
43
  }
35
- const search = useObservabilityStore(_temp$6);
36
- const setSearch = useObservabilityStore(_temp2$3);
44
+ const search = useObservabilityStore(_temp$7);
45
+ const setSearch = useObservabilityStore(_temp2$4);
37
46
  const clearTraces = useObservabilityStore(_temp3$1);
38
47
  let t0;
39
48
  if ($[1] !== setSearch) {
@@ -131,10 +140,10 @@ const SearchBar = memo(() => {
131
140
  return t11;
132
141
  });
133
142
  SearchBar.displayName = "SearchBar";
134
- function _temp$6(state) {
143
+ function _temp$7(state) {
135
144
  return state.search;
136
145
  }
137
- function _temp2$3(state_0) {
146
+ function _temp2$4(state_0) {
138
147
  return state_0.setSearch;
139
148
  }
140
149
  function _temp3$1(state_1) {
@@ -149,7 +158,7 @@ const TraceEmptyState = memo(() => {
149
158
  for (let $i = 0; $i < 2; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
150
159
  $[0] = "2108089e2c746ed0862d68dda608395c37fa47e1141188e212f129d7d9fe3d12";
151
160
  }
152
- if (useObservabilityStore(_temp$5)) return null;
161
+ if (useObservabilityStore(_temp$6)) return null;
153
162
  let t0;
154
163
  if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
155
164
  t0 = /* @__PURE__ */ jsx("div", {
@@ -161,7 +170,7 @@ const TraceEmptyState = memo(() => {
161
170
  return t0;
162
171
  });
163
172
  TraceEmptyState.displayName = "TraceEmptyState";
164
- function _temp$5(state) {
173
+ function _temp$6(state) {
165
174
  return state.selectedTraceGroupId;
166
175
  }
167
176
 
@@ -211,6 +220,37 @@ const useGetEndTime = (group) => {
211
220
  return endTime;
212
221
  };
213
222
 
223
+ //#endregion
224
+ //#region src/hooks/use-traces-stream.ts
225
+ const streamName$1 = "motia-trace";
226
+ const useTracesStream = () => {
227
+ const $ = c(4);
228
+ if ($[0] !== "bcd1cb2c3d5b881ae86f74bb18d93ab6669b2358da38d97af969437f8354452c") {
229
+ for (let $i = 0; $i < 4; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
230
+ $[0] = "bcd1cb2c3d5b881ae86f74bb18d93ab6669b2358da38d97af969437f8354452c";
231
+ }
232
+ const groupId$1 = useObservabilityStore(_temp$5);
233
+ const setData = useObservabilityStore(_temp2$3);
234
+ let t0;
235
+ if ($[1] !== groupId$1 || $[2] !== setData) {
236
+ t0 = {
237
+ streamName: streamName$1,
238
+ groupId: groupId$1,
239
+ setData
240
+ };
241
+ $[1] = groupId$1;
242
+ $[2] = setData;
243
+ $[3] = t0;
244
+ } else t0 = $[3];
245
+ useStreamGroup(t0);
246
+ };
247
+ function _temp$5(state) {
248
+ return state.selectedTraceGroupId;
249
+ }
250
+ function _temp2$3(state_0) {
251
+ return state_0.setTraces;
252
+ }
253
+
214
254
  //#endregion
215
255
  //#region src/lib/utils.ts
216
256
  const formatDuration = (duration) => {
@@ -1342,369 +1382,401 @@ TraceItemDetail.displayName = "TraceItemDetail";
1342
1382
  //#region src/components/trace-timeline.tsx
1343
1383
  const TraceTimeline = memo(() => {
1344
1384
  const $ = c(3);
1345
- if ($[0] !== "fd73f7a8c1f8a9d942e9e6008a32a002af26b3ecbbb06d98f5a3a138c6f4c73a") {
1385
+ if ($[0] !== "8148f10395e8d4a4f6bf69c46ca41780936fccb5b43d5883c233f5bc10919674") {
1346
1386
  for (let $i = 0; $i < 3; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
1347
- $[0] = "fd73f7a8c1f8a9d942e9e6008a32a002af26b3ecbbb06d98f5a3a138c6f4c73a";
1387
+ $[0] = "8148f10395e8d4a4f6bf69c46ca41780936fccb5b43d5883c233f5bc10919674";
1348
1388
  }
1349
- const groupId = useObservabilityStore(_temp$3);
1350
- if (!groupId) return null;
1389
+ const groupId$1 = useObservabilityStore(_temp$3);
1390
+ if (!groupId$1) return null;
1351
1391
  let t0;
1352
- if ($[1] !== groupId) {
1353
- t0 = /* @__PURE__ */ jsx(TraceTimelineComponent, { groupId });
1354
- $[1] = groupId;
1392
+ if ($[1] !== groupId$1) {
1393
+ t0 = /* @__PURE__ */ jsx(TraceTimelineComponent, { groupId: groupId$1 });
1394
+ $[1] = groupId$1;
1355
1395
  $[2] = t0;
1356
1396
  } else t0 = $[2];
1357
1397
  return t0;
1358
1398
  });
1359
1399
  TraceTimeline.displayName = "TraceTimeline";
1360
1400
  const TraceTimelineComponent = memo((t0) => {
1361
- const $ = c(80);
1362
- if ($[0] !== "fd73f7a8c1f8a9d942e9e6008a32a002af26b3ecbbb06d98f5a3a138c6f4c73a") {
1363
- for (let $i = 0; $i < 80; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
1364
- $[0] = "fd73f7a8c1f8a9d942e9e6008a32a002af26b3ecbbb06d98f5a3a138c6f4c73a";
1401
+ const $ = c(83);
1402
+ if ($[0] !== "8148f10395e8d4a4f6bf69c46ca41780936fccb5b43d5883c233f5bc10919674") {
1403
+ for (let $i = 0; $i < 83; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
1404
+ $[0] = "8148f10395e8d4a4f6bf69c46ca41780936fccb5b43d5883c233f5bc10919674";
1365
1405
  }
1366
- const { groupId } = t0;
1406
+ const { groupId: groupId$1 } = t0;
1407
+ useTracesStream();
1408
+ const traceGroups = useObservabilityStore(_temp2$1);
1409
+ const traces = useObservabilityStore(_temp3);
1367
1410
  let t1;
1368
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
1369
- t1 = {
1370
- streamName: "motia-trace-group",
1371
- groupId: "default"
1372
- };
1373
- $[1] = t1;
1374
- } else t1 = $[1];
1375
- const { data: traceGroups } = useStreamGroup(t1);
1411
+ if ($[1] !== groupId$1 || $[2] !== traceGroups) {
1412
+ let t2$1;
1413
+ if ($[4] !== groupId$1) {
1414
+ t2$1 = (traceGroup) => traceGroup.id === groupId$1;
1415
+ $[4] = groupId$1;
1416
+ $[5] = t2$1;
1417
+ } else t2$1 = $[5];
1418
+ t1 = traceGroups.find(t2$1);
1419
+ $[1] = groupId$1;
1420
+ $[2] = traceGroups;
1421
+ $[3] = t1;
1422
+ } else t1 = $[3];
1423
+ const group = t1;
1424
+ const endTime = useGetEndTime(group);
1425
+ const [zoom, setZoom] = useState(100);
1426
+ const selectedTraceId = useObservabilityStore(_temp4);
1427
+ const selectTraceId = useObservabilityStore(_temp5);
1376
1428
  let t2;
1377
- if ($[2] !== groupId || $[3] !== traceGroups) {
1429
+ if ($[6] !== selectedTraceId || $[7] !== traces) {
1378
1430
  let t3$1;
1379
- if ($[5] !== groupId) {
1380
- t3$1 = (traceGroup) => traceGroup.id === groupId;
1381
- $[5] = groupId;
1382
- $[6] = t3$1;
1383
- } else t3$1 = $[6];
1384
- t2 = traceGroups.find(t3$1);
1385
- $[2] = groupId;
1386
- $[3] = traceGroups;
1387
- $[4] = t2;
1388
- } else t2 = $[4];
1389
- const group = t2;
1431
+ if ($[9] !== selectedTraceId) {
1432
+ t3$1 = (trace) => trace.id === selectedTraceId;
1433
+ $[9] = selectedTraceId;
1434
+ $[10] = t3$1;
1435
+ } else t3$1 = $[10];
1436
+ t2 = traces.find(t3$1);
1437
+ $[6] = selectedTraceId;
1438
+ $[7] = traces;
1439
+ $[8] = t2;
1440
+ } else t2 = $[8];
1441
+ const selectedTrace = t2;
1390
1442
  let t3;
1391
- if ($[7] !== groupId) {
1392
- t3 = {
1393
- streamName: "motia-trace",
1394
- groupId
1395
- };
1396
- $[7] = groupId;
1397
- $[8] = t3;
1398
- } else t3 = $[8];
1399
- const { data } = useStreamGroup(t3);
1400
- const endTime = useGetEndTime(group);
1401
- const [zoom, setZoom] = useState(100);
1402
- const selectedTraceId = useObservabilityStore(_temp2$1);
1403
- const selectTraceId = useObservabilityStore(_temp3);
1443
+ if ($[11] !== zoom) {
1444
+ t3 = () => zoom > 100 && setZoom(_temp6);
1445
+ $[11] = zoom;
1446
+ $[12] = t3;
1447
+ } else t3 = $[12];
1448
+ const zoomMinus = t3;
1404
1449
  let t4;
1405
- if ($[9] !== data || $[10] !== selectedTraceId) {
1406
- t4 = data?.find((trace) => trace.id === selectedTraceId);
1407
- $[9] = data;
1408
- $[10] = selectedTraceId;
1409
- $[11] = t4;
1410
- } else t4 = $[11];
1411
- const selectedTrace = t4;
1412
- let t5;
1413
- if ($[12] !== zoom) {
1414
- t5 = () => zoom > 100 && setZoom(_temp4);
1415
- $[12] = zoom;
1416
- $[13] = t5;
1417
- } else t5 = $[13];
1418
- const zoomMinus = t5;
1419
- let t6;
1420
- if ($[14] !== zoom) {
1421
- t6 = () => zoom < 200 && setZoom(_temp5);
1422
- $[14] = zoom;
1423
- $[15] = t6;
1424
- } else t6 = $[15];
1425
- const zoomPlus = t6;
1450
+ if ($[13] !== zoom) {
1451
+ t4 = () => zoom < 200 && setZoom(_temp7);
1452
+ $[13] = zoom;
1453
+ $[14] = t4;
1454
+ } else t4 = $[14];
1455
+ const zoomPlus = t4;
1426
1456
  if (!group) return null;
1457
+ const t5 = `${zoom}%`;
1458
+ let t6;
1459
+ if ($[15] !== t5) {
1460
+ t6 = { width: t5 };
1461
+ $[15] = t5;
1462
+ $[16] = t6;
1463
+ } else t6 = $[16];
1427
1464
  const t7 = `${zoom}%`;
1428
1465
  let t8;
1429
- if ($[16] !== t7) {
1466
+ if ($[17] !== t7) {
1430
1467
  t8 = { width: t7 };
1431
- $[16] = t7;
1432
- $[17] = t8;
1433
- } else t8 = $[17];
1434
- const t9 = `${zoom}%`;
1468
+ $[17] = t7;
1469
+ $[18] = t8;
1470
+ } else t8 = $[18];
1471
+ const t9 = zoom <= 100;
1435
1472
  let t10;
1436
- if ($[18] !== t9) {
1437
- t10 = { width: t9 };
1438
- $[18] = t9;
1473
+ if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
1474
+ t10 = /* @__PURE__ */ jsx(Minus, { className: "w-4 h-4 cursor-pointer" });
1439
1475
  $[19] = t10;
1440
1476
  } else t10 = $[19];
1441
- const t11 = zoom <= 100;
1442
- let t12;
1443
- if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
1444
- t12 = /* @__PURE__ */ jsx(Minus, { className: "w-4 h-4 cursor-pointer" });
1445
- $[20] = t12;
1446
- } else t12 = $[20];
1447
- let t13;
1448
- if ($[21] !== t11 || $[22] !== zoomMinus) {
1449
- t13 = /* @__PURE__ */ jsx(Button, {
1477
+ let t11;
1478
+ if ($[20] !== t9 || $[21] !== zoomMinus) {
1479
+ t11 = /* @__PURE__ */ jsx(Button, {
1450
1480
  variant: "icon",
1451
1481
  size: "sm",
1452
1482
  className: "px-2",
1453
1483
  onClick: zoomMinus,
1454
- disabled: t11,
1455
- children: t12
1484
+ disabled: t9,
1485
+ children: t10
1456
1486
  });
1457
- $[21] = t11;
1458
- $[22] = zoomMinus;
1459
- $[23] = t13;
1460
- } else t13 = $[23];
1461
- let t14;
1462
- if ($[24] !== zoom) {
1463
- t14 = /* @__PURE__ */ jsxs("span", {
1487
+ $[20] = t9;
1488
+ $[21] = zoomMinus;
1489
+ $[22] = t11;
1490
+ } else t11 = $[22];
1491
+ let t12;
1492
+ if ($[23] !== zoom) {
1493
+ t12 = /* @__PURE__ */ jsxs("span", {
1464
1494
  className: "min-w-12 text-center select-none text-sm font-bold text-muted-foreground",
1465
1495
  children: [zoom, "%"]
1466
1496
  });
1467
- $[24] = zoom;
1497
+ $[23] = zoom;
1498
+ $[24] = t12;
1499
+ } else t12 = $[24];
1500
+ const t13 = zoom >= 200;
1501
+ let t14;
1502
+ if ($[25] === Symbol.for("react.memo_cache_sentinel")) {
1503
+ t14 = /* @__PURE__ */ jsx(Plus, { className: "w-4 h-4 cursor-pointer" });
1468
1504
  $[25] = t14;
1469
1505
  } else t14 = $[25];
1470
- const t15 = zoom >= 200;
1471
- let t16;
1472
- if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
1473
- t16 = /* @__PURE__ */ jsx(Plus, { className: "w-4 h-4 cursor-pointer" });
1474
- $[26] = t16;
1475
- } else t16 = $[26];
1476
- let t17;
1477
- if ($[27] !== t15 || $[28] !== zoomPlus) {
1478
- t17 = /* @__PURE__ */ jsx(Button, {
1506
+ let t15;
1507
+ if ($[26] !== t13 || $[27] !== zoomPlus) {
1508
+ t15 = /* @__PURE__ */ jsx(Button, {
1479
1509
  variant: "icon",
1480
1510
  size: "sm",
1481
1511
  className: "px-2",
1482
1512
  onClick: zoomPlus,
1483
- disabled: t15,
1484
- children: t16
1513
+ disabled: t13,
1514
+ children: t14
1485
1515
  });
1486
- $[27] = t15;
1487
- $[28] = zoomPlus;
1488
- $[29] = t17;
1489
- } else t17 = $[29];
1490
- let t18;
1491
- if ($[30] !== t13 || $[31] !== t14 || $[32] !== t17) {
1492
- t18 = /* @__PURE__ */ jsxs("div", {
1516
+ $[26] = t13;
1517
+ $[27] = zoomPlus;
1518
+ $[28] = t15;
1519
+ } else t15 = $[28];
1520
+ let t16;
1521
+ if ($[29] !== t11 || $[30] !== t12 || $[31] !== t15) {
1522
+ t16 = /* @__PURE__ */ jsxs("div", {
1493
1523
  className: "shrink-0 w-[200px] h-[37px] flex items-center justify-center gap-2 sticky left-0 top-0 z-10 bg-card backdrop-blur-xs backdrop-filter",
1494
1524
  children: [
1495
- t13,
1496
- t14,
1497
- t17
1525
+ t11,
1526
+ t12,
1527
+ t15
1498
1528
  ]
1499
1529
  });
1500
- $[30] = t13;
1501
- $[31] = t14;
1502
- $[32] = t17;
1503
- $[33] = t18;
1504
- } else t18 = $[33];
1530
+ $[29] = t11;
1531
+ $[30] = t12;
1532
+ $[31] = t15;
1533
+ $[32] = t16;
1534
+ } else t16 = $[32];
1535
+ let t17;
1536
+ if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
1537
+ t17 = /* @__PURE__ */ jsx("span", { children: "0ms" });
1538
+ $[33] = t17;
1539
+ } else t17 = $[33];
1540
+ const t18 = Math.floor((endTime - group.startTime) * .25);
1505
1541
  let t19;
1506
- if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
1507
- t19 = /* @__PURE__ */ jsx("span", { children: "0ms" });
1508
- $[34] = t19;
1509
- } else t19 = $[34];
1510
- const t20 = Math.floor((endTime - group.startTime) * .25);
1511
- let t21;
1512
- if ($[35] !== t20) {
1513
- t21 = formatDuration(t20);
1514
- $[35] = t20;
1515
- $[36] = t21;
1516
- } else t21 = $[36];
1542
+ if ($[34] !== t18) {
1543
+ t19 = formatDuration(t18);
1544
+ $[34] = t18;
1545
+ $[35] = t19;
1546
+ } else t19 = $[35];
1547
+ let t20;
1548
+ if ($[36] !== t19) {
1549
+ t20 = /* @__PURE__ */ jsx("span", { children: t19 });
1550
+ $[36] = t19;
1551
+ $[37] = t20;
1552
+ } else t20 = $[37];
1553
+ const t21 = Math.floor((endTime - group.startTime) * .5);
1517
1554
  let t22;
1518
- if ($[37] !== t21) {
1519
- t22 = /* @__PURE__ */ jsx("span", { children: t21 });
1520
- $[37] = t21;
1521
- $[38] = t22;
1522
- } else t22 = $[38];
1523
- const t23 = Math.floor((endTime - group.startTime) * .5);
1524
- let t24;
1525
- if ($[39] !== t23) {
1526
- t24 = formatDuration(t23);
1527
- $[39] = t23;
1528
- $[40] = t24;
1529
- } else t24 = $[40];
1555
+ if ($[38] !== t21) {
1556
+ t22 = formatDuration(t21);
1557
+ $[38] = t21;
1558
+ $[39] = t22;
1559
+ } else t22 = $[39];
1560
+ let t23;
1561
+ if ($[40] !== t22) {
1562
+ t23 = /* @__PURE__ */ jsx("span", { children: t22 });
1563
+ $[40] = t22;
1564
+ $[41] = t23;
1565
+ } else t23 = $[41];
1566
+ const t24 = Math.floor((endTime - group.startTime) * .75);
1530
1567
  let t25;
1531
- if ($[41] !== t24) {
1532
- t25 = /* @__PURE__ */ jsx("span", { children: t24 });
1533
- $[41] = t24;
1534
- $[42] = t25;
1535
- } else t25 = $[42];
1536
- const t26 = Math.floor((endTime - group.startTime) * .75);
1537
- let t27;
1538
- if ($[43] !== t26) {
1539
- t27 = formatDuration(t26);
1540
- $[43] = t26;
1541
- $[44] = t27;
1542
- } else t27 = $[44];
1568
+ if ($[42] !== t24) {
1569
+ t25 = formatDuration(t24);
1570
+ $[42] = t24;
1571
+ $[43] = t25;
1572
+ } else t25 = $[43];
1573
+ let t26;
1574
+ if ($[44] !== t25) {
1575
+ t26 = /* @__PURE__ */ jsx("span", { children: t25 });
1576
+ $[44] = t25;
1577
+ $[45] = t26;
1578
+ } else t26 = $[45];
1579
+ const t27 = Math.floor(endTime - group.startTime);
1543
1580
  let t28;
1544
- if ($[45] !== t27) {
1545
- t28 = /* @__PURE__ */ jsx("span", { children: t27 });
1546
- $[45] = t27;
1547
- $[46] = t28;
1548
- } else t28 = $[46];
1549
- const t29 = Math.floor(endTime - group.startTime);
1581
+ if ($[46] !== t27) {
1582
+ t28 = formatDuration(t27);
1583
+ $[46] = t27;
1584
+ $[47] = t28;
1585
+ } else t28 = $[47];
1586
+ let t29;
1587
+ if ($[48] !== t28) {
1588
+ t29 = /* @__PURE__ */ jsx("span", { children: t28 });
1589
+ $[48] = t28;
1590
+ $[49] = t29;
1591
+ } else t29 = $[49];
1550
1592
  let t30;
1551
- if ($[47] !== t29) {
1552
- t30 = formatDuration(t29);
1553
- $[47] = t29;
1554
- $[48] = t30;
1555
- } else t30 = $[48];
1556
- let t31;
1557
- if ($[49] !== t30) {
1558
- t31 = /* @__PURE__ */ jsx("span", { children: t30 });
1559
- $[49] = t30;
1560
- $[50] = t31;
1561
- } else t31 = $[50];
1562
- let t32;
1563
- if ($[51] !== t22 || $[52] !== t25 || $[53] !== t28 || $[54] !== t31) {
1564
- t32 = /* @__PURE__ */ jsxs("div", {
1593
+ if ($[50] !== t20 || $[51] !== t23 || $[52] !== t26 || $[53] !== t29) {
1594
+ t30 = /* @__PURE__ */ jsxs("div", {
1565
1595
  className: "flex justify-between font-mono p-2 w-full text-xs text-muted-foreground bg-card",
1566
1596
  children: [
1567
- t19,
1568
- t22,
1569
- t25,
1570
- t28,
1571
- t31
1597
+ t17,
1598
+ t20,
1599
+ t23,
1600
+ t26,
1601
+ t29
1572
1602
  ]
1573
1603
  });
1574
- $[51] = t22;
1575
- $[52] = t25;
1576
- $[53] = t28;
1577
- $[54] = t31;
1578
- $[55] = t32;
1579
- } else t32 = $[55];
1580
- let t33;
1581
- if ($[56] !== t10 || $[57] !== t18 || $[58] !== t32) {
1582
- t33 = /* @__PURE__ */ jsxs("div", {
1604
+ $[50] = t20;
1605
+ $[51] = t23;
1606
+ $[52] = t26;
1607
+ $[53] = t29;
1608
+ $[54] = t30;
1609
+ } else t30 = $[54];
1610
+ let t31;
1611
+ if ($[55] !== t16 || $[56] !== t30 || $[57] !== t8) {
1612
+ t31 = /* @__PURE__ */ jsxs("div", {
1583
1613
  className: "flex flex-1 bg-background",
1584
- style: t10,
1585
- children: [t18, t32]
1586
- });
1587
- $[56] = t10;
1588
- $[57] = t18;
1589
- $[58] = t32;
1590
- $[59] = t33;
1591
- } else t33 = $[59];
1592
- const t34 = `${zoom}%`;
1614
+ style: t8,
1615
+ children: [t16, t30]
1616
+ });
1617
+ $[55] = t16;
1618
+ $[56] = t30;
1619
+ $[57] = t8;
1620
+ $[58] = t31;
1621
+ } else t31 = $[58];
1622
+ const t32 = `${zoom}%`;
1623
+ let t33;
1624
+ if ($[59] !== t32) {
1625
+ t33 = { width: t32 };
1626
+ $[59] = t32;
1627
+ $[60] = t33;
1628
+ } else t33 = $[60];
1629
+ let t34;
1630
+ if ($[61] !== endTime || $[62] !== group.startTime || $[63] !== selectTraceId || $[64] !== traces) {
1631
+ let t35$1;
1632
+ if ($[66] !== endTime || $[67] !== group.startTime || $[68] !== selectTraceId) {
1633
+ t35$1 = (trace_0) => /* @__PURE__ */ jsx(TraceItem, {
1634
+ traceId: trace_0.id,
1635
+ traceName: trace_0.name,
1636
+ traceStatus: trace_0.status,
1637
+ traceStartTime: trace_0.startTime,
1638
+ traceEndTime: trace_0.endTime,
1639
+ groupStartTime: group.startTime,
1640
+ groupEndTime: endTime,
1641
+ onExpand: selectTraceId
1642
+ }, trace_0.id);
1643
+ $[66] = endTime;
1644
+ $[67] = group.startTime;
1645
+ $[68] = selectTraceId;
1646
+ $[69] = t35$1;
1647
+ } else t35$1 = $[69];
1648
+ t34 = traces.map(t35$1);
1649
+ $[61] = endTime;
1650
+ $[62] = group.startTime;
1651
+ $[63] = selectTraceId;
1652
+ $[64] = traces;
1653
+ $[65] = t34;
1654
+ } else t34 = $[65];
1593
1655
  let t35;
1594
- if ($[60] !== t34) {
1595
- t35 = { width: t34 };
1596
- $[60] = t34;
1597
- $[61] = t35;
1598
- } else t35 = $[61];
1599
- let t36;
1600
- if ($[62] !== data || $[63] !== endTime || $[64] !== group.startTime || $[65] !== selectTraceId) {
1601
- t36 = data?.map((trace_0) => /* @__PURE__ */ jsx(TraceItem, {
1602
- traceId: trace_0.id,
1603
- traceName: trace_0.name,
1604
- traceStatus: trace_0.status,
1605
- traceStartTime: trace_0.startTime,
1606
- traceEndTime: trace_0.endTime,
1607
- groupStartTime: group.startTime,
1608
- groupEndTime: endTime,
1609
- onExpand: selectTraceId
1610
- }, trace_0.id));
1611
- $[62] = data;
1612
- $[63] = endTime;
1613
- $[64] = group.startTime;
1614
- $[65] = selectTraceId;
1615
- $[66] = t36;
1616
- } else t36 = $[66];
1617
- let t37;
1618
- if ($[67] !== t35 || $[68] !== t36) {
1619
- t37 = /* @__PURE__ */ jsx("div", {
1656
+ if ($[70] !== t33 || $[71] !== t34) {
1657
+ t35 = /* @__PURE__ */ jsx("div", {
1620
1658
  className: "flex flex-col h-full",
1621
- style: t35,
1622
- children: t36
1659
+ style: t33,
1660
+ children: t34
1623
1661
  });
1624
- $[67] = t35;
1625
- $[68] = t36;
1626
- $[69] = t37;
1627
- } else t37 = $[69];
1628
- let t38;
1629
- if ($[70] !== t33 || $[71] !== t37 || $[72] !== t8) {
1630
- t38 = /* @__PURE__ */ jsx("div", {
1662
+ $[70] = t33;
1663
+ $[71] = t34;
1664
+ $[72] = t35;
1665
+ } else t35 = $[72];
1666
+ let t36;
1667
+ if ($[73] !== t31 || $[74] !== t35 || $[75] !== t6) {
1668
+ t36 = /* @__PURE__ */ jsx("div", {
1631
1669
  className: "flex flex-col flex-1 relative min-h-full min-w-[1000px]",
1632
1670
  children: /* @__PURE__ */ jsxs("div", {
1633
1671
  className: "flex flex-col",
1634
- style: t8,
1635
- children: [t33, t37]
1672
+ style: t6,
1673
+ children: [t31, t35]
1636
1674
  })
1637
1675
  });
1638
- $[70] = t33;
1639
- $[71] = t37;
1640
- $[72] = t8;
1641
- $[73] = t38;
1642
- } else t38 = $[73];
1643
- let t39;
1644
- if ($[74] !== selectTraceId || $[75] !== selectedTrace) {
1645
- t39 = selectedTrace && /* @__PURE__ */ jsx(TraceItemDetail, {
1676
+ $[73] = t31;
1677
+ $[74] = t35;
1678
+ $[75] = t6;
1679
+ $[76] = t36;
1680
+ } else t36 = $[76];
1681
+ let t37;
1682
+ if ($[77] !== selectTraceId || $[78] !== selectedTrace) {
1683
+ t37 = selectedTrace && /* @__PURE__ */ jsx(TraceItemDetail, {
1646
1684
  trace: selectedTrace,
1647
1685
  onClose: () => selectTraceId(void 0)
1648
1686
  });
1649
- $[74] = selectTraceId;
1650
- $[75] = selectedTrace;
1651
- $[76] = t39;
1652
- } else t39 = $[76];
1653
- let t40;
1654
- if ($[77] !== t38 || $[78] !== t39) {
1655
- t40 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t38, t39] });
1656
- $[77] = t38;
1657
- $[78] = t39;
1658
- $[79] = t40;
1659
- } else t40 = $[79];
1660
- return t40;
1687
+ $[77] = selectTraceId;
1688
+ $[78] = selectedTrace;
1689
+ $[79] = t37;
1690
+ } else t37 = $[79];
1691
+ let t38;
1692
+ if ($[80] !== t36 || $[81] !== t37) {
1693
+ t38 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t36, t37] });
1694
+ $[80] = t36;
1695
+ $[81] = t37;
1696
+ $[82] = t38;
1697
+ } else t38 = $[82];
1698
+ return t38;
1661
1699
  });
1662
1700
  TraceTimelineComponent.displayName = "TraceTimelineComponent";
1663
1701
  function _temp$3(state) {
1664
1702
  return state.selectedTraceGroupId;
1665
1703
  }
1666
1704
  function _temp2$1(state) {
1667
- return state.selectedTraceId;
1705
+ return state.traceGroups;
1668
1706
  }
1669
1707
  function _temp3(state_0) {
1670
- return state_0.selectTraceId;
1708
+ return state_0.traces;
1709
+ }
1710
+ function _temp4(state_1) {
1711
+ return state_1.selectedTraceId;
1671
1712
  }
1672
- function _temp4(prevZoom) {
1713
+ function _temp5(state_2) {
1714
+ return state_2.selectTraceId;
1715
+ }
1716
+ function _temp6(prevZoom) {
1673
1717
  return prevZoom - 10;
1674
1718
  }
1675
- function _temp5(prevZoom_0) {
1719
+ function _temp7(prevZoom_0) {
1676
1720
  return prevZoom_0 + 10;
1677
1721
  }
1678
1722
 
1679
1723
  //#endregion
1680
1724
  //#region src/hooks/use-filtered-trace-groups.ts
1681
1725
  const useFilteredTraceGroups = () => {
1682
- const $ = c(5);
1683
- if ($[0] !== "a29b076706acde25ffc4d4424df8f47d5e87949facd0d256c49dc7eec7d042a7") {
1684
- for (let $i = 0; $i < 5; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
1685
- $[0] = "a29b076706acde25ffc4d4424df8f47d5e87949facd0d256c49dc7eec7d042a7";
1726
+ const $ = c(6);
1727
+ if ($[0] !== "bb7b5a50ebd354ac1177c12afa033e3545018c14fe033f5ea4551df3bbda5965") {
1728
+ for (let $i = 0; $i < 6; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
1729
+ $[0] = "bb7b5a50ebd354ac1177c12afa033e3545018c14fe033f5ea4551df3bbda5965";
1686
1730
  }
1731
+ const traceGroups = useObservabilityStore(_temp$2);
1732
+ const search = useObservabilityStore(_temp2);
1687
1733
  let t0;
1688
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
1734
+ if ($[1] !== search || $[2] !== traceGroups) {
1735
+ let t1;
1736
+ if ($[4] !== search) {
1737
+ t1 = (group) => group.name.toLowerCase().includes(search.toLowerCase()) || group.id.toLowerCase().includes(search.toLowerCase());
1738
+ $[4] = search;
1739
+ $[5] = t1;
1740
+ } else t1 = $[5];
1741
+ t0 = traceGroups.filter(t1);
1742
+ $[1] = search;
1743
+ $[2] = traceGroups;
1744
+ $[3] = t0;
1745
+ } else t0 = $[3];
1746
+ return t0;
1747
+ };
1748
+ function _temp$2(state) {
1749
+ return state.traceGroups;
1750
+ }
1751
+ function _temp2(state_0) {
1752
+ return state_0.search;
1753
+ }
1754
+
1755
+ //#endregion
1756
+ //#region src/hooks/use-trace-groups-stream.ts
1757
+ const streamName = "motia-trace-group";
1758
+ const groupId = "default";
1759
+ const useTraceGroupsStream = () => {
1760
+ const $ = c(3);
1761
+ if ($[0] !== "29d24a963c5c777c79f8ec82ca3d5f2b5d6812171a1a0298772d1c34c99549aa") {
1762
+ for (let $i = 0; $i < 3; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
1763
+ $[0] = "29d24a963c5c777c79f8ec82ca3d5f2b5d6812171a1a0298772d1c34c99549aa";
1764
+ }
1765
+ const setData = useObservabilityStore(_temp$1);
1766
+ let t0;
1767
+ if ($[1] !== setData) {
1689
1768
  t0 = {
1690
- streamName: "motia-trace-group",
1691
- groupId: "default"
1769
+ streamName,
1770
+ groupId,
1771
+ setData
1692
1772
  };
1693
- $[1] = t0;
1694
- } else t0 = $[1];
1695
- const { data } = useStreamGroup(t0);
1696
- const search = useObservabilityStore(_temp$2);
1697
- let t1;
1698
- if ($[2] !== data || $[3] !== search) {
1699
- t1 = data?.filter((group) => group.name.toLowerCase().includes(search.toLowerCase()) || group.id.toLowerCase().includes(search.toLowerCase()));
1700
- $[2] = data;
1701
- $[3] = search;
1702
- $[4] = t1;
1703
- } else t1 = $[4];
1704
- return t1;
1773
+ $[1] = setData;
1774
+ $[2] = t0;
1775
+ } else t0 = $[2];
1776
+ useStreamGroup(t0);
1705
1777
  };
1706
- function _temp$2(state) {
1707
- return state.search;
1778
+ function _temp$1(state) {
1779
+ return state.setTraceGroups;
1708
1780
  }
1709
1781
 
1710
1782
  //#endregion
@@ -1741,13 +1813,13 @@ TraceStatusBadge.displayName = "TraceStatusBadge";
1741
1813
  //#endregion
1742
1814
  //#region src/components/trace-group-item.tsx
1743
1815
  const TraceGroupItem = memo((t0) => {
1744
- const $ = c(43);
1745
- if ($[0] !== "bae7176c6d363abcd5ae856478cbdd22c5d53c5296c21141ccf8591a2ba47e9b") {
1746
- for (let $i = 0; $i < 43; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
1747
- $[0] = "bae7176c6d363abcd5ae856478cbdd22c5d53c5296c21141ccf8591a2ba47e9b";
1816
+ const $ = c(44);
1817
+ if ($[0] !== "ade6a55bfd668f5f8283f490ae1f964ba2b70d3e3adecd61f24c5ddb8d2b211f") {
1818
+ for (let $i = 0; $i < 44; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
1819
+ $[0] = "ade6a55bfd668f5f8283f490ae1f964ba2b70d3e3adecd61f24c5ddb8d2b211f";
1748
1820
  }
1749
- const { groupId, groupName, groupStatus, groupStartTime, groupEndTime, totalSteps, activeSteps, isSelected } = t0;
1750
- const selectTraceGroupId = useObservabilityStore(_temp$1);
1821
+ const { groupId: groupId$1, groupName, groupStatus, groupStartTime, groupEndTime, totalSteps, activeSteps, isSelected, style } = t0;
1822
+ const selectTraceGroupId = useObservabilityStore(_temp);
1751
1823
  let t1;
1752
1824
  if ($[1] !== groupEndTime || $[2] !== groupStartTime) {
1753
1825
  t1 = groupEndTime ? formatDuration(groupEndTime - groupStartTime) : void 0;
@@ -1757,16 +1829,16 @@ const TraceGroupItem = memo((t0) => {
1757
1829
  } else t1 = $[3];
1758
1830
  const duration = t1;
1759
1831
  let t2;
1760
- if ($[4] !== groupId || $[5] !== selectTraceGroupId) {
1832
+ if ($[4] !== groupId$1 || $[5] !== selectTraceGroupId) {
1761
1833
  t2 = () => {
1762
- selectTraceGroupId(groupId);
1834
+ selectTraceGroupId(groupId$1);
1763
1835
  };
1764
- $[4] = groupId;
1836
+ $[4] = groupId$1;
1765
1837
  $[5] = selectTraceGroupId;
1766
1838
  $[6] = t2;
1767
1839
  } else t2 = $[6];
1768
1840
  const onSelect = t2;
1769
- const t3 = `trace-${groupId}`;
1841
+ const t3 = `trace-${groupId$1}`;
1770
1842
  const t4 = isSelected ? "bg-muted-foreground/10" : "hover:bg-muted/70";
1771
1843
  let t5;
1772
1844
  if ($[7] !== t4) {
@@ -1804,13 +1876,13 @@ const TraceGroupItem = memo((t0) => {
1804
1876
  $[16] = t8;
1805
1877
  } else t8 = $[16];
1806
1878
  let t9;
1807
- if ($[17] !== groupId) {
1879
+ if ($[17] !== groupId$1) {
1808
1880
  t9 = /* @__PURE__ */ jsx("div", {
1809
1881
  "data-testid": "trace-id",
1810
1882
  className: "text-xs text-muted-foreground font-mono tracking-[1px]",
1811
- children: groupId
1883
+ children: groupId$1
1812
1884
  });
1813
- $[17] = groupId;
1885
+ $[17] = groupId$1;
1814
1886
  $[18] = t9;
1815
1887
  } else t9 = $[18];
1816
1888
  let t10;
@@ -1879,118 +1951,95 @@ const TraceGroupItem = memo((t0) => {
1879
1951
  $[36] = t16;
1880
1952
  } else t16 = $[36];
1881
1953
  let t17;
1882
- if ($[37] !== groupId || $[38] !== onSelect || $[39] !== t16 || $[40] !== t3 || $[41] !== t5) {
1954
+ if ($[37] !== groupId$1 || $[38] !== onSelect || $[39] !== style || $[40] !== t16 || $[41] !== t3 || $[42] !== t5) {
1883
1955
  t17 = /* @__PURE__ */ jsx("button", {
1884
1956
  type: "button",
1885
1957
  "data-testid": t3,
1886
1958
  className: t5,
1959
+ style,
1887
1960
  onClick: onSelect,
1888
1961
  children: t16
1889
- }, groupId);
1890
- $[37] = groupId;
1962
+ }, groupId$1);
1963
+ $[37] = groupId$1;
1891
1964
  $[38] = onSelect;
1892
- $[39] = t16;
1893
- $[40] = t3;
1894
- $[41] = t5;
1895
- $[42] = t17;
1896
- } else t17 = $[42];
1965
+ $[39] = style;
1966
+ $[40] = t16;
1967
+ $[41] = t3;
1968
+ $[42] = t5;
1969
+ $[43] = t17;
1970
+ } else t17 = $[43];
1897
1971
  return t17;
1898
1972
  });
1899
1973
  TraceGroupItem.displayName = "TraceGroupItem";
1900
- function _temp$1(state) {
1974
+ function _temp(state) {
1901
1975
  return state.selectTraceGroupId;
1902
1976
  }
1903
1977
 
1904
1978
  //#endregion
1905
1979
  //#region src/components/traces-groups.tsx
1980
+ const ROW_HEIGHT = 110;
1906
1981
  const TracesGroups = memo(() => {
1907
- const $ = c(18);
1908
- if ($[0] !== "2bddedc9dbf436ff7f1225c5b31bfd84c69748b5b6b8e426fabda2b9e624500a") {
1909
- for (let $i = 0; $i < 18; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
1910
- $[0] = "2bddedc9dbf436ff7f1225c5b31bfd84c69748b5b6b8e426fabda2b9e624500a";
1911
- }
1982
+ useTraceGroupsStream();
1912
1983
  const groups = useFilteredTraceGroups();
1913
- const selectedGroupId = useObservabilityStore(_temp);
1914
- const selectTraceGroupId = useObservabilityStore(_temp2);
1915
- const groupsLength = groups?.length || 0;
1916
- let t0;
1917
- bb0: {
1918
- if (!groups || groups.length === 0) {
1919
- t0 = "";
1920
- break bb0;
1921
- }
1984
+ const selectedGroupId = useObservabilityStore((state) => state.selectedTraceGroupId);
1985
+ const selectTraceGroupId = useObservabilityStore((state_0) => state_0.selectTraceGroupId);
1986
+ const scrollContainerRef = useRef(null);
1987
+ const groupsLength = useMemo(() => groups?.length || 0, [groups]);
1988
+ const lastRunningGroupId = useMemo(() => {
1989
+ if (!groups || groups.length === 0) return "";
1922
1990
  const lastGroup = groups[groups.length - 1];
1923
- t0 = lastGroup?.status === "running" ? lastGroup.id : "";
1924
- }
1925
- const lastRunningGroupId = t0;
1926
- let t1;
1927
- if ($[1] !== groupsLength || $[2] !== lastRunningGroupId || $[3] !== selectTraceGroupId || $[4] !== selectedGroupId) {
1928
- t1 = () => {
1929
- if (lastRunningGroupId && lastRunningGroupId !== selectedGroupId) selectTraceGroupId(lastRunningGroupId);
1930
- else if (!lastRunningGroupId && !groupsLength && selectedGroupId) selectTraceGroupId("");
1931
- };
1932
- $[1] = groupsLength;
1933
- $[2] = lastRunningGroupId;
1934
- $[3] = selectTraceGroupId;
1935
- $[4] = selectedGroupId;
1936
- $[5] = t1;
1937
- } else t1 = $[5];
1938
- let t2;
1939
- if ($[6] !== groupsLength || $[7] !== lastRunningGroupId) {
1940
- t2 = [lastRunningGroupId, groupsLength];
1941
- $[6] = groupsLength;
1942
- $[7] = lastRunningGroupId;
1943
- $[8] = t2;
1944
- } else t2 = $[8];
1945
- useEffect(t1, t2);
1946
- let t3;
1947
- if ($[9] !== groups) {
1948
- t3 = [...groups].reverse();
1949
- $[9] = groups;
1950
- $[10] = t3;
1951
- } else t3 = $[10];
1952
- const reversedGroups = t3;
1991
+ return lastGroup?.status === "running" ? lastGroup.id : "";
1992
+ }, [groups]);
1993
+ useEffect(() => {
1994
+ if (lastRunningGroupId && lastRunningGroupId !== selectedGroupId) selectTraceGroupId(lastRunningGroupId);
1995
+ else if (!lastRunningGroupId && !groupsLength && selectedGroupId) selectTraceGroupId("");
1996
+ }, [
1997
+ lastRunningGroupId,
1998
+ groupsLength,
1999
+ selectedGroupId,
2000
+ selectTraceGroupId
2001
+ ]);
2002
+ const reversedGroups = useMemo(() => groups ? [...groups].reverse() : [], [groups]);
2003
+ const virtualizer = useVirtualizer({
2004
+ count: reversedGroups.length,
2005
+ getScrollElement: () => scrollContainerRef.current,
2006
+ estimateSize: () => ROW_HEIGHT,
2007
+ overscan: 5
2008
+ });
2009
+ const virtualItems = virtualizer.getVirtualItems();
1953
2010
  if (!groups || groups.length === 0) return null;
1954
- let t4;
1955
- if ($[11] !== reversedGroups || $[12] !== selectedGroupId) {
1956
- let t5$1;
1957
- if ($[14] !== selectedGroupId) {
1958
- t5$1 = (group) => /* @__PURE__ */ jsx(TraceGroupItem, {
1959
- groupId: group.id,
1960
- groupName: group.name,
1961
- groupStatus: group.status,
1962
- groupStartTime: group.startTime,
1963
- groupEndTime: group.endTime,
1964
- totalSteps: group.metadata.totalSteps,
1965
- activeSteps: group.metadata.activeSteps,
1966
- isSelected: selectedGroupId === group.id
1967
- }, group.id);
1968
- $[14] = selectedGroupId;
1969
- $[15] = t5$1;
1970
- } else t5$1 = $[15];
1971
- t4 = reversedGroups.map(t5$1);
1972
- $[11] = reversedGroups;
1973
- $[12] = selectedGroupId;
1974
- $[13] = t4;
1975
- } else t4 = $[13];
1976
- let t5;
1977
- if ($[16] !== t4) {
1978
- t5 = /* @__PURE__ */ jsx("div", {
1979
- className: "overflow-auto",
1980
- children: t4
1981
- });
1982
- $[16] = t4;
1983
- $[17] = t5;
1984
- } else t5 = $[17];
1985
- return t5;
2011
+ return /* @__PURE__ */ jsx("div", {
2012
+ ref: scrollContainerRef,
2013
+ className: "overflow-auto h-full",
2014
+ children: /* @__PURE__ */ jsx("div", {
2015
+ className: "relative w-full",
2016
+ style: { height: virtualizer.getTotalSize() },
2017
+ children: virtualItems.map((virtualRow) => {
2018
+ const group = reversedGroups[virtualRow.index];
2019
+ if (!group) return null;
2020
+ return /* @__PURE__ */ jsx(TraceGroupItem, {
2021
+ groupId: group.id,
2022
+ groupName: group.name,
2023
+ groupStatus: group.status,
2024
+ groupStartTime: group.startTime,
2025
+ groupEndTime: group.endTime,
2026
+ totalSteps: group.metadata.totalSteps,
2027
+ activeSteps: group.metadata.activeSteps,
2028
+ isSelected: selectedGroupId === group.id,
2029
+ style: {
2030
+ position: "absolute",
2031
+ top: 0,
2032
+ left: 0,
2033
+ width: "100%",
2034
+ height: ROW_HEIGHT,
2035
+ transform: `translateY(${virtualRow.start}px)`
2036
+ }
2037
+ }, group.id);
2038
+ })
2039
+ })
2040
+ });
1986
2041
  });
1987
2042
  TracesGroups.displayName = "TracesGroups";
1988
- function _temp(state) {
1989
- return state.selectedTraceGroupId;
1990
- }
1991
- function _temp2(state_0) {
1992
- return state_0.selectTraceGroupId;
1993
- }
1994
2043
 
1995
2044
  //#endregion
1996
2045
  //#region src/components/observability-page.tsx