@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.
- package/dist/client/ExternalThread.d.ts.map +1 -1
- package/dist/client/ExternalThread.js +330 -338
- 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 +26 -43
- package/src/client/InMemoryThreadList.ts +5 -4
- package/src/tests/external-thread-parity.test.tsx +95 -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";
|
|
@@ -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(
|
|
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]
|
|
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
|
-
$[
|
|
84
|
-
$[
|
|
85
|
-
$[
|
|
86
|
-
$[
|
|
87
|
-
} else
|
|
88
|
-
const handleSendEdit =
|
|
89
|
-
let
|
|
90
|
-
if ($[
|
|
91
|
-
|
|
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
|
-
$[
|
|
103
|
-
$[
|
|
104
|
-
$[
|
|
105
|
-
$[
|
|
106
|
-
$[
|
|
107
|
-
$[
|
|
108
|
-
|
|
109
|
-
|
|
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
|
|
113
|
-
if ($[
|
|
98
|
+
let t7;
|
|
99
|
+
if ($[21] !== branches || $[22] !== message.id) {
|
|
114
100
|
branchIds = branches?.getBranches(message.id) ?? EMPTY_BRANCH_IDS;
|
|
115
|
-
|
|
116
|
-
$[
|
|
117
|
-
$[
|
|
118
|
-
$[
|
|
119
|
-
$[
|
|
101
|
+
t7 = branchIds.indexOf(message.id);
|
|
102
|
+
$[21] = branches;
|
|
103
|
+
$[22] = message.id;
|
|
104
|
+
$[23] = branchIds;
|
|
105
|
+
$[24] = t7;
|
|
120
106
|
} else {
|
|
121
|
-
branchIds = $[
|
|
122
|
-
|
|
107
|
+
branchIds = $[23];
|
|
108
|
+
t7 = $[24];
|
|
123
109
|
}
|
|
124
|
-
const branchIndex =
|
|
110
|
+
const branchIndex = t7;
|
|
125
111
|
const branchNumber = branchIndex === -1 ? 1 : branchIndex + 1;
|
|
126
112
|
const branchCount = branchIndex === -1 ? 1 : branchIds.length;
|
|
127
|
-
let
|
|
128
|
-
if ($[
|
|
129
|
-
|
|
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
|
-
$[
|
|
137
|
-
$[
|
|
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] !==
|
|
143
|
-
t10 =
|
|
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:
|
|
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
|
-
$[
|
|
164
|
-
$[
|
|
165
|
-
$[
|
|
166
|
-
$[
|
|
167
|
-
$[
|
|
168
|
-
$[
|
|
169
|
-
$[
|
|
170
|
-
$[
|
|
171
|
-
$[
|
|
172
|
-
$[
|
|
173
|
-
$[
|
|
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] !==
|
|
179
|
-
t12 = () =>
|
|
180
|
-
$[44] =
|
|
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] !==
|
|
185
|
-
t13 = () =>
|
|
186
|
-
|
|
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] !==
|
|
191
|
-
t14 = () => {
|
|
192
|
-
|
|
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
|
-
$[
|
|
206
|
-
$[
|
|
207
|
-
$[
|
|
208
|
-
$[
|
|
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] !==
|
|
213
|
-
t16 = () =>
|
|
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
|
-
$[
|
|
225
|
-
$[
|
|
226
|
-
$[
|
|
227
|
-
} else
|
|
228
|
-
let
|
|
229
|
-
if ($[
|
|
230
|
-
|
|
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
|
-
$[
|
|
235
|
-
$[
|
|
236
|
-
} else
|
|
237
|
-
let
|
|
238
|
-
if ($[
|
|
239
|
-
|
|
240
|
-
getState:
|
|
241
|
-
composer:
|
|
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:
|
|
229
|
+
reload: t13,
|
|
244
230
|
speak: onSpeak,
|
|
245
231
|
stopSpeaking: onStopSpeaking,
|
|
246
232
|
submitFeedback: onSubmitFeedback,
|
|
247
|
-
switchToBranch:
|
|
248
|
-
getCopyText:
|
|
249
|
-
part:
|
|
250
|
-
attachment:
|
|
233
|
+
switchToBranch: t14,
|
|
234
|
+
getCopyText: t15,
|
|
235
|
+
part: t16,
|
|
236
|
+
attachment: t17,
|
|
251
237
|
setIsCopied,
|
|
252
238
|
setIsHovering
|
|
253
239
|
};
|
|
254
|
-
$[
|
|
255
|
-
$[
|
|
256
|
-
$[
|
|
257
|
-
$[
|
|
258
|
-
$[
|
|
259
|
-
$[
|
|
260
|
-
$[
|
|
261
|
-
$[
|
|
262
|
-
$[
|
|
263
|
-
$[
|
|
264
|
-
$[
|
|
265
|
-
} else
|
|
266
|
-
return
|
|
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(
|
|
406
|
-
const { type,
|
|
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
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
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 =
|
|
425
|
+
const updateFromMessage = t4;
|
|
440
426
|
let t5;
|
|
441
|
-
if ($[7] !==
|
|
442
|
-
|
|
443
|
-
|
|
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
|
-
$[
|
|
468
|
-
$[
|
|
469
|
-
$[
|
|
470
|
-
} else
|
|
471
|
-
|
|
472
|
-
$[
|
|
473
|
-
$[
|
|
474
|
-
$[
|
|
475
|
-
$[
|
|
476
|
-
} else
|
|
477
|
-
const attachmentClients = useClientLookup(
|
|
478
|
-
let
|
|
479
|
-
if ($[
|
|
480
|
-
|
|
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
|
-
$[
|
|
485
|
-
$[
|
|
486
|
-
} else
|
|
487
|
-
const removePendingAttachments =
|
|
488
|
-
let
|
|
489
|
-
if ($[
|
|
490
|
-
|
|
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
|
-
$[
|
|
500
|
-
$[
|
|
501
|
-
} else
|
|
502
|
-
const upsertAttachment =
|
|
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
|
|
506
|
-
if ($[
|
|
507
|
-
|
|
508
|
-
$[
|
|
509
|
-
$[
|
|
510
|
-
$[
|
|
511
|
-
} else
|
|
512
|
-
const queueItems =
|
|
513
|
-
let
|
|
514
|
-
if ($[
|
|
515
|
-
let
|
|
516
|
-
if ($[
|
|
517
|
-
|
|
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
|
-
$[
|
|
523
|
-
$[
|
|
524
|
-
} else
|
|
525
|
-
|
|
526
|
-
$[
|
|
527
|
-
$[
|
|
528
|
-
$[
|
|
529
|
-
} else
|
|
530
|
-
const queueItemClients = useClientLookup(
|
|
531
|
-
let
|
|
532
|
-
if ($[
|
|
533
|
-
|
|
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
|
-
$[
|
|
552
|
-
$[
|
|
553
|
-
$[
|
|
554
|
-
$[
|
|
555
|
-
$[
|
|
556
|
-
$[
|
|
557
|
-
$[
|
|
558
|
-
$[
|
|
559
|
-
$[
|
|
560
|
-
$[
|
|
561
|
-
$[
|
|
562
|
-
$[
|
|
563
|
-
$[
|
|
564
|
-
} 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];
|
|
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] !==
|
|
568
|
-
t13 =
|
|
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
|
-
$[
|
|
617
|
-
$[
|
|
618
|
-
$[
|
|
619
|
-
$[
|
|
620
|
-
} else
|
|
621
|
-
let
|
|
622
|
-
if ($[
|
|
623
|
-
|
|
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
|
-
$[
|
|
629
|
-
$[
|
|
630
|
-
$[
|
|
631
|
-
$[
|
|
632
|
-
} else
|
|
633
|
-
let
|
|
634
|
-
if ($[
|
|
635
|
-
|
|
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
|
-
$[
|
|
640
|
-
$[
|
|
641
|
-
} else
|
|
642
|
-
let
|
|
643
|
-
if ($[
|
|
644
|
-
|
|
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
|
-
$[
|
|
654
|
-
$[
|
|
655
|
-
$[
|
|
656
|
-
$[
|
|
657
|
-
$[
|
|
658
|
-
$[
|
|
659
|
-
$[
|
|
660
|
-
$[
|
|
661
|
-
} else
|
|
662
|
-
let
|
|
663
|
-
if ($[
|
|
664
|
-
|
|
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 (!
|
|
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")
|
|
689
|
-
|
|
690
|
-
|
|
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
|
-
$[
|
|
701
|
-
$[
|
|
702
|
-
$[
|
|
703
|
-
$[
|
|
704
|
-
$[
|
|
705
|
-
$[
|
|
706
|
-
$[
|
|
707
|
-
$[
|
|
708
|
-
$[
|
|
709
|
-
$[
|
|
710
|
-
$[
|
|
711
|
-
$[
|
|
712
|
-
$[
|
|
713
|
-
$[
|
|
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] =
|
|
716
|
-
} else
|
|
717
|
-
let
|
|
718
|
-
if ($[82] !== onBeginEdit) {
|
|
719
|
-
|
|
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] =
|
|
723
|
-
$[83] =
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
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
|
-
$[
|
|
732
|
-
$[
|
|
733
|
-
} else
|
|
734
|
-
let
|
|
735
|
-
if ($[
|
|
736
|
-
|
|
737
|
-
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,
|
|
738
731
|
setText,
|
|
739
732
|
setRole,
|
|
740
733
|
setRunConfig,
|
|
741
|
-
addAttachment:
|
|
742
|
-
clearAttachments:
|
|
743
|
-
attachment:
|
|
744
|
-
reset:
|
|
745
|
-
send:
|
|
746
|
-
cancel:
|
|
747
|
-
beginEdit:
|
|
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:
|
|
744
|
+
queueItem: t20
|
|
752
745
|
};
|
|
753
|
-
$[
|
|
754
|
-
$[
|
|
755
|
-
$[
|
|
756
|
-
$[
|
|
757
|
-
$[
|
|
758
|
-
$[
|
|
759
|
-
$[
|
|
760
|
-
$[
|
|
761
|
-
$[
|
|
762
|
-
$[
|
|
763
|
-
$[
|
|
764
|
-
$[
|
|
765
|
-
$[
|
|
766
|
-
$[
|
|
767
|
-
} else
|
|
768
|
-
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;
|
|
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
|
|
1309
|
+
return part_0.text;
|
|
1318
1310
|
}
|
|
1319
1311
|
function _temp6(a_0) {
|
|
1320
1312
|
return a_0.status.type !== "complete";
|