@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/index.d.ts CHANGED
@@ -645,6 +645,8 @@ declare const defaultStrings: {
645
645
  connectingPlaceholder: string;
646
646
  /** Loading indicator text */
647
647
  thinking: string;
648
+ /** File processing indicator text (shown during file transformation like OCR) */
649
+ processingFile: string;
648
650
  };
649
651
  fileUpload: {
650
652
  /** Attach files button tooltip */
@@ -829,6 +831,8 @@ interface UseAIChatPanelProps {
829
831
  selectedAgent?: string | null;
830
832
  onAgentChange?: (agentId: string | null) => void;
831
833
  fileUploadConfig?: FileUploadConfig;
834
+ /** File processing state for send-time transformations (e.g., OCR) */
835
+ fileProcessing?: FileProcessingState | null;
832
836
  commands?: SavedCommand[];
833
837
  onSaveCommand?: (name: string, text: string) => Promise<string>;
834
838
  onRenameCommand?: (id: string, newName: string) => Promise<void>;
@@ -840,7 +844,7 @@ interface UseAIChatPanelProps {
840
844
  * Chat panel content - fills its container.
841
845
  * Use directly for embedded mode, or wrap with UseAIFloatingChatWrapper for floating mode.
842
846
  */
843
- declare function UseAIChatPanel({ onSendMessage, messages, loading, connected, streamingText, currentChatId, onNewChat, onLoadChat, onDeleteChat, onListChats, onGetChat, suggestions, availableAgents, defaultAgent, selectedAgent, onAgentChange, fileUploadConfig, commands, onSaveCommand, onRenameCommand, onDeleteCommand, closeButton, }: UseAIChatPanelProps): react_jsx_runtime.JSX.Element;
847
+ declare function UseAIChatPanel({ onSendMessage, messages, loading, connected, streamingText, currentChatId, onNewChat, onLoadChat, onDeleteChat, onListChats, onGetChat, suggestions, availableAgents, defaultAgent, selectedAgent, onAgentChange, fileUploadConfig, fileProcessing, commands, onSaveCommand, onRenameCommand, onDeleteCommand, closeButton, }: UseAIChatPanelProps): react_jsx_runtime.JSX.Element;
844
848
 
845
849
  /**
846
850
  * Handler for AG-UI events from the server.
package/dist/index.js CHANGED
@@ -51,7 +51,9 @@ var defaultStrings = {
51
51
  /** Input placeholder when connecting */
52
52
  connectingPlaceholder: "Connecting...",
53
53
  /** Loading indicator text */
54
- thinking: "Thinking"
54
+ thinking: "Thinking",
55
+ /** File processing indicator text (shown during file transformation like OCR) */
56
+ processingFile: "Processing file..."
55
57
  },
56
58
  // File upload
57
59
  fileUpload: {
@@ -1244,7 +1246,6 @@ async function processAttachments(attachments, config) {
1244
1246
  const chat = await getCurrentChat();
1245
1247
  const context = { chat };
1246
1248
  for (const attachment of attachments) {
1247
- onFileProgress?.(attachment.id, { status: "processing" });
1248
1249
  try {
1249
1250
  if (attachment.transformedContent !== void 0) {
1250
1251
  contentParts.push({
@@ -1256,11 +1257,11 @@ async function processAttachments(attachments, config) {
1256
1257
  size: attachment.file.size
1257
1258
  }
1258
1259
  });
1259
- onFileProgress?.(attachment.id, { status: "done" });
1260
1260
  continue;
1261
1261
  }
1262
1262
  const transformer = findTransformer(attachment.file.type, transformers);
1263
1263
  if (transformer) {
1264
+ onFileProgress?.(attachment.id, { status: "processing" });
1264
1265
  const transformedText = await getTransformedContent(
1265
1266
  attachment.file,
1266
1267
  transformer,
@@ -1278,6 +1279,7 @@ async function processAttachments(attachments, config) {
1278
1279
  size: attachment.file.size
1279
1280
  }
1280
1281
  });
1282
+ onFileProgress?.(attachment.id, { status: "done" });
1281
1283
  } else {
1282
1284
  const url = await backend.prepareForSend(attachment.file);
1283
1285
  if (attachment.file.type.startsWith("image/")) {
@@ -1291,7 +1293,6 @@ async function processAttachments(attachments, config) {
1291
1293
  });
1292
1294
  }
1293
1295
  }
1294
- onFileProgress?.(attachment.id, { status: "done" });
1295
1296
  } catch (error) {
1296
1297
  onFileProgress?.(attachment.id, { status: "error" });
1297
1298
  throw error;
@@ -1597,6 +1598,7 @@ function UseAIChatPanel({
1597
1598
  selectedAgent,
1598
1599
  onAgentChange,
1599
1600
  fileUploadConfig,
1601
+ fileProcessing,
1600
1602
  commands = [],
1601
1603
  onSaveCommand,
1602
1604
  onRenameCommand,
@@ -2265,7 +2267,29 @@ function UseAIChatPanel({
2265
2267
  color: theme.textColor,
2266
2268
  maxWidth: "80%"
2267
2269
  },
2268
- children: streamingText ? /* @__PURE__ */ jsx10(MarkdownContent, { content: streamingText }) : /* @__PURE__ */ jsxs7(Fragment, { children: [
2270
+ children: streamingText ? /* @__PURE__ */ jsx10(MarkdownContent, { content: streamingText }) : fileProcessing && fileProcessing.status === "processing" ? /* @__PURE__ */ jsxs7("div", { children: [
2271
+ /* @__PURE__ */ jsx10("span", { style: { opacity: 0.6 }, children: strings.input.processingFile }),
2272
+ fileProcessing.progress != null && /* @__PURE__ */ jsxs7(Fragment, { children: [
2273
+ /* @__PURE__ */ jsxs7("span", { style: { opacity: 0.6, marginLeft: "4px" }, children: [
2274
+ Math.round(fileProcessing.progress),
2275
+ "%"
2276
+ ] }),
2277
+ /* @__PURE__ */ jsx10("div", { style: {
2278
+ marginTop: "6px",
2279
+ height: "4px",
2280
+ borderRadius: "2px",
2281
+ background: theme.borderColor,
2282
+ overflow: "hidden"
2283
+ }, children: /* @__PURE__ */ jsx10("div", { style: {
2284
+ height: "100%",
2285
+ width: `${fileProcessing.progress}%`,
2286
+ borderRadius: "2px",
2287
+ background: theme.primaryColor,
2288
+ transition: "width 0.3s ease"
2289
+ } }) })
2290
+ ] }),
2291
+ fileProcessing.progress == null && /* @__PURE__ */ jsx10("span", { className: "dots", style: { marginLeft: "4px" }, children: "..." })
2292
+ ] }) : /* @__PURE__ */ jsxs7(Fragment, { children: [
2269
2293
  /* @__PURE__ */ jsx10("span", { style: { opacity: 0.6 }, children: strings.input.thinking }),
2270
2294
  /* @__PURE__ */ jsx10("span", { className: "dots", style: { marginLeft: "4px" }, children: "..." })
2271
2295
  ] })
@@ -2613,6 +2637,7 @@ function UseAIChat({ floating = false }) {
2613
2637
  selectedAgent: ctx.agents.selected,
2614
2638
  onAgentChange: ctx.agents.set,
2615
2639
  fileUploadConfig: ctx.fileUploadConfig,
2640
+ fileProcessing: ctx.fileProcessing,
2616
2641
  commands: ctx.commands.list,
2617
2642
  onSaveCommand: ctx.commands.save,
2618
2643
  onRenameCommand: ctx.commands.rename,
@@ -4153,6 +4178,7 @@ function UseAIProvider({
4153
4178
  const [connected, setConnected] = useState10(false);
4154
4179
  const [isChatOpen, setIsChatOpen] = useState10(false);
4155
4180
  const [loading, setLoading] = useState10(false);
4181
+ const [fileProcessingState, setFileProcessingState] = useState10(null);
4156
4182
  const handleSetChatOpen = useCallback9((open) => {
4157
4183
  setIsChatOpen(open);
4158
4184
  onOpenChange?.(open);
@@ -4369,21 +4395,36 @@ function UseAIProvider({
4369
4395
  });
4370
4396
  }
4371
4397
  persistedContent = persistedParts;
4372
- const fileContent = await processAttachments(attachments, {
4373
- getCurrentChat,
4374
- backend: fileUploadConfig?.backend,
4375
- transformers: fileUploadConfig?.transformers
4376
- });
4377
- multimodalContent = [];
4378
- if (message.trim()) {
4379
- multimodalContent.push({ type: "text", text: message });
4398
+ if (activeChatId) {
4399
+ await saveUserMessage(activeChatId, persistedContent);
4380
4400
  }
4381
- multimodalContent.push(...fileContent);
4382
- }
4383
- if (activeChatId) {
4384
- await saveUserMessage(activeChatId, persistedContent);
4401
+ setLoading(true);
4402
+ try {
4403
+ const fileContent = await processAttachments(attachments, {
4404
+ getCurrentChat,
4405
+ backend: fileUploadConfig?.backend,
4406
+ transformers: fileUploadConfig?.transformers,
4407
+ onFileProgress: (_fileId, state) => {
4408
+ setFileProcessingState(state);
4409
+ }
4410
+ });
4411
+ multimodalContent = [];
4412
+ if (message.trim()) {
4413
+ multimodalContent.push({ type: "text", text: message });
4414
+ }
4415
+ multimodalContent.push(...fileContent);
4416
+ } catch (error) {
4417
+ setLoading(false);
4418
+ throw error;
4419
+ } finally {
4420
+ setFileProcessingState(null);
4421
+ }
4422
+ } else {
4423
+ if (activeChatId) {
4424
+ await saveUserMessage(activeChatId, persistedContent);
4425
+ }
4426
+ setLoading(true);
4385
4427
  }
4386
- setLoading(true);
4387
4428
  await clientRef.current.sendPrompt(message, multimodalContent);
4388
4429
  }, [activatePendingChat, currentChatId, saveUserMessage, fileUploadConfig, getCurrentChat]);
4389
4430
  handleSendMessageRef.current = handleSendMessage;
@@ -4434,6 +4475,7 @@ function UseAIProvider({
4434
4475
  streamingText: effectiveStreamingText,
4435
4476
  suggestions: aggregatedSuggestions,
4436
4477
  fileUploadConfig,
4478
+ fileProcessing: fileProcessingState,
4437
4479
  history: {
4438
4480
  currentId: displayedChatId,
4439
4481
  create: createNewChat,
@@ -4479,6 +4521,7 @@ function UseAIProvider({
4479
4521
  selectedAgent,
4480
4522
  onAgentChange: setAgent,
4481
4523
  fileUploadConfig,
4524
+ fileProcessing: fileProcessingState,
4482
4525
  commands,
4483
4526
  onSaveCommand: saveCommand,
4484
4527
  onRenameCommand: renameCommand,