@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.
Files changed (200) hide show
  1. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  2. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  3. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  4. package/android/.gradle/7.4/gc.properties +0 -0
  5. package/android/.gradle/vcs-1/gc.properties +0 -0
  6. package/lib/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.d.ts +40 -0
  7. package/lib/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.js +467 -0
  8. package/lib/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.js.map +1 -0
  9. package/lib/CometChatAIAssistantChatHistory/Skeleton.d.ts +24 -0
  10. package/lib/CometChatAIAssistantChatHistory/Skeleton.js +130 -0
  11. package/lib/CometChatAIAssistantChatHistory/Skeleton.js.map +1 -0
  12. package/lib/CometChatAIAssistantChatHistory/index.d.ts +1 -0
  13. package/lib/CometChatAIAssistantChatHistory/index.js +2 -0
  14. package/lib/CometChatAIAssistantChatHistory/index.js.map +1 -0
  15. package/lib/CometChatAIAssistantChatHistory/style.d.ts +30 -0
  16. package/lib/CometChatAIAssistantChatHistory/style.js +122 -0
  17. package/lib/CometChatAIAssistantChatHistory/style.js.map +1 -0
  18. package/lib/CometChatConversations/CometChatConversations.js +26 -5
  19. package/lib/CometChatConversations/CometChatConversations.js.map +1 -1
  20. package/lib/CometChatMessageComposer/CometChatMessageComposer.d.ts +7 -0
  21. package/lib/CometChatMessageComposer/CometChatMessageComposer.js +101 -13
  22. package/lib/CometChatMessageComposer/CometChatMessageComposer.js.map +1 -1
  23. package/lib/CometChatMessageHeader/CometChatMessageHeader.d.ts +16 -0
  24. package/lib/CometChatMessageHeader/CometChatMessageHeader.js +63 -13
  25. package/lib/CometChatMessageHeader/CometChatMessageHeader.js.map +1 -1
  26. package/lib/CometChatMessageList/CometChatMessageList.d.ts +33 -0
  27. package/lib/CometChatMessageList/CometChatMessageList.js +535 -76
  28. package/lib/CometChatMessageList/CometChatMessageList.js.map +1 -1
  29. package/lib/CometChatMessageList/style.js +74 -2
  30. package/lib/CometChatMessageList/style.js.map +1 -1
  31. package/lib/calls/CometChatIncomingCall/CometChatIncomingCall.js +6 -12
  32. package/lib/calls/CometChatIncomingCall/CometChatIncomingCall.js.map +1 -1
  33. package/lib/calls/CometChatOutgoingCall/CometChatOutgoingCall.js +4 -3
  34. package/lib/calls/CometChatOutgoingCall/CometChatOutgoingCall.js.map +1 -1
  35. package/lib/extensions/Polls/Polls.js +38 -17
  36. package/lib/extensions/Polls/Polls.js.map +1 -1
  37. package/lib/index.d.ts +5 -1
  38. package/lib/index.js +6 -2
  39. package/lib/index.js.map +1 -1
  40. package/lib/shared/constants/UIKitConstants.d.ts +16 -0
  41. package/lib/shared/constants/UIKitConstants.js +16 -0
  42. package/lib/shared/constants/UIKitConstants.js.map +1 -1
  43. package/lib/shared/events/CometChatMessageEvents/index.d.ts +3 -0
  44. package/lib/shared/events/CometChatMessageEvents/index.js +3 -0
  45. package/lib/shared/events/CometChatMessageEvents/index.js.map +1 -1
  46. package/lib/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.js +3 -0
  47. package/lib/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.js.map +1 -1
  48. package/lib/shared/events/CometChatUIEventHandler/Listener.d.ts +3 -1
  49. package/lib/shared/events/CometChatUIEventHandler/Listener.js +4 -1
  50. package/lib/shared/events/CometChatUIEventHandler/Listener.js.map +1 -1
  51. package/lib/shared/events/ListenerInitializer.d.ts +3 -1
  52. package/lib/shared/events/ListenerInitializer.js +5 -1
  53. package/lib/shared/events/ListenerInitializer.js.map +1 -1
  54. package/lib/shared/events/messages.d.ts +2 -1
  55. package/lib/shared/events/messages.js +1 -0
  56. package/lib/shared/events/messages.js.map +1 -1
  57. package/lib/shared/framework/DataSource.d.ts +3 -1
  58. package/lib/shared/framework/DataSourceDecorator.d.ts +3 -1
  59. package/lib/shared/framework/DataSourceDecorator.js +8 -2
  60. package/lib/shared/framework/DataSourceDecorator.js.map +1 -1
  61. package/lib/shared/framework/MessageDataSource.d.ts +6 -0
  62. package/lib/shared/framework/MessageDataSource.js +64 -1
  63. package/lib/shared/framework/MessageDataSource.js.map +1 -1
  64. package/lib/shared/icons/components/ai-chat-history.d.ts +8 -0
  65. package/lib/shared/icons/components/ai-chat-history.js +9 -0
  66. package/lib/shared/icons/components/ai-chat-history.js.map +1 -0
  67. package/lib/shared/icons/components/ai-copy-option.d.ts +8 -0
  68. package/lib/shared/icons/components/ai-copy-option.js +9 -0
  69. package/lib/shared/icons/components/ai-copy-option.js.map +1 -0
  70. package/lib/shared/icons/components/ai-new-chat.d.ts +8 -0
  71. package/lib/shared/icons/components/ai-new-chat.js +9 -0
  72. package/lib/shared/icons/components/ai-new-chat.js.map +1 -0
  73. package/lib/shared/icons/components/ai-send-button.d.ts +8 -0
  74. package/lib/shared/icons/components/ai-send-button.js +9 -0
  75. package/lib/shared/icons/components/ai-send-button.js.map +1 -0
  76. package/lib/shared/icons/components/right-arrow.d.ts +3 -0
  77. package/lib/shared/icons/components/right-arrow.js +6 -0
  78. package/lib/shared/icons/components/right-arrow.js.map +1 -0
  79. package/lib/shared/icons/components/stop-fill.js +8 -7
  80. package/lib/shared/icons/components/stop-fill.js.map +1 -1
  81. package/lib/shared/icons/icon-mapping.d.ts +11 -0
  82. package/lib/shared/icons/icon-mapping.js +11 -0
  83. package/lib/shared/icons/icon-mapping.js.map +1 -1
  84. package/lib/shared/modals/CometChatAIAssistantTools.d.ts +47 -0
  85. package/lib/shared/modals/CometChatAIAssistantTools.js +44 -0
  86. package/lib/shared/modals/CometChatAIAssistantTools.js.map +1 -0
  87. package/lib/shared/modals/StreamMessage.d.ts +4 -0
  88. package/lib/shared/modals/StreamMessage.js +11 -0
  89. package/lib/shared/modals/StreamMessage.js.map +1 -0
  90. package/lib/shared/modals/index.d.ts +3 -1
  91. package/lib/shared/modals/index.js +3 -1
  92. package/lib/shared/modals/index.js.map +1 -1
  93. package/lib/shared/resources/CometChatLocalizeNew/CometChatLocalizationHelper.d.ts +126 -0
  94. package/lib/shared/resources/CometChatLocalizeNew/resources/de/translation.json +7 -1
  95. package/lib/shared/resources/CometChatLocalizeNew/resources/en/translation.json +7 -1
  96. package/lib/shared/resources/CometChatLocalizeNew/resources/es/translation.json +7 -1
  97. package/lib/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +7 -1
  98. package/lib/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +7 -1
  99. package/lib/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +7 -1
  100. package/lib/shared/resources/CometChatLocalizeNew/resources/it/translation.json +7 -1
  101. package/lib/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +7 -1
  102. package/lib/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +7 -1
  103. package/lib/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +7 -1
  104. package/lib/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +7 -1
  105. package/lib/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +7 -1
  106. package/lib/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +7 -1
  107. package/lib/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +7 -1
  108. package/lib/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +7 -1
  109. package/lib/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +7 -1
  110. package/lib/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +7 -1
  111. package/lib/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +7 -1
  112. package/lib/shared/services/stream-message.service.d.ts +84 -0
  113. package/lib/shared/services/stream-message.service.js +406 -0
  114. package/lib/shared/services/stream-message.service.js.map +1 -0
  115. package/lib/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.d.ts +9 -0
  116. package/lib/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.js +248 -0
  117. package/lib/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.js.map +1 -0
  118. package/lib/shared/views/CometChatAIAssistantMessageBubble/index.d.ts +3 -0
  119. package/lib/shared/views/CometChatAIAssistantMessageBubble/index.js +4 -0
  120. package/lib/shared/views/CometChatAIAssistantMessageBubble/index.js.map +1 -0
  121. package/lib/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.js +5 -2
  122. package/lib/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.js.map +1 -1
  123. package/lib/shared/views/CometChatImageBubble/CometChatImageLoader.js +1 -1
  124. package/lib/shared/views/CometChatImageBubble/CometChatImageLoader.js.map +1 -1
  125. package/lib/shared/views/CometChatImageViewerModal/ImageViewerModal.js +52 -32
  126. package/lib/shared/views/CometChatImageViewerModal/ImageViewerModal.js.map +1 -1
  127. package/lib/shared/views/CometChatSendButtonView/CometChatSendButtonView.d.ts +10 -0
  128. package/lib/shared/views/CometChatSendButtonView/CometChatSendButtonView.js +54 -0
  129. package/lib/shared/views/CometChatSendButtonView/CometChatSendButtonView.js.map +1 -0
  130. package/lib/shared/views/CometChatSendButtonView/index.d.ts +1 -0
  131. package/lib/shared/views/CometChatSendButtonView/index.js +2 -0
  132. package/lib/shared/views/CometChatSendButtonView/index.js.map +1 -0
  133. package/lib/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.d.ts +8 -0
  134. package/lib/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.js +436 -0
  135. package/lib/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.js.map +1 -0
  136. package/lib/shared/views/CometChatStreamMessageBubble/index.d.ts +3 -0
  137. package/lib/shared/views/CometChatStreamMessageBubble/index.js +3 -0
  138. package/lib/shared/views/CometChatStreamMessageBubble/index.js.map +1 -0
  139. package/lib/shared/views/CometChatTextBubble/CometChatTextBubble.d.ts +14 -6
  140. package/lib/shared/views/CometChatTextBubble/CometChatTextBubble.js +82 -57
  141. package/lib/shared/views/CometChatTextBubble/CometChatTextBubble.js.map +1 -1
  142. package/lib/theme/context.d.ts +96 -15
  143. package/lib/theme/type.d.ts +14 -1
  144. package/package.json +5 -2
  145. package/src/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.tsx +627 -0
  146. package/src/CometChatAIAssistantChatHistory/Skeleton.tsx +228 -0
  147. package/src/CometChatAIAssistantChatHistory/index.ts +2 -0
  148. package/src/CometChatAIAssistantChatHistory/style.ts +160 -0
  149. package/src/CometChatConversations/CometChatConversations.tsx +36 -10
  150. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +137 -19
  151. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +106 -18
  152. package/src/CometChatMessageList/CometChatMessageList.tsx +619 -72
  153. package/src/CometChatMessageList/style.ts +74 -2
  154. package/src/index.ts +31 -1
  155. package/src/shared/constants/UIKitConstants.ts +17 -0
  156. package/src/shared/events/CometChatMessageEvents/index.ts +3 -1
  157. package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +3 -0
  158. package/src/shared/events/CometChatUIEventHandler/Listener.ts +4 -0
  159. package/src/shared/events/ListenerInitializer.ts +6 -1
  160. package/src/shared/events/messages.ts +1 -0
  161. package/src/shared/framework/DataSource.ts +4 -2
  162. package/src/shared/framework/DataSourceDecorator.tsx +10 -2
  163. package/src/shared/framework/MessageDataSource.tsx +75 -2
  164. package/src/shared/icons/Icon.tsx +1 -1
  165. package/src/shared/icons/components/ai-chat-history.tsx +21 -0
  166. package/src/shared/icons/components/ai-copy-option.tsx +21 -0
  167. package/src/shared/icons/components/ai-new-chat.tsx +21 -0
  168. package/src/shared/icons/components/ai-send-button.tsx +24 -0
  169. package/src/shared/icons/components/right-arrow.tsx +13 -0
  170. package/src/shared/icons/components/stop-fill.tsx +14 -12
  171. package/src/shared/icons/icon-mapping.tsx +14 -0
  172. package/src/shared/modals/CometChatAIAssistantTools.ts +65 -0
  173. package/src/shared/modals/StreamMessage.ts +12 -0
  174. package/src/shared/modals/index.ts +5 -1
  175. package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +7 -1
  176. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +7 -1
  177. package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +7 -1
  178. package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +7 -1
  179. package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +7 -2
  180. package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +7 -1
  181. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +7 -1
  182. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +7 -1
  183. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +7 -1
  184. package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +7 -1
  185. package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +7 -1
  186. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +7 -1
  187. package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +7 -1
  188. package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +7 -1
  189. package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +7 -1
  190. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +7 -1
  191. package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +7 -1
  192. package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +7 -1
  193. package/src/shared/services/stream-message.service.ts +470 -0
  194. package/src/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.tsx +262 -0
  195. package/src/shared/views/CometChatAIAssistantMessageBubble/index.ts +4 -0
  196. package/src/shared/views/CometChatSendButtonView/CometChatSendButtonView.tsx +86 -0
  197. package/src/shared/views/CometChatSendButtonView/index.ts +1 -0
  198. package/src/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.tsx +493 -0
  199. package/src/shared/views/CometChatStreamMessageBubble/index.ts +9 -0
  200. 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
- return deepMerge(theme.messageComposerStyles, style);
485
- }, [theme, style]);
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 && textMessage.setParentMessageId(parentMessageId as number);
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
- return hideVoiceRecordingButton ? undefined : (
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
- else if (defaultAuxiliaryButtonOptions)
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={{ flex: 1, flexDirection: "row" }}>
499
+ <View style={{
500
+ flex: isAgenticUser() ? 0 : 1,
501
+ flexDirection: "row",
502
+ alignItems: "center"
503
+ }}>
425
504
  <View style={{ marginLeft: "auto", flexDirection: "row" }}>
426
- {AuxiliaryButtonView
427
- ? AuxiliaryButtonView({ user: userObj, group })
428
- : ChatConfigurator.getDataSource().getAuxiliaryHeaderAppbarOptions(userObj, group, {
429
- callButtonStyle: messageHeaderStyles.callButtonStyle,
430
- hideVideoCallButton,
431
- hideVoiceCallButton,
432
- })}
433
- {TrailingView && <>{TrailingView({ user: userObj, group })}</>}
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
  };