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