@cometchat/chat-uikit-react-native 5.1.2 → 5.2.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/android/.gradle/7.4/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.4/gc.properties +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/lib/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.d.ts +40 -0
- package/lib/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.js +467 -0
- package/lib/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.js.map +1 -0
- package/lib/CometChatAIAssistantChatHistory/Skeleton.d.ts +24 -0
- package/lib/CometChatAIAssistantChatHistory/Skeleton.js +130 -0
- package/lib/CometChatAIAssistantChatHistory/Skeleton.js.map +1 -0
- package/lib/CometChatAIAssistantChatHistory/index.d.ts +1 -0
- package/lib/CometChatAIAssistantChatHistory/index.js +2 -0
- package/lib/CometChatAIAssistantChatHistory/index.js.map +1 -0
- package/lib/CometChatAIAssistantChatHistory/style.d.ts +30 -0
- package/lib/CometChatAIAssistantChatHistory/style.js +122 -0
- package/lib/CometChatAIAssistantChatHistory/style.js.map +1 -0
- package/lib/CometChatConversations/CometChatConversations.js +26 -5
- package/lib/CometChatConversations/CometChatConversations.js.map +1 -1
- package/lib/CometChatMessageComposer/CometChatMessageComposer.d.ts +7 -0
- package/lib/CometChatMessageComposer/CometChatMessageComposer.js +101 -13
- package/lib/CometChatMessageComposer/CometChatMessageComposer.js.map +1 -1
- package/lib/CometChatMessageHeader/CometChatMessageHeader.d.ts +16 -0
- package/lib/CometChatMessageHeader/CometChatMessageHeader.js +63 -13
- package/lib/CometChatMessageHeader/CometChatMessageHeader.js.map +1 -1
- package/lib/CometChatMessageList/CometChatMessageList.d.ts +33 -0
- package/lib/CometChatMessageList/CometChatMessageList.js +535 -76
- package/lib/CometChatMessageList/CometChatMessageList.js.map +1 -1
- package/lib/CometChatMessageList/style.js +74 -2
- package/lib/CometChatMessageList/style.js.map +1 -1
- package/lib/calls/CometChatIncomingCall/CometChatIncomingCall.js +6 -12
- package/lib/calls/CometChatIncomingCall/CometChatIncomingCall.js.map +1 -1
- package/lib/calls/CometChatOutgoingCall/CometChatOutgoingCall.js +4 -3
- package/lib/calls/CometChatOutgoingCall/CometChatOutgoingCall.js.map +1 -1
- package/lib/extensions/Polls/Polls.js +38 -17
- package/lib/extensions/Polls/Polls.js.map +1 -1
- package/lib/index.d.ts +5 -1
- package/lib/index.js +6 -2
- package/lib/index.js.map +1 -1
- package/lib/shared/constants/UIKitConstants.d.ts +16 -0
- package/lib/shared/constants/UIKitConstants.js +16 -0
- package/lib/shared/constants/UIKitConstants.js.map +1 -1
- package/lib/shared/events/CometChatMessageEvents/index.d.ts +3 -0
- package/lib/shared/events/CometChatMessageEvents/index.js +3 -0
- package/lib/shared/events/CometChatMessageEvents/index.js.map +1 -1
- package/lib/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.js +3 -0
- package/lib/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.js.map +1 -1
- package/lib/shared/events/CometChatUIEventHandler/Listener.d.ts +3 -1
- package/lib/shared/events/CometChatUIEventHandler/Listener.js +4 -1
- package/lib/shared/events/CometChatUIEventHandler/Listener.js.map +1 -1
- package/lib/shared/events/ListenerInitializer.d.ts +3 -1
- package/lib/shared/events/ListenerInitializer.js +5 -1
- package/lib/shared/events/ListenerInitializer.js.map +1 -1
- package/lib/shared/events/messages.d.ts +2 -1
- package/lib/shared/events/messages.js +1 -0
- package/lib/shared/events/messages.js.map +1 -1
- package/lib/shared/framework/DataSource.d.ts +3 -1
- package/lib/shared/framework/DataSourceDecorator.d.ts +3 -1
- package/lib/shared/framework/DataSourceDecorator.js +8 -2
- package/lib/shared/framework/DataSourceDecorator.js.map +1 -1
- package/lib/shared/framework/MessageDataSource.d.ts +6 -0
- package/lib/shared/framework/MessageDataSource.js +64 -1
- package/lib/shared/framework/MessageDataSource.js.map +1 -1
- package/lib/shared/icons/components/ai-chat-history.d.ts +8 -0
- package/lib/shared/icons/components/ai-chat-history.js +9 -0
- package/lib/shared/icons/components/ai-chat-history.js.map +1 -0
- package/lib/shared/icons/components/ai-copy-option.d.ts +8 -0
- package/lib/shared/icons/components/ai-copy-option.js +9 -0
- package/lib/shared/icons/components/ai-copy-option.js.map +1 -0
- package/lib/shared/icons/components/ai-new-chat.d.ts +8 -0
- package/lib/shared/icons/components/ai-new-chat.js +9 -0
- package/lib/shared/icons/components/ai-new-chat.js.map +1 -0
- package/lib/shared/icons/components/ai-send-button.d.ts +8 -0
- package/lib/shared/icons/components/ai-send-button.js +9 -0
- package/lib/shared/icons/components/ai-send-button.js.map +1 -0
- package/lib/shared/icons/components/right-arrow.d.ts +3 -0
- package/lib/shared/icons/components/right-arrow.js +6 -0
- package/lib/shared/icons/components/right-arrow.js.map +1 -0
- package/lib/shared/icons/components/stop-fill.js +8 -7
- package/lib/shared/icons/components/stop-fill.js.map +1 -1
- package/lib/shared/icons/icon-mapping.d.ts +11 -0
- package/lib/shared/icons/icon-mapping.js +11 -0
- package/lib/shared/icons/icon-mapping.js.map +1 -1
- package/lib/shared/modals/CometChatAIAssistantTools.d.ts +47 -0
- package/lib/shared/modals/CometChatAIAssistantTools.js +44 -0
- package/lib/shared/modals/CometChatAIAssistantTools.js.map +1 -0
- package/lib/shared/modals/StreamMessage.d.ts +4 -0
- package/lib/shared/modals/StreamMessage.js +11 -0
- package/lib/shared/modals/StreamMessage.js.map +1 -0
- package/lib/shared/modals/index.d.ts +3 -1
- package/lib/shared/modals/index.js +3 -1
- package/lib/shared/modals/index.js.map +1 -1
- package/lib/shared/resources/CometChatLocalizeNew/CometChatLocalizationHelper.d.ts +126 -0
- package/lib/shared/resources/CometChatLocalizeNew/resources/de/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/en/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/es/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/it/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +7 -1
- package/lib/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +7 -1
- package/lib/shared/services/stream-message.service.d.ts +84 -0
- package/lib/shared/services/stream-message.service.js +406 -0
- package/lib/shared/services/stream-message.service.js.map +1 -0
- package/lib/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.d.ts +9 -0
- package/lib/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.js +248 -0
- package/lib/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.js.map +1 -0
- package/lib/shared/views/CometChatAIAssistantMessageBubble/index.d.ts +3 -0
- package/lib/shared/views/CometChatAIAssistantMessageBubble/index.js +4 -0
- package/lib/shared/views/CometChatAIAssistantMessageBubble/index.js.map +1 -0
- package/lib/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.js +5 -2
- package/lib/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.js.map +1 -1
- package/lib/shared/views/CometChatImageBubble/CometChatImageLoader.js +1 -1
- package/lib/shared/views/CometChatImageBubble/CometChatImageLoader.js.map +1 -1
- package/lib/shared/views/CometChatImageViewerModal/ImageViewerModal.js +52 -32
- package/lib/shared/views/CometChatImageViewerModal/ImageViewerModal.js.map +1 -1
- package/lib/shared/views/CometChatSendButtonView/CometChatSendButtonView.d.ts +10 -0
- package/lib/shared/views/CometChatSendButtonView/CometChatSendButtonView.js +54 -0
- package/lib/shared/views/CometChatSendButtonView/CometChatSendButtonView.js.map +1 -0
- package/lib/shared/views/CometChatSendButtonView/index.d.ts +1 -0
- package/lib/shared/views/CometChatSendButtonView/index.js +2 -0
- package/lib/shared/views/CometChatSendButtonView/index.js.map +1 -0
- package/lib/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.d.ts +8 -0
- package/lib/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.js +436 -0
- package/lib/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.js.map +1 -0
- package/lib/shared/views/CometChatStreamMessageBubble/index.d.ts +3 -0
- package/lib/shared/views/CometChatStreamMessageBubble/index.js +3 -0
- package/lib/shared/views/CometChatStreamMessageBubble/index.js.map +1 -0
- package/lib/shared/views/CometChatTextBubble/CometChatTextBubble.d.ts +14 -6
- package/lib/shared/views/CometChatTextBubble/CometChatTextBubble.js +82 -57
- package/lib/shared/views/CometChatTextBubble/CometChatTextBubble.js.map +1 -1
- package/lib/theme/context.d.ts +96 -15
- package/lib/theme/type.d.ts +14 -1
- package/package.json +5 -2
- package/src/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.tsx +627 -0
- package/src/CometChatAIAssistantChatHistory/Skeleton.tsx +228 -0
- package/src/CometChatAIAssistantChatHistory/index.ts +2 -0
- package/src/CometChatAIAssistantChatHistory/style.ts +160 -0
- package/src/CometChatConversations/CometChatConversations.tsx +36 -10
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +137 -19
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +106 -18
- package/src/CometChatMessageList/CometChatMessageList.tsx +619 -72
- package/src/CometChatMessageList/style.ts +74 -2
- package/src/index.ts +31 -1
- package/src/shared/constants/UIKitConstants.ts +17 -0
- package/src/shared/events/CometChatMessageEvents/index.ts +3 -1
- package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +3 -0
- package/src/shared/events/CometChatUIEventHandler/Listener.ts +4 -0
- package/src/shared/events/ListenerInitializer.ts +6 -1
- package/src/shared/events/messages.ts +1 -0
- package/src/shared/framework/DataSource.ts +4 -2
- package/src/shared/framework/DataSourceDecorator.tsx +10 -2
- package/src/shared/framework/MessageDataSource.tsx +75 -2
- package/src/shared/icons/Icon.tsx +1 -1
- package/src/shared/icons/components/ai-chat-history.tsx +21 -0
- package/src/shared/icons/components/ai-copy-option.tsx +21 -0
- package/src/shared/icons/components/ai-new-chat.tsx +21 -0
- package/src/shared/icons/components/ai-send-button.tsx +24 -0
- package/src/shared/icons/components/right-arrow.tsx +13 -0
- package/src/shared/icons/components/stop-fill.tsx +14 -12
- package/src/shared/icons/icon-mapping.tsx +14 -0
- package/src/shared/modals/CometChatAIAssistantTools.ts +65 -0
- package/src/shared/modals/StreamMessage.ts +12 -0
- package/src/shared/modals/index.ts +5 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +7 -2
- package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +7 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +7 -1
- package/src/shared/services/stream-message.service.ts +470 -0
- package/src/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.tsx +262 -0
- package/src/shared/views/CometChatAIAssistantMessageBubble/index.ts +4 -0
- package/src/shared/views/CometChatSendButtonView/CometChatSendButtonView.tsx +86 -0
- package/src/shared/views/CometChatSendButtonView/index.ts +1 -0
- package/src/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.tsx +493 -0
- package/src/shared/views/CometChatStreamMessageBubble/index.ts +9 -0
- package/src/theme/type.ts +14 -1
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
View,
|
|
17
17
|
ViewStyle,
|
|
18
18
|
} from "react-native";
|
|
19
|
+
import { startStreamingForRunId, stopStreamingForRunId, streamingState$ } from "../shared/services/stream-message.service";
|
|
19
20
|
import {
|
|
20
21
|
CometChatActionSheet,
|
|
21
22
|
CometChatBottomSheet,
|
|
@@ -46,6 +47,7 @@ import { MessageEvents } from "../shared/events";
|
|
|
46
47
|
import { CometChatUIEventHandler } from "../shared/events/CometChatUIEventHandler/CometChatUIEventHandler";
|
|
47
48
|
import { CometChatMessageComposerAction, DeepPartial } from "../shared/helper/types";
|
|
48
49
|
import { Icon } from "../shared/icons/Icon";
|
|
50
|
+
import { CometChatSendButtonView } from "../shared/views/CometChatSendButtonView/CometChatSendButtonView";
|
|
49
51
|
import {
|
|
50
52
|
getUnixTimestampInMilliseconds,
|
|
51
53
|
messageStatus,
|
|
@@ -431,6 +433,13 @@ export interface CometChatMessageComposerInterface {
|
|
|
431
433
|
* @default "left"
|
|
432
434
|
*/
|
|
433
435
|
auxiliaryButtonsAlignment?: "left" | "right";
|
|
436
|
+
/**
|
|
437
|
+
* Custom send button view for AI agents (only applies to @agentic users)
|
|
438
|
+
*/
|
|
439
|
+
AgentSendButtonView?: React.ComponentType<{
|
|
440
|
+
isButtonDisabled: boolean;
|
|
441
|
+
composerRef: any;
|
|
442
|
+
}>;
|
|
434
443
|
}
|
|
435
444
|
|
|
436
445
|
export const CometChatMessageComposer = React.forwardRef(
|
|
@@ -446,7 +455,7 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
446
455
|
group,
|
|
447
456
|
disableSoundForOutgoingMessages = true,
|
|
448
457
|
customSoundForOutgoingMessage,
|
|
449
|
-
disableTypingEvents,
|
|
458
|
+
disableTypingEvents: propDisableTypingEvents,
|
|
450
459
|
initialComposertext,
|
|
451
460
|
HeaderView,
|
|
452
461
|
onTextChange,
|
|
@@ -457,10 +466,10 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
457
466
|
style = {},
|
|
458
467
|
onSendButtonPress,
|
|
459
468
|
onError,
|
|
460
|
-
hideVoiceRecordingButton,
|
|
469
|
+
hideVoiceRecordingButton: propHideVoiceRecordingButton,
|
|
461
470
|
keyboardAvoidingViewProps,
|
|
462
471
|
textFormatters,
|
|
463
|
-
disableMentions,
|
|
472
|
+
disableMentions: propDisableMentions,
|
|
464
473
|
imageQuality = 20,
|
|
465
474
|
hideCameraOption = false,
|
|
466
475
|
hideImageAttachmentOption = false,
|
|
@@ -470,19 +479,45 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
470
479
|
hidePollsAttachmentOption = false,
|
|
471
480
|
hideCollaborativeDocumentOption = false,
|
|
472
481
|
hideCollaborativeWhiteboardOption = false,
|
|
473
|
-
hideAttachmentButton = false,
|
|
474
|
-
hideStickersButton = false,
|
|
482
|
+
hideAttachmentButton: propHideAttachmentButton = false,
|
|
483
|
+
hideStickersButton: propHideStickersButton = false,
|
|
475
484
|
hideSendButton = false,
|
|
476
485
|
hideAuxiliaryButtons = false,
|
|
477
486
|
addAttachmentOptions,
|
|
478
487
|
auxiliaryButtonsAlignment = "left",
|
|
488
|
+
AgentSendButtonView,
|
|
479
489
|
} = props;
|
|
480
490
|
|
|
491
|
+
// Helper function to check if user is agentic
|
|
492
|
+
const isAgenticUser = useCallback(() => {
|
|
493
|
+
return user?.getRole?.() === '@agentic';
|
|
494
|
+
}, [user]);
|
|
495
|
+
|
|
496
|
+
// Apply automatic hiding for @agentic users
|
|
497
|
+
const disableTypingEvents = isAgenticUser() ? true : propDisableTypingEvents;
|
|
498
|
+
const disableMentions = isAgenticUser() ? true : propDisableMentions;
|
|
499
|
+
const hideAttachmentButton = isAgenticUser() ? true : propHideAttachmentButton;
|
|
500
|
+
const hideStickersButton = isAgenticUser() ? true : propHideStickersButton;
|
|
501
|
+
const hideVoiceRecordingButton = isAgenticUser() ? true : propHideVoiceRecordingButton;
|
|
502
|
+
|
|
481
503
|
const composerIdMap = new Map().set("parentMessageId", parentMessageId);
|
|
504
|
+
const parentMessageIdRef = useRef<string | null>(null);
|
|
482
505
|
|
|
483
506
|
const mergedComposerStyle: CometChatTheme["messageComposerStyles"] = useMemo(() => {
|
|
484
|
-
|
|
485
|
-
|
|
507
|
+
const mergedStyle = deepMerge(theme.messageComposerStyles, style);
|
|
508
|
+
if (isAgenticUser()) {
|
|
509
|
+
return {
|
|
510
|
+
...mergedStyle,
|
|
511
|
+
messageInputStyles: {
|
|
512
|
+
...mergedStyle.messageInputStyles,
|
|
513
|
+
dividerStyle: {
|
|
514
|
+
display: 'none'
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
return mergedStyle;
|
|
520
|
+
}, [theme, style, isAgenticUser]);
|
|
486
521
|
|
|
487
522
|
const defaultAuxiliaryButtonOptions = useMemo(() => {
|
|
488
523
|
if (hideAuxiliaryButtons) return [];
|
|
@@ -515,6 +550,15 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
515
550
|
const [inputMessage, setInputMessage] = React.useState<string | JSX.Element>(
|
|
516
551
|
initialComposertext || ""
|
|
517
552
|
);
|
|
553
|
+
const [isStreaming, setIsStreaming] = React.useState(false);
|
|
554
|
+
|
|
555
|
+
useEffect(() => {
|
|
556
|
+
const sub = streamingState$.subscribe((streaming) => {
|
|
557
|
+
setIsStreaming(streaming);
|
|
558
|
+
if (!streaming) setShowStopButton(false);
|
|
559
|
+
});
|
|
560
|
+
return () => sub.unsubscribe();
|
|
561
|
+
}, []);
|
|
518
562
|
const [showActionSheet, setShowActionSheet] = React.useState(false);
|
|
519
563
|
const [showRecordAudio, setShowRecordAudio] = React.useState(false);
|
|
520
564
|
const [actionSheetItems, setActionSheetItems] = React.useState<any[]>([]);
|
|
@@ -533,9 +577,15 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
533
577
|
const [originalText, setOriginalText] = React.useState<string>("");
|
|
534
578
|
const [hasEdited, setHasEdited] = React.useState<boolean>(false);
|
|
535
579
|
const [plainText, setPlainText] = React.useState(initialComposertext ?? "");
|
|
536
|
-
|
|
537
580
|
const bottomSheetRef = React.useRef<any>(null);
|
|
538
|
-
|
|
581
|
+
const [showStopButton, setShowStopButton] = React.useState(false);
|
|
582
|
+
|
|
583
|
+
// Reset streaming state when component mounts
|
|
584
|
+
useEffect(() => {
|
|
585
|
+
setShowStopButton(false);
|
|
586
|
+
setIsStreaming(false);
|
|
587
|
+
}, []);
|
|
588
|
+
|
|
539
589
|
useLayoutEffect(() => {
|
|
540
590
|
if (Platform.OS === "ios") {
|
|
541
591
|
if (Number.isInteger(commonVars.safeAreaInsets.top)) {
|
|
@@ -559,6 +609,18 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
559
609
|
*/
|
|
560
610
|
React.useImperativeHandle(ref, () => ({
|
|
561
611
|
previewMessageForEdit: previewMessage,
|
|
612
|
+
sendTextMessage,
|
|
613
|
+
getText: () => messageInputRef.current?.getText?.() ?? "",
|
|
614
|
+
clear: () => messageInputRef.current?.clear?.(),
|
|
615
|
+
resetStreaming: () => {
|
|
616
|
+
setShowStopButton(false);
|
|
617
|
+
setIsStreaming(false);
|
|
618
|
+
try {
|
|
619
|
+
stopStreamingForRunId();
|
|
620
|
+
} catch (error) {
|
|
621
|
+
console.log(error);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
562
624
|
}));
|
|
563
625
|
|
|
564
626
|
useLayoutEffect(() => {
|
|
@@ -741,6 +803,7 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
741
803
|
};
|
|
742
804
|
|
|
743
805
|
const sendTextMessage = () => {
|
|
806
|
+
setShowStopButton(true);
|
|
744
807
|
//ignore sending new message
|
|
745
808
|
if (messagePreview != null) {
|
|
746
809
|
editMessage(messagePreview.message);
|
|
@@ -748,10 +811,8 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
748
811
|
}
|
|
749
812
|
|
|
750
813
|
let finalTextInput = getRegexString(plainTextInput.current);
|
|
751
|
-
// Trim the trailing spaces and store in a variable
|
|
752
814
|
let trimmedTextInput = finalTextInput.trim();
|
|
753
815
|
|
|
754
|
-
// Create the text message with the trimmed text
|
|
755
816
|
let textMessage = new CometChat.TextMessage(
|
|
756
817
|
chatWithId.current,
|
|
757
818
|
trimmedTextInput,
|
|
@@ -763,7 +824,11 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
763
824
|
// Use the trimmed text here as well
|
|
764
825
|
textMessage.setText(trimmedTextInput);
|
|
765
826
|
textMessage.setMuid(String(getUnixTimestampInMilliseconds()));
|
|
766
|
-
parentMessageId
|
|
827
|
+
const currentParentId = parentMessageId || (isAgenticUser() ? parentMessageIdRef.current : null);
|
|
828
|
+
|
|
829
|
+
if (currentParentId) {
|
|
830
|
+
textMessage.setParentMessageId(currentParentId as number);
|
|
831
|
+
}
|
|
767
832
|
|
|
768
833
|
allFormatters.current.forEach((item) => {
|
|
769
834
|
textMessage = item.handlePreMessageSend(textMessage);
|
|
@@ -792,6 +857,16 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
792
857
|
|
|
793
858
|
CometChat.sendMessage(textMessage)
|
|
794
859
|
.then((message: any) => {
|
|
860
|
+
if (isAgenticUser() && !parentMessageId && message?.getId) {
|
|
861
|
+
const messageId = typeof message.getId() === 'string' ? Number(message.getId()) : message.getId();
|
|
862
|
+
if (!isNaN(messageId) && !parentMessageIdRef.current) {
|
|
863
|
+
parentMessageIdRef.current = messageId;
|
|
864
|
+
}
|
|
865
|
+
if (messageId && !isNaN(messageId)) {
|
|
866
|
+
startStreamingForRunId(String(messageId));
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
|
|
795
870
|
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
|
|
796
871
|
message: message,
|
|
797
872
|
status: messageStatus.success,
|
|
@@ -1019,18 +1094,27 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1019
1094
|
};
|
|
1020
1095
|
|
|
1021
1096
|
const voiceRecoringButtonElem = useMemo(() => {
|
|
1022
|
-
|
|
1097
|
+
const isAgenticUser = user?.getRole?.() === '@agentic';
|
|
1098
|
+
|
|
1099
|
+
return (hideVoiceRecordingButton || isAgenticUser) ? undefined : (
|
|
1023
1100
|
<RecordAudioButtonView
|
|
1024
1101
|
icon={mergedComposerStyle.voiceRecordingIcon as ImageSourcePropType | JSX.Element}
|
|
1025
1102
|
iconStyle={mergedComposerStyle.voiceRecordingIconStyle as ImageStyle}
|
|
1026
1103
|
/>
|
|
1027
1104
|
);
|
|
1028
|
-
}, [hideVoiceRecordingButton, mergedComposerStyle]);
|
|
1105
|
+
}, [hideVoiceRecordingButton, mergedComposerStyle, user]);
|
|
1029
1106
|
|
|
1030
1107
|
const AuxiliaryButtonViewElem = useCallback(() => {
|
|
1108
|
+
const isAgenticUser = user?.getRole?.() === '@agentic';
|
|
1109
|
+
|
|
1031
1110
|
if (AuxiliaryButtonView)
|
|
1032
1111
|
return <AuxiliaryButtonView user={user} group={group} composerId={id!} />;
|
|
1033
|
-
|
|
1112
|
+
|
|
1113
|
+
if (isAgenticUser) {
|
|
1114
|
+
return <></>;
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
if (defaultAuxiliaryButtonOptions)
|
|
1034
1118
|
return (
|
|
1035
1119
|
<View
|
|
1036
1120
|
style={{
|
|
@@ -1044,12 +1128,44 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1044
1128
|
);
|
|
1045
1129
|
|
|
1046
1130
|
return <></>;
|
|
1047
|
-
}, [defaultAuxiliaryButtonOptions]);
|
|
1131
|
+
}, [defaultAuxiliaryButtonOptions, user, AuxiliaryButtonView, group, id, theme]);
|
|
1132
|
+
|
|
1133
|
+
const DefaultAgentSendButtonView = useCallback(
|
|
1134
|
+
({ isButtonDisabled, composerRef }: { isButtonDisabled: boolean; composerRef: any }) => (
|
|
1135
|
+
<CometChatSendButtonView
|
|
1136
|
+
isButtonDisabled={isButtonDisabled}
|
|
1137
|
+
composerRef={composerRef}
|
|
1138
|
+
isStreaming={isStreaming}
|
|
1139
|
+
showStopButton={showStopButton}
|
|
1140
|
+
setShowStopButton={setShowStopButton}
|
|
1141
|
+
/>
|
|
1142
|
+
),
|
|
1143
|
+
[isStreaming, showStopButton]
|
|
1144
|
+
);
|
|
1048
1145
|
|
|
1049
1146
|
const SendButtonViewElem = useCallback(() => {
|
|
1050
1147
|
if (hideSendButton) return <></>;
|
|
1148
|
+
|
|
1149
|
+
const isAgenticUserCheck = isAgenticUser();
|
|
1150
|
+
|
|
1151
|
+
if (isAgenticUserCheck) {
|
|
1152
|
+
const disabled = isStreaming || plainText.trim().length === 0 || (messagePreview && !hasEdited);
|
|
1153
|
+
const SendButtonComponent = DefaultAgentSendButtonView;
|
|
1154
|
+
// Create a ref-like object that matches what CometChatSendButtonView expects
|
|
1155
|
+
const composerRef = {
|
|
1156
|
+
current: {
|
|
1157
|
+
sendTextMessage: () => {
|
|
1158
|
+
if (!disabled) {
|
|
1159
|
+
sendTextMessage();
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
};
|
|
1164
|
+
return <SendButtonComponent isButtonDisabled={disabled} composerRef={composerRef} />;
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1051
1167
|
if (SendButtonView) return <SendButtonView user={user} group={group} composerId={id!} />;
|
|
1052
|
-
const disabled = plainText.trim().length === 0 || (messagePreview && !hasEdited);
|
|
1168
|
+
const disabled = isStreaming || plainText.trim().length === 0 || (messagePreview && !hasEdited);
|
|
1053
1169
|
return (
|
|
1054
1170
|
<TouchableOpacity
|
|
1055
1171
|
onPress={sendTextMessage}
|
|
@@ -1076,7 +1192,7 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1076
1192
|
/>
|
|
1077
1193
|
</TouchableOpacity>
|
|
1078
1194
|
);
|
|
1079
|
-
}, [mergedComposerStyle, inputMessage, plainText, messagePreview, hasEdited]);
|
|
1195
|
+
}, [mergedComposerStyle, inputMessage, plainText, messagePreview, hasEdited, isStreaming, DefaultAgentSendButtonView, user, isAgenticUser, sendTextMessage, hideSendButton, SendButtonView]);
|
|
1080
1196
|
|
|
1081
1197
|
//fetch logged in user
|
|
1082
1198
|
useEffect(() => {
|
|
@@ -1278,6 +1394,8 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1278
1394
|
|
|
1279
1395
|
inputValueRef.current = text?.text;
|
|
1280
1396
|
setInputMessage(text?.text);
|
|
1397
|
+
plainTextInput.current = text?.text || "";
|
|
1398
|
+
setPlainText(text?.text || "");
|
|
1281
1399
|
},
|
|
1282
1400
|
ccSuggestionData(item: { id: string | number; data: Array<SuggestionItem> }) {
|
|
1283
1401
|
if (activeCharacter.current && id === item?.id) {
|
|
@@ -1964,7 +2082,7 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1964
2082
|
<CometChatMessageInput
|
|
1965
2083
|
messageInputRef={messageInputRef}
|
|
1966
2084
|
text={inputMessage as string}
|
|
1967
|
-
placeHolderText={t("ENTER_YOUR_MESSAGE_HERE")}
|
|
2085
|
+
placeHolderText={isAgenticUser()? t("ASK_ANYTHING") : t("ENTER_YOUR_MESSAGE_HERE")}
|
|
1968
2086
|
style={mergedComposerStyle.messageInputStyles}
|
|
1969
2087
|
onSelectionChange={({ nativeEvent: { selection } }) => {
|
|
1970
2088
|
setSelectionPosition(selection);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React, { JSX, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
-
import { Text, TouchableOpacity, View } from "react-native";
|
|
2
|
+
import { Text, TouchableOpacity, View, Modal, ScrollView } from "react-native";
|
|
3
3
|
import { ChatConfigurator, getLastSeenTime } from "../shared";
|
|
4
4
|
import { listners } from "./listners";
|
|
5
5
|
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
6
6
|
import { GroupTypeConstants, UserStatusConstants } from "../shared/constants/UIKitConstants";
|
|
7
7
|
import { CometChatUIEventHandler } from "../shared/events/CometChatUIEventHandler/CometChatUIEventHandler";
|
|
8
|
+
import { CometChatUIEvents } from "../shared/events/CometChatUIEvents";
|
|
8
9
|
import { deepMerge } from "../shared/helper/helperFunctions";
|
|
9
10
|
import { Icon } from "../shared/icons/Icon";
|
|
10
11
|
import { CometChatAvatar } from "../shared/views/CometChatAvatar";
|
|
@@ -14,6 +15,7 @@ import { MessageHeaderStyle } from "./styles";
|
|
|
14
15
|
import { CommonUtils } from "../shared/utils/CommonUtils";
|
|
15
16
|
import { DeepPartial } from "../shared/helper/types";
|
|
16
17
|
import { useCometChatTranslation } from "../shared/resources/CometChatLocalizeNew";
|
|
18
|
+
import { CometChatAIAssistantChatHistory } from "../CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory";
|
|
17
19
|
|
|
18
20
|
export type CometChatMessageHeaderInterface = {
|
|
19
21
|
/**
|
|
@@ -100,6 +102,22 @@ export type CometChatMessageHeaderInterface = {
|
|
|
100
102
|
* toggle visibilty of user status.
|
|
101
103
|
*/
|
|
102
104
|
usersStatusVisibility?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Flag to hide the new chat button for AI agents (only applies to @agentic users)
|
|
107
|
+
*/
|
|
108
|
+
hideNewChatButton?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Flag to hide the chat history button for AI agents (only applies to @agentic users)
|
|
111
|
+
*/
|
|
112
|
+
hideChatHistoryButton?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Callback when agent new chat button is clicked (only applies to @agentic users)
|
|
115
|
+
*/
|
|
116
|
+
onNewChatButtonClick?: () => void;
|
|
117
|
+
/**
|
|
118
|
+
* Callback when agent chat history button is clicked (only applies to @agentic users)
|
|
119
|
+
*/
|
|
120
|
+
onChatHistoryButtonClick?: () => void;
|
|
103
121
|
};
|
|
104
122
|
|
|
105
123
|
interface Translations {
|
|
@@ -132,16 +150,27 @@ export const CometChatMessageHeader = (props: CometChatMessageHeaderInterface) =
|
|
|
132
150
|
hideVoiceCallButton = false,
|
|
133
151
|
hideVideoCallButton = false,
|
|
134
152
|
usersStatusVisibility = true,
|
|
153
|
+
hideNewChatButton = false,
|
|
154
|
+
hideChatHistoryButton = false,
|
|
155
|
+
onNewChatButtonClick,
|
|
156
|
+
onChatHistoryButtonClick,
|
|
135
157
|
} = props;
|
|
136
158
|
|
|
137
159
|
const [groupObj, setGroupObj] = useState(group);
|
|
138
160
|
const [userObj, setUserObj] = useState<CometChat.User | undefined>(user);
|
|
139
161
|
const [userStatus, setUserStatus] = useState(user && user.getStatus ? user.getStatus() : "");
|
|
140
162
|
const [typingText, setTypingText] = useState("");
|
|
163
|
+
const [showHistoryModal, setShowHistoryModal] = useState(false);
|
|
141
164
|
const receiverTypeRef = useRef(
|
|
142
165
|
user ? CometChat.RECEIVER_TYPE.USER : group ? CometChat.RECEIVER_TYPE.GROUP : null
|
|
143
166
|
);
|
|
144
167
|
|
|
168
|
+
// Helper function to check if user is agentic
|
|
169
|
+
const isAgenticUser = useCallback(() => {
|
|
170
|
+
return userObj?.getRole?.() === '@agentic';
|
|
171
|
+
}, [userObj]);
|
|
172
|
+
|
|
173
|
+
|
|
145
174
|
useEffect(() => {
|
|
146
175
|
setGroupObj(group);
|
|
147
176
|
}, [group]);
|
|
@@ -209,14 +238,6 @@ export const CometChatMessageHeader = (props: CometChatMessageHeaderInterface) =
|
|
|
209
238
|
}
|
|
210
239
|
name={(userObj?.getName() ?? groupObj?.getName())!}
|
|
211
240
|
/>
|
|
212
|
-
{groupObj ? (
|
|
213
|
-
<CometChatStatusIndicator type={statusIndicatorType} />
|
|
214
|
-
) : (
|
|
215
|
-
usersStatusVisibility &&
|
|
216
|
-
!(userObj?.getBlockedByMe() || userObj?.getHasBlockedMe()) && (
|
|
217
|
-
<CometChatStatusIndicator type={statusIndicatorType} />
|
|
218
|
-
)
|
|
219
|
-
)}
|
|
220
241
|
</View>
|
|
221
242
|
);
|
|
222
243
|
} catch (e) {
|
|
@@ -399,6 +420,60 @@ export const CometChatMessageHeader = (props: CometChatMessageHeaderInterface) =
|
|
|
399
420
|
};
|
|
400
421
|
}, []);
|
|
401
422
|
|
|
423
|
+
/**
|
|
424
|
+
* Renders AI agent auxiliary buttons (new chat, history, close)
|
|
425
|
+
*/
|
|
426
|
+
const renderAgentAuxiliaryView = () => {
|
|
427
|
+
const iconSecondary = theme.color.iconSecondary;
|
|
428
|
+
|
|
429
|
+
const handleNewChat = () => {
|
|
430
|
+
if (onNewChatButtonClick) {
|
|
431
|
+
onNewChatButtonClick();
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
const handleChatHistory = () => {
|
|
436
|
+
if (onChatHistoryButtonClick) {
|
|
437
|
+
onChatHistoryButtonClick();
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
return (
|
|
442
|
+
<View style={{ flexDirection: "row", alignItems: "center" }}>
|
|
443
|
+
{!hideNewChatButton && (
|
|
444
|
+
<TouchableOpacity
|
|
445
|
+
style={{
|
|
446
|
+
borderRadius: 12,
|
|
447
|
+
padding: 8,
|
|
448
|
+
alignItems: "center",
|
|
449
|
+
justifyContent: "center",
|
|
450
|
+
flexDirection: "row",
|
|
451
|
+
}}
|
|
452
|
+
onPress={handleNewChat}
|
|
453
|
+
>
|
|
454
|
+
<Icon name="ai-new-chat" width={24} height={24} color={iconSecondary} />
|
|
455
|
+
</TouchableOpacity>
|
|
456
|
+
)}
|
|
457
|
+
|
|
458
|
+
{!hideChatHistoryButton && (
|
|
459
|
+
<TouchableOpacity
|
|
460
|
+
style={{
|
|
461
|
+
borderRadius: 12,
|
|
462
|
+
padding: 8,
|
|
463
|
+
alignItems: "center",
|
|
464
|
+
justifyContent: "center",
|
|
465
|
+
flexDirection: "row",
|
|
466
|
+
}}
|
|
467
|
+
onPress={handleChatHistory}
|
|
468
|
+
>
|
|
469
|
+
<Icon name="ai-chat-history" width={24} height={24} color={iconSecondary} />
|
|
470
|
+
</TouchableOpacity>
|
|
471
|
+
)}
|
|
472
|
+
</View>
|
|
473
|
+
);
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
|
|
402
477
|
return (
|
|
403
478
|
<>
|
|
404
479
|
{ItemView ? (
|
|
@@ -421,20 +496,33 @@ export const CometChatMessageHeader = (props: CometChatMessageHeaderInterface) =
|
|
|
421
496
|
)}
|
|
422
497
|
{SubtitleView ? SubtitleView({ user: userObj, group }) : <SubtitleViewFnc />}
|
|
423
498
|
</View>
|
|
424
|
-
<View style={{
|
|
499
|
+
<View style={{
|
|
500
|
+
flex: isAgenticUser() ? 0 : 1,
|
|
501
|
+
flexDirection: "row",
|
|
502
|
+
alignItems: "center"
|
|
503
|
+
}}>
|
|
425
504
|
<View style={{ marginLeft: "auto", flexDirection: "row" }}>
|
|
426
|
-
{
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
505
|
+
{(() => {
|
|
506
|
+
const isAgenticUser = userObj?.getRole?.() === '@agentic';
|
|
507
|
+
|
|
508
|
+
if (isAgenticUser && !AuxiliaryButtonView) {
|
|
509
|
+
return renderAgentAuxiliaryView();
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
return AuxiliaryButtonView
|
|
513
|
+
? AuxiliaryButtonView({ user: userObj, group })
|
|
514
|
+
: ChatConfigurator.getDataSource().getAuxiliaryHeaderAppbarOptions(userObj, group, {
|
|
515
|
+
callButtonStyle: messageHeaderStyles.callButtonStyle,
|
|
516
|
+
hideVideoCallButton,
|
|
517
|
+
hideVoiceCallButton,
|
|
518
|
+
});
|
|
519
|
+
})()}
|
|
520
|
+
{TrailingView && !isAgenticUser() && <>{TrailingView({ user: userObj, group })}</>}
|
|
434
521
|
</View>
|
|
435
522
|
</View>
|
|
436
523
|
</View>
|
|
437
524
|
)}
|
|
525
|
+
|
|
438
526
|
</>
|
|
439
527
|
);
|
|
440
528
|
};
|