@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 +62 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +62 -41
- package/dist/index.js.map +1 -1
- package/dist/styles.css +12 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -163,6 +163,10 @@ interface ChatConfig {
|
|
|
163
163
|
inputPlaceholder?: string;
|
|
164
164
|
sendButton?: string;
|
|
165
165
|
sendMessageTooltip?: string;
|
|
166
|
+
stageMessageTooltip?: string;
|
|
167
|
+
sendNowTooltip?: string;
|
|
168
|
+
stagedMessageLabel?: string;
|
|
169
|
+
discardStagedMessageTooltip?: string;
|
|
166
170
|
newThread?: string;
|
|
167
171
|
deleteThread?: string;
|
|
168
172
|
copyMessage?: string;
|
|
@@ -357,6 +361,10 @@ interface ChatCallbacks {
|
|
|
357
361
|
onThemeChange?: (theme: "light" | "dark" | "system") => void;
|
|
358
362
|
onLogout?: () => void;
|
|
359
363
|
}
|
|
364
|
+
interface ChatActivityNotice {
|
|
365
|
+
tone: "info" | "error";
|
|
366
|
+
message: string;
|
|
367
|
+
}
|
|
360
368
|
interface ChatV2Props {
|
|
361
369
|
messages?: ChatMessage[];
|
|
362
370
|
threads?: ChatThread[];
|
|
@@ -370,6 +378,8 @@ interface ChatV2Props {
|
|
|
370
378
|
isMessagesLoading?: boolean;
|
|
371
379
|
isLoadingOlderMessages?: boolean;
|
|
372
380
|
hasMoreMessagesBefore?: boolean;
|
|
381
|
+
activityNotice?: ChatActivityNotice | null;
|
|
382
|
+
isBackgroundRefreshingMessages?: boolean;
|
|
373
383
|
callbacks?: ChatCallbacks;
|
|
374
384
|
onLoadOlderMessages?: () => void;
|
|
375
385
|
user?: {
|
|
@@ -519,4 +529,4 @@ declare function mergeConfig(_baseConfig: ChatConfig, userConfig?: Partial<ChatC
|
|
|
519
529
|
declare const getAttachmentKindFromMimeType: (mimeType?: string | null) => MediaAttachmentKind;
|
|
520
530
|
declare const getMimeTypeFromDataUrl: (dataUrl: string) => string | null;
|
|
521
531
|
|
|
522
|
-
export { type AgentOption, AssistantActivity, type AssistantActivityBlock, type AssistantActivityItem, type AssistantActivityKind, type AssistantActivityStatus, type AudioAttachment, type ChatCallbacks, type ChatConfig, type ChatHeaderMenuItem, type ChatMarkdownConfig, type ChatMessage, type ChatSender, type ChatState, type ChatThread, type ChatThreadTag, ChatUI, type ChatUserContext, ChatUserContextProvider, type ChatUserMenuItem, type ChatUserMenuSection, type ChatV2Props, type CreateVoiceProvider, type FileUploadProgress, type MediaAttachment, type MediaAttachmentKind, type MemoryItem, type MessageAction, type MessageActionEvent, MessageSenderAvatar, type StateCallback, type StreamingUpdate, type ToolCall, type UserCustomField, type VoiceComposerState, type VoiceProvider, type VoiceProviderHandlers, type VoiceProviderOptions, type VoiceReviewMode, type VoiceSegment, type VoiceTranscript, type VoiceTranscriptMode, defaultChatConfig, getAttachmentKindFromMimeType, getMimeTypeFromDataUrl, mergeConfig, resolveMessageSenderDisplay, useChatUserContext };
|
|
532
|
+
export { type AgentOption, AssistantActivity, type AssistantActivityBlock, type AssistantActivityItem, type AssistantActivityKind, type AssistantActivityStatus, type AudioAttachment, type ChatActivityNotice, type ChatCallbacks, type ChatConfig, type ChatHeaderMenuItem, type ChatMarkdownConfig, type ChatMessage, type ChatSender, type ChatState, type ChatThread, type ChatThreadTag, ChatUI, type ChatUserContext, ChatUserContextProvider, type ChatUserMenuItem, type ChatUserMenuSection, type ChatV2Props, type CreateVoiceProvider, type FileUploadProgress, type MediaAttachment, type MediaAttachmentKind, type MemoryItem, type MessageAction, type MessageActionEvent, MessageSenderAvatar, type StateCallback, type StreamingUpdate, type ToolCall, type UserCustomField, type VoiceComposerState, type VoiceProvider, type VoiceProviderHandlers, type VoiceProviderOptions, type VoiceReviewMode, type VoiceSegment, type VoiceTranscript, type VoiceTranscriptMode, defaultChatConfig, getAttachmentKindFromMimeType, getMimeTypeFromDataUrl, mergeConfig, resolveMessageSenderDisplay, useChatUserContext };
|
package/dist/index.d.ts
CHANGED
|
@@ -163,6 +163,10 @@ interface ChatConfig {
|
|
|
163
163
|
inputPlaceholder?: string;
|
|
164
164
|
sendButton?: string;
|
|
165
165
|
sendMessageTooltip?: string;
|
|
166
|
+
stageMessageTooltip?: string;
|
|
167
|
+
sendNowTooltip?: string;
|
|
168
|
+
stagedMessageLabel?: string;
|
|
169
|
+
discardStagedMessageTooltip?: string;
|
|
166
170
|
newThread?: string;
|
|
167
171
|
deleteThread?: string;
|
|
168
172
|
copyMessage?: string;
|
|
@@ -357,6 +361,10 @@ interface ChatCallbacks {
|
|
|
357
361
|
onThemeChange?: (theme: "light" | "dark" | "system") => void;
|
|
358
362
|
onLogout?: () => void;
|
|
359
363
|
}
|
|
364
|
+
interface ChatActivityNotice {
|
|
365
|
+
tone: "info" | "error";
|
|
366
|
+
message: string;
|
|
367
|
+
}
|
|
360
368
|
interface ChatV2Props {
|
|
361
369
|
messages?: ChatMessage[];
|
|
362
370
|
threads?: ChatThread[];
|
|
@@ -370,6 +378,8 @@ interface ChatV2Props {
|
|
|
370
378
|
isMessagesLoading?: boolean;
|
|
371
379
|
isLoadingOlderMessages?: boolean;
|
|
372
380
|
hasMoreMessagesBefore?: boolean;
|
|
381
|
+
activityNotice?: ChatActivityNotice | null;
|
|
382
|
+
isBackgroundRefreshingMessages?: boolean;
|
|
373
383
|
callbacks?: ChatCallbacks;
|
|
374
384
|
onLoadOlderMessages?: () => void;
|
|
375
385
|
user?: {
|
|
@@ -519,4 +529,4 @@ declare function mergeConfig(_baseConfig: ChatConfig, userConfig?: Partial<ChatC
|
|
|
519
529
|
declare const getAttachmentKindFromMimeType: (mimeType?: string | null) => MediaAttachmentKind;
|
|
520
530
|
declare const getMimeTypeFromDataUrl: (dataUrl: string) => string | null;
|
|
521
531
|
|
|
522
|
-
export { type AgentOption, AssistantActivity, type AssistantActivityBlock, type AssistantActivityItem, type AssistantActivityKind, type AssistantActivityStatus, type AudioAttachment, type ChatCallbacks, type ChatConfig, type ChatHeaderMenuItem, type ChatMarkdownConfig, type ChatMessage, type ChatSender, type ChatState, type ChatThread, type ChatThreadTag, ChatUI, type ChatUserContext, ChatUserContextProvider, type ChatUserMenuItem, type ChatUserMenuSection, type ChatV2Props, type CreateVoiceProvider, type FileUploadProgress, type MediaAttachment, type MediaAttachmentKind, type MemoryItem, type MessageAction, type MessageActionEvent, MessageSenderAvatar, type StateCallback, type StreamingUpdate, type ToolCall, type UserCustomField, type VoiceComposerState, type VoiceProvider, type VoiceProviderHandlers, type VoiceProviderOptions, type VoiceReviewMode, type VoiceSegment, type VoiceTranscript, type VoiceTranscriptMode, defaultChatConfig, getAttachmentKindFromMimeType, getMimeTypeFromDataUrl, mergeConfig, resolveMessageSenderDisplay, useChatUserContext };
|
|
532
|
+
export { type AgentOption, AssistantActivity, type AssistantActivityBlock, type AssistantActivityItem, type AssistantActivityKind, type AssistantActivityStatus, type AudioAttachment, type ChatActivityNotice, type ChatCallbacks, type ChatConfig, type ChatHeaderMenuItem, type ChatMarkdownConfig, type ChatMessage, type ChatSender, type ChatState, type ChatThread, type ChatThreadTag, ChatUI, type ChatUserContext, ChatUserContextProvider, type ChatUserMenuItem, type ChatUserMenuSection, type ChatV2Props, type CreateVoiceProvider, type FileUploadProgress, type MediaAttachment, type MediaAttachmentKind, type MemoryItem, type MessageAction, type MessageActionEvent, MessageSenderAvatar, type StateCallback, type StreamingUpdate, type ToolCall, type UserCustomField, type VoiceComposerState, type VoiceProvider, type VoiceProviderHandlers, type VoiceProviderOptions, type VoiceReviewMode, type VoiceSegment, type VoiceTranscript, type VoiceTranscriptMode, defaultChatConfig, getAttachmentKindFromMimeType, getMimeTypeFromDataUrl, mergeConfig, resolveMessageSenderDisplay, useChatUserContext };
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,10 @@ var defaultChatConfig = {
|
|
|
25
25
|
inputPlaceholder: "Type your message...",
|
|
26
26
|
sendButton: "Send",
|
|
27
27
|
sendMessageTooltip: "Send message",
|
|
28
|
+
stageMessageTooltip: "Stage message",
|
|
29
|
+
sendNowTooltip: "Send now",
|
|
30
|
+
stagedMessageLabel: "Not sent yet",
|
|
31
|
+
discardStagedMessageTooltip: "Discard",
|
|
28
32
|
newThread: "New Conversation",
|
|
29
33
|
deleteThread: "Delete Conversation",
|
|
30
34
|
copyMessage: "Copy",
|
|
@@ -5285,7 +5289,8 @@ var ChatInput = memo4(function ChatInput2({
|
|
|
5285
5289
|
config?.labels?.attachmentsCount,
|
|
5286
5290
|
"{{count}}/{{max}} attachments",
|
|
5287
5291
|
{ count: staged.attachments.length, max: maxAttachments }
|
|
5288
|
-
) })
|
|
5292
|
+
) }),
|
|
5293
|
+
/* @__PURE__ */ jsx25("div", { className: "text-xs text-muted-foreground", children: config?.labels?.stagedMessageLabel || "Not sent yet" })
|
|
5289
5294
|
] }),
|
|
5290
5295
|
/* @__PURE__ */ jsxs15(Tooltip, { children: [
|
|
5291
5296
|
/* @__PURE__ */ jsx25(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx25(
|
|
@@ -5298,7 +5303,7 @@ var ChatInput = memo4(function ChatInput2({
|
|
|
5298
5303
|
children: /* @__PURE__ */ jsx25(Send2, { className: "h-4 w-4" })
|
|
5299
5304
|
}
|
|
5300
5305
|
) }),
|
|
5301
|
-
/* @__PURE__ */ jsx25(TooltipContent, { children: config?.labels?.sendMessageTooltip })
|
|
5306
|
+
/* @__PURE__ */ jsx25(TooltipContent, { children: config?.labels?.sendNowTooltip || config?.labels?.sendMessageTooltip })
|
|
5302
5307
|
] }),
|
|
5303
5308
|
/* @__PURE__ */ jsxs15(Tooltip, { children: [
|
|
5304
5309
|
/* @__PURE__ */ jsx25(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx25(
|
|
@@ -5312,7 +5317,7 @@ var ChatInput = memo4(function ChatInput2({
|
|
|
5312
5317
|
children: /* @__PURE__ */ jsx25(X5, { className: "h-4 w-4" })
|
|
5313
5318
|
}
|
|
5314
5319
|
) }),
|
|
5315
|
-
/* @__PURE__ */ jsx25(TooltipContent, { children: config?.labels?.voiceCancel })
|
|
5320
|
+
/* @__PURE__ */ jsx25(TooltipContent, { children: config?.labels?.discardStagedMessageTooltip || config?.labels?.voiceCancel })
|
|
5316
5321
|
] })
|
|
5317
5322
|
]
|
|
5318
5323
|
},
|
|
@@ -5437,7 +5442,7 @@ var ChatInput = memo4(function ChatInput2({
|
|
|
5437
5442
|
children: /* @__PURE__ */ jsx25(Send2, { className: "h-4 w-4" })
|
|
5438
5443
|
}
|
|
5439
5444
|
) }),
|
|
5440
|
-
/* @__PURE__ */ jsx25(TooltipContent, { children: config?.labels?.sendMessageTooltip })
|
|
5445
|
+
/* @__PURE__ */ jsx25(TooltipContent, { children: config?.labels?.stageMessageTooltip || config?.labels?.sendMessageTooltip })
|
|
5441
5446
|
] }),
|
|
5442
5447
|
/* @__PURE__ */ jsxs15(Tooltip, { children: [
|
|
5443
5448
|
/* @__PURE__ */ jsx25(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx25(
|
|
@@ -6069,6 +6074,8 @@ var ChatUI = ({
|
|
|
6069
6074
|
isMessagesLoading = false,
|
|
6070
6075
|
isLoadingOlderMessages = false,
|
|
6071
6076
|
hasMoreMessagesBefore = false,
|
|
6077
|
+
activityNotice = null,
|
|
6078
|
+
isBackgroundRefreshingMessages = false,
|
|
6072
6079
|
callbacks = {},
|
|
6073
6080
|
onLoadOlderMessages,
|
|
6074
6081
|
user,
|
|
@@ -6204,7 +6211,9 @@ var ChatUI = ({
|
|
|
6204
6211
|
prevMessageCountRef.current = groupedMessages.length;
|
|
6205
6212
|
return;
|
|
6206
6213
|
}
|
|
6207
|
-
const
|
|
6214
|
+
const previousMessageCount = prevMessageCountRef.current;
|
|
6215
|
+
const wasEmpty = previousMessageCount === 0;
|
|
6216
|
+
const didAppendMessages = groupedMessages.length > previousMessageCount;
|
|
6208
6217
|
prevMessageCountRef.current = groupedMessages.length;
|
|
6209
6218
|
if (wasEmpty) {
|
|
6210
6219
|
requestAnimationFrame(() => {
|
|
@@ -6216,6 +6225,9 @@ var ChatUI = ({
|
|
|
6216
6225
|
});
|
|
6217
6226
|
return;
|
|
6218
6227
|
}
|
|
6228
|
+
if (isBackgroundRefreshingMessages && !didAppendMessages) {
|
|
6229
|
+
return;
|
|
6230
|
+
}
|
|
6219
6231
|
if (!state.isAtBottom) return;
|
|
6220
6232
|
requestAnimationFrame(() => {
|
|
6221
6233
|
const viewport = scrollAreaRef.current;
|
|
@@ -6226,7 +6238,7 @@ var ChatUI = ({
|
|
|
6226
6238
|
viewport.scrollTop = viewport.scrollHeight;
|
|
6227
6239
|
}
|
|
6228
6240
|
});
|
|
6229
|
-
}, [groupedMessages, state.isAtBottom, virtualizer]);
|
|
6241
|
+
}, [groupedMessages, isBackgroundRefreshingMessages, state.isAtBottom, virtualizer]);
|
|
6230
6242
|
useEffect10(() => {
|
|
6231
6243
|
const viewport = scrollAreaRef.current;
|
|
6232
6244
|
if (!viewport) return;
|
|
@@ -6717,41 +6729,50 @@ var ChatUI = ({
|
|
|
6717
6729
|
] })
|
|
6718
6730
|
}
|
|
6719
6731
|
),
|
|
6720
|
-
/* @__PURE__ */
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
|
|
6727
|
-
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6737
|
-
|
|
6738
|
-
|
|
6739
|
-
|
|
6740
|
-
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
6752
|
-
|
|
6753
|
-
|
|
6754
|
-
|
|
6732
|
+
/* @__PURE__ */ jsxs18("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: [
|
|
6733
|
+
activityNotice && /* @__PURE__ */ jsx28("div", { className: "mx-auto mb-2 w-full max-w-3xl px-3 md:px-2", children: /* @__PURE__ */ jsx28(
|
|
6734
|
+
"div",
|
|
6735
|
+
{
|
|
6736
|
+
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",
|
|
6737
|
+
children: activityNotice.message
|
|
6738
|
+
}
|
|
6739
|
+
) }),
|
|
6740
|
+
/* @__PURE__ */ jsx28(
|
|
6741
|
+
ChatInput,
|
|
6742
|
+
{
|
|
6743
|
+
value: inputValue,
|
|
6744
|
+
onChange: (value) => {
|
|
6745
|
+
inputValueRef.current = value;
|
|
6746
|
+
if (initialInputApplied.current && !initialInputConsumedRef.current) {
|
|
6747
|
+
initialInputConsumedRef.current = true;
|
|
6748
|
+
onInitialInputConsumed?.();
|
|
6749
|
+
}
|
|
6750
|
+
},
|
|
6751
|
+
onSubmit: handleSendMessage,
|
|
6752
|
+
attachments,
|
|
6753
|
+
onAttachmentsChange: setAttachments,
|
|
6754
|
+
placeholder: config.labels.inputPlaceholder,
|
|
6755
|
+
disabled: false,
|
|
6756
|
+
isGenerating,
|
|
6757
|
+
onStopGeneration: callbacks.onStopGeneration,
|
|
6758
|
+
enableFileUpload: config.features.enableFileUpload,
|
|
6759
|
+
enableAudioRecording: config.features.enableAudioRecording,
|
|
6760
|
+
maxAttachments: config.features.maxAttachments,
|
|
6761
|
+
maxFileSize: config.features.maxFileSize,
|
|
6762
|
+
acceptedFileTypes: config.features.acceptedFileTypes,
|
|
6763
|
+
config,
|
|
6764
|
+
mentionAgents: participantIds && participantIds.length > 0 ? agentOptions.filter(
|
|
6765
|
+
(a) => participantIds.includes(a.id)
|
|
6766
|
+
) : agentOptions,
|
|
6767
|
+
targetAgentId,
|
|
6768
|
+
showTargetAgentSelector: Boolean(
|
|
6769
|
+
isMultiAgentMode && shouldShowAgentSelector && onTargetAgentChange
|
|
6770
|
+
),
|
|
6771
|
+
targetAgentSelectorPlaceholder: config.agentSelector?.label || "Select agent",
|
|
6772
|
+
onTargetAgentChange
|
|
6773
|
+
}
|
|
6774
|
+
)
|
|
6775
|
+
] })
|
|
6755
6776
|
] }),
|
|
6756
6777
|
config?.customComponent?.component && !isMobile && /* @__PURE__ */ jsx28(
|
|
6757
6778
|
"div",
|