@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
|
@@ -2,6 +2,7 @@ import { Slot } from '@radix-ui/react-slot';
|
|
|
2
2
|
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { cn } from '../../lib/cn';
|
|
5
|
+
import { Spinner, type SpinnerSize } from './spinner';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* The button for the observability UI.
|
|
@@ -9,22 +10,13 @@ import { cn } from '../../lib/cn';
|
|
|
9
10
|
* Fill, text and border are painted from four custom properties —
|
|
10
11
|
* `--themed-bg`, `--themed-fg`, `--themed-border` and `--themed-hover-bg` — so
|
|
11
12
|
* a variant only redeclares the tokens it changes and the base rules stay the
|
|
12
|
-
* same.
|
|
13
|
-
*
|
|
14
|
-
* of horizontal padding at medium.
|
|
15
|
-
*
|
|
16
|
-
* The styles have to resolve in whichever app consumes
|
|
17
|
-
* `@workflow/web-shared`, so:
|
|
18
|
-
* - dark mode is matched with ancestor selectors rather than a `dark-theme:`
|
|
19
|
-
* variant, which only exists once our `styles.css` is imported;
|
|
20
|
-
* - the focus ring is written as arbitrary properties, because bare
|
|
21
|
-
* `outline` and arbitrary-colour utilities differ between Tailwind v3
|
|
22
|
-
* and v4.
|
|
13
|
+
* same. The label's span holds 6px of the horizontal padding so the label
|
|
14
|
+
* can truncate, which is why each size's own padding is 6px short.
|
|
23
15
|
*/
|
|
24
16
|
const buttonVariants = cva(
|
|
25
17
|
[
|
|
26
|
-
'group/trigger relative m-0 inline-flex max-w-full shrink-0 items-center justify-center
|
|
27
|
-
'cursor-pointer select-none whitespace-nowrap border-0 align-baseline font-medium no-underline outline-none',
|
|
18
|
+
'group/trigger relative m-0 inline-flex max-w-full shrink-0 items-center justify-center',
|
|
19
|
+
'cursor-pointer select-none whitespace-nowrap border-0 align-baseline font-sans font-medium no-underline outline-none',
|
|
28
20
|
'transform translate-z-0',
|
|
29
21
|
// Fill, text and border all come from --themed-*; the fallbacks below are
|
|
30
22
|
// the inverted `default` variant, so it declares no colour tokens at all.
|
|
@@ -35,9 +27,12 @@ const buttonVariants = cva(
|
|
|
35
27
|
// `hover:bg-*` utility on the element and a call site that needs its own
|
|
36
28
|
// hover fill replaces it in both themes at once.
|
|
37
29
|
'hover:bg-[var(--themed-hover-bg)]',
|
|
38
|
-
'transition-
|
|
39
|
-
'focus-visible:[
|
|
30
|
+
'transition-all duration-150 ease-in-out',
|
|
31
|
+
'focus-visible:shadow-[var(--ds-focus-ring)] focus-visible:transition-none',
|
|
40
32
|
'[&_svg]:shrink-0',
|
|
33
|
+
// Icons in the prefix and suffix slots use the decoration size. The
|
|
34
|
+
// attribute keeps this rule more specific than each size's `[&_svg]` rule.
|
|
35
|
+
'[&_[data-button-slot]_svg]:size-[var(--ds-control-decoration-size)]',
|
|
41
36
|
// Disabled buttons flatten to the gray-100 fill with a gray-400 border.
|
|
42
37
|
'disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-700 disabled:[--themed-border:_var(--ds-gray-400)] disabled:hover:bg-gray-100',
|
|
43
38
|
'aria-disabled:cursor-not-allowed aria-disabled:bg-gray-100 aria-disabled:text-gray-700 aria-disabled:[--themed-border:_var(--ds-gray-400)] aria-disabled:hover:bg-gray-100',
|
|
@@ -45,44 +40,38 @@ const buttonVariants = cva(
|
|
|
45
40
|
{
|
|
46
41
|
variants: {
|
|
47
42
|
variant: {
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
// the theme, because the fill itself does.
|
|
43
|
+
// Literal hover fills for the inverted default type: no `--ds-*`
|
|
44
|
+
// token sits one step off gray-1000.
|
|
51
45
|
default: [
|
|
52
46
|
'[--themed-hover-bg:_hsl(0,_0%,_22%)]',
|
|
53
|
-
'
|
|
54
|
-
'[.dark-theme_&]:[--themed-hover-bg:_hsl(0,_0%,_80%)]',
|
|
55
|
-
'[[data-theme=dark]_&]:[--themed-hover-bg:_hsl(0,_0%,_80%)]',
|
|
47
|
+
'dark:[--themed-hover-bg:_hsl(0,_0%,_80%)]',
|
|
56
48
|
],
|
|
57
49
|
secondary: [
|
|
58
50
|
'[--themed-bg:_var(--ds-background-100)]',
|
|
59
51
|
'[--themed-fg:_var(--ds-gray-1000)]',
|
|
60
52
|
'[--themed-border:_var(--ds-gray-400)]',
|
|
61
53
|
'[--themed-hover-bg:_var(--ds-gray-100)]',
|
|
62
|
-
'
|
|
63
|
-
'[.dark-theme_&]:[--themed-hover-bg:_var(--ds-gray-200)]',
|
|
64
|
-
'[[data-theme=dark]_&]:[--themed-hover-bg:_var(--ds-gray-200)]',
|
|
54
|
+
'dark:[--themed-hover-bg:_var(--ds-gray-200)]',
|
|
65
55
|
],
|
|
66
56
|
// Tertiary is the one variant allowed to go borderless when disabled;
|
|
67
|
-
// it drops to 50% opacity instead.
|
|
57
|
+
// it keeps its text colour and drops to 50% opacity instead.
|
|
68
58
|
tertiary: [
|
|
69
59
|
'[--themed-bg:_transparent]',
|
|
70
60
|
'[--themed-fg:_var(--ds-gray-1000)]',
|
|
71
61
|
'[--themed-border:_transparent]',
|
|
72
62
|
// The alpha token already flips with the theme.
|
|
73
63
|
'[--themed-hover-bg:_var(--ds-gray-alpha-200)]',
|
|
74
|
-
'disabled:bg-transparent disabled:opacity-50 disabled:shadow-none disabled:hover:bg-transparent',
|
|
75
|
-
'aria-disabled:bg-transparent aria-disabled:opacity-50 aria-disabled:shadow-none aria-disabled:hover:bg-transparent',
|
|
64
|
+
'disabled:bg-transparent disabled:text-gray-1000 disabled:opacity-50 disabled:shadow-none disabled:hover:bg-transparent',
|
|
65
|
+
'aria-disabled:bg-transparent aria-disabled:text-gray-1000 aria-disabled:opacity-50 aria-disabled:shadow-none aria-disabled:hover:bg-transparent',
|
|
76
66
|
],
|
|
77
67
|
},
|
|
78
|
-
// Radii are literal rather than `rounded-md`/`rounded-lg`: apps that
|
|
79
|
-
// still carry a shadcn theme redefine the `--radius-*` scale, and these
|
|
80
|
-
// corners should not move with it.
|
|
81
68
|
size: {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
medium:
|
|
85
|
-
|
|
69
|
+
small:
|
|
70
|
+
'h-8 rounded-md px-1.5 text-[14px] leading-normal [&_svg]:size-4',
|
|
71
|
+
medium:
|
|
72
|
+
'h-9 rounded-md px-2.5 text-[14px] leading-normal [&_svg]:size-4',
|
|
73
|
+
large:
|
|
74
|
+
'h-10 rounded-lg px-3.5 text-[16px] leading-normal [&_svg]:size-4',
|
|
86
75
|
},
|
|
87
76
|
// Icon-only buttons: square keeps the size's radius, circle is a pill.
|
|
88
77
|
shape: {
|
|
@@ -97,29 +86,138 @@ const buttonVariants = cva(
|
|
|
97
86
|
}
|
|
98
87
|
);
|
|
99
88
|
|
|
100
|
-
|
|
89
|
+
type Size = NonNullable<VariantProps<typeof buttonVariants>['size']>;
|
|
90
|
+
|
|
91
|
+
const SPINNER_SIZE: Record<Size, SpinnerSize> = {
|
|
92
|
+
small: 'sm',
|
|
93
|
+
medium: 'md',
|
|
94
|
+
large: 'lg',
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export type ButtonProps = Omit<
|
|
98
|
+
React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
99
|
+
'prefix'
|
|
100
|
+
> &
|
|
101
101
|
VariantProps<typeof buttonVariants> & {
|
|
102
102
|
/** Render the child element instead of a `<button>`, keeping the styles. */
|
|
103
103
|
asChild?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Show a spinner in place of `prefix`, disable the button and set
|
|
106
|
+
* `aria-busy`. The label stays, and with a `prefix` the width does not
|
|
107
|
+
* change, because the spinner takes the prefix's slot.
|
|
108
|
+
*/
|
|
109
|
+
loading?: boolean;
|
|
110
|
+
/** Element before the label, usually an icon. */
|
|
111
|
+
prefix?: React.ReactNode;
|
|
112
|
+
/** Element after the label, usually an icon. */
|
|
113
|
+
suffix?: React.ReactNode;
|
|
104
114
|
};
|
|
105
115
|
|
|
116
|
+
function ButtonContent({
|
|
117
|
+
size,
|
|
118
|
+
iconOnly,
|
|
119
|
+
loading,
|
|
120
|
+
prefix,
|
|
121
|
+
suffix,
|
|
122
|
+
children,
|
|
123
|
+
}: {
|
|
124
|
+
size: Size;
|
|
125
|
+
iconOnly: boolean;
|
|
126
|
+
loading: boolean;
|
|
127
|
+
prefix: React.ReactNode;
|
|
128
|
+
suffix: React.ReactNode;
|
|
129
|
+
children: React.ReactNode;
|
|
130
|
+
}) {
|
|
131
|
+
return (
|
|
132
|
+
<>
|
|
133
|
+
{loading || prefix != null ? (
|
|
134
|
+
<span
|
|
135
|
+
data-button-slot="prefix"
|
|
136
|
+
aria-hidden={loading || undefined}
|
|
137
|
+
className="mr-[3px] flex min-w-5 shrink-0 items-center justify-center"
|
|
138
|
+
>
|
|
139
|
+
{loading ? <Spinner size={SPINNER_SIZE[size]} /> : prefix}
|
|
140
|
+
</span>
|
|
141
|
+
) : null}
|
|
142
|
+
<span
|
|
143
|
+
className={cn(
|
|
144
|
+
'px-1.5',
|
|
145
|
+
iconOnly
|
|
146
|
+
? 'inline-flex shrink-0 items-center justify-center'
|
|
147
|
+
: 'truncate'
|
|
148
|
+
)}
|
|
149
|
+
>
|
|
150
|
+
{children}
|
|
151
|
+
</span>
|
|
152
|
+
{suffix != null ? (
|
|
153
|
+
<span
|
|
154
|
+
data-button-slot="suffix"
|
|
155
|
+
className="mr-0.5 ml-1 flex shrink-0 items-center justify-center"
|
|
156
|
+
>
|
|
157
|
+
{suffix}
|
|
158
|
+
</span>
|
|
159
|
+
) : null}
|
|
160
|
+
</>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
106
164
|
export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
107
165
|
(
|
|
108
|
-
{
|
|
166
|
+
{
|
|
167
|
+
className,
|
|
168
|
+
variant,
|
|
169
|
+
size,
|
|
170
|
+
shape,
|
|
171
|
+
asChild = false,
|
|
172
|
+
loading = false,
|
|
173
|
+
prefix,
|
|
174
|
+
suffix,
|
|
175
|
+
disabled,
|
|
176
|
+
type,
|
|
177
|
+
children,
|
|
178
|
+
...props
|
|
179
|
+
},
|
|
109
180
|
ref
|
|
110
181
|
) => {
|
|
111
|
-
const
|
|
182
|
+
const content = (label: React.ReactNode) => (
|
|
183
|
+
<ButtonContent
|
|
184
|
+
size={size ?? 'medium'}
|
|
185
|
+
iconOnly={shape != null}
|
|
186
|
+
loading={loading}
|
|
187
|
+
prefix={prefix}
|
|
188
|
+
suffix={suffix}
|
|
189
|
+
>
|
|
190
|
+
{label}
|
|
191
|
+
</ButtonContent>
|
|
192
|
+
);
|
|
193
|
+
const shared = {
|
|
194
|
+
ref,
|
|
195
|
+
className: cn(buttonVariants({ variant, size, shape }), className),
|
|
196
|
+
'aria-busy': loading || undefined,
|
|
197
|
+
...props,
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
// With `asChild`, the child element (a link, usually) becomes the button
|
|
201
|
+
// and its own children go in the label slot.
|
|
202
|
+
if (asChild) {
|
|
203
|
+
const child = React.Children.only(children) as React.ReactElement<{
|
|
204
|
+
children?: React.ReactNode;
|
|
205
|
+
}>;
|
|
206
|
+
return (
|
|
207
|
+
<Slot {...shared} aria-disabled={disabled || loading || undefined}>
|
|
208
|
+
{React.cloneElement(child, undefined, content(child.props.children))}
|
|
209
|
+
</Slot>
|
|
210
|
+
);
|
|
211
|
+
}
|
|
112
212
|
|
|
113
213
|
return (
|
|
114
|
-
<
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
{...props}
|
|
122
|
-
/>
|
|
214
|
+
<button
|
|
215
|
+
{...shared}
|
|
216
|
+
type={type ?? 'button'}
|
|
217
|
+
disabled={disabled || loading}
|
|
218
|
+
>
|
|
219
|
+
{content(children)}
|
|
220
|
+
</button>
|
|
123
221
|
);
|
|
124
222
|
}
|
|
125
223
|
);
|
|
@@ -274,7 +274,7 @@ export function ContextCardProvider({
|
|
|
274
274
|
>
|
|
275
275
|
<div
|
|
276
276
|
className={cn(
|
|
277
|
-
'absolute bg-background-100 bg-clip-padding rounded-[6px] overflow-visible pointer-events-none z-[1000000] shadow-[var(--ds-shadow-tooltip)
|
|
277
|
+
'absolute bg-background-100 bg-clip-padding rounded-[6px] overflow-visible pointer-events-none z-[1000000] shadow-[var(--ds-shadow-tooltip)] w-fit',
|
|
278
278
|
skipTransition
|
|
279
279
|
? '!transition-none'
|
|
280
280
|
: 'transition-[transform,width,height] duration-[250ms] ease-[easing-function:cubic-bezier(0.29,0.31,0.05,0.96)] will-change-[transform,width,height] motion-reduce:!transition-none'
|
|
@@ -328,7 +328,7 @@ export function ContextCardProvider({
|
|
|
328
328
|
<path
|
|
329
329
|
d="M15 -0.5V0.5H12.9834L12.8184 0.508789C12.4377 0.550822 12.0853 0.738056 11.8359 1.03418L8.53027 4.95996C7.73114 5.90893 6.26886 5.90892 5.46973 4.95996L2.16406 1.03418C1.87905 0.695733 1.45907 0.5 1.0166 0.5H-1V-0.5H15Z"
|
|
330
330
|
fill="var(--ds-background-100)"
|
|
331
|
-
className="fill-background-100 stroke-
|
|
331
|
+
className="fill-background-100 stroke-gray-alpha-400"
|
|
332
332
|
/>
|
|
333
333
|
</g>
|
|
334
334
|
<defs>
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
4
|
+
import { Check, Copy } from 'lucide-react';
|
|
5
|
+
import {
|
|
6
|
+
forwardRef,
|
|
7
|
+
type MouseEvent,
|
|
8
|
+
useEffect,
|
|
9
|
+
useRef,
|
|
10
|
+
useState,
|
|
11
|
+
} from 'react';
|
|
12
|
+
import { cn } from '../../lib/cn';
|
|
13
|
+
import { useToast } from '../../lib/toast';
|
|
14
|
+
import { IconButton, type IconButtonProps } from './icon-button';
|
|
15
|
+
|
|
16
|
+
const copyButtonVariants = cva('', {
|
|
17
|
+
variants: {
|
|
18
|
+
size: {
|
|
19
|
+
tiny: '',
|
|
20
|
+
small: '[&_svg]:size-3',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
defaultVariants: {
|
|
24
|
+
size: 'tiny',
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export type CopyButtonProps = Omit<IconButtonProps, 'children' | 'size'> &
|
|
29
|
+
VariantProps<typeof copyButtonVariants> & {
|
|
30
|
+
textToCopy: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const icon =
|
|
34
|
+
'[grid-area:1/1] transition-[opacity,scale] duration-200 ease-in-out';
|
|
35
|
+
|
|
36
|
+
export const CopyButton = forwardRef<HTMLButtonElement, CopyButtonProps>(
|
|
37
|
+
({ textToCopy, size, onClick, className, ...props }, ref) => {
|
|
38
|
+
const toast = useToast();
|
|
39
|
+
const [copied, setCopied] = useState(false);
|
|
40
|
+
const timeoutRef = useRef<ReturnType<typeof setTimeout>>(undefined);
|
|
41
|
+
|
|
42
|
+
useEffect(() => () => clearTimeout(timeoutRef.current), []);
|
|
43
|
+
|
|
44
|
+
const copy = (e: MouseEvent<HTMLButtonElement>) => {
|
|
45
|
+
e.stopPropagation();
|
|
46
|
+
onClick?.(e);
|
|
47
|
+
clearTimeout(timeoutRef.current);
|
|
48
|
+
navigator.clipboard
|
|
49
|
+
.writeText(textToCopy)
|
|
50
|
+
.then(() => {
|
|
51
|
+
setCopied(true);
|
|
52
|
+
timeoutRef.current = setTimeout(() => setCopied(false), 1000);
|
|
53
|
+
})
|
|
54
|
+
.catch(() => toast.error('Failed to copy to clipboard'));
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<IconButton
|
|
59
|
+
ref={ref}
|
|
60
|
+
onClick={copy}
|
|
61
|
+
className={cn(copyButtonVariants({ size }), className)}
|
|
62
|
+
{...props}
|
|
63
|
+
>
|
|
64
|
+
<span className="grid">
|
|
65
|
+
<Check
|
|
66
|
+
className={cn(
|
|
67
|
+
icon,
|
|
68
|
+
copied ? 'scale-100 opacity-100' : 'scale-50 opacity-0'
|
|
69
|
+
)}
|
|
70
|
+
/>
|
|
71
|
+
<Copy
|
|
72
|
+
className={cn(
|
|
73
|
+
icon,
|
|
74
|
+
copied ? 'scale-50 opacity-0' : 'scale-100 opacity-100'
|
|
75
|
+
)}
|
|
76
|
+
/>
|
|
77
|
+
</span>
|
|
78
|
+
{/* biome-ignore lint/a11y/useSemanticElements: <output> is a form control */}
|
|
79
|
+
<span role="status" className="sr-only">
|
|
80
|
+
{copied ? 'Copied' : ''}
|
|
81
|
+
</span>
|
|
82
|
+
</IconButton>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
CopyButton.displayName = 'CopyButton';
|
|
@@ -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 {
|
|
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
|
-
//
|
|
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="
|
|
125
|
+
size="small"
|
|
171
126
|
className="align-baseline"
|
|
172
|
-
|
|
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
|
-
|
|
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
|
-
<
|
|
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="
|
|
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 {
|
|
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
|
|
22
|
-
* Three states: idle
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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 (
|
|
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 '
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
className="absolute right-2 top-2
|
|
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 && (
|