@cometchat/chat-uikit-react-native 5.5.4 → 5.7.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 (215) hide show
  1. package/android/src/main/java/com/reactnativecometchatuikit/CometChatKeyboardModule.kt +101 -0
  2. package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +1 -0
  3. package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +78 -3
  4. package/android/src/main/java/com/reactnativecometchatuikit/KeyboardDirectionWatcher.kt +64 -0
  5. package/android/src/main/java/com/reactnativecometchatuikit/KeyboardLanguageDirection.kt +44 -0
  6. package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +287 -49
  7. package/android/src/main/java/com/reactnativecometchatuikit/SafeFileName.java +78 -0
  8. package/ios/CCLocalFileGuard.h +19 -0
  9. package/ios/CCLocalFileGuard.m +34 -0
  10. package/ios/CometChatKeyboardModule.m +9 -0
  11. package/ios/CometChatKeyboardModule.swift +71 -0
  12. package/ios/FileManager.m +70 -6
  13. package/ios/KeyboardLanguageDirection.swift +24 -0
  14. package/ios/RichTextEditorView.swift +253 -51
  15. package/ios/RichTextEditorViewManager.m +1 -0
  16. package/ios/VideoManager.m +1 -1
  17. package/package.json +18 -3
  18. package/src/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.tsx +41 -57
  19. package/src/CometChatAIAssistantChatHistory/Skeleton.tsx +4 -1
  20. package/src/CometChatAIAssistantChatHistory/style.ts +5 -2
  21. package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +145 -63
  22. package/src/CometChatCompactMessageComposer/styles.ts +7 -7
  23. package/src/CometChatConversations/CometChatConversations.tsx +276 -147
  24. package/src/CometChatConversations/Skeleton.tsx +4 -1
  25. package/src/CometChatConversations/style.ts +1 -1
  26. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +39 -18
  27. package/src/CometChatGroupMembers/Skeleton.tsx +4 -1
  28. package/src/CometChatGroupMembers/style.ts +6 -4
  29. package/src/CometChatGroups/CometChatGroups.tsx +74 -58
  30. package/src/CometChatGroups/GroupsStyle.ts +1 -1
  31. package/src/CometChatGroups/Skeleton.tsx +4 -1
  32. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +190 -96
  33. package/src/CometChatMessageComposer/styles.tsx +1 -1
  34. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +28 -15
  35. package/src/CometChatMessageHeader/listners.ts +76 -56
  36. package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +8 -1
  37. package/src/CometChatMessageInformation/Skeleton.tsx +4 -1
  38. package/src/CometChatMessageList/CometChatMessageList.tsx +1465 -313
  39. package/src/CometChatMessageList/SwipeToReplyView.tsx +61 -0
  40. package/src/CometChatMessageList/style.ts +32 -32
  41. package/src/CometChatMessageList/swipeToReply.ts +25 -0
  42. package/src/CometChatNotificationFeed/CometChatNotificationFeed.tsx +81 -10
  43. package/src/CometChatNotificationFeed/style.ts +1 -1
  44. package/src/CometChatNotificationFeed/utils.ts +17 -18
  45. package/src/CometChatPinnedMessages/CometChatPinnedMessages.tsx +82 -3
  46. package/src/CometChatPinnedMessages/style.ts +5 -5
  47. package/src/CometChatRichTextEditor/RichTextEditorViewNativeComponent.ts +2 -0
  48. package/src/CometChatRichTextEditor/index.tsx +3 -0
  49. package/src/CometChatSavedMessages/CometChatSavedMessages.tsx +83 -15
  50. package/src/CometChatSavedMessages/style.ts +3 -3
  51. package/src/CometChatSearch/CometChatSearch.tsx +391 -136
  52. package/src/CometChatSearch/Skeleton.tsx +4 -1
  53. package/src/CometChatSearch/searchLabels.ts +26 -0
  54. package/src/CometChatSearch/style.ts +7 -7
  55. package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +34 -8
  56. package/src/CometChatThreadHeader/Header.tsx +2 -2
  57. package/src/CometChatUsers/CometChatUsers.tsx +10 -1
  58. package/src/CometChatUsers/Skeleton.tsx +4 -1
  59. package/src/CometChatUsers/style.ts +1 -1
  60. package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +27 -1
  61. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +16 -4
  62. package/src/calls/CometChatCallLogs/Skeleton.tsx +4 -1
  63. package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +11 -3
  64. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +10 -2
  65. package/src/extensions/CollaborativeBubble/style.ts +4 -4
  66. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +1 -1
  67. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +1 -1
  68. package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +11 -6
  69. package/src/extensions/LinkPreview/style.ts +6 -6
  70. package/src/extensions/Polls/Header.tsx +1 -1
  71. package/src/extensions/Polls/Polls.tsx +25 -12
  72. package/src/extensions/Polls/PollsBubble.tsx +10 -6
  73. package/src/extensions/Polls/style.ts +4 -4
  74. package/src/extensions/Stickers/CometChatStickerKeyboard/CometChatStickerKeyboard.tsx +2 -2
  75. package/src/extensions/Stickers/CometChatStickerKeyboard/Skeleton.tsx +1 -1
  76. package/src/extensions/Stickers/CometChatStickerKeyboard/style.ts +1 -1
  77. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +4 -2
  78. package/src/index.ts +11 -1
  79. package/src/shared/CometChatUiKit/CometChatUIKit.ts +102 -2
  80. package/src/shared/CometChatUiKit/UIKitSettings.ts +28 -0
  81. package/src/shared/events/CometChatUIEventHandler/Listener.ts +10 -0
  82. package/src/shared/events/index.ts +4 -0
  83. package/src/shared/events/offline.ts +28 -0
  84. package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +18 -13
  85. package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +15 -7
  86. package/src/shared/formatters/CometChatTextFormatter.ts +11 -0
  87. package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +7 -4
  88. package/src/shared/framework/MessageDataSource.tsx +51 -108
  89. package/src/shared/helper/LocalizedDateHelper.ts +64 -4
  90. package/src/shared/helper/helperFunctions.ts +71 -4
  91. package/src/shared/helper/keyboardDirection.ts +54 -0
  92. package/src/shared/helper/layoutDirection.ts +205 -0
  93. package/src/shared/helper/pluralRules.ts +67 -0
  94. package/src/shared/helper/textDirection.ts +118 -0
  95. package/src/shared/icons/Icon.tsx +37 -2
  96. package/src/shared/icons/components/format-list-numbered-rtl.tsx +15 -0
  97. package/src/shared/index.ts +2 -0
  98. package/src/shared/offline/OfflineHub.ts +651 -0
  99. package/src/shared/offline/OfflineMediaBubble.tsx +49 -0
  100. package/src/shared/offline/OfflineViews.tsx +222 -0
  101. package/src/shared/offline/conversationPins.ts +137 -0
  102. package/src/shared/offline/conversations.ts +325 -0
  103. package/src/shared/offline/frameProbe.ts +24 -0
  104. package/src/shared/offline/gate.ts +94 -0
  105. package/src/shared/offline/groupActions.ts +81 -0
  106. package/src/shared/offline/identity.ts +162 -0
  107. package/src/shared/offline/index.ts +76 -0
  108. package/src/shared/offline/media.ts +247 -0
  109. package/src/shared/offline/notices.ts +84 -0
  110. package/src/shared/offline/reconcile.ts +296 -0
  111. package/src/shared/offline/searchOutcome.ts +62 -0
  112. package/src/shared/offline/send.ts +430 -0
  113. package/src/shared/offline/stateContract.ts +85 -0
  114. package/src/shared/offline/threadReplies.ts +125 -0
  115. package/src/shared/offline/twoPhase.ts +372 -0
  116. package/src/shared/offline/unsentActions.ts +168 -0
  117. package/src/shared/offline/useOfflineMediaUri.ts +87 -0
  118. package/src/shared/offline/useOfflineReconnect.ts +25 -0
  119. package/src/shared/offline/useOfflineSessionEnded.ts +22 -0
  120. package/src/shared/offline/useOfflineUploadTray.ts +76 -0
  121. package/src/shared/offline/usePresenceHidden.ts +33 -0
  122. package/src/shared/resources/CometChatLocalizeNew/CometChatLocalizationHelper.ts +2 -0
  123. package/src/shared/resources/CometChatLocalizeNew/resources/ar/translation.json +720 -0
  124. package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +74 -3
  125. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +75 -4
  126. package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +74 -3
  127. package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +75 -4
  128. package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +74 -3
  129. package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +74 -3
  130. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +74 -3
  131. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +74 -3
  132. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +74 -3
  133. package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +82 -3
  134. package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +74 -3
  135. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +74 -3
  136. package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +74 -3
  137. package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +90 -3
  138. package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +74 -3
  139. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +74 -3
  140. package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +74 -3
  141. package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +74 -3
  142. package/src/shared/services/UploadQueueService.ts +106 -1
  143. package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +13 -12
  144. package/src/shared/utils/CometChatMessagePreview/style.ts +1 -1
  145. package/src/shared/utils/MessageReceiptUtils.ts +8 -0
  146. package/src/shared/utils/MessageUtils.tsx +14 -14
  147. package/src/shared/utils/PermissionUtil.ts +16 -5
  148. package/src/shared/utils/SavedMessagesHelper.ts +18 -1
  149. package/src/shared/utils/attachmentLimits.ts +3 -2
  150. package/src/shared/utils/catchUpCursor.ts +36 -0
  151. package/src/shared/utils/conversationUtils.ts +3 -5
  152. package/src/shared/utils/failedMessageRetry.ts +73 -0
  153. package/src/shared/utils/fileIconFontSize.ts +10 -0
  154. package/src/shared/utils/fileSizeLabel.ts +16 -0
  155. package/src/shared/utils/groupActionText.ts +75 -0
  156. package/src/shared/utils/messageIdentity.ts +38 -0
  157. package/src/shared/views/CometChatAIAssistantMessageBubble/CometChatAIAssistantMessageBubble.tsx +12 -8
  158. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreview.style.ts +1 -1
  159. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentPreviewItem.tsx +5 -3
  160. package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentTile.tsx +22 -17
  161. package/src/shared/views/CometChatAttachmentViewer/CometChatAttachmentViewer.tsx +45 -12
  162. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +16 -10
  163. package/src/shared/views/CometChatAudiosBubble/CometChatAudiosBubble.tsx +20 -8
  164. package/src/shared/views/CometChatBadge/CometChatBadge.tsx +8 -4
  165. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +6 -2
  166. package/src/shared/views/CometChatComposerErrorBanner.tsx +3 -1
  167. package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +8 -3
  168. package/src/shared/views/CometChatConversationStarter/CometChatConversationStarter.tsx +2 -2
  169. package/src/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.tsx +5 -3
  170. package/src/shared/views/CometChatEmojiKeyboard/emojis.ts +8 -8
  171. package/src/shared/views/CometChatEmojiKeyboard/style.ts +2 -2
  172. package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +13 -27
  173. package/src/shared/views/CometChatFilesBubble/CometChatFilesBubble.tsx +65 -15
  174. package/src/shared/views/CometChatImageViewerModal/ImageViewerModal.tsx +7 -3
  175. package/src/shared/views/CometChatImagesBubble/CometChatImagesBubble.tsx +56 -25
  176. package/src/shared/views/CometChatInlineAudioRecorder/CometChatInlineAudioRecorder.tsx +41 -21
  177. package/src/shared/views/CometChatInlineAudioRecorder/useAudioRecorder.ts +7 -3
  178. package/src/shared/views/CometChatLinkConfirmPopup/CometChatLinkConfirmPopup.tsx +7 -3
  179. package/src/shared/views/CometChatList/CometChatList.tsx +478 -21
  180. package/src/shared/views/CometChatList/Header.tsx +5 -2
  181. package/src/shared/views/CometChatList/sectionLetter.ts +44 -0
  182. package/src/shared/views/CometChatList/styles.ts +7 -7
  183. package/src/shared/views/CometChatListItem/CometChatListItem.tsx +6 -4
  184. package/src/shared/views/CometChatMediaRecorder/CometChatAudioPlayer.tsx +16 -10
  185. package/src/shared/views/CometChatMediaRecorder/Timer.tsx +5 -1
  186. package/src/shared/views/CometChatMediaViewer/CometChatMediaViewer.tsx +43 -16
  187. package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +24 -4
  188. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +19 -2
  189. package/src/shared/views/CometChatNewMessageIndicator/CometChatNewMessageIndicator.tsx +3 -2
  190. package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +59 -12
  191. package/src/shared/views/CometChatReactionList/ReactionListStyle.tsx +2 -2
  192. package/src/shared/views/CometChatReactionList/Skeleton.tsx +4 -1
  193. package/src/shared/views/CometChatReactions/CometChatReactions.tsx +6 -2
  194. package/src/shared/views/CometChatReportDialog/CometChatReportDialog.tsx +7 -3
  195. package/src/shared/views/CometChatReportDialog/style.ts +1 -1
  196. package/src/shared/views/CometChatSmartReplies/CometChatSmartReplies.tsx +1 -1
  197. package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +4 -0
  198. package/src/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.tsx +20 -13
  199. package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +3 -2
  200. package/src/shared/views/CometChatSuggestionList/Skeleton.tsx +1 -1
  201. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +29 -3
  202. package/src/shared/views/CometChatTooltipMenu/CometChatTooltipMenu.tsx +20 -30
  203. package/src/shared/views/CometChatTooltipMenu/tooltipPosition.ts +43 -0
  204. package/src/shared/views/CometChatVideoBubble/style.ts +2 -2
  205. package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +4 -1
  206. package/src/shared/views/CometChatVideosBubble/CometChatVideosBubble.tsx +58 -24
  207. package/src/shared/views/CometChatVoiceNoteBubble/CometChatVoiceNoteBubble.tsx +24 -12
  208. package/src/shared/views/SenderLabel.tsx +41 -0
  209. package/src/theme/default/default.ts +1 -1
  210. package/src/theme/type.ts +17 -0
  211. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  212. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  213. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  214. package/android/.gradle/7.4/gc.properties +0 -0
  215. package/android/.gradle/vcs-1/gc.properties +0 -0
@@ -48,6 +48,10 @@ import {
48
48
  ViewAlignment,
49
49
  } from "../shared/constants/UIKitConstants";
50
50
  import { MessageEvents } from "../shared/events";
51
+ import { afterFirstAnswer, quietAwareOnError, routeSend } from "../shared/offline/send";
52
+ import { isOfflineOn } from "../shared/offline/gate";
53
+ import { useOfflineThreadTrayReset, useOfflineUploadTray } from "../shared/offline/useOfflineUploadTray";
54
+ import { offlineMutationErrorText } from "../shared/offline/notices";
51
55
  import { CometChatUIEventHandler } from "../shared/events/CometChatUIEventHandler/CometChatUIEventHandler";
52
56
  import { CometChatMessageEvents } from "../shared/events/CometChatMessageEvents";
53
57
  import { CometChatMessageComposerAction, DeepPartial } from "../shared/helper/types";
@@ -81,6 +85,7 @@ import { getFileUploadLimits, clampToServer, acceptPickedAttachments, toastAttac
81
85
  import { partitionAttachmentsByKind, AttachmentKindGroup } from "../shared/utils/partitionAttachmentsByKind";
82
86
  import { attachmentCountLabel } from "../shared/utils/conversationUtils";
83
87
  import { CometChatComposerErrorBanner } from "../shared/views/CometChatComposerErrorBanner";
88
+ import { LayoutDirectionContext, directionStyle, useComponentLayoutDirection } from "../shared/helper/layoutDirection";
84
89
 
85
90
  type MentionOverlap = {
86
91
  key: string;
@@ -175,6 +180,8 @@ type IntRange<F extends number, T extends number> = Exclude<Enumerate<T>, Enumer
175
180
  * Properties for the CometChat message composer component.
176
181
  */
177
182
  export interface CometChatMessageComposerInterface {
183
+ /** Lays this component out `"ltr"` or `"rtl"`, overriding the kit's global `layoutDirection`. Not set = inherit. */
184
+ layoutDirection?: "ltr" | "rtl";
178
185
  /**
179
186
  * Message composer identifier.
180
187
  *
@@ -537,6 +544,8 @@ export const CometChatMessageComposer = React.forwardRef(
537
544
  // §1 — false → legacy single-select, send-immediately attachments (no tray/fan-out).
538
545
  enableMultipleAttachments = true,
539
546
  } = props;
547
+ // ENG-41333: own setting → enclosing component → global; drives the root and the context.
548
+ const direction = useComponentLayoutDirection(props.layoutDirection);
540
549
 
541
550
  // Helper function to check if user is agentic
542
551
  const isAgenticUser = useCallback(() => {
@@ -635,6 +644,16 @@ export const CometChatMessageComposer = React.forwardRef(
635
644
  const [trayViewerVisible, setTrayViewerVisible] = React.useState(false);
636
645
  const [trayViewerIndex, setTrayViewerIndex] = React.useState(0);
637
646
  const [plainText, setPlainText] = React.useState(initialComposertext ?? "");
647
+ /**
648
+ * The raw input (no formatting) lives twice: a ref, which handlers read synchronously, and state,
649
+ * which renders read (send button, CometChatMessageInput's caret side). One write path keeps them
650
+ * equal. Only clearInputBox/clearEditPreview write one of them (the state) on their own; see the
651
+ * composer tests.
652
+ */
653
+ const setRawText = (value: string) => {
654
+ plainTextInput.current = value;
655
+ setPlainText(value);
656
+ };
638
657
  const bottomSheetRef = React.useRef<any>(null);
639
658
  const [showStopButton, setShowStopButton] = React.useState(false);
640
659
  const [isSendButtonDisabledForDelay, setIsSendButtonDisabledForDelay] = React.useState(false);
@@ -753,10 +772,10 @@ export const CometChatMessageComposer = React.forwardRef(
753
772
  // RBAC/SBAC presign authorization. Read the refs fresh here (uploadQueue is memoized at mount,
754
773
  // the refs are not) — constructor-time capture would be stale.
755
774
  newAttachments.forEach(a =>
756
- uploadQueue.enqueue(a, { receiver: chatWithId.current, receiverType: chatWith.current })
775
+ uploadQueue.enqueue(a, { receiver: chatWithId.current, receiverType: chatWith.current, parentMessageId })
757
776
  );
758
777
  },
759
- [selectedAttachments, uploadQueue]
778
+ [selectedAttachments, uploadQueue, parentMessageId]
760
779
  );
761
780
 
762
781
  const handleRemoveAttachment = useCallback(
@@ -820,7 +839,8 @@ export const CometChatMessageComposer = React.forwardRef(
820
839
  if (sendButtonDelayTimer.current) {
821
840
  clearTimeout(sendButtonDelayTimer.current);
822
841
  }
823
- uploadQueue.cancelAll();
842
+ // Offline OFF: destroy the batch as today; ON: detach so it can be restored.
843
+ uploadQueue.leave();
824
844
  };
825
845
  }, []);
826
846
 
@@ -850,8 +870,7 @@ export const CometChatMessageComposer = React.forwardRef(
850
870
  sendTextMessage,
851
871
  getText: () => messageInputRef.current?.getText?.() ?? "",
852
872
  setText: (text: string) => {
853
- plainTextInput.current = text;
854
- setPlainText(text);
873
+ setRawText(text);
855
874
  messageInputRef.current?.setNativeProps?.({ text });
856
875
  },
857
876
  clear: () => messageInputRef.current?.clear?.(),
@@ -886,7 +905,7 @@ export const CometChatMessageComposer = React.forwardRef(
886
905
  <Icon name='info-fill' color={theme.color.error}></Icon>
887
906
  <Text
888
907
  style={{
889
- marginLeft: 5,
908
+ marginStart: 5,
890
909
  color: theme.color.error,
891
910
  ...theme.typography.caption1.regular,
892
911
  }}
@@ -970,8 +989,7 @@ export const CometChatMessageComposer = React.forwardRef(
970
989
  // Sort edits by startIndex to apply them in order
971
990
  edits.sort((a: any, b: any) => a.startIndex - b.startIndex);
972
991
 
973
- plainTextInput.current = getPlainString(editSourceText, edits) ?? "";
974
- setPlainText(plainTextInput.current);
992
+ setRawText(getPlainString(editSourceText, edits) ?? "");
975
993
  setOriginalText(plainTextInput.current.trim());
976
994
  setHasEdited(false);
977
995
  const hashMap = new Map();
@@ -1006,7 +1024,7 @@ export const CometChatMessageComposer = React.forwardRef(
1006
1024
  if (messagePreview) {
1007
1025
  setMessagePreview(null);
1008
1026
  mentionMap.current = new Map();
1009
- plainTextInput.current = "";
1027
+ // The edit text stays in the input and in the raw text, so Send sends what is shown, as a reply.
1010
1028
  setOriginalText("");
1011
1029
  }
1012
1030
 
@@ -1198,39 +1216,53 @@ export const CometChatMessageComposer = React.forwardRef(
1198
1216
 
1199
1217
  // §7/§12.1 — independent per-message send: one kind can fail while others deliver.
1200
1218
  const outgoing = buildMessage(group, index, muid);
1201
- CometChat.sendMediaMessage(outgoing)
1202
- .then((msg: any) => {
1203
- CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
1204
- message: msg,
1205
- status: messageStatus.success,
1219
+ // Gate read once, at send: OFF runs today's code unchanged; ON goes through the
1220
+ // kit's one send helper (hub reports state and the public events, once).
1221
+ const routed = routeSend(outgoing, "media", () => {
1222
+ CometChat.sendMediaMessage(outgoing)
1223
+ .then((msg: any) => {
1224
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
1225
+ message: msg,
1226
+ status: messageStatus.success,
1227
+ });
1228
+ if (replyMessageId) {
1229
+ CometChatMessageEvents.emit(CometChatMessageEvents.ccReplyToMessage, {
1230
+ message: msg,
1231
+ status: messageStatus.success,
1232
+ });
1233
+ }
1234
+ })
1235
+ .catch((error: any) => {
1236
+ // Preserve the batch metadata; just flag this message's optimistic echo as failed.
1237
+ const currentData = localMessage.getData() || {};
1238
+ localMessage.setData({ ...currentData, metaData: { error: true } });
1239
+ const md = (localMessage.getMetadata?.() as Record<string, unknown>) || {};
1240
+ localMessage.setMetadata({ ...md, error: true });
1241
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
1242
+ message: localMessage,
1243
+ status: messageStatus.error,
1244
+ });
1245
+ onError && onError(error);
1206
1246
  });
1247
+ }, {
1248
+ onSent: (msg: any) => {
1207
1249
  if (replyMessageId) {
1208
1250
  CometChatMessageEvents.emit(CometChatMessageEvents.ccReplyToMessage, {
1209
1251
  message: msg,
1210
1252
  status: messageStatus.success,
1211
1253
  });
1212
1254
  }
1213
- })
1214
- .catch((error: any) => {
1215
- // Preserve the batch metadata; just flag this message's optimistic echo as failed.
1216
- const currentData = localMessage.getData() || {};
1217
- localMessage.setData({ ...currentData, metaData: { error: true } });
1218
- const md = (localMessage.getMetadata?.() as Record<string, unknown>) || {};
1219
- localMessage.setMetadata({ ...md, error: true });
1220
- CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
1221
- message: localMessage,
1222
- status: messageStatus.error,
1223
- });
1224
- onError && onError(error);
1225
- });
1255
+ },
1256
+ onFailed: quietAwareOnError(onError),
1257
+ });
1258
+ void routed;
1226
1259
  });
1227
1260
 
1228
1261
  // Clear composer state immediately
1229
1262
  setSelectedAttachments([]);
1230
1263
  selectedAttachmentsRef.current = []; // keep the ref exact so a pick right after send isn't gated on a stale count
1231
- plainTextInput.current = '';
1264
+ setRawText('');
1232
1265
  inputValueRef.current = '';
1233
- setPlainText('');
1234
1266
  setInputMessage('');
1235
1267
  setReplyMessage(null);
1236
1268
 
@@ -1339,11 +1371,10 @@ export const CometChatMessageComposer = React.forwardRef(
1339
1371
  });
1340
1372
 
1341
1373
  setMentionsSearchData([]);
1342
- plainTextInput.current = "";
1374
+ setRawText("");
1343
1375
 
1344
1376
  // Clear input and reply message immediately for better UX
1345
1377
  inputValueRef.current = "";
1346
- setPlainText("");
1347
1378
  setHasEdited(false);
1348
1379
  setInputMessage("");
1349
1380
  setWarningMessage("");
@@ -1384,8 +1415,36 @@ export const CometChatMessageComposer = React.forwardRef(
1384
1415
  }, 1000);
1385
1416
  }
1386
1417
 
1387
- CometChat.sendMessage(textMessage)
1388
- .then((message: any) => {
1418
+ // Gate read once, at send: OFF runs today's code unchanged; ON goes through the
1419
+ // kit's one send helper (hub reports state and the public events, once).
1420
+ const routed = routeSend(textMessage, "text", () => {
1421
+ CometChat.sendMessage(textMessage)
1422
+ .then((message: any) => {
1423
+ if (isAgenticUser() && !parentMessageId && message?.getId) {
1424
+ const messageId = typeof message.getId() === 'string' ? Number(message.getId()) : message.getId();
1425
+ if (!isNaN(messageId) && !parentMessageIdRef.current) {
1426
+ parentMessageIdRef.current = messageId;
1427
+ }
1428
+ if (messageId && !isNaN(messageId)) {
1429
+ startStreamingForRunId(String(messageId));
1430
+ }
1431
+ }
1432
+
1433
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
1434
+ message: message,
1435
+ status: messageStatus.success,
1436
+ });
1437
+ })
1438
+ .catch((error: any) => {
1439
+ onError && onError(error);
1440
+ textMessage.setMetadata({ error: true });
1441
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
1442
+ message: textMessage,
1443
+ status: messageStatus.error,
1444
+ });
1445
+ });
1446
+ }, {
1447
+ onSent: (message: any) => {
1389
1448
  if (isAgenticUser() && !parentMessageId && message?.getId) {
1390
1449
  const messageId = typeof message.getId() === 'string' ? Number(message.getId()) : message.getId();
1391
1450
  if (!isNaN(messageId) && !parentMessageIdRef.current) {
@@ -1395,20 +1454,10 @@ export const CometChatMessageComposer = React.forwardRef(
1395
1454
  startStreamingForRunId(String(messageId));
1396
1455
  }
1397
1456
  }
1398
-
1399
- CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
1400
- message: message,
1401
- status: messageStatus.success,
1402
- });
1403
- })
1404
- .catch((error: any) => {
1405
- onError && onError(error);
1406
- textMessage.setMetadata({ error: true });
1407
- CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
1408
- message: textMessage,
1409
- status: messageStatus.error,
1410
- });
1411
- });
1457
+ },
1458
+ onFailed: quietAwareOnError(onError),
1459
+ });
1460
+ void routed;
1412
1461
  };
1413
1462
 
1414
1463
  /** edit message */
@@ -1454,6 +1503,11 @@ export const CometChatMessageComposer = React.forwardRef(
1454
1503
  outgoing = textMessage;
1455
1504
  }
1456
1505
 
1506
+ // The composer is cleared and leaves edit mode before the request, offline on or off. A failed
1507
+ // edit goes to onError (plus the offline error notice below); the text is not put back, as on
1508
+ // the Android UI Kit.
1509
+ const offlineOn = isOfflineOn();
1510
+
1457
1511
  inputValueRef.current = "";
1458
1512
  clearInputBox();
1459
1513
 
@@ -1477,6 +1531,9 @@ export const CometChatMessageComposer = React.forwardRef(
1477
1531
  })
1478
1532
  .catch((error: any) => {
1479
1533
  onError && onError(error);
1534
+ // Offline ON: today's error notice too (ENG-41199).
1535
+ const errorText = offlineMutationErrorText(offlineOn, t);
1536
+ if (errorText) showToast(errorText);
1480
1537
  });
1481
1538
  };
1482
1539
 
@@ -1611,25 +1668,40 @@ export const CometChatMessageComposer = React.forwardRef(
1611
1668
  });
1612
1669
 
1613
1670
  if (!disableSoundForOutgoingMessages) playAudio();
1614
- CometChat.sendMediaMessage(mediaMessage)
1615
- .then((message: any) => {
1616
- CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
1617
- message: message,
1618
- status: messageStatus.success,
1619
- });
1620
- if (replyMessageId) {
1621
- CometChatMessageEvents.emit(CometChatMessageEvents.ccReplyToMessage, {
1671
+ // Gate read once, at send: OFF runs today's code unchanged; ON goes through the
1672
+ // kit's one send helper (hub reports state and the public events, once).
1673
+ const routed = routeSend(mediaMessage, "media", () => {
1674
+ CometChat.sendMediaMessage(mediaMessage)
1675
+ .then((message: any) => {
1676
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
1622
1677
  message: message,
1623
1678
  status: messageStatus.success,
1624
1679
  });
1625
- }
1626
- setReplyMessage(null);
1627
- setWarningMessage("");
1628
- setShowRecordAudio(false);
1629
- })
1630
- .catch((error: any) => {
1631
- setShowRecordAudio(false);
1632
- if (error?.code === "ERR_PERMISSION_DENIED") {
1680
+ if (replyMessageId) {
1681
+ CometChatMessageEvents.emit(CometChatMessageEvents.ccReplyToMessage, {
1682
+ message: message,
1683
+ status: messageStatus.success,
1684
+ });
1685
+ }
1686
+ setReplyMessage(null);
1687
+ setWarningMessage("");
1688
+ setShowRecordAudio(false);
1689
+ })
1690
+ .catch((error: any) => {
1691
+ setShowRecordAudio(false);
1692
+ if (error?.code === "ERR_PERMISSION_DENIED") {
1693
+ onError && onError(error);
1694
+ // Set error in data.metaData where the message list receipt logic checks
1695
+ const currentData = localMessage.getData() || {};
1696
+ localMessage.setData({ ...currentData, metaData: { error: true } });
1697
+ localMessage.setMetadata({ error: true });
1698
+ CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
1699
+ message: localMessage,
1700
+ status: messageStatus.error,
1701
+ });
1702
+ setReplyMessage(null);
1703
+ return;
1704
+ }
1633
1705
  onError && onError(error);
1634
1706
  // Set error in data.metaData where the message list receipt logic checks
1635
1707
  const currentData = localMessage.getData() || {};
@@ -1640,19 +1712,19 @@ export const CometChatMessageComposer = React.forwardRef(
1640
1712
  status: messageStatus.error,
1641
1713
  });
1642
1714
  setReplyMessage(null);
1643
- return;
1644
- }
1645
- onError && onError(error);
1646
- // Set error in data.metaData where the message list receipt logic checks
1647
- const currentData = localMessage.getData() || {};
1648
- localMessage.setData({ ...currentData, metaData: { error: true } });
1649
- localMessage.setMetadata({ error: true });
1650
- CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageSent, {
1651
- message: localMessage,
1652
- status: messageStatus.error,
1653
1715
  });
1654
- setReplyMessage(null);
1655
- });
1716
+ }, {
1717
+ onSent: (message: any) => {
1718
+ if (replyMessageId) {
1719
+ CometChatMessageEvents.emit(CometChatMessageEvents.ccReplyToMessage, {
1720
+ message: message,
1721
+ status: messageStatus.success,
1722
+ });
1723
+ }
1724
+ },
1725
+ onFailed: quietAwareOnError(onError),
1726
+ });
1727
+ afterFirstAnswer(routed, () => { setReplyMessage(null); setWarningMessage(""); setShowRecordAudio(false); });
1656
1728
  };
1657
1729
 
1658
1730
  const startTyping = (endTypingTimeout?: any, typingMetadata?: any) => {
@@ -1875,6 +1947,7 @@ export const CometChatMessageComposer = React.forwardRef(
1875
1947
  : sendTextMessage;
1876
1948
  return (
1877
1949
  <TouchableOpacity
1950
+ testID="CometChatComposer.send"
1878
1951
  onPress={handleSendPress}
1879
1952
  style={[
1880
1953
  {
@@ -1932,6 +2005,8 @@ export const CometChatMessageComposer = React.forwardRef(
1932
2005
  if (trackingCharacter) trackingCharacters.current.push(trackingCharacter);
1933
2006
 
1934
2007
  let newFormatter = CommonUtils.clone(formatter);
2008
+ // Only the composer's copy draws the input box; the app's instance may also draw the list.
2009
+ newFormatter.markAsComposerInput?.();
1935
2010
  // A formatter with no tracking character has no suggestion list, but it still takes part in
1936
2011
  // the send and edit-preview lifecycle — so key it by id instead of letting an empty key
1937
2012
  // collapse them all into one entry. The prefix keeps it clear of tracking-character lookups.
@@ -1954,7 +2029,9 @@ export const CometChatMessageComposer = React.forwardRef(
1954
2029
  // for the SAME conversation doesn't wipe a tray the user is mid-staging. Skip the first
1955
2030
  // assignment (chatWithId.current === null → nothing staged yet).
1956
2031
  if (chatWithId.current != null && chatWithId.current !== newChatWithId) {
1957
- uploadQueue.cancelAll();
2032
+ // Offline OFF: destroy the batch as today. Offline ON: detach; the SDK keeps it for a
2033
+ // restore when the user comes back (BEH-UPLOAD-14).
2034
+ uploadQueue.leave();
1958
2035
  setSelectedAttachments([]);
1959
2036
  selectedAttachmentsRef.current = [];
1960
2037
  }
@@ -1977,6 +2054,22 @@ export const CometChatMessageComposer = React.forwardRef(
1977
2054
  }
1978
2055
  }, [user, group, chatRef]);
1979
2056
 
2057
+ // Offline ON: a thread switch in the same chat lets go of the previous thread's tray. The
2058
+ // receiver guard above only sees chat switches. Offline OFF: nothing.
2059
+ useOfflineThreadTrayReset(uploadQueue, parentMessageId, selectedAttachmentsRef, setSelectedAttachments);
2060
+
2061
+ // Offline ON: restore this chat's tray and clear it with the session. Offline OFF: nothing.
2062
+ useOfflineUploadTray(
2063
+ uploadQueue,
2064
+ {
2065
+ receiver: user?.getUid?.() ?? group?.getGuid?.(),
2066
+ receiverType: user?.getUid?.() ? ReceiverTypeConstants.user : group?.getGuid?.() ? ReceiverTypeConstants.group : undefined,
2067
+ parentMessageId,
2068
+ },
2069
+ selectedAttachmentsRef,
2070
+ setSelectedAttachments
2071
+ );
2072
+
1980
2073
  const handleOnClick = (CustomView: any) => {
1981
2074
  let view = CustomView(
1982
2075
  user,
@@ -2157,8 +2250,7 @@ export const CometChatMessageComposer = React.forwardRef(
2157
2250
 
2158
2251
  inputValueRef.current = text?.text;
2159
2252
  setInputMessage(text?.text);
2160
- plainTextInput.current = text?.text || "";
2161
- setPlainText(text?.text || "");
2253
+ setRawText(text?.text || "");
2162
2254
  },
2163
2255
  ccSuggestionData(item: { id: string | number; data: Array<SuggestionItem> }) {
2164
2256
  if (activeCharacter.current && id === item?.id) {
@@ -2429,8 +2521,7 @@ export const CometChatMessageComposer = React.forwardRef(
2429
2521
 
2430
2522
  shiftRemainingMentionKeys(deletionMentionMap, range.start, totalShift);
2431
2523
 
2432
- plainTextInput.current = finalText;
2433
- setPlainText(finalText);
2524
+ setRawText(finalText);
2434
2525
  onTextChange?.(finalText);
2435
2526
  mentionMap.current = deletionMentionMap;
2436
2527
 
@@ -2469,8 +2560,7 @@ export const CometChatMessageComposer = React.forwardRef(
2469
2560
 
2470
2561
  let decr = 0;
2471
2562
 
2472
- plainTextInput.current = newText;
2473
- setPlainText(newText);
2563
+ setRawText(newText);
2474
2564
 
2475
2565
  const newMentionMap: Map<string, SuggestionItem> = new Map(mentionMap.current);
2476
2566
 
@@ -2592,7 +2682,7 @@ export const CometChatMessageComposer = React.forwardRef(
2592
2682
  selectionPosition.end,
2593
2683
  plainTextInput.current?.length
2594
2684
  )}`;
2595
- plainTextInput.current = updatedPlainTextInput;
2685
+ setRawText(updatedPlainTextInput);
2596
2686
 
2597
2687
  let key =
2598
2688
  selectionPosition.start -
@@ -2739,6 +2829,7 @@ export const CometChatMessageComposer = React.forwardRef(
2739
2829
  };
2740
2830
 
2741
2831
  return (
2832
+ <LayoutDirectionContext.Provider value={direction}>
2742
2833
  <>
2743
2834
  {/* {!isVisible && typeof CustomView === "function" && <CustomView />} TODOM */}
2744
2835
  <Modal
@@ -2763,6 +2854,7 @@ export const CometChatMessageComposer = React.forwardRef(
2763
2854
  >
2764
2855
  <View
2765
2856
  style={[
2857
+ directionStyle(direction),
2766
2858
  Style.container,
2767
2859
  {
2768
2860
  paddingTop: CustomViewHeader ? theme.spacing.padding.p0 : theme.spacing.padding.p2,
@@ -2856,8 +2948,8 @@ export const CometChatMessageComposer = React.forwardRef(
2856
2948
  backgroundColor: theme.color.background1,
2857
2949
  // radius.r2 + borderDefault + (s0_5 / 2) width — the SAME tokens the input's
2858
2950
  // messageInputStyles.containerStyle uses, so the tray joins it seamlessly.
2859
- borderTopRightRadius: theme.spacing.radius.r2,
2860
- borderTopLeftRadius: theme.spacing.radius.r2,
2951
+ borderTopEndRadius: theme.spacing.radius.r2,
2952
+ borderTopStartRadius: theme.spacing.radius.r2,
2861
2953
  paddingHorizontal: theme.spacing.padding.p1,
2862
2954
  borderWidth: theme.spacing.spacing.s0_5 / 2,
2863
2955
  borderColor: theme.color.borderDefault,
@@ -2899,14 +2991,14 @@ export const CometChatMessageComposer = React.forwardRef(
2899
2991
  setMessagePreview(null);
2900
2992
  clearEditPreview();
2901
2993
  mentionMap.current = new Map();
2902
- plainTextInput.current = "";
2994
+ setRawText("");
2903
2995
  setOriginalText("");
2904
2996
  }}
2905
2997
  style={{
2906
2998
  borderRadius: 8,
2907
2999
  borderWidth: 0,
2908
- borderLeftWidth: 3,
2909
- borderLeftColor: theme.color.borderHighlight,
3000
+ borderStartWidth: 3,
3001
+ borderStartColor: theme.color.borderHighlight,
2910
3002
  margin:theme.spacing.padding.p1,
2911
3003
  }}
2912
3004
  />
@@ -2923,8 +3015,8 @@ export const CometChatMessageComposer = React.forwardRef(
2923
3015
  titleStyle={{ color: theme.color.textHighlight }}
2924
3016
  style={{
2925
3017
  borderRadius: 8,
2926
- borderLeftWidth: 3,
2927
- borderLeftColor: theme.color.borderHighlight,
3018
+ borderStartWidth: 3,
3019
+ borderStartColor: theme.color.borderHighlight,
2928
3020
  margin:theme.spacing.padding.p1,
2929
3021
  }}
2930
3022
  />
@@ -2941,6 +3033,7 @@ export const CometChatMessageComposer = React.forwardRef(
2941
3033
  <CometChatMessageInput
2942
3034
  messageInputRef={messageInputRef}
2943
3035
  text={inputMessage as string}
3036
+ plainText={plainText}
2944
3037
  placeHolderText={isAgenticUser()? t("ASK_ANYTHING") : t("ENTER_YOUR_MESSAGE_HERE")}
2945
3038
  style={{
2946
3039
  ...mergedComposerStyle.messageInputStyles,
@@ -2949,12 +3042,12 @@ export const CometChatMessageComposer = React.forwardRef(
2949
3042
  // Square the TOP for previews above (edit/reply) and the BOTTOM for the tray below,
2950
3043
  // so the input joins whichever surface is attached into one continuous composer.
2951
3044
  ...(messagePreview || replyMessage ? {
2952
- borderTopLeftRadius: 0,
2953
- borderTopRightRadius: 0,
3045
+ borderTopStartRadius: 0,
3046
+ borderTopEndRadius: 0,
2954
3047
  } : {}),
2955
3048
  ...(selectedAttachments.length > 0 ? {
2956
- borderBottomLeftRadius: 0,
2957
- borderBottomRightRadius: 0,
3049
+ borderBottomStartRadius: 0,
3050
+ borderBottomEndRadius: 0,
2958
3051
  // No bottom edge either — the tray surface below closes the box, so input + tray
2959
3052
  // read as one seamless container (like the single-line composer), not two pieces.
2960
3053
  borderBottomWidth: 0,
@@ -3004,8 +3097,8 @@ export const CometChatMessageComposer = React.forwardRef(
3004
3097
  <View
3005
3098
  style={{
3006
3099
  backgroundColor: theme.color.background1,
3007
- borderBottomRightRadius: theme.spacing.radius.r2,
3008
- borderBottomLeftRadius: theme.spacing.radius.r2,
3100
+ borderBottomEndRadius: theme.spacing.radius.r2,
3101
+ borderBottomStartRadius: theme.spacing.radius.r2,
3009
3102
  paddingHorizontal: theme.spacing.padding.p1,
3010
3103
  borderWidth: theme.spacing.spacing.s0_5 / 2,
3011
3104
  borderColor: theme.color.borderDefault,
@@ -3031,6 +3124,7 @@ export const CometChatMessageComposer = React.forwardRef(
3031
3124
  )
3032
3125
  ) : null}
3033
3126
  </>
3127
+ </LayoutDirectionContext.Provider>
3034
3128
  );
3035
3129
  }
3036
3130
  );
@@ -45,7 +45,7 @@ const getAttachmentOptionsStyle = (
45
45
  titleStyle: {
46
46
  ...typography.body.regular,
47
47
  color: color.textPrimary,
48
- paddingLeft: spacing.padding.p1,
48
+ paddingStart: spacing.padding.p1,
49
49
  },
50
50
  iconStyle: {
51
51
  height: 24,