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