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

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 (25) hide show
  1. package/package.json +1 -1
  2. package/src/CometChatConversations/CometChatConversations.tsx +9 -0
  3. package/src/CometChatMessageList/CometChatMessageList.tsx +67 -4
  4. package/src/shared/CometChatUiKit/CometChatUIKit.changes.md +76 -0
  5. package/src/shared/CometChatUiKit/checkAuthSettings-review.md +211 -0
  6. package/src/shared/framework/MessageDataSource.tsx +14 -2
  7. package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +1 -0
  8. package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +1 -0
  9. package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +2 -1
  10. package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +2 -1
  11. package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +2 -1
  12. package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +2 -1
  13. package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +2 -1
  14. package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +2 -1
  15. package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +2 -1
  16. package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +2 -1
  17. package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +2 -1
  18. package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +2 -1
  19. package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +2 -1
  20. package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +2 -1
  21. package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +2 -1
  22. package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +2 -1
  23. package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +2 -1
  24. package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +2 -1
  25. package/src/shared/utils/conversationUtils.ts +18 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cometchat/chat-uikit-react-native",
3
- "version": "5.3.9",
3
+ "version": "5.3.10",
4
4
  "description": "Ready-to-use Chat UI Components for React Native",
5
5
  "main": "src/index",
6
6
  "module": "src/index",
@@ -1558,6 +1558,15 @@ export const CometChatConversations = (props: ConversationInterface) => {
1558
1558
  messageEventHandler(customInteractiveMessage);
1559
1559
  !disableSoundForMessages && CometChatSoundManager.play("incomingMessage");
1560
1560
  },
1561
+ // Agent (agentic/assistant) reply — update the conversation's last message + unread
1562
+ // count in real time, otherwise the subtitle only refreshes after a re-fetch.
1563
+ onAIAssistantMessageReceived: (aiAssistantMessage: any) => {
1564
+ if (!shouldUpdateLastMessageAndUnreadCount(aiAssistantMessage)) {
1565
+ return;
1566
+ }
1567
+ messageEventHandler(aiAssistantMessage);
1568
+ !disableSoundForMessages && CometChatSoundManager.play("incomingMessage");
1569
+ },
1561
1570
  onMessageModerated: (moderatedMessage: CometChat.BaseMessage) => {
1562
1571
  checkAndUpdateLastMessage(moderatedMessage);
1563
1572
  },
@@ -1963,9 +1963,23 @@ export const CometChatMessageList = memo(
1963
1963
  }
1964
1964
 
1965
1965
  if (isAgenticUser) {
1966
+ // A 1:1 agent conversation only ever contains user-receiver messages. Reject
1967
+ // anything addressed to a group (e.g. a group agent reply that reached this
1968
+ // listener) — otherwise a top-level group message matches the parent-id check
1969
+ // below (String(undefined) === String(undefined)) and leaks into the 1:1 chat.
1970
+ //
1971
+ // In a 1:1 agent chat the `parentMessageId` prop is undefined, but messages
1972
+ // from the 2nd onward are stamped with the first message's id (the thread
1973
+ // root), tracked in agenticParentMessageIdRef. Accept those too, otherwise
1974
+ // every message after the first is filtered out until a remount refetch.
1975
+ const agenticParentId = agenticParentMessageIdRef.current;
1966
1976
  if (
1967
- String(baseMessage.getParentMessageId()) === String(parentMessageId) ||
1968
- String(baseMessage.getId()) === String(parentMessageId)
1977
+ baseMessage.getReceiverType?.() === ReceiverTypeConstants.user &&
1978
+ (String(baseMessage.getParentMessageId()) === String(parentMessageId) ||
1979
+ String(baseMessage.getId()) === String(parentMessageId) ||
1980
+ (agenticParentId !== undefined &&
1981
+ (String(baseMessage.getParentMessageId()) === String(agenticParentId) ||
1982
+ String(baseMessage.getId()) === String(agenticParentId))))
1969
1983
  ) {
1970
1984
  CometChat.markAsDelivered(newMessage);
1971
1985
  bottomHandler(newMessage, isReceived);
@@ -2035,8 +2049,22 @@ export const CometChatMessageList = memo(
2035
2049
  // Thread mismatch check — must run BEFORE the sender check to prevent
2036
2050
  // messages from appearing in the wrong context (main list vs thread)
2037
2051
  // when the same user is logged in on multiple devices.
2052
+ //
2053
+ // Exception: in a 1:1 agent chat the `parentMessageId` prop is undefined,
2054
+ // but messages from the 2nd onward carry the agent thread-root id (tracked
2055
+ // in agenticParentMessageIdRef). Those belong in this list, so don't treat
2056
+ // them as a thread mismatch — otherwise every message after the first is
2057
+ // dropped here until a remount refetch.
2058
+ const isAgenticThreadRootMessage =
2059
+ isAgenticUser &&
2060
+ !parentMessageId &&
2061
+ agenticParentMessageIdRef.current !== undefined &&
2062
+ String(newMessage.getParentMessageId()) ===
2063
+ String(agenticParentMessageIdRef.current);
2038
2064
  if (
2039
- (!parentMessageId && newMessage.getParentMessageId()) ||
2065
+ (!parentMessageId &&
2066
+ newMessage.getParentMessageId() &&
2067
+ !isAgenticThreadRootMessage) ||
2040
2068
  (parentMessageId && !newMessage.getParentMessageId()) ||
2041
2069
  (parentMessageId &&
2042
2070
  newMessage.getParentMessageId() &&
@@ -2951,6 +2979,26 @@ export const CometChatMessageList = memo(
2951
2979
  ) {
2952
2980
  return;
2953
2981
  }
2982
+ // Group agent reply belongs ONLY to its own group conversation. In a 1:1
2983
+ // agent chat `group` is undefined, and a different group won't match the
2984
+ // guid — so the reply can never leak outside its own group list.
2985
+ if (
2986
+ aiAssistantMessage.getReceiverType?.() === ReceiverTypeConstants.group
2987
+ ) {
2988
+ if (group && aiAssistantMessage.getReceiverId?.() === group.getGuid()) {
2989
+ newMessage(aiAssistantMessage);
2990
+ }
2991
+ return;
2992
+ }
2993
+ // 1:1 agent reply belongs ONLY to the matching 1:1 agent conversation — its
2994
+ // sender is the agent represented by `user`. Anything else (a group list, or
2995
+ // a different agent's chat) ignores it so it can't leak across conversations.
2996
+ if (
2997
+ !user ||
2998
+ aiAssistantMessage.getSender?.()?.getUid?.() !== user.getUid()
2999
+ ) {
3000
+ return;
3001
+ }
2954
3002
  if (runId) {
2955
3003
  storeAIAssistantMessage(String(runId), aiAssistantMessage);
2956
3004
  }
@@ -3245,6 +3293,12 @@ export const CometChatMessageList = memo(
3245
3293
  })();
3246
3294
 
3247
3295
  if (item.getSender()?.getUid() != loggedInUser.current?.getUid()) {
3296
+ // Agent (assistant) replies use the normal incoming bubble — which has a
3297
+ // background container and no negative top margin — so the reply is visually
3298
+ // contained like other messages. Applies to both group and 1:1 AI chat.
3299
+ if (type === MessageTypeConstants.assistant) {
3300
+ return mergedTheme.messageListStyles.incomingMessageBubbleStyles as BubbleStyles;
3301
+ }
3248
3302
  return (
3249
3303
  overridenBubbleStyles.get(type)?.incoming ??
3250
3304
  mergedTheme.messageListStyles.incomingMessageBubbleStyles
@@ -4055,8 +4109,17 @@ export const CometChatMessageList = memo(
4055
4109
  }
4056
4110
  }, [onReply, message]);
4057
4111
 
4112
+ // Disable swipe-to-reply for agent ("@agentic") messages. Covers both the
4113
+ // 1:1 AI chat (isAgenticUser, whole conversation) and agent messages inside a
4114
+ // group — where the reply context-menu option is already removed, so the swipe
4115
+ // gesture is suppressed to match (otherwise mobile users could still swipe-reply).
4116
+ const isAgenticMessage =
4117
+ isAgenticUser ||
4118
+ message.getSender?.()?.getRole?.() === "@agentic" ||
4119
+ message.getCategory?.() === MessageCategoryConstants.agentic;
4120
+
4058
4121
  return (
4059
- message.getCategory() === MessageCategoryConstants.action || isAgenticUser ? (
4122
+ message.getCategory() === MessageCategoryConstants.action || isAgenticMessage ? (
4060
4123
  <View style={staticStyles.positionRelative}>
4061
4124
  <TouchableOpacity
4062
4125
  activeOpacity={1}
@@ -0,0 +1,76 @@
1
+ # CometChatUIKit.ts — Auth-check refactor
2
+
3
+ ## What changed
4
+
5
+ The `checkAuthSettings()` helper and its call sites were refactored. The single
6
+ function that did three jobs (predicate + error construction + error
7
+ dispatch via a callback) was split into three small, single-purpose pieces:
8
+
9
+ | Member | Kind | Responsibility |
10
+ | --- | --- | --- |
11
+ | `checkAuthSettings()` | public, pure predicate | Returns `true` when the UIKit is configured well enough to make authenticated calls (`uiKitSettings != null && uiKitSettings.appId` set). No side effects. |
12
+ | `authError()` | private factory | Single source of truth for the "not initialized" exception. Returns the correct `CometChatException` (`code: "ERR"` when settings are null, `code: "appIdErr"` when only `appId` is missing). |
13
+ | `assertInitialized()` | private guard | Throws `authError()` when unconfigured. Safe in both `async` methods (the throw becomes a rejected promise) and sync methods that are caught. |
14
+
15
+ Call sites updated:
16
+
17
+ - `getLoggedInUser()` / `login()` → `CometChatUIKit.assertInitialized();`
18
+ - `logout()` / `createUser()` / `updateUser()` → `if (!this.checkAuthSettings()) return Promise.reject(this.authError());`
19
+
20
+ ## Why it was necessary
21
+
22
+ The old `checkAuthSettings(onError)` took an error callback and returned a
23
+ boolean, and **every call site was using it incorrectly** — the guard either
24
+ did nothing or did the opposite of what was intended:
25
+
26
+ 1. **No-op guards (`getLoggedInUser`, `login`)**
27
+
28
+ ```ts
29
+ if (CometChatUIKit.checkAuthSettings(Promise.reject)) null;
30
+ ```
31
+
32
+ `Promise.reject` was passed as the `onError` callback, but its return value
33
+ was discarded and the `if` body was just `null`. When settings were missing
34
+ the method continued anyway instead of stopping — so the guard provided **no
35
+ protection at all**.
36
+
37
+ 2. **Inverted logic (`logout`)**
38
+
39
+ ```ts
40
+ if (this.checkAuthSettings(Promise.reject)) {
41
+ return Promise.reject(/* not initialized */);
42
+ }
43
+ ```
44
+
45
+ `checkAuthSettings` returned `true` when the UIKit **was** properly
46
+ configured. So this rejected with "UIKit not initialized" exactly when it
47
+ *was* initialized, and proceeded when it was not — **backwards**.
48
+
49
+ 3. **Empty guards (`createUser`, `updateUser`)**
50
+
51
+ ```ts
52
+ if (this.checkAuthSettings(Promise.reject)) {
53
+ }
54
+ ```
55
+
56
+ Empty body. The only effect was the `Promise.reject` callback firing as a
57
+ side effect, creating an unhandled rejection while the method continued.
58
+
59
+ The root cause was a function that mixed a **predicate** with **error
60
+ dispatch**, which made every call site ambiguous and easy to get wrong. After
61
+ the split:
62
+
63
+ - `checkAuthSettings()` reads as a plain question — `if (!checkAuthSettings())`
64
+ is unambiguous.
65
+ - Async methods `assertInitialized()` (throw → rejected promise).
66
+ - The exception text/codes live in one place (`authError()`), so the
67
+ "call `init()` first" message is consistent everywhere.
68
+
69
+ ## Behavioral result
70
+
71
+ Every public entry point now **actually fails fast** with the correct
72
+ `CometChatException` when the UIKit has not been initialized, instead of
73
+ silently continuing or rejecting on the wrong condition.
74
+
75
+ The accompanying test file `__tests__/CometChatUIKit.test.ts` was updated to
76
+ cover these guards.
@@ -0,0 +1,211 @@
1
+ # `checkAuthSettings` — Code Review & Recommended Approach
2
+
3
+ > File: `packages/ChatUiKit/src/shared/CometChatUiKit/CometChatUIKit.ts`
4
+ > Trigger: "is using `!` the best approach in `if (!this.checkAuthSettings(Promise.reject))`?"
5
+ > Verified against source on review date — **5** call sites, line numbers below.
6
+
7
+ ---
8
+
9
+ ## 1. TL;DR
10
+
11
+ - The `!` you asked about is the **logical NOT operator**, not a TypeScript non-null assertion. It is
12
+ correct and idiomatic — **keep it**. It was never the problem.
13
+ - The real problems sit *around* it:
14
+ 1. `checkAuthSettings` is a **side-effecting predicate** — it returns a `boolean` *and* fires an
15
+ `onError` callback. (line 323)
16
+ 2. Every caller passes `Promise.reject` as that callback, which creates a **floating, unhandled
17
+ rejected promise**.
18
+ 3. `logout()` is the only caller that branches correctly — but it **double-fires** the error.
19
+ 4. The other **four** callers (`getLoggedInUser`, `login`, `createUser`, `updateUser`) use the guard
20
+ as a **no-op** — validation is silently skipped.
21
+ 5. Separately: `uiKitSettings` is typed non-optional but is `undefined` until `init()` runs — the
22
+ type lies, which is what lets the unsafe `.authKey` access compile.
23
+
24
+ ---
25
+
26
+ ## 2. Call-site inventory (verified)
27
+
28
+ | Method | Line | Form | Effect |
29
+ | --- | --- | --- | --- |
30
+ | `getLoggedInUser` | 220 | `if (checkAuthSettings(Promise.reject)) null;` | **no-op** |
31
+ | `login` | 267 | `if (checkAuthSettings(Promise.reject)) null;` | **no-op** |
32
+ | `logout` | 293 | `if (!checkAuthSettings(Promise.reject)) { return Promise.reject(...) }` | branches, but double-fires |
33
+ | `createUser` | 309 | `if (checkAuthSettings(Promise.reject)) { }` | **no-op** |
34
+ | `updateUser` | 316 | `if (checkAuthSettings(Promise.reject)) { }` | **no-op** |
35
+
36
+ ---
37
+
38
+ ## 3. The guard itself (line 323)
39
+
40
+ ```ts
41
+ // returns boolean AND calls onError as a side effect
42
+ static checkAuthSettings(onError: (e: CometChat.CometChatException) => void): boolean {
43
+ if (this.uiKitSettings == null) {
44
+ if (onError != null) {
45
+ onError(new CometChat.CometChatException({
46
+ code: "ERR", name: "Authentication null",
47
+ message: "Populate authSettings before initializing",
48
+ }));
49
+ }
50
+ return false;
51
+ }
52
+ if (!this.uiKitSettings?.appId) {
53
+ if (onError != null) {
54
+ onError(new CometChat.CometChatException({
55
+ code: "appIdErr", name: "APP ID null",
56
+ message: "Populate appId in authSettings before initializing",
57
+ }));
58
+ }
59
+ return false;
60
+ }
61
+ return true;
62
+ }
63
+ ```
64
+
65
+ ---
66
+
67
+ ## 4. Why this is a problem
68
+
69
+ ### 4.1 `Promise.reject` as a callback → unhandled rejection
70
+ `Promise.reject(error)` does **not** reject the calling function. It synchronously constructs a new,
71
+ already-rejected promise that nobody awaits or `.catch()`es. On Hermes/Node this surfaces as an
72
+ `UnhandledPromiseRejection` — noise at best, a crash signal at worst.
73
+
74
+ ### 4.2 Dual contract (command + query)
75
+ `checkAuthSettings` both **answers a question** (is config valid?) and **performs an action** (fire the
76
+ error). Callers can't tell from the signature that calling it has side effects — which is precisely how
77
+ the no-op call sites slipped in. A predicate should be pure.
78
+
79
+ ### 4.3 `logout()` double-fires (line 293)
80
+ ```ts
81
+ if (!this.checkAuthSettings(Promise.reject)) { // (a) fires Promise.reject(error) internally
82
+ return Promise.reject(new CometChat.CometChatException({ code: "ERR", ... })); // (b) fires again
83
+ }
84
+ ```
85
+ `(a)` is an unhandled rejection that also carries the *more specific* code (`appIdErr` when appId is
86
+ missing); `(b)` is the real return but always uses the generic `ERR`. One failure, two error objects,
87
+ worse error code.
88
+
89
+ ### 4.4 Four call sites validate nothing
90
+ `if (cond) null;` and `if (cond) {}` are no-ops — the result is computed and thrown away. `getLoggedInUser`,
91
+ `login`, `createUser`, and `updateUser` proceed even when `uiKitSettings` is `null`, deferring to a
92
+ later, more cryptic crash (e.g. `this.uiKitSettings.authKey` reading a property of `undefined`).
93
+
94
+ ### 4.5 The type lies (line 21)
95
+ ```ts
96
+ static uiKitSettings: UIKitSettings; // declared always-present, but undefined until init()
97
+ ```
98
+ Because the declared type is non-optional, TypeScript believes `this.uiKitSettings.authKey` is always
99
+ safe — so the unsafe access in `createUser`/`updateUser` compiles cleanly. The type should be
100
+ `UIKitSettings | undefined` so the compiler forces a guard.
101
+
102
+ ---
103
+
104
+ ## 5. Recommended approach
105
+
106
+ Make `checkAuthSettings` a **pure predicate**, centralize the exception in a factory, and let each
107
+ caller decide how to report failure. Throwing assertions (no eager `Promise.reject`) avoid
108
+ re-introducing the unhandled-rejection footgun.
109
+
110
+ > ⚠️ **Breaking change:** dropping `onError` changes the signature of the `static` (public)
111
+ > `checkAuthSettings`. Grep the repo + consuming apps and migrate all callers, or keep `onError`
112
+ > optional and ignore it. Treat as a semver-minor/major change, not a drop-in edit.
113
+
114
+ ### 5.1 Pure predicate + error factory + throwing assert
115
+ ```ts
116
+ /** Pure predicate: is the UIKit configured well enough to make authenticated calls? */
117
+ static checkAuthSettings(): boolean {
118
+ return this.uiKitSettings != null && !!this.uiKitSettings.appId;
119
+ }
120
+
121
+ /** Single source of truth for the "not initialized" exception (preserves the specific code). */
122
+ private static authError(): CometChat.CometChatException {
123
+ if (this.uiKitSettings == null) {
124
+ return new CometChat.CometChatException({
125
+ code: "ERR", name: "Authentication null",
126
+ message: "Populate authSettings before initializing. Call CometChatUIKit.init() first.",
127
+ });
128
+ }
129
+ return new CometChat.CometChatException({
130
+ code: "appIdErr", name: "APP ID null",
131
+ message: "Populate appId in authSettings before initializing.",
132
+ });
133
+ }
134
+
135
+ /** Throws the right exception when unconfigured. Works in sync (caught below) and async methods. */
136
+ private static assertInitialized(): void {
137
+ if (!this.checkAuthSettings()) throw this.authError();
138
+ }
139
+ ```
140
+
141
+ ### 5.2 Call sites — async methods just `throw`
142
+ ```ts
143
+ static async getLoggedInUser(): Promise<CometChat.User> {
144
+ this.assertInitialized(); // rejection is automatic in an async fn
145
+ // ...existing logic
146
+ }
147
+
148
+ static async login({ uid, authToken }: { uid?: string; authToken?: string }): Promise<CometChat.User> {
149
+ this.assertInitialized(); // keep the destructured params — body uses uid/authToken
150
+ // ...existing logic
151
+ }
152
+ ```
153
+
154
+ ### 5.3 Call sites — sync methods return a rejected promise once
155
+ ```ts
156
+ static logout(): Promise<Object> {
157
+ if (!this.checkAuthSettings()) return Promise.reject(this.authError()); // single fire, correct code
158
+ return CometChat.logout().then(() => {
159
+ CometChatUIKit.loggedInUser = null;
160
+ return {};
161
+ });
162
+ }
163
+
164
+ static createUser(user: CometChat.User): Promise<CometChat.User> {
165
+ if (!this.checkAuthSettings()) return Promise.reject(this.authError());
166
+ // authKey is safe here because checkAuthSettings() guaranteed uiKitSettings is set
167
+ return CometChat.createUser(user, this.uiKitSettings.authKey as string);
168
+ }
169
+
170
+ static updateUser(user: CometChat.User): Promise<CometChat.User> {
171
+ if (!this.checkAuthSettings()) return Promise.reject(this.authError());
172
+ return CometChat.updateUser(user, this.uiKitSettings.authKey as string);
173
+ }
174
+ ```
175
+
176
+ > Why not a `requireAuth()` helper that returns a `Promise.reject`? Because building the rejected
177
+ > promise inside the helper makes it float unhandled for a microtask if the caller `await`s anything
178
+ > before returning it — re-creating bug 4.1. A **throwing** assert has no such window.
179
+
180
+ ---
181
+
182
+ ## 6. Before / After
183
+
184
+ | Concern | Before | After |
185
+ | --- | --- | --- |
186
+ | `checkAuthSettings` contract | boolean **+** side effect | pure boolean predicate |
187
+ | `checkAuthSettings` signature | `(onError)` | `()` — **breaking; migrate callers** |
188
+ | Unhandled rejections | yes (`Promise.reject` as callback) | none (throw / single return) |
189
+ | `logout` error firing | twice; generic code wins | once; specific code preserved |
190
+ | `getLoggedInUser` / `login` validation | no-op (`if (...) null;`) | real guard |
191
+ | `createUser` / `updateUser` validation | no-op (empty block) | real guard |
192
+ | Error message source | duplicated inline ×5 | single `authError()` factory |
193
+ | `uiKitSettings` type | non-optional (lies) | `UIKitSettings \| undefined` (optional improvement) |
194
+
195
+ ---
196
+
197
+ ## 7. Answer to the original question
198
+
199
+ `if (!this.checkAuthSettings())` is the clearest way to express "bail out when config is invalid" — the
200
+ `!` is correct and should stay. What actually deserved scrutiny was the side-effecting validator and the
201
+ `Promise.reject`-as-callback pattern wrapped around it. Fix those (pure predicate + factory + throwing
202
+ assert) and the `!` reads exactly as intended at every call site.
203
+
204
+ ---
205
+
206
+ ## 8. Follow-ups (out of scope here)
207
+
208
+ - Change `uiKitSettings` to `UIKitSettings | undefined` so the compiler enforces the guard.
209
+ - Add unit tests asserting each public method rejects with the right `code` when `uiKitSettings` is
210
+ `null` and when `appId` is missing (covers all 5 call sites).
211
+ - Consider a lint rule against expression-statement no-ops (`if (x) null;`) to prevent regressions.
@@ -22,6 +22,7 @@ import {
22
22
  MessageCategoryConstants,
23
23
  MessageOptionConstants,
24
24
  MessageTypeConstants,
25
+ ReceiverTypeConstants,
25
26
  } from "../constants/UIKitConstants";
26
27
  import { CometChatUiKitConstants } from "../index";
27
28
  import { CometChatMessageComposerAction } from "../helper/types";
@@ -131,12 +132,23 @@ export class MessageDataSource implements DataSource {
131
132
  };
132
133
 
133
134
 
134
- getAgentAssistantMessageTemplate(theme: CometChatTheme): CometChatMessageTemplate {
135
+ getAgentAssistantMessageTemplate(
136
+ theme: CometChatTheme,
137
+ additionalParams?: AdditionalParams
138
+ ): CometChatMessageTemplate {
135
139
  return new CometChatMessageTemplate({
136
140
  type: 'assistant',
137
141
  category: 'agentic',
138
- ContentView: (message: CometChat.BaseMessage) =>
142
+ ContentView: (message: CometChat.BaseMessage) =>
139
143
  this.getAgentAssistantMessageBubble(message, theme),
144
+ ReplyView: (message: CometChat.BaseMessage, _alignment: MessageBubbleAlignmentType) => {
145
+ if (message.getReceiverType() !== ReceiverTypeConstants.group) {
146
+ return null;
147
+ }
148
+ const replyView = ChatConfigurator.dataSource.getReplyView?.(message, theme, additionalParams) || null;
149
+ if (!replyView) return null;
150
+ return <View style={{ marginTop: 2, marginBottom: 6 }}>{replyView}</View>;
151
+ },
140
152
 
141
153
  options: undefined,
142
154
 
@@ -392,6 +392,7 @@
392
392
  "REQUIRED_FIELDS_WARNING": "Bitte füllen Sie alle Pflichtfelder aus, bevor Sie eine Umfrage erstellen",
393
393
  "NOT_SUPPORTED": "Dieser Nachrichtentyp wird nicht unterstützt",
394
394
  "CARD_MESSAGE": "Kartennachricht",
395
+ "AI_AGENT_MESSAGE": "KI-Agent-Nachricht",
395
396
  "NO_USERS_FOUND": "Keine Benutzer gefunden",
396
397
  "USERS_EMPTY_STATE_MESSAGE": "Wir konnten keine Benutzer finden, die Ihrer Suche entsprechen. Versuchen Sie, Ihre Suche anzupassen.",
397
398
  "SAVE": "Speichern",
@@ -391,6 +391,7 @@
391
391
  "REQUIRED_FIELDS_WARNING": "Please fill in all required fields before creating a poll.",
392
392
  "NOT_SUPPORTED": "This message type is not supported",
393
393
  "CARD_MESSAGE": "Card Message",
394
+ "AI_AGENT_MESSAGE": "AI agent message",
394
395
  "NO_USERS_FOUND": "No Users Found",
395
396
  "USERS_EMPTY_STATE_MESSAGE": "We couldn’t find any users matching your search. Try adjusting your search.",
396
397
  "SAVE": "Save",
@@ -518,5 +518,6 @@
518
518
  "NOTIFICATION_FEED_LOADING_MORE": "Cargando...",
519
519
  "NOTIFICATION_FEED_LOAD_MORE_ERROR": "No se pudo cargar más",
520
520
  "NOTIFICATION_FEED_TAP_TO_RETRY": "Toca para reintentar",
521
- "CARD_MESSAGE": "Mensaje de tarjeta"
521
+ "CARD_MESSAGE": "Mensaje de tarjeta",
522
+ "AI_AGENT_MESSAGE": "Mensaje del agente de IA"
522
523
  }
@@ -518,5 +518,6 @@
518
518
  "NOTIFICATION_FEED_LOADING_MORE": "Chargement...",
519
519
  "NOTIFICATION_FEED_LOAD_MORE_ERROR": "Impossible de charger plus",
520
520
  "NOTIFICATION_FEED_TAP_TO_RETRY": "Appuyez pour réessayer",
521
- "CARD_MESSAGE": "Message de carte"
521
+ "CARD_MESSAGE": "Message de carte",
522
+ "AI_AGENT_MESSAGE": "Message de l'agent IA"
522
523
  }
@@ -518,5 +518,6 @@
518
518
  "NOTIFICATION_FEED_LOADING_MORE": "लोड हो रहा है...",
519
519
  "NOTIFICATION_FEED_LOAD_MORE_ERROR": "और लोड नहीं हो सका",
520
520
  "NOTIFICATION_FEED_TAP_TO_RETRY": "पुनः प्रयास करने के लिए टैप करें",
521
- "CARD_MESSAGE": "कार्ड संदेश"
521
+ "CARD_MESSAGE": "कार्ड संदेश",
522
+ "AI_AGENT_MESSAGE": "एआई एजेंट संदेश"
522
523
  }
@@ -518,5 +518,6 @@
518
518
  "NOTIFICATION_FEED_LOADING_MORE": "Betöltés...",
519
519
  "NOTIFICATION_FEED_LOAD_MORE_ERROR": "Nem sikerült többet betölteni",
520
520
  "NOTIFICATION_FEED_TAP_TO_RETRY": "Koppintson az újrapróbálkozáshoz",
521
- "CARD_MESSAGE": "Kártyaüzenet"
521
+ "CARD_MESSAGE": "Kártyaüzenet",
522
+ "AI_AGENT_MESSAGE": "MI-ügynök üzenet"
522
523
  }
@@ -518,5 +518,6 @@
518
518
  "NOTIFICATION_FEED_LOADING_MORE": "Caricamento...",
519
519
  "NOTIFICATION_FEED_LOAD_MORE_ERROR": "Impossibile caricare altro",
520
520
  "NOTIFICATION_FEED_TAP_TO_RETRY": "Tocca per riprovare",
521
- "CARD_MESSAGE": "Messaggio con scheda"
521
+ "CARD_MESSAGE": "Messaggio con scheda",
522
+ "AI_AGENT_MESSAGE": "Messaggio dell'agente IA"
522
523
  }
@@ -518,5 +518,6 @@
518
518
  "NOTIFICATION_FEED_LOADING_MORE": "読み込み中...",
519
519
  "NOTIFICATION_FEED_LOAD_MORE_ERROR": "さらに読み込めませんでした",
520
520
  "NOTIFICATION_FEED_TAP_TO_RETRY": "タップして再試行",
521
- "CARD_MESSAGE": "カードメッセージ"
521
+ "CARD_MESSAGE": "カードメッセージ",
522
+ "AI_AGENT_MESSAGE": "AIエージェントメッセージ"
522
523
  }
@@ -518,5 +518,6 @@
518
518
  "NOTIFICATION_FEED_LOADING_MORE": "로딩 중...",
519
519
  "NOTIFICATION_FEED_LOAD_MORE_ERROR": "더 불러올 수 없습니다",
520
520
  "NOTIFICATION_FEED_TAP_TO_RETRY": "탭하여 재시도",
521
- "CARD_MESSAGE": "카드 메시지"
521
+ "CARD_MESSAGE": "카드 메시지",
522
+ "AI_AGENT_MESSAGE": "AI 에이전트 메시지"
522
523
  }
@@ -518,5 +518,6 @@
518
518
  "NOTIFICATION_FEED_LOADING_MORE": "Kraunama...",
519
519
  "NOTIFICATION_FEED_LOAD_MORE_ERROR": "Nepavyko įkelti daugiau",
520
520
  "NOTIFICATION_FEED_TAP_TO_RETRY": "Bakstelėkite, kad bandytumėte dar kartą",
521
- "CARD_MESSAGE": "Kortelės žinutė"
521
+ "CARD_MESSAGE": "Kortelės žinutė",
522
+ "AI_AGENT_MESSAGE": "DI agento žinutė"
522
523
  }
@@ -518,5 +518,6 @@
518
518
  "NOTIFICATION_FEED_LOADING_MORE": "Memuatkan...",
519
519
  "NOTIFICATION_FEED_LOAD_MORE_ERROR": "Tidak dapat memuatkan lagi",
520
520
  "NOTIFICATION_FEED_TAP_TO_RETRY": "Ketik untuk cuba semula",
521
- "CARD_MESSAGE": "Mesej Kad"
521
+ "CARD_MESSAGE": "Mesej Kad",
522
+ "AI_AGENT_MESSAGE": "Mesej ejen AI"
522
523
  }
@@ -518,5 +518,6 @@
518
518
  "NOTIFICATION_FEED_LOADING_MORE": "Laden...",
519
519
  "NOTIFICATION_FEED_LOAD_MORE_ERROR": "Kan niet meer laden",
520
520
  "NOTIFICATION_FEED_TAP_TO_RETRY": "Tik om opnieuw te proberen",
521
- "CARD_MESSAGE": "Kaartbericht"
521
+ "CARD_MESSAGE": "Kaartbericht",
522
+ "AI_AGENT_MESSAGE": "AI-agentbericht"
522
523
  }
@@ -518,5 +518,6 @@
518
518
  "NOTIFICATION_FEED_LOADING_MORE": "Carregando...",
519
519
  "NOTIFICATION_FEED_LOAD_MORE_ERROR": "Não foi possível carregar mais",
520
520
  "NOTIFICATION_FEED_TAP_TO_RETRY": "Toque para tentar novamente",
521
- "CARD_MESSAGE": "Mensagem de cartão"
521
+ "CARD_MESSAGE": "Mensagem de cartão",
522
+ "AI_AGENT_MESSAGE": "Mensagem do agente de IA"
522
523
  }
@@ -518,5 +518,6 @@
518
518
  "NOTIFICATION_FEED_LOADING_MORE": "Загрузка...",
519
519
  "NOTIFICATION_FEED_LOAD_MORE_ERROR": "Не удалось загрузить ещё",
520
520
  "NOTIFICATION_FEED_TAP_TO_RETRY": "Нажмите, чтобы повторить",
521
- "CARD_MESSAGE": "Сообщение-карточка"
521
+ "CARD_MESSAGE": "Сообщение-карточка",
522
+ "AI_AGENT_MESSAGE": "Сообщение ИИ-агента"
522
523
  }
@@ -518,5 +518,6 @@
518
518
  "NOTIFICATION_FEED_LOADING_MORE": "Laddar...",
519
519
  "NOTIFICATION_FEED_LOAD_MORE_ERROR": "Kunde inte ladda mer",
520
520
  "NOTIFICATION_FEED_TAP_TO_RETRY": "Tryck för att försöka igen",
521
- "CARD_MESSAGE": "Kortmeddelande"
521
+ "CARD_MESSAGE": "Kortmeddelande",
522
+ "AI_AGENT_MESSAGE": "AI-agentmeddelande"
522
523
  }
@@ -518,5 +518,6 @@
518
518
  "NOTIFICATION_FEED_LOADING_MORE": "Yükleniyor...",
519
519
  "NOTIFICATION_FEED_LOAD_MORE_ERROR": "Daha fazla yüklenemedi",
520
520
  "NOTIFICATION_FEED_TAP_TO_RETRY": "Tekrar denemek için dokunun",
521
- "CARD_MESSAGE": "Kart Mesajı"
521
+ "CARD_MESSAGE": "Kart Mesajı",
522
+ "AI_AGENT_MESSAGE": "AI aracı mesajı"
522
523
  }
@@ -518,5 +518,6 @@
518
518
  "NOTIFICATION_FEED_LOADING_MORE": "加载中...",
519
519
  "NOTIFICATION_FEED_LOAD_MORE_ERROR": "无法加载更多",
520
520
  "NOTIFICATION_FEED_TAP_TO_RETRY": "点击重试",
521
- "CARD_MESSAGE": "卡片消息"
521
+ "CARD_MESSAGE": "卡片消息",
522
+ "AI_AGENT_MESSAGE": "AI 代理消息"
522
523
  }
@@ -518,5 +518,6 @@
518
518
  "NOTIFICATION_FEED_LOADING_MORE": "載入中...",
519
519
  "NOTIFICATION_FEED_LOAD_MORE_ERROR": "無法載入更多",
520
520
  "NOTIFICATION_FEED_TAP_TO_RETRY": "點擊重試",
521
- "CARD_MESSAGE": "卡片訊息"
521
+ "CARD_MESSAGE": "卡片訊息",
522
+ "AI_AGENT_MESSAGE": "AI 代理訊息"
522
523
  }
@@ -57,6 +57,24 @@ export class CometChatConversationUtils {
57
57
  return cardText;
58
58
  }
59
59
 
60
+ // Edit D — Agent (agentic/assistant) last-message preview. The text lives in
61
+ // getAssistantMessageData().getText() for an AIAssistantMessage; fall back to
62
+ // getText(), then a localized label (previously fell through to empty string).
63
+ if (lastMessage.getCategory() === MessageCategoryConstants.agentic) {
64
+ const agentMsg = lastMessage as any;
65
+ let agentText = "";
66
+ if (typeof agentMsg.getAssistantMessageData === "function") {
67
+ const assistantData = agentMsg.getAssistantMessageData();
68
+ if (assistantData && typeof assistantData.getText === "function") {
69
+ agentText = assistantData.getText() || "";
70
+ }
71
+ }
72
+ if (!agentText && typeof agentMsg.getText === "function") {
73
+ agentText = agentMsg.getText() || "";
74
+ }
75
+ return agentText || t("AI_AGENT_MESSAGE") || "AI agent message";
76
+ }
77
+
60
78
  if (lastMessage.getCategory() == "call") {
61
79
  let color: ColorValue | undefined = theme?.color?.textSecondary;
62
80
  let text = "Video call";