@vllnt/ui 0.2.1-canary.9e6a7be → 0.2.1-canary.b3f1dff
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/bottom-activity-strip/bottom-activity-strip.js +91 -0
- package/dist/components/bottom-activity-strip/index.js +6 -0
- package/dist/components/comment-pin/comment-pin.js +104 -0
- package/dist/components/comment-pin/index.js +6 -0
- package/dist/components/conversation-thread/conversation-thread.js +348 -0
- package/dist/components/conversation-thread/index.js +20 -0
- package/dist/components/heat-overlay/heat-overlay.js +92 -0
- package/dist/components/heat-overlay/index.js +6 -0
- package/dist/components/index.js +82 -0
- package/dist/components/infinite-plane/index.js +6 -0
- package/dist/components/infinite-plane/infinite-plane.js +75 -0
- package/dist/components/live-cursor/index.js +6 -0
- package/dist/components/live-cursor/live-cursor.js +62 -0
- package/dist/components/metric-cluster/index.js +6 -0
- package/dist/components/metric-cluster/metric-cluster.js +96 -0
- package/dist/components/playback-ghost/index.js +6 -0
- package/dist/components/playback-ghost/playback-ghost.js +83 -0
- package/dist/components/presence-stack/index.js +6 -0
- package/dist/components/presence-stack/presence-stack.js +108 -0
- package/dist/components/presence-sync-indicator/index.js +6 -0
- package/dist/components/presence-sync-indicator/presence-sync-indicator.js +73 -0
- package/dist/components/run-timeline/index.js +6 -0
- package/dist/components/run-timeline/run-timeline.js +221 -0
- package/dist/components/selection-presence/index.js +6 -0
- package/dist/components/selection-presence/selection-presence.js +50 -0
- package/dist/components/state-badge-overlay/index.js +6 -0
- package/dist/components/state-badge-overlay/state-badge-overlay.js +90 -0
- package/dist/components/thread-bubble/index.js +6 -0
- package/dist/components/thread-bubble/thread-bubble.js +85 -0
- package/dist/components/timeline-scrubber/index.js +6 -0
- package/dist/components/timeline-scrubber/timeline-scrubber.js +179 -0
- package/dist/components/viewport-bookmarks/index.js +6 -0
- package/dist/components/viewport-bookmarks/viewport-bookmarks.js +116 -0
- package/dist/components/world-breadcrumbs/index.js +6 -0
- package/dist/components/world-breadcrumbs/world-breadcrumbs.js +114 -0
- package/dist/index.d.ts +1389 -2
- package/package.json +1 -1
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
forwardRef
|
|
5
|
+
} from "react";
|
|
6
|
+
import { cn } from "../../lib/utils";
|
|
7
|
+
const TONE_DOT = {
|
|
8
|
+
danger: "bg-red-500",
|
|
9
|
+
info: "bg-blue-500",
|
|
10
|
+
neutral: "bg-muted-foreground",
|
|
11
|
+
success: "bg-emerald-500",
|
|
12
|
+
warn: "bg-amber-500"
|
|
13
|
+
};
|
|
14
|
+
const DEFAULT_LABELS = {
|
|
15
|
+
empty: "No recent activity",
|
|
16
|
+
region: "Recent activity"
|
|
17
|
+
};
|
|
18
|
+
const ChipBody = (props) => {
|
|
19
|
+
const { event } = props;
|
|
20
|
+
const tone = event.tone ?? "neutral";
|
|
21
|
+
return /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5 whitespace-nowrap", children: [
|
|
22
|
+
/* @__PURE__ */ jsx(
|
|
23
|
+
"span",
|
|
24
|
+
{
|
|
25
|
+
"aria-hidden": "true",
|
|
26
|
+
className: cn("h-1.5 w-1.5 rounded-full", TONE_DOT[tone])
|
|
27
|
+
}
|
|
28
|
+
),
|
|
29
|
+
/* @__PURE__ */ jsx("span", { className: "text-foreground", children: event.label }),
|
|
30
|
+
/* @__PURE__ */ jsx("span", { className: "text-[10px] text-muted-foreground", "data-strip-event-ts": true, children: event.ts })
|
|
31
|
+
] });
|
|
32
|
+
};
|
|
33
|
+
const Chip = (props) => {
|
|
34
|
+
const { event } = props;
|
|
35
|
+
const tone = event.tone ?? "neutral";
|
|
36
|
+
if (event.onActivate) {
|
|
37
|
+
const handleClick = () => {
|
|
38
|
+
event.onActivate?.();
|
|
39
|
+
};
|
|
40
|
+
return /* @__PURE__ */ jsx(
|
|
41
|
+
"button",
|
|
42
|
+
{
|
|
43
|
+
className: "flex items-center rounded-full border border-border bg-background px-2 py-1 text-[11px] transition-colors hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
44
|
+
"data-strip-event": event.id,
|
|
45
|
+
"data-strip-event-tone": tone,
|
|
46
|
+
onClick: handleClick,
|
|
47
|
+
type: "button",
|
|
48
|
+
children: /* @__PURE__ */ jsx(ChipBody, { event })
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
return /* @__PURE__ */ jsx(
|
|
53
|
+
"span",
|
|
54
|
+
{
|
|
55
|
+
className: "flex items-center rounded-full border border-border bg-background px-2 py-1 text-[11px]",
|
|
56
|
+
"data-strip-event": event.id,
|
|
57
|
+
"data-strip-event-tone": tone,
|
|
58
|
+
children: /* @__PURE__ */ jsx(ChipBody, { event })
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
const BottomActivityStrip = forwardRef((props, ref) => {
|
|
63
|
+
const { className, events, labels, maxEvents, ...rest } = props;
|
|
64
|
+
const resolvedLabels = { ...DEFAULT_LABELS, ...labels };
|
|
65
|
+
const visible = maxEvents === void 0 || maxEvents >= events.length ? events : events.slice(0, maxEvents);
|
|
66
|
+
return /* @__PURE__ */ jsx(
|
|
67
|
+
"section",
|
|
68
|
+
{
|
|
69
|
+
"aria-label": resolvedLabels.region,
|
|
70
|
+
className: cn(
|
|
71
|
+
"flex w-full items-center gap-2 overflow-x-auto rounded-md border border-border bg-background/90 px-2 py-1 text-foreground",
|
|
72
|
+
className
|
|
73
|
+
),
|
|
74
|
+
"data-bottom-activity-strip": true,
|
|
75
|
+
ref,
|
|
76
|
+
...rest,
|
|
77
|
+
children: visible.length === 0 ? /* @__PURE__ */ jsx(
|
|
78
|
+
"span",
|
|
79
|
+
{
|
|
80
|
+
className: "px-2 text-[11px] text-muted-foreground",
|
|
81
|
+
"data-strip-state": "empty",
|
|
82
|
+
children: resolvedLabels.empty
|
|
83
|
+
}
|
|
84
|
+
) : visible.map((event) => /* @__PURE__ */ jsx(Chip, { event }, event.id))
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
});
|
|
88
|
+
BottomActivityStrip.displayName = "BottomActivityStrip";
|
|
89
|
+
export {
|
|
90
|
+
BottomActivityStrip
|
|
91
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
forwardRef
|
|
5
|
+
} from "react";
|
|
6
|
+
import { cn } from "../../lib/utils";
|
|
7
|
+
const DEFAULT_LABELS = {
|
|
8
|
+
region: "Comment",
|
|
9
|
+
unreadSuffix: "unread"
|
|
10
|
+
};
|
|
11
|
+
const STATE_FILL = {
|
|
12
|
+
open: "bg-foreground text-background",
|
|
13
|
+
resolved: "bg-muted text-muted-foreground"
|
|
14
|
+
};
|
|
15
|
+
const PinBody = (props) => {
|
|
16
|
+
const showBadge = typeof props.unread === "number" && props.unread > 0;
|
|
17
|
+
const useAccent = props.accent && props.state === "open";
|
|
18
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
19
|
+
/* @__PURE__ */ jsx(
|
|
20
|
+
"span",
|
|
21
|
+
{
|
|
22
|
+
"aria-hidden": "true",
|
|
23
|
+
className: cn(
|
|
24
|
+
"flex h-7 w-7 items-center justify-center rounded-full border border-background text-[11px] font-semibold shadow-sm",
|
|
25
|
+
STATE_FILL[props.state]
|
|
26
|
+
),
|
|
27
|
+
"data-comment-pin-body": true,
|
|
28
|
+
style: useAccent ? { backgroundColor: props.accent, color: "white" } : void 0,
|
|
29
|
+
children: props.authorInitial ?? "\u2022"
|
|
30
|
+
}
|
|
31
|
+
),
|
|
32
|
+
showBadge ? /* @__PURE__ */ jsx(
|
|
33
|
+
"span",
|
|
34
|
+
{
|
|
35
|
+
"aria-hidden": "true",
|
|
36
|
+
className: "absolute -right-1 -top-1 inline-flex min-h-[14px] min-w-[14px] items-center justify-center rounded-full bg-red-500 px-1 text-[9px] font-medium text-white",
|
|
37
|
+
"data-comment-pin-unread": true,
|
|
38
|
+
children: props.unread
|
|
39
|
+
}
|
|
40
|
+
) : null
|
|
41
|
+
] });
|
|
42
|
+
};
|
|
43
|
+
const CommentPin = forwardRef(
|
|
44
|
+
(props, ref) => {
|
|
45
|
+
const {
|
|
46
|
+
authorInitial,
|
|
47
|
+
className,
|
|
48
|
+
color,
|
|
49
|
+
labels,
|
|
50
|
+
onActivate,
|
|
51
|
+
state = "open",
|
|
52
|
+
unread,
|
|
53
|
+
x,
|
|
54
|
+
y,
|
|
55
|
+
...rest
|
|
56
|
+
} = props;
|
|
57
|
+
const resolvedLabels = { ...DEFAULT_LABELS, ...labels };
|
|
58
|
+
const showBadge = typeof unread === "number" && unread > 0;
|
|
59
|
+
const ariaLabel = showBadge ? `${resolvedLabels.region}, ${unread} ${resolvedLabels.unreadSuffix}` : resolvedLabels.region;
|
|
60
|
+
const handleClick = () => {
|
|
61
|
+
onActivate?.();
|
|
62
|
+
};
|
|
63
|
+
const body = /* @__PURE__ */ jsx(
|
|
64
|
+
PinBody,
|
|
65
|
+
{
|
|
66
|
+
accent: color,
|
|
67
|
+
authorInitial,
|
|
68
|
+
state,
|
|
69
|
+
unread
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
return /* @__PURE__ */ jsx(
|
|
73
|
+
"div",
|
|
74
|
+
{
|
|
75
|
+
"aria-label": ariaLabel,
|
|
76
|
+
className: cn(
|
|
77
|
+
"absolute z-30 inline-flex -translate-x-1/2 -translate-y-1/2",
|
|
78
|
+
className
|
|
79
|
+
),
|
|
80
|
+
"data-comment-pin": true,
|
|
81
|
+
"data-comment-pin-state": state,
|
|
82
|
+
ref,
|
|
83
|
+
role: "img",
|
|
84
|
+
style: { left: x, top: y },
|
|
85
|
+
...rest,
|
|
86
|
+
children: onActivate ? /* @__PURE__ */ jsx(
|
|
87
|
+
"button",
|
|
88
|
+
{
|
|
89
|
+
"aria-label": ariaLabel,
|
|
90
|
+
className: "relative inline-flex rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
91
|
+
"data-comment-pin-trigger": true,
|
|
92
|
+
onClick: handleClick,
|
|
93
|
+
type: "button",
|
|
94
|
+
children: body
|
|
95
|
+
}
|
|
96
|
+
) : /* @__PURE__ */ jsx("span", { className: "relative inline-flex", children: body })
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
CommentPin.displayName = "CommentPin";
|
|
102
|
+
export {
|
|
103
|
+
CommentPin
|
|
104
|
+
};
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
createContext,
|
|
5
|
+
forwardRef,
|
|
6
|
+
useCallback,
|
|
7
|
+
useContext,
|
|
8
|
+
useEffect,
|
|
9
|
+
useMemo,
|
|
10
|
+
useRef,
|
|
11
|
+
useState
|
|
12
|
+
} from "react";
|
|
13
|
+
import { ArrowDown, RefreshCw, ThumbsDown, ThumbsUp } from "lucide-react";
|
|
14
|
+
import { cn } from "../../lib/utils";
|
|
15
|
+
import { ThinkingBlock } from "../thinking-block";
|
|
16
|
+
const ConversationThreadContext = createContext(null);
|
|
17
|
+
function useConversationThreadContext() {
|
|
18
|
+
const ctx = useContext(ConversationThreadContext);
|
|
19
|
+
if (!ctx) {
|
|
20
|
+
throw new Error(
|
|
21
|
+
"ConversationThread compound components must be used within <ConversationThread>"
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
return ctx;
|
|
25
|
+
}
|
|
26
|
+
function MessageActions({ messageId }) {
|
|
27
|
+
const { onFeedback, onRetry } = useConversationThreadContext();
|
|
28
|
+
return /* @__PURE__ */ jsxs("div", { className: "mt-2 flex items-center gap-1", children: [
|
|
29
|
+
onRetry ? /* @__PURE__ */ jsx(
|
|
30
|
+
"button",
|
|
31
|
+
{
|
|
32
|
+
"aria-label": "Retry message",
|
|
33
|
+
className: "rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
|
|
34
|
+
onClick: () => {
|
|
35
|
+
onRetry(messageId);
|
|
36
|
+
},
|
|
37
|
+
type: "button",
|
|
38
|
+
children: /* @__PURE__ */ jsx(RefreshCw, { className: "h-3 w-3" })
|
|
39
|
+
}
|
|
40
|
+
) : null,
|
|
41
|
+
onFeedback ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
42
|
+
/* @__PURE__ */ jsx(
|
|
43
|
+
"button",
|
|
44
|
+
{
|
|
45
|
+
"aria-label": "Positive feedback",
|
|
46
|
+
className: "rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
|
|
47
|
+
onClick: () => {
|
|
48
|
+
onFeedback(messageId, "positive");
|
|
49
|
+
},
|
|
50
|
+
type: "button",
|
|
51
|
+
children: /* @__PURE__ */ jsx(ThumbsUp, { className: "h-3 w-3" })
|
|
52
|
+
}
|
|
53
|
+
),
|
|
54
|
+
/* @__PURE__ */ jsx(
|
|
55
|
+
"button",
|
|
56
|
+
{
|
|
57
|
+
"aria-label": "Negative feedback",
|
|
58
|
+
className: "rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
|
|
59
|
+
onClick: () => {
|
|
60
|
+
onFeedback(messageId, "negative");
|
|
61
|
+
},
|
|
62
|
+
type: "button",
|
|
63
|
+
children: /* @__PURE__ */ jsx(ThumbsDown, { className: "h-3 w-3" })
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
] }) : null
|
|
67
|
+
] });
|
|
68
|
+
}
|
|
69
|
+
function MessageItem({ message }) {
|
|
70
|
+
const isUser = message.role === "user";
|
|
71
|
+
return /* @__PURE__ */ jsx(
|
|
72
|
+
"div",
|
|
73
|
+
{
|
|
74
|
+
className: cn(
|
|
75
|
+
"mb-4 flex gap-3",
|
|
76
|
+
isUser ? "justify-end" : "justify-start"
|
|
77
|
+
),
|
|
78
|
+
children: /* @__PURE__ */ jsxs(
|
|
79
|
+
"div",
|
|
80
|
+
{
|
|
81
|
+
className: cn(
|
|
82
|
+
"max-w-[80%] rounded-2xl px-4 py-3 text-sm",
|
|
83
|
+
isUser ? "rounded-br-sm bg-primary text-primary-foreground" : "rounded-bl-sm bg-muted text-foreground"
|
|
84
|
+
),
|
|
85
|
+
children: [
|
|
86
|
+
!isUser && message.thinking ? /* @__PURE__ */ jsx(
|
|
87
|
+
ThinkingBlock,
|
|
88
|
+
{
|
|
89
|
+
isStreaming: message.isStreaming,
|
|
90
|
+
thinking: message.thinking
|
|
91
|
+
}
|
|
92
|
+
) : null,
|
|
93
|
+
message.toolCalls && message.toolCalls.length > 0 ? /* @__PURE__ */ jsx(
|
|
94
|
+
"ul",
|
|
95
|
+
{
|
|
96
|
+
"aria-label": "Tool calls",
|
|
97
|
+
className: "mb-2 flex flex-col gap-1 text-xs text-muted-foreground",
|
|
98
|
+
children: message.toolCalls.map((toolCall) => /* @__PURE__ */ jsx("li", { className: "font-mono", children: toolCall.name }, toolCall.id))
|
|
99
|
+
}
|
|
100
|
+
) : null,
|
|
101
|
+
/* @__PURE__ */ jsx("p", { className: "whitespace-pre-wrap leading-relaxed", children: message.content }),
|
|
102
|
+
isUser ? null : /* @__PURE__ */ jsx(MessageActions, { messageId: message.id })
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
function useConversationScroll(messages, isStreaming) {
|
|
110
|
+
const scrollContainerRef = useRef(null);
|
|
111
|
+
const messagesEndRef = useRef(null);
|
|
112
|
+
const isAtBottomRef = useRef(true);
|
|
113
|
+
const [isAtBottom, setIsAtBottom] = useState(true);
|
|
114
|
+
const scrollToBottom = useCallback(() => {
|
|
115
|
+
const element = messagesEndRef.current;
|
|
116
|
+
if (element && typeof element.scrollIntoView === "function") {
|
|
117
|
+
element.scrollIntoView({ behavior: "smooth" });
|
|
118
|
+
}
|
|
119
|
+
}, []);
|
|
120
|
+
const scrollToBottomInstant = useCallback(() => {
|
|
121
|
+
const element = messagesEndRef.current;
|
|
122
|
+
if (element && typeof element.scrollIntoView === "function") {
|
|
123
|
+
element.scrollIntoView({ behavior: "instant" });
|
|
124
|
+
}
|
|
125
|
+
}, []);
|
|
126
|
+
const handleScroll = useCallback(() => {
|
|
127
|
+
const container = scrollContainerRef.current;
|
|
128
|
+
if (!container) return;
|
|
129
|
+
const { clientHeight, scrollHeight, scrollTop } = container;
|
|
130
|
+
const nearBottom = scrollHeight - scrollTop - clientHeight <= 100;
|
|
131
|
+
isAtBottomRef.current = nearBottom;
|
|
132
|
+
setIsAtBottom(nearBottom);
|
|
133
|
+
}, []);
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
if (!isAtBottomRef.current) return;
|
|
136
|
+
scrollToBottomInstant();
|
|
137
|
+
}, [messages, scrollToBottomInstant]);
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
if (!isStreaming || !isAtBottomRef.current) return;
|
|
140
|
+
scrollToBottomInstant();
|
|
141
|
+
}, [isStreaming, scrollToBottomInstant]);
|
|
142
|
+
return {
|
|
143
|
+
handleScroll,
|
|
144
|
+
isAtBottom,
|
|
145
|
+
messagesEndRef,
|
|
146
|
+
scrollContainerRef,
|
|
147
|
+
scrollToBottom
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
const ConversationThread = forwardRef(
|
|
151
|
+
({
|
|
152
|
+
children,
|
|
153
|
+
className,
|
|
154
|
+
isStreaming = false,
|
|
155
|
+
messages,
|
|
156
|
+
onFeedback,
|
|
157
|
+
onRetry,
|
|
158
|
+
onSend
|
|
159
|
+
}, reference) => {
|
|
160
|
+
const {
|
|
161
|
+
handleScroll,
|
|
162
|
+
isAtBottom,
|
|
163
|
+
messagesEndRef,
|
|
164
|
+
scrollContainerRef,
|
|
165
|
+
scrollToBottom
|
|
166
|
+
} = useConversationScroll(messages, isStreaming);
|
|
167
|
+
const contextValue = useMemo(
|
|
168
|
+
() => ({
|
|
169
|
+
handleScroll,
|
|
170
|
+
isAtBottom,
|
|
171
|
+
isStreaming,
|
|
172
|
+
messages,
|
|
173
|
+
messagesEndRef,
|
|
174
|
+
onFeedback,
|
|
175
|
+
onRetry,
|
|
176
|
+
onSend,
|
|
177
|
+
scrollContainerRef,
|
|
178
|
+
scrollToBottom
|
|
179
|
+
}),
|
|
180
|
+
[
|
|
181
|
+
handleScroll,
|
|
182
|
+
isAtBottom,
|
|
183
|
+
isStreaming,
|
|
184
|
+
messages,
|
|
185
|
+
messagesEndRef,
|
|
186
|
+
onFeedback,
|
|
187
|
+
onRetry,
|
|
188
|
+
onSend,
|
|
189
|
+
scrollContainerRef,
|
|
190
|
+
scrollToBottom
|
|
191
|
+
]
|
|
192
|
+
);
|
|
193
|
+
return /* @__PURE__ */ jsx(ConversationThreadContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
|
|
194
|
+
"div",
|
|
195
|
+
{
|
|
196
|
+
className: cn("flex h-full flex-col overflow-hidden", className),
|
|
197
|
+
ref: reference,
|
|
198
|
+
children
|
|
199
|
+
}
|
|
200
|
+
) });
|
|
201
|
+
}
|
|
202
|
+
);
|
|
203
|
+
ConversationThread.displayName = "ConversationThread";
|
|
204
|
+
const ConversationHeader = forwardRef(({ children, className }, reference) => {
|
|
205
|
+
return /* @__PURE__ */ jsx(
|
|
206
|
+
"div",
|
|
207
|
+
{
|
|
208
|
+
className: cn("flex shrink-0 items-center border-b px-4 py-3", className),
|
|
209
|
+
ref: reference,
|
|
210
|
+
children
|
|
211
|
+
}
|
|
212
|
+
);
|
|
213
|
+
});
|
|
214
|
+
ConversationHeader.displayName = "ConversationHeader";
|
|
215
|
+
const ConversationTitle = forwardRef(({ children, className }, reference) => {
|
|
216
|
+
return /* @__PURE__ */ jsx(
|
|
217
|
+
"h2",
|
|
218
|
+
{
|
|
219
|
+
className: cn("text-sm font-semibold leading-none", className),
|
|
220
|
+
ref: reference,
|
|
221
|
+
children
|
|
222
|
+
}
|
|
223
|
+
);
|
|
224
|
+
});
|
|
225
|
+
ConversationTitle.displayName = "ConversationTitle";
|
|
226
|
+
const ConversationMessages = forwardRef(({ children, className }, reference) => {
|
|
227
|
+
const { handleScroll, messages, messagesEndRef, scrollContainerRef } = useConversationThreadContext();
|
|
228
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("relative min-h-0 flex-1", className), ref: reference, children: [
|
|
229
|
+
/* @__PURE__ */ jsx(
|
|
230
|
+
"div",
|
|
231
|
+
{
|
|
232
|
+
"aria-label": "Conversation messages",
|
|
233
|
+
"aria-live": "polite",
|
|
234
|
+
className: "absolute inset-0 overflow-y-auto",
|
|
235
|
+
onScroll: handleScroll,
|
|
236
|
+
ref: scrollContainerRef,
|
|
237
|
+
role: "log",
|
|
238
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col p-4", children: [
|
|
239
|
+
messages.map((message) => /* @__PURE__ */ jsx(MessageItem, { message }, message.id)),
|
|
240
|
+
/* @__PURE__ */ jsx("div", { "aria-hidden": "true", ref: messagesEndRef })
|
|
241
|
+
] })
|
|
242
|
+
}
|
|
243
|
+
),
|
|
244
|
+
children
|
|
245
|
+
] });
|
|
246
|
+
});
|
|
247
|
+
ConversationMessages.displayName = "ConversationMessages";
|
|
248
|
+
const ConversationEmpty = forwardRef(({ children, className }, reference) => {
|
|
249
|
+
const { messages } = useConversationThreadContext();
|
|
250
|
+
if (messages.length > 0) return null;
|
|
251
|
+
return /* @__PURE__ */ jsx(
|
|
252
|
+
"div",
|
|
253
|
+
{
|
|
254
|
+
className: cn(
|
|
255
|
+
"pointer-events-none absolute inset-0 flex flex-col items-center justify-center gap-4 p-8",
|
|
256
|
+
className
|
|
257
|
+
),
|
|
258
|
+
ref: reference,
|
|
259
|
+
children: /* @__PURE__ */ jsx("div", { className: "pointer-events-auto flex flex-col items-center gap-4", children })
|
|
260
|
+
}
|
|
261
|
+
);
|
|
262
|
+
});
|
|
263
|
+
ConversationEmpty.displayName = "ConversationEmpty";
|
|
264
|
+
const ConversationSuggestions = forwardRef(({ className, suggestions = [] }, reference) => {
|
|
265
|
+
const { onSend } = useConversationThreadContext();
|
|
266
|
+
return /* @__PURE__ */ jsx(
|
|
267
|
+
"div",
|
|
268
|
+
{
|
|
269
|
+
className: cn("flex flex-wrap justify-center gap-2", className),
|
|
270
|
+
ref: reference,
|
|
271
|
+
children: suggestions.map((suggestion) => /* @__PURE__ */ jsx(
|
|
272
|
+
"button",
|
|
273
|
+
{
|
|
274
|
+
className: "rounded-full border bg-background px-4 py-2 text-sm transition-colors hover:bg-muted",
|
|
275
|
+
onClick: () => onSend?.(suggestion),
|
|
276
|
+
type: "button",
|
|
277
|
+
children: suggestion
|
|
278
|
+
},
|
|
279
|
+
suggestion
|
|
280
|
+
))
|
|
281
|
+
}
|
|
282
|
+
);
|
|
283
|
+
});
|
|
284
|
+
ConversationSuggestions.displayName = "ConversationSuggestions";
|
|
285
|
+
const ConversationScrollButton = forwardRef(({ className }, reference) => {
|
|
286
|
+
const { isAtBottom, scrollToBottom } = useConversationThreadContext();
|
|
287
|
+
if (isAtBottom) return null;
|
|
288
|
+
return /* @__PURE__ */ jsx(
|
|
289
|
+
"button",
|
|
290
|
+
{
|
|
291
|
+
"aria-label": "Scroll to bottom",
|
|
292
|
+
className: cn(
|
|
293
|
+
"absolute bottom-4 right-4 flex h-8 w-8 items-center justify-center rounded-full border bg-background shadow-md transition-colors hover:bg-muted",
|
|
294
|
+
className
|
|
295
|
+
),
|
|
296
|
+
onClick: scrollToBottom,
|
|
297
|
+
ref: reference,
|
|
298
|
+
type: "button",
|
|
299
|
+
children: /* @__PURE__ */ jsx(ArrowDown, { className: "h-4 w-4" })
|
|
300
|
+
}
|
|
301
|
+
);
|
|
302
|
+
});
|
|
303
|
+
ConversationScrollButton.displayName = "ConversationScrollButton";
|
|
304
|
+
const ConversationLoading = forwardRef(({ className }, reference) => {
|
|
305
|
+
const { isStreaming, messages } = useConversationThreadContext();
|
|
306
|
+
const lastMessage = messages.at(-1);
|
|
307
|
+
if (!isStreaming || lastMessage?.role !== "assistant") return null;
|
|
308
|
+
return /* @__PURE__ */ jsxs(
|
|
309
|
+
"div",
|
|
310
|
+
{
|
|
311
|
+
"aria-label": "Assistant is typing",
|
|
312
|
+
className: cn(
|
|
313
|
+
"absolute bottom-4 left-4 flex items-center gap-1",
|
|
314
|
+
className
|
|
315
|
+
),
|
|
316
|
+
ref: reference,
|
|
317
|
+
role: "status",
|
|
318
|
+
children: [
|
|
319
|
+
/* @__PURE__ */ jsx(
|
|
320
|
+
"span",
|
|
321
|
+
{
|
|
322
|
+
className: "h-2 w-2 animate-bounce rounded-full bg-muted-foreground",
|
|
323
|
+
style: { animationDelay: "-0.3s" }
|
|
324
|
+
}
|
|
325
|
+
),
|
|
326
|
+
/* @__PURE__ */ jsx(
|
|
327
|
+
"span",
|
|
328
|
+
{
|
|
329
|
+
className: "h-2 w-2 animate-bounce rounded-full bg-muted-foreground",
|
|
330
|
+
style: { animationDelay: "-0.15s" }
|
|
331
|
+
}
|
|
332
|
+
),
|
|
333
|
+
/* @__PURE__ */ jsx("span", { className: "h-2 w-2 animate-bounce rounded-full bg-muted-foreground" })
|
|
334
|
+
]
|
|
335
|
+
}
|
|
336
|
+
);
|
|
337
|
+
});
|
|
338
|
+
ConversationLoading.displayName = "ConversationLoading";
|
|
339
|
+
export {
|
|
340
|
+
ConversationEmpty,
|
|
341
|
+
ConversationHeader,
|
|
342
|
+
ConversationLoading,
|
|
343
|
+
ConversationMessages,
|
|
344
|
+
ConversationScrollButton,
|
|
345
|
+
ConversationSuggestions,
|
|
346
|
+
ConversationThread,
|
|
347
|
+
ConversationTitle
|
|
348
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConversationEmpty,
|
|
3
|
+
ConversationHeader,
|
|
4
|
+
ConversationLoading,
|
|
5
|
+
ConversationMessages,
|
|
6
|
+
ConversationScrollButton,
|
|
7
|
+
ConversationSuggestions,
|
|
8
|
+
ConversationThread,
|
|
9
|
+
ConversationTitle
|
|
10
|
+
} from "./conversation-thread";
|
|
11
|
+
export {
|
|
12
|
+
ConversationEmpty,
|
|
13
|
+
ConversationHeader,
|
|
14
|
+
ConversationLoading,
|
|
15
|
+
ConversationMessages,
|
|
16
|
+
ConversationScrollButton,
|
|
17
|
+
ConversationSuggestions,
|
|
18
|
+
ConversationThread,
|
|
19
|
+
ConversationTitle
|
|
20
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useId } from "react";
|
|
4
|
+
import { cn } from "../../lib/utils";
|
|
5
|
+
const TONE_FILL = {
|
|
6
|
+
cool: "fill-blue-500",
|
|
7
|
+
danger: "fill-red-500",
|
|
8
|
+
neutral: "fill-foreground",
|
|
9
|
+
warn: "fill-amber-500"
|
|
10
|
+
};
|
|
11
|
+
const DEFAULT_LABELS = {
|
|
12
|
+
region: "Heat overlay"
|
|
13
|
+
};
|
|
14
|
+
const clamp01 = (v) => {
|
|
15
|
+
if (v < 0) {
|
|
16
|
+
return 0;
|
|
17
|
+
}
|
|
18
|
+
if (v > 1) {
|
|
19
|
+
return 1;
|
|
20
|
+
}
|
|
21
|
+
return v;
|
|
22
|
+
};
|
|
23
|
+
const HeatBlob = (props) => {
|
|
24
|
+
const { defaultTone, gradientId, intensity, point } = props;
|
|
25
|
+
const weight = clamp01(point.weight);
|
|
26
|
+
const tone = point.tone ?? defaultTone;
|
|
27
|
+
return /* @__PURE__ */ jsx(
|
|
28
|
+
"circle",
|
|
29
|
+
{
|
|
30
|
+
className: cn("mix-blend-multiply", TONE_FILL[tone]),
|
|
31
|
+
cx: point.x,
|
|
32
|
+
cy: point.y,
|
|
33
|
+
"data-heat-point": point.id,
|
|
34
|
+
"data-heat-tone": tone,
|
|
35
|
+
fill: `url(#${gradientId})`,
|
|
36
|
+
fillOpacity: weight * 0.6,
|
|
37
|
+
r: Math.max(8, intensity * weight)
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
const HeatOverlay = forwardRef(
|
|
42
|
+
(props, ref) => {
|
|
43
|
+
const {
|
|
44
|
+
className,
|
|
45
|
+
defaultTone = "warn",
|
|
46
|
+
intensity = 48,
|
|
47
|
+
labels,
|
|
48
|
+
points,
|
|
49
|
+
...rest
|
|
50
|
+
} = props;
|
|
51
|
+
const resolvedLabels = { ...DEFAULT_LABELS, ...labels };
|
|
52
|
+
const gradientId = useId();
|
|
53
|
+
if (points.length === 0) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
return /* @__PURE__ */ jsxs(
|
|
57
|
+
"svg",
|
|
58
|
+
{
|
|
59
|
+
"aria-label": resolvedLabels.region,
|
|
60
|
+
className: cn(
|
|
61
|
+
"pointer-events-none absolute inset-0 z-10 h-full w-full",
|
|
62
|
+
className
|
|
63
|
+
),
|
|
64
|
+
"data-heat-overlay": true,
|
|
65
|
+
ref,
|
|
66
|
+
role: "img",
|
|
67
|
+
...rest,
|
|
68
|
+
children: [
|
|
69
|
+
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("radialGradient", { cx: "50%", cy: "50%", id: gradientId, r: "50%", children: [
|
|
70
|
+
/* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: "currentColor", stopOpacity: "1" }),
|
|
71
|
+
/* @__PURE__ */ jsx("stop", { offset: "70%", stopColor: "currentColor", stopOpacity: "0.4" }),
|
|
72
|
+
/* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: "currentColor", stopOpacity: "0" })
|
|
73
|
+
] }) }),
|
|
74
|
+
points.map((point) => /* @__PURE__ */ jsx(
|
|
75
|
+
HeatBlob,
|
|
76
|
+
{
|
|
77
|
+
defaultTone,
|
|
78
|
+
gradientId,
|
|
79
|
+
intensity,
|
|
80
|
+
point
|
|
81
|
+
},
|
|
82
|
+
point.id
|
|
83
|
+
))
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
HeatOverlay.displayName = "HeatOverlay";
|
|
90
|
+
export {
|
|
91
|
+
HeatOverlay
|
|
92
|
+
};
|