@workflow/web-shared 5.2.0 → 5.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/event-list/event-details-panel.d.ts.map +1 -1
- package/dist/components/event-list/event-details-panel.js +3 -3
- package/dist/components/event-list/event-list-toolbar.d.ts +2 -1
- package/dist/components/event-list/event-list-toolbar.d.ts.map +1 -1
- package/dist/components/event-list/event-list-toolbar.js +20 -11
- package/dist/components/event-list/event-row.d.ts +3 -3
- package/dist/components/event-list/event-row.d.ts.map +1 -1
- package/dist/components/event-list/event-row.js +15 -13
- package/dist/components/event-list/use-event-search.d.ts +3 -1
- package/dist/components/event-list/use-event-search.d.ts.map +1 -1
- package/dist/components/event-list/use-event-search.js +19 -20
- package/dist/components/event-list-view.d.ts.map +1 -1
- package/dist/components/event-list-view.js +53 -24
- package/dist/components/hook-actions.d.ts +0 -1
- package/dist/components/hook-actions.d.ts.map +1 -1
- package/dist/components/hook-actions.js +1 -3
- package/dist/components/index.d.ts +5 -9
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +4 -9
- package/dist/components/sidebar/attribute-panel.d.ts +0 -13
- package/dist/components/sidebar/attribute-panel.d.ts.map +1 -1
- package/dist/components/sidebar/attribute-panel.js +5 -5
- package/dist/components/sidebar/attributes-block.d.ts +0 -7
- package/dist/components/sidebar/attributes-block.d.ts.map +1 -1
- package/dist/components/sidebar/attributes-block.js +5 -5
- package/dist/components/sidebar/conversation-view.d.ts.map +1 -1
- package/dist/components/sidebar/conversation-view.js +4 -3
- package/dist/components/sidebar/copyable-data-block.d.ts.map +1 -1
- package/dist/components/sidebar/copyable-data-block.js +8 -6
- package/dist/components/sidebar/entity-detail-panel.d.ts.map +1 -1
- package/dist/components/sidebar/entity-detail-panel.js +2 -3
- package/dist/components/stream-image-preview.js +2 -2
- package/dist/components/stream-viewer.js +3 -3
- package/dist/components/trace-viewer/components/middle-truncate/truncate.d.ts +1 -4
- package/dist/components/trace-viewer/components/middle-truncate/truncate.d.ts.map +1 -1
- package/dist/components/trace-viewer/components/middle-truncate/truncate.js +2 -2
- package/dist/components/trace-viewer/components/minimap.d.ts.map +1 -1
- package/dist/components/trace-viewer/components/minimap.js +6 -4
- package/dist/components/trace-viewer/components/timeline.d.ts +0 -11
- package/dist/components/trace-viewer/components/timeline.d.ts.map +1 -1
- package/dist/components/trace-viewer/components/timeline.js +1 -2
- package/dist/components/trace-viewer/trace-viewer.js +4 -10
- package/dist/components/ui/button.d.ts +28 -17
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/button.js +47 -43
- package/dist/components/ui/context-card.js +3 -3
- package/dist/components/ui/copy-button.d.ts +15 -0
- package/dist/components/ui/copy-button.d.ts.map +1 -0
- package/dist/components/ui/copy-button.js +41 -0
- package/dist/components/ui/data-inspector.d.ts.map +1 -1
- package/dist/components/ui/data-inspector.js +8 -38
- package/dist/components/ui/decrypt-button.d.ts +3 -2
- package/dist/components/ui/decrypt-button.d.ts.map +1 -1
- package/dist/components/ui/decrypt-button.js +13 -7
- package/dist/components/ui/duplicate-event-tooltip.d.ts +1 -9
- package/dist/components/ui/duplicate-event-tooltip.d.ts.map +1 -1
- package/dist/components/ui/duplicate-event-tooltip.js +2 -10
- package/dist/components/ui/error-stack-block.js +3 -3
- package/dist/components/ui/icon-button.d.ts +2 -2
- package/dist/components/ui/icon-button.d.ts.map +1 -1
- package/dist/components/ui/icon-button.js +2 -3
- package/dist/components/ui/kbd.d.ts +1 -1
- package/dist/components/ui/kbd.d.ts.map +1 -1
- package/dist/components/ui/kbd.js +1 -2
- package/dist/components/ui/search-input.d.ts +19 -0
- package/dist/components/ui/search-input.d.ts.map +1 -0
- package/dist/components/ui/search-input.js +61 -0
- package/dist/components/ui/spinner.d.ts +54 -6
- package/dist/components/ui/spinner.d.ts.map +1 -1
- package/dist/components/ui/spinner.js +84 -46
- package/dist/components/workflow-traces/trace-span-construction.d.ts +1 -22
- package/dist/components/workflow-traces/trace-span-construction.d.ts.map +1 -1
- package/dist/components/workflow-traces/trace-span-construction.js +3 -3
- package/dist/index.d.ts +9 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -11
- package/dist/lib/event-analysis.d.ts +1 -25
- package/dist/lib/event-analysis.d.ts.map +1 -1
- package/dist/lib/event-analysis.js +2 -75
- package/dist/lib/event-list-model.d.ts +4 -2
- package/dist/lib/event-list-model.d.ts.map +1 -1
- package/dist/lib/event-list-model.js +13 -11
- package/dist/lib/exact-event-search-id.d.ts +0 -2
- package/dist/lib/exact-event-search-id.d.ts.map +1 -1
- package/dist/lib/exact-event-search-id.js +1 -12
- package/dist/lib/hydration.d.ts +1 -12
- package/dist/lib/hydration.d.ts.map +1 -1
- package/dist/lib/hydration.js +8 -20
- package/dist/lib/stream-display.d.ts +0 -1
- package/dist/lib/stream-display.d.ts.map +1 -1
- package/dist/lib/stream-display.js +2 -2
- package/dist/lib/trace-builder.d.ts +0 -8
- package/dist/lib/trace-builder.d.ts.map +1 -1
- package/dist/lib/trace-builder.js +2 -2
- package/dist/lib/utils.d.ts +0 -22
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +1 -31
- package/dist/styles.css +268 -118
- package/package.json +4 -16
- package/src/components/event-list/event-details-panel.tsx +3 -4
- package/src/components/event-list/event-list-toolbar.tsx +35 -28
- package/src/components/event-list/event-row.tsx +33 -29
- package/src/components/event-list/use-event-search.ts +29 -22
- package/src/components/event-list-view.tsx +180 -52
- package/src/components/hook-actions.tsx +0 -1
- package/src/components/index.ts +4 -20
- package/src/components/sidebar/attribute-panel.tsx +4 -7
- package/src/components/sidebar/attributes-block.tsx +7 -6
- package/src/components/sidebar/conversation-view.tsx +3 -2
- package/src/components/sidebar/copyable-data-block.tsx +17 -14
- package/src/components/sidebar/entity-detail-panel.tsx +2 -7
- package/src/components/stream-image-preview.tsx +1 -1
- package/src/components/stream-viewer.tsx +4 -4
- package/src/components/trace-viewer/components/middle-truncate/truncate.ts +1 -2
- package/src/components/trace-viewer/components/minimap.tsx +4 -3
- package/src/components/trace-viewer/components/timeline.tsx +0 -2
- package/src/components/trace-viewer/trace-viewer.tsx +12 -38
- package/src/components/ui/button.tsx +144 -46
- package/src/components/ui/context-card.tsx +2 -2
- package/src/components/ui/copy-button.tsx +86 -0
- package/src/components/ui/data-inspector.tsx +23 -67
- package/src/components/ui/decrypt-button.tsx +23 -48
- package/src/components/ui/duplicate-event-tooltip.tsx +1 -22
- package/src/components/ui/error-stack-block.tsx +4 -4
- package/src/components/ui/icon-button.tsx +1 -3
- package/src/components/ui/kbd.tsx +0 -2
- package/src/components/ui/search-input.tsx +143 -0
- package/src/components/ui/spinner.tsx +105 -55
- package/src/components/workflow-traces/trace-span-construction.ts +2 -2
- package/src/index.ts +7 -55
- package/src/lib/event-analysis.ts +1 -104
- package/src/lib/event-list-model.ts +15 -12
- package/src/lib/exact-event-search-id.ts +0 -13
- package/src/lib/hydration.ts +6 -31
- package/src/lib/stream-display.ts +1 -1
- package/src/lib/trace-builder.ts +1 -1
- package/src/lib/utils.ts +0 -48
- package/src/styles.css +268 -118
- package/dist/components/trace-viewer/components/copy-button.d.ts +0 -9
- package/dist/components/trace-viewer/components/copy-button.d.ts.map +0 -1
- package/dist/components/trace-viewer/components/copy-button.js +0 -27
- package/dist/components/ui/alert.d.ts +0 -9
- package/dist/components/ui/alert.d.ts.map +0 -1
- package/dist/components/ui/alert.js +0 -23
- package/dist/components/ui/card.d.ts +0 -9
- package/dist/components/ui/card.d.ts.map +0 -1
- package/dist/components/ui/card.js +0 -18
- package/dist/components/ui/load-more-button.d.ts +0 -13
- package/dist/components/ui/load-more-button.d.ts.map +0 -1
- package/dist/components/ui/load-more-button.js +0 -12
- package/dist/components/ui/menu-dropdown.d.ts +0 -16
- package/dist/components/ui/menu-dropdown.d.ts.map +0 -1
- package/dist/components/ui/menu-dropdown.js +0 -30
- package/dist/hooks/use-dark-mode.d.ts +0 -9
- package/dist/hooks/use-dark-mode.d.ts.map +0 -1
- package/dist/hooks/use-dark-mode.js +0 -30
- package/dist/lib/event-materialization.d.ts +0 -91
- package/dist/lib/event-materialization.d.ts.map +0 -1
- package/dist/lib/event-materialization.js +0 -219
- package/src/components/index.d.ts +0 -1
- package/src/components/trace-viewer/components/copy-button.tsx +0 -68
- package/src/components/ui/alert.tsx +0 -59
- package/src/components/ui/card.tsx +0 -79
- package/src/components/ui/load-more-button.tsx +0 -38
- package/src/components/ui/menu-dropdown.tsx +0 -97
- package/src/hooks/use-dark-mode.ts +0 -34
- package/src/index.d.ts +0 -1
- package/src/lib/event-materialization.ts +0 -304
|
@@ -1,47 +1,54 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { Info } from 'lucide-react';
|
|
4
|
+
import { useId, useRef, useState } from 'react';
|
|
5
|
+
import { SearchInput } from '../ui/search-input';
|
|
6
|
+
|
|
7
|
+
/** How long typing has to pause before the hint shows. */
|
|
8
|
+
const HINT_DELAY_MS = 500;
|
|
5
9
|
|
|
6
10
|
/** The events search box. */
|
|
7
11
|
export function EventListToolbar({
|
|
8
12
|
query,
|
|
13
|
+
hint,
|
|
9
14
|
onQueryChange,
|
|
10
15
|
}: {
|
|
11
16
|
query: string;
|
|
17
|
+
hint: string | null;
|
|
12
18
|
onQueryChange: (query: string) => void;
|
|
13
19
|
}) {
|
|
20
|
+
const hintId = useId();
|
|
21
|
+
const [paused, setPaused] = useState(false);
|
|
22
|
+
const pauseTimer = useRef<ReturnType<typeof setTimeout>>(undefined);
|
|
23
|
+
|
|
24
|
+
const handleQueryChange = (next: string) => {
|
|
25
|
+
// With no hint showing, the next one waits for typing to pause.
|
|
26
|
+
if (!hint) setPaused(false);
|
|
27
|
+
clearTimeout(pauseTimer.current);
|
|
28
|
+
pauseTimer.current = setTimeout(() => setPaused(true), HINT_DELAY_MS);
|
|
29
|
+
onQueryChange(next);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const shownHint = paused ? hint : null;
|
|
14
33
|
return (
|
|
15
|
-
<div className="
|
|
16
|
-
<
|
|
17
|
-
<input
|
|
18
|
-
type="text"
|
|
34
|
+
<div className="shrink-0">
|
|
35
|
+
<SearchInput
|
|
19
36
|
name="event-list-search"
|
|
20
|
-
|
|
37
|
+
label="Search events"
|
|
21
38
|
placeholder="Search by step ID, wait ID, hook ID, or event ID…"
|
|
39
|
+
aria-describedby={hintId}
|
|
22
40
|
value={query}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (e.key === 'Escape' && query) {
|
|
26
|
-
e.preventDefault();
|
|
27
|
-
e.stopPropagation();
|
|
28
|
-
onQueryChange('');
|
|
29
|
-
}
|
|
30
|
-
}}
|
|
31
|
-
className="min-w-0 flex-1 bg-transparent text-label-14 text-gray-1000 outline-none placeholder:text-gray-800"
|
|
41
|
+
onValueChange={handleQueryChange}
|
|
42
|
+
className="pl-[34px]"
|
|
32
43
|
/>
|
|
33
|
-
{
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
Esc
|
|
42
|
-
</Kbd>
|
|
43
|
-
</button>
|
|
44
|
-
) : null}
|
|
44
|
+
<div id={hintId} aria-live="polite">
|
|
45
|
+
{shownHint ? (
|
|
46
|
+
<div className="flex h-8 items-center gap-1.5 bg-gray-100 pl-[34px] pr-2 text-label-13 text-gray-1000">
|
|
47
|
+
<Info className="h-3.5 w-3.5 shrink-0 text-gray-900" />
|
|
48
|
+
<span className="min-w-0 truncate">{shownHint}</span>
|
|
49
|
+
</div>
|
|
50
|
+
) : null}
|
|
51
|
+
</div>
|
|
45
52
|
</div>
|
|
46
53
|
);
|
|
47
54
|
}
|
|
@@ -27,15 +27,15 @@ const COL = {
|
|
|
27
27
|
time: 'w-[172px]',
|
|
28
28
|
since: 'w-[100px]',
|
|
29
29
|
event: 'w-[136px]',
|
|
30
|
-
name: 'w-[
|
|
30
|
+
name: 'w-[280px]',
|
|
31
31
|
duration: 'w-[96px] justify-end',
|
|
32
32
|
} as const;
|
|
33
33
|
|
|
34
34
|
const CELL = 'flex h-full shrink-0 items-center overflow-hidden px-1.5';
|
|
35
35
|
|
|
36
36
|
const LEVEL_ROW_CLASS: Record<EventLevel, string> = {
|
|
37
|
-
default: 'text-gray-1000 hover:bg-gray-
|
|
38
|
-
muted: 'text-gray-700 hover:bg-gray-
|
|
37
|
+
default: 'text-gray-1000 hover:bg-gray-100',
|
|
38
|
+
muted: 'text-gray-700 hover:bg-gray-100',
|
|
39
39
|
warning: 'bg-amber-100 text-amber-900 hover:bg-amber-200',
|
|
40
40
|
error: 'bg-red-100 text-red-900 hover:bg-red-200',
|
|
41
41
|
};
|
|
@@ -49,8 +49,8 @@ const LEVEL_SEPARATOR_CLASS: Record<EventLevel, string> = {
|
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
const LEVEL_SELECTED_CLASS: Record<EventLevel, string> = {
|
|
52
|
-
default: 'bg-
|
|
53
|
-
muted: 'bg-
|
|
52
|
+
default: 'bg-blue-300 hover:bg-blue-300',
|
|
53
|
+
muted: 'bg-blue-300 hover:bg-blue-300',
|
|
54
54
|
warning: 'bg-amber-300 hover:bg-amber-300',
|
|
55
55
|
error: 'bg-red-300 hover:bg-red-300',
|
|
56
56
|
};
|
|
@@ -147,7 +147,7 @@ export function EventListHeader({
|
|
|
147
147
|
return (
|
|
148
148
|
<div
|
|
149
149
|
role="row"
|
|
150
|
-
className="
|
|
150
|
+
className="flex h-10 shrink-0 items-center border-b border-gray-alpha-400 px-1 font-sans text-label-14 text-gray-900"
|
|
151
151
|
>
|
|
152
152
|
<div className={cn(CELL, COL.level)} />
|
|
153
153
|
{showOccurred ? (
|
|
@@ -159,8 +159,8 @@ export function EventListHeader({
|
|
|
159
159
|
sortButton('Time')
|
|
160
160
|
)}
|
|
161
161
|
<div className={cn(CELL, COL.since)} />
|
|
162
|
-
<div className={cn(CELL, COL.event)}>Event</div>
|
|
163
162
|
<div className={cn(CELL, COL.name)}>Name</div>
|
|
163
|
+
<div className={cn(CELL, COL.event)}>Event</div>
|
|
164
164
|
<div
|
|
165
165
|
className={cn(CELL, 'min-w-0 flex-1 h-3.5 border-l border-gray-400')}
|
|
166
166
|
>
|
|
@@ -194,8 +194,8 @@ export interface EventRowProps {
|
|
|
194
194
|
isSelected: boolean;
|
|
195
195
|
/** The one row Tab lands on (roving tabindex): the selection, else the first row. */
|
|
196
196
|
isTabStop: boolean;
|
|
197
|
-
/**
|
|
198
|
-
|
|
197
|
+
/** Whether the row belongs to the selected event's step, hook, wait or run. */
|
|
198
|
+
relation?: 'related' | 'unrelated';
|
|
199
199
|
onSelect: (event: Event) => void;
|
|
200
200
|
/** Show occurredAt separately instead of folding it into the Created timestamp. */
|
|
201
201
|
showSeparateEventOccurrenceTimestamps?: boolean;
|
|
@@ -206,7 +206,7 @@ export function EventRow({
|
|
|
206
206
|
index,
|
|
207
207
|
isSelected,
|
|
208
208
|
isTabStop,
|
|
209
|
-
|
|
209
|
+
relation,
|
|
210
210
|
onSelect,
|
|
211
211
|
showSeparateEventOccurrenceTimestamps = false,
|
|
212
212
|
}: EventRowProps) {
|
|
@@ -215,10 +215,11 @@ export function EventRow({
|
|
|
215
215
|
const displayedAt = showSeparateEventOccurrenceTimestamps
|
|
216
216
|
? new Date(event.createdAt)
|
|
217
217
|
: getEffectiveEventDate(event);
|
|
218
|
-
const zebra = (level === 'default' || level === 'muted') && index % 2 === 1;
|
|
219
218
|
// Tinted rows keep one color throughout.
|
|
220
|
-
const
|
|
221
|
-
|
|
219
|
+
const isTinted = level === 'warning' || level === 'error';
|
|
220
|
+
const isRelated = relation === 'related';
|
|
221
|
+
const isMuted = relation === 'unrelated' && !isTinted;
|
|
222
|
+
const secondaryClass = isTinted || isMuted ? undefined : 'text-gray-900';
|
|
222
223
|
|
|
223
224
|
return (
|
|
224
225
|
<div
|
|
@@ -236,7 +237,9 @@ export function EventRow({
|
|
|
236
237
|
className={cn(
|
|
237
238
|
'mx-1 mt-px flex h-6 cursor-pointer items-center rounded-md font-mono text-[13px] leading-5 outline-none focus-visible:relative focus-visible:z-10 focus-visible:shadow-[0_0_0_2px_var(--ds-focus-color)]',
|
|
238
239
|
LEVEL_ROW_CLASS[level],
|
|
239
|
-
|
|
240
|
+
!isTinted && !relation && index % 2 === 1 && 'bg-background-200',
|
|
241
|
+
isRelated && !isTinted && 'bg-blue-300/50 hover:bg-blue-300/75',
|
|
242
|
+
isMuted && 'text-gray-700 [&_svg]:text-gray-700',
|
|
240
243
|
isSelected && LEVEL_SELECTED_CLASS[level]
|
|
241
244
|
)}
|
|
242
245
|
>
|
|
@@ -255,16 +258,6 @@ export function EventRow({
|
|
|
255
258
|
? formatSinceStart(row.sinceStartMs)
|
|
256
259
|
: ''}
|
|
257
260
|
</div>
|
|
258
|
-
<div className={cn(CELL, COL.event)}>
|
|
259
|
-
<EventNoticeTooltip notice={notice}>
|
|
260
|
-
<span
|
|
261
|
-
className={cn('truncate', notice && 'line-through')}
|
|
262
|
-
title={event.eventType}
|
|
263
|
-
>
|
|
264
|
-
{event.eventType}
|
|
265
|
-
</span>
|
|
266
|
-
</EventNoticeTooltip>
|
|
267
|
-
</div>
|
|
268
261
|
<div className={cn(CELL, COL.name, 'gap-2')} title={name || undefined}>
|
|
269
262
|
<ResourceIcon
|
|
270
263
|
resource={row.resource}
|
|
@@ -275,13 +268,24 @@ export function EventRow({
|
|
|
275
268
|
<span
|
|
276
269
|
className={cn(
|
|
277
270
|
'-mx-1 truncate rounded px-1',
|
|
278
|
-
isRelated && '
|
|
271
|
+
isRelated && 'text-blue-900',
|
|
272
|
+
isRelated && isTinted && 'bg-blue-100'
|
|
279
273
|
)}
|
|
280
274
|
>
|
|
281
275
|
{name}
|
|
282
276
|
</span>
|
|
283
277
|
) : null}
|
|
284
278
|
</div>
|
|
279
|
+
<div className={cn(CELL, COL.event)}>
|
|
280
|
+
<EventNoticeTooltip notice={notice}>
|
|
281
|
+
<span
|
|
282
|
+
className={cn('truncate', notice && 'line-through')}
|
|
283
|
+
title={event.eventType}
|
|
284
|
+
>
|
|
285
|
+
{event.eventType}
|
|
286
|
+
</span>
|
|
287
|
+
</EventNoticeTooltip>
|
|
288
|
+
</div>
|
|
285
289
|
<div
|
|
286
290
|
className={cn(
|
|
287
291
|
CELL,
|
|
@@ -315,7 +319,7 @@ export function EventRowsSkeleton() {
|
|
|
315
319
|
key={i}
|
|
316
320
|
className={cn(
|
|
317
321
|
'mx-1 mt-px flex h-6 items-center rounded-md',
|
|
318
|
-
i % 2 === 1 && 'bg-
|
|
322
|
+
i % 2 === 1 && 'bg-background-200'
|
|
319
323
|
)}
|
|
320
324
|
>
|
|
321
325
|
<div className={cn(CELL, COL.level)} />
|
|
@@ -325,12 +329,12 @@ export function EventRowsSkeleton() {
|
|
|
325
329
|
<div className={cn(CELL, COL.since)}>
|
|
326
330
|
<Skeleton className="h-3 w-12" />
|
|
327
331
|
</div>
|
|
328
|
-
<div className={cn(CELL, COL.event)}>
|
|
329
|
-
<Skeleton className="h-3 w-[104px]" />
|
|
330
|
-
</div>
|
|
331
332
|
<div className={cn(CELL, COL.name)}>
|
|
332
333
|
<Skeleton className="h-3 w-24" />
|
|
333
334
|
</div>
|
|
335
|
+
<div className={cn(CELL, COL.event)}>
|
|
336
|
+
<Skeleton className="h-3 w-[104px]" />
|
|
337
|
+
</div>
|
|
334
338
|
<div className={cn(CELL, 'min-w-0 flex-1')}>
|
|
335
339
|
<Skeleton
|
|
336
340
|
className="h-3"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import type { Event } from '@workflow/world';
|
|
4
|
-
import { useEffect, useMemo, useState } from 'react';
|
|
4
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
5
5
|
import type { EventSearchState } from '../../lib/event-list-model';
|
|
6
6
|
import {
|
|
7
7
|
type ExactIdSearchResult,
|
|
@@ -12,12 +12,17 @@ import {
|
|
|
12
12
|
/** How long typing has to pause before an exact-ID lookup is sent. */
|
|
13
13
|
const EXACT_SEARCH_DEBOUNCE_MS = 300;
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
type ExactSearchOutcome = { query: string } & (
|
|
15
|
+
type ExactSearchAnswer =
|
|
17
16
|
| { status: 'ok'; events: Event[]; truncated: boolean }
|
|
18
17
|
| { status: 'not_found' }
|
|
19
|
-
| { status: 'error'; message
|
|
20
|
-
|
|
18
|
+
| { status: 'error'; message?: string };
|
|
19
|
+
|
|
20
|
+
/** A settled exact-ID lookup, for the query and attempt it answered. */
|
|
21
|
+
type ExactSearchOutcome = {
|
|
22
|
+
query: string;
|
|
23
|
+
attempt: number;
|
|
24
|
+
answer: ExactSearchAnswer;
|
|
25
|
+
};
|
|
21
26
|
|
|
22
27
|
export type ExactSearchHandler = (
|
|
23
28
|
id: string,
|
|
@@ -28,15 +33,18 @@ export type ExactSearchHandler = (
|
|
|
28
33
|
/**
|
|
29
34
|
* The Events tab search box. The input text is the only thing typed; the
|
|
30
35
|
* search state is derived from it plus the latest settled exact-ID lookup, so
|
|
31
|
-
* a lookup that answered an older query is never shown for the
|
|
36
|
+
* a lookup that answered an older query or attempt is never shown for the
|
|
37
|
+
* current one.
|
|
32
38
|
*/
|
|
33
39
|
export function useEventSearch(onExactIdSearch?: ExactSearchHandler): {
|
|
34
40
|
query: string;
|
|
35
41
|
setQuery: (query: string) => void;
|
|
36
42
|
search: EventSearchState;
|
|
43
|
+
retry: () => void;
|
|
37
44
|
} {
|
|
38
45
|
const [query, setQuery] = useState('');
|
|
39
46
|
const [outcome, setOutcome] = useState<ExactSearchOutcome | null>(null);
|
|
47
|
+
const [attempt, setAttempt] = useState(0);
|
|
40
48
|
|
|
41
49
|
const trimmed = query.trim();
|
|
42
50
|
const parsed = useMemo(() => parseExactWorkflowSearchId(trimmed), [trimmed]);
|
|
@@ -47,7 +55,7 @@ export function useEventSearch(onExactIdSearch?: ExactSearchHandler): {
|
|
|
47
55
|
// Aborted when the query changes, so a superseded lookup never settles.
|
|
48
56
|
const abortController = new AbortController();
|
|
49
57
|
const timer = setTimeout(async () => {
|
|
50
|
-
let
|
|
58
|
+
let answer: ExactSearchAnswer;
|
|
51
59
|
try {
|
|
52
60
|
const result = await onExactIdSearch(
|
|
53
61
|
parsed.id,
|
|
@@ -55,28 +63,25 @@ export function useEventSearch(onExactIdSearch?: ExactSearchHandler): {
|
|
|
55
63
|
abortController.signal
|
|
56
64
|
);
|
|
57
65
|
if (result.status === 'error') {
|
|
58
|
-
|
|
66
|
+
answer = result;
|
|
59
67
|
} else if (
|
|
60
68
|
result.status === 'not_found' ||
|
|
61
69
|
result.events.length === 0
|
|
62
70
|
) {
|
|
63
|
-
|
|
71
|
+
answer = { status: 'not_found' };
|
|
64
72
|
} else {
|
|
65
|
-
|
|
66
|
-
query: trimmed,
|
|
73
|
+
answer = {
|
|
67
74
|
status: 'ok',
|
|
68
75
|
events: result.events,
|
|
69
76
|
truncated: Boolean(result.truncated),
|
|
70
77
|
};
|
|
71
78
|
}
|
|
72
79
|
} catch {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
};
|
|
80
|
+
answer = { status: 'error' };
|
|
81
|
+
}
|
|
82
|
+
if (!abortController.signal.aborted) {
|
|
83
|
+
setOutcome({ query: trimmed, attempt, answer });
|
|
78
84
|
}
|
|
79
|
-
if (!abortController.signal.aborted) setOutcome(next);
|
|
80
85
|
}, EXACT_SEARCH_DEBOUNCE_MS);
|
|
81
86
|
|
|
82
87
|
return () => {
|
|
@@ -86,7 +91,9 @@ export function useEventSearch(onExactIdSearch?: ExactSearchHandler): {
|
|
|
86
91
|
// answer it had before.
|
|
87
92
|
setOutcome(null);
|
|
88
93
|
};
|
|
89
|
-
}, [trimmed, parsed, onExactIdSearch]);
|
|
94
|
+
}, [trimmed, parsed, onExactIdSearch, attempt]);
|
|
95
|
+
|
|
96
|
+
const retry = useCallback(() => setAttempt((n) => n + 1), []);
|
|
90
97
|
|
|
91
98
|
const search = useMemo((): EventSearchState => {
|
|
92
99
|
if (!trimmed) return { status: 'idle' };
|
|
@@ -94,11 +101,11 @@ export function useEventSearch(onExactIdSearch?: ExactSearchHandler): {
|
|
|
94
101
|
return { status: 'incomplete', query: trimmed };
|
|
95
102
|
}
|
|
96
103
|
if (!onExactIdSearch) return { status: 'unavailable', query: trimmed };
|
|
97
|
-
if (outcome?.query !== trimmed) {
|
|
104
|
+
if (outcome?.query !== trimmed || outcome.attempt !== attempt) {
|
|
98
105
|
return { status: 'loading', query: trimmed, id: parsed };
|
|
99
106
|
}
|
|
100
|
-
return { ...outcome, id: parsed };
|
|
101
|
-
}, [trimmed, parsed, onExactIdSearch, outcome]);
|
|
107
|
+
return { ...outcome.answer, query: trimmed, id: parsed };
|
|
108
|
+
}, [trimmed, parsed, onExactIdSearch, outcome, attempt]);
|
|
102
109
|
|
|
103
|
-
return { query, setQuery, search };
|
|
110
|
+
return { query, setQuery, search, retry };
|
|
104
111
|
}
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import type { Event, WorkflowRun } from '@workflow/world';
|
|
4
|
+
import { AlertCircle } from 'lucide-react';
|
|
4
5
|
import type { KeyboardEvent as ReactKeyboardEvent } from 'react';
|
|
5
6
|
import { useCallback, useMemo, useRef, useState } from 'react';
|
|
6
7
|
import { Virtuoso, type VirtuosoHandle } from 'react-virtuoso';
|
|
8
|
+
import { cn } from '../lib/cn';
|
|
7
9
|
import { findDuplicateEventIds } from '../lib/duplicate-events';
|
|
8
10
|
import {
|
|
9
11
|
buildEventLookups,
|
|
10
12
|
buildEventRow,
|
|
11
13
|
buildListItems,
|
|
14
|
+
type EventSearchState,
|
|
12
15
|
getEmptyMessage,
|
|
13
16
|
getEventEntity,
|
|
14
17
|
getFooterLabel,
|
|
15
18
|
getListSource,
|
|
19
|
+
getSearchHint,
|
|
16
20
|
mergeEventsById,
|
|
17
21
|
sortEventsByTime,
|
|
18
22
|
} from '../lib/event-list-model';
|
|
@@ -30,9 +34,9 @@ import {
|
|
|
30
34
|
useEventSearch,
|
|
31
35
|
} from './event-list/use-event-search';
|
|
32
36
|
import { useDetailPanelWidth } from './trace-viewer/components/use-detail-panel-width';
|
|
37
|
+
import { Button } from './ui/button';
|
|
33
38
|
import { ContextCardProvider } from './ui/context-card';
|
|
34
39
|
import { DecryptClickContext } from './ui/data-inspector';
|
|
35
|
-
import { LoadMoreButton } from './ui/load-more-button';
|
|
36
40
|
import { TooltipProvider } from './ui/tooltip';
|
|
37
41
|
|
|
38
42
|
interface EventsListProps {
|
|
@@ -65,6 +69,38 @@ interface EventsListProps {
|
|
|
65
69
|
onViewInTrace?: (spanId: string) => void;
|
|
66
70
|
}
|
|
67
71
|
|
|
72
|
+
function EmptyState({
|
|
73
|
+
search,
|
|
74
|
+
onRetry,
|
|
75
|
+
}: {
|
|
76
|
+
search: EventSearchState;
|
|
77
|
+
onRetry: () => void;
|
|
78
|
+
}) {
|
|
79
|
+
if (search.status === 'error') {
|
|
80
|
+
return (
|
|
81
|
+
<div className="flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center">
|
|
82
|
+
<div className="flex flex-col items-center gap-1">
|
|
83
|
+
<div className="flex items-center gap-2 text-label-14 font-medium text-gray-1000">
|
|
84
|
+
<AlertCircle className="h-4 w-4 shrink-0 text-red-800" />
|
|
85
|
+
Failed to search events
|
|
86
|
+
</div>
|
|
87
|
+
{search.message ? (
|
|
88
|
+
<p className="m-0 text-copy-13 text-gray-900">{search.message}</p>
|
|
89
|
+
) : null}
|
|
90
|
+
</div>
|
|
91
|
+
<Button variant="secondary" size="small" onClick={onRetry}>
|
|
92
|
+
Try again
|
|
93
|
+
</Button>
|
|
94
|
+
</div>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
return (
|
|
98
|
+
<div className="flex flex-1 items-center justify-center px-6 text-center text-copy-14 text-gray-900">
|
|
99
|
+
{getEmptyMessage(search)}
|
|
100
|
+
</div>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
68
104
|
function EventListViewInner({
|
|
69
105
|
events,
|
|
70
106
|
run,
|
|
@@ -92,7 +128,7 @@ function EventListViewInner({
|
|
|
92
128
|
const bodyRef = useRef<HTMLDivElement>(null);
|
|
93
129
|
|
|
94
130
|
const [selectedEventId, setSelectedEventId] = useState<string | undefined>();
|
|
95
|
-
const { query, setQuery, search } = useEventSearch(onExactIdSearch);
|
|
131
|
+
const { query, setQuery, search, retry } = useEventSearch(onExactIdSearch);
|
|
96
132
|
const list = getListSource(search, { events, hasMore: hasMoreEvents });
|
|
97
133
|
|
|
98
134
|
// Rows come from the list's source; names and timings from every event on
|
|
@@ -152,6 +188,28 @@ function EventListViewInner({
|
|
|
152
188
|
: search.id.id
|
|
153
189
|
: (selectedRow?.entity.key ?? null);
|
|
154
190
|
|
|
191
|
+
const [visibleRange, setVisibleRange] = useState({
|
|
192
|
+
startIndex: 0,
|
|
193
|
+
endIndex: 0,
|
|
194
|
+
});
|
|
195
|
+
const relatedIndexes = useMemo(
|
|
196
|
+
() =>
|
|
197
|
+
listItems.flatMap((item, i) =>
|
|
198
|
+
item.kind === 'event' && item.row.entity.key === relatedKey ? [i] : []
|
|
199
|
+
),
|
|
200
|
+
[listItems, relatedKey]
|
|
201
|
+
);
|
|
202
|
+
const relatedAbove = relatedIndexes.filter(
|
|
203
|
+
(i) => i < visibleRange.startIndex
|
|
204
|
+
);
|
|
205
|
+
const relatedBelow = relatedIndexes.filter((i) => i > visibleRange.endIndex);
|
|
206
|
+
const scrollToItem = (index: number) =>
|
|
207
|
+
virtuosoRef.current?.scrollToIndex({
|
|
208
|
+
index,
|
|
209
|
+
align: 'center',
|
|
210
|
+
behavior: 'smooth',
|
|
211
|
+
});
|
|
212
|
+
|
|
155
213
|
// Event data cache: ref avoids re-renders when cache updates
|
|
156
214
|
const eventDataCacheRef = useRef<Map<string, unknown>>(new Map());
|
|
157
215
|
const cacheEventData = useCallback((eventId: string, data: unknown) => {
|
|
@@ -220,7 +278,13 @@ function EventListViewInner({
|
|
|
220
278
|
|
|
221
279
|
const panelWidth = useDetailPanelWidth(bodyRef, selectedRow !== undefined);
|
|
222
280
|
|
|
223
|
-
const toolbar =
|
|
281
|
+
const toolbar = (
|
|
282
|
+
<EventListToolbar
|
|
283
|
+
query={query}
|
|
284
|
+
hint={getSearchHint(search)}
|
|
285
|
+
onQueryChange={setQuery}
|
|
286
|
+
/>
|
|
287
|
+
);
|
|
224
288
|
|
|
225
289
|
if (isInitialLoad) {
|
|
226
290
|
return (
|
|
@@ -266,54 +330,73 @@ function EventListViewInner({
|
|
|
266
330
|
{isRefetching || search.status === 'loading' ? (
|
|
267
331
|
<EventRowsSkeleton />
|
|
268
332
|
) : rows.length === 0 ? (
|
|
269
|
-
<
|
|
270
|
-
{getEmptyMessage(search)}
|
|
271
|
-
</div>
|
|
333
|
+
<EmptyState search={search} onRetry={retry} />
|
|
272
334
|
) : (
|
|
273
|
-
<
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
335
|
+
<div className="relative flex min-h-0 flex-1 flex-col">
|
|
336
|
+
<Virtuoso
|
|
337
|
+
ref={virtuosoRef}
|
|
338
|
+
rangeChanged={setVisibleRange}
|
|
339
|
+
totalCount={listItems.length}
|
|
340
|
+
overscan={20}
|
|
341
|
+
defaultItemHeight={25}
|
|
342
|
+
computeItemKey={(i) => {
|
|
343
|
+
const item = listItems[i];
|
|
344
|
+
return item.kind === 'gap'
|
|
345
|
+
? item.key
|
|
346
|
+
: item.row.event.eventId;
|
|
347
|
+
}}
|
|
348
|
+
endReached={() => {
|
|
349
|
+
if (list.hasMore && !isLoadingMoreEvents) {
|
|
350
|
+
void onLoadMoreEvents?.();
|
|
351
|
+
}
|
|
352
|
+
}}
|
|
353
|
+
components={{ Footer: () => <div className="h-2" /> }}
|
|
354
|
+
itemContent={(i: number) => {
|
|
355
|
+
const item = listItems[i];
|
|
356
|
+
if (item.kind === 'gap') {
|
|
357
|
+
return <IdleGapRow ms={item.ms} reason={item.reason} />;
|
|
358
|
+
}
|
|
359
|
+
const { row } = item;
|
|
360
|
+
const isSelected = selectedEventId === row.event.eventId;
|
|
361
|
+
return (
|
|
362
|
+
<EventRow
|
|
363
|
+
row={row}
|
|
364
|
+
index={item.index}
|
|
365
|
+
isSelected={isSelected}
|
|
366
|
+
isTabStop={
|
|
367
|
+
selectedIndex === -1 ? item.index === 0 : isSelected
|
|
368
|
+
}
|
|
369
|
+
relation={
|
|
370
|
+
relatedKey === null
|
|
371
|
+
? undefined
|
|
372
|
+
: row.entity.key === relatedKey
|
|
373
|
+
? 'related'
|
|
374
|
+
: 'unrelated'
|
|
375
|
+
}
|
|
376
|
+
onSelect={toggleSelectedEvent}
|
|
377
|
+
showSeparateEventOccurrenceTimestamps={
|
|
378
|
+
showSeparateEventOccurrenceTimestamps
|
|
379
|
+
}
|
|
380
|
+
/>
|
|
381
|
+
);
|
|
382
|
+
}}
|
|
383
|
+
style={{ flex: 1, minHeight: 0 }}
|
|
384
|
+
/>
|
|
385
|
+
{relatedAbove.length > 0 && (
|
|
386
|
+
<RelatedHint
|
|
387
|
+
direction="above"
|
|
388
|
+
count={relatedAbove.length}
|
|
389
|
+
onClick={() => scrollToItem(relatedAbove.at(-1) ?? 0)}
|
|
390
|
+
/>
|
|
391
|
+
)}
|
|
392
|
+
{relatedBelow.length > 0 && (
|
|
393
|
+
<RelatedHint
|
|
394
|
+
direction="below"
|
|
395
|
+
count={relatedBelow.length}
|
|
396
|
+
onClick={() => scrollToItem(relatedBelow[0])}
|
|
397
|
+
/>
|
|
398
|
+
)}
|
|
399
|
+
</div>
|
|
317
400
|
)}
|
|
318
401
|
|
|
319
402
|
<div className="relative flex h-10 shrink-0 items-center border-t border-gray-alpha-400 px-4 text-label-13 text-gray-900">
|
|
@@ -326,10 +409,13 @@ function EventListViewInner({
|
|
|
326
409
|
{list.hasMore && (
|
|
327
410
|
<div className="pointer-events-none absolute inset-0 flex items-center justify-center">
|
|
328
411
|
<div className="pointer-events-auto">
|
|
329
|
-
<
|
|
412
|
+
<Button
|
|
413
|
+
variant="secondary"
|
|
330
414
|
loading={isLoadingMoreEvents}
|
|
331
415
|
onClick={() => void onLoadMoreEvents?.()}
|
|
332
|
-
|
|
416
|
+
>
|
|
417
|
+
Load more
|
|
418
|
+
</Button>
|
|
333
419
|
</div>
|
|
334
420
|
</div>
|
|
335
421
|
)}
|
|
@@ -362,6 +448,48 @@ function EventListViewInner({
|
|
|
362
448
|
);
|
|
363
449
|
}
|
|
364
450
|
|
|
451
|
+
function RelatedHint({
|
|
452
|
+
direction,
|
|
453
|
+
count,
|
|
454
|
+
onClick,
|
|
455
|
+
}: {
|
|
456
|
+
direction: 'above' | 'below';
|
|
457
|
+
count: number;
|
|
458
|
+
onClick: () => void;
|
|
459
|
+
}) {
|
|
460
|
+
const label = `${count} related ${count === 1 ? 'event' : 'events'}`;
|
|
461
|
+
const layer = cn('absolute inset-0', direction === 'above' && '-scale-y-100');
|
|
462
|
+
return (
|
|
463
|
+
<button
|
|
464
|
+
type="button"
|
|
465
|
+
aria-label={`${label} ${direction}`}
|
|
466
|
+
onClick={onClick}
|
|
467
|
+
className={cn(
|
|
468
|
+
'group absolute inset-x-0 z-10 flex h-10 cursor-pointer justify-end px-3 py-2 outline-none transition-opacity duration-200 ease-[cubic-bezier(0.23,1,0.32,1)] focus-visible:shadow-[inset_0_0_0_2px_var(--ds-focus-color)] starting:opacity-0',
|
|
469
|
+
direction === 'above' ? 'top-0 items-start' : 'bottom-0 items-end'
|
|
470
|
+
)}
|
|
471
|
+
>
|
|
472
|
+
<span
|
|
473
|
+
aria-hidden
|
|
474
|
+
className={cn(
|
|
475
|
+
layer,
|
|
476
|
+
'bg-[linear-gradient(to_top,color-mix(in_oklab,var(--ds-background-100)_70%,transparent),30%,transparent)]'
|
|
477
|
+
)}
|
|
478
|
+
/>
|
|
479
|
+
<span
|
|
480
|
+
aria-hidden
|
|
481
|
+
className={cn(
|
|
482
|
+
layer,
|
|
483
|
+
'bg-[linear-gradient(to_top,color-mix(in_oklab,var(--ds-blue-500)_60%,transparent),30%,transparent)] opacity-45 transition-opacity duration-300 ease-[ease] group-hover:opacity-100 group-hover:duration-150 group-focus-visible:opacity-100 group-active:opacity-75 group-active:duration-75'
|
|
484
|
+
)}
|
|
485
|
+
/>
|
|
486
|
+
<span className="relative font-medium text-label-12 text-blue-900">
|
|
487
|
+
{label}
|
|
488
|
+
</span>
|
|
489
|
+
</button>
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
|
|
365
493
|
export function EventListView(props: EventsListProps) {
|
|
366
494
|
return (
|
|
367
495
|
<TooltipProvider delayDuration={300}>
|