@copilotz/chat-ui 0.9.22 → 0.9.24

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
@@ -64,6 +64,10 @@ var defaultChatConfig = {
64
64
  inputPlaceholder: "Type your message...",
65
65
  sendButton: "Send",
66
66
  sendMessageTooltip: "Send message",
67
+ stageMessageTooltip: "Stage message",
68
+ sendNowTooltip: "Send now",
69
+ stagedMessageLabel: "Not sent yet",
70
+ discardStagedMessageTooltip: "Discard",
67
71
  newThread: "New Conversation",
68
72
  deleteThread: "Delete Conversation",
69
73
  copyMessage: "Copy",
@@ -5266,7 +5270,8 @@ var ChatInput = (0, import_react8.memo)(function ChatInput2({
5266
5270
  config?.labels?.attachmentsCount,
5267
5271
  "{{count}}/{{max}} attachments",
5268
5272
  { count: staged.attachments.length, max: maxAttachments }
5269
- ) })
5273
+ ) }),
5274
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "text-xs text-muted-foreground", children: config?.labels?.stagedMessageLabel || "Not sent yet" })
5270
5275
  ] }),
5271
5276
  /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(Tooltip, { children: [
5272
5277
  /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
@@ -5279,7 +5284,7 @@ var ChatInput = (0, import_react8.memo)(function ChatInput2({
5279
5284
  children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react12.Send, { className: "h-4 w-4" })
5280
5285
  }
5281
5286
  ) }),
5282
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TooltipContent, { children: config?.labels?.sendMessageTooltip })
5287
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TooltipContent, { children: config?.labels?.sendNowTooltip || config?.labels?.sendMessageTooltip })
5283
5288
  ] }),
5284
5289
  /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(Tooltip, { children: [
5285
5290
  /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
@@ -5293,7 +5298,7 @@ var ChatInput = (0, import_react8.memo)(function ChatInput2({
5293
5298
  children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react12.X, { className: "h-4 w-4" })
5294
5299
  }
5295
5300
  ) }),
5296
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TooltipContent, { children: config?.labels?.voiceCancel })
5301
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TooltipContent, { children: config?.labels?.discardStagedMessageTooltip || config?.labels?.voiceCancel })
5297
5302
  ] })
5298
5303
  ]
5299
5304
  },
@@ -5418,7 +5423,7 @@ var ChatInput = (0, import_react8.memo)(function ChatInput2({
5418
5423
  children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react12.Send, { className: "h-4 w-4" })
5419
5424
  }
5420
5425
  ) }),
5421
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TooltipContent, { children: config?.labels?.sendMessageTooltip })
5426
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TooltipContent, { children: config?.labels?.stageMessageTooltip || config?.labels?.sendMessageTooltip })
5422
5427
  ] }),
5423
5428
  /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(Tooltip, { children: [
5424
5429
  /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
@@ -6017,6 +6022,8 @@ var ChatUI = ({
6017
6022
  isMessagesLoading = false,
6018
6023
  isLoadingOlderMessages = false,
6019
6024
  hasMoreMessagesBefore = false,
6025
+ activityNotice = null,
6026
+ isBackgroundRefreshingMessages = false,
6020
6027
  callbacks = {},
6021
6028
  onLoadOlderMessages,
6022
6029
  user,
@@ -6152,7 +6159,9 @@ var ChatUI = ({
6152
6159
  prevMessageCountRef.current = groupedMessages.length;
6153
6160
  return;
6154
6161
  }
6155
- const wasEmpty = prevMessageCountRef.current === 0;
6162
+ const previousMessageCount = prevMessageCountRef.current;
6163
+ const wasEmpty = previousMessageCount === 0;
6164
+ const didAppendMessages = groupedMessages.length > previousMessageCount;
6156
6165
  prevMessageCountRef.current = groupedMessages.length;
6157
6166
  if (wasEmpty) {
6158
6167
  requestAnimationFrame(() => {
@@ -6164,6 +6173,9 @@ var ChatUI = ({
6164
6173
  });
6165
6174
  return;
6166
6175
  }
6176
+ if (isBackgroundRefreshingMessages && !didAppendMessages) {
6177
+ return;
6178
+ }
6167
6179
  if (!state.isAtBottom) return;
6168
6180
  requestAnimationFrame(() => {
6169
6181
  const viewport = scrollAreaRef.current;
@@ -6174,7 +6186,7 @@ var ChatUI = ({
6174
6186
  viewport.scrollTop = viewport.scrollHeight;
6175
6187
  }
6176
6188
  });
6177
- }, [groupedMessages, state.isAtBottom, virtualizer]);
6189
+ }, [groupedMessages, isBackgroundRefreshingMessages, state.isAtBottom, virtualizer]);
6178
6190
  (0, import_react10.useEffect)(() => {
6179
6191
  const viewport = scrollAreaRef.current;
6180
6192
  if (!viewport) return;
@@ -6665,41 +6677,50 @@ var ChatUI = ({
6665
6677
  ] })
6666
6678
  }
6667
6679
  ),
6668
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "-mt-8 bg-gradient-to-t from-background via-background/95 to-transparent px-0 pb-[env(safe-area-inset-bottom)] pt-10", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
6669
- ChatInput,
6670
- {
6671
- value: inputValue,
6672
- onChange: (value) => {
6673
- inputValueRef.current = value;
6674
- if (initialInputApplied.current && !initialInputConsumedRef.current) {
6675
- initialInputConsumedRef.current = true;
6676
- onInitialInputConsumed?.();
6677
- }
6678
- },
6679
- onSubmit: handleSendMessage,
6680
- attachments,
6681
- onAttachmentsChange: setAttachments,
6682
- placeholder: config.labels.inputPlaceholder,
6683
- disabled: false,
6684
- isGenerating,
6685
- onStopGeneration: callbacks.onStopGeneration,
6686
- enableFileUpload: config.features.enableFileUpload,
6687
- enableAudioRecording: config.features.enableAudioRecording,
6688
- maxAttachments: config.features.maxAttachments,
6689
- maxFileSize: config.features.maxFileSize,
6690
- acceptedFileTypes: config.features.acceptedFileTypes,
6691
- config,
6692
- mentionAgents: participantIds && participantIds.length > 0 ? agentOptions.filter(
6693
- (a) => participantIds.includes(a.id)
6694
- ) : agentOptions,
6695
- targetAgentId,
6696
- showTargetAgentSelector: Boolean(
6697
- isMultiAgentMode && shouldShowAgentSelector && onTargetAgentChange
6698
- ),
6699
- targetAgentSelectorPlaceholder: config.agentSelector?.label || "Select agent",
6700
- onTargetAgentChange
6701
- }
6702
- ) })
6680
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "-mt-8 bg-gradient-to-t from-background via-background/95 to-transparent px-0 pb-[env(safe-area-inset-bottom)] pt-10", children: [
6681
+ activityNotice && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "mx-auto mb-2 w-full max-w-3xl px-3 md:px-2", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
6682
+ "div",
6683
+ {
6684
+ className: activityNotice.tone === "error" ? "rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive" : "rounded-md border border-border bg-muted/70 px-3 py-2 text-sm text-muted-foreground",
6685
+ children: activityNotice.message
6686
+ }
6687
+ ) }),
6688
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
6689
+ ChatInput,
6690
+ {
6691
+ value: inputValue,
6692
+ onChange: (value) => {
6693
+ inputValueRef.current = value;
6694
+ if (initialInputApplied.current && !initialInputConsumedRef.current) {
6695
+ initialInputConsumedRef.current = true;
6696
+ onInitialInputConsumed?.();
6697
+ }
6698
+ },
6699
+ onSubmit: handleSendMessage,
6700
+ attachments,
6701
+ onAttachmentsChange: setAttachments,
6702
+ placeholder: config.labels.inputPlaceholder,
6703
+ disabled: false,
6704
+ isGenerating,
6705
+ onStopGeneration: callbacks.onStopGeneration,
6706
+ enableFileUpload: config.features.enableFileUpload,
6707
+ enableAudioRecording: config.features.enableAudioRecording,
6708
+ maxAttachments: config.features.maxAttachments,
6709
+ maxFileSize: config.features.maxFileSize,
6710
+ acceptedFileTypes: config.features.acceptedFileTypes,
6711
+ config,
6712
+ mentionAgents: participantIds && participantIds.length > 0 ? agentOptions.filter(
6713
+ (a) => participantIds.includes(a.id)
6714
+ ) : agentOptions,
6715
+ targetAgentId,
6716
+ showTargetAgentSelector: Boolean(
6717
+ isMultiAgentMode && shouldShowAgentSelector && onTargetAgentChange
6718
+ ),
6719
+ targetAgentSelectorPlaceholder: config.agentSelector?.label || "Select agent",
6720
+ onTargetAgentChange
6721
+ }
6722
+ )
6723
+ ] })
6703
6724
  ] }),
6704
6725
  config?.customComponent?.component && !isMobile && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
6705
6726
  "div",