@invergent/agent-chat-react 2.7.2 → 2.7.4
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/index.cjs +26 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4547,6 +4547,9 @@ var ChatMessage = memo(function ChatMessage2({
|
|
|
4547
4547
|
message,
|
|
4548
4548
|
onFileSelect
|
|
4549
4549
|
}) {
|
|
4550
|
+
const fileAttachments = (message.attachments ?? []).filter(
|
|
4551
|
+
(a) => !a.mimeType?.startsWith("image/")
|
|
4552
|
+
);
|
|
4550
4553
|
return /* @__PURE__ */ jsx(Message, { from: "user", children: /* @__PURE__ */ jsxs(MessageContent, { children: [
|
|
4551
4554
|
/* @__PURE__ */ jsx(CollapsibleMessageBody, { content: message.content }),
|
|
4552
4555
|
message.images && message.images.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2 mt-2", children: message.images.map((img, i) => /* @__PURE__ */ jsx(
|
|
@@ -4558,7 +4561,7 @@ var ChatMessage = memo(function ChatMessage2({
|
|
|
4558
4561
|
},
|
|
4559
4562
|
i
|
|
4560
4563
|
)) }),
|
|
4561
|
-
|
|
4564
|
+
fileAttachments.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2 mt-2", children: fileAttachments.map((a, i) => /* @__PURE__ */ jsx(
|
|
4562
4565
|
AttachmentChip,
|
|
4563
4566
|
{
|
|
4564
4567
|
attachment: a,
|
|
@@ -5596,6 +5599,27 @@ var PromptInputSubmit = ({
|
|
|
5596
5599
|
}
|
|
5597
5600
|
);
|
|
5598
5601
|
};
|
|
5602
|
+
|
|
5603
|
+
// src/lib/split-composer-files.ts
|
|
5604
|
+
function splitComposerFiles(files) {
|
|
5605
|
+
const images = [];
|
|
5606
|
+
const pending = [];
|
|
5607
|
+
for (const file of files) {
|
|
5608
|
+
if (file.mediaType?.startsWith("image/") && file.url) {
|
|
5609
|
+
images.push({ data: file.url, mimeType: file.mediaType });
|
|
5610
|
+
}
|
|
5611
|
+
if (!file.file) {
|
|
5612
|
+
continue;
|
|
5613
|
+
}
|
|
5614
|
+
pending.push({
|
|
5615
|
+
file: file.file,
|
|
5616
|
+
filename: file.filename ?? file.file.name,
|
|
5617
|
+
mimeType: file.mediaType ?? file.file.type ?? void 0,
|
|
5618
|
+
size: file.file.size
|
|
5619
|
+
});
|
|
5620
|
+
}
|
|
5621
|
+
return { images, pending };
|
|
5622
|
+
}
|
|
5599
5623
|
function Popover({
|
|
5600
5624
|
...props
|
|
5601
5625
|
}) {
|
|
@@ -6273,23 +6297,7 @@ function ChatComposerInner({
|
|
|
6273
6297
|
async (message) => {
|
|
6274
6298
|
const text = message.text.trim();
|
|
6275
6299
|
if (!text || disabled) return;
|
|
6276
|
-
const images =
|
|
6277
|
-
const pending = [];
|
|
6278
|
-
for (const file of message.files) {
|
|
6279
|
-
if (file.mediaType?.startsWith("image/") && file.url) {
|
|
6280
|
-
images.push({ data: file.url, mimeType: file.mediaType });
|
|
6281
|
-
continue;
|
|
6282
|
-
}
|
|
6283
|
-
if (!file.file) {
|
|
6284
|
-
continue;
|
|
6285
|
-
}
|
|
6286
|
-
pending.push({
|
|
6287
|
-
file: file.file,
|
|
6288
|
-
filename: file.filename ?? file.file.name,
|
|
6289
|
-
mimeType: file.mediaType ?? file.file.type ?? void 0,
|
|
6290
|
-
size: file.file.size
|
|
6291
|
-
});
|
|
6292
|
-
}
|
|
6300
|
+
const { images, pending } = splitComposerFiles(message.files);
|
|
6293
6301
|
if (images.length > MAX_IMAGES_PER_MESSAGE) {
|
|
6294
6302
|
onComposerError?.({
|
|
6295
6303
|
code: "max_images",
|