@invergent/agent-chat-react 2.7.1 → 2.7.3

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 CHANGED
@@ -4806,6 +4806,9 @@ var ChatMessage = react.memo(function ChatMessage2({
4806
4806
  message,
4807
4807
  onFileSelect
4808
4808
  }) {
4809
+ const fileAttachments = (message.attachments ?? []).filter(
4810
+ (a) => !a.mimeType?.startsWith("image/")
4811
+ );
4809
4812
  return /* @__PURE__ */ jsxRuntime.jsx(Message, { from: "user", children: /* @__PURE__ */ jsxRuntime.jsxs(MessageContent, { children: [
4810
4813
  /* @__PURE__ */ jsxRuntime.jsx(CollapsibleMessageBody, { content: message.content }),
4811
4814
  message.images && message.images.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-2 mt-2", children: message.images.map((img, i) => /* @__PURE__ */ jsxRuntime.jsx(
@@ -4817,7 +4820,7 @@ var ChatMessage = react.memo(function ChatMessage2({
4817
4820
  },
4818
4821
  i
4819
4822
  )) }),
4820
- message.attachments && message.attachments.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-2 mt-2", children: message.attachments.map((a, i) => /* @__PURE__ */ jsxRuntime.jsx(
4823
+ fileAttachments.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-2 mt-2", children: fileAttachments.map((a, i) => /* @__PURE__ */ jsxRuntime.jsx(
4821
4824
  AttachmentChip,
4822
4825
  {
4823
4826
  attachment: a,
@@ -5868,6 +5871,27 @@ var PromptInputSubmit = ({
5868
5871
  );
5869
5872
  };
5870
5873
 
5874
+ // src/lib/split-composer-files.ts
5875
+ function splitComposerFiles(files) {
5876
+ const images = [];
5877
+ const pending = [];
5878
+ for (const file of files) {
5879
+ if (file.mediaType?.startsWith("image/") && file.url) {
5880
+ images.push({ data: file.url, mimeType: file.mediaType });
5881
+ }
5882
+ if (!file.file) {
5883
+ continue;
5884
+ }
5885
+ pending.push({
5886
+ file: file.file,
5887
+ filename: file.filename ?? file.file.name,
5888
+ mimeType: file.mediaType ?? file.file.type ?? void 0,
5889
+ size: file.file.size
5890
+ });
5891
+ }
5892
+ return { images, pending };
5893
+ }
5894
+
5871
5895
  // src/components/ui/popover.tsx
5872
5896
  init_utils();
5873
5897
  function Popover({
@@ -6559,23 +6583,7 @@ function ChatComposerInner({
6559
6583
  async (message) => {
6560
6584
  const text = message.text.trim();
6561
6585
  if (!text || disabled) return;
6562
- const images = [];
6563
- const pending = [];
6564
- for (const file of message.files) {
6565
- if (file.mediaType?.startsWith("image/") && file.url) {
6566
- images.push({ data: file.url, mimeType: file.mediaType });
6567
- continue;
6568
- }
6569
- if (!file.file) {
6570
- continue;
6571
- }
6572
- pending.push({
6573
- file: file.file,
6574
- filename: file.filename ?? file.file.name,
6575
- mimeType: file.mediaType ?? file.file.type ?? void 0,
6576
- size: file.file.size
6577
- });
6578
- }
6586
+ const { images, pending } = splitComposerFiles(message.files);
6579
6587
  if (images.length > MAX_IMAGES_PER_MESSAGE) {
6580
6588
  onComposerError?.({
6581
6589
  code: "max_images",