@workflow/web-shared 5.1.1 → 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 (175) 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 +7 -6
  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/detail-panel-shell.d.ts +2 -1
  35. package/dist/components/trace-viewer/components/detail-panel-shell.d.ts.map +1 -1
  36. package/dist/components/trace-viewer/components/detail-panel-shell.js +3 -3
  37. package/dist/components/trace-viewer/components/event-list.d.ts.map +1 -1
  38. package/dist/components/trace-viewer/components/event-list.js +2 -2
  39. package/dist/components/trace-viewer/components/middle-truncate/truncate.d.ts +1 -4
  40. package/dist/components/trace-viewer/components/middle-truncate/truncate.d.ts.map +1 -1
  41. package/dist/components/trace-viewer/components/middle-truncate/truncate.js +2 -2
  42. package/dist/components/trace-viewer/components/minimap.d.ts.map +1 -1
  43. package/dist/components/trace-viewer/components/minimap.js +6 -4
  44. package/dist/components/trace-viewer/components/timeline.d.ts +0 -11
  45. package/dist/components/trace-viewer/components/timeline.d.ts.map +1 -1
  46. package/dist/components/trace-viewer/components/timeline.js +1 -2
  47. package/dist/components/trace-viewer/trace-viewer.js +9 -10
  48. package/dist/components/ui/button.d.ts +28 -17
  49. package/dist/components/ui/button.d.ts.map +1 -1
  50. package/dist/components/ui/button.js +47 -43
  51. package/dist/components/ui/context-card.js +3 -3
  52. package/dist/components/ui/copy-button.d.ts +15 -0
  53. package/dist/components/ui/copy-button.d.ts.map +1 -0
  54. package/dist/components/ui/copy-button.js +41 -0
  55. package/dist/components/ui/data-inspector.d.ts.map +1 -1
  56. package/dist/components/ui/data-inspector.js +8 -38
  57. package/dist/components/ui/decrypt-button.d.ts +3 -2
  58. package/dist/components/ui/decrypt-button.d.ts.map +1 -1
  59. package/dist/components/ui/decrypt-button.js +13 -7
  60. package/dist/components/ui/duplicate-event-tooltip.d.ts +1 -9
  61. package/dist/components/ui/duplicate-event-tooltip.d.ts.map +1 -1
  62. package/dist/components/ui/duplicate-event-tooltip.js +2 -10
  63. package/dist/components/ui/error-stack-block.js +3 -3
  64. package/dist/components/ui/icon-button.d.ts +2 -2
  65. package/dist/components/ui/icon-button.d.ts.map +1 -1
  66. package/dist/components/ui/icon-button.js +2 -3
  67. package/dist/components/ui/kbd.d.ts +1 -1
  68. package/dist/components/ui/kbd.d.ts.map +1 -1
  69. package/dist/components/ui/kbd.js +1 -2
  70. package/dist/components/ui/search-input.d.ts +19 -0
  71. package/dist/components/ui/search-input.d.ts.map +1 -0
  72. package/dist/components/ui/search-input.js +61 -0
  73. package/dist/components/ui/spinner.d.ts +54 -6
  74. package/dist/components/ui/spinner.d.ts.map +1 -1
  75. package/dist/components/ui/spinner.js +84 -46
  76. package/dist/components/workflow-traces/trace-span-construction.d.ts +1 -22
  77. package/dist/components/workflow-traces/trace-span-construction.d.ts.map +1 -1
  78. package/dist/components/workflow-traces/trace-span-construction.js +3 -3
  79. package/dist/index.d.ts +9 -14
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +8 -11
  82. package/dist/lib/event-analysis.d.ts +1 -25
  83. package/dist/lib/event-analysis.d.ts.map +1 -1
  84. package/dist/lib/event-analysis.js +2 -75
  85. package/dist/lib/event-list-model.d.ts +4 -2
  86. package/dist/lib/event-list-model.d.ts.map +1 -1
  87. package/dist/lib/event-list-model.js +13 -11
  88. package/dist/lib/exact-event-search-id.d.ts +0 -2
  89. package/dist/lib/exact-event-search-id.d.ts.map +1 -1
  90. package/dist/lib/exact-event-search-id.js +1 -12
  91. package/dist/lib/hydration.d.ts +1 -12
  92. package/dist/lib/hydration.d.ts.map +1 -1
  93. package/dist/lib/hydration.js +8 -20
  94. package/dist/lib/stream-display.d.ts +0 -1
  95. package/dist/lib/stream-display.d.ts.map +1 -1
  96. package/dist/lib/stream-display.js +2 -2
  97. package/dist/lib/trace-builder.d.ts +0 -8
  98. package/dist/lib/trace-builder.d.ts.map +1 -1
  99. package/dist/lib/trace-builder.js +2 -2
  100. package/dist/lib/utils.d.ts +0 -22
  101. package/dist/lib/utils.d.ts.map +1 -1
  102. package/dist/lib/utils.js +1 -31
  103. package/dist/styles.css +286 -117
  104. package/package.json +5 -17
  105. package/src/components/event-list/event-details-panel.tsx +22 -26
  106. package/src/components/event-list/event-list-toolbar.tsx +35 -28
  107. package/src/components/event-list/event-row.tsx +33 -29
  108. package/src/components/event-list/use-event-search.ts +29 -22
  109. package/src/components/event-list-view.tsx +180 -52
  110. package/src/components/hook-actions.tsx +0 -1
  111. package/src/components/index.ts +4 -20
  112. package/src/components/sidebar/attribute-panel.tsx +4 -7
  113. package/src/components/sidebar/attributes-block.tsx +7 -6
  114. package/src/components/sidebar/conversation-view.tsx +3 -2
  115. package/src/components/sidebar/copyable-data-block.tsx +17 -14
  116. package/src/components/sidebar/entity-detail-panel.tsx +2 -7
  117. package/src/components/stream-image-preview.tsx +1 -1
  118. package/src/components/stream-viewer.tsx +4 -4
  119. package/src/components/trace-viewer/components/detail-panel-shell.tsx +3 -0
  120. package/src/components/trace-viewer/components/event-list.tsx +16 -18
  121. package/src/components/trace-viewer/components/middle-truncate/truncate.ts +1 -2
  122. package/src/components/trace-viewer/components/minimap.tsx +4 -3
  123. package/src/components/trace-viewer/components/timeline.tsx +0 -2
  124. package/src/components/trace-viewer/trace-viewer.tsx +19 -38
  125. package/src/components/ui/button.tsx +144 -46
  126. package/src/components/ui/context-card.tsx +2 -2
  127. package/src/components/ui/copy-button.tsx +86 -0
  128. package/src/components/ui/data-inspector.tsx +23 -67
  129. package/src/components/ui/decrypt-button.tsx +23 -48
  130. package/src/components/ui/duplicate-event-tooltip.tsx +1 -22
  131. package/src/components/ui/error-stack-block.tsx +4 -4
  132. package/src/components/ui/icon-button.tsx +1 -3
  133. package/src/components/ui/kbd.tsx +0 -2
  134. package/src/components/ui/search-input.tsx +143 -0
  135. package/src/components/ui/spinner.tsx +105 -55
  136. package/src/components/workflow-traces/trace-span-construction.ts +2 -2
  137. package/src/index.ts +7 -55
  138. package/src/lib/event-analysis.ts +1 -104
  139. package/src/lib/event-list-model.ts +15 -12
  140. package/src/lib/exact-event-search-id.ts +0 -13
  141. package/src/lib/hydration.ts +6 -31
  142. package/src/lib/stream-display.ts +1 -1
  143. package/src/lib/trace-builder.ts +1 -1
  144. package/src/lib/utils.ts +0 -48
  145. package/src/styles.css +286 -117
  146. package/dist/components/trace-viewer/components/copy-button.d.ts +0 -9
  147. package/dist/components/trace-viewer/components/copy-button.d.ts.map +0 -1
  148. package/dist/components/trace-viewer/components/copy-button.js +0 -27
  149. package/dist/components/ui/alert.d.ts +0 -9
  150. package/dist/components/ui/alert.d.ts.map +0 -1
  151. package/dist/components/ui/alert.js +0 -23
  152. package/dist/components/ui/card.d.ts +0 -9
  153. package/dist/components/ui/card.d.ts.map +0 -1
  154. package/dist/components/ui/card.js +0 -18
  155. package/dist/components/ui/load-more-button.d.ts +0 -13
  156. package/dist/components/ui/load-more-button.d.ts.map +0 -1
  157. package/dist/components/ui/load-more-button.js +0 -12
  158. package/dist/components/ui/menu-dropdown.d.ts +0 -16
  159. package/dist/components/ui/menu-dropdown.d.ts.map +0 -1
  160. package/dist/components/ui/menu-dropdown.js +0 -30
  161. package/dist/hooks/use-dark-mode.d.ts +0 -9
  162. package/dist/hooks/use-dark-mode.d.ts.map +0 -1
  163. package/dist/hooks/use-dark-mode.js +0 -30
  164. package/dist/lib/event-materialization.d.ts +0 -91
  165. package/dist/lib/event-materialization.d.ts.map +0 -1
  166. package/dist/lib/event-materialization.js +0 -219
  167. package/src/components/index.d.ts +0 -1
  168. package/src/components/trace-viewer/components/copy-button.tsx +0 -68
  169. package/src/components/ui/alert.tsx +0 -59
  170. package/src/components/ui/card.tsx +0 -79
  171. package/src/components/ui/load-more-button.tsx +0 -38
  172. package/src/components/ui/menu-dropdown.tsx +0 -97
  173. package/src/hooks/use-dark-mode.ts +0 -34
  174. package/src/index.d.ts +0 -1
  175. package/src/lib/event-materialization.ts +0 -304
@@ -12,7 +12,7 @@
12
12
  * class instances.
13
13
  */
14
14
 
15
- import { Lock } from 'lucide-react';
15
+ import { ChevronDown, ChevronRight, Lock, Radio } from 'lucide-react';
16
16
  import {
17
17
  createContext,
18
18
  type KeyboardEvent as ReactKeyboardEvent,
@@ -26,7 +26,15 @@ import {
26
26
  useState,
27
27
  } from 'react';
28
28
  import { cn } from '../../lib/cn';
29
- import { ENCRYPTED_DISPLAY_NAME } from '../../lib/hydration';
29
+ import {
30
+ type ClassInstanceRef,
31
+ isClassInstanceRef,
32
+ isEncryptedMarker,
33
+ isRunRef,
34
+ isStreamRef,
35
+ type RunRef,
36
+ type StreamRef,
37
+ } from '../../lib/hydration';
30
38
  import {
31
39
  type DecodedStreamChunkSource,
32
40
  type FormattedStreamChunkDisplay,
@@ -34,41 +42,19 @@ import {
34
42
  } from '../../lib/stream-display';
35
43
  import { Button } from './button';
36
44
  import { CLS, JSON_VIEW_STYLES } from './data-inspector.styles';
37
- import { Spinner } from './spinner';
38
45
 
39
46
  // ---------------------------------------------------------------------------
40
- // StreamRef / ClassInstanceRef type detection
41
- // (inline to avoid circular deps with hydration module)
47
+ // Decoded byte display (built by `collapseRefs`, rendered by `DataRender`)
42
48
  // ---------------------------------------------------------------------------
43
49
 
44
- const STREAM_REF_TYPE = '__workflow_stream_ref__';
45
- const CLASS_INSTANCE_REF_TYPE = '__workflow_class_instance_ref__';
46
- const RUN_REF_TYPE = '__workflow_run_ref__';
47
50
  const BYTES_DISPLAY_TYPE = '__workflow_bytes_display__';
48
51
 
49
- interface StreamRef {
50
- __type: typeof STREAM_REF_TYPE;
51
- streamId: string;
52
- }
53
-
54
- interface RunRef {
55
- __type: typeof RUN_REF_TYPE;
56
- runId: string;
57
- }
58
-
59
52
  interface BytesDisplay {
60
53
  __type: typeof BYTES_DISPLAY_TYPE;
61
54
  text: string;
62
55
  decodedFrom?: DecodedStreamChunkSource;
63
56
  }
64
57
 
65
- interface ClassInstanceRef {
66
- __type: typeof CLASS_INSTANCE_REF_TYPE;
67
- className: string;
68
- classId: string;
69
- data: unknown;
70
- }
71
-
72
58
  function deserializeChunkText(text: string): string {
73
59
  try {
74
60
  const parsed = JSON.parse(text);
@@ -89,43 +75,12 @@ function parseChunkData(text: string): unknown {
89
75
  }
90
76
  }
91
77
 
92
- function isStreamRef(value: unknown): value is StreamRef {
93
- if (value === null || typeof value !== 'object') return false;
94
- // Check both enumerable and non-enumerable __type (opaque refs use non-enumerable)
95
- const desc = Object.getOwnPropertyDescriptor(value, '__type');
96
- return desc?.value === STREAM_REF_TYPE;
97
- }
98
-
99
- function isRunRef(value: unknown): value is RunRef {
100
- if (value === null || typeof value !== 'object') return false;
101
- const desc = Object.getOwnPropertyDescriptor(value, '__type');
102
- return desc?.value === RUN_REF_TYPE;
103
- }
104
-
105
78
  export function isBytesDisplay(value: unknown): value is BytesDisplay {
106
79
  if (value === null || typeof value !== 'object') return false;
107
80
  const desc = Object.getOwnPropertyDescriptor(value, '__type');
108
81
  return desc?.value === BYTES_DISPLAY_TYPE;
109
82
  }
110
83
 
111
- function isClassInstanceRef(value: unknown): value is ClassInstanceRef {
112
- return (
113
- value !== null &&
114
- typeof value === 'object' &&
115
- '__type' in value &&
116
- (value as Record<string, unknown>).__type === CLASS_INSTANCE_REF_TYPE
117
- );
118
- }
119
-
120
- function isEncryptedMarker(value: unknown): boolean {
121
- return (
122
- value !== null &&
123
- typeof value === 'object' &&
124
- (value as { constructor?: { name?: string } }).constructor?.name ===
125
- ENCRYPTED_DISPLAY_NAME
126
- );
127
- }
128
-
129
84
  // ---------------------------------------------------------------------------
130
85
  // Stream click context (passed through from the panel)
131
86
  // ---------------------------------------------------------------------------
@@ -167,21 +122,18 @@ function EncryptedInlineLabel() {
167
122
  if (ctx) {
168
123
  return (
169
124
  <Button
170
- size="tiny"
125
+ size="small"
171
126
  className="align-baseline"
172
- disabled={ctx.isDecrypting || ctx.isDecryptDisabled}
127
+ loading={ctx.isDecrypting}
128
+ disabled={ctx.isDecryptDisabled}
129
+ prefix={<Lock />}
173
130
  title={ctx.isDecryptDisabled ? ctx.decryptDisabledReason : undefined}
174
131
  onClick={(e) => {
175
132
  e.stopPropagation();
176
133
  ctx.onDecrypt();
177
134
  }}
178
135
  >
179
- {ctx.isDecrypting ? (
180
- <Spinner size={10} />
181
- ) : (
182
- <Lock className="h-3 w-3" />
183
- )}
184
- <span>Decrypt</span>
136
+ Decrypt
185
137
  </Button>
186
138
  );
187
139
  }
@@ -205,7 +157,7 @@ function StreamRefInline({ streamRef }: { streamRef: StreamRef }) {
205
157
  }}
206
158
  title={`View stream: ${streamRef.streamId}`}
207
159
  >
208
- <span>📡</span>
160
+ <Radio className="size-3 shrink-0" aria-hidden />
209
161
  <span>{streamRef.streamId}</span>
210
162
  </button>
211
163
  );
@@ -307,8 +259,12 @@ function DecodedBytesInspector({
307
259
  onClick={() => setExpanded((value) => !value)}
308
260
  title={`${source.type} decoded as ${source.encoding.toUpperCase()} text`}
309
261
  >
310
- <span className="select-none text-gray-700">
311
- {expanded ? '▼' : '▶'}
262
+ <span className="flex h-[1lh] shrink-0 items-center text-gray-700">
263
+ {expanded ? (
264
+ <ChevronDown className="size-3" aria-hidden />
265
+ ) : (
266
+ <ChevronRight className="size-3" aria-hidden />
267
+ )}
312
268
  </span>
313
269
  <span className="min-w-0 break-words">{source.rawSummary}</span>
314
270
  </button>
@@ -1,8 +1,7 @@
1
1
  'use client';
2
2
 
3
- import { Spinner } from './spinner';
4
-
5
- const STYLES = `.wf-decrypt-btn{appearance:none;-webkit-appearance:none;border:none;display:inline-flex;align-items:center;justify-content:center;height:28px;padding:0 10px;border-radius:6px;font-size:14px;font-weight:500;line-height:20px;cursor:pointer;white-space:nowrap;gap:6px;transition:background 150ms}.wf-decrypt-idle{color:var(--ds-gray-1000);background:var(--ds-background-100);box-shadow:0 0 0 1px var(--ds-gray-400)}.wf-decrypt-idle:hover{background:var(--ds-gray-alpha-200)}.wf-decrypt-btn:disabled{cursor:not-allowed;opacity:.5}.wf-decrypt-done{color:var(--ds-green-900);background:var(--ds-green-100);box-shadow:0 0 0 1px var(--ds-green-400);cursor:default}`;
3
+ import { Lock, LockOpen } from 'lucide-react';
4
+ import { Button } from './button';
6
5
 
7
6
  interface DecryptButtonProps {
8
7
  /** Whether an encryption key has been obtained (decryption is active). */
@@ -18,8 +17,9 @@ interface DecryptButtonProps {
18
17
  }
19
18
 
20
19
  /**
21
- * Decrypt/Decrypted button using Geist secondary style.
22
- * Three states: idle (secondary gray), decrypting (spinner), decrypted (green success).
20
+ * Decrypt/Decrypted button: a small secondary `Button` with a lock prefix.
21
+ * Three states: idle, decrypting (the spinner takes the lock's place) and
22
+ * decrypted (green success, inert).
23
23
  */
24
24
  export function DecryptButton({
25
25
  decrypted = false,
@@ -29,48 +29,23 @@ export function DecryptButton({
29
29
  onClick,
30
30
  }: DecryptButtonProps) {
31
31
  return (
32
- <>
33
- <style dangerouslySetInnerHTML={{ __html: STYLES }} />
34
- <button
35
- type="button"
36
- onClick={decrypted ? undefined : onClick}
37
- disabled={decrypted || loading || disabled}
38
- title={disabled ? disabledReason : undefined}
39
- className={`wf-decrypt-btn ${decrypted ? 'wf-decrypt-done' : 'wf-decrypt-idle'}`}
40
- >
41
- {loading ? (
42
- <Spinner size={14} />
43
- ) : decrypted ? (
44
- <svg
45
- width={14}
46
- height={14}
47
- viewBox="0 0 24 24"
48
- fill="none"
49
- stroke="currentColor"
50
- strokeWidth={2}
51
- strokeLinecap="round"
52
- strokeLinejoin="round"
53
- >
54
- <rect x="3" y="11" width="18" height="11" rx="2" ry="2" />
55
- <path d="M7 11V7a5 5 0 0 1 9.9-1" />
56
- </svg>
57
- ) : (
58
- <svg
59
- width={14}
60
- height={14}
61
- viewBox="0 0 24 24"
62
- fill="none"
63
- stroke="currentColor"
64
- strokeWidth={2}
65
- strokeLinecap="round"
66
- strokeLinejoin="round"
67
- >
68
- <rect x="3" y="11" width="18" height="11" rx="2" ry="2" />
69
- <path d="M7 11V7a5 5 0 0 1 10 0v4" />
70
- </svg>
71
- )}
72
- {loading ? 'Decrypting…' : decrypted ? 'Decrypted' : 'Decrypt'}
73
- </button>
74
- </>
32
+ <Button
33
+ variant="secondary"
34
+ size="small"
35
+ onClick={decrypted ? undefined : onClick}
36
+ loading={loading}
37
+ disabled={decrypted || disabled}
38
+ title={disabled ? disabledReason : undefined}
39
+ prefix={decrypted ? <LockOpen /> : <Lock />}
40
+ // Decrypted is a success state rather than an unavailable one, so it
41
+ // keeps the green fill instead of the disabled gray.
42
+ className={
43
+ decrypted
44
+ ? 'disabled:cursor-default disabled:bg-green-100 disabled:text-green-900 disabled:[--themed-border:_var(--ds-green-400)] disabled:hover:bg-green-100'
45
+ : undefined
46
+ }
47
+ >
48
+ {decrypted ? 'Decrypted' : 'Decrypt'}
49
+ </Button>
75
50
  );
76
51
  }
@@ -1,7 +1,6 @@
1
1
  'use client';
2
2
 
3
3
  import type { ReactNode } from 'react';
4
- import { DUPLICATE_EVENT_MESSAGE } from '../../lib/duplicate-events';
5
4
  import {
6
5
  Tooltip,
7
6
  TooltipContent,
@@ -11,7 +10,7 @@ import {
11
10
 
12
11
  /**
13
12
  * Explains why an event row is shown greyed out, whether it is a repeat the
14
- * runtime read past ({@link DUPLICATE_EVENT_MESSAGE}), a backend seal for an
13
+ * runtime read past (`DUPLICATE_EVENT_MESSAGE`), a backend seal for an
15
14
  * abandoned position (`SEALED_EVENT_MESSAGE`), or any other notice a list
16
15
  * attaches.
17
16
  *
@@ -44,23 +43,3 @@ export function EventNoticeTooltip({
44
43
  </TooltipProvider>
45
44
  );
46
45
  }
47
-
48
- /**
49
- * The duplicate-specific wrapper kept for existing call sites: greys the
50
- * event out as a repeat the runtime read past.
51
- */
52
- export function DuplicateEventTooltip({
53
- isDuplicate = false,
54
- children,
55
- }: {
56
- isDuplicate?: boolean;
57
- children: ReactNode;
58
- }): ReactNode {
59
- return (
60
- <EventNoticeTooltip
61
- notice={isDuplicate ? DUPLICATE_EVENT_MESSAGE : undefined}
62
- >
63
- {children}
64
- </EventNoticeTooltip>
65
- );
66
- }
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
 
3
3
  import { AlertCircle } from 'lucide-react';
4
- import { CopyButton } from '../trace-viewer/components/copy-button';
4
+ import { CopyButton } from './copy-button';
5
5
 
6
6
  export type StructuredErrorRecord = Record<string, unknown> & {
7
7
  message?: string;
@@ -78,9 +78,9 @@ export function ErrorStackBlock({ value }: { value: StructuredErrorRecord }) {
78
78
  }}
79
79
  >
80
80
  <CopyButton
81
- copyText={copyText}
82
- ariaLabel="Copy error"
83
- className="absolute right-2 top-2 flex h-6 w-6 items-center justify-center rounded-md border border-red-400 bg-red-100 p-0 text-red-900 transition-transform transition-colors duration-100 hover:bg-red-200 active:scale-95"
81
+ textToCopy={copyText}
82
+ aria-label="Copy error"
83
+ className="absolute right-2 top-2 border border-red-400 text-red-900 enabled:hover:bg-red-200 enabled:hover:text-red-900 focus-visible:text-red-900"
84
84
  />
85
85
 
86
86
  {title && (
@@ -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
  ): {