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