@tencent-rtc/mcp 1.6.8 → 1.7.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 (86) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +58 -39
  3. package/knowledge/build-index.js +30 -6
  4. package/knowledge/chunker.js +82 -14
  5. package/knowledge/chunking-policy.js +100 -0
  6. package/knowledge/content-loader.js +3 -3
  7. package/knowledge/doc-url-resolver.js +43 -16
  8. package/knowledge/frontmatter-meta.js +167 -0
  9. package/knowledge/path-meta.js +28 -6
  10. package/knowledge/search/exact-lookup.js +120 -239
  11. package/knowledge/search/filter-pool.js +12 -29
  12. package/knowledge/search/framework-fallback.js +22 -0
  13. package/knowledge/search/intent-router.js +29 -0
  14. package/knowledge/search/l1-enrich.js +159 -0
  15. package/knowledge/search/query-normalizer.js +63 -3
  16. package/knowledge/search/search-core.js +410 -0
  17. package/knowledge/search/search-knowledge.js +421 -379
  18. package/knowledge/search/search-message.js +88 -0
  19. package/knowledge/search/search-pass.js +428 -0
  20. package/knowledge/search/search-types.js +1 -0
  21. package/knowledge/search/url-row-idf.js +120 -0
  22. package/knowledge/search/url-row-scorer.js +337 -0
  23. package/package.json +3 -1
  24. package/resource/_schema/feature-aliases.yaml +1 -1
  25. package/resource/index/manifest.json +1 -1
  26. package/resource/knowledge/callkit/best-practice/callkit-miniprogram/uniapp-shrink.md +60 -0
  27. package/resource/knowledge/callkit/best-practice/common/call-autoplay-blocked.md +77 -0
  28. package/resource/knowledge/callkit/best-practice/common/call-message-in-chat.md +78 -0
  29. package/resource/knowledge/callkit/best-practice/common/call-vs-calls.md +110 -0
  30. package/resource/knowledge/callkit/best-practice/common/callengine-call-flow.md +123 -0
  31. package/resource/knowledge/callkit/best-practice/common/callengine-log-level.md +67 -0
  32. package/resource/knowledge/callkit/best-practice/common/callkit-get-engine-instance.md +81 -0
  33. package/resource/knowledge/callkit/best-practice/common/callkit-get-roomid.md +78 -0
  34. package/resource/knowledge/callkit/best-practice/common/callkit-limitations.md +37 -0
  35. package/resource/knowledge/callkit/best-practice/common/callkit-user-register-and-kicked.md +98 -0
  36. package/resource/knowledge/chat/best-practice/common/avchatroom-message-loss-diagnosis.md +65 -0
  37. package/resource/knowledge/chat/best-practice/common/group-conversation-cleanup-on-system-notice.md +62 -0
  38. package/resource/knowledge/chat/best-practice/common/image-message-url-lifecycle.md +59 -0
  39. package/resource/knowledge/chat/best-practice/common/login-repeat-2025-diagnosis.md +61 -0
  40. package/resource/knowledge/chat/best-practice/common/message-read-report-and-receipt.md +64 -0
  41. package/resource/knowledge/chat/best-practice/common/message-receive-event.md +65 -0
  42. package/resource/knowledge/chat/best-practice/common/message-risk-error-and-render.md +65 -0
  43. package/resource/knowledge/chat/best-practice/common/message-unread-count.md +71 -0
  44. package/resource/knowledge/chat/best-practice/miniprogram/audio-message-send.md +113 -0
  45. package/resource/knowledge/chat/best-practice/miniprogram/login-timeout-2801-diagnosis.md +63 -0
  46. package/resource/knowledge/chat/best-practice/miniprogram/media-upload-fail-diagnosis.md +64 -0
  47. package/resource/knowledge/chat/best-practice/web/audio-message-send.md +118 -0
  48. package/resource/knowledge/chat/urls/product.md +17 -16
  49. package/resource/knowledge/chat/urls/restapi.md +3 -2
  50. package/resource/knowledge/chat/urls/sdk/android.md +6 -5
  51. package/resource/knowledge/chat/urls/sdk/flutter.md +6 -5
  52. package/resource/knowledge/chat/urls/sdk/ios.md +4 -3
  53. package/resource/knowledge/chat/urls/sdk/web.md +7 -6
  54. package/resource/knowledge/chat/urls/webhook.md +0 -5
  55. package/resource/knowledge/livekit/best-practice/android/voice-room-anchor-start.md +120 -0
  56. package/resource/knowledge/livekit/best-practice/common/admin-take-seat.md +73 -0
  57. package/resource/knowledge/livekit/best-practice/common/audience-leave-live.md +81 -0
  58. package/resource/knowledge/livekit/best-practice/common/voice-room-no-audio-troubleshoot.md +100 -0
  59. package/resource/knowledge/livekit/best-practice/common/voice-room-seat-list-change.md +65 -0
  60. package/resource/knowledge/livekit/best-practice/flutter/voice-room-anchor-start.md +122 -0
  61. package/resource/knowledge/livekit/best-practice/ios/voice-room-anchor-start.md +126 -0
  62. package/resource/knowledge/roomkit/best-practice/common/room-ghost-member.md +70 -0
  63. package/resource/knowledge/roomkit/best-practice/common/room-limit-and-multi.md +83 -0
  64. package/resource/knowledge/roomkit/best-practice/common/room-screen-share-preview.md +83 -0
  65. package/resource/knowledge/roomkit/best-practice/common/room-status-after-all-leave.md +69 -0
  66. package/resource/knowledge/roomkit/best-practice/vue/room-uikit-vs-atomicx.md +111 -0
  67. package/resource/knowledge/rtcengine/web/plugin/30-advanced-cross-room-link.md +2 -0
  68. package/resource/knowledge/rtcengine/web/plugin/39-advanced-video-decoder.md +2 -0
  69. package/server.js +28 -23
  70. package/streamable-http.js +19 -54
  71. package/tools/common/search_trtc_knowledge.js +24 -12
  72. package/tools/definitions/finalize_answer_def.js +2 -2
  73. package/tools/definitions/integration-boundary.js +2 -1
  74. package/tools/definitions/search_trtc_knowledge_def.js +5 -3
  75. package/utils/fetch-doc-content.js +198 -0
  76. package/utils/preflight-route.js +197 -0
  77. package/utils/report-cls-client.js +1 -1
  78. package/utils/report-es-client.js +1 -1
  79. package/cursor-setting.png +0 -0
  80. package/mcp-server-prompt.png +0 -0
  81. package/resource/knowledge/callkit/best-practice/web/callengine-invitation.md +0 -80
  82. package/resource/knowledge/callkit/best-practice/web/callengine-log-control.md +0 -24
  83. package/resource/knowledge/callkit/best-practice/web/callkit-call-vs-calls.md +0 -116
  84. package/resource/knowledge/callkit/preset/react/uikit-api-reference.md +0 -444
  85. package/resource/knowledge/callkit/preset/vue/uikit-api-reference.md +0 -464
  86. package/resource/knowledge/chat/best-practice/web/image-message-url-handling.md +0 -16
@@ -0,0 +1,78 @@
1
+ ---
2
+ title: "How to get the roomID during a TUICallKit Call(获取 TUICallKit 房间号)"
3
+ product: call
4
+ frameworks: [react, vue, miniprogram, web]
5
+ scope: platform_common
6
+ tags: [TUICallKit, roomID, room ID, ON_CALL_BEGIN, ON_CALL_END, callengine, get room ID, call room ID, Roomid, onCallBegin]
7
+ version_range: ">=4.0.0"
8
+ ---
9
+
10
+ # How to Get the Room ID During a TUICallKit Call
11
+
12
+ ## 1. Key Takeaways
13
+
14
+ - To get the call room ID: listen to TUICallEngine events (`ON_CALL_BEGIN`, `ON_CALL_END`, etc.) and read `event.roomID`, which is the current call's room ID.
15
+ - First obtain the TUICallEngine instance via `TUICallKitAPI.getTUICallEngineInstance()`, then call `on()` to listen to events.
16
+ - The API is the same across React, Vue, and mini programs; only the package name differs.
17
+
18
+ ## 2. Field / API Reference
19
+
20
+ | Field / API | Purpose | Notes |
21
+ |---|---|---|
22
+ | `TUICallEvent.ON_CALL_BEGIN` | Call established event | Triggered when the call connects; carries `roomID` |
23
+ | `TUICallEvent.ON_CALL_END` | Call ended event | Triggered when the call ends; carries `roomID` |
24
+ | `TUICallKitAPI.getTUICallEngineInstance()` | Get the TUICallEngine instance | Obtains the underlying engine instance from TUICallKit |
25
+ | `engine.on(event, handler)` | Listen to engine events | Registers event callbacks via the engine instance |
26
+ | `event.roomID` | Call room ID | The room ID field in the event parameters |
27
+
28
+ ## 3. Mechanism & Sequence
29
+
30
+ TUICallKit initializes -> call connects (`ON_CALL_BEGIN`) -> call in progress -> call ends (`ON_CALL_END`). Call-related events such as `ON_CALL_BEGIN` and `ON_CALL_END` all carry `roomID`; simply read it in the callback.
31
+
32
+ ## 4. Standard Usage
33
+
34
+ 1. Get the TUICallEngine instance via `TUICallKitAPI.getTUICallEngineInstance()`.
35
+ 2. Call `engine.on()` to listen to `TUICallEvent.ON_CALL_BEGIN` or `ON_CALL_END`.
36
+ 3. Read `event.roomID` in the callback to obtain the room ID.
37
+
38
+ ```javascript
39
+ // Web: @trtc/call-engine-lite-js
40
+ // 小程序: @trtc/call-engine-lite-wx (API 一致,仅包名不同)
41
+ import { TUICallEvent } from "@trtc/call-engine-lite-js";
42
+
43
+ const handleOnCallBegin = function(event) {
44
+ // event.roomID 即为当前通话的房间号
45
+ console.log('通话建立,房间号:', event.roomID);
46
+ };
47
+
48
+ TUICallKitAPI.getTUICallEngineInstance().on(
49
+ TUICallEvent.ON_CALL_BEGIN,
50
+ handleOnCallBegin
51
+ );
52
+ ```
53
+
54
+ ## 5. Expected Results
55
+
56
+ - After the call is established, the `ON_CALL_BEGIN` callback fires and `event.roomID` returns a valid room ID.
57
+ - After the call ends, the `ON_CALL_END` callback fires and `event.roomID` can also be read.
58
+ - The `roomID` value remains constant throughout the call.
59
+
60
+ ## 6. Common Pitfalls
61
+
62
+ - Pitfall 1: Calling `getTUICallEngineInstance()` before TUICallKit initialization completes (ensure initialization is done first).
63
+ - Pitfall 2: Assuming `roomID` changes during the call (the room ID is fixed for a given call).
64
+
65
+ ## 7. Problem Definition (retrieval hint)
66
+
67
+ Web TUICallKit React/Vue/mini program users need to get the current call's room ID for logging or associating with other services.
68
+
69
+ ## 8. Alternative Queries (retrieval recall)
70
+
71
+ - How to get the room ID in TUICallKit?
72
+ - How to obtain the roomID when a call is established?
73
+ - How to listen to the `ON_CALL_BEGIN` event?
74
+ - How to get the call room ID in TUICallKit React?
75
+ - How to get the roomID in mini program TUICallKit?
76
+ - How to get the call room ID / Roomid?
77
+ - How to get the room ID in Web TUICallKit?
78
+ - How to obtain the call room ID?
@@ -0,0 +1,37 @@
1
+ ---
2
+ title: "TUICallKit Limitations(TUICallKit:离线推送、支付宝、抖音、企微以及桌面版微信小程序)"
3
+ product: call
4
+ frameworks: [react, vue, miniprogram, web]
5
+ scope: platform_common
6
+ tags: [TUICallKit, limitation, unsupported, offline push, Alipay, Douyin mini program, WeCom, desktop, compatibility]
7
+ version_range: ">=2.0.0"
8
+ ---
9
+
10
+ # TUICallKit Limitations
11
+
12
+ ## 1. Key Takeaways
13
+
14
+ | Question | Answer |
15
+ |---|---|
16
+ | Can Web TUICallKit receive offline push messages? | No. Web TUICallKit does not support receiving offline push messages. |
17
+ | Can WeChat Mini Program TUICallKit run on Alipay or Douyin mini programs? | No. It only supports running on WeChat Mini Programs. |
18
+ | Can WeChat Mini Program TUICallKit run in WeCom (Enterprise WeChat)? | No. It only supports running on WeChat Mini Programs. |
19
+ | Can WeChat Mini Program TUICallKit run in the PC desktop WeChat client? | No. It only supports running on WeChat Mini Programs. |
20
+ | Can WeChat Mini Program TUICallKit receive offline push messages? | No. WeChat Mini Program TUICallKit does not support receiving offline push messages. |
21
+
22
+ ## 3. Mechanism & Sequence
23
+
24
+ The capability boundaries of TUICallKit on each platform are determined by underlying platform restrictions. WeChat Mini Programs rely on WeChat native capabilities and cannot run cross-platform; the Web platform is limited by browser autoplay policies and offline push mechanisms.
25
+
26
+ ## 7. Problem Definition (retrieval hint)
27
+
28
+ Users inquire about TUICallKit capability boundaries across different platforms and scenarios, confirming whether offline push, cross-platform execution, etc. are supported.
29
+
30
+ ## 8. Alternative Queries (retrieval recall)
31
+
32
+ - Does TUICallKit support offline push?
33
+ - Can WeChat Mini Program TUICallKit run on Alipay?
34
+ - Can TUICallKit mini program run in WeCom?
35
+ - Does TUICallKit WeChat Mini Program support the PC WeChat client?
36
+ - Does TUICallKit Web have offline message notifications?
37
+ - Does TUICallKit mini program only support WeChat?
@@ -0,0 +1,98 @@
1
+ ---
2
+ title: "TUICallKit user registration and Multi-Instance Kick-Out Explained(TUICallKit 用户注册 / 多实例登录)"
3
+ product: call
4
+ frameworks: [react, vue, miniprogram, web]
5
+ scope: platform_common
6
+ tags: [TUICallKit, user registration, init, userSig, auto-create user, multi-instance login, kicked out, KICKED_OUT, troubleshooting, same browser, multi-instance, web multi-instance]
7
+ version_range: ">=4.0.0"
8
+ ---
9
+
10
+ # TUICallKit User Registration and Multi-Instance Kick-Out Explained
11
+
12
+ ## 1. Key Takeaways
13
+
14
+ ### User Registration
15
+
16
+ - TUICallKit **does not have a dedicated frontend registration API**. User registration is completed through the `init` API: passing `userID` and `userSig` completes authentication and login.
17
+ - When a `userID` and `userSig` issued by the backend are used to log in to TUICallKit for the first time, the system automatically creates the user if that `userID` does not yet exist in Tencent Cloud IM.
18
+ - Alternatively, users can be batch-imported via the IM Console, and then the imported `userID` with its corresponding `userSig` can be used to log in.
19
+
20
+ ### Multi-Instance Kick-Out
21
+
22
+ - When the same `userID` is logged in simultaneously across different browser tabs or devices, the earlier session is kicked offline (`KICKED_OUT`) by default, because the Chat SDK Web allows only one instance online per user by default.
23
+ - After enabling **Web Multi-Instance Login** in the Chat Console, the same `userID` can be online across multiple tabs or devices simultaneously without being kicked.
24
+ - Different `userID`s logged in within the same browser are not affected by this restriction and will not kick each other offline.
25
+
26
+ ## 2. Field / API Reference
27
+
28
+ | Field / API | Purpose | Notes |
29
+ |---|---|---|
30
+ | `init` | Initialize and register a user | Pass `SDKAppID`, `userID`, `userSig` to complete authentication |
31
+ | `userID` | User identifier | Issued or defined by the business backend; auto-creates the user on first login |
32
+ | `userSig` | User signature | Issued by the business backend for authentication |
33
+ | `KICKED_OUT` | Kicked offline event | Triggered during same-account / multi-instance login |
34
+ | Web Multi-Instance Login | Console configuration | Once enabled, the same browser can have multiple sessions online simultaneously |
35
+
36
+ ## 3. Mechanism & Sequence
37
+
38
+ ### User Registration Flow
39
+
40
+ Backend generates `userID` + `userSig` -> frontend calls `init({ SDKAppID, userID, userSig })` -> TUICallKit logs in via the Chat SDK -> if the user does not exist, it is auto-created -> login succeeds.
41
+
42
+ ### Multi-Instance Kick-Out Mechanism
43
+
44
+ Same `userID` logs in on tab A -> same browser opens tab B and logs in with the same `userID` -> Chat backend detects a multi-instance login -> kicks tab A offline -> tab A receives the `KICKED_OUT` event.
45
+
46
+ ## 4. Standard Usage
47
+
48
+ ### User Registration and Initialization
49
+
50
+ ```javascript
51
+ // React: @trtc/calls-uikit-react
52
+ // Vue 3: @trtc/calls-uikit-vue
53
+ // Vue 2.7: @trtc/calls-uikit-vue2
54
+ // Vue 2.6: @trtc/calls-uikit-vue2.6
55
+ // uniapp 小程序: @trtc/calls-uikit-wx-uniapp
56
+ // 微信原生小程序: @trtc/calls-uikit-wx (API 一致,仅包名不同)
57
+ import { TUICallKitAPI } from "@trtc/calls-uikit-react";
58
+
59
+ TUICallKitAPI.init({
60
+ SDKAppID: 0, // 控制台获取的 SDKAppID
61
+ userID: 'user_xxx', // 业务后端签发的用户 ID
62
+ userSig: 'xxx', // 业务后端签发的用户签名
63
+ });
64
+ ```
65
+
66
+ ### Enabling Web Multi-Instance Login (Resolving Kick-Out)
67
+
68
+ 1. Log in to the Tencent Cloud IM Console.
69
+ 2. Navigate to the target application's feature configuration page.
70
+ 3. Enable the **Web Multi-Instance Login** toggle.
71
+ 4. Save. The change takes effect immediately without restarting the client.
72
+
73
+ ## 5. Expected Results
74
+
75
+ - After calling `init`, login succeeds with no errors.
76
+ - With Web Multi-Instance enabled in the console, the same `userID` can be online across multiple tabs or devices simultaneously.
77
+ - Without the feature enabled, logging in with the same `userID` on a new tab causes the old tab to receive the `KICKED_OUT` event.
78
+
79
+ ## 6. Common Pitfalls
80
+
81
+ - Pitfall 1: Assuming TUICallKit has a dedicated frontend registration API (registration and login are actually done through `init`).
82
+ - Pitfall 2: Treating kick-out as a TUICallKit bug (it is actually the Chat SDK's multi-device login restriction).
83
+ - Pitfall 3: Assuming different origins also cause kick-out (different origins are treated as different instances and are unaffected).
84
+ - Pitfall 4: Assuming different `userID`s in the same browser kick each other out (the multi-instance restriction applies to the same `userID`; different `userID`s are independent).
85
+ - Pitfall 5: Thinking `KICKED_OUT` can only be resolved by closing other logins (enabling Web Multi-Instance Login avoids it).
86
+
87
+ ## 7. Problem Definition (retrieval hint)
88
+
89
+ Users ask about TUICallKit Web user registration (whether there is a dedicated registration API, whether users are auto-created), and the cause and solution for multi-account kick-out within the same browser.
90
+
91
+ ## 8. Alternative Queries (retrieval recall)
92
+
93
+ - What is the TUICallKit user registration API?
94
+ - Does first-time login auto-create a user?
95
+ - What to do when two accounts in the same browser get kicked out?
96
+ - How to troubleshoot `KICKED_OUT`?
97
+ - Does logging in from a different domain cause kick-out?
98
+ - How to let multiple users log in on the same page simultaneously?
@@ -0,0 +1,65 @@
1
+ ---
2
+ title: "Web/Mini Program Chat SDK: AVChatRoom Message Loss Diagnosis and Mitigation(直播群消息丢失)"
3
+ product: chat
4
+ frameworks: [web, miniprogram]
5
+ scope: platform_common
6
+ tags: [AVChatRoom, message loss, avchatroom, MESSAGE_RECEIVED, long polling, MsgPriority, priority, restapi, rate limit, 40 messages per second]
7
+ version_range: ">=3.0.0"
8
+ ---
9
+
10
+ # Web/Mini Program Chat SDK: AVChatRoom Message Loss Diagnosis and Mitigation
11
+
12
+ ## 1. Key Takeaways
13
+
14
+ - Scenario 1 (messages lost during batch sending): The root cause is incorrect consumption logic of the `MESSAGE_RECEIVED` callback on the business side. This callback may return multiple messages at once; you must read the full list `event.data`.
15
+ - Scenario 2 (important messages not received during high-frequency chat): The root cause is triggering the backend group message rate limit. The default is `40` messages/second per group; messages exceeding this limit are discarded. You can increase the retention probability of important messages by setting message priority.
16
+ - Scenario 3 (messages lost after unstable network or long background period): This is expected behavior for avchatroom. When the app resumes after more than `2` minutes in the background, it cannot pull historical messages beyond the cache window.
17
+ - Avchatroom messages are not stored in roaming. The backend caches messages for only `2` minutes with a maximum of `2000` messages by default; messages beyond the window or limit cannot be recovered via long polling.
18
+
19
+ ## 2. Field / API Reference
20
+
21
+ | Field / Capability | Purpose | Description |
22
+ |---|---|---|
23
+ | `EVENT.MESSAGE_RECEIVED` | Message receive callback | A single callback may return multiple messages; the business must iterate over all items in `event.data` |
24
+ | `priority` (SDK) | SDK message sending priority | Can be set in `createXXXMessage`; higher priority messages are less likely to be discarded when the rate limit is exceeded |
25
+ | `MsgPriority` (REST API) | REST API message sending priority | Set priority in the message body to ensure critical notifications in high-concurrency scenarios |
26
+ | Group rate limit (default `40` msg/s) | Backend flow control threshold | Messages exceeding the threshold are discarded; long polling cannot retrieve discarded messages |
27
+ | avchatroom cache window (`2` min / `2000` msgs) | Temporary cache boundary | Messages beyond the time or count limit are purged from the cache |
28
+
29
+ ## 3. Mechanism & Sequence
30
+
31
+ Business sends message (SDK/REST API) -> AVChatRoom backend applies group rate limit (default `40` msg/s) -> Client receives messages via long polling and triggers `MESSAGE_RECEIVED` -> Business consumes the callback list.
32
+ When the app resumes after a long background period (over `2` minutes): WebSocket reconnects -> long polling resumes -> only messages within the cache window (`2` minutes and at most `2000` messages) can be pulled.
33
+
34
+ ## 4. Standard Usage
35
+
36
+ 1. **Fix receive logic (Scenario 1)**: Iterate over all items in `event.data` within the `MESSAGE_RECEIVED` callback. Never process only `event.data[0]`.
37
+ 2. **Ensure important message delivery (Scenario 2)**: Set high priority for critical messages such as lottery draws or product listing/delisting notifications.
38
+ - SDK sending: Set `priority` in `createXXXMessage`.
39
+ - REST API sending: Set `MsgPriority` in the message body.
40
+ 3. **Control sending rate (Scenario 2)**: Implement rate limiting or message merging on the business side to avoid continuously exceeding `40` messages/second per group.
41
+ 4. **Handle background recovery expectations (Scenario 3)**: Treat "possible loss of avchatroom history after a long background period" as an expected product behavior, and use business-level fallback mechanisms (e.g., critical state re-pull API) to recover.
42
+
43
+ ## 5. Expected Results
44
+
45
+ - During batch message stress testing, every item in `event.data` from the `MESSAGE_RECEIVED` callback is consumed, with no "only first message received" issue.
46
+ - When the sending rate exceeds `40` msg/s, low-priority messages are discarded first, and the delivery rate of high-priority critical notifications increases.
47
+ - Both REST API and SDK sending paths have the priority field (`MsgPriority` / `priority`) configured.
48
+ - After the app resumes from more than `2` minutes in the background, the business side can recover critical state through fallback mechanisms.
49
+
50
+ ## 6. Common Pitfalls
51
+
52
+ - Pitfall 1: Treating `MESSAGE_RECEIVED` as a single-message callback and only processing `event.data[0]`.
53
+ - Pitfall 2: Not setting message priority in high-concurrency avchatroom, causing critical messages to compete at the same level as spam messages.
54
+ - Pitfall 3: Using a avchatroom as if it were a roaming group, expecting all historical messages to be available after a long background period.
55
+
56
+ ## 7. Problem Definition (retrieval hint)
57
+
58
+ In the Web Chat SDK AVChatRoom scenario, "message loss" is observed. The business wants to ensure that important messages such as lottery draws and product listing/delisting notifications are not lost.
59
+
60
+ ## 8. Alternative Queries (retrieval recall)
61
+
62
+ - Why does AVChatRoom lose messages?
63
+ - How to ensure product delisting messages are always delivered during high-frequency chat in a avchatroom?
64
+ - How to handle multiple messages returned in a single `MESSAGE_RECEIVED` callback?
65
+ - Why can't previously sent messages be pulled after reconnecting from a long background period in a avchatroom?
@@ -0,0 +1,62 @@
1
+ ---
2
+ title: "Web/Mini Program Chat SDK: Removing Residual Conversations After Leaving or Dismissing a Group(退群 / 群组解散 / 被踢出群 / 删除会话列表中已退出的群组)"
3
+ product: chat
4
+ frameworks: [web, miniprogram]
5
+ scope: platform_common
6
+ tags: [quitGroup, dismissGroup, deleteConversation, TIMGroupSystemNoticeElem, operationType, conversation list, leave group, dismiss group]
7
+ version_range: ">=3.0.0"
8
+ ---
9
+
10
+ # Web/Mini Program Chat SDK: Removing Residual Conversations After Leaving or Dismissing a Group
11
+
12
+ ## 1. Key Takeaways
13
+
14
+ - The conversation remaining after `quitGroup` / `dismissGroup` is an intentional SDK UX design: while the login session is valid, the group conversation is retained so users can still view message history.
15
+ - To completely remove it from the conversation list, you must actively call `deleteConversation` after receiving the group system notice (`TIMGroupSystemNoticeElem`).
16
+ - The deletion trigger condition is determined by `message.payload.operationType`: `4` (kicked from group), `5` (group dismissed), `8` (user actively left group).
17
+ - Relying solely on the return result of `quitGroup` / `dismissGroup` does not automatically delete the conversation list entry.
18
+
19
+ ## 2. Field / API Reference
20
+
21
+ | Field / Capability | Purpose | Description |
22
+ |---|---|---|
23
+ | `TIMGroupSystemNoticeElem` | Group system notice type | Identifies system events such as member changes, dismissal, and leaving |
24
+ | `message.payload.operationType` | Notice action code | `4` kicked out, `5` group dismissed, `8` actively left |
25
+ | `deleteConversation` | Delete conversation API | Called when the trigger condition is met to remove the corresponding group conversation from the conversation list |
26
+ | `quitGroup` / `dismissGroup` | Group management actions | Perform leave/dismiss; they do not handle conversation list cleanup |
27
+
28
+ ## 3. Mechanism & Sequence
29
+
30
+ Business calls `quitGroup` or `dismissGroup` -> SDK retains the corresponding group conversation (while login session is valid) -> Receives `TIMGroupSystemNoticeElem` -> Business checks `operationType` to determine whether to trigger deletion -> When matching `4/5/8`, calls `deleteConversation` -> Conversation list removes the group conversation.
31
+
32
+ ## 4. Standard Usage
33
+
34
+ 1. Without UI integration: Listen to `MESSAGE_RECEIVED` directly via `chat.on` and handle group system notices in the callback.
35
+ 2. With UI integration: First obtain the `chat` instance from `TUILogin.getContext()`, then listen to `MESSAGE_RECEIVED` via `chat.on` to receive system notices.
36
+ 3. Filter messages of type `TIMGroupSystemNoticeElem` in the callback.
37
+ 4. Read `message.payload.operationType`; only enter the deletion branch for values `4`, `5`, or `8`.
38
+ 5. Call `deleteConversation` with the group conversation ID, and refresh the conversation list state after success to avoid local cache residuals.
39
+
40
+ ## 5. Expected Results
41
+
42
+ - After calling `quitGroup`, the `operationType=8` notice is received and `deleteConversation` is triggered successfully.
43
+ - After calling `dismissGroup`, the `operationType=5` notice is received and the group conversation is removed successfully.
44
+ - When kicked by an admin, the `operationType=4` notice triggers automatic conversation cleanup.
45
+ - After refreshing the conversation list, the target group conversation no longer appears and is not re-displayed due to system notice echoing.
46
+
47
+ ## 6. Common Pitfalls
48
+
49
+ - Pitfall 1: Assuming `quitGroup` / `dismissGroup` automatically deletes the conversation list entry.
50
+ - Pitfall 2: Ignoring the group system notice without reading `operationType`.
51
+ - Pitfall 3: Only performing local UI deletion without calling `deleteConversation`, causing the conversation to reappear.
52
+
53
+ ## 7. Problem Definition (retrieval hint)
54
+
55
+ After calling `quitGroup` or `dismissGroup` in the Web Chat SDK, the group conversation still exists in the conversation list; after receiving the system message "You have left this group", the conversation reappears in the list. The business needs to completely remove the group conversation after leaving or dismissing the group.
56
+
57
+ ## 8. Alternative Queries (retrieval recall)
58
+
59
+ - Why is the group conversation still in the conversation list after calling `quitGroup`?
60
+ - Why does the conversation reappear after `dismissGroup`?
61
+ - How to delete the conversation after receiving "You have left this group"?
62
+ - How to link group system notices with `deleteConversation`?
@@ -0,0 +1,59 @@
1
+ ---
2
+ title: "Chat SDK: Image Message URL Lifecycle (blob vs. imageUrl)(图片消息 blob 地址 / 服务端 url 更新时机 / imageInfoArray / 图片消息 url)"
3
+ product: chat
4
+ frameworks: [web, miniprogram]
5
+ scope: platform_common
6
+ tags: [sendMessage, createImageMessage, imageInfoArray, imageUrl, url, blob, https, image message, upload progress, lifecycle]
7
+ version_range: ">=3.0.0"
8
+ ---
9
+
10
+ # Chat SDK: Image Message URL Lifecycle (blob vs. imageUrl)
11
+
12
+ ## 1. Key Takeaways
13
+
14
+ - `imageInfoArray[x].url` is primarily used for local preview; it remains a `blob:` in-memory URL even after the message is sent successfully.
15
+ - When you need a cloud-accessible URL, read `imageInfoArray[x].imageUrl` from the successfully sent message.
16
+ - After refreshing and re-logging in, when pulling roaming messages, `imageInfoArray[x].url` is the server-side URL.
17
+ - To get upload progress, pass an `onProgress` callback when calling `createImageMessage`.
18
+
19
+ ## 2. Field / API Reference
20
+
21
+ | Field / Capability | Phase | Semantics |
22
+ |---|---|---|
23
+ | `imageInfoArray[x].url` | During/after sending | Local preview address; may be `blob:`; not guaranteed to auto-update to a cloud URL |
24
+ | `imageInfoArray[x].imageUrl` | After successful send | Server-accessible address; use as the externally accessible URL |
25
+ | `onProgress` | During upload | File upload progress callback for displaying upload progress |
26
+
27
+ ## 3. Mechanism & Sequence
28
+
29
+ `createImageMessage` -> `sendMessage` -> Internal upload flow -> Upload succeeds and message is sent to IM backend -> Read `imageInfoArray[x].imageUrl` from the returned message -> After refreshing and re-logging in, pulling roaming messages yields `imageInfoArray[x].url` as the server-side URL.
30
+
31
+ ## 4. Standard Usage
32
+
33
+ 1. Call `createImageMessage` to create an image message (pass `onProgress` if progress is needed).
34
+ 2. Call `sendMessage` to send the message.
35
+ 3. After successful sending, read `imageInfoArray[x].imageUrl` from the returned message as the cloud URL.
36
+ 4. Correct approach for rendering images on the frontend: read `imageInfoArray[x].url` when rendering the message; using the `blob` address during sending enables faster image rendering.
37
+
38
+ ## 5. Expected Results
39
+
40
+ - After sending, inspect the same message:
41
+ - `imageInfoArray[x].url` is still `blob:`;
42
+ - `imageInfoArray[x].imageUrl` is a server-accessible address.
43
+ - After refreshing and re-logging in, pulling history messages yields `imageInfoArray[x].url` as the server-side URL.
44
+
45
+ ## 6. Common Pitfalls
46
+
47
+ - Pitfall 1: Assuming that `url` will automatically change to a cloud link after upload.
48
+
49
+ ## 7. Problem Definition (retrieval hint)
50
+
51
+ After sending an image message, the user observes that `imageInfoArray[x].url` is still a `blob:` local URL and expects it to automatically become a Tencent Cloud `https` URL. The user also wants to know which field to read as the final accessible address after upload is complete.
52
+
53
+ ## 8. Alternative Queries (retrieval recall)
54
+
55
+ - Why is `url` still `blob:` after sending an image message?
56
+ - Which field should I use to get the cloud `https` image URL?
57
+ - How to get the final image URL after `sendMessage` succeeds?
58
+ - What is the difference between `imageInfoArray[x].url` and `imageInfoArray[x].imageUrl`?
59
+ - Why does the image URL in history messages change after refreshing?
@@ -0,0 +1,61 @@
1
+ ---
2
+ title: "Web Chat SDK: login Returns 2025 (Repeat Login) Diagnosis and Fix(重复登录 / repeatLogin)"
3
+ product: chat
4
+ frameworks: [web, miniprogram]
5
+ scope: platform_common
6
+ tags: [login, 2025, repeat login, repeatLogin, web, miniprogram, concurrent calls, debounce]
7
+ version_range: ">=3.0.0"
8
+ ---
9
+
10
+ # Web Chat SDK: login Returns 2025 (Repeat Login) Diagnosis and Fix
11
+
12
+ ## 1. Key Takeaways
13
+
14
+ - The direct cause of `2025` is that the business side calls `login` consecutively in a short time while the SDK has not yet received the backend response for the first login request.
15
+ - Within approximately `15s` after the first `login` is initiated, if the previous login has not received a response, the SDK directly blocks subsequent `login` calls and returns `2025`.
16
+ - If the SDK has already received the login response and the same `userID` calls `login` again, it does not trigger the `2025` blocking branch; instead it returns `imResponse.data.repeatLogin = true` in `login.then`.
17
+ - The solution is to fix the `login` call logic on the business side: ensure only one in-flight `login` request exists for the same session.
18
+
19
+ ## 2. Field / API Reference
20
+
21
+ | Field / Capability | Purpose | Description |
22
+ |---|---|---|
23
+ | Error code `2025` | Repeat login blocking signal | When a previous `login` has not received a response, subsequent calls within a short period are directly blocked by the SDK |
24
+ | `imResponse.data.repeatLogin` | Repeat login flag | When the SDK has received a response and the same `userID` logs in again, this returns `true` in `then` |
25
+ | `login` in-flight state | Key state for concurrency control | The business side must ensure only one `login` is executing at a time |
26
+
27
+ ## 3. Mechanism & Sequence
28
+
29
+ First `login` call -> SDK sends login request -> Backend response not yet received -> Business side calls `login` again within ~`15s` -> SDK directly blocks and returns `2025`.
30
+ First `login` call -> SDK has received backend response -> Business side calls `login` again with the same `userID` -> `imResponse.data.repeatLogin = true` is returned in `login.then`.
31
+
32
+ ## 4. Standard Usage
33
+
34
+ 1. Implement single-flight login on the business side: for the same `userID`, prohibit duplicate calls before the previous `login` completes.
35
+ 2. Add a state machine (`idle`/`logging_in`/`logged_in`) or Promise reuse for `login`, reusing the in-flight login result.
36
+ 3. Upon receiving `2025`, do not retry immediately; wait for the current in-flight login to complete, then decide the next action based on the result.
37
+ 4. Check `imResponse.data.repeatLogin` in `login.then` and handle it as an "already logged in" branch without re-initializing the session.
38
+
39
+ ## 5. Expected Results
40
+
41
+ - When login is triggered consecutively for the same `userID`, the business side only sends one real `login` request.
42
+ - Under stress testing with rapid login button clicks, `2025` no longer occurs.
43
+ - When `login` is called again after a response has been received, `repeatLogin` is consistently observed in `then` and the expected branch is followed.
44
+ - Login state initialization logic executes only once, with no duplicate conversation pulls or duplicate listeners.
45
+
46
+ ## 6. Common Pitfalls
47
+
48
+ - Pitfall 1: Immediately calling `login` again upon receiving `2025`, creating a blocking loop.
49
+ - Pitfall 2: Treating `2025` and `repeatLogin=true` as the same-phase error.
50
+ - Pitfall 3: Not implementing idempotency protection in `onShow`, route changes, or reconnection callbacks, leading to concurrent login calls.
51
+
52
+ ## 7. Problem Definition (retrieval hint)
53
+
54
+ When calling `login` in the Web Chat SDK, triggering the login request repeatedly in a short time returns `2025`. The business side needs to understand: under what conditions `2025` is triggered, and how it differs from `imResponse.data.repeatLogin = true`.
55
+
56
+ ## 8. Alternative Queries (retrieval recall)
57
+
58
+ - Why does the Web IM SDK `login` return 2025?
59
+ - What does `login` returning 2025 mean?
60
+ - Under what circumstances does the repeat login error code 2025 occur?
61
+ - What is the difference between `repeatLogin=true` and `2025`?
@@ -0,0 +1,64 @@
1
+ ---
2
+ title: "Web Chat SDK: Conversation Read Report and Message Read Receipt (setMessageRead vs. sendMessageReadReceipt)(已读上报 setMessageRead / 已读回执 sendMessageReadReceipt)"
3
+ product: chat
4
+ frameworks: [web, miniprogram]
5
+ scope: platform_common
6
+ tags: [setMessageRead, sendMessageReadReceipt, read receipt, MESSAGE_READ_BY_PEER, MESSAGE_READ_RECEIPT_RECEIVED, needReadReceipt, group message read]
7
+ version_range: ">=3.0.0"
8
+ ---
9
+
10
+ # Web Chat SDK: Conversation Read Report and Message Read Receipt (setMessageRead vs. sendMessageReadReceipt)
11
+
12
+ ## 1. Key Takeaways
13
+
14
+ - The recommended flow for automatically sending message-level read receipts upon entering a conversation is: first pull roaming messages via `getMessageList`, then call `sendMessageReadReceipt` to report the corresponding messages as read.
15
+ - `setMessageRead` is a conversation-level read report: a successful call clears the unread count of the current conversation; in one-to-one chat scenarios, the peer can update message read status via `MESSAGE_READ_BY_PEER`.
16
+ - `sendMessageReadReceipt` is a message-level read receipt: it does not affect the conversation unread count, only the read/unread status of individual messages; for group messages, this capability is required to implement message-level read status.
17
+ - The message read receipt capability has usage restrictions: not available on Trial/Standard plans; `needReadReceipt=true` must be set when creating the message; group read receipts require a group size limit of `200` and the group message read receipt switch must be enabled in the console (Console > Feature Configuration > Group Configuration > Group Message Read Receipt).
18
+
19
+ ## 2. Field / API Reference
20
+
21
+ | Field / Capability | Purpose | Description |
22
+ |---|---|---|
23
+ | `setMessageRead` | Conversation-level read report | Clears the current conversation's unread count; in one-to-one chat, can trigger `MESSAGE_READ_BY_PEER` on the peer side |
24
+ | `sendMessageReadReceipt` | Message-level read receipt | Does not clear conversation unread count; only updates message read/unread status |
25
+ | `needReadReceipt` | Message read receipt switch | Must be set to `true` when creating a message to enable message-level receipts |
26
+ | `MESSAGE_READ_BY_PEER` | One-to-one chat peer read event | Used to update one-to-one chat message read status |
27
+ | `MESSAGE_READ_RECEIPT_RECEIVED` | Message receipt received event | Used to process received message read receipt updates |
28
+
29
+ ## 3. Mechanism & Sequence
30
+
31
+ Enter conversation -> Call `getMessageList` to pull roaming messages -> Pass the message list to `sendMessageReadReceipt` (SDK internally filters and processes) -> SDK dispatches read receipt event (e.g., `MESSAGE_READ_RECEIPT_RECEIVED`) -> Business updates message read/unread display.
32
+ If `setMessageRead` is called: conversation unread count is cleared; in one-to-one chat, the peer can receive `MESSAGE_READ_BY_PEER`.
33
+
34
+ ## 4. Standard Usage
35
+
36
+ 1. Upon entering a conversation, first call `getMessageList` to pull the message list.
37
+ 2. Pass the message list returned by `getMessageList` directly to `sendMessageReadReceipt`; the SDK internally filters and completes message-level read reporting.
38
+ 3. Only call `setMessageRead` when you need to handle conversation unread count; do not use it as a substitute for group message read receipts.
39
+ 4. Set `needReadReceipt = true` when creating messages that require receipts.
40
+ 5. Subscribe to and handle `MESSAGE_READ_BY_PEER` and `MESSAGE_READ_RECEIPT_RECEIVED` to synchronously update message read status.
41
+
42
+ ## 5. Expected Results
43
+
44
+ - After entering a group chat, pulled messages successfully trigger `sendMessageReadReceipt`.
45
+ - After calling `sendMessageReadReceipt`, the conversation unread count is not cleared, but message read status is updated.
46
+ - After calling `setMessageRead`, the conversation unread count is cleared, and the one-to-one chat peer can observe `MESSAGE_READ_BY_PEER`.
47
+ - In the group read scenario, the correct plan is activated, the console switch is enabled, and the group size does not exceed `200`.
48
+
49
+ ## 6. Common Pitfalls
50
+
51
+ - Pitfall 1: Using `setMessageRead` instead of `sendMessageReadReceipt` to implement group message read status.
52
+ - Pitfall 2: Expecting to receive message-level read receipts without setting `needReadReceipt=true`.
53
+ - Pitfall 3: Going live with group read capability without activating the Premium plan or enabling the group message read receipt switch.
54
+
55
+ ## 7. Problem Definition (retrieval hint)
56
+
57
+ After entering a group chat conversation on the Web, how to automatically send read receipts to message senders? What is the difference between `setMessageRead` and `sendMessageReadReceipt`?
58
+
59
+ ## 8. Alternative Queries (retrieval recall)
60
+
61
+ - How to automatically report read status after entering a conversation?
62
+ - Which API should be used for group chat read/unread display?
63
+ - What is the difference between `setMessageRead` and `sendMessageReadReceipt`?
64
+ - Why does message read status not change as expected after calling `setMessageRead`?
@@ -0,0 +1,65 @@
1
+ ---
2
+ title: "Web Chat SDK: MESSAGE_RECEIVED Event and Group Tip Message Handling(MESSAGE_RECEIVED / 群提示消息TIMGroupTipElem / 接收消息 / 自己发的消息上屏)"
3
+ product: chat
4
+ frameworks: [web, miniprogram]
5
+ scope: platform_common
6
+ tags: [MESSAGE_RECEIVED, TIMGroupTipElem, TIMGroupSystemNoticeElem, message receive, self-sent message, event.data]
7
+ version_range: ">=3.0.0"
8
+ ---
9
+
10
+ # Web Chat SDK: MESSAGE_RECEIVED Event and Group Tip Message Handling
11
+
12
+ ## 1. Key Takeaways
13
+
14
+ - The Web Chat SDK delivers all message notifications to the business side through the unified `MESSAGE_RECEIVED` event.
15
+ - By iterating over `event.data` in the callback, you can distinguish between normal messages, group tip messages (`TIMGroupTipElem`), and group system notices (`TIMGroupSystemNoticeElem`) using the `type` field.
16
+ - Messages sent by the current instance are not delivered back to itself via `MESSAGE_RECEIVED`; self-sent messages should be added to the on-screen message list immediately after creation.
17
+ - In multi-instance or multi-device login scenarios, messages sent by other instances can be received via `MESSAGE_RECEIVED`.
18
+
19
+ ## 2. Field / API Reference
20
+
21
+ | Field / Capability | Purpose | Description |
22
+ |---|---|---|
23
+ | `EVENT.MESSAGE_RECEIVED` | Unified receive entry | All received messages are delivered to the business side through this event |
24
+ | `event.data` | Message list payload | A single callback may contain multiple messages; all must be iterated and processed |
25
+ | `message.type` | Message classification field | Used to identify normal messages, `TIMGroupTipElem`, and `TIMGroupSystemNoticeElem` |
26
+ | Self-sent message rendering | UI timing control | Messages sent by the current instance should be rendered on screen immediately after creation, not relying on `MESSAGE_RECEIVED` |
27
+
28
+ ## 3. Mechanism & Sequence
29
+
30
+ Business subscribes to `MESSAGE_RECEIVED` -> SDK delivers message list `event.data` -> Business iterates the list and routes by `type`.
31
+ Current instance sends a message: creates message and immediately renders locally -> calls send API -> does not deliver back via `MESSAGE_RECEIVED`.
32
+ Other instances/devices send a message: current device receives it via `MESSAGE_RECEIVED` and processes by type.
33
+
34
+ ## 4. Standard Usage
35
+
36
+ 1. Subscribe to `EVENT.MESSAGE_RECEIVED`; read the full `event.data` list in the callback.
37
+ 2. Route each message by `type`: normal messages, `TIMGroupTipElem`, and `TIMGroupSystemNoticeElem` go to different business handlers.
38
+ 3. When sending a message yourself, add it to the local message list immediately after `createXXXMessage` to ensure timely on-screen display.
39
+ 4. Maintain clear responsibility boundaries between send callbacks and receive callbacks: the send path handles local state, the receive path handles messages from other devices/instances.
40
+
41
+ ## 5. Expected Results
42
+
43
+ - After a group tip event triggers, `TIMGroupTipElem` is correctly identified in `MESSAGE_RECEIVED` and the correct handling logic is executed.
44
+ - Group system notices are correctly identified as `TIMGroupSystemNoticeElem` in the callback and properly routed.
45
+ - When the current instance sends a message, it is rendered locally immediately without waiting for `MESSAGE_RECEIVED`.
46
+ - In multi-device login scenarios, messages sent from other devices are received normally via `MESSAGE_RECEIVED`.
47
+
48
+ ## 6. Common Pitfalls
49
+
50
+ - Pitfall 1: Treating `MESSAGE_RECEIVED` as a single-message callback and only processing `event.data[0]`.
51
+ - Pitfall 2: Expecting messages sent by the current instance to be delivered back via `MESSAGE_RECEIVED` before rendering on screen.
52
+ - Pitfall 3: Not classifying by `type`, causing group tip messages and normal text messages to share the same handling logic.
53
+
54
+ ## 7. Problem Definition (retrieval hint)
55
+
56
+ In the Web Chat SDK scenario, the business side needs to clarify two things:
57
+ 1) How to receive and identify group tip messages `TIMGroupTipElem`;
58
+ 2) Whether `MESSAGE_RECEIVED` delivers messages sent by the current instance itself.
59
+
60
+ ## 8. Alternative Queries (retrieval recall)
61
+
62
+ - How does the Web SDK receive group tip messages `TIMGroupTipElem`?
63
+ - How to distinguish between normal messages and group system messages in the `MESSAGE_RECEIVED` callback?
64
+ - Why are self-sent messages not received via `MESSAGE_RECEIVED`?
65
+ - In multi-device login, can messages sent from other devices be received via `MESSAGE_RECEIVED`?