@workflow/web-shared 5.2.0 → 5.3.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.
Files changed (168) hide show
  1. package/dist/components/event-list/event-details-panel.d.ts.map +1 -1
  2. package/dist/components/event-list/event-details-panel.js +3 -3
  3. package/dist/components/event-list/event-list-toolbar.d.ts +2 -1
  4. package/dist/components/event-list/event-list-toolbar.d.ts.map +1 -1
  5. package/dist/components/event-list/event-list-toolbar.js +20 -11
  6. package/dist/components/event-list/event-row.d.ts +3 -3
  7. package/dist/components/event-list/event-row.d.ts.map +1 -1
  8. package/dist/components/event-list/event-row.js +15 -13
  9. package/dist/components/event-list/use-event-search.d.ts +3 -1
  10. package/dist/components/event-list/use-event-search.d.ts.map +1 -1
  11. package/dist/components/event-list/use-event-search.js +19 -20
  12. package/dist/components/event-list-view.d.ts.map +1 -1
  13. package/dist/components/event-list-view.js +53 -24
  14. package/dist/components/hook-actions.d.ts +0 -1
  15. package/dist/components/hook-actions.d.ts.map +1 -1
  16. package/dist/components/hook-actions.js +1 -3
  17. package/dist/components/index.d.ts +5 -9
  18. package/dist/components/index.d.ts.map +1 -1
  19. package/dist/components/index.js +4 -9
  20. package/dist/components/sidebar/attribute-panel.d.ts +0 -13
  21. package/dist/components/sidebar/attribute-panel.d.ts.map +1 -1
  22. package/dist/components/sidebar/attribute-panel.js +5 -5
  23. package/dist/components/sidebar/attributes-block.d.ts +0 -7
  24. package/dist/components/sidebar/attributes-block.d.ts.map +1 -1
  25. package/dist/components/sidebar/attributes-block.js +5 -5
  26. package/dist/components/sidebar/conversation-view.d.ts.map +1 -1
  27. package/dist/components/sidebar/conversation-view.js +4 -3
  28. package/dist/components/sidebar/copyable-data-block.d.ts.map +1 -1
  29. package/dist/components/sidebar/copyable-data-block.js +8 -6
  30. package/dist/components/sidebar/entity-detail-panel.d.ts.map +1 -1
  31. package/dist/components/sidebar/entity-detail-panel.js +2 -3
  32. package/dist/components/stream-image-preview.js +2 -2
  33. package/dist/components/stream-viewer.js +3 -3
  34. package/dist/components/trace-viewer/components/middle-truncate/truncate.d.ts +1 -4
  35. package/dist/components/trace-viewer/components/middle-truncate/truncate.d.ts.map +1 -1
  36. package/dist/components/trace-viewer/components/middle-truncate/truncate.js +2 -2
  37. package/dist/components/trace-viewer/components/minimap.d.ts.map +1 -1
  38. package/dist/components/trace-viewer/components/minimap.js +6 -4
  39. package/dist/components/trace-viewer/components/timeline.d.ts +0 -11
  40. package/dist/components/trace-viewer/components/timeline.d.ts.map +1 -1
  41. package/dist/components/trace-viewer/components/timeline.js +1 -2
  42. package/dist/components/trace-viewer/trace-viewer.js +4 -10
  43. package/dist/components/ui/button.d.ts +28 -17
  44. package/dist/components/ui/button.d.ts.map +1 -1
  45. package/dist/components/ui/button.js +47 -43
  46. package/dist/components/ui/context-card.js +3 -3
  47. package/dist/components/ui/copy-button.d.ts +15 -0
  48. package/dist/components/ui/copy-button.d.ts.map +1 -0
  49. package/dist/components/ui/copy-button.js +41 -0
  50. package/dist/components/ui/data-inspector.d.ts.map +1 -1
  51. package/dist/components/ui/data-inspector.js +8 -38
  52. package/dist/components/ui/decrypt-button.d.ts +3 -2
  53. package/dist/components/ui/decrypt-button.d.ts.map +1 -1
  54. package/dist/components/ui/decrypt-button.js +13 -7
  55. package/dist/components/ui/duplicate-event-tooltip.d.ts +1 -9
  56. package/dist/components/ui/duplicate-event-tooltip.d.ts.map +1 -1
  57. package/dist/components/ui/duplicate-event-tooltip.js +2 -10
  58. package/dist/components/ui/error-stack-block.js +3 -3
  59. package/dist/components/ui/icon-button.d.ts +2 -2
  60. package/dist/components/ui/icon-button.d.ts.map +1 -1
  61. package/dist/components/ui/icon-button.js +2 -3
  62. package/dist/components/ui/kbd.d.ts +1 -1
  63. package/dist/components/ui/kbd.d.ts.map +1 -1
  64. package/dist/components/ui/kbd.js +1 -2
  65. package/dist/components/ui/search-input.d.ts +19 -0
  66. package/dist/components/ui/search-input.d.ts.map +1 -0
  67. package/dist/components/ui/search-input.js +61 -0
  68. package/dist/components/ui/spinner.d.ts +54 -6
  69. package/dist/components/ui/spinner.d.ts.map +1 -1
  70. package/dist/components/ui/spinner.js +84 -46
  71. package/dist/components/workflow-traces/trace-span-construction.d.ts +1 -22
  72. package/dist/components/workflow-traces/trace-span-construction.d.ts.map +1 -1
  73. package/dist/components/workflow-traces/trace-span-construction.js +3 -3
  74. package/dist/index.d.ts +9 -14
  75. package/dist/index.d.ts.map +1 -1
  76. package/dist/index.js +8 -11
  77. package/dist/lib/event-analysis.d.ts +1 -25
  78. package/dist/lib/event-analysis.d.ts.map +1 -1
  79. package/dist/lib/event-analysis.js +2 -75
  80. package/dist/lib/event-list-model.d.ts +4 -2
  81. package/dist/lib/event-list-model.d.ts.map +1 -1
  82. package/dist/lib/event-list-model.js +13 -11
  83. package/dist/lib/exact-event-search-id.d.ts +0 -2
  84. package/dist/lib/exact-event-search-id.d.ts.map +1 -1
  85. package/dist/lib/exact-event-search-id.js +1 -12
  86. package/dist/lib/hydration.d.ts +1 -12
  87. package/dist/lib/hydration.d.ts.map +1 -1
  88. package/dist/lib/hydration.js +8 -20
  89. package/dist/lib/stream-display.d.ts +0 -1
  90. package/dist/lib/stream-display.d.ts.map +1 -1
  91. package/dist/lib/stream-display.js +2 -2
  92. package/dist/lib/trace-builder.d.ts +0 -8
  93. package/dist/lib/trace-builder.d.ts.map +1 -1
  94. package/dist/lib/trace-builder.js +2 -2
  95. package/dist/lib/utils.d.ts +0 -22
  96. package/dist/lib/utils.d.ts.map +1 -1
  97. package/dist/lib/utils.js +1 -31
  98. package/dist/styles.css +268 -118
  99. package/package.json +4 -16
  100. package/src/components/event-list/event-details-panel.tsx +3 -4
  101. package/src/components/event-list/event-list-toolbar.tsx +35 -28
  102. package/src/components/event-list/event-row.tsx +33 -29
  103. package/src/components/event-list/use-event-search.ts +29 -22
  104. package/src/components/event-list-view.tsx +180 -52
  105. package/src/components/hook-actions.tsx +0 -1
  106. package/src/components/index.ts +4 -20
  107. package/src/components/sidebar/attribute-panel.tsx +4 -7
  108. package/src/components/sidebar/attributes-block.tsx +7 -6
  109. package/src/components/sidebar/conversation-view.tsx +3 -2
  110. package/src/components/sidebar/copyable-data-block.tsx +17 -14
  111. package/src/components/sidebar/entity-detail-panel.tsx +2 -7
  112. package/src/components/stream-image-preview.tsx +1 -1
  113. package/src/components/stream-viewer.tsx +4 -4
  114. package/src/components/trace-viewer/components/middle-truncate/truncate.ts +1 -2
  115. package/src/components/trace-viewer/components/minimap.tsx +4 -3
  116. package/src/components/trace-viewer/components/timeline.tsx +0 -2
  117. package/src/components/trace-viewer/trace-viewer.tsx +12 -38
  118. package/src/components/ui/button.tsx +144 -46
  119. package/src/components/ui/context-card.tsx +2 -2
  120. package/src/components/ui/copy-button.tsx +86 -0
  121. package/src/components/ui/data-inspector.tsx +23 -67
  122. package/src/components/ui/decrypt-button.tsx +23 -48
  123. package/src/components/ui/duplicate-event-tooltip.tsx +1 -22
  124. package/src/components/ui/error-stack-block.tsx +4 -4
  125. package/src/components/ui/icon-button.tsx +1 -3
  126. package/src/components/ui/kbd.tsx +0 -2
  127. package/src/components/ui/search-input.tsx +143 -0
  128. package/src/components/ui/spinner.tsx +105 -55
  129. package/src/components/workflow-traces/trace-span-construction.ts +2 -2
  130. package/src/index.ts +7 -55
  131. package/src/lib/event-analysis.ts +1 -104
  132. package/src/lib/event-list-model.ts +15 -12
  133. package/src/lib/exact-event-search-id.ts +0 -13
  134. package/src/lib/hydration.ts +6 -31
  135. package/src/lib/stream-display.ts +1 -1
  136. package/src/lib/trace-builder.ts +1 -1
  137. package/src/lib/utils.ts +0 -48
  138. package/src/styles.css +268 -118
  139. package/dist/components/trace-viewer/components/copy-button.d.ts +0 -9
  140. package/dist/components/trace-viewer/components/copy-button.d.ts.map +0 -1
  141. package/dist/components/trace-viewer/components/copy-button.js +0 -27
  142. package/dist/components/ui/alert.d.ts +0 -9
  143. package/dist/components/ui/alert.d.ts.map +0 -1
  144. package/dist/components/ui/alert.js +0 -23
  145. package/dist/components/ui/card.d.ts +0 -9
  146. package/dist/components/ui/card.d.ts.map +0 -1
  147. package/dist/components/ui/card.js +0 -18
  148. package/dist/components/ui/load-more-button.d.ts +0 -13
  149. package/dist/components/ui/load-more-button.d.ts.map +0 -1
  150. package/dist/components/ui/load-more-button.js +0 -12
  151. package/dist/components/ui/menu-dropdown.d.ts +0 -16
  152. package/dist/components/ui/menu-dropdown.d.ts.map +0 -1
  153. package/dist/components/ui/menu-dropdown.js +0 -30
  154. package/dist/hooks/use-dark-mode.d.ts +0 -9
  155. package/dist/hooks/use-dark-mode.d.ts.map +0 -1
  156. package/dist/hooks/use-dark-mode.js +0 -30
  157. package/dist/lib/event-materialization.d.ts +0 -91
  158. package/dist/lib/event-materialization.d.ts.map +0 -1
  159. package/dist/lib/event-materialization.js +0 -219
  160. package/src/components/index.d.ts +0 -1
  161. package/src/components/trace-viewer/components/copy-button.tsx +0 -68
  162. package/src/components/ui/alert.tsx +0 -59
  163. package/src/components/ui/card.tsx +0 -79
  164. package/src/components/ui/load-more-button.tsx +0 -38
  165. package/src/components/ui/menu-dropdown.tsx +0 -97
  166. package/src/hooks/use-dark-mode.ts +0 -34
  167. package/src/index.d.ts +0 -1
  168. package/src/lib/event-materialization.ts +0 -304
@@ -4,7 +4,7 @@ import { cn } from '../../lib/cn';
4
4
 
5
5
  const iconButtonVariants = cva(
6
6
  [
7
- 'm-0 inline-flex shrink-0 appearance-none items-center justify-center border-0 bg-transparent p-0 align-baseline font-inherit no-underline [background:none] [-webkit-appearance:none] [-webkit-tap-highlight-color:transparent]',
7
+ 'm-0 inline-flex shrink-0 appearance-none items-center justify-center border-0 bg-transparent p-0 align-baseline font-inherit no-underline [-webkit-appearance:none] [-webkit-tap-highlight-color:transparent]',
8
8
  'transition-colors duration-150 ease-in-out',
9
9
  'enabled:cursor-pointer disabled:cursor-not-allowed disabled:opacity-40',
10
10
  'focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--ds-focus-color)] focus-visible:outline-offset-2',
@@ -14,8 +14,6 @@ const iconButtonVariants = cva(
14
14
  variant: {
15
15
  tertiary:
16
16
  'text-gray-900 enabled:hover:bg-gray-alpha-200 enabled:hover:text-gray-1000 enabled:active:bg-gray-alpha-200 focus-visible:text-gray-1000',
17
- muted:
18
- 'text-gray-900 enabled:hover:bg-gray-alpha-200 enabled:hover:text-gray-1000 enabled:active:bg-gray-alpha-200 focus-visible:text-gray-1000',
19
17
  },
20
18
  size: {
21
19
  tiny: 'h-6 w-6 rounded-[4px] [&_svg]:h-4 [&_svg]:w-4',
@@ -39,5 +39,3 @@ export function Kbd({
39
39
  </kbd>
40
40
  );
41
41
  }
42
-
43
- export { kbdVariants };
@@ -0,0 +1,143 @@
1
+ 'use client';
2
+
3
+ import { Search, X } from 'lucide-react';
4
+ import {
5
+ type ComponentProps,
6
+ type ReactNode,
7
+ useEffect,
8
+ useId,
9
+ useRef,
10
+ useState,
11
+ } from 'react';
12
+ import { cn } from '../../lib/cn';
13
+ import { Kbd } from './kbd';
14
+
15
+ export type SearchInputProps = Omit<
16
+ ComponentProps<'input'>,
17
+ 'value' | 'onChange' | 'type' | 'size' | 'className' | 'aria-label'
18
+ > & {
19
+ /** The current query. */
20
+ value: string;
21
+ /** Called with the new query, and with `''` when the search is cleared. */
22
+ onValueChange: (value: string) => void;
23
+ /** Accessible name of the field, rendered as a visually hidden label. */
24
+ label: string;
25
+ /** Classes for the bar, such as its left padding. */
26
+ className?: string;
27
+ };
28
+
29
+ /**
30
+ * The search bar at the top of a list or trace pane: a search icon, the
31
+ * field, and a clear button that shows while there is a query. Escape clears
32
+ * a non-empty query. The whole bar shows Geist's focus outline while the
33
+ * field has keyboard focus.
34
+ */
35
+ export function SearchInput({
36
+ value,
37
+ onValueChange,
38
+ label,
39
+ className,
40
+ id,
41
+ onKeyDown,
42
+ onFocus,
43
+ onBlur,
44
+ ...props
45
+ }: SearchInputProps): ReactNode {
46
+ const generatedId = useId();
47
+ const inputId = id ?? generatedId;
48
+ const inputRef = useRef<HTMLInputElement>(null);
49
+
50
+ // Text fields match `:focus-visible` however they were focused, clicks
51
+ // included, so the bar tracks the last input instead and draws its outline
52
+ // only when the field gains focus from the keyboard.
53
+ const lastInputRef = useRef<'keyboard' | 'pointer'>('keyboard');
54
+ const [focusVisible, setFocusVisible] = useState(false);
55
+
56
+ useEffect(() => {
57
+ const onPointerDown = () => {
58
+ lastInputRef.current = 'pointer';
59
+ };
60
+ const onDocumentKeyDown = (e: KeyboardEvent) => {
61
+ // Shortcuts such as Cmd+Tab don't move focus within the page.
62
+ if (e.metaKey || e.altKey || e.ctrlKey) return;
63
+ lastInputRef.current = 'keyboard';
64
+ };
65
+ document.addEventListener('pointerdown', onPointerDown, true);
66
+ document.addEventListener('keydown', onDocumentKeyDown, true);
67
+ return () => {
68
+ document.removeEventListener('pointerdown', onPointerDown, true);
69
+ document.removeEventListener('keydown', onDocumentKeyDown, true);
70
+ };
71
+ }, []);
72
+
73
+ const clear = () => {
74
+ onValueChange('');
75
+ inputRef.current?.focus();
76
+ };
77
+
78
+ return (
79
+ <div
80
+ className={cn(
81
+ '@container flex h-10 min-h-10 shrink-0 items-center gap-1.5 border-b border-gray-alpha-400 bg-background-100 pr-2',
82
+ focusVisible &&
83
+ '[outline:var(--ds-focus-ring-outline,2px_solid_var(--ds-focus-color))] -outline-offset-2',
84
+ className
85
+ )}
86
+ >
87
+ <label htmlFor={inputId} className="sr-only">
88
+ {label}
89
+ </label>
90
+ <Search aria-hidden className="size-3.5 shrink-0 text-gray-800" />
91
+ <input
92
+ {...props}
93
+ ref={inputRef}
94
+ id={inputId}
95
+ type="search"
96
+ autoComplete="off"
97
+ spellCheck={false}
98
+ value={value}
99
+ onChange={(e) => onValueChange(e.target.value)}
100
+ onFocus={(e) => {
101
+ onFocus?.(e);
102
+ setFocusVisible(lastInputRef.current === 'keyboard');
103
+ }}
104
+ onBlur={(e) => {
105
+ onBlur?.(e);
106
+ setFocusVisible(false);
107
+ }}
108
+ onKeyDown={(e) => {
109
+ onKeyDown?.(e);
110
+ if (e.defaultPrevented) return;
111
+ if (e.key === 'Escape' && value) {
112
+ e.preventDefault();
113
+ e.stopPropagation();
114
+ onValueChange('');
115
+ }
116
+ }}
117
+ className="min-w-0 flex-1 appearance-none bg-transparent text-label-14 text-gray-1000 outline-none placeholder:text-gray-800 [&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none"
118
+ />
119
+ {value ? (
120
+ <button
121
+ type="button"
122
+ aria-label="Clear search"
123
+ onClick={clear}
124
+ className={cn(
125
+ '-mr-2 flex h-full shrink-0 cursor-pointer items-center rounded-r-md border-0 bg-transparent px-2.5 text-gray-900 transition-colors duration-150 ease-in hover:text-gray-1000',
126
+ 'focus-visible:[outline:var(--ds-focus-ring-outline,2px_solid_var(--ds-focus-color))] focus-visible:-outline-offset-2'
127
+ )}
128
+ >
129
+ {/* A narrow bar shows a compact icon instead of the Esc hint. */}
130
+ <X aria-hidden className="size-3.5 @min-[320px]:hidden" />
131
+ <Kbd
132
+ aria-hidden
133
+ variant="outline"
134
+ size="search"
135
+ className="hidden @min-[320px]:inline-flex"
136
+ >
137
+ Esc
138
+ </Kbd>
139
+ </button>
140
+ ) : null}
141
+ </div>
142
+ );
143
+ }
@@ -1,72 +1,122 @@
1
- const KEYFRAMES = `@keyframes wf-spinner-fade{0%{opacity:1}100%{opacity:.15}}`;
1
+ import { cva } from 'class-variance-authority';
2
+ import type * as React from 'react';
3
+ import { cn } from '../../lib/cn';
4
+
5
+ const sizeConfig = {
6
+ sm: {
7
+ angleIncrement: 45,
8
+ lineDimensions: 'h-[1.5px] w-[3px]',
9
+ delays: [-875, -750, -625, -500, -375, -250, -125, 0],
10
+ duration: 1000,
11
+ },
12
+ md: {
13
+ angleIncrement: 36,
14
+ lineDimensions: 'h-[1.5px] w-1',
15
+ delays: [-900, -800, -700, -600, -500, -400, -300, -200, -100, 0],
16
+ duration: 1000,
17
+ },
18
+ lg: {
19
+ angleIncrement: 30,
20
+ lineDimensions: 'h-[2px] w-[5px]',
21
+ delays: [
22
+ -1100, -1000, -900, -800, -700, -600, -500, -400, -300, -200, -100, 0,
23
+ ],
24
+ duration: 1200,
25
+ },
26
+ xl: {
27
+ angleIncrement: 30,
28
+ lineDimensions: 'h-[2.5px] w-1.5',
29
+ delays: [
30
+ -1100, -1000, -900, -800, -700, -600, -500, -400, -300, -200, -100, 0,
31
+ ],
32
+ duration: 1200,
33
+ },
34
+ '2xl': {
35
+ angleIncrement: 24,
36
+ lineDimensions: 'h-[2.5px] w-2',
37
+ delays: [
38
+ -1120, -1040, -960, -880, -800, -720, -640, -560, -480, -400, -320, -240,
39
+ -160, -80, 0,
40
+ ],
41
+ duration: 1200,
42
+ },
43
+ '3xl': {
44
+ angleIncrement: 24,
45
+ lineDimensions: 'h-[3px] w-2.5',
46
+ delays: [
47
+ -1120, -1040, -960, -880, -800, -720, -640, -560, -480, -400, -320, -240,
48
+ -160, -80, 0,
49
+ ],
50
+ duration: 1200,
51
+ },
52
+ '4xl': {
53
+ angleIncrement: 20,
54
+ lineDimensions: 'h-[3.5px] w-3.5',
55
+ delays: [
56
+ -1228, -1156, -1083, -1011, -939, -867, -794, -722, -650, -578, -506,
57
+ -433, -361, -289, -217, -144, -72, 0,
58
+ ],
59
+ duration: 1300,
60
+ },
61
+ } as const;
62
+
63
+ export type SpinnerSize = keyof typeof sizeConfig;
64
+
65
+ const spinnerVariants = cva(
66
+ 'relative inline-block aspect-square transform-gpu text-gray-700',
67
+ {
68
+ variants: {
69
+ size: {
70
+ sm: 'size-3', // 12px
71
+ md: 'size-4', // 16px
72
+ lg: 'size-5', // 20px
73
+ xl: 'size-6', // 24px
74
+ '2xl': 'size-8', // 32px
75
+ '3xl': 'size-10', // 40px
76
+ '4xl': 'size-14', // 56px
77
+ },
78
+ },
79
+ }
80
+ );
81
+
82
+ export interface SpinnerProps extends React.HTMLAttributes<HTMLSpanElement> {
83
+ size?: SpinnerSize;
84
+ }
2
85
 
3
86
  /**
4
- * Spinner matching Geist's multi-line fade spinner.
5
- * At size ≤12: 8 lines, ≤16: 10 lines, else: 12 lines.
87
+ * Lines that fade in turn around a ring, painted with `currentColor`
88
+ * (`text-gray-700` unless `className` sets another). The fade is the
89
+ * `spinner-opacity` keyframes in our `styles.css`.
6
90
  */
7
- export function Spinner({
8
- size = 14,
9
- color,
10
- }: {
11
- size?: number;
12
- color?: string;
13
- }) {
14
- const config =
15
- size <= 12
16
- ? {
17
- count: 8,
18
- angle: 45,
19
- delays: [-875, -750, -625, -500, -375, -250, -125, 0],
20
- duration: 1000,
21
- lineW: 3,
22
- lineH: 1.5,
23
- }
24
- : size <= 16
25
- ? {
26
- count: 10,
27
- angle: 36,
28
- delays: [-900, -800, -700, -600, -500, -400, -300, -200, -100, 0],
29
- duration: 1000,
30
- lineW: 4,
31
- lineH: 1.5,
32
- }
33
- : {
34
- count: 12,
35
- angle: 30,
36
- delays: [
37
- -1100, -1000, -900, -800, -700, -600, -500, -400, -300, -200,
38
- -100, 0,
39
- ],
40
- duration: 1200,
41
- lineW: size * 0.24,
42
- lineH: size * 0.08,
43
- };
91
+ export function Spinner({ size = 'lg', className, ...props }: SpinnerProps) {
92
+ const { angleIncrement, lineDimensions, delays, duration } = sizeConfig[size];
44
93
 
45
94
  return (
95
+ // biome-ignore lint/a11y/useSemanticElements: a loading indicator is a status region; <output> is a form control
46
96
  <span
47
- className="relative inline-flex"
48
- style={{
49
- width: size,
50
- height: size,
51
- }}
97
+ role="status"
98
+ aria-label="Loading"
99
+ className={cn(spinnerVariants({ size }), className)}
100
+ {...props}
52
101
  >
53
- <style dangerouslySetInnerHTML={{ __html: KEYFRAMES }} />
54
- {config.delays.map((delay, i) => (
102
+ {delays.map((delay, index) => (
55
103
  <span
104
+ aria-hidden="true"
56
105
  key={delay}
57
- className="absolute top-1/2 left-1/2 rounded-[1px] bg-gray-700 [animation-iteration-count:infinite] [animation-name:wf-spinner-fade] [animation-timing-function:linear]"
106
+ className={cn(
107
+ 'absolute top-1/2 left-1/2 origin-center rounded-full bg-current will-change-transform',
108
+ lineDimensions
109
+ )}
58
110
  style={{
59
- width: config.lineW,
60
- height: config.lineH,
61
- marginLeft: -config.lineW / 2,
62
- marginTop: -config.lineH / 2,
63
- backgroundColor: color,
64
- transform: `rotate(${i * config.angle}deg) translate(${size * 0.36}px)`,
65
- animationDuration: `${config.duration}ms`,
111
+ animation: `spinner-opacity ${duration}ms linear infinite`,
66
112
  animationDelay: `${delay}ms`,
113
+ // Centring lives in the transform rather than translate
114
+ // utilities, which Tailwind v3 compiles to `transform` too.
115
+ transform: `translate(-50%, -50%) rotate(${index * angleIncrement}deg) translate(146%)`,
67
116
  }}
68
117
  />
69
118
  ))}
119
+ <span className="sr-only">Loading...</span>
70
120
  </span>
71
121
  );
72
122
  }
@@ -49,7 +49,7 @@ export const getEventTimestamp = (
49
49
  * Convert workflow events to span events
50
50
  * Only includes events that should be displayed as markers
51
51
  */
52
- export function convertEventsToSpanEvents(
52
+ function convertEventsToSpanEvents(
53
53
  events: Event[],
54
54
  filterTypes = true,
55
55
  options: { preferOccurredAt?: boolean } = {}
@@ -327,7 +327,7 @@ export function stepToSpan(
327
327
  * (the run's creation stands for it), so pass its `startHook` creation from
328
328
  * `findStartHookCreation` to build it from deliveries alone.
329
329
  */
330
- export const hookEventsToHookEntity = (
330
+ const hookEventsToHookEntity = (
331
331
  events: Event[],
332
332
  startHook?: StartHookCreation
333
333
  ): {
package/src/index.ts CHANGED
@@ -6,85 +6,37 @@ export {
6
6
  export type { Event, Hook, Step, WorkflowRun } from '@workflow/world';
7
7
  export * from './components';
8
8
  export {
9
- hookEventsToHookEntity,
10
9
  stepEventsToStepEntity,
11
10
  waitEventsToWaitEntity,
12
11
  } from './components/workflow-traces/trace-span-construction';
13
- export {
14
- DUPLICATE_EVENT_MESSAGE,
15
- findDuplicateEventIds,
16
- } from './lib/duplicate-events';
12
+ export { cn } from './lib/cn';
17
13
  export type { EventAnalysis } from './lib/event-analysis';
18
- export {
19
- analyzeEvents,
20
- hasPendingHooksFromEvents,
21
- hasPendingStepsFromEvents,
22
- isTerminalStatus,
23
- shouldShowReenqueueButton,
24
- } from './lib/event-analysis';
14
+ export { analyzeEvents } from './lib/event-analysis';
25
15
  export type {
26
- MaterializedEntities,
27
- MaterializedHook,
28
- MaterializedStep,
29
- MaterializedWait,
30
- } from './lib/event-materialization';
31
- export {
32
- materializeAll,
33
- materializeHooks,
34
- materializeSteps,
35
- materializeWaits,
36
- } from './lib/event-materialization';
37
- export {
38
- type ExactIdSearchResult,
39
- type ExactWorkflowSearchId,
40
- type ExactWorkflowSearchIdKind,
41
- looksLikeWorkflowIdSearchInput,
42
- parseExactWorkflowSearchId,
16
+ ExactIdSearchResult,
17
+ ExactWorkflowSearchIdKind,
43
18
  } from './lib/exact-event-search-id';
44
- export type { Revivers, StreamRef } from './lib/hydration';
19
+ export type { Revivers } from './lib/hydration';
45
20
  export {
46
- CLASS_INSTANCE_REF_TYPE,
47
- ClassInstanceRef,
48
21
  ENCRYPTED_PLACEHOLDER,
49
- extractStreamIds,
50
22
  getWebRevivers,
51
23
  hasEncryptedFields,
52
24
  hydrateResourceIO,
53
25
  hydrateResourceIOAsync,
54
- hydrateResourceIOWithKey,
55
- isClassInstanceRef,
56
- isEncryptedMarker,
57
- isStreamId,
58
- isStreamRef,
59
- STREAM_REF_TYPE,
60
- truncateId,
61
26
  } from './lib/hydration';
62
27
  export {
63
28
  getRunLimitGuidance,
64
- isQuickJSSnapshotRun,
65
29
  type RunLimitGuidance,
66
30
  type RunLimitGuidanceInput,
67
31
  type RunLimitGuidanceKind,
68
32
  } from './lib/run-limit-guidance';
69
- export {
70
- isSealedNoopEvent,
71
- SEALED_EVENT_MESSAGE,
72
- } from './lib/sealed-events';
73
33
  export {
74
34
  createRunStateHydrator,
75
35
  type RunStateHydrator,
76
36
  type RunStateHydratorOptions,
77
37
  type StateHistoryPage,
78
38
  } from './lib/state-hydration';
79
- export type { DecodedStreamChunkSource } from './lib/stream-display';
80
39
  export { getStreamImageType } from './lib/stream-image';
81
40
  export type { ToastAdapter } from './lib/toast';
82
- export { ToastProvider, useToast } from './lib/toast';
83
- export type { StreamStep } from './lib/utils';
84
- export {
85
- extractConversation,
86
- formatDuration,
87
- formatDurationPrecise,
88
- identifyStreamSteps,
89
- isDoStreamStep,
90
- } from './lib/utils';
41
+ export { ToastProvider } from './lib/toast';
42
+ export { formatDuration } from './lib/utils';
@@ -3,18 +3,9 @@
3
3
  * Used by run-actions and trace viewer components.
4
4
  */
5
5
 
6
- import {
7
- type Event,
8
- isRunCreationEvent,
9
- isTerminalWorkflowRunStatus,
10
- type WorkflowRunStatus,
11
- } from '@workflow/world';
6
+ import { type Event, isRunCreationEvent } from '@workflow/world';
12
7
  import { findStartHookCreation } from './start-hook';
13
8
 
14
- // Time thresholds for Re-enqueue button visibility
15
- const STEP_ACTIVITY_TIMEOUT_MS = 30 * 60 * 1000; // 30 minutes
16
- const STEP_IDLE_TIMEOUT_MS = 5 * 60 * 1000; // 5 minutes
17
-
18
9
  /**
19
10
  * Result of analyzing events for a workflow run
20
11
  */
@@ -146,97 +137,3 @@ export function analyzeEvents(events: Event[] | undefined): EventAnalysis {
146
137
  lastStepCompletionAt,
147
138
  };
148
139
  }
149
-
150
- /**
151
- * Check if a workflow run status is terminal (completed, failed, or cancelled)
152
- */
153
- export function isTerminalStatus(
154
- status: WorkflowRunStatus | undefined
155
- ): boolean {
156
- return status ? isTerminalWorkflowRunStatus(status) : false;
157
- }
158
-
159
- /**
160
- * Determine if the Re-enqueue button should be shown without the debug flag.
161
- *
162
- * The Re-enqueue button is shown when the workflow appears to be stuck:
163
- * - The workflow is not in a terminal state
164
- * - There are no pending sleeps (which would show the Wake up button instead)
165
- * - There are no pending hooks (which are waiting for external input)
166
- * - Either:
167
- * - The last step_started or step_retrying event was >30 minutes ago, OR
168
- * - There have been no pending steps for >5 minutes (all steps completed/failed)
169
- */
170
- export function shouldShowReenqueueButton(
171
- events: Event[] | undefined,
172
- status: WorkflowRunStatus | undefined
173
- ): boolean {
174
- // Never show if in terminal state
175
- if (isTerminalStatus(status)) {
176
- return false;
177
- }
178
-
179
- const analysis = analyzeEvents(events);
180
-
181
- // Don't show if there are pending sleeps (Wake up button handles this)
182
- if (analysis.hasPendingSleeps) {
183
- return false;
184
- }
185
-
186
- // Don't show if there are pending hooks (waiting for external input)
187
- if (analysis.hasPendingHooks) {
188
- return false;
189
- }
190
-
191
- const now = Date.now();
192
-
193
- // Check if last step activity was >30 minutes ago
194
- if (analysis.lastStepActivityAt) {
195
- const timeSinceLastActivity = now - analysis.lastStepActivityAt.getTime();
196
- if (timeSinceLastActivity > STEP_ACTIVITY_TIMEOUT_MS) {
197
- return true;
198
- }
199
- }
200
-
201
- // Check if there are no pending steps and last completion was >5 minutes ago
202
- if (!analysis.hasPendingSteps && analysis.lastStepCompletionAt) {
203
- const timeSinceLastCompletion =
204
- now - analysis.lastStepCompletionAt.getTime();
205
- if (timeSinceLastCompletion > STEP_IDLE_TIMEOUT_MS) {
206
- return true;
207
- }
208
- }
209
-
210
- // If there's no step activity at all but the run is not terminal,
211
- // and we've been waiting for a while, show the button
212
- if (
213
- !analysis.lastStepActivityAt &&
214
- !analysis.hasPendingSteps &&
215
- !analysis.hasPendingSleeps &&
216
- !analysis.hasPendingHooks
217
- ) {
218
- // This case handles runs that haven't started any steps yet
219
- // but aren't in a terminal state - they might be stuck
220
- return true;
221
- }
222
-
223
- return false;
224
- }
225
-
226
- /**
227
- * Check if there are pending steps from an events list.
228
- */
229
- export function hasPendingStepsFromEvents(
230
- events: Event[] | undefined
231
- ): boolean {
232
- return analyzeEvents(events).hasPendingSteps;
233
- }
234
-
235
- /**
236
- * Check if there are pending hooks from an events list.
237
- */
238
- export function hasPendingHooksFromEvents(
239
- events: Event[] | undefined
240
- ): boolean {
241
- return analyzeEvents(events).hasPendingHooks;
242
- }
@@ -609,7 +609,7 @@ export type EventSearchState =
609
609
  status: 'error';
610
610
  query: string;
611
611
  id: ExactWorkflowSearchId;
612
- message: string;
612
+ message?: string;
613
613
  };
614
614
 
615
615
  const NO_EVENTS: Event[] = [];
@@ -648,15 +648,20 @@ function countEvents(n: number): string {
648
648
 
649
649
  /** Shown in place of the list when it has no rows. */
650
650
  export function getEmptyMessage(search: EventSearchState): string {
651
+ return search.status === 'not_found'
652
+ ? `No events found for ${search.query}`
653
+ : 'No events found';
654
+ }
655
+
656
+ /** Shown under the search box while the query cannot be looked up. */
657
+ export function getSearchHint(search: EventSearchState): string | null {
651
658
  switch (search.status) {
652
- case 'not_found':
653
- return `No events found for ${search.query}`;
654
- case 'error':
655
- return search.message;
659
+ case 'incomplete':
660
+ return 'Enter a full step, wait, hook, or event ID to search';
656
661
  case 'unavailable':
657
- return 'Exact ID search is unavailable in this view.';
662
+ return 'Search isn’t available in this view';
658
663
  default:
659
- return 'No events found';
664
+ return null;
660
665
  }
661
666
  }
662
667
 
@@ -667,17 +672,15 @@ export function getFooterLabel(
667
672
  total: number;
668
673
  hasMoreEvents: boolean;
669
674
  }
670
- ): string {
675
+ ): string | null {
671
676
  const { total, hasMoreEvents } = counts;
672
677
  switch (search.status) {
673
678
  case 'ok':
674
679
  return `${countEvents(total)} for ${search.query}${search.truncated ? ' (results may be truncated)' : ''}`;
680
+ case 'loading':
675
681
  case 'not_found':
676
- return `No events found for ${search.query}`;
677
682
  case 'error':
678
- return search.message;
679
- case 'incomplete':
680
- return 'Enter a full step ID, wait ID, hook ID, or event ID';
683
+ return null;
681
684
  default:
682
685
  return `${countEvents(total)}${hasMoreEvents ? ' loaded' : ''}`;
683
686
  }
@@ -7,8 +7,6 @@ const WAIT_ID_PATTERN = new RegExp(`^wait_(${WORKFLOW_ULID_BODY})$`, 'i');
7
7
  const HOOK_ID_PATTERN = new RegExp(`^hook_(${WORKFLOW_ULID_BODY})$`, 'i');
8
8
  const EVENT_ID_PATTERN = new RegExp(`^evnt_(${WORKFLOW_ULID_BODY})$`, 'i');
9
9
 
10
- const WORKFLOW_ID_PREFIX_PATTERN = /^(step_|wait_|hook_|evnt_|wrun_)/i;
11
-
12
10
  export type ExactWorkflowSearchIdKind = 'step' | 'wait' | 'hook' | 'event';
13
11
 
14
12
  export type ExactWorkflowSearchId = {
@@ -54,14 +52,3 @@ export function parseExactWorkflowSearchId(
54
52
  matchPrefixedId(EVENT_ID_PATTERN, 'evnt', 'event', trimmed)
55
53
  );
56
54
  }
57
-
58
- /** True when input looks like the user is attempting an ID search (including partial). */
59
- export function looksLikeWorkflowIdSearchInput(query: string): boolean {
60
- const trimmed = query.trim();
61
- if (!WORKFLOW_ID_PREFIX_PATTERN.test(trimmed)) {
62
- return false;
63
- }
64
- // Distinguish IDs (contain digits) from event-type strings like step_started.
65
- // Assumes workflow event types do not include digits in their names.
66
- return /\d/.test(trimmed);
67
- }