@workflow/web-shared 5.1.0 → 5.2.0
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/README.md +8 -0
- package/dist/components/error-boundary.js +1 -1
- package/dist/components/event-list/event-details-panel.d.ts +25 -0
- package/dist/components/event-list/event-details-panel.d.ts.map +1 -0
- package/dist/components/event-list/event-details-panel.js +157 -0
- package/dist/components/event-list/event-list-toolbar.d.ts +6 -0
- package/dist/components/event-list/event-list-toolbar.d.ts.map +1 -0
- package/dist/components/event-list/event-list-toolbar.js +15 -0
- package/dist/components/event-list/event-row.d.ts +29 -0
- package/dist/components/event-list/event-row.d.ts.map +1 -0
- package/dist/components/event-list/event-row.js +102 -0
- package/dist/components/event-list/use-event-search.d.ts +14 -0
- package/dist/components/event-list/use-event-search.d.ts.map +1 -0
- package/dist/components/event-list/use-event-search.js +74 -0
- package/dist/components/event-list-view.d.ts +9 -66
- package/dist/components/event-list-view.d.ts.map +1 -1
- package/dist/components/event-list-view.js +112 -984
- package/dist/components/hook-actions.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/sidebar/attribute-panel.js +1 -1
- package/dist/components/sidebar/attributes-block.js +1 -1
- package/dist/components/sidebar/conversation-view.js +1 -1
- package/dist/components/sidebar/copyable-data-block.js +1 -1
- package/dist/components/sidebar/entity-detail-panel.js +1 -1
- package/dist/components/sidebar/events-list.js +1 -1
- package/dist/components/sidebar/resolve-hook-modal.js +1 -1
- package/dist/components/sidebar/sidebar-data-context.js +1 -1
- package/dist/components/sidebar/span-detail-merge.js +1 -1
- package/dist/components/sidebar/use-selected-span-detail.js +1 -1
- package/dist/components/stream-image-preview.d.ts +4 -0
- package/dist/components/stream-image-preview.d.ts.map +1 -0
- package/dist/components/stream-image-preview.js +21 -0
- package/dist/components/stream-viewer-skeleton.js +1 -1
- package/dist/components/stream-viewer.d.ts.map +1 -1
- package/dist/components/stream-viewer.js +7 -2
- package/dist/components/trace-viewer/components/copy-button.js +1 -1
- package/dist/components/trace-viewer/components/detail-panel-shell.d.ts +23 -0
- package/dist/components/trace-viewer/components/detail-panel-shell.d.ts.map +1 -0
- package/dist/components/trace-viewer/components/detail-panel-shell.js +49 -0
- package/dist/components/trace-viewer/components/detail-panel-width.js +1 -1
- package/dist/components/trace-viewer/components/detail-panel.d.ts +4 -4
- package/dist/components/trace-viewer/components/detail-panel.d.ts.map +1 -1
- package/dist/components/trace-viewer/components/detail-panel.js +11 -51
- package/dist/components/trace-viewer/components/draggable-border.js +1 -1
- package/dist/components/trace-viewer/components/event-list.d.ts +9 -0
- package/dist/components/trace-viewer/components/event-list.d.ts.map +1 -1
- package/dist/components/trace-viewer/components/event-list.js +10 -3
- package/dist/components/trace-viewer/components/middle-truncate/copy-selection.js +1 -1
- package/dist/components/trace-viewer/components/middle-truncate/measurement-batch.js +1 -1
- package/dist/components/trace-viewer/components/middle-truncate/middle-truncate.js +1 -1
- package/dist/components/trace-viewer/components/middle-truncate/truncate.js +1 -1
- package/dist/components/trace-viewer/components/middle-truncate/use-middle-truncate.js +1 -1
- package/dist/components/trace-viewer/components/minimap.js +1 -1
- package/dist/components/trace-viewer/components/pane-constants.js +1 -1
- package/dist/components/trace-viewer/components/span-markers.js +1 -1
- package/dist/components/trace-viewer/components/split-pane.js +1 -1
- package/dist/components/trace-viewer/components/timeline.js +1 -1
- package/dist/components/trace-viewer/components/trace-shortcut-helper.js +1 -1
- package/dist/components/trace-viewer/components/trace-viewer-skeleton.js +1 -1
- package/dist/components/trace-viewer/components/use-alt-held.d.ts +1 -0
- package/dist/components/trace-viewer/components/use-alt-held.d.ts.map +1 -1
- package/dist/components/trace-viewer/components/use-alt-held.js +2 -2
- package/dist/components/trace-viewer/components/use-detail-panel-width.d.ts +19 -0
- package/dist/components/trace-viewer/components/use-detail-panel-width.d.ts.map +1 -0
- package/dist/components/trace-viewer/components/use-detail-panel-width.js +26 -0
- package/dist/components/trace-viewer/components/use-element-width.js +1 -1
- package/dist/components/trace-viewer/components/use-row-window.js +1 -1
- package/dist/components/trace-viewer/context.d.ts +2 -1
- package/dist/components/trace-viewer/context.d.ts.map +1 -1
- package/dist/components/trace-viewer/context.js +3 -3
- package/dist/components/trace-viewer/icons.js +1 -1
- package/dist/components/trace-viewer/search.js +1 -1
- package/dist/components/trace-viewer/trace-viewer.d.ts +2 -1
- package/dist/components/trace-viewer/trace-viewer.d.ts.map +1 -1
- package/dist/components/trace-viewer/trace-viewer.js +9 -13
- package/dist/components/trace-viewer/types.js +1 -1
- package/dist/components/trace-viewer/util/timing.js +1 -1
- package/dist/components/trace-viewer/utils.js +1 -1
- package/dist/components/trace-viewer.d.ts +2 -1
- package/dist/components/trace-viewer.d.ts.map +1 -1
- package/dist/components/trace-viewer.js +3 -3
- package/dist/components/ui/alert.js +1 -1
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/card.js +1 -1
- package/dist/components/ui/collapsible.d.ts +3 -1
- package/dist/components/ui/collapsible.d.ts.map +1 -1
- package/dist/components/ui/collapsible.js +3 -3
- package/dist/components/ui/context-card.js +1 -1
- package/dist/components/ui/data-inspector.js +1 -1
- package/dist/components/ui/data-inspector.styles.js +1 -1
- package/dist/components/ui/decrypt-button.js +2 -2
- package/dist/components/ui/duplicate-event-tooltip.js +1 -1
- package/dist/components/ui/error-card.js +2 -2
- package/dist/components/ui/error-stack-block.js +1 -1
- package/dist/components/ui/icon-button.d.ts +2 -2
- package/dist/components/ui/icon-button.js +1 -1
- package/dist/components/ui/kbd.d.ts +1 -1
- package/dist/components/ui/kbd.js +1 -1
- package/dist/components/ui/load-more-button.js +1 -1
- package/dist/components/ui/menu-dropdown.js +1 -1
- package/dist/components/ui/skeleton.js +1 -1
- package/dist/components/ui/spinner.js +1 -1
- package/dist/components/ui/timestamp-tooltip.js +1 -1
- package/dist/components/ui/tooltip.js +1 -1
- package/dist/components/workflow-traces/event-colors.js +1 -1
- package/dist/components/workflow-traces/trace-span-construction.js +1 -1
- package/dist/components/workflow-traces/trace-time-utils.js +1 -1
- package/dist/hooks/use-dark-mode.js +1 -1
- package/dist/hooks/use-intersection-observer.js +1 -1
- package/dist/hooks/use-load-more-on-scroll.js +1 -1
- package/dist/hooks/use-reduced-motion.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/lib/cn.js +1 -1
- package/dist/lib/duplicate-events.js +1 -1
- package/dist/lib/event-analysis.js +1 -1
- package/dist/lib/event-list-model.d.ts +179 -0
- package/dist/lib/event-list-model.d.ts.map +1 -0
- package/dist/lib/event-list-model.js +459 -0
- package/dist/lib/event-materialization.js +1 -1
- package/dist/lib/exact-event-search-id.js +1 -1
- package/dist/lib/hydration.js +1 -1
- package/dist/lib/run-limit-guidance.js +1 -1
- package/dist/lib/sealed-events.js +1 -1
- package/dist/lib/start-hook.js +1 -1
- package/dist/lib/state-hydration.js +1 -1
- package/dist/lib/stream-display.js +1 -1
- package/dist/lib/stream-image.d.ts +3 -0
- package/dist/lib/stream-image.d.ts.map +1 -0
- package/dist/lib/stream-image.js +23 -0
- package/dist/lib/toast.js +1 -1
- package/dist/lib/trace-builder.d.ts +1 -0
- package/dist/lib/trace-builder.d.ts.map +1 -1
- package/dist/lib/trace-builder.js +5 -1
- package/dist/lib/trace-types.js +1 -1
- package/dist/lib/utils.js +1 -1
- package/dist/lib/zstd-browser-decoder.js +1 -1
- package/dist/styles.css +19 -0
- package/package.json +8 -6
- package/src/components/event-list/event-details-panel.tsx +404 -0
- package/src/components/event-list/event-list-toolbar.tsx +47 -0
- package/src/components/event-list/event-row.tsx +348 -0
- package/src/components/event-list/use-event-search.ts +104 -0
- package/src/components/event-list-view.tsx +258 -1848
- package/src/components/stream-image-preview.tsx +54 -0
- package/src/components/stream-viewer.tsx +16 -6
- package/src/components/trace-viewer/components/detail-panel-shell.tsx +146 -0
- package/src/components/trace-viewer/components/detail-panel.tsx +37 -176
- package/src/components/trace-viewer/components/event-list.tsx +46 -27
- package/src/components/trace-viewer/components/use-alt-held.ts +1 -1
- package/src/components/trace-viewer/components/use-detail-panel-width.ts +53 -0
- package/src/components/trace-viewer/context.tsx +5 -1
- package/src/components/trace-viewer/trace-viewer.tsx +13 -11
- package/src/components/trace-viewer.tsx +3 -0
- package/src/components/ui/collapsible.tsx +11 -0
- package/src/components/ui/decrypt-button.tsx +1 -1
- package/src/components/ui/error-card.tsx +1 -1
- package/src/index.ts +1 -0
- package/src/lib/event-list-model.ts +684 -0
- package/src/lib/stream-image.ts +21 -0
- package/src/lib/trace-builder.ts +5 -0
- package/src/styles.css +19 -0
- package/src/components/event-list-view.test.ts +0 -51
- package/src/components/trace-viewer/components/detail-panel-width.test.ts +0 -123
- package/src/components/trace-viewer/utils.test.ts +0 -492
- package/src/components/workflow-traces/event-colors.test.ts +0 -14
- package/src/components/workflow-traces/trace-span-construction.test.ts +0 -202
- package/src/lib/duplicate-events.test.ts +0 -336
- package/src/lib/event-materialization.test.ts +0 -136
- package/src/lib/hydration.test.ts +0 -63
- package/src/lib/run-limit-guidance.test.ts +0 -90
- package/src/lib/start-hook.test.ts +0 -174
- package/src/lib/state-hydration.test.ts +0 -332
- package/src/lib/trace-builder.test.ts +0 -143
- package/src/lib/utils.test.ts +0 -33
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import { getStreamImageType } from '../lib/stream-image';
|
|
5
|
+
import { Button } from './ui/button';
|
|
6
|
+
|
|
7
|
+
export function StreamImagePreview({ data }: { data: Uint8Array }) {
|
|
8
|
+
const [source, setSource] = useState<{
|
|
9
|
+
data: Uint8Array;
|
|
10
|
+
url: string;
|
|
11
|
+
} | null>(null);
|
|
12
|
+
const [failed, setFailed] = useState(false);
|
|
13
|
+
const type = getStreamImageType(data);
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (!type) return;
|
|
17
|
+
const url = URL.createObjectURL(new Blob([new Uint8Array(data)], { type }));
|
|
18
|
+
setSource({ data, url });
|
|
19
|
+
setFailed(false);
|
|
20
|
+
return () => URL.revokeObjectURL(url);
|
|
21
|
+
}, [data, type]);
|
|
22
|
+
|
|
23
|
+
const url = source?.data === data ? source.url : null;
|
|
24
|
+
return (
|
|
25
|
+
<div className="min-w-0 w-full">
|
|
26
|
+
<div className="mb-2 flex items-center justify-between gap-2">
|
|
27
|
+
<span className="text-label-12 text-gray-900">Image Preview</span>
|
|
28
|
+
{url ? (
|
|
29
|
+
<Button asChild size="tiny" variant="secondary">
|
|
30
|
+
<a href={url} download={`workflow-stream.${type?.split('/')[1]}`}>
|
|
31
|
+
Download Image
|
|
32
|
+
</a>
|
|
33
|
+
</Button>
|
|
34
|
+
) : null}
|
|
35
|
+
</div>
|
|
36
|
+
<div className="relative aspect-video w-full">
|
|
37
|
+
{failed ? (
|
|
38
|
+
<output className="text-copy-14 text-gray-900">
|
|
39
|
+
This image can’t be previewed. Download it to view its contents.
|
|
40
|
+
</output>
|
|
41
|
+
) : url ? (
|
|
42
|
+
<img
|
|
43
|
+
alt="Workflow stream content"
|
|
44
|
+
className="absolute inset-0 h-full w-full object-contain"
|
|
45
|
+
onError={() => setFailed(true)}
|
|
46
|
+
src={url}
|
|
47
|
+
/>
|
|
48
|
+
) : (
|
|
49
|
+
<div className="h-full w-full bg-gray-100" aria-hidden="true" />
|
|
50
|
+
)}
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import React, { useEffect, useRef } from 'react';
|
|
4
4
|
import { Virtuoso, type VirtuosoHandle } from 'react-virtuoso';
|
|
5
|
+
import { getStreamImageType } from '../lib/stream-image';
|
|
5
6
|
import { serializeForClipboard } from './sidebar/copyable-data-block';
|
|
7
|
+
import { StreamImagePreview } from './stream-image-preview';
|
|
6
8
|
import { StreamViewerSkeleton } from './stream-viewer-skeleton';
|
|
7
9
|
import { CopyButton } from './trace-viewer/components/copy-button';
|
|
8
10
|
import { DataInspector } from './ui/data-inspector';
|
|
@@ -34,10 +36,16 @@ interface StreamViewerProps {
|
|
|
34
36
|
// ──────────────────────────────────────────────────────────────────────────
|
|
35
37
|
|
|
36
38
|
const ChunkRow = React.memo(function ChunkRow({ chunk }: { chunk: Chunk }) {
|
|
39
|
+
const image =
|
|
40
|
+
chunk.value instanceof Uint8Array && getStreamImageType(chunk.value)
|
|
41
|
+
? chunk.value
|
|
42
|
+
: null;
|
|
37
43
|
return (
|
|
38
44
|
<div className="flex w-full items-start gap-1 border-b border-gray-alpha-400 px-3 py-2">
|
|
39
45
|
<div className="min-w-0 flex-1">
|
|
40
|
-
{
|
|
46
|
+
{image ? (
|
|
47
|
+
<StreamImagePreview data={image} />
|
|
48
|
+
) : typeof chunk.value === 'string' ? (
|
|
41
49
|
<span className="whitespace-pre-wrap break-words text-label-12 font-mono text-gray-1000">
|
|
42
50
|
{chunk.value}
|
|
43
51
|
</span>
|
|
@@ -45,11 +53,13 @@ const ChunkRow = React.memo(function ChunkRow({ chunk }: { chunk: Chunk }) {
|
|
|
45
53
|
<DataInspector data={chunk.value} expandLevel={1} />
|
|
46
54
|
)}
|
|
47
55
|
</div>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
56
|
+
{!image && (
|
|
57
|
+
<CopyButton
|
|
58
|
+
copyText={serializeForClipboard(chunk.value)}
|
|
59
|
+
ariaLabel="Copy chunk"
|
|
60
|
+
className="shrink-0 -mr-1 [&>div]:h-4 [&>div]:w-4 [&_svg]:h-4 [&_svg]:w-4"
|
|
61
|
+
/>
|
|
62
|
+
)}
|
|
53
63
|
</div>
|
|
54
64
|
);
|
|
55
65
|
});
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { ChevronDown, ChevronUp, X } from 'lucide-react';
|
|
4
|
+
import { type ReactNode, useEffect, useRef } from 'react';
|
|
5
|
+
import { IconButton } from '../../ui/icon-button';
|
|
6
|
+
import { Kbd } from '../../ui/kbd';
|
|
7
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from '../../ui/tooltip';
|
|
8
|
+
import { PANEL_DEFAULT_WIDTH, PANEL_MIN_WIDTH } from './detail-panel-width';
|
|
9
|
+
import { DraggableBorder } from './draggable-border';
|
|
10
|
+
import { isTypingTarget } from './use-alt-held';
|
|
11
|
+
import type { DetailPanelWidth } from './use-detail-panel-width';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The right-hand details aside shared by the Trace and Events tabs: resizable
|
|
15
|
+
* left border, a header with the title, prev/next and close, and a scrolling
|
|
16
|
+
* body. While mounted it handles the shortcuts its header advertises (K or
|
|
17
|
+
* ArrowUp, J or ArrowDown, Escape) anywhere on the page, so mount it only
|
|
18
|
+
* while an item is selected. The width lives with the owner
|
|
19
|
+
* (`useDetailPanelWidth`), which stays mounted while the panel comes and goes.
|
|
20
|
+
*/
|
|
21
|
+
export function DetailPanelShell({
|
|
22
|
+
id,
|
|
23
|
+
width,
|
|
24
|
+
title,
|
|
25
|
+
itemLabel,
|
|
26
|
+
actions,
|
|
27
|
+
onPrev,
|
|
28
|
+
onNext,
|
|
29
|
+
onClose,
|
|
30
|
+
children,
|
|
31
|
+
}: {
|
|
32
|
+
id: string;
|
|
33
|
+
width: DetailPanelWidth;
|
|
34
|
+
title: ReactNode;
|
|
35
|
+
/** What one item is called in labels, e.g. "span" or "event". */
|
|
36
|
+
itemLabel: string;
|
|
37
|
+
actions?: ReactNode;
|
|
38
|
+
onPrev?: () => void;
|
|
39
|
+
onNext?: () => void;
|
|
40
|
+
onClose: () => void;
|
|
41
|
+
children: ReactNode;
|
|
42
|
+
}): ReactNode {
|
|
43
|
+
const asideRef = useRef<HTMLElement | null>(null);
|
|
44
|
+
|
|
45
|
+
// Read through a ref so the listener is registered once, whatever the
|
|
46
|
+
// identity of the callbacks the owner passes on each render.
|
|
47
|
+
const handlersRef = useRef({ onPrev, onNext, onClose });
|
|
48
|
+
handlersRef.current = { onPrev, onNext, onClose };
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
const onKeyDown = (e: KeyboardEvent): void => {
|
|
51
|
+
// Leave keys typed into a field, and presses another handler took (a
|
|
52
|
+
// tree row moving focus, a search box clearing itself).
|
|
53
|
+
if (e.defaultPrevented || isTypingTarget(e.target)) return;
|
|
54
|
+
const handlers = handlersRef.current;
|
|
55
|
+
let handler: (() => void) | undefined;
|
|
56
|
+
if (e.key === 'k' || e.key === 'ArrowUp') handler = handlers.onPrev;
|
|
57
|
+
else if (e.key === 'j' || e.key === 'ArrowDown')
|
|
58
|
+
handler = handlers.onNext;
|
|
59
|
+
else if (e.key === 'Escape') handler = handlers.onClose;
|
|
60
|
+
if (!handler) return;
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
handler();
|
|
63
|
+
};
|
|
64
|
+
window.addEventListener('keydown', onKeyDown);
|
|
65
|
+
return () => window.removeEventListener('keydown', onKeyDown);
|
|
66
|
+
}, []);
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<aside
|
|
70
|
+
ref={asideRef}
|
|
71
|
+
id={id}
|
|
72
|
+
className="relative flex flex-col h-full max-h-full shrink-0 bg-background-100 border-l border-gray-alpha-400"
|
|
73
|
+
style={{ width: width.width }}
|
|
74
|
+
>
|
|
75
|
+
<DraggableBorder
|
|
76
|
+
element={asideRef}
|
|
77
|
+
position="left"
|
|
78
|
+
onWidthChange={width.resize}
|
|
79
|
+
onReset={() => width.resize(PANEL_DEFAULT_WIDTH)}
|
|
80
|
+
aria-label={`Resize ${itemLabel} details panel`}
|
|
81
|
+
aria-controls={id}
|
|
82
|
+
aria-valuemin={PANEL_MIN_WIDTH}
|
|
83
|
+
aria-valuemax={width.maxWidth}
|
|
84
|
+
aria-valuenow={Math.min(
|
|
85
|
+
Math.max(Math.round(width.width), PANEL_MIN_WIDTH),
|
|
86
|
+
width.maxWidth
|
|
87
|
+
)}
|
|
88
|
+
/>
|
|
89
|
+
{/* Panel header */}
|
|
90
|
+
<div className="flex items-center justify-between gap-2 shrink-0 px-4 py-[7.5px]">
|
|
91
|
+
<div className="flex min-w-0 items-center gap-2 text-label-14 font-medium text-gray-1000">
|
|
92
|
+
{title}
|
|
93
|
+
</div>
|
|
94
|
+
<div className="flex items-center gap-0.5 shrink-0">
|
|
95
|
+
{actions}
|
|
96
|
+
<Tooltip>
|
|
97
|
+
<TooltipTrigger asChild>
|
|
98
|
+
<IconButton
|
|
99
|
+
aria-label="Navigate up"
|
|
100
|
+
aria-keyshortcuts="K"
|
|
101
|
+
onClick={onPrev}
|
|
102
|
+
disabled={!onPrev}
|
|
103
|
+
>
|
|
104
|
+
<ChevronUp className="w-4 h-4" />
|
|
105
|
+
</IconButton>
|
|
106
|
+
</TooltipTrigger>
|
|
107
|
+
{onPrev ? (
|
|
108
|
+
<TooltipContent>
|
|
109
|
+
Navigate up
|
|
110
|
+
<Kbd>K</Kbd>
|
|
111
|
+
</TooltipContent>
|
|
112
|
+
) : null}
|
|
113
|
+
</Tooltip>
|
|
114
|
+
<Tooltip>
|
|
115
|
+
<TooltipTrigger asChild>
|
|
116
|
+
<IconButton
|
|
117
|
+
aria-label="Navigate down"
|
|
118
|
+
aria-keyshortcuts="J"
|
|
119
|
+
onClick={onNext}
|
|
120
|
+
disabled={!onNext}
|
|
121
|
+
>
|
|
122
|
+
<ChevronDown className="w-4 h-4" />
|
|
123
|
+
</IconButton>
|
|
124
|
+
</TooltipTrigger>
|
|
125
|
+
{onNext ? (
|
|
126
|
+
<TooltipContent>
|
|
127
|
+
Navigate down
|
|
128
|
+
<Kbd>J</Kbd>
|
|
129
|
+
</TooltipContent>
|
|
130
|
+
) : null}
|
|
131
|
+
</Tooltip>
|
|
132
|
+
<div aria-hidden className="w-px h-4 bg-gray-alpha-400 mx-1" />
|
|
133
|
+
<IconButton
|
|
134
|
+
aria-label={`Close ${itemLabel} details`}
|
|
135
|
+
aria-keyshortcuts="Escape"
|
|
136
|
+
onClick={onClose}
|
|
137
|
+
>
|
|
138
|
+
<X className="w-4 h-4" />
|
|
139
|
+
</IconButton>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
{/* Panel body */}
|
|
143
|
+
<div className="flex-1 overflow-y-auto">{children}</div>
|
|
144
|
+
</aside>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { parseStepName, parseWorkflowName } from '@workflow/utils/parse-name';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
type ReactNode,
|
|
7
|
-
type RefObject,
|
|
8
|
-
useCallback,
|
|
9
|
-
useEffect,
|
|
10
|
-
useMemo,
|
|
11
|
-
useRef,
|
|
12
|
-
useState,
|
|
13
|
-
} from 'react';
|
|
4
|
+
import { type ReactNode, type RefObject, useCallback, useMemo } from 'react';
|
|
14
5
|
import { filterSpanRawEvents } from '../../../lib/trace-builder';
|
|
15
6
|
import { ErrorBoundary } from '../../error-boundary';
|
|
16
7
|
import {
|
|
@@ -18,20 +9,9 @@ import {
|
|
|
18
9
|
type SelectedSpanInfo,
|
|
19
10
|
} from '../../sidebar/entity-detail-panel';
|
|
20
11
|
import { useSidebarData } from '../../sidebar/sidebar-data-context';
|
|
21
|
-
import { IconButton } from '../../ui/icon-button';
|
|
22
|
-
import { Kbd } from '../../ui/kbd';
|
|
23
|
-
import { Tooltip, TooltipContent, TooltipTrigger } from '../../ui/tooltip';
|
|
24
12
|
import { useActiveSpan } from '../context';
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
computeMaxPanelWidth,
|
|
28
|
-
PANEL_DEFAULT_WIDTH,
|
|
29
|
-
PANEL_MIN_WIDTH,
|
|
30
|
-
readStoredPanelWidth,
|
|
31
|
-
writeStoredPanelWidth,
|
|
32
|
-
} from './detail-panel-width';
|
|
33
|
-
import { DraggableBorder } from './draggable-border';
|
|
34
|
-
import { useElementWidth } from './use-element-width';
|
|
13
|
+
import { DetailPanelShell } from './detail-panel-shell';
|
|
14
|
+
import { useDetailPanelWidth } from './use-detail-panel-width';
|
|
35
15
|
|
|
36
16
|
const DETAIL_PANEL_ID = 'trace-detail-panel';
|
|
37
17
|
|
|
@@ -61,11 +41,11 @@ function useSelectedSpanInfo(): SelectedSpanInfo | null {
|
|
|
61
41
|
}
|
|
62
42
|
|
|
63
43
|
/**
|
|
64
|
-
* The span detail aside:
|
|
65
|
-
* the
|
|
44
|
+
* The span detail aside: the selected span's details in `DetailPanelShell`,
|
|
45
|
+
* which supplies the header, its J/K/Escape shortcuts and the resizable border.
|
|
66
46
|
*
|
|
67
|
-
* Always mounted (it renders null without a selection)
|
|
68
|
-
* survives closing and reopening within a session.
|
|
47
|
+
* Always mounted (it renders null without a selection) and holds the panel
|
|
48
|
+
* width, so the width survives closing and reopening within a session.
|
|
69
49
|
*/
|
|
70
50
|
export function TraceDetailPanel({
|
|
71
51
|
containerRef,
|
|
@@ -79,28 +59,7 @@ export function TraceDetailPanel({
|
|
|
79
59
|
const { activeSpan, activeSpanId, spans } = useActiveSpan();
|
|
80
60
|
const sidebar = useSidebarData();
|
|
81
61
|
const selectedSpan = useSelectedSpanInfo();
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
const [storedWidth, setStoredWidth] = useState<number>(() =>
|
|
85
|
-
readStoredPanelWidth()
|
|
86
|
-
);
|
|
87
|
-
const containerWidth = useElementWidth(containerRef, isOpen);
|
|
88
|
-
const asideRef = useRef<HTMLDivElement | null>(null);
|
|
89
|
-
|
|
90
|
-
const handleResize = useCallback(
|
|
91
|
-
(next: number) => {
|
|
92
|
-
const clamped = clampPanelWidth(next, containerWidth);
|
|
93
|
-
setStoredWidth(clamped);
|
|
94
|
-
writeStoredPanelWidth(clamped);
|
|
95
|
-
},
|
|
96
|
-
[containerWidth]
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
const panelWidth = clampPanelWidth(storedWidth, containerWidth);
|
|
100
|
-
const panelMaxWidth = Math.max(
|
|
101
|
-
PANEL_MIN_WIDTH,
|
|
102
|
-
computeMaxPanelWidth(containerWidth)
|
|
103
|
-
);
|
|
62
|
+
const panelWidth = useDetailPanelWidth(containerRef, Boolean(activeSpan));
|
|
104
63
|
|
|
105
64
|
const { prevSpanId, nextSpanId } = useMemo(() => {
|
|
106
65
|
if (!activeSpanId) return { prevSpanId: null, nextSpanId: null };
|
|
@@ -120,38 +79,6 @@ export function TraceDetailPanel({
|
|
|
120
79
|
if (nextSpanId) onNavigateToSpan(nextSpanId);
|
|
121
80
|
}, [nextSpanId, onNavigateToSpan]);
|
|
122
81
|
|
|
123
|
-
useEffect(() => {
|
|
124
|
-
if (!isOpen) return;
|
|
125
|
-
|
|
126
|
-
const onKeyDown = (e: KeyboardEvent): void => {
|
|
127
|
-
if (
|
|
128
|
-
e.key !== 'j' &&
|
|
129
|
-
e.key !== 'k' &&
|
|
130
|
-
e.key !== 'ArrowDown' &&
|
|
131
|
-
e.key !== 'ArrowUp'
|
|
132
|
-
) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
const target = e.target as HTMLElement | null;
|
|
136
|
-
if (
|
|
137
|
-
target instanceof HTMLInputElement ||
|
|
138
|
-
target instanceof HTMLTextAreaElement ||
|
|
139
|
-
target?.isContentEditable
|
|
140
|
-
) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
const targetId =
|
|
144
|
-
e.key === 'k' || e.key === 'ArrowUp' ? prevSpanId : nextSpanId;
|
|
145
|
-
if (targetId) {
|
|
146
|
-
e.preventDefault();
|
|
147
|
-
onNavigateToSpan(targetId);
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
window.addEventListener('keydown', onKeyDown);
|
|
152
|
-
return () => window.removeEventListener('keydown', onKeyDown);
|
|
153
|
-
}, [isOpen, prevSpanId, nextSpanId, onNavigateToSpan]);
|
|
154
|
-
|
|
155
82
|
// Derive the selected span name for the panel header
|
|
156
83
|
const selectedSpanName = useMemo(() => {
|
|
157
84
|
if (!selectedSpan?.data) return 'Details';
|
|
@@ -175,102 +102,36 @@ export function TraceDetailPanel({
|
|
|
175
102
|
if (!activeSpan) return null;
|
|
176
103
|
|
|
177
104
|
return (
|
|
178
|
-
<
|
|
179
|
-
ref={asideRef}
|
|
105
|
+
<DetailPanelShell
|
|
180
106
|
id={DETAIL_PANEL_ID}
|
|
181
|
-
|
|
182
|
-
|
|
107
|
+
width={panelWidth}
|
|
108
|
+
title={<span className="truncate block">{selectedSpanName}</span>}
|
|
109
|
+
itemLabel="span"
|
|
110
|
+
onPrev={prevSpanId ? handleSelectPrev : undefined}
|
|
111
|
+
onNext={nextSpanId ? handleSelectNext : undefined}
|
|
112
|
+
onClose={onClose}
|
|
183
113
|
>
|
|
184
|
-
<
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
<IconButton
|
|
207
|
-
aria-label="Navigate up"
|
|
208
|
-
aria-keyshortcuts="K"
|
|
209
|
-
onClick={handleSelectPrev}
|
|
210
|
-
disabled={!prevSpanId}
|
|
211
|
-
>
|
|
212
|
-
<ChevronUp className="w-4 h-4" />
|
|
213
|
-
</IconButton>
|
|
214
|
-
</TooltipTrigger>
|
|
215
|
-
{prevSpanId ? (
|
|
216
|
-
<TooltipContent>
|
|
217
|
-
Navigate up
|
|
218
|
-
<Kbd>K</Kbd>
|
|
219
|
-
</TooltipContent>
|
|
220
|
-
) : null}
|
|
221
|
-
</Tooltip>
|
|
222
|
-
<Tooltip>
|
|
223
|
-
<TooltipTrigger asChild>
|
|
224
|
-
<IconButton
|
|
225
|
-
aria-label="Navigate down"
|
|
226
|
-
aria-keyshortcuts="J"
|
|
227
|
-
onClick={handleSelectNext}
|
|
228
|
-
disabled={!nextSpanId}
|
|
229
|
-
>
|
|
230
|
-
<ChevronDown className="w-4 h-4" />
|
|
231
|
-
</IconButton>
|
|
232
|
-
</TooltipTrigger>
|
|
233
|
-
{nextSpanId ? (
|
|
234
|
-
<TooltipContent>
|
|
235
|
-
Navigate down
|
|
236
|
-
<Kbd>J</Kbd>
|
|
237
|
-
</TooltipContent>
|
|
238
|
-
) : null}
|
|
239
|
-
</Tooltip>
|
|
240
|
-
<div aria-hidden className="w-px h-4 bg-gray-alpha-400 mx-1" />
|
|
241
|
-
<IconButton
|
|
242
|
-
aria-label="Close span details"
|
|
243
|
-
aria-keyshortcuts="Escape"
|
|
244
|
-
onClick={onClose}
|
|
245
|
-
>
|
|
246
|
-
<X className="w-4 h-4" />
|
|
247
|
-
</IconButton>
|
|
248
|
-
</div>
|
|
249
|
-
</div>
|
|
250
|
-
{/* Panel body */}
|
|
251
|
-
<div className="flex-1 overflow-y-auto">
|
|
252
|
-
<ErrorBoundary>
|
|
253
|
-
<EntityDetailPanel
|
|
254
|
-
run={sidebar.run}
|
|
255
|
-
onStreamClick={sidebar.onStreamClick}
|
|
256
|
-
onRunClick={sidebar.onRunClick}
|
|
257
|
-
fetchSpanDetail={sidebar.fetchSpanDetail}
|
|
258
|
-
onWakeUpSleep={sidebar.onWakeUpSleep}
|
|
259
|
-
onLoadEventData={sidebar.onLoadEventData}
|
|
260
|
-
onResolveHook={sidebar.onResolveHook}
|
|
261
|
-
encryptionKey={sidebar.encryptionKey}
|
|
262
|
-
onDecrypt={sidebar.onDecrypt}
|
|
263
|
-
isDecrypting={sidebar.isDecrypting}
|
|
264
|
-
isDecryptDisabled={sidebar.isDecryptDisabled}
|
|
265
|
-
decryptDisabledReason={sidebar.decryptDisabledReason}
|
|
266
|
-
selectedSpan={selectedSpan}
|
|
267
|
-
showSeparateEventOccurrenceTimestamps={
|
|
268
|
-
sidebar.showSeparateEventOccurrenceTimestamps
|
|
269
|
-
}
|
|
270
|
-
getModuleSourceUrl={sidebar.getModuleSourceUrl}
|
|
271
|
-
/>
|
|
272
|
-
</ErrorBoundary>
|
|
273
|
-
</div>
|
|
274
|
-
</aside>
|
|
114
|
+
<ErrorBoundary>
|
|
115
|
+
<EntityDetailPanel
|
|
116
|
+
run={sidebar.run}
|
|
117
|
+
onStreamClick={sidebar.onStreamClick}
|
|
118
|
+
onRunClick={sidebar.onRunClick}
|
|
119
|
+
fetchSpanDetail={sidebar.fetchSpanDetail}
|
|
120
|
+
onWakeUpSleep={sidebar.onWakeUpSleep}
|
|
121
|
+
onLoadEventData={sidebar.onLoadEventData}
|
|
122
|
+
onResolveHook={sidebar.onResolveHook}
|
|
123
|
+
encryptionKey={sidebar.encryptionKey}
|
|
124
|
+
onDecrypt={sidebar.onDecrypt}
|
|
125
|
+
isDecrypting={sidebar.isDecrypting}
|
|
126
|
+
isDecryptDisabled={sidebar.isDecryptDisabled}
|
|
127
|
+
decryptDisabledReason={sidebar.decryptDisabledReason}
|
|
128
|
+
selectedSpan={selectedSpan}
|
|
129
|
+
showSeparateEventOccurrenceTimestamps={
|
|
130
|
+
sidebar.showSeparateEventOccurrenceTimestamps
|
|
131
|
+
}
|
|
132
|
+
getModuleSourceUrl={sidebar.getModuleSourceUrl}
|
|
133
|
+
/>
|
|
134
|
+
</ErrorBoundary>
|
|
135
|
+
</DetailPanelShell>
|
|
275
136
|
);
|
|
276
137
|
}
|
|
@@ -55,6 +55,36 @@ function getEventStyle(
|
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
/**
|
|
59
|
+
* The colored type icon (workflow, step, hook, sleep) with its tooltip. Shared
|
|
60
|
+
* by the Trace span list and the Events tab so both mark entities the same way.
|
|
61
|
+
*/
|
|
62
|
+
export function ResourceIcon({
|
|
63
|
+
resource,
|
|
64
|
+
isErrored = false,
|
|
65
|
+
isCancelled = false,
|
|
66
|
+
}: {
|
|
67
|
+
resource: string;
|
|
68
|
+
isErrored?: boolean;
|
|
69
|
+
isCancelled?: boolean;
|
|
70
|
+
}) {
|
|
71
|
+
const {
|
|
72
|
+
icon: Icon,
|
|
73
|
+
className,
|
|
74
|
+
label,
|
|
75
|
+
} = getEventStyle(resource, isErrored, isCancelled);
|
|
76
|
+
return (
|
|
77
|
+
<Tooltip delayDuration={500}>
|
|
78
|
+
<TooltipTrigger asChild>
|
|
79
|
+
<span className={cn('shrink-0', className)}>
|
|
80
|
+
<Icon className="w-4 h-4" />
|
|
81
|
+
</span>
|
|
82
|
+
</TooltipTrigger>
|
|
83
|
+
<TooltipContent side="top">{label}</TooltipContent>
|
|
84
|
+
</Tooltip>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
58
88
|
const EventRow = ({
|
|
59
89
|
span,
|
|
60
90
|
isSelected,
|
|
@@ -69,16 +99,10 @@ const EventRow = ({
|
|
|
69
99
|
const durationMs = getSpanDurationMs(span);
|
|
70
100
|
const isErrored = isSpanErrored(span);
|
|
71
101
|
const isCancelled = isSpanCancelled(span);
|
|
72
|
-
const {
|
|
73
|
-
icon: Icon,
|
|
74
|
-
className: tagClassName,
|
|
75
|
-
label: iconLabel,
|
|
76
|
-
} = getEventStyle(span.resource, isErrored, isCancelled);
|
|
77
|
-
|
|
78
102
|
return (
|
|
79
103
|
<li
|
|
80
104
|
className={cn(
|
|
81
|
-
'relative overflow-clip
|
|
105
|
+
'relative overflow-clip transition-opacity hover:bg-gray-100 aria-selected:bg-gray-100 aria-selected:hover:bg-gray-200',
|
|
82
106
|
ROW_HEIGHT_CLASS,
|
|
83
107
|
isDimmed && 'opacity-35'
|
|
84
108
|
)}
|
|
@@ -88,26 +112,21 @@ const EventRow = ({
|
|
|
88
112
|
aria-level={1}
|
|
89
113
|
onClick={() => onSelectSpan(span.spanId)}
|
|
90
114
|
>
|
|
91
|
-
<div className="h-full
|
|
92
|
-
<div className="flex
|
|
93
|
-
<
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
</
|
|
106
|
-
<div className="ml-2 shrink-0">
|
|
107
|
-
<span className="text-label-14 text-gray-900 tabular-nums">
|
|
108
|
-
{formatDurationPrecise(durationMs)}
|
|
109
|
-
</span>
|
|
110
|
-
</div>
|
|
115
|
+
<div className="flex h-full min-w-0 items-center pl-4 pr-2">
|
|
116
|
+
<div className="flex min-w-0 flex-1 items-center gap-2">
|
|
117
|
+
<ResourceIcon
|
|
118
|
+
resource={span.resource}
|
|
119
|
+
isErrored={isErrored}
|
|
120
|
+
isCancelled={isCancelled}
|
|
121
|
+
/>
|
|
122
|
+
<span className="min-w-0 text-label-14">
|
|
123
|
+
<MiddleTruncate value={span.name} />
|
|
124
|
+
</span>
|
|
125
|
+
</div>
|
|
126
|
+
<div className="ml-2 shrink-0">
|
|
127
|
+
<span className="text-label-14 text-gray-900 tabular-nums">
|
|
128
|
+
{formatDurationPrecise(durationMs)}
|
|
129
|
+
</span>
|
|
111
130
|
</div>
|
|
112
131
|
</div>
|
|
113
132
|
</li>
|
|
@@ -6,7 +6,7 @@ function isAltModifierKey(key: string): boolean {
|
|
|
6
6
|
return key === 'Alt' || key === 'AltGraph';
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
function isTypingTarget(target: EventTarget | null): boolean {
|
|
9
|
+
export function isTypingTarget(target: EventTarget | null): boolean {
|
|
10
10
|
return (
|
|
11
11
|
target instanceof HTMLInputElement ||
|
|
12
12
|
target instanceof HTMLTextAreaElement ||
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { type RefObject, useCallback, useState } from 'react';
|
|
4
|
+
import {
|
|
5
|
+
clampPanelWidth,
|
|
6
|
+
computeMaxPanelWidth,
|
|
7
|
+
PANEL_MIN_WIDTH,
|
|
8
|
+
readStoredPanelWidth,
|
|
9
|
+
writeStoredPanelWidth,
|
|
10
|
+
} from './detail-panel-width';
|
|
11
|
+
import { useElementWidth } from './use-element-width';
|
|
12
|
+
|
|
13
|
+
/** The details panel's width, bounded by the container it shares. */
|
|
14
|
+
export interface DetailPanelWidth {
|
|
15
|
+
/** Rendered width (px): the preferred width clamped to the container. */
|
|
16
|
+
width: number;
|
|
17
|
+
/** Widest the container allows (px), for the resize handle. */
|
|
18
|
+
maxWidth: number;
|
|
19
|
+
/** Sets and persists the preferred width, clamped to the container. */
|
|
20
|
+
resize: (width: number) => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Width state for `DetailPanelShell` (model in detail-panel-width.ts). Call it
|
|
25
|
+
* from a component that stays mounted while the panel opens, closes and
|
|
26
|
+
* changes selection, so the width holds across all three in a session;
|
|
27
|
+
* localStorage only carries it to the next one. The container is measured
|
|
28
|
+
* only while `open`.
|
|
29
|
+
*/
|
|
30
|
+
export function useDetailPanelWidth(
|
|
31
|
+
containerRef: RefObject<HTMLElement | null>,
|
|
32
|
+
open: boolean
|
|
33
|
+
): DetailPanelWidth {
|
|
34
|
+
const [storedWidth, setStoredWidth] = useState<number>(() =>
|
|
35
|
+
readStoredPanelWidth()
|
|
36
|
+
);
|
|
37
|
+
const containerWidth = useElementWidth(containerRef, open);
|
|
38
|
+
|
|
39
|
+
const resize = useCallback(
|
|
40
|
+
(next: number) => {
|
|
41
|
+
const clamped = clampPanelWidth(next, containerWidth);
|
|
42
|
+
setStoredWidth(clamped);
|
|
43
|
+
writeStoredPanelWidth(clamped);
|
|
44
|
+
},
|
|
45
|
+
[containerWidth]
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
width: clampPanelWidth(storedWidth, containerWidth),
|
|
50
|
+
maxWidth: Math.max(PANEL_MIN_WIDTH, computeMaxPanelWidth(containerWidth)),
|
|
51
|
+
resize,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -25,12 +25,16 @@ ActiveSpanContext.displayName = 'ActiveSpanContext';
|
|
|
25
25
|
|
|
26
26
|
export function ActiveSpanProvider({
|
|
27
27
|
spans,
|
|
28
|
+
initialSelectedSpanId,
|
|
28
29
|
children,
|
|
29
30
|
}: {
|
|
30
31
|
spans: Span[];
|
|
32
|
+
initialSelectedSpanId?: string;
|
|
31
33
|
children: ReactNode;
|
|
32
34
|
}) {
|
|
33
|
-
const [activeSpanId, setActiveSpanId] = useState<string | null>(
|
|
35
|
+
const [activeSpanId, setActiveSpanId] = useState<string | null>(
|
|
36
|
+
initialSelectedSpanId ?? null
|
|
37
|
+
);
|
|
34
38
|
|
|
35
39
|
useEffect(() => {
|
|
36
40
|
setActiveSpanId((currentSpanId) => {
|