@cerebriline/ui 0.0.0-stage → 4.100.313
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/ADOPTION.md +833 -0
- package/LICENSE +201 -0
- package/RADIX-COLORS-LICENSE +21 -0
- package/README.md +427 -2
- package/components/agent-approval-card.css +70 -0
- package/components/agent-approval-card.tsx +109 -0
- package/components/agent-ask-question.css +103 -0
- package/components/agent-ask-question.tsx +276 -0
- package/components/agent-aurora.css +228 -0
- package/components/agent-aurora.tsx +96 -0
- package/components/agent-changes.css +13 -0
- package/components/agent-changes.tsx +167 -0
- package/components/agent-chat/agent-chat.css +556 -0
- package/components/agent-chat/index.tsx +1037 -0
- package/components/agent-chat/tool-diff.tsx +165 -0
- package/components/agent-chat/tool-summary/agents.ts +114 -0
- package/components/agent-chat/tool-summary/diff.ts +152 -0
- package/components/agent-chat/tool-summary/index.ts +928 -0
- package/components/agent-chat/tool-summary/parsers.ts +611 -0
- package/components/agent-chat/tool-summary/paths.ts +84 -0
- package/components/agent-chat/tool-summary/team.ts +401 -0
- package/components/agent-command-output.tsx +63 -0
- package/components/agent-composer.tsx +263 -0
- package/components/agent-context-usage.tsx +181 -0
- package/components/agent-conversation-layout.tsx +139 -0
- package/components/agent-hero-heading.css +53 -0
- package/components/agent-hero-heading.tsx +45 -0
- package/components/agent-image-lightbox.tsx +48 -0
- package/components/agent-prompt-queue.css +20 -0
- package/components/agent-prompt-queue.tsx +350 -0
- package/components/agent-pull-request-bar.css +13 -0
- package/components/agent-pull-request-bar.tsx +346 -0
- package/components/agent-quick-actions.css +19 -0
- package/components/agent-quick-actions.tsx +70 -0
- package/components/agent-session-row.tsx +183 -0
- package/components/agent-welcome-hero-pointer.ts +199 -0
- package/components/agent-welcome-hero.css +205 -0
- package/components/agent-welcome-hero.tsx +68 -0
- package/components/attachment-drop-zone.tsx +154 -0
- package/components/badge.tsx +21 -0
- package/components/button.tsx +324 -0
- package/components/generated-media.tsx +173 -0
- package/components/github-icon.tsx +19 -0
- package/components/index.ts +133 -0
- package/components/markdown.css +490 -0
- package/components/markdown.ts +365 -0
- package/components/mermaid-block.tsx +722 -0
- package/components/mermaid-diagram.ts +1260 -0
- package/components/mermaid-dom.ts +301 -0
- package/components/message-scroller.css +118 -0
- package/components/message-scroller.tsx +114 -0
- package/components/search-combobox.css +67 -0
- package/components/search-combobox.tsx +433 -0
- package/components/session-status.css +19 -0
- package/components/session-status.tsx +39 -0
- package/components/switch.css +221 -0
- package/components/switch.tsx +48 -0
- package/components.css +16 -0
- package/dist/components/agent-approval-card.d.ts +14 -0
- package/dist/components/agent-approval-card.d.ts.map +1 -0
- package/dist/components/agent-approval-card.js +12 -0
- package/dist/components/agent-approval-card.js.map +1 -0
- package/dist/components/agent-ask-question.d.ts +18 -0
- package/dist/components/agent-ask-question.d.ts.map +1 -0
- package/dist/components/agent-ask-question.js +101 -0
- package/dist/components/agent-ask-question.js.map +1 -0
- package/dist/components/agent-aurora.d.ts +3 -0
- package/dist/components/agent-aurora.d.ts.map +1 -0
- package/dist/components/agent-aurora.js +60 -0
- package/dist/components/agent-aurora.js.map +1 -0
- package/dist/components/agent-changes.d.ts +26 -0
- package/dist/components/agent-changes.d.ts.map +1 -0
- package/dist/components/agent-changes.js +19 -0
- package/dist/components/agent-changes.js.map +1 -0
- package/dist/components/agent-chat/disclosure.d.ts +25 -0
- package/dist/components/agent-chat/disclosure.d.ts.map +1 -0
- package/dist/components/agent-chat/disclosure.js +39 -0
- package/dist/components/agent-chat/disclosure.js.map +1 -0
- package/dist/components/agent-chat/index.d.ts +140 -0
- package/dist/components/agent-chat/index.d.ts.map +1 -0
- package/dist/components/agent-chat/index.js +379 -0
- package/dist/components/agent-chat/index.js.map +1 -0
- package/dist/components/agent-chat/tool-diff.d.ts +32 -0
- package/dist/components/agent-chat/tool-diff.d.ts.map +1 -0
- package/dist/components/agent-chat/tool-diff.js +97 -0
- package/dist/components/agent-chat/tool-diff.js.map +1 -0
- package/dist/components/agent-chat/tool-summary/agents.d.ts +10 -0
- package/dist/components/agent-chat/tool-summary/agents.d.ts.map +1 -0
- package/dist/components/agent-chat/tool-summary/agents.js +100 -0
- package/dist/components/agent-chat/tool-summary/agents.js.map +1 -0
- package/dist/components/agent-chat/tool-summary/diff.d.ts +22 -0
- package/dist/components/agent-chat/tool-summary/diff.d.ts.map +1 -0
- package/dist/components/agent-chat/tool-summary/diff.js +127 -0
- package/dist/components/agent-chat/tool-summary/diff.js.map +1 -0
- package/dist/components/agent-chat/tool-summary/index.d.ts +145 -0
- package/dist/components/agent-chat/tool-summary/index.d.ts.map +1 -0
- package/dist/components/agent-chat/tool-summary/index.js +663 -0
- package/dist/components/agent-chat/tool-summary/index.js.map +1 -0
- package/dist/components/agent-chat/tool-summary/parsers.d.ts +114 -0
- package/dist/components/agent-chat/tool-summary/parsers.d.ts.map +1 -0
- package/dist/components/agent-chat/tool-summary/parsers.js +502 -0
- package/dist/components/agent-chat/tool-summary/parsers.js.map +1 -0
- package/dist/components/agent-chat/tool-summary/paths.d.ts +10 -0
- package/dist/components/agent-chat/tool-summary/paths.d.ts.map +1 -0
- package/dist/components/agent-chat/tool-summary/paths.js +88 -0
- package/dist/components/agent-chat/tool-summary/paths.js.map +1 -0
- package/dist/components/agent-chat/tool-summary/team.d.ts +16 -0
- package/dist/components/agent-chat/tool-summary/team.d.ts.map +1 -0
- package/dist/components/agent-chat/tool-summary/team.js +283 -0
- package/dist/components/agent-chat/tool-summary/team.js.map +1 -0
- package/dist/components/agent-command-output.d.ts +14 -0
- package/dist/components/agent-command-output.d.ts.map +1 -0
- package/dist/components/agent-command-output.js +22 -0
- package/dist/components/agent-command-output.js.map +1 -0
- package/dist/components/agent-composer.d.ts +34 -0
- package/dist/components/agent-composer.d.ts.map +1 -0
- package/dist/components/agent-composer.js +65 -0
- package/dist/components/agent-composer.js.map +1 -0
- package/dist/components/agent-context-usage.d.ts +28 -0
- package/dist/components/agent-context-usage.d.ts.map +1 -0
- package/dist/components/agent-context-usage.js +51 -0
- package/dist/components/agent-context-usage.js.map +1 -0
- package/dist/components/agent-conversation-layout.d.ts +30 -0
- package/dist/components/agent-conversation-layout.d.ts.map +1 -0
- package/dist/components/agent-conversation-layout.js +24 -0
- package/dist/components/agent-conversation-layout.js.map +1 -0
- package/dist/components/agent-hero-heading.d.ts +2 -0
- package/dist/components/agent-hero-heading.d.ts.map +1 -0
- package/dist/components/agent-hero-heading.js +20 -0
- package/dist/components/agent-hero-heading.js.map +1 -0
- package/dist/components/agent-image-lightbox.d.ts +11 -0
- package/dist/components/agent-image-lightbox.d.ts.map +1 -0
- package/dist/components/agent-image-lightbox.js +8 -0
- package/dist/components/agent-image-lightbox.js.map +1 -0
- package/dist/components/agent-prompt-queue.d.ts +14 -0
- package/dist/components/agent-prompt-queue.d.ts.map +1 -0
- package/dist/components/agent-prompt-queue.js +114 -0
- package/dist/components/agent-prompt-queue.js.map +1 -0
- package/dist/components/agent-pull-request-bar.d.ts +72 -0
- package/dist/components/agent-pull-request-bar.d.ts.map +1 -0
- package/dist/components/agent-pull-request-bar.js +90 -0
- package/dist/components/agent-pull-request-bar.js.map +1 -0
- package/dist/components/agent-quick-actions.d.ts +14 -0
- package/dist/components/agent-quick-actions.d.ts.map +1 -0
- package/dist/components/agent-quick-actions.js +12 -0
- package/dist/components/agent-quick-actions.js.map +1 -0
- package/dist/components/agent-session-row.d.ts +45 -0
- package/dist/components/agent-session-row.d.ts.map +1 -0
- package/dist/components/agent-session-row.js +34 -0
- package/dist/components/agent-session-row.js.map +1 -0
- package/dist/components/agent-welcome-hero-pointer.d.ts +3 -0
- package/dist/components/agent-welcome-hero-pointer.d.ts.map +1 -0
- package/dist/components/agent-welcome-hero-pointer.js +169 -0
- package/dist/components/agent-welcome-hero-pointer.js.map +1 -0
- package/dist/components/agent-welcome-hero.d.ts +9 -0
- package/dist/components/agent-welcome-hero.d.ts.map +1 -0
- package/dist/components/agent-welcome-hero.js +14 -0
- package/dist/components/agent-welcome-hero.js.map +1 -0
- package/dist/components/attachment-drop-zone.d.ts +15 -0
- package/dist/components/attachment-drop-zone.d.ts.map +1 -0
- package/dist/components/attachment-drop-zone.js +64 -0
- package/dist/components/attachment-drop-zone.js.map +1 -0
- package/dist/components/badge.d.ts +5 -0
- package/dist/components/badge.d.ts.map +1 -0
- package/dist/components/badge.js +7 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/button.d.ts +27 -0
- package/dist/components/button.d.ts.map +1 -0
- package/dist/components/button.js +209 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/generated-media.d.ts +12 -0
- package/dist/components/generated-media.d.ts.map +1 -0
- package/dist/components/generated-media.js +105 -0
- package/dist/components/generated-media.js.map +1 -0
- package/dist/components/github-icon.d.ts +3 -0
- package/dist/components/github-icon.d.ts.map +1 -0
- package/dist/components/github-icon.js +6 -0
- package/dist/components/github-icon.js.map +1 -0
- package/dist/components/index.d.ts +24 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +25 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/markdown.d.ts +48 -0
- package/dist/components/markdown.d.ts.map +1 -0
- package/dist/components/markdown.js +264 -0
- package/dist/components/markdown.js.map +1 -0
- package/dist/components/mermaid-block.d.ts +14 -0
- package/dist/components/mermaid-block.d.ts.map +1 -0
- package/dist/components/mermaid-block.js +339 -0
- package/dist/components/mermaid-block.js.map +1 -0
- package/dist/components/mermaid-diagram.d.ts +264 -0
- package/dist/components/mermaid-diagram.d.ts.map +1 -0
- package/dist/components/mermaid-diagram.js +999 -0
- package/dist/components/mermaid-diagram.js.map +1 -0
- package/dist/components/mermaid-dom.d.ts +51 -0
- package/dist/components/mermaid-dom.d.ts.map +1 -0
- package/dist/components/mermaid-dom.js +246 -0
- package/dist/components/mermaid-dom.js.map +1 -0
- package/dist/components/message-scroller.d.ts +23 -0
- package/dist/components/message-scroller.d.ts.map +1 -0
- package/dist/components/message-scroller.js +31 -0
- package/dist/components/message-scroller.js.map +1 -0
- package/dist/components/search-combobox.d.ts +44 -0
- package/dist/components/search-combobox.d.ts.map +1 -0
- package/dist/components/search-combobox.js +191 -0
- package/dist/components/search-combobox.js.map +1 -0
- package/dist/components/session-status.d.ts +9 -0
- package/dist/components/session-status.d.ts.map +1 -0
- package/dist/components/session-status.js +11 -0
- package/dist/components/session-status.js.map +1 -0
- package/dist/components/switch.d.ts +7 -0
- package/dist/components/switch.d.ts.map +1 -0
- package/dist/components/switch.js +14 -0
- package/dist/components/switch.js.map +1 -0
- package/package.json +177 -5
- package/theme/base.css +83 -0
- package/theme/component-theme.css +126 -0
- package/theme/index.css +3 -0
- package/theme/palette.css +347 -0
- package/theme/scoped-tokens.css +503 -0
- package/theme/theme.css +90 -0
- package/theme/tokens.css +165 -0
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
4
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
5
|
+
import { clsx } from "clsx";
|
|
6
|
+
import {
|
|
7
|
+
type ButtonHTMLAttributes,
|
|
8
|
+
cloneElement,
|
|
9
|
+
forwardRef,
|
|
10
|
+
isValidElement,
|
|
11
|
+
type MouseEventHandler,
|
|
12
|
+
type ReactNode,
|
|
13
|
+
} from "react";
|
|
14
|
+
|
|
15
|
+
const BASE =
|
|
16
|
+
"inline-flex items-center justify-center whitespace-nowrap rounded-cline-ui-md font-cline-ui-medium cursor-pointer " +
|
|
17
|
+
"disabled:pointer-events-none disabled:opacity-50 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 " +
|
|
18
|
+
"[&_svg]:pointer-events-none [&_svg]:shrink-0 shrink-0 " +
|
|
19
|
+
"outline-none focus-visible:ring-2 focus-visible:ring-cline-ui-ring/60 transition-colors";
|
|
20
|
+
|
|
21
|
+
// ─── Button ───────────────────────────────────────────────────────────────────
|
|
22
|
+
|
|
23
|
+
export const buttonVariants = cva(BASE, {
|
|
24
|
+
variants: {
|
|
25
|
+
variant: {
|
|
26
|
+
fill: "",
|
|
27
|
+
surface: "",
|
|
28
|
+
ghost: "",
|
|
29
|
+
},
|
|
30
|
+
tone: {
|
|
31
|
+
accent: "",
|
|
32
|
+
neutral: "",
|
|
33
|
+
destructive: "",
|
|
34
|
+
},
|
|
35
|
+
size: {
|
|
36
|
+
xs: "h-7 px-2.5 gap-1.5 text-cline-ui-xs [&_svg:not([class*='size-'])]:size-3",
|
|
37
|
+
sm: "h-8 px-3 gap-1.5 text-cline-ui-sm [&_svg:not([class*='size-'])]:size-3.5",
|
|
38
|
+
md: "h-9 px-3.5 gap-2 text-cline-ui-sm [&_svg:not([class*='size-'])]:size-4",
|
|
39
|
+
lg: "h-10 px-4 gap-2 text-cline-ui-base [&_svg:not([class*='size-'])]:size-4",
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
compoundVariants: [
|
|
43
|
+
// fill
|
|
44
|
+
{
|
|
45
|
+
variant: "fill",
|
|
46
|
+
tone: "accent",
|
|
47
|
+
className:
|
|
48
|
+
"bg-cline-ui-primary text-cline-ui-primary-foreground hover:bg-cline-ui-primary-emphasis",
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
variant: "fill",
|
|
52
|
+
tone: "neutral",
|
|
53
|
+
className:
|
|
54
|
+
"bg-cline-ui-secondary text-cline-ui-secondary-foreground hover:bg-cline-ui-border",
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
variant: "fill",
|
|
58
|
+
tone: "destructive",
|
|
59
|
+
className:
|
|
60
|
+
"bg-cline-ui-destructive text-cline-ui-destructive-foreground hover:bg-cline-ui-destructive/90",
|
|
61
|
+
},
|
|
62
|
+
// surface
|
|
63
|
+
{
|
|
64
|
+
variant: "surface",
|
|
65
|
+
tone: "accent",
|
|
66
|
+
className:
|
|
67
|
+
"bg-cline-ui-accent text-cline-ui-accent-foreground hover:bg-cline-ui-primary/15",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
variant: "surface",
|
|
71
|
+
tone: "neutral",
|
|
72
|
+
className:
|
|
73
|
+
"bg-cline-ui-surface-hover-lighter text-cline-ui-foreground hover:bg-cline-ui-surface-hover",
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
variant: "surface",
|
|
77
|
+
tone: "destructive",
|
|
78
|
+
className:
|
|
79
|
+
"bg-cline-ui-destructive/10 text-cline-ui-destructive hover:bg-cline-ui-destructive/15",
|
|
80
|
+
},
|
|
81
|
+
// ghost
|
|
82
|
+
{
|
|
83
|
+
variant: "ghost",
|
|
84
|
+
tone: "accent",
|
|
85
|
+
className: "text-cline-ui-primary hover:bg-cline-ui-primary/10",
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
variant: "ghost",
|
|
89
|
+
tone: "neutral",
|
|
90
|
+
className:
|
|
91
|
+
"text-cline-ui-muted-foreground hover:bg-cline-ui-surface-hover hover:text-cline-ui-foreground",
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
variant: "ghost",
|
|
95
|
+
tone: "destructive",
|
|
96
|
+
className: "text-cline-ui-destructive hover:bg-cline-ui-destructive/10",
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
defaultVariants: {
|
|
100
|
+
variant: "fill",
|
|
101
|
+
tone: "accent",
|
|
102
|
+
size: "md",
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
export type ButtonVariant = NonNullable<
|
|
107
|
+
VariantProps<typeof buttonVariants>["variant"]
|
|
108
|
+
>;
|
|
109
|
+
export type ButtonTone = NonNullable<
|
|
110
|
+
VariantProps<typeof buttonVariants>["tone"]
|
|
111
|
+
>;
|
|
112
|
+
export type ButtonSize = NonNullable<
|
|
113
|
+
VariantProps<typeof buttonVariants>["size"]
|
|
114
|
+
>;
|
|
115
|
+
|
|
116
|
+
export interface ButtonProps
|
|
117
|
+
extends ButtonHTMLAttributes<HTMLButtonElement>,
|
|
118
|
+
VariantProps<typeof buttonVariants> {
|
|
119
|
+
asChild?: boolean;
|
|
120
|
+
children?: ReactNode;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const preventDisabledActivation: MouseEventHandler<HTMLElement> = (event) => {
|
|
124
|
+
event.preventDefault();
|
|
125
|
+
event.stopPropagation();
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
function disableComposedChild(children: ReactNode) {
|
|
129
|
+
if (
|
|
130
|
+
!isValidElement<{
|
|
131
|
+
onClick?: MouseEventHandler;
|
|
132
|
+
onClickCapture?: MouseEventHandler;
|
|
133
|
+
}>(children)
|
|
134
|
+
) {
|
|
135
|
+
return children;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Radix Slot composes same-element event handlers child-first. Remove the
|
|
139
|
+
// child's activation handlers before Slot sees them so disabled composed
|
|
140
|
+
// controls cannot run an action before our guard.
|
|
141
|
+
return cloneElement(children, {
|
|
142
|
+
onClick: preventDisabledActivation,
|
|
143
|
+
onClickCapture: preventDisabledActivation,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
148
|
+
(
|
|
149
|
+
{
|
|
150
|
+
asChild = false,
|
|
151
|
+
children,
|
|
152
|
+
className,
|
|
153
|
+
disabled,
|
|
154
|
+
onClick,
|
|
155
|
+
onClickCapture,
|
|
156
|
+
size,
|
|
157
|
+
tone,
|
|
158
|
+
type,
|
|
159
|
+
variant,
|
|
160
|
+
...props
|
|
161
|
+
},
|
|
162
|
+
ref,
|
|
163
|
+
) => {
|
|
164
|
+
const Comp = asChild ? Slot : "button";
|
|
165
|
+
return (
|
|
166
|
+
<Comp
|
|
167
|
+
{...props}
|
|
168
|
+
className={clsx(buttonVariants({ size, tone, variant }), className)}
|
|
169
|
+
data-slot="button"
|
|
170
|
+
ref={ref}
|
|
171
|
+
{...(asChild
|
|
172
|
+
? disabled
|
|
173
|
+
? {
|
|
174
|
+
"aria-disabled": true,
|
|
175
|
+
"data-disabled": "",
|
|
176
|
+
onClick: preventDisabledActivation,
|
|
177
|
+
onClickCapture: preventDisabledActivation,
|
|
178
|
+
tabIndex: -1,
|
|
179
|
+
}
|
|
180
|
+
: { onClick, onClickCapture }
|
|
181
|
+
: { disabled, onClick, onClickCapture, type: type ?? "button" })}
|
|
182
|
+
>
|
|
183
|
+
{asChild && disabled ? disableComposedChild(children) : children}
|
|
184
|
+
</Comp>
|
|
185
|
+
);
|
|
186
|
+
},
|
|
187
|
+
);
|
|
188
|
+
Button.displayName = "Button";
|
|
189
|
+
|
|
190
|
+
// ─── IconButton ───────────────────────────────────────────────────────────────
|
|
191
|
+
|
|
192
|
+
export const iconButtonVariants = cva(BASE, {
|
|
193
|
+
variants: {
|
|
194
|
+
variant: {
|
|
195
|
+
fill: "",
|
|
196
|
+
surface: "",
|
|
197
|
+
ghost: "",
|
|
198
|
+
},
|
|
199
|
+
tone: {
|
|
200
|
+
accent: "",
|
|
201
|
+
neutral: "",
|
|
202
|
+
destructive: "",
|
|
203
|
+
},
|
|
204
|
+
size: {
|
|
205
|
+
xs: "size-7 [&_svg:not([class*='size-'])]:size-3.5",
|
|
206
|
+
sm: "size-8 [&_svg:not([class*='size-'])]:size-4",
|
|
207
|
+
md: "size-9 [&_svg:not([class*='size-'])]:size-4",
|
|
208
|
+
lg: "size-10 [&_svg:not([class*='size-'])]:size-5",
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
compoundVariants: [
|
|
212
|
+
// fill
|
|
213
|
+
{
|
|
214
|
+
variant: "fill",
|
|
215
|
+
tone: "accent",
|
|
216
|
+
className:
|
|
217
|
+
"bg-cline-ui-primary text-cline-ui-primary-foreground hover:bg-cline-ui-primary-emphasis",
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
variant: "fill",
|
|
221
|
+
tone: "neutral",
|
|
222
|
+
className:
|
|
223
|
+
"bg-cline-ui-secondary text-cline-ui-secondary-foreground hover:bg-cline-ui-border",
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
variant: "fill",
|
|
227
|
+
tone: "destructive",
|
|
228
|
+
className:
|
|
229
|
+
"bg-cline-ui-destructive text-cline-ui-destructive-foreground hover:bg-cline-ui-destructive/90",
|
|
230
|
+
},
|
|
231
|
+
// surface
|
|
232
|
+
{
|
|
233
|
+
variant: "surface",
|
|
234
|
+
tone: "accent",
|
|
235
|
+
className:
|
|
236
|
+
"bg-cline-ui-accent text-cline-ui-accent-foreground hover:bg-cline-ui-primary/15",
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
variant: "surface",
|
|
240
|
+
tone: "neutral",
|
|
241
|
+
className:
|
|
242
|
+
"bg-cline-ui-surface-hover-lighter text-cline-ui-foreground hover:bg-cline-ui-surface-hover",
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
variant: "surface",
|
|
246
|
+
tone: "destructive",
|
|
247
|
+
className:
|
|
248
|
+
"bg-cline-ui-destructive/10 text-cline-ui-destructive hover:bg-cline-ui-destructive/15",
|
|
249
|
+
},
|
|
250
|
+
// ghost
|
|
251
|
+
{
|
|
252
|
+
variant: "ghost",
|
|
253
|
+
tone: "accent",
|
|
254
|
+
className: "text-cline-ui-primary hover:bg-cline-ui-primary/10",
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
variant: "ghost",
|
|
258
|
+
tone: "neutral",
|
|
259
|
+
className:
|
|
260
|
+
"text-cline-ui-muted-foreground hover:bg-cline-ui-surface-hover hover:text-cline-ui-foreground",
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
variant: "ghost",
|
|
264
|
+
tone: "destructive",
|
|
265
|
+
className: "text-cline-ui-destructive hover:bg-cline-ui-destructive/10",
|
|
266
|
+
},
|
|
267
|
+
],
|
|
268
|
+
defaultVariants: {
|
|
269
|
+
variant: "ghost",
|
|
270
|
+
tone: "neutral",
|
|
271
|
+
size: "sm",
|
|
272
|
+
},
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
export interface IconButtonProps
|
|
276
|
+
extends ButtonHTMLAttributes<HTMLButtonElement>,
|
|
277
|
+
VariantProps<typeof iconButtonVariants> {
|
|
278
|
+
"aria-label": string;
|
|
279
|
+
asChild?: boolean;
|
|
280
|
+
children?: ReactNode;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(
|
|
284
|
+
(
|
|
285
|
+
{
|
|
286
|
+
asChild = false,
|
|
287
|
+
children,
|
|
288
|
+
className,
|
|
289
|
+
disabled,
|
|
290
|
+
onClick,
|
|
291
|
+
onClickCapture,
|
|
292
|
+
size,
|
|
293
|
+
tone,
|
|
294
|
+
type,
|
|
295
|
+
variant,
|
|
296
|
+
...props
|
|
297
|
+
},
|
|
298
|
+
ref,
|
|
299
|
+
) => {
|
|
300
|
+
const Comp = asChild ? Slot : "button";
|
|
301
|
+
return (
|
|
302
|
+
<Comp
|
|
303
|
+
{...props}
|
|
304
|
+
className={clsx(iconButtonVariants({ size, tone, variant }), className)}
|
|
305
|
+
data-slot="icon-button"
|
|
306
|
+
ref={ref}
|
|
307
|
+
{...(asChild
|
|
308
|
+
? disabled
|
|
309
|
+
? {
|
|
310
|
+
"aria-disabled": true,
|
|
311
|
+
"data-disabled": "",
|
|
312
|
+
onClick: preventDisabledActivation,
|
|
313
|
+
onClickCapture: preventDisabledActivation,
|
|
314
|
+
tabIndex: -1,
|
|
315
|
+
}
|
|
316
|
+
: { onClick, onClickCapture }
|
|
317
|
+
: { disabled, onClick, onClickCapture, type: type ?? "button" })}
|
|
318
|
+
>
|
|
319
|
+
{asChild && disabled ? disableComposedChild(children) : children}
|
|
320
|
+
</Comp>
|
|
321
|
+
);
|
|
322
|
+
},
|
|
323
|
+
);
|
|
324
|
+
IconButton.displayName = "IconButton";
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
DEFAULT_MAX_TOTAL_MEDIA_BYTES,
|
|
5
|
+
type GeneratedMedia,
|
|
6
|
+
type GeneratedMediaModality,
|
|
7
|
+
isCanonicalBase64,
|
|
8
|
+
SUPPORTED_IMAGE_MEDIA_TYPES,
|
|
9
|
+
} from "@cerebriline/shared/browser";
|
|
10
|
+
import { useEffect, useState } from "react";
|
|
11
|
+
|
|
12
|
+
export interface GeneratedMediaClassNames
|
|
13
|
+
extends Partial<Record<GeneratedMediaModality, string>> {
|
|
14
|
+
unavailable?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface GeneratedMediaContentProps {
|
|
18
|
+
media: GeneratedMedia;
|
|
19
|
+
className?: string;
|
|
20
|
+
classNames?: GeneratedMediaClassNames;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function decodeBase64(data: string): ArrayBuffer | undefined {
|
|
24
|
+
if (data.length > DEFAULT_MAX_TOTAL_MEDIA_BYTES || !isCanonicalBase64(data)) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
const binary = atob(data);
|
|
29
|
+
const buffer = new ArrayBuffer(binary.length);
|
|
30
|
+
const bytes = new Uint8Array(buffer);
|
|
31
|
+
for (let index = 0; index < binary.length; index += 1) {
|
|
32
|
+
bytes[index] = binary.charCodeAt(index);
|
|
33
|
+
}
|
|
34
|
+
return buffer;
|
|
35
|
+
} catch {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const MEDIA_TYPE_PATTERN =
|
|
41
|
+
/^[a-z0-9][a-z0-9!#$&^_.+-]*\/[a-z0-9][a-z0-9!#$&^_.+-]*$/i;
|
|
42
|
+
|
|
43
|
+
function renderableMediaType(media: GeneratedMedia): string | undefined {
|
|
44
|
+
const mediaType = media.mediaType.trim().toLowerCase();
|
|
45
|
+
if (!MEDIA_TYPE_PATTERN.test(mediaType)) return undefined;
|
|
46
|
+
switch (media.modality) {
|
|
47
|
+
case "image":
|
|
48
|
+
return (SUPPORTED_IMAGE_MEDIA_TYPES as readonly string[]).includes(
|
|
49
|
+
mediaType,
|
|
50
|
+
)
|
|
51
|
+
? mediaType
|
|
52
|
+
: undefined;
|
|
53
|
+
case "audio":
|
|
54
|
+
return mediaType.startsWith("audio/") ? mediaType : undefined;
|
|
55
|
+
case "video":
|
|
56
|
+
return mediaType.startsWith("video/") ? mediaType : undefined;
|
|
57
|
+
case "file":
|
|
58
|
+
// Files are downloads, never active browser content.
|
|
59
|
+
return "application/octet-stream";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Materialize provider bytes behind a browser-owned URL.
|
|
65
|
+
*
|
|
66
|
+
* Never bind a provider-supplied URL or data URL directly to a DOM navigation
|
|
67
|
+
* sink. Remote and artifact sources require a client-owned resolver with an
|
|
68
|
+
* explicit trust policy; this shared renderer only displays validated inline
|
|
69
|
+
* bytes and revokes the temporary URL when the content changes.
|
|
70
|
+
*/
|
|
71
|
+
function useInlineMediaUrl(media: GeneratedMedia): string | undefined {
|
|
72
|
+
const inlineData =
|
|
73
|
+
media.source.type === "base64" ? media.source.data : undefined;
|
|
74
|
+
const [source, setSource] = useState<string>();
|
|
75
|
+
const blobMediaType = renderableMediaType(media);
|
|
76
|
+
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
setSource(undefined);
|
|
79
|
+
if (inlineData === undefined || blobMediaType === undefined) return;
|
|
80
|
+
|
|
81
|
+
const bytes = decodeBase64(inlineData);
|
|
82
|
+
if (!bytes || typeof URL.createObjectURL !== "function") return;
|
|
83
|
+
|
|
84
|
+
let objectUrl: string;
|
|
85
|
+
try {
|
|
86
|
+
objectUrl = URL.createObjectURL(
|
|
87
|
+
new Blob([bytes], { type: blobMediaType }),
|
|
88
|
+
);
|
|
89
|
+
} catch {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
setSource(objectUrl);
|
|
93
|
+
return () => URL.revokeObjectURL?.(objectUrl);
|
|
94
|
+
}, [blobMediaType, inlineData]);
|
|
95
|
+
|
|
96
|
+
return source;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function unavailableMessage(media: GeneratedMedia): string {
|
|
100
|
+
if (media.source.type === "artifact") {
|
|
101
|
+
return `Generated ${media.modality} is stored as an artifact (${media.source.artifactId}).`;
|
|
102
|
+
}
|
|
103
|
+
if (media.source.type === "url") {
|
|
104
|
+
return `Generated ${media.modality} requires a trusted remote-media resolver.`;
|
|
105
|
+
}
|
|
106
|
+
return `Generated ${media.modality} could not be rendered.`;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Render canonical generated media with a safe fallback for artifact refs. */
|
|
110
|
+
export function GeneratedMediaContent({
|
|
111
|
+
media,
|
|
112
|
+
className,
|
|
113
|
+
classNames,
|
|
114
|
+
}: GeneratedMediaContentProps) {
|
|
115
|
+
const source = useInlineMediaUrl(media);
|
|
116
|
+
const browserOwnedSource = source?.startsWith("blob:") ? source : undefined;
|
|
117
|
+
if (!browserOwnedSource) {
|
|
118
|
+
return (
|
|
119
|
+
<div
|
|
120
|
+
className={classNames?.unavailable ?? className}
|
|
121
|
+
data-media-id={media.id}
|
|
122
|
+
data-testid="generated-media-unavailable"
|
|
123
|
+
>
|
|
124
|
+
{unavailableMessage(media)}
|
|
125
|
+
</div>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const modalityClassName = classNames?.[media.modality] ?? className;
|
|
130
|
+
switch (media.modality) {
|
|
131
|
+
case "image":
|
|
132
|
+
return (
|
|
133
|
+
<img
|
|
134
|
+
alt={media.name ?? "Generated image"}
|
|
135
|
+
className={modalityClassName}
|
|
136
|
+
data-media-id={media.id}
|
|
137
|
+
src={browserOwnedSource}
|
|
138
|
+
/>
|
|
139
|
+
);
|
|
140
|
+
case "audio":
|
|
141
|
+
return (
|
|
142
|
+
// biome-ignore lint/a11y/useMediaCaption: Model-generated audio does not include a caption track.
|
|
143
|
+
<audio
|
|
144
|
+
className={modalityClassName}
|
|
145
|
+
controls
|
|
146
|
+
data-media-id={media.id}
|
|
147
|
+
src={browserOwnedSource}
|
|
148
|
+
/>
|
|
149
|
+
);
|
|
150
|
+
case "video":
|
|
151
|
+
return (
|
|
152
|
+
// biome-ignore lint/a11y/useMediaCaption: Model-generated video does not include a caption track.
|
|
153
|
+
<video
|
|
154
|
+
className={modalityClassName}
|
|
155
|
+
controls
|
|
156
|
+
data-media-id={media.id}
|
|
157
|
+
src={browserOwnedSource}
|
|
158
|
+
/>
|
|
159
|
+
);
|
|
160
|
+
case "file":
|
|
161
|
+
return (
|
|
162
|
+
<a
|
|
163
|
+
className={modalityClassName}
|
|
164
|
+
data-media-id={media.id}
|
|
165
|
+
download={media.name ?? true}
|
|
166
|
+
href={browserOwnedSource}
|
|
167
|
+
>
|
|
168
|
+
{media.name ?? `Generated file (${media.mediaType})`}
|
|
169
|
+
</a>
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { SVGProps } from "react";
|
|
4
|
+
|
|
5
|
+
export function GitHubIcon(props: SVGProps<SVGSVGElement>) {
|
|
6
|
+
return (
|
|
7
|
+
<svg
|
|
8
|
+
aria-hidden="true"
|
|
9
|
+
fill="currentColor"
|
|
10
|
+
height={16}
|
|
11
|
+
viewBox="0 0 24 24"
|
|
12
|
+
width={16}
|
|
13
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
14
|
+
{...props}
|
|
15
|
+
>
|
|
16
|
+
<path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12" />
|
|
17
|
+
</svg>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
export {
|
|
4
|
+
type AgentApprovalAction,
|
|
5
|
+
AgentApprovalCard,
|
|
6
|
+
type AgentApprovalCardProps,
|
|
7
|
+
} from "./agent-approval-card.js";
|
|
8
|
+
export {
|
|
9
|
+
AgentAskQuestion,
|
|
10
|
+
type AgentAskQuestionItem,
|
|
11
|
+
type AgentAskQuestionProps,
|
|
12
|
+
} from "./agent-ask-question.js";
|
|
13
|
+
export { AgentAurora } from "./agent-aurora.js";
|
|
14
|
+
export {
|
|
15
|
+
AgentChangedFile,
|
|
16
|
+
type AgentChangedFileProps,
|
|
17
|
+
AgentChangesPanel,
|
|
18
|
+
type AgentChangesPanelProps,
|
|
19
|
+
} from "./agent-changes.js";
|
|
20
|
+
export {
|
|
21
|
+
AgentCommandOutput,
|
|
22
|
+
type AgentCommandOutputProps,
|
|
23
|
+
} from "./agent-command-output.js";
|
|
24
|
+
export {
|
|
25
|
+
AgentComposer,
|
|
26
|
+
AgentComposerActions,
|
|
27
|
+
type AgentComposerActionsProps,
|
|
28
|
+
AgentComposerAttachments,
|
|
29
|
+
type AgentComposerAttachmentsProps,
|
|
30
|
+
AgentComposerBody,
|
|
31
|
+
type AgentComposerBodyProps,
|
|
32
|
+
AgentComposerField,
|
|
33
|
+
type AgentComposerFieldProps,
|
|
34
|
+
type AgentComposerProps,
|
|
35
|
+
AgentComposerSendButton,
|
|
36
|
+
type AgentComposerSendButtonProps,
|
|
37
|
+
AgentComposerSettings,
|
|
38
|
+
AgentComposerSettingsEnd,
|
|
39
|
+
type AgentComposerSettingsEndProps,
|
|
40
|
+
AgentComposerSettingsGroup,
|
|
41
|
+
type AgentComposerSettingsGroupProps,
|
|
42
|
+
type AgentComposerSettingsProps,
|
|
43
|
+
AgentComposerStopButton,
|
|
44
|
+
type AgentComposerStopButtonProps,
|
|
45
|
+
AgentComposerTextarea,
|
|
46
|
+
type AgentComposerTextareaProps,
|
|
47
|
+
type AgentComposerVariant,
|
|
48
|
+
} from "./agent-composer.js";
|
|
49
|
+
export {
|
|
50
|
+
AgentContextUsage,
|
|
51
|
+
type AgentContextUsageData,
|
|
52
|
+
type AgentContextUsagePresentation,
|
|
53
|
+
type AgentContextUsageProps,
|
|
54
|
+
} from "./agent-context-usage.js";
|
|
55
|
+
export {
|
|
56
|
+
AgentConversationHeader,
|
|
57
|
+
type AgentConversationHeaderProps,
|
|
58
|
+
AgentConversationLayout,
|
|
59
|
+
type AgentConversationLayoutProps,
|
|
60
|
+
AgentSessionContent,
|
|
61
|
+
type AgentSessionContentProps,
|
|
62
|
+
} from "./agent-conversation-layout.js";
|
|
63
|
+
export { AgentHeroHeading } from "./agent-hero-heading.js";
|
|
64
|
+
export {
|
|
65
|
+
AgentImageLightboxContent,
|
|
66
|
+
type AgentImageLightboxContentProps,
|
|
67
|
+
} from "./agent-image-lightbox.js";
|
|
68
|
+
export {
|
|
69
|
+
AgentPromptQueue,
|
|
70
|
+
type AgentPromptQueueItem,
|
|
71
|
+
type AgentPromptQueueProps,
|
|
72
|
+
} from "./agent-prompt-queue.js";
|
|
73
|
+
export {
|
|
74
|
+
AgentPullRequestBar,
|
|
75
|
+
type AgentPullRequestBarProps,
|
|
76
|
+
type AgentPullRequestCheck,
|
|
77
|
+
type AgentPullRequestData,
|
|
78
|
+
type AgentPullRequestNavigation,
|
|
79
|
+
getAgentPullRequestMergeStatus,
|
|
80
|
+
summarizeAgentPullRequestChecks,
|
|
81
|
+
} from "./agent-pull-request-bar.js";
|
|
82
|
+
export {
|
|
83
|
+
type AgentQuickAction,
|
|
84
|
+
AgentQuickActions,
|
|
85
|
+
type AgentQuickActionsProps,
|
|
86
|
+
} from "./agent-quick-actions.js";
|
|
87
|
+
export {
|
|
88
|
+
AgentSessionOverview,
|
|
89
|
+
type AgentSessionOverviewProps,
|
|
90
|
+
AgentSessionRow,
|
|
91
|
+
AgentSessionRowEditor,
|
|
92
|
+
type AgentSessionRowEditorProps,
|
|
93
|
+
type AgentSessionRowProps,
|
|
94
|
+
} from "./agent-session-row.js";
|
|
95
|
+
export {
|
|
96
|
+
AgentWelcomeHero,
|
|
97
|
+
type AgentWelcomeHeroLayout,
|
|
98
|
+
type AgentWelcomeHeroProps,
|
|
99
|
+
} from "./agent-welcome-hero.js";
|
|
100
|
+
export {
|
|
101
|
+
AttachmentDropZone,
|
|
102
|
+
type AttachmentDropZoneProps,
|
|
103
|
+
} from "./attachment-drop-zone.js";
|
|
104
|
+
export { Badge, type BadgeProps } from "./badge.js";
|
|
105
|
+
export {
|
|
106
|
+
Button,
|
|
107
|
+
type ButtonProps,
|
|
108
|
+
type ButtonSize,
|
|
109
|
+
type ButtonTone,
|
|
110
|
+
type ButtonVariant,
|
|
111
|
+
buttonVariants,
|
|
112
|
+
IconButton,
|
|
113
|
+
type IconButtonProps,
|
|
114
|
+
iconButtonVariants,
|
|
115
|
+
} from "./button.js";
|
|
116
|
+
export {
|
|
117
|
+
type GeneratedMediaClassNames,
|
|
118
|
+
GeneratedMediaContent,
|
|
119
|
+
type GeneratedMediaContentProps,
|
|
120
|
+
} from "./generated-media.js";
|
|
121
|
+
export { GitHubIcon } from "./github-icon.js";
|
|
122
|
+
export {
|
|
123
|
+
SearchCombobox,
|
|
124
|
+
type SearchComboboxOption,
|
|
125
|
+
type SearchComboboxProps,
|
|
126
|
+
type SearchComboboxSection,
|
|
127
|
+
} from "./search-combobox.js";
|
|
128
|
+
export {
|
|
129
|
+
SessionStatus,
|
|
130
|
+
type SessionStatusProps,
|
|
131
|
+
type SessionStatusTone,
|
|
132
|
+
} from "./session-status.js";
|
|
133
|
+
export { Switch, type SwitchProps } from "./switch.js";
|