@localstack/appinspector-ui 1.0.40 → 1.0.41

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,6 +1,6 @@
1
1
  // src/pages/spans-list-page.tsx
2
2
  import { Box as Box18 } from "@mui/material";
3
- import { useCallback as useCallback5, useEffect as useEffect6, useMemo as useMemo6, useRef as useRef3, useState as useState9 } from "react";
3
+ import { useCallback as useCallback5, useEffect as useEffect6, useMemo as useMemo6, useRef as useRef4, useState as useState9 } from "react";
4
4
 
5
5
  // src/api/use-api.tsx
6
6
  import { createContext, useContext } from "react";
@@ -3208,7 +3208,7 @@ import { ArrowBack } from "@mui/icons-material";
3208
3208
  import { Box as Box17, Button as Button5, Drawer, Paper as Paper2 } from "@mui/material";
3209
3209
  import { styled } from "@mui/material/styles";
3210
3210
  import { ReactFlowProvider } from "@xyflow/react";
3211
- import { useCallback as useCallback4, useEffect as useEffect5, useState as useState8 } from "react";
3211
+ import { useCallback as useCallback4, useEffect as useEffect5, useRef as useRef3, useState as useState8 } from "react";
3212
3212
 
3213
3213
  // src/components/event-details/event-details.tsx
3214
3214
  import { Box as Box13, Chip as Chip3, Divider as Divider2, Stack, Typography as Typography9 } from "@mui/material";
@@ -4034,7 +4034,7 @@ function renderKeyValue(key, value) {
4034
4034
  // src/components/trace-graph/trace-graph.tsx
4035
4035
  import "@xyflow/react/dist/base.css";
4036
4036
  import { Alert as Alert3, Button as Button4, useTheme as useTheme2 } from "@mui/material";
4037
- import { Background, ReactFlow, useNodesState, useReactFlow as useReactFlow2 } from "@xyflow/react";
4037
+ import { Background, ReactFlow, useNodesState } from "@xyflow/react";
4038
4038
  import { useEffect as useEffect4, useState as useState7 } from "react";
4039
4039
 
4040
4040
  // src/components/trace-graph/service-node.tsx
@@ -4383,13 +4383,10 @@ var TraceGraph = ({
4383
4383
  initialFocusEventId,
4384
4384
  onEventSelect,
4385
4385
  onRefresh,
4386
- spans,
4387
- viewPortPixelWidth
4386
+ spans
4388
4387
  }) => {
4389
4388
  const [nodes, setNodes, onNodesChange] = useNodesState([]);
4390
4389
  const [edges, setEdges] = useState7([]);
4391
- const [initialViewSet, setInitialViewSet] = useState7(false);
4392
- const { fitView, setCenter } = useReactFlow2();
4393
4390
  useEffect4(() => {
4394
4391
  const spansMap = /* @__PURE__ */ new Map();
4395
4392
  const rootSpans = [];
@@ -4425,21 +4422,6 @@ var TraceGraph = ({
4425
4422
  setNodes(layoutedNodes);
4426
4423
  setEdges(layoutedEdges);
4427
4424
  }, [spans.data, initialFocusEventId, setNodes]);
4428
- useEffect4(() => {
4429
- const shouldSetInitialView = !spans.loading && nodes.length > 0 && !initialViewSet;
4430
- if (shouldSetInitialView) {
4431
- if (initialFocusEventId) {
4432
- const focusNode = nodes.find((node) => node.id === initialFocusEventId);
4433
- if (focusNode) {
4434
- void fitView({ maxZoom: 0.8, nodes: [focusNode], padding: 0.2 });
4435
- onEventSelect(focusNode.data.event);
4436
- }
4437
- } else {
4438
- void fitView({ duration: 500 });
4439
- }
4440
- setInitialViewSet(true);
4441
- }
4442
- }, [spans.loading, nodes, initialFocusEventId, viewPortPixelWidth, setCenter, fitView, onEventSelect, initialViewSet]);
4443
4425
  const theme = useTheme2();
4444
4426
  return /* @__PURE__ */ jsxs132(Fragment6, { children: [
4445
4427
  spans.error && /* @__PURE__ */ jsxs132(
@@ -4460,16 +4442,16 @@ var TraceGraph = ({
4460
4442
  ReactFlow,
4461
4443
  {
4462
4444
  "data-testid": "trace-graph",
4463
- defaultViewport: { x: 0, y: 0, zoom: 1 },
4464
4445
  edges,
4465
4446
  fitView: true,
4447
+ fitViewOptions: initialFocusEventId ? { maxZoom: 1, nodes: [{ id: initialFocusEventId }], padding: 0.2 } : void 0,
4466
4448
  maxZoom: 1.5,
4467
4449
  minZoom: 0.1,
4468
4450
  nodes,
4469
4451
  nodesDraggable: false,
4470
4452
  nodeTypes,
4471
4453
  onNodeClick: (_event, node) => {
4472
- onEventSelect(node.data.event);
4454
+ onEventSelect(node.data.event.span_id);
4473
4455
  },
4474
4456
  onNodesChange,
4475
4457
  selectNodesOnDrag: false,
@@ -4534,8 +4516,7 @@ var TraceGraphView = ({
4534
4516
  spans,
4535
4517
  status,
4536
4518
  statusError,
4537
- traceId,
4538
- viewPortPixelWidth
4519
+ traceId
4539
4520
  }) => {
4540
4521
  const shouldShowStatusMessage = Boolean(statusError) || status?.status === "DISABLED";
4541
4522
  return /* @__PURE__ */ jsxs133(
@@ -4594,8 +4575,7 @@ var TraceGraphView = ({
4594
4575
  data: spans,
4595
4576
  error: fetchError,
4596
4577
  loading
4597
- },
4598
- viewPortPixelWidth
4578
+ }
4599
4579
  }
4600
4580
  ) })
4601
4581
  }
@@ -4634,35 +4614,20 @@ var TraceGraphPage = ({ onClose, spanId, traceId }) => {
4634
4614
  void fetchSpans();
4635
4615
  }, [fetchSpans]);
4636
4616
  const [open, setOpen] = useState8(true);
4637
- const [selectedEvent, setSelectedEvent] = useState8();
4638
- const [viewPortPixelWidth, setViewPortPixelWidth] = useState8(0);
4639
- const { checkStatus, error: statusError, status } = useStatus();
4640
- const calculateDrawerWidth = useCallback4(() => {
4641
- const percentageMatch = /(\d+)%/.exec(DRAWER_WIDTH);
4642
- if (percentageMatch && open) {
4643
- const percentage = Number.parseInt(percentageMatch[1], 10);
4644
- return window.innerWidth * percentage / 100;
4645
- }
4646
- return 0;
4647
- }, [open]);
4617
+ const [selectedEvent, setSelectedEvent] = useState8(() => spans?.find((span) => span.span_id === spanId));
4618
+ const spansReference = useRef3();
4648
4619
  useEffect5(() => {
4649
- const updateViewportWidth = () => {
4650
- const totalWidth = window.innerWidth;
4651
- const drawerPixelWidth = open ? calculateDrawerWidth() : 0;
4652
- setViewPortPixelWidth(totalWidth - drawerPixelWidth);
4653
- };
4654
- updateViewportWidth();
4655
- const timeoutId = setTimeout(updateViewportWidth, 50);
4656
- window.addEventListener("resize", updateViewportWidth);
4657
- return () => {
4658
- window.removeEventListener("resize", updateViewportWidth);
4659
- clearTimeout(timeoutId);
4660
- };
4661
- }, [open, calculateDrawerWidth]);
4662
- const handleEventSelect = useCallback4((event) => {
4663
- setSelectedEvent(event);
4620
+ if (!spansReference.current && spans) {
4621
+ setSelectedEvent(spans.find((span) => span.span_id === spanId));
4622
+ spansReference.current = spans;
4623
+ }
4624
+ }, [spans, setSelectedEvent, spanId]);
4625
+ const { checkStatus, error: statusError, status } = useStatus();
4626
+ const handleEventSelect = useCallback4((spanId2) => {
4627
+ const span = spans?.find((s) => s.span_id === spanId2);
4628
+ setSelectedEvent(span);
4664
4629
  setOpen(true);
4665
- }, []);
4630
+ }, [spans]);
4666
4631
  const handleRetry = useCallback4(() => {
4667
4632
  void checkStatus();
4668
4633
  }, [checkStatus]);
@@ -4687,8 +4652,7 @@ var TraceGraphPage = ({ onClose, spanId, traceId }) => {
4687
4652
  spans,
4688
4653
  status,
4689
4654
  statusError,
4690
- traceId,
4691
- viewPortPixelWidth
4655
+ traceId
4692
4656
  }
4693
4657
  );
4694
4658
  };
@@ -4700,9 +4664,9 @@ var SpansListPage = () => {
4700
4664
  const api = useAppInspectorApi();
4701
4665
  const [spans, setSpans] = useState9();
4702
4666
  const [loading, setLoading] = useState9(false);
4703
- const hasFetched = useRef3(false);
4667
+ const hasFetched = useRef4(false);
4704
4668
  const [includeReadOperations, setIncludeReadOperations] = useLocalStorage("includeReadOperations", false);
4705
- const mapPageToNextCursor = useRef3({});
4669
+ const mapPageToNextCursor = useRef4({});
4706
4670
  const [page, setPage] = useState9(0);
4707
4671
  const [pageSize, setPageSize] = useState9(100);
4708
4672
  const [spanCount, setSpanCount] = useState9(0);