@meshagent/meshagent-tailwind 0.43.3 → 0.44.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/chat/agent-thread-message-status-store.d.ts +105 -0
- package/dist/cjs/chat/agent-thread-message-status-store.js +617 -0
- package/dist/cjs/chat/agent-thread.d.ts +76 -4
- package/dist/cjs/chat/agent-thread.js +1114 -54
- package/dist/cjs/chat/chat-bot-view.d.ts +7 -4
- package/dist/cjs/chat/chat-bot-view.js +33 -525
- package/dist/cjs/chat/chat-hooks.d.ts +6 -5
- package/dist/cjs/chat/chat-hooks.js +21 -466
- package/dist/cjs/chat/chat-typing-indicator.d.ts +15 -1
- package/dist/cjs/chat/chat-typing-indicator.js +35 -5
- package/dist/cjs/chat/file-attachment.d.ts +7 -3
- package/dist/cjs/chat/file-attachment.js +30 -6
- package/dist/cjs/chat/multi-thread-view.d.ts +3 -1
- package/dist/cjs/chat/multi-thread-view.js +4 -2
- package/dist/cjs/chat/new-chat-thread.d.ts +3 -1
- package/dist/cjs/chat/new-chat-thread.js +7 -3
- package/dist/cjs/chat/thread-list-view.d.ts +22 -0
- package/dist/cjs/chat/thread-list-view.js +518 -0
- package/dist/cjs/chat/tool-call-status-accumulator.d.ts +69 -0
- package/dist/cjs/chat/tool-call-status-accumulator.js +268 -0
- package/dist/cjs/components/pane-example.d.ts +1 -1
- package/dist/cjs/components/ui/avatar.d.ts +3 -3
- package/dist/cjs/components/ui/button.d.ts +3 -3
- package/dist/cjs/components/ui/card.d.ts +7 -7
- package/dist/cjs/components/ui/dialog.d.ts +10 -10
- package/dist/cjs/components/ui/form.d.ts +7 -7
- package/dist/cjs/components/ui/input.d.ts +1 -1
- package/dist/cjs/components/ui/label.d.ts +1 -1
- package/dist/cjs/components/ui/progress.d.ts +1 -1
- package/dist/cjs/components/ui/radio-group.d.ts +2 -2
- package/dist/cjs/components/ui/select.d.ts +10 -10
- package/dist/cjs/components/ui/sheet.d.ts +8 -8
- package/dist/cjs/components/ui/skeleton.d.ts +1 -1
- package/dist/cjs/components/ui/sonner.d.ts +1 -1
- package/dist/cjs/components/ui/spinner.d.ts +2 -2
- package/dist/cjs/components/ui/textarea.d.ts +1 -1
- package/dist/cjs/file-preview/file-preview.d.ts +1 -0
- package/dist/cjs/file-preview/file-preview.js +41 -5
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +13 -0
- package/dist/cjs/meetings/camera-grid.d.ts +2 -2
- package/dist/cjs/tools/ask-user-for-file.js +2 -2
- package/dist/cjs/tools/file-dialog.d.ts +2 -1
- package/dist/cjs/tools/form-dialog.d.ts +2 -1
- package/dist/esm/chat/agent-thread-message-status-store.d.ts +105 -0
- package/dist/esm/chat/agent-thread-message-status-store.js +614 -0
- package/dist/esm/chat/agent-thread.d.ts +76 -4
- package/dist/esm/chat/agent-thread.js +1132 -56
- package/dist/esm/chat/chat-bot-view.d.ts +7 -4
- package/dist/esm/chat/chat-bot-view.js +40 -555
- package/dist/esm/chat/chat-hooks.d.ts +6 -5
- package/dist/esm/chat/chat-hooks.js +23 -468
- package/dist/esm/chat/chat-typing-indicator.d.ts +15 -1
- package/dist/esm/chat/chat-typing-indicator.js +35 -5
- package/dist/esm/chat/file-attachment.d.ts +7 -3
- package/dist/esm/chat/file-attachment.js +30 -6
- package/dist/esm/chat/multi-thread-view.d.ts +3 -1
- package/dist/esm/chat/multi-thread-view.js +4 -2
- package/dist/esm/chat/new-chat-thread.d.ts +3 -1
- package/dist/esm/chat/new-chat-thread.js +8 -4
- package/dist/esm/chat/thread-list-view.d.ts +22 -0
- package/dist/esm/chat/thread-list-view.js +514 -0
- package/dist/esm/chat/tool-call-status-accumulator.d.ts +69 -0
- package/dist/esm/chat/tool-call-status-accumulator.js +248 -0
- package/dist/esm/components/pane-example.d.ts +1 -1
- package/dist/esm/components/ui/avatar.d.ts +3 -3
- package/dist/esm/components/ui/button.d.ts +3 -3
- package/dist/esm/components/ui/card.d.ts +7 -7
- package/dist/esm/components/ui/dialog.d.ts +10 -10
- package/dist/esm/components/ui/form.d.ts +7 -7
- package/dist/esm/components/ui/input.d.ts +1 -1
- package/dist/esm/components/ui/label.d.ts +1 -1
- package/dist/esm/components/ui/progress.d.ts +1 -1
- package/dist/esm/components/ui/radio-group.d.ts +2 -2
- package/dist/esm/components/ui/select.d.ts +10 -10
- package/dist/esm/components/ui/sheet.d.ts +8 -8
- package/dist/esm/components/ui/skeleton.d.ts +1 -1
- package/dist/esm/components/ui/sonner.d.ts +1 -1
- package/dist/esm/components/ui/spinner.d.ts +2 -2
- package/dist/esm/components/ui/textarea.d.ts +1 -1
- package/dist/esm/file-preview/file-preview.d.ts +1 -0
- package/dist/esm/file-preview/file-preview.js +29 -3
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/meetings/camera-grid.d.ts +2 -2
- package/dist/esm/tools/ask-user-for-file.js +2 -2
- package/dist/esm/tools/file-dialog.d.ts +2 -1
- package/dist/esm/tools/form-dialog.d.ts +2 -1
- package/dist/index.css +1 -1
- package/package.json +4 -4
- package/dist/cjs/chat/chat-bot-view.test.js +0 -325
- package/dist/cjs/chat/live-chat-widgets.test.js +0 -256
- package/dist/esm/chat/chat-bot-view.test.js +0 -336
- package/dist/esm/chat/live-chat-widgets.test.js +0 -262
|
@@ -1,179 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useCallback, useEffect,
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from "
|
|
9
|
-
import {
|
|
10
|
-
AlertTriangle,
|
|
11
|
-
Check,
|
|
12
|
-
MessageSquare,
|
|
13
|
-
MessageSquarePlus,
|
|
14
|
-
Pencil
|
|
15
|
-
} from "lucide-react";
|
|
16
|
-
import { useThreadStatus } from "./chat-hooks.js";
|
|
17
|
-
import { AgentThread } from "./agent-thread.js";
|
|
18
|
-
import { Button } from "../components/ui/button.js";
|
|
19
|
-
import {
|
|
20
|
-
Dialog,
|
|
21
|
-
DialogClose,
|
|
22
|
-
DialogContent,
|
|
23
|
-
DialogDescription,
|
|
24
|
-
DialogFooter,
|
|
25
|
-
DialogHeader,
|
|
26
|
-
DialogTitle
|
|
27
|
-
} from "../components/ui/dialog.js";
|
|
28
|
-
import { Input } from "../components/ui/input.js";
|
|
29
|
-
import { Label } from "../components/ui/label.js";
|
|
30
|
-
import { Spinner } from "../components/ui/spinner.js";
|
|
31
|
-
import {
|
|
32
|
-
ChatThreadDisplayMode,
|
|
33
|
-
chatDocumentPath,
|
|
34
|
-
defaultThreadDisplayNameFromPath,
|
|
35
|
-
resolvedThreadListPath
|
|
36
|
-
} from "./conversation-descriptor.js";
|
|
37
|
-
import { cn } from "../lib/utils.js";
|
|
38
|
-
import { MultiThreadView } from "./multi-thread-view.js";
|
|
39
|
-
const multiThreadLayoutBreakpointPx = 920;
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { MessagingChatClient } from "@meshagent/meshagent-agents";
|
|
4
|
+
import { AlertTriangle } from "lucide-react";
|
|
5
|
+
import { AgentThread } from "./agent-thread";
|
|
6
|
+
import { ChatThreadDisplayMode, chatDocumentPath } from "./conversation-descriptor";
|
|
7
|
+
import { cn } from "../lib/utils";
|
|
8
|
+
import { MultiThreadView } from "./multi-thread-view";
|
|
9
|
+
import { ThreadListView } from "./thread-list-view";
|
|
40
10
|
import {
|
|
41
11
|
ChatThreadDisplayMode as ChatThreadDisplayMode2,
|
|
42
12
|
chatDocumentPath as chatDocumentPath2,
|
|
43
|
-
resolvedThreadListPath
|
|
44
|
-
} from "./conversation-descriptor
|
|
13
|
+
resolvedThreadListPath
|
|
14
|
+
} from "./conversation-descriptor";
|
|
15
|
+
const multiThreadLayoutBreakpointPx = 920;
|
|
45
16
|
function normalizePath(path) {
|
|
46
17
|
const normalized = path?.trim();
|
|
47
18
|
return normalized ? normalized : null;
|
|
48
19
|
}
|
|
49
|
-
function parseDate(value) {
|
|
50
|
-
const parsed = new Date(value);
|
|
51
|
-
return Number.isNaN(parsed.getTime()) ? /* @__PURE__ */ new Date(0) : parsed;
|
|
52
|
-
}
|
|
53
|
-
function compareThreadEntries(left, right) {
|
|
54
|
-
const leftSortDate = left.modifiedAt.trim() ? parseDate(left.modifiedAt) : parseDate(left.createdAt);
|
|
55
|
-
const rightSortDate = right.modifiedAt.trim() ? parseDate(right.modifiedAt) : parseDate(right.createdAt);
|
|
56
|
-
const dateComparison = rightSortDate.getTime() - leftSortDate.getTime();
|
|
57
|
-
if (dateComparison !== 0) {
|
|
58
|
-
return dateComparison;
|
|
59
|
-
}
|
|
60
|
-
const leftCreatedAt = parseDate(left.createdAt);
|
|
61
|
-
const rightCreatedAt = parseDate(right.createdAt);
|
|
62
|
-
const createdDateComparison = rightCreatedAt.getTime() - leftCreatedAt.getTime();
|
|
63
|
-
if (createdDateComparison !== 0) {
|
|
64
|
-
return createdDateComparison;
|
|
65
|
-
}
|
|
66
|
-
return left.path.localeCompare(right.path);
|
|
67
|
-
}
|
|
68
|
-
function parseThreadListEntries(document) {
|
|
69
|
-
const entries = [];
|
|
70
|
-
for (const child of document.root.getChildren()) {
|
|
71
|
-
if (child.tagName !== "thread") {
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
const rawPath = child.getAttribute("path");
|
|
75
|
-
if (typeof rawPath !== "string" || rawPath.trim() === "") {
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
const path = rawPath.trim();
|
|
79
|
-
const rawName = child.getAttribute("name");
|
|
80
|
-
const rawCreatedAt = child.getAttribute("created_at");
|
|
81
|
-
const rawModifiedAt = child.getAttribute("modified_at");
|
|
82
|
-
entries.push({
|
|
83
|
-
element: child,
|
|
84
|
-
path,
|
|
85
|
-
name: typeof rawName === "string" && rawName.trim() !== "" ? rawName.trim() : defaultThreadDisplayNameFromPath(path),
|
|
86
|
-
createdAt: typeof rawCreatedAt === "string" ? rawCreatedAt : "",
|
|
87
|
-
modifiedAt: typeof rawModifiedAt === "string" ? rawModifiedAt : ""
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
entries.sort(compareThreadEntries);
|
|
91
|
-
return entries;
|
|
92
|
-
}
|
|
93
|
-
function threadEntriesEqual(left, right) {
|
|
94
|
-
return left.length === right.length && left.every((entry, index) => {
|
|
95
|
-
const other = right[index];
|
|
96
|
-
return entry.path === other?.path && entry.name === other.name && entry.createdAt === other.createdAt && entry.modifiedAt === other.modifiedAt;
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
function describeError(error) {
|
|
100
|
-
if (error instanceof Error && error.message.trim() !== "") {
|
|
101
|
-
return error.message;
|
|
102
|
-
}
|
|
103
|
-
return `${error}`;
|
|
104
|
-
}
|
|
105
|
-
async function closeDocument(room, path) {
|
|
106
|
-
try {
|
|
107
|
-
await room.sync.close(path);
|
|
108
|
-
} catch {
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
function threadListEntryFromAgentEntry(entry) {
|
|
112
|
-
return {
|
|
113
|
-
path: entry.path,
|
|
114
|
-
name: entry.name,
|
|
115
|
-
createdAt: entry.createdAt,
|
|
116
|
-
modifiedAt: entry.modifiedAt
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
class MeshDocumentChatThreadListStore {
|
|
120
|
-
constructor(room, path) {
|
|
121
|
-
this.room = room;
|
|
122
|
-
this.path = path;
|
|
123
|
-
}
|
|
124
|
-
room;
|
|
125
|
-
path;
|
|
126
|
-
document = null;
|
|
127
|
-
async open() {
|
|
128
|
-
this.document = await this.room.sync.open(this.path);
|
|
129
|
-
}
|
|
130
|
-
async close() {
|
|
131
|
-
this.document = null;
|
|
132
|
-
await closeDocument(this.room, this.path);
|
|
133
|
-
}
|
|
134
|
-
entries() {
|
|
135
|
-
return this.document === null ? [] : parseThreadListEntries(this.document);
|
|
136
|
-
}
|
|
137
|
-
async renameThread(entry, name) {
|
|
138
|
-
if (entry.element == null) {
|
|
139
|
-
throw new Error("Thread list entry is not backed by a mesh document element.");
|
|
140
|
-
}
|
|
141
|
-
entry.element.setAttribute("name", name);
|
|
142
|
-
}
|
|
143
|
-
async deleteThread(entry) {
|
|
144
|
-
if (entry.element == null) {
|
|
145
|
-
throw new Error("Thread list entry is not backed by a mesh document element.");
|
|
146
|
-
}
|
|
147
|
-
await this.room.storage.delete(entry.path);
|
|
148
|
-
entry.element.delete();
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
class RepositoryChatThreadListStore {
|
|
152
|
-
constructor(repository, onChanged) {
|
|
153
|
-
this.repository = repository;
|
|
154
|
-
this.onChanged = onChanged;
|
|
155
|
-
}
|
|
156
|
-
repository;
|
|
157
|
-
onChanged;
|
|
158
|
-
document = null;
|
|
159
|
-
async open() {
|
|
160
|
-
this.repository.addListener(this.onChanged);
|
|
161
|
-
await this.repository.open();
|
|
162
|
-
}
|
|
163
|
-
async close() {
|
|
164
|
-
this.repository.removeListener(this.onChanged);
|
|
165
|
-
await this.repository.close();
|
|
166
|
-
}
|
|
167
|
-
entries() {
|
|
168
|
-
return this.repository.entries().map(threadListEntryFromAgentEntry);
|
|
169
|
-
}
|
|
170
|
-
async renameThread(entry, name) {
|
|
171
|
-
await this.repository.renameThread(entry.path, name);
|
|
172
|
-
}
|
|
173
|
-
async deleteThread(entry) {
|
|
174
|
-
await this.repository.deleteThread(entry.path);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
20
|
function useIsWideLayout(minWidth) {
|
|
178
21
|
const [matches, setMatches] = useState(false);
|
|
179
22
|
useEffect(() => {
|
|
@@ -192,275 +35,6 @@ function useIsWideLayout(minWidth) {
|
|
|
192
35
|
}, [minWidth]);
|
|
193
36
|
return matches;
|
|
194
37
|
}
|
|
195
|
-
function useThreadListDocument({ room, chatClient, path }) {
|
|
196
|
-
const [document, setDocument] = useState(null);
|
|
197
|
-
const [entries, setEntries] = useState([]);
|
|
198
|
-
const [loading, setLoading] = useState(path !== null);
|
|
199
|
-
const [error, setError] = useState(null);
|
|
200
|
-
const storeRef = useRef(null);
|
|
201
|
-
const syncEntries = useCallback((store = storeRef.current) => {
|
|
202
|
-
if (store === null) {
|
|
203
|
-
setEntries([]);
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
const nextEntries = [...store.entries()].sort(compareThreadEntries);
|
|
207
|
-
setEntries((currentEntries) => threadEntriesEqual(currentEntries, nextEntries) ? currentEntries : nextEntries);
|
|
208
|
-
}, []);
|
|
209
|
-
const createStore = useCallback((nextPath) => {
|
|
210
|
-
if (nextPath.startsWith("agent://")) {
|
|
211
|
-
if (chatClient === null) {
|
|
212
|
-
throw new Error("Agent thread lists require a chat client.");
|
|
213
|
-
}
|
|
214
|
-
return new RepositoryChatThreadListStore(
|
|
215
|
-
new AgentThreadStorageRepository({ chatClient }),
|
|
216
|
-
() => syncEntries()
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
if (nextPath.startsWith("dataset://")) {
|
|
220
|
-
return new RepositoryChatThreadListStore(
|
|
221
|
-
new DatasetThreadStorage({ room, path: nextPath }),
|
|
222
|
-
() => syncEntries()
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
return new MeshDocumentChatThreadListStore(room, nextPath);
|
|
226
|
-
}, [chatClient, room, syncEntries]);
|
|
227
|
-
useEffect(() => {
|
|
228
|
-
let cancelled = false;
|
|
229
|
-
if (path === null) {
|
|
230
|
-
const previousStore = storeRef.current;
|
|
231
|
-
storeRef.current = null;
|
|
232
|
-
void previousStore?.close();
|
|
233
|
-
setDocument(null);
|
|
234
|
-
setEntries([]);
|
|
235
|
-
setLoading(false);
|
|
236
|
-
setError(null);
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
setDocument(null);
|
|
240
|
-
setEntries([]);
|
|
241
|
-
setLoading(true);
|
|
242
|
-
setError(null);
|
|
243
|
-
const store = createStore(path);
|
|
244
|
-
storeRef.current = store;
|
|
245
|
-
void store.open().then(() => {
|
|
246
|
-
if (cancelled) {
|
|
247
|
-
void store.close();
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
setDocument(store.document);
|
|
251
|
-
syncEntries(store);
|
|
252
|
-
setLoading(false);
|
|
253
|
-
setError(null);
|
|
254
|
-
}).catch((nextError) => {
|
|
255
|
-
if (cancelled) {
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
setDocument(null);
|
|
259
|
-
setEntries([]);
|
|
260
|
-
setLoading(false);
|
|
261
|
-
setError(nextError);
|
|
262
|
-
});
|
|
263
|
-
return () => {
|
|
264
|
-
cancelled = true;
|
|
265
|
-
if (storeRef.current === store) {
|
|
266
|
-
storeRef.current = null;
|
|
267
|
-
}
|
|
268
|
-
void store.close();
|
|
269
|
-
};
|
|
270
|
-
}, [createStore, path, syncEntries]);
|
|
271
|
-
useDocumentChanged({
|
|
272
|
-
document,
|
|
273
|
-
onChanged: () => syncEntries()
|
|
274
|
-
});
|
|
275
|
-
return {
|
|
276
|
-
document,
|
|
277
|
-
entries,
|
|
278
|
-
loading,
|
|
279
|
-
error,
|
|
280
|
-
renameThread: async (entry, name) => {
|
|
281
|
-
await storeRef.current?.renameThread(entry, name);
|
|
282
|
-
syncEntries();
|
|
283
|
-
},
|
|
284
|
-
deleteThread: async (entry) => {
|
|
285
|
-
await storeRef.current?.deleteThread(entry);
|
|
286
|
-
syncEntries();
|
|
287
|
-
}
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
function ThreadListRow({
|
|
291
|
-
title,
|
|
292
|
-
selected,
|
|
293
|
-
onClick,
|
|
294
|
-
icon,
|
|
295
|
-
trailing
|
|
296
|
-
}) {
|
|
297
|
-
return /* @__PURE__ */ jsx("div", { className: "px-2 py-1 cursor-pointer", children: /* @__PURE__ */ jsxs(
|
|
298
|
-
"div",
|
|
299
|
-
{
|
|
300
|
-
className: cn(
|
|
301
|
-
"flex min-w-0 items-center rounded-lg border border-transparent transition-colors",
|
|
302
|
-
selected ? "bg-accent text-accent-foreground" : "text-muted-foreground hover:bg-accent/50 hover:text-foreground"
|
|
303
|
-
),
|
|
304
|
-
children: [
|
|
305
|
-
/* @__PURE__ */ jsxs(
|
|
306
|
-
"button",
|
|
307
|
-
{
|
|
308
|
-
type: "button",
|
|
309
|
-
className: "flex min-w-0 flex-1 items-center gap-3 px-3 py-2 text-left",
|
|
310
|
-
onClick,
|
|
311
|
-
children: [
|
|
312
|
-
/* @__PURE__ */ jsx("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center", children: icon }),
|
|
313
|
-
/* @__PURE__ */ jsx(
|
|
314
|
-
"span",
|
|
315
|
-
{
|
|
316
|
-
className: cn(
|
|
317
|
-
"truncate text-sm font-medium",
|
|
318
|
-
selected ? "text-accent-foreground" : "text-foreground"
|
|
319
|
-
),
|
|
320
|
-
children: title
|
|
321
|
-
}
|
|
322
|
-
)
|
|
323
|
-
]
|
|
324
|
-
}
|
|
325
|
-
),
|
|
326
|
-
/* @__PURE__ */ jsx("div", { className: "shrink-0 pr-1", children: trailing ?? /* @__PURE__ */ jsx("div", { className: "h-8 w-8" }) })
|
|
327
|
-
]
|
|
328
|
-
}
|
|
329
|
-
) });
|
|
330
|
-
}
|
|
331
|
-
function ThreadListEntryRow({
|
|
332
|
-
room,
|
|
333
|
-
entry,
|
|
334
|
-
agentName,
|
|
335
|
-
selected,
|
|
336
|
-
onSelect,
|
|
337
|
-
onRename
|
|
338
|
-
}) {
|
|
339
|
-
const status = useThreadStatus({ room, path: entry.path, agentName });
|
|
340
|
-
const iconClassName = selected ? "text-accent-foreground" : "text-muted-foreground";
|
|
341
|
-
return /* @__PURE__ */ jsx(
|
|
342
|
-
ThreadListRow,
|
|
343
|
-
{
|
|
344
|
-
title: entry.name,
|
|
345
|
-
selected,
|
|
346
|
-
onClick: () => onSelect(entry),
|
|
347
|
-
icon: status.hasStatus ? /* @__PURE__ */ jsx(Spinner, { size: "sm", className: iconClassName }) : selected ? /* @__PURE__ */ jsx(Check, { className: cn("h-4 w-4", iconClassName) }) : /* @__PURE__ */ jsx(MessageSquare, { className: cn("h-4 w-4", iconClassName) }),
|
|
348
|
-
trailing: /* @__PURE__ */ jsx(
|
|
349
|
-
Button,
|
|
350
|
-
{
|
|
351
|
-
type: "button",
|
|
352
|
-
variant: "ghost",
|
|
353
|
-
size: "icon",
|
|
354
|
-
className: "h-8 w-8 rounded-md",
|
|
355
|
-
"aria-label": `Rename ${entry.name}`,
|
|
356
|
-
onClick: () => onRename(entry),
|
|
357
|
-
children: /* @__PURE__ */ jsx(Pencil, { className: "h-4 w-4" })
|
|
358
|
-
}
|
|
359
|
-
)
|
|
360
|
-
}
|
|
361
|
-
);
|
|
362
|
-
}
|
|
363
|
-
function ThreadListPanel({
|
|
364
|
-
room,
|
|
365
|
-
threadList,
|
|
366
|
-
selectedThreadPath,
|
|
367
|
-
agentName,
|
|
368
|
-
onSelectThread,
|
|
369
|
-
onClearSelection,
|
|
370
|
-
onRenameThread
|
|
371
|
-
}) {
|
|
372
|
-
const { entries, error, loading } = threadList;
|
|
373
|
-
const hasSelectedEntry = selectedThreadPath !== null && entries.some((entry) => entry.path === selectedThreadPath);
|
|
374
|
-
const showPendingNewThreadSelection = selectedThreadPath === null;
|
|
375
|
-
const pendingSelectedThreadEntry = selectedThreadPath !== null && !hasSelectedEntry ? {
|
|
376
|
-
path: selectedThreadPath,
|
|
377
|
-
name: defaultThreadDisplayNameFromPath(selectedThreadPath),
|
|
378
|
-
createdAt: "",
|
|
379
|
-
modifiedAt: ""
|
|
380
|
-
} : null;
|
|
381
|
-
return /* @__PURE__ */ jsx("div", { className: "h-full flex flex-col rounded-md border", children: loading ? /* @__PURE__ */ jsx("div", { className: "flex min-h-0 flex-1 items-center justify-center p-6", children: /* @__PURE__ */ jsx(Spinner, { size: "lg", className: "text-muted-foreground" }) }) : error ? /* @__PURE__ */ jsx("div", { className: "flex min-h-0 flex-1 items-center justify-center p-6 text-center text-sm text-muted-foreground", children: `Unable to load threads: ${describeError(error)}` }) : /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-1 flex-col overflow-y-auto py-1", children: [
|
|
382
|
-
/* @__PURE__ */ jsx(
|
|
383
|
-
ThreadListRow,
|
|
384
|
-
{
|
|
385
|
-
title: "New thread",
|
|
386
|
-
selected: showPendingNewThreadSelection,
|
|
387
|
-
onClick: onClearSelection,
|
|
388
|
-
icon: showPendingNewThreadSelection ? /* @__PURE__ */ jsx(Check, { className: "h-4 w-4 text-accent-foreground" }) : /* @__PURE__ */ jsx(MessageSquarePlus, { className: "h-4 w-4 text-muted-foreground" })
|
|
389
|
-
}
|
|
390
|
-
),
|
|
391
|
-
entries.length === 0 && showPendingNewThreadSelection ? /* @__PURE__ */ jsx("div", { className: "flex min-h-0 flex-1 items-center justify-center px-4 py-6 text-center text-sm text-muted-foreground", children: "No threads yet" }) : null,
|
|
392
|
-
pendingSelectedThreadEntry !== null ? /* @__PURE__ */ jsx(
|
|
393
|
-
ThreadListEntryRow,
|
|
394
|
-
{
|
|
395
|
-
room,
|
|
396
|
-
entry: pendingSelectedThreadEntry,
|
|
397
|
-
agentName,
|
|
398
|
-
selected: true,
|
|
399
|
-
onSelect: onSelectThread,
|
|
400
|
-
onRename: onRenameThread
|
|
401
|
-
},
|
|
402
|
-
pendingSelectedThreadEntry.path
|
|
403
|
-
) : null,
|
|
404
|
-
entries.map((entry) => /* @__PURE__ */ jsx(
|
|
405
|
-
ThreadListEntryRow,
|
|
406
|
-
{
|
|
407
|
-
room,
|
|
408
|
-
entry,
|
|
409
|
-
agentName,
|
|
410
|
-
selected: entry.path === selectedThreadPath,
|
|
411
|
-
onSelect: onSelectThread,
|
|
412
|
-
onRename: onRenameThread
|
|
413
|
-
},
|
|
414
|
-
entry.path
|
|
415
|
-
))
|
|
416
|
-
] }) });
|
|
417
|
-
}
|
|
418
|
-
function RenameThreadDialog({
|
|
419
|
-
dialogState,
|
|
420
|
-
onNameChange,
|
|
421
|
-
onOpenChange,
|
|
422
|
-
onSubmit
|
|
423
|
-
}) {
|
|
424
|
-
const inputId = useId();
|
|
425
|
-
const inputRef = useRef(null);
|
|
426
|
-
const trimmedName = dialogState?.value.trim() ?? "";
|
|
427
|
-
const saveDisabled = dialogState === null || trimmedName === "" || trimmedName === dialogState.entry.name;
|
|
428
|
-
return /* @__PURE__ */ jsx(Dialog, { open: dialogState !== null, onOpenChange, children: /* @__PURE__ */ jsx(
|
|
429
|
-
DialogContent,
|
|
430
|
-
{
|
|
431
|
-
showCloseButton: false,
|
|
432
|
-
className: "sm:max-w-[425px]",
|
|
433
|
-
onOpenAutoFocus: (event) => {
|
|
434
|
-
event.preventDefault();
|
|
435
|
-
inputRef.current?.focus();
|
|
436
|
-
inputRef.current?.select();
|
|
437
|
-
},
|
|
438
|
-
children: /* @__PURE__ */ jsxs("form", { className: "space-y-4", onSubmit, children: [
|
|
439
|
-
/* @__PURE__ */ jsxs(DialogHeader, { children: [
|
|
440
|
-
/* @__PURE__ */ jsx(DialogTitle, { children: "Rename thread" }),
|
|
441
|
-
/* @__PURE__ */ jsx(DialogDescription, { children: "Use a short and descriptive name" })
|
|
442
|
-
] }),
|
|
443
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
444
|
-
/* @__PURE__ */ jsx(Label, { htmlFor: inputId, children: "Name" }),
|
|
445
|
-
/* @__PURE__ */ jsx(
|
|
446
|
-
Input,
|
|
447
|
-
{
|
|
448
|
-
ref: inputRef,
|
|
449
|
-
id: inputId,
|
|
450
|
-
value: dialogState?.value ?? "",
|
|
451
|
-
autoComplete: "off",
|
|
452
|
-
onChange: onNameChange
|
|
453
|
-
}
|
|
454
|
-
)
|
|
455
|
-
] }),
|
|
456
|
-
/* @__PURE__ */ jsxs(DialogFooter, { children: [
|
|
457
|
-
/* @__PURE__ */ jsx(DialogClose, { asChild: true, children: /* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", children: "Cancel" }) }),
|
|
458
|
-
/* @__PURE__ */ jsx(Button, { type: "submit", disabled: saveDisabled, children: "Save" })
|
|
459
|
-
] })
|
|
460
|
-
] })
|
|
461
|
-
}
|
|
462
|
-
) });
|
|
463
|
-
}
|
|
464
38
|
function MultiThreadUnavailable() {
|
|
465
39
|
return /* @__PURE__ */ jsx("div", { className: "flex min-h-0 flex-1 items-center justify-center px-4 py-8", children: /* @__PURE__ */ jsx("div", { className: "w-full max-w-[912px] rounded-3xl border border-destructive/30 bg-destructive/5 p-6 text-destructive", children: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
|
|
466
40
|
/* @__PURE__ */ jsx(AlertTriangle, { className: "mt-0.5 h-5 w-5 shrink-0" }),
|
|
@@ -476,11 +50,9 @@ function ChatBotView({
|
|
|
476
50
|
disposeChatClient = false,
|
|
477
51
|
path,
|
|
478
52
|
documentPath,
|
|
479
|
-
participants,
|
|
480
53
|
agentName,
|
|
481
54
|
threadDisplayMode = ChatThreadDisplayMode.SingleThread,
|
|
482
55
|
threadDir,
|
|
483
|
-
threadListPath,
|
|
484
56
|
toolkit,
|
|
485
57
|
tool,
|
|
486
58
|
centerComposer = false,
|
|
@@ -489,6 +61,7 @@ function ChatBotView({
|
|
|
489
61
|
startNewThreadTitle = "Start a new thread",
|
|
490
62
|
startNewThreadDescription = "Connect with this agent and your team.",
|
|
491
63
|
selectedThreadPath,
|
|
64
|
+
selectedThreadDisplayName,
|
|
492
65
|
onSelectedThreadPathChanged,
|
|
493
66
|
onSelectedThreadResolved,
|
|
494
67
|
onThreadResolved,
|
|
@@ -496,17 +69,13 @@ function ChatBotView({
|
|
|
496
69
|
showThreadList = true,
|
|
497
70
|
threadListWidth = 280,
|
|
498
71
|
threadListCollapsedHeight = 220,
|
|
499
|
-
clientToolkits
|
|
72
|
+
clientToolkits,
|
|
73
|
+
toolChoice,
|
|
74
|
+
collapseMessages = true
|
|
500
75
|
}) {
|
|
501
76
|
const isWideLayout = useIsWideLayout(multiThreadLayoutBreakpointPx);
|
|
502
|
-
const resolvedDocumentPath = useMemo(
|
|
503
|
-
|
|
504
|
-
[documentPath, path]
|
|
505
|
-
);
|
|
506
|
-
const resolvedSingleThreadPath = useMemo(
|
|
507
|
-
() => resolvedDocumentPath ?? chatDocumentPath(agentName, { threadDir }),
|
|
508
|
-
[agentName, resolvedDocumentPath, threadDir]
|
|
509
|
-
);
|
|
77
|
+
const resolvedDocumentPath = useMemo(() => normalizePath(documentPath ?? path), [documentPath, path]);
|
|
78
|
+
const resolvedSingleThreadPath = useMemo(() => resolvedDocumentPath ?? chatDocumentPath(agentName, { threadDir }), [agentName, resolvedDocumentPath, threadDir]);
|
|
510
79
|
const needsChatClient = chatClient != null || threadDisplayMode === ChatThreadDisplayMode.MultiThreadComposer;
|
|
511
80
|
const ownsChatClient = chatClient == null && needsChatClient;
|
|
512
81
|
const activeChatClient = useMemo(
|
|
@@ -518,17 +87,7 @@ function ChatBotView({
|
|
|
518
87
|
const [internalSelectedThreadPath, setInternalSelectedThreadPath] = useState(() => explicitSelectedThreadPath ?? legacySelectedThreadPath ?? null);
|
|
519
88
|
const previousLegacySelectedThreadPathRef = useRef(legacySelectedThreadPath);
|
|
520
89
|
const previousNewThreadResetVersionRef = useRef(newThreadResetVersion);
|
|
521
|
-
const [renameThreadDialog, setRenameThreadDialog] = useState(null);
|
|
522
90
|
const activeSelectedThreadPath = explicitSelectedThreadPath ?? internalSelectedThreadPath;
|
|
523
|
-
const resolvedThreadListDocumentPath = useMemo(
|
|
524
|
-
() => resolvedThreadListPath(threadListPath, { threadDir, agentName }),
|
|
525
|
-
[agentName, threadDir, threadListPath]
|
|
526
|
-
);
|
|
527
|
-
const threadList = useThreadListDocument({
|
|
528
|
-
room,
|
|
529
|
-
chatClient: activeChatClient,
|
|
530
|
-
path: threadDisplayMode === ChatThreadDisplayMode.MultiThreadComposer && showThreadList && resolvedThreadListDocumentPath !== null ? resolvedThreadListDocumentPath : null
|
|
531
|
-
});
|
|
532
91
|
useEffect(() => {
|
|
533
92
|
return () => {
|
|
534
93
|
if (activeChatClient !== null && (ownsChatClient || disposeChatClient)) {
|
|
@@ -568,9 +127,6 @@ function ChatBotView({
|
|
|
568
127
|
handleSelectedThreadPathChanged(normalizedNextPath);
|
|
569
128
|
emitResolvedThread(normalizedNextPath, displayName);
|
|
570
129
|
}, [emitResolvedThread, handleSelectedThreadPathChanged]);
|
|
571
|
-
const closeRenameThreadDialog = useCallback(() => {
|
|
572
|
-
setRenameThreadDialog(null);
|
|
573
|
-
}, []);
|
|
574
130
|
useEffect(() => {
|
|
575
131
|
if (threadDisplayMode !== ChatThreadDisplayMode.MultiThreadComposer) {
|
|
576
132
|
previousNewThreadResetVersionRef.current = newThreadResetVersion;
|
|
@@ -581,49 +137,6 @@ function ChatBotView({
|
|
|
581
137
|
}
|
|
582
138
|
previousNewThreadResetVersionRef.current = newThreadResetVersion;
|
|
583
139
|
}, [activeSelectedThreadPath, newThreadResetVersion, setSelectedThread, threadDisplayMode]);
|
|
584
|
-
const handleRenameThread = useCallback((entry) => {
|
|
585
|
-
setRenameThreadDialog({
|
|
586
|
-
entry,
|
|
587
|
-
value: entry.name
|
|
588
|
-
});
|
|
589
|
-
}, []);
|
|
590
|
-
const handleRenameThreadNameChanged = useCallback((event) => {
|
|
591
|
-
const nextValue = event.target.value;
|
|
592
|
-
setRenameThreadDialog((currentDialogState) => {
|
|
593
|
-
if (currentDialogState === null) {
|
|
594
|
-
return currentDialogState;
|
|
595
|
-
}
|
|
596
|
-
return {
|
|
597
|
-
...currentDialogState,
|
|
598
|
-
value: nextValue
|
|
599
|
-
};
|
|
600
|
-
});
|
|
601
|
-
}, []);
|
|
602
|
-
const handleRenameThreadDialogOpenChange = useCallback((open) => {
|
|
603
|
-
if (!open) {
|
|
604
|
-
closeRenameThreadDialog();
|
|
605
|
-
}
|
|
606
|
-
}, [closeRenameThreadDialog]);
|
|
607
|
-
const handleRenameThreadSubmit = useCallback((event) => {
|
|
608
|
-
event.preventDefault();
|
|
609
|
-
if (renameThreadDialog === null) {
|
|
610
|
-
return;
|
|
611
|
-
}
|
|
612
|
-
const trimmedName = renameThreadDialog.value.trim();
|
|
613
|
-
if (trimmedName === "" || trimmedName === renameThreadDialog.entry.name) {
|
|
614
|
-
return;
|
|
615
|
-
}
|
|
616
|
-
void threadList.renameThread(renameThreadDialog.entry, trimmedName).then(() => {
|
|
617
|
-
if (renameThreadDialog.entry.path === activeSelectedThreadPath) {
|
|
618
|
-
emitResolvedThread(renameThreadDialog.entry.path, trimmedName);
|
|
619
|
-
}
|
|
620
|
-
closeRenameThreadDialog();
|
|
621
|
-
}).catch((renameError) => {
|
|
622
|
-
setTimeout(() => {
|
|
623
|
-
throw renameError;
|
|
624
|
-
}, 0);
|
|
625
|
-
});
|
|
626
|
-
}, [activeSelectedThreadPath, closeRenameThreadDialog, emitResolvedThread, renameThreadDialog, threadList]);
|
|
627
140
|
if (threadDisplayMode !== ChatThreadDisplayMode.MultiThreadComposer) {
|
|
628
141
|
return /* @__PURE__ */ jsx(
|
|
629
142
|
AgentThread,
|
|
@@ -635,7 +148,9 @@ function ChatBotView({
|
|
|
635
148
|
agentName,
|
|
636
149
|
emptyStateTitle,
|
|
637
150
|
emptyStateDescription,
|
|
638
|
-
clientToolkits
|
|
151
|
+
clientToolkits,
|
|
152
|
+
toolChoice,
|
|
153
|
+
collapseMessages
|
|
639
154
|
}
|
|
640
155
|
);
|
|
641
156
|
}
|
|
@@ -657,6 +172,7 @@ function ChatBotView({
|
|
|
657
172
|
newThreadResetVersion,
|
|
658
173
|
centerComposer,
|
|
659
174
|
clientToolkits,
|
|
175
|
+
toolChoice,
|
|
660
176
|
builder: (threadPath) => /* @__PURE__ */ jsx(
|
|
661
177
|
AgentThread,
|
|
662
178
|
{
|
|
@@ -667,66 +183,35 @@ function ChatBotView({
|
|
|
667
183
|
agentName,
|
|
668
184
|
emptyStateTitle: startNewThreadTitle,
|
|
669
185
|
emptyStateDescription: startNewThreadDescription,
|
|
670
|
-
clientToolkits
|
|
186
|
+
clientToolkits,
|
|
187
|
+
toolChoice,
|
|
188
|
+
collapseMessages
|
|
671
189
|
}
|
|
672
190
|
)
|
|
673
191
|
}
|
|
674
192
|
);
|
|
675
|
-
if (!showThreadList ||
|
|
676
|
-
return
|
|
677
|
-
content,
|
|
678
|
-
/* @__PURE__ */ jsx(
|
|
679
|
-
RenameThreadDialog,
|
|
680
|
-
{
|
|
681
|
-
dialogState: renameThreadDialog,
|
|
682
|
-
onNameChange: handleRenameThreadNameChanged,
|
|
683
|
-
onOpenChange: handleRenameThreadDialogOpenChange,
|
|
684
|
-
onSubmit: handleRenameThreadSubmit
|
|
685
|
-
}
|
|
686
|
-
)
|
|
687
|
-
] });
|
|
193
|
+
if (!showThreadList || activeChatClient === null) {
|
|
194
|
+
return content;
|
|
688
195
|
}
|
|
689
|
-
return /* @__PURE__ */ jsxs(
|
|
690
|
-
/* @__PURE__ */
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
"div",
|
|
694
|
-
{
|
|
695
|
-
className: cn("shrink-0 mr-4", isWideLayout ? "ml-3" : "mt-3"),
|
|
696
|
-
style: isWideLayout ? { width: threadListWidth } : { height: threadListCollapsedHeight },
|
|
697
|
-
children: /* @__PURE__ */ jsx(
|
|
698
|
-
ThreadListPanel,
|
|
699
|
-
{
|
|
700
|
-
room,
|
|
701
|
-
threadList,
|
|
702
|
-
selectedThreadPath: activeSelectedThreadPath,
|
|
703
|
-
agentName,
|
|
704
|
-
onSelectThread: (entry) => {
|
|
705
|
-
setSelectedThread(entry.path, entry.name);
|
|
706
|
-
},
|
|
707
|
-
onClearSelection: () => {
|
|
708
|
-
setSelectedThread(null, null);
|
|
709
|
-
},
|
|
710
|
-
onRenameThread: handleRenameThread
|
|
711
|
-
}
|
|
712
|
-
)
|
|
713
|
-
}
|
|
714
|
-
)
|
|
715
|
-
] }),
|
|
716
|
-
/* @__PURE__ */ jsx(
|
|
717
|
-
RenameThreadDialog,
|
|
196
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-1 h-full", isWideLayout ? "flex-row items-stretch" : "flex-col"), children: [
|
|
197
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col h-full min-h-0 min-w-0 flex-1", children: content }),
|
|
198
|
+
/* @__PURE__ */ jsx("div", { className: cn("shrink-0 mr-4", isWideLayout ? "ml-3" : "mt-3"), style: isWideLayout ? { width: threadListWidth } : { height: threadListCollapsedHeight }, children: /* @__PURE__ */ jsx(
|
|
199
|
+
ThreadListView,
|
|
718
200
|
{
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
201
|
+
room,
|
|
202
|
+
chatClient: activeChatClient,
|
|
203
|
+
selectedThreadPath: activeSelectedThreadPath,
|
|
204
|
+
selectedThreadDisplayName,
|
|
205
|
+
agentName,
|
|
206
|
+
onSelectedThreadPathChanged: handleSelectedThreadPathChanged,
|
|
207
|
+
onSelectedThreadResolved: emitResolvedThread
|
|
723
208
|
}
|
|
724
|
-
)
|
|
209
|
+
) })
|
|
725
210
|
] });
|
|
726
211
|
}
|
|
727
212
|
export {
|
|
728
213
|
ChatBotView,
|
|
729
214
|
ChatThreadDisplayMode2 as ChatThreadDisplayMode,
|
|
730
215
|
chatDocumentPath2 as chatDocumentPath,
|
|
731
|
-
|
|
216
|
+
resolvedThreadListPath
|
|
732
217
|
};
|