@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,70 @@
|
|
|
1
|
+
.cline-ui-agent-approval-card,
|
|
2
|
+
.cline-ui-agent-approval-card__detail,
|
|
3
|
+
.cline-ui-agent-approval-card__button {
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
border-style: solid;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.cline-ui-agent-approval-card__detail {
|
|
9
|
+
margin: 0.5rem 0 0;
|
|
10
|
+
overflow-x: hidden;
|
|
11
|
+
overflow-y: auto;
|
|
12
|
+
white-space: pre-wrap;
|
|
13
|
+
overflow-wrap: break-word;
|
|
14
|
+
border: 1px solid color-mix(in oklab, var(--border) 70%, transparent);
|
|
15
|
+
border-radius: var(--radius-md);
|
|
16
|
+
background: var(--background);
|
|
17
|
+
padding: 0.5rem;
|
|
18
|
+
color: var(--muted-foreground);
|
|
19
|
+
font-family: var(--font-mono);
|
|
20
|
+
font-size: var(--text-xs);
|
|
21
|
+
line-height: var(--text-xs--line-height);
|
|
22
|
+
letter-spacing: var(--text-xs--letter-spacing);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.cline-ui-agent-approval-card__error {
|
|
26
|
+
margin-top: 0.5rem;
|
|
27
|
+
color: var(--error-text);
|
|
28
|
+
font-size: var(--text-xs);
|
|
29
|
+
line-height: var(--text-xs--line-height);
|
|
30
|
+
letter-spacing: var(--text-xs--letter-spacing);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.cline-ui-agent-approval-card__actions {
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
gap: 0.5rem;
|
|
37
|
+
margin-top: 0.5rem;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.cline-ui-agent-approval-card__button {
|
|
41
|
+
padding-block: 0;
|
|
42
|
+
font-family: inherit;
|
|
43
|
+
font-size: inherit;
|
|
44
|
+
font-style: inherit;
|
|
45
|
+
font-variant: inherit;
|
|
46
|
+
letter-spacing: inherit;
|
|
47
|
+
line-height: inherit;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.cline-ui-agent-approval-card__spinner {
|
|
51
|
+
animation: cline-ui-agent-approval-card-spin 1s linear infinite;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.cline-ui-agent-approval-card__button:has(
|
|
55
|
+
> .cline-ui-agent-approval-card__spinner
|
|
56
|
+
) {
|
|
57
|
+
padding-inline: 0.625rem;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@keyframes cline-ui-agent-approval-card-spin {
|
|
61
|
+
to {
|
|
62
|
+
transform: rotate(360deg);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@media (prefers-reduced-motion: reduce) {
|
|
67
|
+
.cline-ui-agent-approval-card__spinner {
|
|
68
|
+
animation: none;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { type ReactNode, useId } from "react";
|
|
4
|
+
|
|
5
|
+
export type AgentApprovalAction = "approve" | "reject";
|
|
6
|
+
|
|
7
|
+
export interface AgentApprovalCardProps {
|
|
8
|
+
description?: ReactNode;
|
|
9
|
+
detail?: ReactNode;
|
|
10
|
+
error?: ReactNode;
|
|
11
|
+
meta?: ReactNode;
|
|
12
|
+
onApprove: () => void;
|
|
13
|
+
onReject: () => void;
|
|
14
|
+
responding?: AgentApprovalAction;
|
|
15
|
+
title: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function Spinner() {
|
|
19
|
+
return (
|
|
20
|
+
<svg
|
|
21
|
+
aria-hidden="true"
|
|
22
|
+
className="cline-ui-agent-approval-card__spinner mr-1 size-3.5 fill-none stroke-current [stroke-linecap:round] [stroke-linejoin:round] stroke-2"
|
|
23
|
+
viewBox="0 0 24 24"
|
|
24
|
+
>
|
|
25
|
+
<path d="M21 12a9 9 0 1 1-6.219-8.56" />
|
|
26
|
+
</svg>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function AgentApprovalCard({
|
|
31
|
+
description,
|
|
32
|
+
detail,
|
|
33
|
+
error,
|
|
34
|
+
meta,
|
|
35
|
+
onApprove,
|
|
36
|
+
onReject,
|
|
37
|
+
responding,
|
|
38
|
+
title,
|
|
39
|
+
}: AgentApprovalCardProps) {
|
|
40
|
+
const titleId = useId();
|
|
41
|
+
const isPending = responding !== undefined;
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<section
|
|
45
|
+
aria-busy={isPending || undefined}
|
|
46
|
+
aria-labelledby={titleId}
|
|
47
|
+
className="cline-ui-agent-approval-card rounded-cline-ui-lg border border-cline-ui-border/80 bg-cline-ui-background/70 p-3"
|
|
48
|
+
>
|
|
49
|
+
<div className="cline-ui-agent-approval-card__header flex items-center justify-between gap-2">
|
|
50
|
+
<div
|
|
51
|
+
className="cline-ui-agent-approval-card__title font-cline-ui-medium text-cline-ui-foreground text-cline-ui-sm"
|
|
52
|
+
id={titleId}
|
|
53
|
+
>
|
|
54
|
+
{title}
|
|
55
|
+
</div>
|
|
56
|
+
{meta ? (
|
|
57
|
+
<div className="cline-ui-agent-approval-card__meta inline-flex items-center gap-1 text-[11px] text-cline-ui-muted-foreground">
|
|
58
|
+
{meta}
|
|
59
|
+
</div>
|
|
60
|
+
) : null}
|
|
61
|
+
</div>
|
|
62
|
+
{description ? (
|
|
63
|
+
<div className="cline-ui-agent-approval-card__description mt-1 text-[11px] text-cline-ui-muted-foreground">
|
|
64
|
+
{description}
|
|
65
|
+
</div>
|
|
66
|
+
) : null}
|
|
67
|
+
{detail != null ? (
|
|
68
|
+
<pre className="cline-ui-agent-approval-card__detail max-h-44 max-w-full">
|
|
69
|
+
{detail}
|
|
70
|
+
</pre>
|
|
71
|
+
) : null}
|
|
72
|
+
{error ? (
|
|
73
|
+
<div className="cline-ui-agent-approval-card__error">{error}</div>
|
|
74
|
+
) : null}
|
|
75
|
+
<div className="cline-ui-agent-approval-card__actions">
|
|
76
|
+
<button
|
|
77
|
+
className="cline-ui-agent-approval-card__button cline-ui-agent-approval-card__button--approve inline-flex h-8 shrink-0 cursor-pointer items-center justify-center gap-1.5 whitespace-nowrap rounded-cline-ui-md border-0 bg-cline-ui-primary px-3 font-cline-ui-medium text-cline-ui-primary-foreground transition-[color,background-color,border-color,box-shadow] duration-150 ease-[ease] [&:hover]:bg-cline-ui-primary/90 focus-visible:outline-3 focus-visible:outline-cline-ui-ring/50 focus-visible:outline-offset-0 disabled:pointer-events-none disabled:opacity-50"
|
|
78
|
+
disabled={isPending}
|
|
79
|
+
onClick={onApprove}
|
|
80
|
+
type="button"
|
|
81
|
+
>
|
|
82
|
+
{responding === "approve" ? (
|
|
83
|
+
<>
|
|
84
|
+
<Spinner />
|
|
85
|
+
Approving...
|
|
86
|
+
</>
|
|
87
|
+
) : (
|
|
88
|
+
"Approve"
|
|
89
|
+
)}
|
|
90
|
+
</button>
|
|
91
|
+
<button
|
|
92
|
+
className="cline-ui-agent-approval-card__button cline-ui-agent-approval-card__button--reject inline-flex h-8 shrink-0 cursor-pointer items-center justify-center gap-1.5 whitespace-nowrap rounded-cline-ui-md border border-cline-ui-border bg-cline-ui-background px-3 font-cline-ui-medium text-cline-ui-foreground shadow-xs transition-[color,background-color,border-color,box-shadow] duration-150 ease-[ease] [&:hover]:bg-cline-ui-accent [&:hover]:text-cline-ui-accent-foreground focus-visible:outline-3 focus-visible:outline-cline-ui-ring/50 focus-visible:outline-offset-0 disabled:pointer-events-none disabled:opacity-50 cline-ui-dark:border-cline-ui-input cline-ui-dark:bg-cline-ui-input/30 cline-ui-dark:[&:hover]:bg-cline-ui-input/50"
|
|
93
|
+
disabled={isPending}
|
|
94
|
+
onClick={onReject}
|
|
95
|
+
type="button"
|
|
96
|
+
>
|
|
97
|
+
{responding === "reject" ? (
|
|
98
|
+
<>
|
|
99
|
+
<Spinner />
|
|
100
|
+
Rejecting...
|
|
101
|
+
</>
|
|
102
|
+
) : (
|
|
103
|
+
"Reject"
|
|
104
|
+
)}
|
|
105
|
+
</button>
|
|
106
|
+
</div>
|
|
107
|
+
</section>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
.cline-ui-agent-ask-question,
|
|
2
|
+
.cline-ui-agent-ask-question__item,
|
|
3
|
+
.cline-ui-agent-ask-question__option,
|
|
4
|
+
.cline-ui-agent-ask-question__option-key {
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
border-style: solid;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.cline-ui-agent-ask-question__item {
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
border: 1px solid var(--border);
|
|
12
|
+
border-radius: var(--radius-lg);
|
|
13
|
+
background: var(--background);
|
|
14
|
+
padding-top: 0.75rem;
|
|
15
|
+
-webkit-user-select: text;
|
|
16
|
+
user-select: text;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.cline-ui-agent-ask-question__item-header {
|
|
20
|
+
padding-inline: 1rem 0.75rem;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.cline-ui-agent-ask-question__option {
|
|
24
|
+
font-family: inherit;
|
|
25
|
+
font-size: inherit;
|
|
26
|
+
font-style: inherit;
|
|
27
|
+
font-variant: inherit;
|
|
28
|
+
letter-spacing: inherit;
|
|
29
|
+
line-height: inherit;
|
|
30
|
+
/* The Button base sets `whitespace-nowrap`, and clsx keeps both classes on
|
|
31
|
+
* the element, letting the utility stylesheet's order pick nowrap. This
|
|
32
|
+
* unlayered rule beats layered utilities so long options wrap instead of
|
|
33
|
+
* clipping under the item's overflow:hidden. */
|
|
34
|
+
white-space: normal;
|
|
35
|
+
overflow-wrap: anywhere;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.cline-ui-agent-ask-question__option:hover:not(:disabled) {
|
|
39
|
+
background: var(--surface-hover-lighter);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.cline-ui-agent-ask-question__option-label {
|
|
43
|
+
font-size: var(--text-md);
|
|
44
|
+
line-height: var(--text-md--line-height);
|
|
45
|
+
letter-spacing: var(--text-md--letter-spacing);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.cline-ui-agent-ask-question__option[aria-pressed="true"] {
|
|
49
|
+
background: var(--surface-hover);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.cline-ui-agent-ask-question__option[aria-pressed="true"]
|
|
53
|
+
.cline-ui-agent-ask-question__option-key {
|
|
54
|
+
border-color: var(--neutral-6);
|
|
55
|
+
background: var(--neutral-5);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.cline-ui-agent-ask-question__option-key {
|
|
59
|
+
display: inline-flex;
|
|
60
|
+
height: 1.375rem;
|
|
61
|
+
width: 1.375rem;
|
|
62
|
+
flex: none;
|
|
63
|
+
align-items: center;
|
|
64
|
+
justify-content: center;
|
|
65
|
+
border: 1px solid var(--border);
|
|
66
|
+
border-radius: var(--radius-md);
|
|
67
|
+
background: var(--surface-hover-lighter);
|
|
68
|
+
color: var(--muted-foreground);
|
|
69
|
+
font-family: var(--font-mono);
|
|
70
|
+
font-size: var(--text-xs);
|
|
71
|
+
font-weight: var(--font-weight-medium);
|
|
72
|
+
line-height: var(--text-xs--line-height);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.cline-ui-agent-ask-question__spinner {
|
|
76
|
+
animation: cline-ui-agent-ask-question-spin 1s linear infinite;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.cline-ui-agent-ask-question__footer {
|
|
80
|
+
border-style: solid;
|
|
81
|
+
border-width: 1px 0 0;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.cline-ui-agent-ask-question__submit:not(:disabled) {
|
|
85
|
+
background: var(--foreground);
|
|
86
|
+
color: var(--background);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.cline-ui-agent-ask-question__submit:hover:not(:disabled) {
|
|
90
|
+
opacity: 0.9;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@keyframes cline-ui-agent-ask-question-spin {
|
|
94
|
+
to {
|
|
95
|
+
transform: rotate(360deg);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@media (prefers-reduced-motion: reduce) {
|
|
100
|
+
.cline-ui-agent-ask-question__spinner {
|
|
101
|
+
animation: none;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type KeyboardEvent as ReactKeyboardEvent,
|
|
5
|
+
type ReactNode,
|
|
6
|
+
useState,
|
|
7
|
+
} from "react";
|
|
8
|
+
import { Badge } from "./badge.js";
|
|
9
|
+
import { Button } from "./button.js";
|
|
10
|
+
|
|
11
|
+
export interface AgentAskQuestionItem {
|
|
12
|
+
description?: ReactNode;
|
|
13
|
+
id: string;
|
|
14
|
+
meta?: ReactNode;
|
|
15
|
+
multiple?: boolean;
|
|
16
|
+
options: readonly string[];
|
|
17
|
+
question: ReactNode;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface AgentAskQuestionProps {
|
|
21
|
+
errors?: Readonly<Record<string, ReactNode>>;
|
|
22
|
+
items: readonly AgentAskQuestionItem[];
|
|
23
|
+
onAnswer: (id: string, answer: string) => void;
|
|
24
|
+
onAnswers?: (id: string, answers: readonly string[]) => void;
|
|
25
|
+
pendingAnswers?: Readonly<
|
|
26
|
+
Record<string, string | readonly string[] | undefined>
|
|
27
|
+
>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function optionLabel(index: number) {
|
|
31
|
+
let value = index + 1;
|
|
32
|
+
let label = "";
|
|
33
|
+
|
|
34
|
+
while (value > 0) {
|
|
35
|
+
value -= 1;
|
|
36
|
+
label = String.fromCharCode(65 + (value % 26)) + label;
|
|
37
|
+
value = Math.floor(value / 26);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return label;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function Spinner() {
|
|
44
|
+
return (
|
|
45
|
+
<svg
|
|
46
|
+
aria-hidden="true"
|
|
47
|
+
className="cline-ui-agent-ask-question__spinner mr-1 size-3.5 flex-none fill-none stroke-current [stroke-linecap:round] [stroke-linejoin:round] stroke-2"
|
|
48
|
+
viewBox="0 0 24 24"
|
|
49
|
+
>
|
|
50
|
+
<path d="M21 12a9 9 0 1 1-6.219-8.56" />
|
|
51
|
+
</svg>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function AgentAskQuestion({
|
|
56
|
+
errors = {},
|
|
57
|
+
items,
|
|
58
|
+
onAnswer,
|
|
59
|
+
onAnswers,
|
|
60
|
+
pendingAnswers = {},
|
|
61
|
+
}: AgentAskQuestionProps) {
|
|
62
|
+
const [selections, setSelections] = useState<
|
|
63
|
+
Readonly<Record<string, readonly string[]>>
|
|
64
|
+
>({});
|
|
65
|
+
const [customAnswers, setCustomAnswers] = useState<
|
|
66
|
+
Readonly<Record<string, string>>
|
|
67
|
+
>({});
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<section
|
|
71
|
+
aria-label="Follow-up question"
|
|
72
|
+
className="cline-ui-agent-ask-question flex flex-col gap-2"
|
|
73
|
+
>
|
|
74
|
+
{items.map((item, itemIndex) => {
|
|
75
|
+
const pendingAnswer = pendingAnswers[item.id];
|
|
76
|
+
const isPending = Array.isArray(pendingAnswer)
|
|
77
|
+
? pendingAnswer.length > 0
|
|
78
|
+
: Boolean(pendingAnswer);
|
|
79
|
+
const error = errors[item.id];
|
|
80
|
+
const options = [...new Set(item.options)];
|
|
81
|
+
const pendingSelection = (
|
|
82
|
+
Array.isArray(pendingAnswer)
|
|
83
|
+
? pendingAnswer
|
|
84
|
+
: pendingAnswer
|
|
85
|
+
? [pendingAnswer]
|
|
86
|
+
: []
|
|
87
|
+
).filter((option) => options.includes(option));
|
|
88
|
+
const selected = (
|
|
89
|
+
isPending ? pendingSelection : (selections[item.id] ?? [])
|
|
90
|
+
).filter((option) => options.includes(option));
|
|
91
|
+
const customAnswer = customAnswers[item.id] ?? "";
|
|
92
|
+
const canSubmit = item.multiple
|
|
93
|
+
? selected.length > 0 && Boolean(onAnswers)
|
|
94
|
+
: customAnswer.trim().length > 0;
|
|
95
|
+
// Single-choice items answer as soon as an option is picked; only
|
|
96
|
+
// multiple-choice items collect a selection for explicit submission.
|
|
97
|
+
const selectOption = (option: string) => {
|
|
98
|
+
if (!item.multiple) {
|
|
99
|
+
onAnswer(item.id, option);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
setSelections((current) => {
|
|
103
|
+
const currentSelection = current[item.id] ?? [];
|
|
104
|
+
const nextSelection = currentSelection.includes(option)
|
|
105
|
+
? currentSelection.filter((value) => value !== option)
|
|
106
|
+
: [...currentSelection, option];
|
|
107
|
+
|
|
108
|
+
return { ...current, [item.id]: nextSelection };
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
const submit = () => {
|
|
112
|
+
if (!canSubmit || isPending) return;
|
|
113
|
+
if (item.multiple) onAnswers?.(item.id, selected);
|
|
114
|
+
else onAnswer(item.id, customAnswer.trim());
|
|
115
|
+
};
|
|
116
|
+
const handleOptionKeyDown = (
|
|
117
|
+
event: ReactKeyboardEvent<HTMLFieldSetElement>,
|
|
118
|
+
) => {
|
|
119
|
+
if (isPending || event.altKey || event.ctrlKey || event.metaKey)
|
|
120
|
+
return;
|
|
121
|
+
|
|
122
|
+
const optionButtons = Array.from(
|
|
123
|
+
event.currentTarget.querySelectorAll<HTMLButtonElement>(
|
|
124
|
+
".cline-ui-agent-ask-question__option:not(:disabled)",
|
|
125
|
+
),
|
|
126
|
+
);
|
|
127
|
+
const activeIndex = optionButtons.indexOf(
|
|
128
|
+
document.activeElement as HTMLButtonElement,
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
if (event.key === "ArrowDown" || event.key === "ArrowRight") {
|
|
132
|
+
event.preventDefault();
|
|
133
|
+
optionButtons[(activeIndex + 1) % optionButtons.length]?.focus();
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (event.key === "ArrowUp" || event.key === "ArrowLeft") {
|
|
137
|
+
event.preventDefault();
|
|
138
|
+
optionButtons[
|
|
139
|
+
(activeIndex - 1 + optionButtons.length) % optionButtons.length
|
|
140
|
+
]?.focus();
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (/^[a-z]$/i.test(event.key)) {
|
|
145
|
+
const optionIndex = event.key.toUpperCase().charCodeAt(0) - 65;
|
|
146
|
+
const option = options[optionIndex];
|
|
147
|
+
if (option) {
|
|
148
|
+
event.preventDefault();
|
|
149
|
+
selectOption(option);
|
|
150
|
+
optionButtons[optionIndex]?.focus();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
return (
|
|
156
|
+
<div
|
|
157
|
+
aria-busy={isPending || undefined}
|
|
158
|
+
className="cline-ui-agent-ask-question__item"
|
|
159
|
+
key={item.id}
|
|
160
|
+
>
|
|
161
|
+
<div className="cline-ui-agent-ask-question__item-header flex items-start justify-between gap-3">
|
|
162
|
+
<div className="min-w-0 flex-1 mt-1 w-full flex">
|
|
163
|
+
<div className="flex justify-between gap-1 w-full flex-col">
|
|
164
|
+
<h5 className="cline-ui-agent-ask-question__question font-cline-ui-medium text-cline-ui-foreground text-cline-ui-base w-full">
|
|
165
|
+
{item.question}
|
|
166
|
+
</h5>
|
|
167
|
+
|
|
168
|
+
{item.multiple ? (
|
|
169
|
+
<div className="cline-ui-agent-ask-question__multiple-hint text-cline-ui-sm text-cline-ui-muted-foreground">
|
|
170
|
+
Select all that apply.
|
|
171
|
+
</div>
|
|
172
|
+
) : null}
|
|
173
|
+
{item.description ? (
|
|
174
|
+
<div className="cline-ui-agent-ask-question__description text-cline-ui-sm text-cline-ui-muted-foreground">
|
|
175
|
+
{item.description}
|
|
176
|
+
</div>
|
|
177
|
+
) : null}
|
|
178
|
+
</div>
|
|
179
|
+
{item.meta ? (
|
|
180
|
+
<Badge className="cline-ui-agent-ask-question__meta h-fit -mt-1">
|
|
181
|
+
{item.meta}
|
|
182
|
+
</Badge>
|
|
183
|
+
) : null}
|
|
184
|
+
</div>
|
|
185
|
+
</div>
|
|
186
|
+
|
|
187
|
+
<fieldset
|
|
188
|
+
aria-label="Answer options"
|
|
189
|
+
className="cline-ui-agent-ask-question__options m-0 flex min-w-0 flex-col border-0 px-1 py-4"
|
|
190
|
+
onKeyDown={handleOptionKeyDown}
|
|
191
|
+
>
|
|
192
|
+
{/* Options are model-supplied and may repeat; repeats submit the same answer. */}
|
|
193
|
+
{options.map((option, index) => (
|
|
194
|
+
<Button
|
|
195
|
+
aria-pressed={selected.includes(option)}
|
|
196
|
+
autoFocus={itemIndex === 0 && index === 0 && !isPending}
|
|
197
|
+
className="cline-ui-agent-ask-question__option h-auto min-h-9.5 w-full max-w-full justify-start gap-3 rounded-cline-ui-md p-2 text-left text-cline-ui-sm"
|
|
198
|
+
disabled={isPending}
|
|
199
|
+
key={option}
|
|
200
|
+
onClick={() => selectOption(option)}
|
|
201
|
+
size="sm"
|
|
202
|
+
tone="neutral"
|
|
203
|
+
variant="ghost"
|
|
204
|
+
>
|
|
205
|
+
{index < 26 ? (
|
|
206
|
+
<span
|
|
207
|
+
aria-hidden="true"
|
|
208
|
+
className="cline-ui-agent-ask-question__option-key"
|
|
209
|
+
>
|
|
210
|
+
{optionLabel(index)}
|
|
211
|
+
</span>
|
|
212
|
+
) : null}
|
|
213
|
+
<span className="cline-ui-agent-ask-question__option-label min-w-0 flex-1 font-cline-ui-medium text-cline-ui-foreground">
|
|
214
|
+
{option}
|
|
215
|
+
</span>
|
|
216
|
+
</Button>
|
|
217
|
+
))}
|
|
218
|
+
</fieldset>
|
|
219
|
+
<div className="cline-ui-agent-ask-question__footer flex flex-col gap-2 border-cline-ui-border border-t px-2 py-2">
|
|
220
|
+
{error ? (
|
|
221
|
+
<div
|
|
222
|
+
className="cline-ui-agent-ask-question__error text-cline-ui-destructive text-cline-ui-xs px-2"
|
|
223
|
+
role="alert"
|
|
224
|
+
>
|
|
225
|
+
{error}
|
|
226
|
+
</div>
|
|
227
|
+
) : null}
|
|
228
|
+
<div className="flex items-center justify-end gap-2">
|
|
229
|
+
{item.multiple ? null : (
|
|
230
|
+
<input
|
|
231
|
+
aria-label="Custom answer"
|
|
232
|
+
className="cline-ui-agent-ask-question__custom min-w-0 flex-1 h-8 rounded-cline-ui-md border border-cline-ui-border bg-cline-ui-background px-2 text-cline-ui-foreground text-cline-ui-sm outline-none focus:border-[color-mix(in_oklab,var(--cline-ui-primary)_50%,transparent)] focus:shadow-[0_0_0_1px_color-mix(in_oklab,var(--cline-ui-primary)_20%,transparent)]"
|
|
233
|
+
disabled={isPending}
|
|
234
|
+
onChange={(event) => {
|
|
235
|
+
const value = event.target.value;
|
|
236
|
+
setCustomAnswers((current) => ({
|
|
237
|
+
...current,
|
|
238
|
+
[item.id]: value,
|
|
239
|
+
}));
|
|
240
|
+
}}
|
|
241
|
+
onKeyDown={(event) => {
|
|
242
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
243
|
+
event.preventDefault();
|
|
244
|
+
submit();
|
|
245
|
+
}
|
|
246
|
+
}}
|
|
247
|
+
placeholder="Or type your own answer…"
|
|
248
|
+
type="text"
|
|
249
|
+
value={customAnswer}
|
|
250
|
+
/>
|
|
251
|
+
)}
|
|
252
|
+
<Button
|
|
253
|
+
className="cline-ui-agent-ask-question__submit"
|
|
254
|
+
disabled={!canSubmit || isPending}
|
|
255
|
+
onClick={submit}
|
|
256
|
+
size="sm"
|
|
257
|
+
tone="neutral"
|
|
258
|
+
variant="fill"
|
|
259
|
+
>
|
|
260
|
+
{isPending ? (
|
|
261
|
+
<>
|
|
262
|
+
<Spinner />
|
|
263
|
+
Sending…
|
|
264
|
+
</>
|
|
265
|
+
) : (
|
|
266
|
+
"Submit"
|
|
267
|
+
)}
|
|
268
|
+
</Button>
|
|
269
|
+
</div>
|
|
270
|
+
</div>
|
|
271
|
+
</div>
|
|
272
|
+
);
|
|
273
|
+
})}
|
|
274
|
+
</section>
|
|
275
|
+
);
|
|
276
|
+
}
|