@meshagent/meshagent-tailwind 0.43.2 → 0.44.0
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 +107 -0
- package/dist/cjs/chat/agent-thread-message-status-store.js +649 -0
- package/dist/cjs/chat/agent-thread.d.ts +87 -0
- package/dist/cjs/chat/agent-thread.js +1673 -0
- package/dist/cjs/chat/chat-bot-view.d.ts +9 -5
- package/dist/cjs/chat/chat-bot-view.js +44 -536
- 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 +5 -2
- package/dist/cjs/chat/multi-thread-view.js +6 -2
- package/dist/cjs/chat/new-chat-thread.d.ts +5 -2
- package/dist/cjs/chat/new-chat-thread.js +10 -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 +43 -7
- package/dist/cjs/index.d.ts +4 -2
- package/dist/cjs/index.js +14 -2
- 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 +107 -0
- package/dist/esm/chat/agent-thread-message-status-store.js +647 -0
- package/dist/esm/chat/agent-thread.d.ts +87 -0
- package/dist/esm/chat/agent-thread.js +1682 -0
- package/dist/esm/chat/chat-bot-view.d.ts +9 -5
- package/dist/esm/chat/chat-bot-view.js +51 -566
- 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 +5 -2
- package/dist/esm/chat/multi-thread-view.js +6 -2
- package/dist/esm/chat/new-chat-thread.d.ts +5 -2
- package/dist/esm/chat/new-chat-thread.js +11 -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 +31 -5
- package/dist/esm/index.d.ts +4 -2
- package/dist/esm/index.js +10 -2
- 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 +10 -5
- package/dist/cjs/chat/chat-thread.d.ts +0 -12
- package/dist/cjs/chat/chat-thread.js +0 -815
- package/dist/cjs/chat/dataset-chat-thread.d.ts +0 -16
- package/dist/cjs/chat/dataset-chat-thread.js +0 -1813
- package/dist/esm/chat/chat-thread.d.ts +0 -12
- package/dist/esm/chat/chat-thread.js +0 -785
- package/dist/esm/chat/dataset-chat-thread.d.ts +0 -16
- package/dist/esm/chat/dataset-chat-thread.js +0 -1811
|
@@ -1,183 +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 { ChatThread } from "./chat-thread.js";
|
|
18
|
-
import { DatasetChatThread } from "./dataset-chat-thread.js";
|
|
19
|
-
import { Button } from "../components/ui/button.js";
|
|
20
|
-
import {
|
|
21
|
-
Dialog,
|
|
22
|
-
DialogClose,
|
|
23
|
-
DialogContent,
|
|
24
|
-
DialogDescription,
|
|
25
|
-
DialogFooter,
|
|
26
|
-
DialogHeader,
|
|
27
|
-
DialogTitle
|
|
28
|
-
} from "../components/ui/dialog.js";
|
|
29
|
-
import { Input } from "../components/ui/input.js";
|
|
30
|
-
import { Label } from "../components/ui/label.js";
|
|
31
|
-
import { Spinner } from "../components/ui/spinner.js";
|
|
32
|
-
import {
|
|
33
|
-
ChatThreadDisplayMode,
|
|
34
|
-
chatDocumentPath,
|
|
35
|
-
defaultThreadDisplayNameFromPath,
|
|
36
|
-
resolvedThreadListPath
|
|
37
|
-
} from "./conversation-descriptor.js";
|
|
38
|
-
import { cn } from "../lib/utils.js";
|
|
39
|
-
import { MultiThreadView } from "./multi-thread-view.js";
|
|
40
|
-
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";
|
|
41
10
|
import {
|
|
42
11
|
ChatThreadDisplayMode as ChatThreadDisplayMode2,
|
|
43
12
|
chatDocumentPath as chatDocumentPath2,
|
|
44
|
-
resolvedThreadListPath
|
|
45
|
-
} from "./conversation-descriptor
|
|
13
|
+
resolvedThreadListPath
|
|
14
|
+
} from "./conversation-descriptor";
|
|
15
|
+
const multiThreadLayoutBreakpointPx = 920;
|
|
46
16
|
function normalizePath(path) {
|
|
47
17
|
const normalized = path?.trim();
|
|
48
18
|
return normalized ? normalized : null;
|
|
49
19
|
}
|
|
50
|
-
function isDatasetBackedThreadPath(path) {
|
|
51
|
-
return path.startsWith("dataset://") || path.startsWith("tmp://");
|
|
52
|
-
}
|
|
53
|
-
function parseDate(value) {
|
|
54
|
-
const parsed = new Date(value);
|
|
55
|
-
return Number.isNaN(parsed.getTime()) ? /* @__PURE__ */ new Date(0) : parsed;
|
|
56
|
-
}
|
|
57
|
-
function compareThreadEntries(left, right) {
|
|
58
|
-
const leftSortDate = left.modifiedAt.trim() ? parseDate(left.modifiedAt) : parseDate(left.createdAt);
|
|
59
|
-
const rightSortDate = right.modifiedAt.trim() ? parseDate(right.modifiedAt) : parseDate(right.createdAt);
|
|
60
|
-
const dateComparison = rightSortDate.getTime() - leftSortDate.getTime();
|
|
61
|
-
if (dateComparison !== 0) {
|
|
62
|
-
return dateComparison;
|
|
63
|
-
}
|
|
64
|
-
const leftCreatedAt = parseDate(left.createdAt);
|
|
65
|
-
const rightCreatedAt = parseDate(right.createdAt);
|
|
66
|
-
const createdDateComparison = rightCreatedAt.getTime() - leftCreatedAt.getTime();
|
|
67
|
-
if (createdDateComparison !== 0) {
|
|
68
|
-
return createdDateComparison;
|
|
69
|
-
}
|
|
70
|
-
return left.path.localeCompare(right.path);
|
|
71
|
-
}
|
|
72
|
-
function parseThreadListEntries(document) {
|
|
73
|
-
const entries = [];
|
|
74
|
-
for (const child of document.root.getChildren()) {
|
|
75
|
-
if (child.tagName !== "thread") {
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
const rawPath = child.getAttribute("path");
|
|
79
|
-
if (typeof rawPath !== "string" || rawPath.trim() === "") {
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
const path = rawPath.trim();
|
|
83
|
-
const rawName = child.getAttribute("name");
|
|
84
|
-
const rawCreatedAt = child.getAttribute("created_at");
|
|
85
|
-
const rawModifiedAt = child.getAttribute("modified_at");
|
|
86
|
-
entries.push({
|
|
87
|
-
element: child,
|
|
88
|
-
path,
|
|
89
|
-
name: typeof rawName === "string" && rawName.trim() !== "" ? rawName.trim() : defaultThreadDisplayNameFromPath(path),
|
|
90
|
-
createdAt: typeof rawCreatedAt === "string" ? rawCreatedAt : "",
|
|
91
|
-
modifiedAt: typeof rawModifiedAt === "string" ? rawModifiedAt : ""
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
entries.sort(compareThreadEntries);
|
|
95
|
-
return entries;
|
|
96
|
-
}
|
|
97
|
-
function threadEntriesEqual(left, right) {
|
|
98
|
-
return left.length === right.length && left.every((entry, index) => {
|
|
99
|
-
const other = right[index];
|
|
100
|
-
return entry.path === other?.path && entry.name === other.name && entry.createdAt === other.createdAt && entry.modifiedAt === other.modifiedAt;
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
function describeError(error) {
|
|
104
|
-
if (error instanceof Error && error.message.trim() !== "") {
|
|
105
|
-
return error.message;
|
|
106
|
-
}
|
|
107
|
-
return `${error}`;
|
|
108
|
-
}
|
|
109
|
-
async function closeDocument(room, path) {
|
|
110
|
-
try {
|
|
111
|
-
await room.sync.close(path);
|
|
112
|
-
} catch {
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
function threadListEntryFromAgentEntry(entry) {
|
|
116
|
-
return {
|
|
117
|
-
path: entry.path,
|
|
118
|
-
name: entry.name,
|
|
119
|
-
createdAt: entry.createdAt,
|
|
120
|
-
modifiedAt: entry.modifiedAt
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
class MeshDocumentChatThreadListStore {
|
|
124
|
-
constructor(room, path) {
|
|
125
|
-
this.room = room;
|
|
126
|
-
this.path = path;
|
|
127
|
-
}
|
|
128
|
-
room;
|
|
129
|
-
path;
|
|
130
|
-
document = null;
|
|
131
|
-
async open() {
|
|
132
|
-
this.document = await this.room.sync.open(this.path);
|
|
133
|
-
}
|
|
134
|
-
async close() {
|
|
135
|
-
this.document = null;
|
|
136
|
-
await closeDocument(this.room, this.path);
|
|
137
|
-
}
|
|
138
|
-
entries() {
|
|
139
|
-
return this.document === null ? [] : parseThreadListEntries(this.document);
|
|
140
|
-
}
|
|
141
|
-
async renameThread(entry, name) {
|
|
142
|
-
if (entry.element == null) {
|
|
143
|
-
throw new Error("Thread list entry is not backed by a mesh document element.");
|
|
144
|
-
}
|
|
145
|
-
entry.element.setAttribute("name", name);
|
|
146
|
-
}
|
|
147
|
-
async deleteThread(entry) {
|
|
148
|
-
if (entry.element == null) {
|
|
149
|
-
throw new Error("Thread list entry is not backed by a mesh document element.");
|
|
150
|
-
}
|
|
151
|
-
await this.room.storage.delete(entry.path);
|
|
152
|
-
entry.element.delete();
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
class RepositoryChatThreadListStore {
|
|
156
|
-
constructor(repository, onChanged) {
|
|
157
|
-
this.repository = repository;
|
|
158
|
-
this.onChanged = onChanged;
|
|
159
|
-
}
|
|
160
|
-
repository;
|
|
161
|
-
onChanged;
|
|
162
|
-
document = null;
|
|
163
|
-
async open() {
|
|
164
|
-
this.repository.addListener(this.onChanged);
|
|
165
|
-
await this.repository.open();
|
|
166
|
-
}
|
|
167
|
-
async close() {
|
|
168
|
-
this.repository.removeListener(this.onChanged);
|
|
169
|
-
await this.repository.close();
|
|
170
|
-
}
|
|
171
|
-
entries() {
|
|
172
|
-
return this.repository.entries().map(threadListEntryFromAgentEntry);
|
|
173
|
-
}
|
|
174
|
-
async renameThread(entry, name) {
|
|
175
|
-
await this.repository.renameThread(entry.path, name);
|
|
176
|
-
}
|
|
177
|
-
async deleteThread(entry) {
|
|
178
|
-
await this.repository.deleteThread(entry.path);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
20
|
function useIsWideLayout(minWidth) {
|
|
182
21
|
const [matches, setMatches] = useState(false);
|
|
183
22
|
useEffect(() => {
|
|
@@ -196,257 +35,6 @@ function useIsWideLayout(minWidth) {
|
|
|
196
35
|
}, [minWidth]);
|
|
197
36
|
return matches;
|
|
198
37
|
}
|
|
199
|
-
function useThreadListDocument({ room, chatClient, path }) {
|
|
200
|
-
const [document, setDocument] = useState(null);
|
|
201
|
-
const [entries, setEntries] = useState([]);
|
|
202
|
-
const [loading, setLoading] = useState(path !== null);
|
|
203
|
-
const [error, setError] = useState(null);
|
|
204
|
-
const storeRef = useRef(null);
|
|
205
|
-
const syncEntries = useCallback((store = storeRef.current) => {
|
|
206
|
-
if (store === null) {
|
|
207
|
-
setEntries([]);
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
const nextEntries = [...store.entries()].sort(compareThreadEntries);
|
|
211
|
-
setEntries((currentEntries) => threadEntriesEqual(currentEntries, nextEntries) ? currentEntries : nextEntries);
|
|
212
|
-
}, []);
|
|
213
|
-
const createStore = useCallback((nextPath) => {
|
|
214
|
-
if (nextPath.startsWith("agent://")) {
|
|
215
|
-
if (chatClient === null) {
|
|
216
|
-
throw new Error("Agent thread lists require a chat client.");
|
|
217
|
-
}
|
|
218
|
-
return new RepositoryChatThreadListStore(
|
|
219
|
-
new AgentThreadStorageRepository({ chatClient }),
|
|
220
|
-
() => syncEntries()
|
|
221
|
-
);
|
|
222
|
-
}
|
|
223
|
-
if (nextPath.startsWith("dataset://")) {
|
|
224
|
-
return new RepositoryChatThreadListStore(
|
|
225
|
-
new DatasetThreadStorage({ room, path: nextPath }),
|
|
226
|
-
() => syncEntries()
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
return new MeshDocumentChatThreadListStore(room, nextPath);
|
|
230
|
-
}, [chatClient, room, syncEntries]);
|
|
231
|
-
useEffect(() => {
|
|
232
|
-
let cancelled = false;
|
|
233
|
-
if (path === null) {
|
|
234
|
-
const previousStore = storeRef.current;
|
|
235
|
-
storeRef.current = null;
|
|
236
|
-
void previousStore?.close();
|
|
237
|
-
setDocument(null);
|
|
238
|
-
setEntries([]);
|
|
239
|
-
setLoading(false);
|
|
240
|
-
setError(null);
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
setDocument(null);
|
|
244
|
-
setEntries([]);
|
|
245
|
-
setLoading(true);
|
|
246
|
-
setError(null);
|
|
247
|
-
const store = createStore(path);
|
|
248
|
-
storeRef.current = store;
|
|
249
|
-
void store.open().then(() => {
|
|
250
|
-
if (cancelled) {
|
|
251
|
-
void store.close();
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
setDocument(store.document);
|
|
255
|
-
syncEntries(store);
|
|
256
|
-
setLoading(false);
|
|
257
|
-
setError(null);
|
|
258
|
-
}).catch((nextError) => {
|
|
259
|
-
if (cancelled) {
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
setDocument(null);
|
|
263
|
-
setEntries([]);
|
|
264
|
-
setLoading(false);
|
|
265
|
-
setError(nextError);
|
|
266
|
-
});
|
|
267
|
-
return () => {
|
|
268
|
-
cancelled = true;
|
|
269
|
-
if (storeRef.current === store) {
|
|
270
|
-
storeRef.current = null;
|
|
271
|
-
}
|
|
272
|
-
void store.close();
|
|
273
|
-
};
|
|
274
|
-
}, [createStore, path, syncEntries]);
|
|
275
|
-
useDocumentChanged({
|
|
276
|
-
document,
|
|
277
|
-
onChanged: () => syncEntries()
|
|
278
|
-
});
|
|
279
|
-
return {
|
|
280
|
-
document,
|
|
281
|
-
entries,
|
|
282
|
-
loading,
|
|
283
|
-
error,
|
|
284
|
-
renameThread: async (entry, name) => {
|
|
285
|
-
await storeRef.current?.renameThread(entry, name);
|
|
286
|
-
syncEntries();
|
|
287
|
-
},
|
|
288
|
-
deleteThread: async (entry) => {
|
|
289
|
-
await storeRef.current?.deleteThread(entry);
|
|
290
|
-
syncEntries();
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
|
-
function ThreadListRow({
|
|
295
|
-
title,
|
|
296
|
-
selected,
|
|
297
|
-
onClick,
|
|
298
|
-
icon,
|
|
299
|
-
trailing
|
|
300
|
-
}) {
|
|
301
|
-
return /* @__PURE__ */ jsx("div", { className: "px-2 py-1 cursor-pointer", children: /* @__PURE__ */ jsxs(
|
|
302
|
-
"div",
|
|
303
|
-
{
|
|
304
|
-
className: cn(
|
|
305
|
-
"flex min-w-0 items-center rounded-lg border border-transparent transition-colors",
|
|
306
|
-
selected ? "bg-accent text-accent-foreground" : "text-muted-foreground hover:bg-accent/50 hover:text-foreground"
|
|
307
|
-
),
|
|
308
|
-
children: [
|
|
309
|
-
/* @__PURE__ */ jsxs(
|
|
310
|
-
"button",
|
|
311
|
-
{
|
|
312
|
-
type: "button",
|
|
313
|
-
className: "flex min-w-0 flex-1 items-center gap-3 px-3 py-2 text-left",
|
|
314
|
-
onClick,
|
|
315
|
-
children: [
|
|
316
|
-
/* @__PURE__ */ jsx("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center", children: icon }),
|
|
317
|
-
/* @__PURE__ */ jsx(
|
|
318
|
-
"span",
|
|
319
|
-
{
|
|
320
|
-
className: cn(
|
|
321
|
-
"truncate text-sm font-medium",
|
|
322
|
-
selected ? "text-accent-foreground" : "text-foreground"
|
|
323
|
-
),
|
|
324
|
-
children: title
|
|
325
|
-
}
|
|
326
|
-
)
|
|
327
|
-
]
|
|
328
|
-
}
|
|
329
|
-
),
|
|
330
|
-
/* @__PURE__ */ jsx("div", { className: "shrink-0 pr-1", children: trailing ?? /* @__PURE__ */ jsx("div", { className: "h-8 w-8" }) })
|
|
331
|
-
]
|
|
332
|
-
}
|
|
333
|
-
) });
|
|
334
|
-
}
|
|
335
|
-
function ThreadListEntryRow({
|
|
336
|
-
room,
|
|
337
|
-
entry,
|
|
338
|
-
agentName,
|
|
339
|
-
selected,
|
|
340
|
-
onSelect,
|
|
341
|
-
onRename
|
|
342
|
-
}) {
|
|
343
|
-
const status = useThreadStatus({ room, path: entry.path, agentName });
|
|
344
|
-
const iconClassName = selected ? "text-accent-foreground" : "text-muted-foreground";
|
|
345
|
-
return /* @__PURE__ */ jsx(
|
|
346
|
-
ThreadListRow,
|
|
347
|
-
{
|
|
348
|
-
title: entry.name,
|
|
349
|
-
selected,
|
|
350
|
-
onClick: () => onSelect(entry),
|
|
351
|
-
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) }),
|
|
352
|
-
trailing: /* @__PURE__ */ jsx(
|
|
353
|
-
Button,
|
|
354
|
-
{
|
|
355
|
-
type: "button",
|
|
356
|
-
variant: "ghost",
|
|
357
|
-
size: "icon",
|
|
358
|
-
className: "h-8 w-8 rounded-md",
|
|
359
|
-
"aria-label": `Rename ${entry.name}`,
|
|
360
|
-
onClick: () => onRename(entry),
|
|
361
|
-
children: /* @__PURE__ */ jsx(Pencil, { className: "h-4 w-4" })
|
|
362
|
-
}
|
|
363
|
-
)
|
|
364
|
-
}
|
|
365
|
-
);
|
|
366
|
-
}
|
|
367
|
-
function ThreadListPanel({
|
|
368
|
-
room,
|
|
369
|
-
threadList,
|
|
370
|
-
selectedThreadPath,
|
|
371
|
-
agentName,
|
|
372
|
-
onSelectThread,
|
|
373
|
-
onClearSelection,
|
|
374
|
-
onRenameThread
|
|
375
|
-
}) {
|
|
376
|
-
const { entries, error, loading } = threadList;
|
|
377
|
-
const hasSelectedEntry = selectedThreadPath !== null && entries.some((entry) => entry.path === selectedThreadPath);
|
|
378
|
-
const showPendingNewThreadSelection = selectedThreadPath === null || !hasSelectedEntry;
|
|
379
|
-
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: [
|
|
380
|
-
/* @__PURE__ */ jsx(
|
|
381
|
-
ThreadListRow,
|
|
382
|
-
{
|
|
383
|
-
title: "New thread",
|
|
384
|
-
selected: showPendingNewThreadSelection,
|
|
385
|
-
onClick: onClearSelection,
|
|
386
|
-
icon: showPendingNewThreadSelection ? /* @__PURE__ */ jsx(Check, { className: "h-4 w-4 text-accent-foreground" }) : /* @__PURE__ */ jsx(MessageSquarePlus, { className: "h-4 w-4 text-muted-foreground" })
|
|
387
|
-
}
|
|
388
|
-
),
|
|
389
|
-
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,
|
|
390
|
-
entries.map((entry) => /* @__PURE__ */ jsx(
|
|
391
|
-
ThreadListEntryRow,
|
|
392
|
-
{
|
|
393
|
-
room,
|
|
394
|
-
entry,
|
|
395
|
-
agentName,
|
|
396
|
-
selected: entry.path === selectedThreadPath,
|
|
397
|
-
onSelect: onSelectThread,
|
|
398
|
-
onRename: onRenameThread
|
|
399
|
-
},
|
|
400
|
-
entry.path
|
|
401
|
-
))
|
|
402
|
-
] }) });
|
|
403
|
-
}
|
|
404
|
-
function RenameThreadDialog({
|
|
405
|
-
dialogState,
|
|
406
|
-
onNameChange,
|
|
407
|
-
onOpenChange,
|
|
408
|
-
onSubmit
|
|
409
|
-
}) {
|
|
410
|
-
const inputId = useId();
|
|
411
|
-
const inputRef = useRef(null);
|
|
412
|
-
const trimmedName = dialogState?.value.trim() ?? "";
|
|
413
|
-
const saveDisabled = dialogState === null || trimmedName === "" || trimmedName === dialogState.entry.name;
|
|
414
|
-
return /* @__PURE__ */ jsx(Dialog, { open: dialogState !== null, onOpenChange, children: /* @__PURE__ */ jsx(
|
|
415
|
-
DialogContent,
|
|
416
|
-
{
|
|
417
|
-
showCloseButton: false,
|
|
418
|
-
className: "sm:max-w-[425px]",
|
|
419
|
-
onOpenAutoFocus: (event) => {
|
|
420
|
-
event.preventDefault();
|
|
421
|
-
inputRef.current?.focus();
|
|
422
|
-
inputRef.current?.select();
|
|
423
|
-
},
|
|
424
|
-
children: /* @__PURE__ */ jsxs("form", { className: "space-y-4", onSubmit, children: [
|
|
425
|
-
/* @__PURE__ */ jsxs(DialogHeader, { children: [
|
|
426
|
-
/* @__PURE__ */ jsx(DialogTitle, { children: "Rename thread" }),
|
|
427
|
-
/* @__PURE__ */ jsx(DialogDescription, { children: "Use a short and descriptive name" })
|
|
428
|
-
] }),
|
|
429
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
430
|
-
/* @__PURE__ */ jsx(Label, { htmlFor: inputId, children: "Name" }),
|
|
431
|
-
/* @__PURE__ */ jsx(
|
|
432
|
-
Input,
|
|
433
|
-
{
|
|
434
|
-
ref: inputRef,
|
|
435
|
-
id: inputId,
|
|
436
|
-
value: dialogState?.value ?? "",
|
|
437
|
-
autoComplete: "off",
|
|
438
|
-
onChange: onNameChange
|
|
439
|
-
}
|
|
440
|
-
)
|
|
441
|
-
] }),
|
|
442
|
-
/* @__PURE__ */ jsxs(DialogFooter, { children: [
|
|
443
|
-
/* @__PURE__ */ jsx(DialogClose, { asChild: true, children: /* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", children: "Cancel" }) }),
|
|
444
|
-
/* @__PURE__ */ jsx(Button, { type: "submit", disabled: saveDisabled, children: "Save" })
|
|
445
|
-
] })
|
|
446
|
-
] })
|
|
447
|
-
}
|
|
448
|
-
) });
|
|
449
|
-
}
|
|
450
38
|
function MultiThreadUnavailable() {
|
|
451
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: [
|
|
452
40
|
/* @__PURE__ */ jsx(AlertTriangle, { className: "mt-0.5 h-5 w-5 shrink-0" }),
|
|
@@ -462,11 +50,9 @@ function ChatBotView({
|
|
|
462
50
|
disposeChatClient = false,
|
|
463
51
|
path,
|
|
464
52
|
documentPath,
|
|
465
|
-
participants,
|
|
466
53
|
agentName,
|
|
467
54
|
threadDisplayMode = ChatThreadDisplayMode.SingleThread,
|
|
468
55
|
threadDir,
|
|
469
|
-
threadListPath,
|
|
470
56
|
toolkit,
|
|
471
57
|
tool,
|
|
472
58
|
centerComposer = false,
|
|
@@ -475,24 +61,22 @@ function ChatBotView({
|
|
|
475
61
|
startNewThreadTitle = "Start a new thread",
|
|
476
62
|
startNewThreadDescription = "Connect with this agent and your team.",
|
|
477
63
|
selectedThreadPath,
|
|
64
|
+
selectedThreadDisplayName,
|
|
478
65
|
onSelectedThreadPathChanged,
|
|
479
66
|
onSelectedThreadResolved,
|
|
480
67
|
onThreadResolved,
|
|
481
68
|
newThreadResetVersion = 0,
|
|
482
69
|
showThreadList = true,
|
|
483
70
|
threadListWidth = 280,
|
|
484
|
-
threadListCollapsedHeight = 220
|
|
71
|
+
threadListCollapsedHeight = 220,
|
|
72
|
+
clientToolkits,
|
|
73
|
+
toolChoice,
|
|
74
|
+
collapseMessages = true
|
|
485
75
|
}) {
|
|
486
76
|
const isWideLayout = useIsWideLayout(multiThreadLayoutBreakpointPx);
|
|
487
|
-
const resolvedDocumentPath = useMemo(
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
);
|
|
491
|
-
const resolvedSingleThreadPath = useMemo(
|
|
492
|
-
() => resolvedDocumentPath ?? chatDocumentPath(agentName, { threadDir }),
|
|
493
|
-
[agentName, resolvedDocumentPath, threadDir]
|
|
494
|
-
);
|
|
495
|
-
const needsChatClient = chatClient != null || threadDisplayMode === ChatThreadDisplayMode.MultiThreadComposer || isDatasetBackedThreadPath(resolvedSingleThreadPath);
|
|
77
|
+
const resolvedDocumentPath = useMemo(() => normalizePath(documentPath ?? path), [documentPath, path]);
|
|
78
|
+
const resolvedSingleThreadPath = useMemo(() => resolvedDocumentPath ?? chatDocumentPath(agentName, { threadDir }), [agentName, resolvedDocumentPath, threadDir]);
|
|
79
|
+
const needsChatClient = chatClient != null || threadDisplayMode === ChatThreadDisplayMode.MultiThreadComposer;
|
|
496
80
|
const ownsChatClient = chatClient == null && needsChatClient;
|
|
497
81
|
const activeChatClient = useMemo(
|
|
498
82
|
() => needsChatClient ? chatClient ?? new MessagingChatClient({ room, agentName }) : null,
|
|
@@ -503,17 +87,7 @@ function ChatBotView({
|
|
|
503
87
|
const [internalSelectedThreadPath, setInternalSelectedThreadPath] = useState(() => explicitSelectedThreadPath ?? legacySelectedThreadPath ?? null);
|
|
504
88
|
const previousLegacySelectedThreadPathRef = useRef(legacySelectedThreadPath);
|
|
505
89
|
const previousNewThreadResetVersionRef = useRef(newThreadResetVersion);
|
|
506
|
-
const [renameThreadDialog, setRenameThreadDialog] = useState(null);
|
|
507
90
|
const activeSelectedThreadPath = explicitSelectedThreadPath ?? internalSelectedThreadPath;
|
|
508
|
-
const resolvedThreadListDocumentPath = useMemo(
|
|
509
|
-
() => resolvedThreadListPath(threadListPath, { threadDir, agentName }),
|
|
510
|
-
[agentName, threadDir, threadListPath]
|
|
511
|
-
);
|
|
512
|
-
const threadList = useThreadListDocument({
|
|
513
|
-
room,
|
|
514
|
-
chatClient: activeChatClient,
|
|
515
|
-
path: threadDisplayMode === ChatThreadDisplayMode.MultiThreadComposer && showThreadList && resolvedThreadListDocumentPath !== null ? resolvedThreadListDocumentPath : null
|
|
516
|
-
});
|
|
517
91
|
useEffect(() => {
|
|
518
92
|
return () => {
|
|
519
93
|
if (activeChatClient !== null && (ownsChatClient || disposeChatClient)) {
|
|
@@ -553,9 +127,6 @@ function ChatBotView({
|
|
|
553
127
|
handleSelectedThreadPathChanged(normalizedNextPath);
|
|
554
128
|
emitResolvedThread(normalizedNextPath, displayName);
|
|
555
129
|
}, [emitResolvedThread, handleSelectedThreadPathChanged]);
|
|
556
|
-
const closeRenameThreadDialog = useCallback(() => {
|
|
557
|
-
setRenameThreadDialog(null);
|
|
558
|
-
}, []);
|
|
559
130
|
useEffect(() => {
|
|
560
131
|
if (threadDisplayMode !== ChatThreadDisplayMode.MultiThreadComposer) {
|
|
561
132
|
previousNewThreadResetVersionRef.current = newThreadResetVersion;
|
|
@@ -566,69 +137,20 @@ function ChatBotView({
|
|
|
566
137
|
}
|
|
567
138
|
previousNewThreadResetVersionRef.current = newThreadResetVersion;
|
|
568
139
|
}, [activeSelectedThreadPath, newThreadResetVersion, setSelectedThread, threadDisplayMode]);
|
|
569
|
-
const handleRenameThread = useCallback((entry) => {
|
|
570
|
-
setRenameThreadDialog({
|
|
571
|
-
entry,
|
|
572
|
-
value: entry.name
|
|
573
|
-
});
|
|
574
|
-
}, []);
|
|
575
|
-
const handleRenameThreadNameChanged = useCallback((event) => {
|
|
576
|
-
const nextValue = event.target.value;
|
|
577
|
-
setRenameThreadDialog((currentDialogState) => {
|
|
578
|
-
if (currentDialogState === null) {
|
|
579
|
-
return currentDialogState;
|
|
580
|
-
}
|
|
581
|
-
return {
|
|
582
|
-
...currentDialogState,
|
|
583
|
-
value: nextValue
|
|
584
|
-
};
|
|
585
|
-
});
|
|
586
|
-
}, []);
|
|
587
|
-
const handleRenameThreadDialogOpenChange = useCallback((open) => {
|
|
588
|
-
if (!open) {
|
|
589
|
-
closeRenameThreadDialog();
|
|
590
|
-
}
|
|
591
|
-
}, [closeRenameThreadDialog]);
|
|
592
|
-
const handleRenameThreadSubmit = useCallback((event) => {
|
|
593
|
-
event.preventDefault();
|
|
594
|
-
if (renameThreadDialog === null) {
|
|
595
|
-
return;
|
|
596
|
-
}
|
|
597
|
-
const trimmedName = renameThreadDialog.value.trim();
|
|
598
|
-
if (trimmedName === "" || trimmedName === renameThreadDialog.entry.name) {
|
|
599
|
-
return;
|
|
600
|
-
}
|
|
601
|
-
void threadList.renameThread(renameThreadDialog.entry, trimmedName).then(() => {
|
|
602
|
-
if (renameThreadDialog.entry.path === activeSelectedThreadPath) {
|
|
603
|
-
emitResolvedThread(renameThreadDialog.entry.path, trimmedName);
|
|
604
|
-
}
|
|
605
|
-
closeRenameThreadDialog();
|
|
606
|
-
}).catch((renameError) => {
|
|
607
|
-
setTimeout(() => {
|
|
608
|
-
throw renameError;
|
|
609
|
-
}, 0);
|
|
610
|
-
});
|
|
611
|
-
}, [activeSelectedThreadPath, closeRenameThreadDialog, emitResolvedThread, renameThreadDialog, threadList]);
|
|
612
140
|
if (threadDisplayMode !== ChatThreadDisplayMode.MultiThreadComposer) {
|
|
613
|
-
return
|
|
614
|
-
|
|
141
|
+
return /* @__PURE__ */ jsx(
|
|
142
|
+
AgentThread,
|
|
615
143
|
{
|
|
616
144
|
room,
|
|
617
145
|
path: resolvedSingleThreadPath,
|
|
618
146
|
chatClient: activeChatClient ?? void 0,
|
|
147
|
+
disposeChatClient: false,
|
|
619
148
|
agentName,
|
|
620
149
|
emptyStateTitle,
|
|
621
|
-
emptyStateDescription
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
{
|
|
626
|
-
room,
|
|
627
|
-
path: resolvedSingleThreadPath,
|
|
628
|
-
participants,
|
|
629
|
-
agentName,
|
|
630
|
-
emptyStateTitle,
|
|
631
|
-
emptyStateDescription
|
|
150
|
+
emptyStateDescription,
|
|
151
|
+
clientToolkits,
|
|
152
|
+
toolChoice,
|
|
153
|
+
collapseMessages
|
|
632
154
|
}
|
|
633
155
|
);
|
|
634
156
|
}
|
|
@@ -649,84 +171,47 @@ function ChatBotView({
|
|
|
649
171
|
onSelectedThreadResolved: emitResolvedThread,
|
|
650
172
|
newThreadResetVersion,
|
|
651
173
|
centerComposer,
|
|
652
|
-
|
|
653
|
-
|
|
174
|
+
clientToolkits,
|
|
175
|
+
toolChoice,
|
|
176
|
+
builder: (threadPath) => /* @__PURE__ */ jsx(
|
|
177
|
+
AgentThread,
|
|
654
178
|
{
|
|
655
179
|
room,
|
|
656
180
|
path: threadPath,
|
|
657
181
|
chatClient: activeChatClient ?? void 0,
|
|
182
|
+
disposeChatClient: false,
|
|
658
183
|
agentName,
|
|
659
184
|
emptyStateTitle: startNewThreadTitle,
|
|
660
|
-
emptyStateDescription: startNewThreadDescription
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
{
|
|
665
|
-
room,
|
|
666
|
-
path: threadPath,
|
|
667
|
-
participants,
|
|
668
|
-
agentName,
|
|
669
|
-
emptyStateTitle: startNewThreadTitle,
|
|
670
|
-
emptyStateDescription: startNewThreadDescription
|
|
185
|
+
emptyStateDescription: startNewThreadDescription,
|
|
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
|
};
|