@assistant-ui/react 0.15.10 → 0.15.11

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.
@@ -2,7 +2,7 @@ import { SingleThreadList } from "./SingleThreadList.js";
2
2
  import { Derived, attachTransformScopes, useClientLookup, useClientResource } from "@assistant-ui/store";
3
3
  import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
4
4
  import { DataRenderers, Tools } from "@assistant-ui/core/react";
5
- import { useEffect, useEffectEvent, useRef, useState } from "@assistant-ui/tap/react-shim";
5
+ import { useEffect, useRef, useState } from "@assistant-ui/tap/react-shim";
6
6
  import { ToolResponse } from "assistant-stream";
7
7
  import { ModelContext, Suggestions } from "@assistant-ui/core/store";
8
8
  import { resource, withKey } from "@assistant-ui/tap";
@@ -16,11 +16,10 @@ const derivePartStatus = (message, partIndex, part) => {
16
16
  return toMessagePartStatus(message, partIndex, part);
17
17
  };
18
18
  const useMessageClient = (t0) => {
19
- const $ = c(73);
19
+ const $ = c(71);
20
20
  const { message, index, parentId, onEdit, onReload, queue, branches, onRespondToToolApproval, onAddToolResult, onResumeToolCall, attachmentAdapter, submittedFeedback, onSubmitFeedback, speech, onSpeak, onStopSpeaking } = t0;
21
21
  const [isCopied, setIsCopied] = useState(false);
22
22
  const [isHovering, setIsHovering] = useState(false);
23
- const [isEditing, setIsEditing] = useState(false);
24
23
  let t1;
25
24
  if ($[0] !== message || $[1] !== onAddToolResult || $[2] !== onRespondToToolApproval || $[3] !== onResumeToolCall) {
26
25
  t1 = message.content.map((part, idx) => withKey(idx, PartResource({
@@ -55,100 +54,87 @@ const useMessageClient = (t0) => {
55
54
  if ($[9] !== onEdit) {
56
55
  t4 = () => {
57
56
  if (!onEdit) throw new Error("Runtime does not support editing.");
58
- setIsEditing(true);
59
57
  };
60
58
  $[9] = onEdit;
61
59
  $[10] = t4;
62
60
  } else t4 = $[10];
63
61
  const handleBeginEdit = t4;
64
62
  let t5;
65
- if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
66
- t5 = () => {
67
- setIsEditing(false);
68
- };
69
- $[11] = t5;
70
- } else t5 = $[11];
71
- const handleCancelEdit = t5;
72
- let t6;
73
- if ($[12] !== message.id || $[13] !== onEdit || $[14] !== parentId) {
74
- t6 = (msg) => {
63
+ if ($[11] !== message.id || $[12] !== onEdit || $[13] !== parentId) {
64
+ t5 = (msg) => {
75
65
  if (!onEdit) throw new Error("Runtime does not support editing.");
76
66
  onEdit({
77
67
  ...msg,
78
68
  parentId,
79
69
  sourceId: message.id
80
70
  });
81
- setIsEditing(false);
82
71
  };
83
- $[12] = message.id;
84
- $[13] = onEdit;
85
- $[14] = parentId;
86
- $[15] = t6;
87
- } else t6 = $[15];
88
- const handleSendEdit = t6;
89
- let t7;
90
- if ($[16] !== attachmentAdapter || $[17] !== handleBeginEdit || $[18] !== handleSendEdit || $[19] !== isEditing || $[20] !== message || $[21] !== queue) {
91
- t7 = ComposerClientResource({
72
+ $[11] = message.id;
73
+ $[12] = onEdit;
74
+ $[13] = parentId;
75
+ $[14] = t5;
76
+ } else t5 = $[14];
77
+ const handleSendEdit = t5;
78
+ let t6;
79
+ if ($[15] !== attachmentAdapter || $[16] !== handleBeginEdit || $[17] !== handleSendEdit || $[18] !== message || $[19] !== queue) {
80
+ t6 = ComposerClientResource({
92
81
  type: "edit",
93
- isEditing,
94
82
  canCancel: true,
95
- onCancel: handleCancelEdit,
96
83
  onBeginEdit: handleBeginEdit,
97
84
  onSend: handleSendEdit,
98
85
  message,
99
86
  queue,
100
87
  attachmentAdapter
101
88
  });
102
- $[16] = attachmentAdapter;
103
- $[17] = handleBeginEdit;
104
- $[18] = handleSendEdit;
105
- $[19] = isEditing;
106
- $[20] = message;
107
- $[21] = queue;
108
- $[22] = t7;
109
- } else t7 = $[22];
110
- const composerClient = useClientResource(t7);
89
+ $[15] = attachmentAdapter;
90
+ $[16] = handleBeginEdit;
91
+ $[17] = handleSendEdit;
92
+ $[18] = message;
93
+ $[19] = queue;
94
+ $[20] = t6;
95
+ } else t6 = $[20];
96
+ const composerClient = useClientResource(t6);
111
97
  let branchIds;
112
- let t8;
113
- if ($[23] !== branches || $[24] !== message.id) {
98
+ let t7;
99
+ if ($[21] !== branches || $[22] !== message.id) {
114
100
  branchIds = branches?.getBranches(message.id) ?? EMPTY_BRANCH_IDS;
115
- t8 = branchIds.indexOf(message.id);
116
- $[23] = branches;
117
- $[24] = message.id;
118
- $[25] = branchIds;
119
- $[26] = t8;
101
+ t7 = branchIds.indexOf(message.id);
102
+ $[21] = branches;
103
+ $[22] = message.id;
104
+ $[23] = branchIds;
105
+ $[24] = t7;
120
106
  } else {
121
- branchIds = $[25];
122
- t8 = $[26];
107
+ branchIds = $[23];
108
+ t7 = $[24];
123
109
  }
124
- const branchIndex = t8;
110
+ const branchIndex = t7;
125
111
  const branchNumber = branchIndex === -1 ? 1 : branchIndex + 1;
126
112
  const branchCount = branchIndex === -1 ? 1 : branchIds.length;
127
- let t9;
128
- if ($[27] !== message || $[28] !== submittedFeedback) {
129
- t9 = submittedFeedback && message.role === "assistant" ? {
113
+ let t8;
114
+ if ($[25] !== message || $[26] !== submittedFeedback) {
115
+ t8 = submittedFeedback && message.role === "assistant" ? {
130
116
  ...message,
131
117
  metadata: {
132
118
  ...message.metadata,
133
119
  submittedFeedback: { type: submittedFeedback }
134
120
  }
135
121
  } : message;
136
- $[27] = message;
137
- $[28] = submittedFeedback;
122
+ $[25] = message;
123
+ $[26] = submittedFeedback;
124
+ $[27] = t8;
125
+ } else t8 = $[27];
126
+ const messageWithFeedback = t8;
127
+ let t9;
128
+ if ($[28] !== message.attachments) {
129
+ t9 = message.attachments ?? [];
130
+ $[28] = message.attachments;
138
131
  $[29] = t9;
139
132
  } else t9 = $[29];
140
- const messageWithFeedback = t9;
141
133
  let t10;
142
- if ($[30] !== message.attachments) {
143
- t10 = message.attachments ?? [];
144
- $[30] = message.attachments;
145
- $[31] = t10;
146
- } else t10 = $[31];
147
- let t11;
148
- if ($[32] !== branchCount || $[33] !== branchNumber || $[34] !== composerClient.state || $[35] !== index || $[36] !== isCopied || $[37] !== isHovering || $[38] !== messageWithFeedback || $[39] !== parentId || $[40] !== partClients.state || $[41] !== speech || $[42] !== t10) {
149
- t11 = {
134
+ if ($[30] !== branchCount || $[31] !== branchNumber || $[32] !== composerClient.state || $[33] !== index || $[34] !== isCopied || $[35] !== isHovering || $[36] !== messageWithFeedback || $[37] !== parentId || $[38] !== partClients.state || $[39] !== speech || $[40] !== t9) {
135
+ t10 = {
150
136
  ...messageWithFeedback,
151
- attachments: t10,
137
+ attachments: t9,
152
138
  parentId,
153
139
  isLast: false,
154
140
  branchNumber,
@@ -160,110 +146,110 @@ const useMessageClient = (t0) => {
160
146
  index,
161
147
  composer: composerClient.state
162
148
  };
163
- $[32] = branchCount;
164
- $[33] = branchNumber;
165
- $[34] = composerClient.state;
166
- $[35] = index;
167
- $[36] = isCopied;
168
- $[37] = isHovering;
169
- $[38] = messageWithFeedback;
170
- $[39] = parentId;
171
- $[40] = partClients.state;
172
- $[41] = speech;
173
- $[42] = t10;
149
+ $[30] = branchCount;
150
+ $[31] = branchNumber;
151
+ $[32] = composerClient.state;
152
+ $[33] = index;
153
+ $[34] = isCopied;
154
+ $[35] = isHovering;
155
+ $[36] = messageWithFeedback;
156
+ $[37] = parentId;
157
+ $[38] = partClients.state;
158
+ $[39] = speech;
159
+ $[40] = t9;
160
+ $[41] = t10;
161
+ } else t10 = $[41];
162
+ const state = t10;
163
+ let t11;
164
+ if ($[42] !== state) {
165
+ t11 = () => state;
166
+ $[42] = state;
174
167
  $[43] = t11;
175
168
  } else t11 = $[43];
176
- const state = t11;
177
169
  let t12;
178
- if ($[44] !== state) {
179
- t12 = () => state;
180
- $[44] = state;
170
+ if ($[44] !== composerClient.methods) {
171
+ t12 = () => composerClient.methods;
172
+ $[44] = composerClient.methods;
181
173
  $[45] = t12;
182
174
  } else t12 = $[45];
183
175
  let t13;
184
- if ($[46] !== composerClient.methods) {
185
- t13 = () => composerClient.methods;
186
- $[46] = composerClient.methods;
176
+ if ($[46] !== onReload) {
177
+ t13 = () => {
178
+ onReload?.();
179
+ };
180
+ $[46] = onReload;
187
181
  $[47] = t13;
188
182
  } else t13 = $[47];
189
183
  let t14;
190
- if ($[48] !== onReload) {
191
- t14 = () => {
192
- onReload?.();
193
- };
194
- $[48] = onReload;
195
- $[49] = t14;
196
- } else t14 = $[49];
197
- let t15;
198
- if ($[50] !== branchIds || $[51] !== branchIndex || $[52] !== branches || $[53] !== message.id) {
199
- t15 = (t16) => {
200
- const { position, branchId } = t16;
184
+ if ($[48] !== branchIds || $[49] !== branchIndex || $[50] !== branches || $[51] !== message.id) {
185
+ t14 = (t15) => {
186
+ const { position, branchId } = t15;
201
187
  if (!branches) return;
202
188
  const target = branchId ?? (branchIndex === -1 ? void 0 : position === "previous" ? branchIds[branchIndex - 1] : position === "next" ? branchIds[branchIndex + 1] : void 0);
203
189
  if (target !== void 0 && target !== message.id) branches.switchToBranch(target);
204
190
  };
205
- $[50] = branchIds;
206
- $[51] = branchIndex;
207
- $[52] = branches;
208
- $[53] = message.id;
191
+ $[48] = branchIds;
192
+ $[49] = branchIndex;
193
+ $[50] = branches;
194
+ $[51] = message.id;
195
+ $[52] = t14;
196
+ } else t14 = $[52];
197
+ let t15;
198
+ if ($[53] !== message) {
199
+ t15 = () => getThreadMessageText(message);
200
+ $[53] = message;
209
201
  $[54] = t15;
210
202
  } else t15 = $[54];
211
203
  let t16;
212
- if ($[55] !== message) {
213
- t16 = () => getThreadMessageText(message);
214
- $[55] = message;
215
- $[56] = t16;
216
- } else t16 = $[56];
217
- let t17;
218
- if ($[57] !== partClients || $[58] !== state) {
219
- t17 = (selector) => {
204
+ if ($[55] !== partClients || $[56] !== state) {
205
+ t16 = (selector) => {
220
206
  if ("index" in selector) return partClients.get(selector);
221
207
  const partIndex = state.parts.findIndex((p) => p.type === "tool-call" && p.toolCallId === selector.toolCallId);
222
208
  return partClients.get({ index: partIndex });
223
209
  };
224
- $[57] = partClients;
225
- $[58] = state;
226
- $[59] = t17;
227
- } else t17 = $[59];
228
- let t18;
229
- if ($[60] !== attachmentClients) {
230
- t18 = (selector_0) => {
210
+ $[55] = partClients;
211
+ $[56] = state;
212
+ $[57] = t16;
213
+ } else t16 = $[57];
214
+ let t17;
215
+ if ($[58] !== attachmentClients) {
216
+ t17 = (selector_0) => {
231
217
  if ("id" in selector_0) return attachmentClients.get({ key: selector_0.id });
232
218
  return attachmentClients.get(selector_0);
233
219
  };
234
- $[60] = attachmentClients;
235
- $[61] = t18;
236
- } else t18 = $[61];
237
- let t19;
238
- if ($[62] !== onSpeak || $[63] !== onStopSpeaking || $[64] !== onSubmitFeedback || $[65] !== t12 || $[66] !== t13 || $[67] !== t14 || $[68] !== t15 || $[69] !== t16 || $[70] !== t17 || $[71] !== t18) {
239
- t19 = {
240
- getState: t12,
241
- composer: t13,
220
+ $[58] = attachmentClients;
221
+ $[59] = t17;
222
+ } else t17 = $[59];
223
+ let t18;
224
+ if ($[60] !== onSpeak || $[61] !== onStopSpeaking || $[62] !== onSubmitFeedback || $[63] !== t11 || $[64] !== t12 || $[65] !== t13 || $[66] !== t14 || $[67] !== t15 || $[68] !== t16 || $[69] !== t17) {
225
+ t18 = {
226
+ getState: t11,
227
+ composer: t12,
242
228
  delete: _temp3,
243
- reload: t14,
229
+ reload: t13,
244
230
  speak: onSpeak,
245
231
  stopSpeaking: onStopSpeaking,
246
232
  submitFeedback: onSubmitFeedback,
247
- switchToBranch: t15,
248
- getCopyText: t16,
249
- part: t17,
250
- attachment: t18,
233
+ switchToBranch: t14,
234
+ getCopyText: t15,
235
+ part: t16,
236
+ attachment: t17,
251
237
  setIsCopied,
252
238
  setIsHovering
253
239
  };
254
- $[62] = onSpeak;
255
- $[63] = onStopSpeaking;
256
- $[64] = onSubmitFeedback;
257
- $[65] = t12;
258
- $[66] = t13;
259
- $[67] = t14;
260
- $[68] = t15;
261
- $[69] = t16;
262
- $[70] = t17;
263
- $[71] = t18;
264
- $[72] = t19;
265
- } else t19 = $[72];
266
- return t19;
240
+ $[60] = onSpeak;
241
+ $[61] = onStopSpeaking;
242
+ $[62] = onSubmitFeedback;
243
+ $[63] = t11;
244
+ $[64] = t12;
245
+ $[65] = t13;
246
+ $[66] = t14;
247
+ $[67] = t15;
248
+ $[68] = t16;
249
+ $[69] = t17;
250
+ $[70] = t18;
251
+ } else t18 = $[70];
252
+ return t18;
267
253
  };
268
254
  const MessageClient = resource(useMessageClient);
269
255
  const usePartResource = (t0) => {
@@ -402,9 +388,10 @@ const useLiveState = (initial) => {
402
388
  return t1;
403
389
  };
404
390
  const useComposerClientResource = (t0) => {
405
- const $ = c(100);
406
- const { type, isEditing, canCancel, isSendDisabled: t1, onCancel, onBeginEdit, onSend, message, queue, attachmentAdapter } = t0;
391
+ const $ = c(104);
392
+ const { type, canCancel, isSendDisabled: t1, onCancel, onBeginEdit, onSend, message, queue, attachmentAdapter } = t0;
407
393
  const isSendDisabled = t1 === void 0 ? false : t1;
394
+ const [isEditing, setIsEditing, isEditingRef] = useLiveState(type === "thread");
408
395
  const [text, setText, textRef] = useLiveState("");
409
396
  const [role, setRole, roleRef] = useLiveState("user");
410
397
  let t2;
@@ -423,12 +410,11 @@ const useComposerClientResource = (t0) => {
423
410
  let t4;
424
411
  if ($[2] !== message || $[3] !== setAttachments || $[4] !== setRole || $[5] !== setText) {
425
412
  t4 = () => {
426
- if (message) {
427
- const messageText = message.content.filter(_temp4).map(_temp5).join("\n\n");
428
- setText(messageText);
429
- setRole(message.role);
430
- setAttachments(message.attachments ?? []);
431
- }
413
+ if (!message) return;
414
+ const messageText = message.content.filter(_temp4).map(_temp5).join("\n\n");
415
+ setText(messageText);
416
+ setRole(message.role);
417
+ setAttachments(message.attachments ?? []);
432
418
  };
433
419
  $[2] = message;
434
420
  $[3] = setAttachments;
@@ -436,58 +422,42 @@ const useComposerClientResource = (t0) => {
436
422
  $[5] = setText;
437
423
  $[6] = t4;
438
424
  } else t4 = $[6];
439
- const updateFromMessage = useEffectEvent(t4);
425
+ const updateFromMessage = t4;
440
426
  let t5;
441
- if ($[7] !== isEditing || $[8] !== updateFromMessage) {
442
- t5 = () => {
443
- if (isEditing) updateFromMessage();
444
- };
445
- $[7] = isEditing;
446
- $[8] = updateFromMessage;
447
- $[9] = t5;
448
- } else t5 = $[9];
449
- let t6;
450
- if ($[10] !== isEditing) {
451
- t6 = [isEditing];
452
- $[10] = isEditing;
453
- $[11] = t6;
454
- } else t6 = $[11];
455
- useEffect(t5, t6);
456
- let t7;
457
- if ($[12] !== attachmentAdapter || $[13] !== attachments || $[14] !== setAttachments) {
458
- let t8;
459
- if ($[16] !== attachmentAdapter || $[17] !== setAttachments) {
460
- t8 = (attachment) => withKey(attachment.id, AttachmentResource({
427
+ if ($[7] !== attachmentAdapter || $[8] !== attachments || $[9] !== setAttachments) {
428
+ let t6;
429
+ if ($[11] !== attachmentAdapter || $[12] !== setAttachments) {
430
+ t6 = (attachment) => withKey(attachment.id, AttachmentResource({
461
431
  attachment,
462
432
  onRemove: async () => {
463
433
  await attachmentAdapter?.remove(attachment);
464
434
  setAttachments((prev) => prev.filter((a) => a.id !== attachment.id));
465
435
  }
466
436
  }));
467
- $[16] = attachmentAdapter;
468
- $[17] = setAttachments;
469
- $[18] = t8;
470
- } else t8 = $[18];
471
- t7 = attachments.map(t8);
472
- $[12] = attachmentAdapter;
473
- $[13] = attachments;
474
- $[14] = setAttachments;
475
- $[15] = t7;
476
- } else t7 = $[15];
477
- const attachmentClients = useClientLookup(t7);
478
- let t8;
479
- if ($[19] !== attachmentAdapter) {
480
- t8 = async (removed) => {
437
+ $[11] = attachmentAdapter;
438
+ $[12] = setAttachments;
439
+ $[13] = t6;
440
+ } else t6 = $[13];
441
+ t5 = attachments.map(t6);
442
+ $[7] = attachmentAdapter;
443
+ $[8] = attachments;
444
+ $[9] = setAttachments;
445
+ $[10] = t5;
446
+ } else t5 = $[10];
447
+ const attachmentClients = useClientLookup(t5);
448
+ let t6;
449
+ if ($[14] !== attachmentAdapter) {
450
+ t6 = async (removed) => {
481
451
  if (!attachmentAdapter) return;
482
452
  await Promise.all(removed.filter(_temp6).map((a_1) => attachmentAdapter.remove(a_1)));
483
453
  };
484
- $[19] = attachmentAdapter;
485
- $[20] = t8;
486
- } else t8 = $[20];
487
- const removePendingAttachments = t8;
488
- let t9;
489
- if ($[21] !== setAttachments) {
490
- t9 = (attachment_0) => {
454
+ $[14] = attachmentAdapter;
455
+ $[15] = t6;
456
+ } else t6 = $[15];
457
+ const removePendingAttachments = t6;
458
+ let t7;
459
+ if ($[16] !== setAttachments) {
460
+ t7 = (attachment_0) => {
491
461
  setAttachments((prev_0) => {
492
462
  const idx = prev_0.findIndex((a_2) => a_2.id === attachment_0.id);
493
463
  if (idx === -1) return [...prev_0, attachment_0];
@@ -496,41 +466,41 @@ const useComposerClientResource = (t0) => {
496
466
  return next;
497
467
  });
498
468
  };
499
- $[21] = setAttachments;
500
- $[22] = t9;
501
- } else t9 = $[22];
502
- const upsertAttachment = t9;
469
+ $[16] = setAttachments;
470
+ $[17] = t7;
471
+ } else t7 = $[17];
472
+ const upsertAttachment = t7;
503
473
  const steerItems = queue?.steerItems ?? EMPTY_QUEUE_ITEMS;
504
474
  const laneItems = queue?.items ?? EMPTY_QUEUE_ITEMS;
505
- let t10;
506
- if ($[23] !== laneItems || $[24] !== steerItems) {
507
- t10 = steerItems.length === 0 ? laneItems : laneItems.length === 0 ? steerItems : [...steerItems, ...laneItems];
508
- $[23] = laneItems;
509
- $[24] = steerItems;
510
- $[25] = t10;
511
- } else t10 = $[25];
512
- const queueItems = t10;
513
- let t11;
514
- if ($[26] !== queue || $[27] !== queueItems) {
515
- let t12;
516
- if ($[29] !== queue) {
517
- t12 = (item) => withKey(item.id, QueueItemClient({
475
+ let t8;
476
+ if ($[18] !== laneItems || $[19] !== steerItems) {
477
+ t8 = steerItems.length === 0 ? laneItems : laneItems.length === 0 ? steerItems : [...steerItems, ...laneItems];
478
+ $[18] = laneItems;
479
+ $[19] = steerItems;
480
+ $[20] = t8;
481
+ } else t8 = $[20];
482
+ const queueItems = t8;
483
+ let t9;
484
+ if ($[21] !== queue || $[22] !== queueItems) {
485
+ let t10;
486
+ if ($[24] !== queue) {
487
+ t10 = (item) => withKey(item.id, QueueItemClient({
518
488
  item,
519
489
  onMove: (placement) => queue?.move(item.id, placement),
520
490
  onRemove: () => queue?.remove(item.id)
521
491
  }));
522
- $[29] = queue;
523
- $[30] = t12;
524
- } else t12 = $[30];
525
- t11 = queueItems.map(t12);
526
- $[26] = queue;
527
- $[27] = queueItems;
528
- $[28] = t11;
529
- } else t11 = $[28];
530
- const queueItemClients = useClientLookup(t11);
531
- let t12;
532
- if ($[31] !== attachmentAdapter?.accept || $[32] !== attachmentClients.state || $[33] !== attachments.length || $[34] !== canCancel || $[35] !== isEditing || $[36] !== isSendDisabled || $[37] !== queueItems || $[38] !== quote || $[39] !== role || $[40] !== runConfig || $[41] !== text || $[42] !== type) {
533
- t12 = () => {
492
+ $[24] = queue;
493
+ $[25] = t10;
494
+ } else t10 = $[25];
495
+ t9 = queueItems.map(t10);
496
+ $[21] = queue;
497
+ $[22] = queueItems;
498
+ $[23] = t9;
499
+ } else t9 = $[23];
500
+ const queueItemClients = useClientLookup(t9);
501
+ let t10;
502
+ if ($[26] !== attachmentAdapter?.accept || $[27] !== attachmentClients.state || $[28] !== attachments.length || $[29] !== canCancel || $[30] !== isEditing || $[31] !== isSendDisabled || $[32] !== queueItems || $[33] !== quote || $[34] !== role || $[35] !== runConfig || $[36] !== text || $[37] !== type) {
503
+ t10 = () => {
534
504
  const isEmpty = !text.trim() && !attachments.length;
535
505
  return {
536
506
  text,
@@ -548,37 +518,37 @@ const useComposerClientResource = (t0) => {
548
518
  queue: queueItems
549
519
  };
550
520
  };
551
- $[31] = attachmentAdapter?.accept;
552
- $[32] = attachmentClients.state;
553
- $[33] = attachments.length;
554
- $[34] = canCancel;
555
- $[35] = isEditing;
556
- $[36] = isSendDisabled;
557
- $[37] = queueItems;
558
- $[38] = quote;
559
- $[39] = role;
560
- $[40] = runConfig;
561
- $[41] = text;
562
- $[42] = type;
563
- $[43] = t12;
564
- } else t12 = $[43];
521
+ $[26] = attachmentAdapter?.accept;
522
+ $[27] = attachmentClients.state;
523
+ $[28] = attachments.length;
524
+ $[29] = canCancel;
525
+ $[30] = isEditing;
526
+ $[31] = isSendDisabled;
527
+ $[32] = queueItems;
528
+ $[33] = quote;
529
+ $[34] = role;
530
+ $[35] = runConfig;
531
+ $[36] = text;
532
+ $[37] = type;
533
+ $[38] = t10;
534
+ } else t10 = $[38];
565
535
  attachmentAdapter?.accept;
536
+ let t11;
537
+ if ($[39] !== t10) {
538
+ t11 = t10();
539
+ $[39] = t10;
540
+ $[40] = t11;
541
+ } else t11 = $[40];
542
+ const state = t11;
543
+ let t12;
544
+ if ($[41] !== state) {
545
+ t12 = () => state;
546
+ $[41] = state;
547
+ $[42] = t12;
548
+ } else t12 = $[42];
566
549
  let t13;
567
- if ($[44] !== t12) {
568
- t13 = t12();
569
- $[44] = t12;
570
- $[45] = t13;
571
- } else t13 = $[45];
572
- const state = t13;
573
- let t14;
574
- if ($[46] !== state) {
575
- t14 = () => state;
576
- $[46] = state;
577
- $[47] = t14;
578
- } else t14 = $[47];
579
- let t15;
580
- if ($[48] !== attachmentAdapter || $[49] !== setAttachments || $[50] !== upsertAttachment) {
581
- t15 = async (fileOrAttachment) => {
550
+ if ($[43] !== attachmentAdapter || $[44] !== setAttachments || $[45] !== upsertAttachment) {
551
+ t13 = async (fileOrAttachment) => {
582
552
  if (attachmentAdapter) {
583
553
  const file = isCreateAttachment(fileOrAttachment) ? {
584
554
  name: fileOrAttachment.name,
@@ -613,35 +583,35 @@ const useComposerClientResource = (t0) => {
613
583
  setAttachments((prev_2) => [...prev_2, newAttachment_0]);
614
584
  }
615
585
  };
616
- $[48] = attachmentAdapter;
617
- $[49] = setAttachments;
618
- $[50] = upsertAttachment;
619
- $[51] = t15;
620
- } else t15 = $[51];
621
- let t16;
622
- if ($[52] !== attachmentsRef || $[53] !== removePendingAttachments || $[54] !== setAttachments) {
623
- t16 = async () => {
586
+ $[43] = attachmentAdapter;
587
+ $[44] = setAttachments;
588
+ $[45] = upsertAttachment;
589
+ $[46] = t13;
590
+ } else t13 = $[46];
591
+ let t14;
592
+ if ($[47] !== attachmentsRef || $[48] !== removePendingAttachments || $[49] !== setAttachments) {
593
+ t14 = async () => {
624
594
  const removed_0 = attachmentsRef.current;
625
595
  setAttachments([]);
626
596
  await removePendingAttachments(removed_0);
627
597
  };
628
- $[52] = attachmentsRef;
629
- $[53] = removePendingAttachments;
630
- $[54] = setAttachments;
631
- $[55] = t16;
632
- } else t16 = $[55];
633
- let t17;
634
- if ($[56] !== attachmentClients) {
635
- t17 = (selector) => {
598
+ $[47] = attachmentsRef;
599
+ $[48] = removePendingAttachments;
600
+ $[49] = setAttachments;
601
+ $[50] = t14;
602
+ } else t14 = $[50];
603
+ let t15;
604
+ if ($[51] !== attachmentClients) {
605
+ t15 = (selector) => {
636
606
  if ("id" in selector) return attachmentClients.get({ key: selector.id });
637
607
  return attachmentClients.get(selector);
638
608
  };
639
- $[56] = attachmentClients;
640
- $[57] = t17;
641
- } else t17 = $[57];
642
- let t18;
643
- if ($[58] !== attachmentsRef || $[59] !== removePendingAttachments || $[60] !== setAttachments || $[61] !== setQuote || $[62] !== setRole || $[63] !== setRunConfig || $[64] !== setText) {
644
- t18 = async () => {
609
+ $[51] = attachmentClients;
610
+ $[52] = t15;
611
+ } else t15 = $[52];
612
+ let t16;
613
+ if ($[53] !== attachmentsRef || $[54] !== removePendingAttachments || $[55] !== setAttachments || $[56] !== setQuote || $[57] !== setRole || $[58] !== setRunConfig || $[59] !== setText) {
614
+ t16 = async () => {
645
615
  const removed_1 = attachmentsRef.current;
646
616
  setText("");
647
617
  setRole("user");
@@ -650,23 +620,24 @@ const useComposerClientResource = (t0) => {
650
620
  setQuote(void 0);
651
621
  await removePendingAttachments(removed_1);
652
622
  };
653
- $[58] = attachmentsRef;
654
- $[59] = removePendingAttachments;
655
- $[60] = setAttachments;
656
- $[61] = setQuote;
657
- $[62] = setRole;
658
- $[63] = setRunConfig;
659
- $[64] = setText;
660
- $[65] = t18;
661
- } else t18 = $[65];
662
- let t19;
663
- if ($[66] !== attachmentAdapter || $[67] !== attachmentsRef || $[68] !== canCancel || $[69] !== isEditing || $[70] !== isSendDisabled || $[71] !== onSend || $[72] !== queue || $[73] !== quoteRef || $[74] !== roleRef || $[75] !== runConfigRef || $[76] !== setAttachments || $[77] !== setQuote || $[78] !== setText || $[79] !== textRef || $[80] !== type) {
664
- t19 = (opts) => {
623
+ $[53] = attachmentsRef;
624
+ $[54] = removePendingAttachments;
625
+ $[55] = setAttachments;
626
+ $[56] = setQuote;
627
+ $[57] = setRole;
628
+ $[58] = setRunConfig;
629
+ $[59] = setText;
630
+ $[60] = t16;
631
+ } else t16 = $[60];
632
+ let t17;
633
+ if ($[61] !== attachmentAdapter || $[62] !== attachmentsRef || $[63] !== canCancel || $[64] !== isEditingRef || $[65] !== isSendDisabled || $[66] !== onSend || $[67] !== queue || $[68] !== quoteRef || $[69] !== roleRef || $[70] !== runConfigRef || $[71] !== setAttachments || $[72] !== setIsEditing || $[73] !== setQuote || $[74] !== setText || $[75] !== textRef || $[76] !== type) {
634
+ t17 = (opts) => {
665
635
  const currentQuote = quoteRef.current;
666
636
  const currentText = textRef.current;
667
637
  const currentAttachments = attachmentsRef.current;
668
638
  const isEmpty_0 = !currentText.trim() && !currentAttachments.length;
669
- if (!isEditing || isEmpty_0 || isSendDisabled) return;
639
+ if (!isEditingRef.current) throw new Error("Composer is not available");
640
+ if (isEmpty_0 || isSendDisabled) return;
670
641
  setText("");
671
642
  setAttachments([]);
672
643
  setQuote(void 0);
@@ -685,9 +656,11 @@ const useComposerClientResource = (t0) => {
685
656
  startRun: opts?.startRun,
686
657
  metadata: { custom: { ...currentQuote ? { quote: currentQuote } : {} } }
687
658
  };
688
- if (queue && type === "thread") if (opts?.steer ?? canCancel) queue.steer(composedMessage);
689
- else queue.enqueue(composedMessage);
690
- else onSend?.(composedMessage);
659
+ if (queue && type === "thread") {
660
+ if (opts?.steer ?? canCancel) queue.steer(composedMessage);
661
+ else queue.enqueue(composedMessage);
662
+ } else onSend?.(composedMessage);
663
+ if (type === "edit") setIsEditing(false);
691
664
  };
692
665
  if (attachmentAdapter && currentAttachments.length > 0) Promise.all(currentAttachments.map((attachment_1) => attachment_1.status.type === "complete" ? attachment_1 : attachmentAdapter.send(attachment_1))).then(dispatch, (error) => {
693
666
  setText((prev_3) => currentText && prev_3 ? currentText + "\n" + prev_3 : currentText || prev_3);
@@ -697,75 +670,95 @@ const useComposerClientResource = (t0) => {
697
670
  });
698
671
  else dispatch(currentAttachments);
699
672
  };
700
- $[66] = attachmentAdapter;
701
- $[67] = attachmentsRef;
702
- $[68] = canCancel;
703
- $[69] = isEditing;
704
- $[70] = isSendDisabled;
705
- $[71] = onSend;
706
- $[72] = queue;
707
- $[73] = quoteRef;
708
- $[74] = roleRef;
709
- $[75] = runConfigRef;
710
- $[76] = setAttachments;
711
- $[77] = setQuote;
712
- $[78] = setText;
713
- $[79] = textRef;
673
+ $[61] = attachmentAdapter;
674
+ $[62] = attachmentsRef;
675
+ $[63] = canCancel;
676
+ $[64] = isEditingRef;
677
+ $[65] = isSendDisabled;
678
+ $[66] = onSend;
679
+ $[67] = queue;
680
+ $[68] = quoteRef;
681
+ $[69] = roleRef;
682
+ $[70] = runConfigRef;
683
+ $[71] = setAttachments;
684
+ $[72] = setIsEditing;
685
+ $[73] = setQuote;
686
+ $[74] = setText;
687
+ $[75] = textRef;
688
+ $[76] = type;
689
+ $[77] = t17;
690
+ } else t17 = $[77];
691
+ let t18;
692
+ if ($[78] !== onCancel || $[79] !== setIsEditing || $[80] !== type) {
693
+ t18 = () => {
694
+ onCancel?.();
695
+ if (type === "edit") setIsEditing(false);
696
+ };
697
+ $[78] = onCancel;
698
+ $[79] = setIsEditing;
714
699
  $[80] = type;
715
- $[81] = t19;
716
- } else t19 = $[81];
717
- let t20;
718
- if ($[82] !== onBeginEdit) {
719
- t20 = () => {
700
+ $[81] = t18;
701
+ } else t18 = $[81];
702
+ let t19;
703
+ if ($[82] !== isEditingRef || $[83] !== onBeginEdit || $[84] !== setIsEditing || $[85] !== type || $[86] !== updateFromMessage) {
704
+ t19 = () => {
720
705
  onBeginEdit?.();
706
+ if (type === "thread") return;
707
+ if (isEditingRef.current) throw new Error("Edit already in progress");
708
+ setIsEditing(true);
709
+ updateFromMessage();
721
710
  };
722
- $[82] = onBeginEdit;
723
- $[83] = t20;
724
- } else t20 = $[83];
725
- let t21;
726
- if ($[84] !== queueItemClients) {
727
- t21 = (selector_0) => {
711
+ $[82] = isEditingRef;
712
+ $[83] = onBeginEdit;
713
+ $[84] = setIsEditing;
714
+ $[85] = type;
715
+ $[86] = updateFromMessage;
716
+ $[87] = t19;
717
+ } else t19 = $[87];
718
+ let t20;
719
+ if ($[88] !== queueItemClients) {
720
+ t20 = (selector_0) => {
728
721
  if ("id" in selector_0) return queueItemClients.get({ key: selector_0.id });
729
722
  return queueItemClients.get(selector_0);
730
723
  };
731
- $[84] = queueItemClients;
732
- $[85] = t21;
733
- } else t21 = $[85];
734
- let t22;
735
- if ($[86] !== onCancel || $[87] !== setQuote || $[88] !== setRole || $[89] !== setRunConfig || $[90] !== setText || $[91] !== t14 || $[92] !== t15 || $[93] !== t16 || $[94] !== t17 || $[95] !== t18 || $[96] !== t19 || $[97] !== t20 || $[98] !== t21) {
736
- t22 = {
737
- getState: t14,
724
+ $[88] = queueItemClients;
725
+ $[89] = t20;
726
+ } else t20 = $[89];
727
+ let t21;
728
+ if ($[90] !== setQuote || $[91] !== setRole || $[92] !== setRunConfig || $[93] !== setText || $[94] !== t12 || $[95] !== t13 || $[96] !== t14 || $[97] !== t15 || $[98] !== t16 || $[99] !== t17 || $[100] !== t18 || $[101] !== t19 || $[102] !== t20) {
729
+ t21 = {
730
+ getState: t12,
738
731
  setText,
739
732
  setRole,
740
733
  setRunConfig,
741
- addAttachment: t15,
742
- clearAttachments: t16,
743
- attachment: t17,
744
- reset: t18,
745
- send: t19,
746
- cancel: onCancel,
747
- beginEdit: t20,
734
+ addAttachment: t13,
735
+ clearAttachments: t14,
736
+ attachment: t15,
737
+ reset: t16,
738
+ send: t17,
739
+ cancel: t18,
740
+ beginEdit: t19,
748
741
  startDictation: _temp7,
749
742
  stopDictation: _temp8,
750
743
  setQuote,
751
- queueItem: t21
744
+ queueItem: t20
752
745
  };
753
- $[86] = onCancel;
754
- $[87] = setQuote;
755
- $[88] = setRole;
756
- $[89] = setRunConfig;
757
- $[90] = setText;
758
- $[91] = t14;
759
- $[92] = t15;
760
- $[93] = t16;
761
- $[94] = t17;
762
- $[95] = t18;
763
- $[96] = t19;
764
- $[97] = t20;
765
- $[98] = t21;
766
- $[99] = t22;
767
- } else t22 = $[99];
768
- return t22;
746
+ $[90] = setQuote;
747
+ $[91] = setRole;
748
+ $[92] = setRunConfig;
749
+ $[93] = setText;
750
+ $[94] = t12;
751
+ $[95] = t13;
752
+ $[96] = t14;
753
+ $[97] = t15;
754
+ $[98] = t16;
755
+ $[99] = t17;
756
+ $[100] = t18;
757
+ $[101] = t19;
758
+ $[102] = t20;
759
+ $[103] = t21;
760
+ } else t21 = $[103];
761
+ return t21;
769
762
  };
770
763
  const ComposerClientResource = resource(useComposerClientResource);
771
764
  const createSpeechController = (notify) => {
@@ -1058,7 +1051,6 @@ const useExternalThread = (t0) => {
1058
1051
  if ($[49] !== attachmentAdapter || $[50] !== composerQueue || $[51] !== handleCancelRun || $[52] !== handleSendNew || $[53] !== isRunning || $[54] !== isSendDisabled) {
1059
1052
  t22 = ComposerClientResource({
1060
1053
  type: "thread",
1061
- isEditing: true,
1062
1054
  canCancel: isRunning,
1063
1055
  isSendDisabled,
1064
1056
  onCancel: handleCancelRun,
@@ -1314,7 +1306,7 @@ function _temp4(part) {
1314
1306
  return part.type === "text";
1315
1307
  }
1316
1308
  function _temp5(part_0) {
1317
- return "text" in part_0 ? part_0.text : "";
1309
+ return part_0.text;
1318
1310
  }
1319
1311
  function _temp6(a_0) {
1320
1312
  return a_0.status.type !== "complete";