@cometchat/chat-uikit-react-native 5.3.10 → 5.4.1

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 (132) hide show
  1. package/android/src/main/java/com/reactnativecometchatuikit/CometChatClipboardModule.kt +52 -0
  2. package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +1 -0
  3. package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +95 -8
  4. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +300 -7
  5. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorViewManager.kt +2 -1
  6. package/android/src/main/java/com/reactnativecometchatuikit/SoundPlayer.java +85 -47
  7. package/ios/CometChatClipboardModule.m +11 -0
  8. package/ios/CometChatClipboardModule.swift +41 -0
  9. package/ios/FileManager.m +201 -39
  10. package/ios/RichTextEditorView.swift +367 -8
  11. package/ios/RichTextEditorViewManager.m +1 -0
  12. package/ios/SoundPlayer.m +18 -6
  13. package/package.json +10 -7
  14. package/react-native-cometchat-ui-kit.podspec +1 -0
  15. package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +692 -107
  16. package/src/CometChatConversations/CometChatConversations.tsx +19 -6
  17. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +649 -49
  18. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +23 -4
  19. package/src/CometChatMessageList/CometChatMessageList.tsx +463 -54
  20. package/src/CometChatMessageList/SEARCH_NAV_SLOWNESS_FINDINGS_AND_FIX.md +313 -0
  21. package/src/CometChatMessageList/components/MessageListItem.tsx +30 -17
  22. package/src/CometChatMessageList/style.ts +33 -5
  23. package/src/CometChatRichTextEditor/RichTextEditorViewNativeComponent.ts +13 -0
  24. package/src/CometChatRichTextEditor/index.tsx +25 -0
  25. package/src/CometChatSearch/CometChatSearch.tsx +296 -154
  26. package/src/calls/CallingExtension.tsx +19 -13
  27. package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +20 -1
  28. package/src/extensions/ThumbnailGeneration/ThumbnailGenerationDecorator.tsx +20 -9
  29. package/src/index.ts +39 -0
  30. package/src/shared/CometChatUiKit/CometChatUIKit.ts +40 -34
  31. package/src/shared/base/Types.ts +3 -0
  32. package/src/shared/constants/UIKitConstants.ts +15 -1
  33. package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +3 -2
  34. package/src/shared/framework/DataSource.ts +14 -4
  35. package/src/shared/framework/DataSourceDecorator.tsx +17 -8
  36. package/src/shared/framework/MessageDataSource.tsx +307 -60
  37. package/src/shared/helper/useToast.tsx +29 -0
  38. package/src/shared/icons/components/audio-file-type.tsx +11 -22
  39. package/src/shared/icons/components/document-file-type.tsx +11 -24
  40. package/src/shared/icons/components/image-file-type.tsx +12 -21
  41. package/src/shared/icons/components/link-file-type.tsx +25 -0
  42. package/src/shared/icons/components/pdf-file-type.tsx +11 -22
  43. package/src/shared/icons/components/presentation-file-type.tsx +11 -24
  44. package/src/shared/icons/components/spreadsheet-file-type.tsx +11 -24
  45. package/src/shared/icons/components/text-file-type.tsx +11 -21
  46. package/src/shared/icons/components/unknown-file-type.tsx +21 -25
  47. package/src/shared/icons/components/video-file-type.tsx +11 -24
  48. package/src/shared/icons/components/zip-file-type.tsx +11 -24
  49. package/src/shared/icons/icon-mapping.tsx +2 -0
  50. package/src/shared/index.ts +28 -0
  51. package/src/shared/modals/AttachmentPickerConfiguration.ts +13 -0
  52. package/src/shared/modals/SelectedAttachment.ts +65 -0
  53. package/src/shared/modals/UploadState.ts +10 -0
  54. package/src/shared/modals/index.ts +4 -0
  55. package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +42 -1
  56. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +42 -1
  57. package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +43 -2
  58. package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +43 -2
  59. package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +43 -2
  60. package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +43 -2
  61. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +43 -2
  62. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +43 -2
  63. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +43 -2
  64. package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +43 -2
  65. package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +43 -2
  66. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +43 -2
  67. package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +43 -2
  68. package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +43 -2
  69. package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +43 -2
  70. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +43 -2
  71. package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +43 -2
  72. package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +43 -2
  73. package/src/shared/services/UploadQueueService.ts +145 -0
  74. package/src/shared/services/index.ts +2 -0
  75. package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +44 -19
  76. package/src/shared/utils/MessageUtils.tsx +13 -4
  77. package/src/shared/utils/attachmentLimits.ts +156 -0
  78. package/src/shared/utils/audioPlaybackCoordinator.ts +28 -0
  79. package/src/shared/utils/batchMediaContext.tsx +30 -0
  80. package/src/shared/utils/conversationUtils.ts +26 -4
  81. package/src/shared/utils/elementType.tsx +38 -0
  82. package/src/shared/utils/groupAttachments.ts +93 -0
  83. package/src/shared/utils/index.ts +8 -0
  84. package/src/shared/utils/openMultiFileChooser.ts +123 -0
  85. package/src/shared/utils/partitionAttachmentsByKind.ts +44 -0
  86. package/src/shared/views/ClipboardPasteHandler/ClipboardPasteHandler.ts +28 -0
  87. package/src/shared/views/ClipboardPasteHandler/NativeCometChatClipboardModule.ts +16 -0
  88. package/src/shared/views/ClipboardPasteHandler/index.ts +2 -0
  89. package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +1 -0
  90. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreview.style.ts +32 -0
  91. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreview.tsx +90 -0
  92. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreviewItem.tsx +276 -0
  93. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentTile.tsx +827 -0
  94. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentTray.tsx +110 -0
  95. package/src/shared/views/CometChatAttachmentPreview/StagedVideoDurationProbe.tsx +53 -0
  96. package/src/shared/views/CometChatAttachmentPreview/index.ts +8 -0
  97. package/src/shared/views/CometChatAttachmentViewer/CometChatAttachmentViewer.tsx +305 -0
  98. package/src/shared/views/CometChatAttachmentViewer/index.ts +2 -0
  99. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +71 -74
  100. package/src/shared/views/CometChatAudiosBubble/CometChatAudiosBubble.tsx +587 -0
  101. package/src/shared/views/CometChatAudiosBubble/index.ts +2 -0
  102. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +31 -20
  103. package/src/shared/views/CometChatCaptionText/CometChatCaptionText.tsx +182 -0
  104. package/src/shared/views/CometChatCaptionText/index.ts +2 -0
  105. package/src/shared/views/CometChatComposerErrorBanner.tsx +83 -0
  106. package/src/shared/views/CometChatConversationStarter/CometChatConversationStarter.tsx +141 -0
  107. package/src/shared/views/CometChatConversationStarter/index.ts +2 -0
  108. package/src/shared/views/CometChatConversationSummary/CometChatConversationSummary.tsx +155 -0
  109. package/src/shared/views/CometChatConversationSummary/index.ts +2 -0
  110. package/src/shared/views/CometChatFileBubble/style.ts +6 -4
  111. package/src/shared/views/CometChatFilesBubble/CometChatFilesBubble.tsx +316 -0
  112. package/src/shared/views/CometChatFilesBubble/index.ts +2 -0
  113. package/src/shared/views/CometChatImagesBubble/CometChatImagesBubble.tsx +323 -0
  114. package/src/shared/views/CometChatImagesBubble/index.ts +2 -0
  115. package/src/shared/views/CometChatMediaViewer/CometChatMediaViewer.tsx +425 -0
  116. package/src/shared/views/CometChatMediaViewer/index.ts +2 -0
  117. package/src/shared/views/CometChatMediaViewer/mediaViewerUtils.ts +30 -0
  118. package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +14 -4
  119. package/src/shared/views/CometChatSendButtonView/CometChatSendButtonView.tsx +1 -0
  120. package/src/shared/views/CometChatSmartReplies/CometChatSmartReplies.tsx +172 -0
  121. package/src/shared/views/CometChatSmartReplies/index.ts +2 -0
  122. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +4 -3
  123. package/src/shared/views/CometChatVideoBubble/style.ts +3 -3
  124. package/src/shared/views/CometChatVideosBubble/CometChatVideosBubble.tsx +441 -0
  125. package/src/shared/views/CometChatVideosBubble/index.ts +2 -0
  126. package/src/shared/views/CometChatVoiceNoteBubble/CometChatVoiceNoteBubble.tsx +78 -0
  127. package/src/shared/views/CometChatVoiceNoteBubble/index.ts +2 -0
  128. package/src/shared/views/index.ts +37 -1
  129. package/src/theme/CometChatThemeHelper.ts +8 -0
  130. package/src/theme/default/color/dark.ts +9 -0
  131. package/src/theme/default/color/light.ts +10 -0
  132. package/src/theme/type.ts +73 -0
@@ -71,6 +71,8 @@ import { Icon } from "../shared/icons/Icon";
71
71
  import { CometChatMessageTemplate } from "../shared/modals/CometChatMessageTemplate";
72
72
  import { getUnixTimestamp, messageStatus } from "../shared/utils/CometChatMessageHelper";
73
73
  import { CommonUtils } from "../shared/utils/CommonUtils";
74
+ import { CometChatBatchMediaContext, BatchMediaResult } from "../shared/utils/batchMediaContext";
75
+ import { CometChatUIKit } from "../shared/CometChatUiKit/CometChatUIKit";
74
76
  import { CometChatNewMessageIndicator, CometChatReceipt, NewMessageIndicatorStyle } from "../shared/views";
75
77
  import { CometChatAvatar } from "../shared/views/CometChatAvatar";
76
78
  import { CometChatBadge } from "../shared/views/CometChatBadge";
@@ -105,9 +107,10 @@ import { MessageModals } from "./components/MessageModals";
105
107
  import { ReactionModals } from "./components/ReactionModals";
106
108
  import { MessageOptionsSheet } from "./components/MessageOptionsSheet";
107
109
  import { MessageListItem } from "./components/MessageListItem";
110
+ import CometChatConversationStarter from "../shared/views/CometChatConversationStarter/CometChatConversationStarter";
111
+ import CometChatSmartReplies from "../shared/views/CometChatSmartReplies/CometChatSmartReplies";
108
112
 
109
113
  let _defaultRequestBuilder: CometChat.MessagesRequestBuilder;
110
- const SEPARATOR_HEIGHT = 40;
111
114
  const AVERAGE_ITEM_LENGTH = 120;
112
115
  const SMALL_LIST_THRESHOLD = 30;
113
116
 
@@ -415,6 +418,12 @@ export interface CometChatMessageListProps {
415
418
  * Flag to hide the reply option
416
419
  */
417
420
  hideReplyOption?: boolean;
421
+ /**
422
+ * DD §9 — message-list attachment rendering. `true` (default): new per-type bubbles that render
423
+ * 1..N attachments (including a single one). `false`: the deprecated single-attachment bubbles
424
+ * (set this only to keep legacy single-bubble styling for messages that carry one attachment).
425
+ */
426
+ enableMultipleAttachments?: boolean;
418
427
  /**
419
428
  * Flag to hide the reply in thread option
420
429
  */
@@ -491,6 +500,14 @@ export interface CometChatMessageListProps {
491
500
  * Callback when suggested message is clicked (only applies to @agentic users)
492
501
  */
493
502
  onSuggestedMessageClick?: (suggestion: string) => void;
503
+ /**
504
+ * When true, shows AI-generated conversation starters when the message list is empty.
505
+ */
506
+ showConversationStarters?: boolean;
507
+ /**
508
+ * When true, shows AI-generated smart reply chips above the composer after a new message arrives.
509
+ */
510
+ showSmartReplies?: boolean;
494
511
  /**
495
512
  * Custom AI assistant tools with action functions (only applies to @agentic users)
496
513
  */
@@ -584,6 +601,81 @@ export interface CometChatMessageListActionsInterface {
584
601
  updateMessageReceipt: (message: CometChat.BaseMessage) => void;
585
602
  }
586
603
 
604
+ // ---------------------------------------------------------------------------
605
+ // §8.3a — Batch grouping helpers. After the §7 fan-out, one user "send" becomes
606
+ // N single-kind messages sharing metadata.batchId. Consecutive messages from the
607
+ // same sender that share a batchId render as ONE visual group: a single avatar on
608
+ // the group's first (top/oldest) member and a single receipt+timestamp on the last
609
+ // (bottom/newest) member. Pure functions (no closures) — safe to reuse anywhere.
610
+ // ---------------------------------------------------------------------------
611
+ function getMessageBatchId(m: any): string | number | null {
612
+ try {
613
+ const md = m?.getMetadata?.();
614
+ const id = md?.batchId;
615
+ return id === undefined || id === null || id === "" ? null : id;
616
+ } catch {
617
+ return null;
618
+ }
619
+ }
620
+
621
+ /** True when both messages belong to the SAME batch (same non-empty batchId) AND the same sender. */
622
+ function isSameBatchGroup(a: any, b: any): boolean {
623
+ if (!a || !b) return false;
624
+ const ba = getMessageBatchId(a);
625
+ const bb = getMessageBatchId(b);
626
+ if (ba == null || bb == null || ba !== bb) return false;
627
+ const ua = a.getSender?.()?.getUid?.();
628
+ const ub = b.getSender?.()?.getUid?.();
629
+ return !!ua && ua === ub;
630
+ }
631
+
632
+ function getMessageBatchIndex(m: any): number {
633
+ try {
634
+ const bi = m?.getMetadata?.()?.batchIndex;
635
+ return typeof bi === "number" ? bi : 0;
636
+ } catch {
637
+ return 0;
638
+ }
639
+ }
640
+
641
+ /**
642
+ * §8.3a — enforce the sender's order within a batch on the RECEIVE side. Each kind fans out
643
+ * into an INDEPENDENT async upload, so a small file can arrive (and be stored by the server)
644
+ * before a large image — which would show Files above Images. We reorder each CONTIGUOUS run
645
+ * of same-batch messages by `batchIndex` from metadata. The list is inverted (index 0 = newest
646
+ * / bottom) and a higher batchIndex was sent later, so a run is ordered DESCENDING by batchIndex
647
+ * (last-sent at the bottom). Non-batch messages and the overall message order are untouched.
648
+ * Returns the SAME array reference when nothing needed reordering (keeps the memo stable).
649
+ */
650
+ function orderBatchRuns(messages: any[]): any[] {
651
+ if (!Array.isArray(messages) || messages.length < 2) return messages;
652
+ const result = messages.slice();
653
+ let changed = false;
654
+ let i = 0;
655
+ while (i < result.length) {
656
+ if (getMessageBatchId(result[i]) == null) {
657
+ i++;
658
+ continue;
659
+ }
660
+ let j = i;
661
+ while (j + 1 < result.length && isSameBatchGroup(result[j + 1], result[i])) j++;
662
+ if (j > i) {
663
+ const run = result.slice(i, j + 1);
664
+ const sorted = run.slice().sort((a, b) => getMessageBatchIndex(b) - getMessageBatchIndex(a));
665
+ let runChanged = false;
666
+ for (let k = 0; k < run.length; k++) {
667
+ if (run[k] !== sorted[k]) { runChanged = true; break; }
668
+ }
669
+ if (runChanged) {
670
+ result.splice(i, run.length, ...sorted);
671
+ changed = true;
672
+ }
673
+ }
674
+ i = j + 1;
675
+ }
676
+ return changed ? result : messages;
677
+ }
678
+
587
679
  export const CometChatMessageList = memo(
588
680
  forwardRef<CometChatMessageListActionsInterface, CometChatMessageListProps>(
589
681
  (props: CometChatMessageListProps, ref) => {
@@ -622,6 +714,7 @@ export const CometChatMessageList = memo(
622
714
  addTemplates = [],
623
715
  onLoad,
624
716
  onEmpty,
717
+ enableMultipleAttachments = true,
625
718
  hideReplyOption: propHideReplyOption = false,
626
719
  hideReplyInThreadOption: propHideReplyInThreadOption = false,
627
720
  hideShareMessageOption: propHideShareMessageOption = false,
@@ -640,6 +733,8 @@ export const CometChatMessageList = memo(
640
733
  emptyChatIntroMessageView,
641
734
  emptyChatImageView,
642
735
  onSuggestedMessageClick,
736
+ showConversationStarters = false,
737
+ showSmartReplies = false,
643
738
  aiAssistantTools,
644
739
  streamingSpeed = 30,
645
740
  goToMessageId,
@@ -950,6 +1045,9 @@ export const CometChatMessageList = memo(
950
1045
  // State for showing bottom loading indicator when fetching next messages
951
1046
  const [bottomLoading, setBottomLoading] = useState(false);
952
1047
  const [unreadCount, setUnreadCount] = useState<number>(0);
1048
+ const [showSmartRepliesView, setShowSmartRepliesView] = useState(false);
1049
+ const [smartRepliesKey, setSmartRepliesKey] = useState('');
1050
+ const latestReceivedMessageRef = useRef<CometChat.BaseMessage | null>(null);
953
1051
  const [showMessageOptions, setShowMessageOptions] = useState<any[]>([]);
954
1052
  const [ExtensionsComponent, setExtensionsComponent] = useState<JSX.Element | null>(null);
955
1053
  const [CustomListHeader, setCustomListHeader] = useState<any>(null);
@@ -1642,6 +1740,7 @@ export const CometChatMessageList = memo(
1642
1740
  const isAgenticUserCheck = isAgenticUser;
1643
1741
  const options = {
1644
1742
  textFormatters: textFormatters || [],
1743
+ enableMultipleAttachments,
1645
1744
  hideReplyOption: isAgenticUserCheck || hideReplyOption,
1646
1745
  hideReplyInThreadOption: isAgenticUserCheck || hideReplyInThreadOption,
1647
1746
  hideShareMessageOption: isAgenticUserCheck || hideShareMessageOption,
@@ -1987,11 +2086,11 @@ export const CometChatMessageList = memo(
1987
2086
  return;
1988
2087
  }
1989
2088
  } else {
1990
- if (
2089
+ const inSameConversation =
1991
2090
  checkSameConversation(baseMessage) ||
1992
2091
  checkMessageInSameConversation(baseMessage) ||
1993
- messageToSameConversation(baseMessage)
1994
- ) {
2092
+ messageToSameConversation(baseMessage);
2093
+ if (inSameConversation) {
1995
2094
  if (user) {
1996
2095
  CometChat.markConversationAsDelivered(user.getUid(), CometChat.RECEIVER_TYPE.USER);
1997
2096
  } else if (group) {
@@ -2278,10 +2377,14 @@ export const CometChatMessageList = memo(
2278
2377
  messagesContentListRef.current = [newMessage, ...messagesContentListRef.current];
2279
2378
  }
2280
2379
 
2281
- latestMessageRef.current = messagesContentListRef.current[0] ?? newMessage;
2282
- onLoad && onLoad([...messagesContentListRef.current].reverse());
2380
+ // Capture the snapshot synchronously — see note on the own-message append
2381
+ // below: the deferred (rAF) setMessagesList must not re-read the ref, which
2382
+ // an intervening render can clobber back to the pre-append state.
2383
+ const gapNextList = messagesContentListRef.current;
2384
+ latestMessageRef.current = gapNextList[0] ?? newMessage;
2385
+ onLoad && onLoad([...gapNextList].reverse());
2283
2386
  batchStateUpdates(() => {
2284
- setMessagesList([...messagesContentListRef.current]);
2387
+ setMessagesList([...gapNextList]);
2285
2388
  if (hideScrollToBottomButton === false && unreadCount < 1 && !hasTargetMessageId) {
2286
2389
  setHideScrollToBottomButton(true);
2287
2390
  }
@@ -2290,14 +2393,21 @@ export const CometChatMessageList = memo(
2290
2393
  return;
2291
2394
  }
2292
2395
  }
2293
- messagesContentListRef.current = [newMessage, ...messagesContentListRef.current];
2294
- onLoad && onLoad([...messagesContentListRef.current].reverse());
2396
+ const nextList = [newMessage, ...messagesContentListRef.current];
2397
+ messagesContentListRef.current = nextList;
2398
+ onLoad && onLoad([...nextList].reverse());
2295
2399
  // Update latestMessageRef for gap detection
2296
2400
  latestMessageRef.current = newMessage;
2297
2401
 
2298
- // Batch state updates for better performance
2402
+ // Batch state updates for better performance.
2403
+ // NOTE: batchStateUpdates defers to the next animation frame. Capture the list
2404
+ // in `nextList` and commit THAT — do not re-read messagesContentListRef.current
2405
+ // inside the rAF. An intervening render (e.g. the composer clearing its reply
2406
+ // preview after sending a quoted reply) re-syncs the ref from state via the
2407
+ // `messagesContentListRef.current = orderedMessagesList` line below, which would
2408
+ // drop this just-appended message before the deferred setMessagesList runs.
2299
2409
  batchStateUpdates(() => {
2300
- setMessagesList([...messagesContentListRef.current]);
2410
+ setMessagesList([...nextList]);
2301
2411
  if (hideScrollToBottomButton === false && unreadCount < 1 && !hasTargetMessageId) {
2302
2412
  setHideScrollToBottomButton(true);
2303
2413
  }
@@ -2891,6 +3001,12 @@ export const CometChatMessageList = memo(
2891
3001
  } else {
2892
3002
  newMessage(textMessage);
2893
3003
  }
3004
+ if (showSmartReplies && textMessage.getSender?.()?.getUid() !== loggedInUser.current?.getUid()) {
3005
+ latestReceivedMessageRef.current = textMessage;
3006
+ // keys CometChatSmartReplies below so back-to-back messages force a refetch
3007
+ setSmartRepliesKey(String(textMessage.getId?.() ?? Date.now()));
3008
+ setShowSmartRepliesView(true);
3009
+ }
2894
3010
  },
2895
3011
  onMediaMessageReceived: (mediaMessage: any) => {
2896
3012
  if (isAgenticUser) {
@@ -2938,7 +3054,16 @@ export const CometChatMessageList = memo(
2938
3054
  messageEdited(editedMessage);
2939
3055
  },
2940
3056
  onMessageModerated: (moderatedMessage: any) => {
2941
- !isAgenticUser && messageEdited(moderatedMessage);
3057
+ if (isAgenticUser) return;
3058
+ // A moderation verdict can arrive BEFORE the optimistic message has reconciled to its
3059
+ // server id — common when sending 3+ images at once, where the last sends are still
3060
+ // keyed by muid in the list. messageEdited() matches by id XOR muid, so when the id
3061
+ // isn't present in the list yet, fall back to muid matching (the event carries the
3062
+ // muid and the optimistic bubble has it). Otherwise the block silently misses that
3063
+ // bubble until a refetch (navigate away + back).
3064
+ const mid = moderatedMessage?.getId?.() ?? (moderatedMessage as any)?.id;
3065
+ const foundById = mid != null && messagesContentListRef.current.some((m: any) => m?.getId?.() == mid);
3066
+ messageEdited(moderatedMessage, !foundById && !!(moderatedMessage as any)?.muid);
2942
3067
  },
2943
3068
  onFormMessageReceived: (formMessage: any) => {
2944
3069
  newMessage(formMessage);
@@ -3314,7 +3439,7 @@ export const CometChatMessageList = memo(
3314
3439
  );
3315
3440
 
3316
3441
  // functions returning view
3317
- const getLeadingView = useCallback((item: CometChat.BaseMessage): JSX.Element | undefined => {
3442
+ const getLeadingView = useCallback((item: CometChat.BaseMessage, currentIndex?: number): JSX.Element | undefined => {
3318
3443
  let _style = getCurrentBubbleStyle(item);
3319
3444
 
3320
3445
  if (
@@ -3332,6 +3457,20 @@ export const CometChatMessageList = memo(
3332
3457
  (isAgenticUser && isIncomingMessage));
3333
3458
 
3334
3459
  if (shouldShowAvatar) {
3460
+ // §8.3a — within a batch, show the avatar only on the FIRST (top/oldest) member.
3461
+ // The list is inverted (index 0 = newest), so the older neighbour is at index+1.
3462
+ // For the rest of the batch, render a same-width spacer so the stack stays aligned.
3463
+ const list = messagesContentListRef.current || [];
3464
+ const older = typeof currentIndex === "number" ? list[currentIndex + 1] : undefined;
3465
+ const newer = typeof currentIndex === "number" ? list[currentIndex - 1] : undefined;
3466
+ const isBatchMember =
3467
+ getMessageBatchId(item) != null &&
3468
+ (isSameBatchGroup(item, older) || isSameBatchGroup(item, newer));
3469
+ const isBatchFirst = !isSameBatchGroup(item, older);
3470
+ if (isBatchMember && !isBatchFirst) {
3471
+ const avatarWidth = (_style?.avatarStyle?.containerStyle?.width as number) ?? 32;
3472
+ return <View style={{ width: avatarWidth }} />;
3473
+ }
3335
3474
  return (
3336
3475
  <CometChatAvatar
3337
3476
  image={
@@ -3352,8 +3491,19 @@ export const CometChatMessageList = memo(
3352
3491
  }, []);
3353
3492
 
3354
3493
  const getHeaderView = useCallback(
3355
- (item: CometChat.BaseMessage | any): JSX.Element | undefined => {
3494
+ (item: CometChat.BaseMessage | any, currentIndex?: number): JSX.Element | undefined => {
3356
3495
  const _style = getCurrentBubbleStyle(item);
3496
+ // §8.3a — within a batch, the sender name shows only on the first (top/oldest) member.
3497
+ const _list = messagesContentListRef.current || [];
3498
+ const _older = typeof currentIndex === "number" ? _list[currentIndex + 1] : undefined;
3499
+ const _newer = typeof currentIndex === "number" ? _list[currentIndex - 1] : undefined;
3500
+ const _isBatchMember =
3501
+ getMessageBatchId(item) != null &&
3502
+ (isSameBatchGroup(item, _older) || isSameBatchGroup(item, _newer));
3503
+ if (_isBatchMember && isSameBatchGroup(item, _older)) {
3504
+ // not the first of the batch → suppress the duplicate sender name
3505
+ return undefined;
3506
+ }
3357
3507
  if (
3358
3508
  (alignment === "leftAligned" ||
3359
3509
  (item.getSender()?.getUid() != loggedInUser.current?.getUid() && !user)) &&
@@ -3397,6 +3547,35 @@ export const CometChatMessageList = memo(
3397
3547
  if ((item as CometChat.BaseMessage).getCategory() === MessageCategoryConstants.action)
3398
3548
  return undefined;
3399
3549
 
3550
+ // §8.3a — within a batch, the receipt+timestamp shows only on the LAST (bottom/newest)
3551
+ // member. List is inverted (index 0 = newest) → the newer neighbour is at index-1.
3552
+ // Hide the row on any batch member that still has a same-batch neighbour below it.
3553
+ // EXCEPTION (§12.1): a FAILED member must always show its own status so its error
3554
+ // (and any retry affordance) is never hidden by the group collapse.
3555
+ const _batchList = messagesContentListRef.current || [];
3556
+ const _newerNeighbour =
3557
+ typeof currentIndex === "number" ? _batchList[currentIndex - 1] : undefined;
3558
+ // A batch member with a same-batch neighbour BELOW it (newer) is not the last one — its
3559
+ // receipt/timestamp is normally collapsed onto the last member of the group.
3560
+ const _isCollapsibleBatchMember =
3561
+ getMessageBatchId(item) != null && isSameBatchGroup(item, _newerNeighbour);
3562
+ // EXCEPTION (§12.1): a FAILED or moderation-BLOCKED member must always show its own error
3563
+ // icon, so a blocked/failed first/middle attachment isn't left with NO indication. A
3564
+ // moderation block is NOT stamped as metadata.error, so check the moderation status here too.
3565
+ const _hasError =
3566
+ item?.getData?.()?.metaData?.error ||
3567
+ item?.getMetadata?.()?.error ||
3568
+ (item as any)?.error ||
3569
+ getModerationStatus(item) === "disapproved";
3570
+ if (!_hasError && _isCollapsibleBatchMember) {
3571
+ // Non-last, non-failed batch member: the receipt/timestamp shows only on the LAST member,
3572
+ // but that row is what gives the bubble its bottom footprint. Returning `undefined` leaves
3573
+ // the content flush to the edge, so the rounded bottom corner doesn't render like the top.
3574
+ // Keep a small spacer so the bottom matches the top. Scoped to this branch — the default
3575
+ // (non-batch) bubble is untouched.
3576
+ return <View style={{ height: theme.spacing.spacing.s2 }} />;
3577
+ }
3578
+
3400
3579
  let isOutgoingMessage = item.getSender()?.getUid() === loggedInUser.current?.getUid();
3401
3580
  let _style = getCurrentBubbleStyle(item);
3402
3581
 
@@ -3427,13 +3606,25 @@ export const CometChatMessageList = memo(
3427
3606
  if (moderationStatus === "disapproved") {
3428
3607
  messageState = MessageReceipt.ERROR;
3429
3608
  }
3430
- // Determine if message has been edited.
3431
- // This example assumes you have a method (or property) like getEditedAt() that returns a timestamp when edited.
3609
+ // Determine if message has been edited. Text edits always qualify; media messages qualify
3610
+ // only when they carry a caption (that's the only thing you can edit on media) — the caption
3611
+ // guard also keeps async server edits like thumbnail generation from falsely tagging images.
3612
+ const editedType = (item as CometChat.BaseMessage).getType();
3613
+ const isEditedMedia =
3614
+ (editedType === MessageTypeConstants.image ||
3615
+ editedType === MessageTypeConstants.video ||
3616
+ editedType === MessageTypeConstants.audio ||
3617
+ editedType === MessageTypeConstants.file) &&
3618
+ !!(item as CometChat.MediaMessage).getCaption?.()?.trim();
3432
3619
  const isEdited =
3433
- item.getEditedAt?.() &&
3434
- (item as CometChat.BaseMessage).getType() === MessageTypeConstants.text;
3435
-
3436
- const shouldShowTimestamp = isAgenticUser ? isOutgoingMessage : !hideTimestamp;
3620
+ !!item.getEditedAt?.() &&
3621
+ (editedType === MessageTypeConstants.text || isEditedMedia);
3622
+
3623
+ // A first/middle failed/blocked batch member shows JUST the error icon (below) — hide its
3624
+ // timestamp so only the last member of the group carries the timestamp.
3625
+ const shouldShowTimestamp =
3626
+ (isAgenticUser ? isOutgoingMessage : !hideTimestamp) &&
3627
+ !(_isCollapsibleBatchMember && messageState === MessageReceipt.ERROR);
3437
3628
  return (
3438
3629
  <View>
3439
3630
  <View
@@ -3476,23 +3667,52 @@ export const CometChatMessageList = memo(
3476
3667
  alignment !== "leftAligned" &&
3477
3668
  isOutgoingMessage &&
3478
3669
  !item.getDeletedAt?.() ? (
3479
- <View style={staticStyles.receiptContainer}>
3480
- <CometChatReceipt
3481
- receipt={messageState}
3482
- style={{
3483
- deliveredIcon: _style.receiptStyles.deliveredIcon,
3484
- readIcon: _style.receiptStyles.readIcon,
3485
- sentIcon: _style.receiptStyles.sentIcon,
3486
- waitIcon: _style.receiptStyles.waitIcon,
3487
- errorIcon: _style.receiptStyles.errorIcon,
3488
- sentIconStyle: _style.receiptStyles.sentIconStyle,
3489
- readIconStyle: _style.receiptStyles.readIconStyle,
3490
- waitIconStyle: _style.receiptStyles.waitIconStyle,
3491
- errorIconStyle: _style.receiptStyles.errorIconStyle,
3492
- deliveredIconStyle: _style.receiptStyles.deliveredIconStyle,
3493
- }}
3494
- />
3495
- </View>
3670
+ (() => {
3671
+ const receiptEl = (
3672
+ <CometChatReceipt
3673
+ receipt={messageState}
3674
+ style={{
3675
+ deliveredIcon: _style.receiptStyles.deliveredIcon,
3676
+ readIcon: _style.receiptStyles.readIcon,
3677
+ sentIcon: _style.receiptStyles.sentIcon,
3678
+ waitIcon: _style.receiptStyles.waitIcon,
3679
+ errorIcon: _style.receiptStyles.errorIcon,
3680
+ sentIconStyle: _style.receiptStyles.sentIconStyle,
3681
+ readIconStyle: _style.receiptStyles.readIconStyle,
3682
+ waitIconStyle: _style.receiptStyles.waitIconStyle,
3683
+ errorIconStyle: _style.receiptStyles.errorIconStyle,
3684
+ deliveredIconStyle: _style.receiptStyles.deliveredIconStyle,
3685
+ }}
3686
+ />
3687
+ );
3688
+ // A first/middle failed/blocked batch member shows JUST the error icon (no
3689
+ // timestamp, no Retry label) so the group collapse never hides the failure.
3690
+ if (messageState === MessageReceipt.ERROR && _isCollapsibleBatchMember) {
3691
+ return <View testID="batch-error-icon" style={staticStyles.receiptContainer}>{receiptEl}</View>;
3692
+ }
3693
+ // §12.1 — a failed send becomes a tappable "Retry" (re-sends this message).
3694
+ return messageState === MessageReceipt.ERROR ? (
3695
+ <TouchableOpacity
3696
+ style={[staticStyles.receiptContainer, staticStyles.receiptRow]}
3697
+ onPress={() => resendMediaMessage(item)}
3698
+ accessibilityRole="button"
3699
+ accessibilityLabel={t("RETRY") ?? "Retry"}
3700
+ hitSlop={{ top: 6, bottom: 6, left: 6, right: 6 }}
3701
+ >
3702
+ {receiptEl}
3703
+ <Text
3704
+ style={[
3705
+ _style.dateStyles.textStyle,
3706
+ { textTransform: "none", marginLeft: 4, color: mergedTheme.color.error },
3707
+ ]}
3708
+ >
3709
+ {t("RETRY") ?? "Retry"}
3710
+ </Text>
3711
+ </TouchableOpacity>
3712
+ ) : (
3713
+ <View style={staticStyles.receiptContainer}>{receiptEl}</View>
3714
+ );
3715
+ })()
3496
3716
  ) : null}
3497
3717
  </View>
3498
3718
  </View>
@@ -3501,6 +3721,75 @@ export const CometChatMessageList = memo(
3501
3721
  [mergedTheme, isAgenticUser, hideTimestamp]
3502
3722
  );
3503
3723
 
3724
+ // §8.2 — batch-spanning viewer source: the union of image+video attachments
3725
+ // across all messages of this message's batch (in batchIndex order), plus the
3726
+ // offset where the queried message's own media begins. Null when not a real batch.
3727
+ const getBatchImageVideoItems = useCallback(
3728
+ (message: CometChat.MediaMessage): BatchMediaResult | null => {
3729
+ const batchId = getMessageBatchId(message);
3730
+ if (batchId == null) return null;
3731
+ const list = messagesContentListRef.current || [];
3732
+ const siblings = list.filter((m) => isSameBatchGroup(m, message));
3733
+ if (siblings.length <= 1) return null;
3734
+ const idxOf = (m: any) => {
3735
+ const bi = m?.getMetadata?.()?.batchIndex;
3736
+ return typeof bi === "number" ? bi : 0;
3737
+ };
3738
+ siblings.sort((a, b) => idxOf(a) - idxOf(b));
3739
+ const isVisual = (a: any) => {
3740
+ const mime = a?.getMimeType?.() ?? "";
3741
+ return mime.startsWith("image/") || mime.startsWith("video/");
3742
+ };
3743
+ const sameMsg = (a: any, b: any) => {
3744
+ const ai = a?.getId?.();
3745
+ const bi = b?.getId?.();
3746
+ if (ai && bi) return ai === bi;
3747
+ const am = a?.getMuid?.();
3748
+ const bm = b?.getMuid?.();
3749
+ return !!am && am === bm;
3750
+ };
3751
+ let items: CometChat.Attachment[] = [];
3752
+ let offsetForMessage = 0;
3753
+ for (const sib of siblings) {
3754
+ const media = ((sib as CometChat.MediaMessage).getAttachments?.() ?? []).filter(isVisual);
3755
+ if (sameMsg(sib, message)) offsetForMessage = items.length;
3756
+ items = items.concat(media);
3757
+ }
3758
+ if (items.length === 0) return null;
3759
+ return { items, offsetForMessage };
3760
+ },
3761
+ []
3762
+ );
3763
+
3764
+ const batchMediaContextValue = useMemo(
3765
+ () => ({ getBatchImageVideoItems }),
3766
+ [getBatchImageVideoItems]
3767
+ );
3768
+
3769
+ // §12.1 — retry a FAILED outgoing media message (e.g. one member of a partial batch).
3770
+ // Clears the error flag, then re-sends via the canonical CometChatUIKit path which
3771
+ // re-emits ccMessageSent inprogress→success/error; this list reconciles by muid in place.
3772
+ const resendMediaMessage = useCallback((message: CometChat.BaseMessage) => {
3773
+ try {
3774
+ if (!(message instanceof CometChat.MediaMessage)) return;
3775
+ const data: any = (message as any).getData?.() || {};
3776
+ if (data?.metaData?.error) {
3777
+ delete data.metaData.error;
3778
+ (message as any).setData?.(data);
3779
+ }
3780
+ const md: any = (message as any).getMetadata?.();
3781
+ if (md?.error) {
3782
+ delete md.error;
3783
+ (message as any).setMetadata?.(md);
3784
+ }
3785
+ (message as any).error = undefined;
3786
+ // On failure CometChatUIKit.sendMediaMessage re-applies the error flag + emits error.
3787
+ CometChatUIKit.sendMediaMessage(message as CometChat.MediaMessage).catch(() => {});
3788
+ } catch (e) {
3789
+ // best-effort retry
3790
+ }
3791
+ }, []);
3792
+
3504
3793
  const reactToMessage = (emoji: string, messageObj?: CometChat.BaseMessage) => {
3505
3794
  const originalMessage = messageObj || selectedMessage;
3506
3795
  const msgObj = CommonUtils.clone(originalMessage);
@@ -3946,9 +4235,9 @@ export const CometChatMessageList = memo(
3946
4235
  return hasTemplate?.HeaderView
3947
4236
  ? hasTemplate?.HeaderView(message, bubbleAlignment)
3948
4237
  : !isThreaded
3949
- ? getHeaderView(message)
4238
+ ? getHeaderView(message, currentIndex)
3950
4239
  : undefined;
3951
- }, [message, bubbleAlignment, hasTemplate, getHeaderView]);
4240
+ }, [message, bubbleAlignment, hasTemplate, getHeaderView, currentIndex]);
3952
4241
 
3953
4242
  const FooterView = useMemo(() => {
3954
4243
  return hasTemplate?.FooterView
@@ -3971,8 +4260,8 @@ export const CometChatMessageList = memo(
3971
4260
  if (hasTemplate?.LeadingView) {
3972
4261
  return hasTemplate.LeadingView(message, bubbleAlignment);
3973
4262
  }
3974
- return !isThreaded ? getLeadingView(message) : undefined;
3975
- }, [isThreaded, message, getLeadingView, hasTemplate, bubbleAlignment]);
4263
+ return !isThreaded ? getLeadingView(message, currentIndex) : undefined;
4264
+ }, [isThreaded, message, getLeadingView, hasTemplate, bubbleAlignment, currentIndex]);
3976
4265
 
3977
4266
  const BottomView = useMemo(() => {
3978
4267
  const moderationStatus = getModerationStatus(message);
@@ -4334,7 +4623,14 @@ export const CometChatMessageList = memo(
4334
4623
  return `index_${index}`;
4335
4624
  }, []);
4336
4625
 
4337
- const itemSeparator = useCallback(() => <View style={staticStyles.itemSeparator} />, [staticStyles]);
4626
+ // `tight` collapses the gap between two consecutive messages of the SAME batch so a
4627
+ // fanned-out mixed batch (images + files + audio…) reads as one grouped message.
4628
+ const itemSeparator = useCallback(
4629
+ (tight?: boolean) => (
4630
+ <View style={tight ? staticStyles.itemSeparatorTight : staticStyles.itemSeparator} />
4631
+ ),
4632
+ [staticStyles]
4633
+ );
4338
4634
 
4339
4635
  const getAgentEmptyView = useCallback(() => {
4340
4636
  if (!user) return <></>;
@@ -4408,15 +4704,7 @@ export const CometChatMessageList = memo(
4408
4704
  )}
4409
4705
 
4410
4706
  {!hideSuggestedMessages && displaySuggestions?.length > 0 && (
4411
- <View
4412
- style={{
4413
- flexDirection: "row",
4414
- flexWrap: "wrap",
4415
- justifyContent: "center",
4416
- paddingHorizontal: 0,
4417
- maxWidth: "100%",
4418
- }}
4419
- >
4707
+ <View style={staticStyles.suggestionsWrap}>
4420
4708
  {displaySuggestions.map((suggestion, idx) => (
4421
4709
  <TouchableOpacity
4422
4710
  key={idx}
@@ -4474,12 +4762,52 @@ export const CometChatMessageList = memo(
4474
4762
  mergedTheme,
4475
4763
  ]);
4476
4764
 
4765
+ const fetchConversationStarters = (): Promise<string[]> => {
4766
+ const receiverId = user?.getUid() ?? group?.getGuid() ?? '';
4767
+ const receiverType = user
4768
+ ? CometChat.RECEIVER_TYPE.USER
4769
+ : CometChat.RECEIVER_TYPE.GROUP;
4770
+ return CometChat.getConversationStarter(receiverId, receiverType);
4771
+ };
4772
+
4773
+ const fetchSmartReplies = (): Promise<string[]> => {
4774
+ const msg = latestReceivedMessageRef.current;
4775
+ if (!msg) return Promise.resolve([]);
4776
+ const receiverId = user?.getUid() ?? group?.getGuid() ?? '';
4777
+ const receiverType = user
4778
+ ? CometChat.RECEIVER_TYPE.USER
4779
+ : CometChat.RECEIVER_TYPE.GROUP;
4780
+ return CometChat.getSmartReplies(receiverId, receiverType)
4781
+ .then((res) => Object.values(res) as string[]);
4782
+ };
4783
+
4784
+ // ponytail: group action messages (e.g. "X joined the group") aren't real
4785
+ // conversation messages, so they shouldn't hide the conversation starter chips (ENG-36769).
4786
+ const hasOnlyActionMessages = useMemo(
4787
+ () =>
4788
+ messagesList.length > 0 &&
4789
+ messagesList.every(
4790
+ (m) => m?.getCategory?.() === MessageCategoryConstants.action
4791
+ ),
4792
+ [messagesList]
4793
+ );
4794
+
4477
4795
  const getEmptyStateView = useCallback(() => {
4478
4796
  const isAgenticUserCheck = user?.getRole?.() === "@agentic";
4479
4797
 
4480
4798
  if (isAgenticUserCheck) {
4481
4799
  return getAgentEmptyView();
4482
4800
  }
4801
+ if (showConversationStarters) {
4802
+ return (
4803
+ <View style={{ flex: 1, justifyContent: 'flex-end' }}>
4804
+ <CometChatConversationStarter
4805
+ getConversationStarters={fetchConversationStarters}
4806
+ onSuggestionClicked={(text) => onSuggestedMessageClick?.(text)}
4807
+ />
4808
+ </View>
4809
+ );
4810
+ }
4483
4811
  if (EmptyView)
4484
4812
  return (
4485
4813
  <>
@@ -4495,7 +4823,7 @@ export const CometChatMessageList = memo(
4495
4823
  titleStyle={mergedTheme.messageListStyles.emptyStateStyle?.textStyle as TextStyle}
4496
4824
  />
4497
4825
  );
4498
- }, [mergedTheme, EmptyView, getAgentEmptyView, user]);
4826
+ }, [mergedTheme, EmptyView, getAgentEmptyView, user, group, showConversationStarters]);
4499
4827
 
4500
4828
  const getErrorStateView = useCallback(() => {
4501
4829
  if (hideError) return null;
@@ -4800,6 +5128,17 @@ export const CometChatMessageList = memo(
4800
5128
  const memoizedRenderItem = useCallback(
4801
5129
  ({ item, index }: any) => {
4802
5130
  const nextItem = messagesContentListRef.current[index + 1];
5131
+ const prevItem = messagesContentListRef.current[index - 1];
5132
+ // Collapse this row's vertical padding (and the separator) toward a neighbour that belongs
5133
+ // to the SAME fan-out batch, so a mixed batch (images + files + audio…) reads as one grouped
5134
+ // message. Gated on a shared batchId + sender on the NEIGHBOUR alone — that already proves a
5135
+ // real multi-message batch, so we do NOT also require the `batchSize > 1` metadata field,
5136
+ // which can be absent on reloaded messages and silently left the batch un-clubbed (the big
5137
+ // gap). A lone batchId (single-attachment send) has no same-batch neighbour → never tightened.
5138
+ // List is inverted: index+1 = older (above), index-1 = newer (below); tightTop shrinks toward
5139
+ // the older member, tightBottom toward the newer.
5140
+ const tightTop = isSameBatchGroup(item, nextItem);
5141
+ const tightBottom = isSameBatchGroup(item, prevItem);
4803
5142
  const currentItemMs = sentAtToMs(item);
4804
5143
  const nextItemMs = sentAtToMs(nextItem);
4805
5144
  const showSeparator = shouldShowSeparator(index, currentItemMs, nextItemMs);
@@ -4829,6 +5168,8 @@ export const CometChatMessageList = memo(
4829
5168
  dayHeaderString={dayHeaderString}
4830
5169
  RenderMessageItem={RenderMessageItem}
4831
5170
  itemSeparator={itemSeparator}
5171
+ tightTop={tightTop}
5172
+ tightBottom={tightBottom}
4832
5173
  staticStyles={staticStyles}
4833
5174
  onLayout={handleItemLayout}
4834
5175
  showNewMessageIndicator={showNewMessageIndicator}
@@ -4862,7 +5203,15 @@ export const CometChatMessageList = memo(
4862
5203
  );
4863
5204
 
4864
5205
 
5206
+ // §8.3a — reorder each batch's messages by batchIndex for display, so a batch always
5207
+ // shows in the sender's order even if the kinds arrived out of order (independent uploads).
5208
+ // Keep the neighbour-lookup ref pointing at the SAME ordered list the FlatList renders,
5209
+ // so batch grouping (avatar-first / receipt-last) and the pager stay index-consistent.
5210
+ const orderedMessagesList = useMemo(() => orderBatchRuns(messagesList), [messagesList]);
5211
+ messagesContentListRef.current = orderedMessagesList;
5212
+
4865
5213
  return (
5214
+ <CometChatBatchMediaContext.Provider value={batchMediaContextValue}>
4866
5215
  <View style={mergedTheme.messageListStyles.containerStyle}>
4867
5216
  {listState == "loading" && messagesList.length == 0 ? (
4868
5217
  getLoadingStateView()
@@ -4895,6 +5244,7 @@ export const CometChatMessageList = memo(
4895
5244
  {/* Navigation loading for far message fetching and scroll operations */}
4896
5245
  {navigationLoading && (getLoadingStateView())}
4897
5246
  <FlatList
5247
+ testID="message-list"
4898
5248
  showsVerticalScrollIndicator={false}
4899
5249
  ref={messageListRef}
4900
5250
  onMomentumScrollEnd={handleScrollInternal}
@@ -4909,7 +5259,7 @@ export const CometChatMessageList = memo(
4909
5259
  onStartReachedThreshold={0.5}
4910
5260
  scrollEventThrottle={16}
4911
5261
  keyboardShouldPersistTaps={(Platform.OS === "ios" ? "handled" : "always") as "handled" | "always"}
4912
- data={messagesList}
5262
+ data={orderedMessagesList}
4913
5263
  extraData={themeMode}
4914
5264
  keyExtractor={keyExtractor}
4915
5265
  renderItem={memoizedRenderItem}
@@ -4926,10 +5276,29 @@ export const CometChatMessageList = memo(
4926
5276
  />
4927
5277
 
4928
5278
 
5279
+ {/* ENG-36769: keep conversation starters visible when the group only
5280
+ has action messages (e.g. "X joined the group") and no real messages yet */}
5281
+ {showConversationStarters && hasOnlyActionMessages && (
5282
+ <CometChatConversationStarter
5283
+ getConversationStarters={fetchConversationStarters}
5284
+ onSuggestionClicked={(text) => onSuggestedMessageClick?.(text)}
5285
+ />
5286
+ )}
4929
5287
  {CustomListHeader && <CustomListHeader />}
4930
5288
  {ongoingCallView}
5289
+ {showSmartReplies && showSmartRepliesView && (
5290
+ <CometChatSmartReplies
5291
+ key={smartRepliesKey}
5292
+ getSmartReplies={fetchSmartReplies}
5293
+ onSuggestionClicked={(text) => {
5294
+ setShowSmartRepliesView(false);
5295
+ onSuggestedMessageClick?.(text);
5296
+ }}
5297
+ closeCallback={() => setShowSmartRepliesView(false)}
5298
+ />
5299
+ )}
4931
5300
  {FooterView && (
4932
- <View style={[{ bottom: 0 }]}>
5301
+ <View style={staticStyles.bottomZero}>
4933
5302
  <FooterView
4934
5303
  group={group}
4935
5304
  user={user}
@@ -5045,6 +5414,7 @@ export const CometChatMessageList = memo(
5045
5414
  }}
5046
5415
  />
5047
5416
  </View>
5417
+ </CometChatBatchMediaContext.Provider>
5048
5418
  );
5049
5419
 
5050
5420
  }
@@ -5067,6 +5437,27 @@ const staticStyles = StyleSheet.create({
5067
5437
  alignItems: 'center' as 'center',
5068
5438
  marginBottom: 8,
5069
5439
  },
5440
+ // Collapse the padding on the side of a message row that faces a same-batch neighbour,
5441
+ // so a fanned-out batch reads as one grouped message (vs the default paddingVertical: 8).
5442
+ messageTightTop: {
5443
+ paddingTop: 2,
5444
+ },
5445
+ messageTightBottom: {
5446
+ paddingBottom: 2,
5447
+ },
5448
+ // Full-bleed highlight behind a message row; the background colour is animated at the call site.
5449
+ highlightOverlay: {
5450
+ position: 'absolute' as 'absolute',
5451
+ left: 0,
5452
+ right: 0,
5453
+ top: 0,
5454
+ bottom: 0,
5455
+ zIndex: 1,
5456
+ },
5457
+ // When a date separator sits above the row, drop the highlight below it (separator height).
5458
+ highlightOverlayBelowSeparator: {
5459
+ top: 40,
5460
+ },
5070
5461
  footerContainer: {
5071
5462
  padding: 10,
5072
5463
  alignItems: 'center' as 'center',
@@ -5074,6 +5465,10 @@ const staticStyles = StyleSheet.create({
5074
5465
  itemSeparator: {
5075
5466
  height: 8,
5076
5467
  },
5468
+ // Collapsed gap between two members of the same fan-out batch (grouped-message look).
5469
+ itemSeparatorTight: {
5470
+ height: 2,
5471
+ },
5077
5472
  loadingContainer: {
5078
5473
  padding: 16,
5079
5474
  },
@@ -5125,6 +5520,20 @@ const staticStyles = StyleSheet.create({
5125
5520
  alignItems: "center",
5126
5521
  justifyContent: "center",
5127
5522
  },
5523
+ receiptRow: {
5524
+ flexDirection: "row",
5525
+ alignItems: "center",
5526
+ },
5527
+ suggestionsWrap: {
5528
+ flexDirection: "row",
5529
+ flexWrap: "wrap",
5530
+ justifyContent: "center",
5531
+ paddingHorizontal: 0,
5532
+ maxWidth: "100%",
5533
+ },
5534
+ bottomZero: {
5535
+ bottom: 0,
5536
+ },
5128
5537
  positionRelative: {
5129
5538
  position: 'relative',
5130
5539
  },