@meetsmore-oss/use-ai-client 1.3.0 → 1.4.0

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/bundled.js CHANGED
@@ -5753,7 +5753,9 @@ var defaultStrings = {
5753
5753
  /** Input placeholder when connecting */
5754
5754
  connectingPlaceholder: "Connecting...",
5755
5755
  /** Loading indicator text */
5756
- thinking: "Thinking"
5756
+ thinking: "Thinking",
5757
+ /** File processing indicator text (shown during file transformation like OCR) */
5758
+ processingFile: "Processing file..."
5757
5759
  },
5758
5760
  // File upload
5759
5761
  fileUpload: {
@@ -15550,7 +15552,6 @@ async function processAttachments(attachments, config2) {
15550
15552
  const chat = await getCurrentChat();
15551
15553
  const context = { chat };
15552
15554
  for (const attachment of attachments) {
15553
- onFileProgress?.(attachment.id, { status: "processing" });
15554
15555
  try {
15555
15556
  if (attachment.transformedContent !== void 0) {
15556
15557
  contentParts.push({
@@ -15562,11 +15563,11 @@ async function processAttachments(attachments, config2) {
15562
15563
  size: attachment.file.size
15563
15564
  }
15564
15565
  });
15565
- onFileProgress?.(attachment.id, { status: "done" });
15566
15566
  continue;
15567
15567
  }
15568
15568
  const transformer = findTransformer(attachment.file.type, transformers);
15569
15569
  if (transformer) {
15570
+ onFileProgress?.(attachment.id, { status: "processing" });
15570
15571
  const transformedText = await getTransformedContent(
15571
15572
  attachment.file,
15572
15573
  transformer,
@@ -15584,6 +15585,7 @@ async function processAttachments(attachments, config2) {
15584
15585
  size: attachment.file.size
15585
15586
  }
15586
15587
  });
15588
+ onFileProgress?.(attachment.id, { status: "done" });
15587
15589
  } else {
15588
15590
  const url3 = await backend.prepareForSend(attachment.file);
15589
15591
  if (attachment.file.type.startsWith("image/")) {
@@ -15597,7 +15599,6 @@ async function processAttachments(attachments, config2) {
15597
15599
  });
15598
15600
  }
15599
15601
  }
15600
- onFileProgress?.(attachment.id, { status: "done" });
15601
15602
  } catch (error46) {
15602
15603
  onFileProgress?.(attachment.id, { status: "error" });
15603
15604
  throw error46;
@@ -15954,6 +15955,7 @@ function UseAIChatPanel({
15954
15955
  selectedAgent,
15955
15956
  onAgentChange,
15956
15957
  fileUploadConfig,
15958
+ fileProcessing,
15957
15959
  commands = [],
15958
15960
  onSaveCommand,
15959
15961
  onRenameCommand,
@@ -16622,7 +16624,29 @@ function UseAIChatPanel({
16622
16624
  color: theme.textColor,
16623
16625
  maxWidth: "80%"
16624
16626
  },
16625
- children: streamingText ? /* @__PURE__ */ jsx10(MarkdownContent, { content: streamingText }) : /* @__PURE__ */ jsxs7(Fragment, { children: [
16627
+ children: streamingText ? /* @__PURE__ */ jsx10(MarkdownContent, { content: streamingText }) : fileProcessing && fileProcessing.status === "processing" ? /* @__PURE__ */ jsxs7("div", { children: [
16628
+ /* @__PURE__ */ jsx10("span", { style: { opacity: 0.6 }, children: strings.input.processingFile }),
16629
+ fileProcessing.progress != null && /* @__PURE__ */ jsxs7(Fragment, { children: [
16630
+ /* @__PURE__ */ jsxs7("span", { style: { opacity: 0.6, marginLeft: "4px" }, children: [
16631
+ Math.round(fileProcessing.progress),
16632
+ "%"
16633
+ ] }),
16634
+ /* @__PURE__ */ jsx10("div", { style: {
16635
+ marginTop: "6px",
16636
+ height: "4px",
16637
+ borderRadius: "2px",
16638
+ background: theme.borderColor,
16639
+ overflow: "hidden"
16640
+ }, children: /* @__PURE__ */ jsx10("div", { style: {
16641
+ height: "100%",
16642
+ width: `${fileProcessing.progress}%`,
16643
+ borderRadius: "2px",
16644
+ background: theme.primaryColor,
16645
+ transition: "width 0.3s ease"
16646
+ } }) })
16647
+ ] }),
16648
+ fileProcessing.progress == null && /* @__PURE__ */ jsx10("span", { className: "dots", style: { marginLeft: "4px" }, children: "..." })
16649
+ ] }) : /* @__PURE__ */ jsxs7(Fragment, { children: [
16626
16650
  /* @__PURE__ */ jsx10("span", { style: { opacity: 0.6 }, children: strings.input.thinking }),
16627
16651
  /* @__PURE__ */ jsx10("span", { className: "dots", style: { marginLeft: "4px" }, children: "..." })
16628
16652
  ] })
@@ -16970,6 +16994,7 @@ function UseAIChat({ floating = false }) {
16970
16994
  selectedAgent: ctx.agents.selected,
16971
16995
  onAgentChange: ctx.agents.set,
16972
16996
  fileUploadConfig: ctx.fileUploadConfig,
16997
+ fileProcessing: ctx.fileProcessing,
16973
16998
  commands: ctx.commands.list,
16974
16999
  onSaveCommand: ctx.commands.save,
16975
17000
  onRenameCommand: ctx.commands.rename,
@@ -34531,6 +34556,7 @@ function UseAIProvider({
34531
34556
  const [connected, setConnected] = useState10(false);
34532
34557
  const [isChatOpen, setIsChatOpen] = useState10(false);
34533
34558
  const [loading, setLoading] = useState10(false);
34559
+ const [fileProcessingState, setFileProcessingState] = useState10(null);
34534
34560
  const handleSetChatOpen = useCallback9((open) => {
34535
34561
  setIsChatOpen(open);
34536
34562
  onOpenChange?.(open);
@@ -34747,21 +34773,36 @@ function UseAIProvider({
34747
34773
  });
34748
34774
  }
34749
34775
  persistedContent = persistedParts;
34750
- const fileContent = await processAttachments(attachments, {
34751
- getCurrentChat,
34752
- backend: fileUploadConfig?.backend,
34753
- transformers: fileUploadConfig?.transformers
34754
- });
34755
- multimodalContent = [];
34756
- if (message.trim()) {
34757
- multimodalContent.push({ type: "text", text: message });
34776
+ if (activeChatId) {
34777
+ await saveUserMessage(activeChatId, persistedContent);
34758
34778
  }
34759
- multimodalContent.push(...fileContent);
34760
- }
34761
- if (activeChatId) {
34762
- await saveUserMessage(activeChatId, persistedContent);
34779
+ setLoading(true);
34780
+ try {
34781
+ const fileContent = await processAttachments(attachments, {
34782
+ getCurrentChat,
34783
+ backend: fileUploadConfig?.backend,
34784
+ transformers: fileUploadConfig?.transformers,
34785
+ onFileProgress: (_fileId, state) => {
34786
+ setFileProcessingState(state);
34787
+ }
34788
+ });
34789
+ multimodalContent = [];
34790
+ if (message.trim()) {
34791
+ multimodalContent.push({ type: "text", text: message });
34792
+ }
34793
+ multimodalContent.push(...fileContent);
34794
+ } catch (error46) {
34795
+ setLoading(false);
34796
+ throw error46;
34797
+ } finally {
34798
+ setFileProcessingState(null);
34799
+ }
34800
+ } else {
34801
+ if (activeChatId) {
34802
+ await saveUserMessage(activeChatId, persistedContent);
34803
+ }
34804
+ setLoading(true);
34763
34805
  }
34764
- setLoading(true);
34765
34806
  await clientRef.current.sendPrompt(message, multimodalContent);
34766
34807
  }, [activatePendingChat, currentChatId, saveUserMessage, fileUploadConfig, getCurrentChat]);
34767
34808
  handleSendMessageRef.current = handleSendMessage;
@@ -34812,6 +34853,7 @@ function UseAIProvider({
34812
34853
  streamingText: effectiveStreamingText,
34813
34854
  suggestions: aggregatedSuggestions,
34814
34855
  fileUploadConfig,
34856
+ fileProcessing: fileProcessingState,
34815
34857
  history: {
34816
34858
  currentId: displayedChatId,
34817
34859
  create: createNewChat,
@@ -34857,6 +34899,7 @@ function UseAIProvider({
34857
34899
  selectedAgent,
34858
34900
  onAgentChange: setAgent,
34859
34901
  fileUploadConfig,
34902
+ fileProcessing: fileProcessingState,
34860
34903
  commands,
34861
34904
  onSaveCommand: saveCommand,
34862
34905
  onRenameCommand: renameCommand,