@webex/plugin-meetings 3.12.0-next.17 → 3.12.0-next.171

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 (301) hide show
  1. package/.sdd/manifest.json +1312 -0
  2. package/.sdd/templates/.source.json +30 -0
  3. package/.sdd/templates/component-repo/module-docs/module-spec-quality.md +111 -0
  4. package/.sdd/templates/component-repo/module-docs/module-spec.template.md +321 -0
  5. package/.sdd/templates/component-repo/reference-docs/adr/_adr-example.md +59 -0
  6. package/.sdd/templates/component-repo/reference-docs/patterns/_pattern-example.md +49 -0
  7. package/.sdd/templates/component-repo/reference-docs/rules/_rule-example.md +42 -0
  8. package/.sdd/templates/component-repo/standing-docs/AGENTS.template.md +120 -0
  9. package/.sdd/templates/component-repo/standing-docs/ARCHITECTURE.template.md +206 -0
  10. package/.sdd/templates/component-repo/standing-docs/CONTRACTS.template.md +90 -0
  11. package/.sdd/templates/component-repo/standing-docs/DATA_MODEL.template.md +68 -0
  12. package/.sdd/templates/component-repo/standing-docs/GETTING_STARTED.template.md +111 -0
  13. package/.sdd/templates/component-repo/standing-docs/GLOSSARY.template.md +57 -0
  14. package/.sdd/templates/component-repo/standing-docs/REVIEW_CHECKLIST.template.md +69 -0
  15. package/.sdd/templates/component-repo/standing-docs/RULES.template.md +96 -0
  16. package/.sdd/templates/component-repo/standing-docs/SECURITY.template.md +84 -0
  17. package/.sdd/templates/component-repo/standing-docs/SERVICE_STATE.template.md +82 -0
  18. package/.sdd/templates/component-repo/standing-docs/SPEC_INDEX.template.md +94 -0
  19. package/.sdd/templates/component-repo/standing-docs/TEST_INDEX.template.md +64 -0
  20. package/.sdd/templates/component-repo/template-map.json +112 -0
  21. package/AGENTS.md +135 -0
  22. package/ai-docs/ARCHITECTURE.md +207 -0
  23. package/ai-docs/CONTRACTS.md +267 -0
  24. package/ai-docs/DATA_MODEL.md +64 -0
  25. package/ai-docs/GETTING_STARTED.md +73 -0
  26. package/ai-docs/GLOSSARY.md +56 -0
  27. package/ai-docs/REVIEW_CHECKLIST.md +45 -0
  28. package/ai-docs/RULES.md +79 -0
  29. package/ai-docs/SECURITY.md +74 -0
  30. package/ai-docs/SERVICE_STATE.md +59 -0
  31. package/ai-docs/SPEC_INDEX.md +85 -0
  32. package/ai-docs/TEST_INDEX.md +45 -0
  33. package/ai-docs/adr/0001-migrate-existing-docs-into-sdd.md +61 -0
  34. package/ai-docs/patterns/defensive-error-propagation.md +55 -0
  35. package/ai-docs/patterns/event-scope-emission.md +46 -0
  36. package/ai-docs/patterns/source-to-test-path-mirroring.md +45 -0
  37. package/ai-docs/patterns/stateless-plugin-request-classes.md +53 -0
  38. package/ai-docs/patterns/typed-constants-and-enum-values.md +47 -0
  39. package/dist/aiEnableRequest/index.js +15 -2
  40. package/dist/aiEnableRequest/index.js.map +1 -1
  41. package/dist/annotation/index.js +2 -2
  42. package/dist/annotation/index.js.map +1 -1
  43. package/dist/breakouts/breakout.js +8 -3
  44. package/dist/breakouts/breakout.js.map +1 -1
  45. package/dist/breakouts/events.js +29 -14
  46. package/dist/breakouts/events.js.map +1 -1
  47. package/dist/breakouts/index.js +99 -4
  48. package/dist/breakouts/index.js.map +1 -1
  49. package/dist/common/errors/webex-errors.js +49 -5
  50. package/dist/common/errors/webex-errors.js.map +1 -1
  51. package/dist/config.js +2 -2
  52. package/dist/config.js.map +1 -1
  53. package/dist/constants.js +37 -10
  54. package/dist/constants.js.map +1 -1
  55. package/dist/controls-options-manager/index.js +46 -10
  56. package/dist/controls-options-manager/index.js.map +1 -1
  57. package/dist/hashTree/constants.js +4 -1
  58. package/dist/hashTree/constants.js.map +1 -1
  59. package/dist/hashTree/hashTreeParser.js +1096 -391
  60. package/dist/hashTree/hashTreeParser.js.map +1 -1
  61. package/dist/hashTree/utils.js +20 -0
  62. package/dist/hashTree/utils.js.map +1 -1
  63. package/dist/index.js +7 -0
  64. package/dist/index.js.map +1 -1
  65. package/dist/interceptors/dataChannelAuthToken.js +75 -15
  66. package/dist/interceptors/dataChannelAuthToken.js.map +1 -1
  67. package/dist/interceptors/locusRetry.js +24 -9
  68. package/dist/interceptors/locusRetry.js.map +1 -1
  69. package/dist/interpretation/index.js +55 -12
  70. package/dist/interpretation/index.js.map +1 -1
  71. package/dist/interpretation/interpretation.types.js +7 -0
  72. package/dist/interpretation/interpretation.types.js.map +1 -0
  73. package/dist/interpretation/siLanguage.js +1 -1
  74. package/dist/locus-info/controlsUtils.js +4 -1
  75. package/dist/locus-info/controlsUtils.js.map +1 -1
  76. package/dist/locus-info/index.js +615 -176
  77. package/dist/locus-info/index.js.map +1 -1
  78. package/dist/locus-info/infoUtils.js +36 -5
  79. package/dist/locus-info/infoUtils.js.map +1 -1
  80. package/dist/locus-info/types.js +20 -0
  81. package/dist/locus-info/types.js.map +1 -1
  82. package/dist/media/MediaConnectionAwaiter.js +15 -2
  83. package/dist/media/MediaConnectionAwaiter.js.map +1 -1
  84. package/dist/media/index.js +8 -2
  85. package/dist/media/index.js.map +1 -1
  86. package/dist/media/properties.js +4 -5
  87. package/dist/media/properties.js.map +1 -1
  88. package/dist/meeting/in-meeting-actions.js +5 -1
  89. package/dist/meeting/in-meeting-actions.js.map +1 -1
  90. package/dist/meeting/index.js +1684 -835
  91. package/dist/meeting/index.js.map +1 -1
  92. package/dist/meeting/locusMediaRequest.js +229 -82
  93. package/dist/meeting/locusMediaRequest.js.map +1 -1
  94. package/dist/meeting/muteState.js +10 -1
  95. package/dist/meeting/muteState.js.map +1 -1
  96. package/dist/meeting/request.js +5 -2
  97. package/dist/meeting/request.js.map +1 -1
  98. package/dist/meeting/util.js +37 -3
  99. package/dist/meeting/util.js.map +1 -1
  100. package/dist/meeting/voicea-meeting.js +2 -1
  101. package/dist/meeting/voicea-meeting.js.map +1 -1
  102. package/dist/meeting-info/meeting-info-v2.js +12 -5
  103. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  104. package/dist/meetings/index.js +300 -128
  105. package/dist/meetings/index.js.map +1 -1
  106. package/dist/meetings/meetings.types.js +6 -1
  107. package/dist/meetings/meetings.types.js.map +1 -1
  108. package/dist/meetings/request.js +39 -0
  109. package/dist/meetings/request.js.map +1 -1
  110. package/dist/meetings/util.js +116 -18
  111. package/dist/meetings/util.js.map +1 -1
  112. package/dist/member/index.js +10 -0
  113. package/dist/member/index.js.map +1 -1
  114. package/dist/member/types.js.map +1 -1
  115. package/dist/member/util.js +30 -0
  116. package/dist/member/util.js.map +1 -1
  117. package/dist/members/index.js +101 -43
  118. package/dist/members/index.js.map +1 -1
  119. package/dist/members/util.js +8 -1
  120. package/dist/members/util.js.map +1 -1
  121. package/dist/metrics/constants.js +7 -1
  122. package/dist/metrics/constants.js.map +1 -1
  123. package/dist/multistream/codec/constants.js +63 -0
  124. package/dist/multistream/codec/constants.js.map +1 -0
  125. package/dist/multistream/mediaRequestManager.js +62 -15
  126. package/dist/multistream/mediaRequestManager.js.map +1 -1
  127. package/dist/multistream/receiveSlot.js +9 -0
  128. package/dist/multistream/receiveSlot.js.map +1 -1
  129. package/dist/multistream/remoteMediaManager.js +32 -4
  130. package/dist/multistream/remoteMediaManager.js.map +1 -1
  131. package/dist/reachability/clusterReachability.js.map +1 -1
  132. package/dist/reachability/index.js +121 -83
  133. package/dist/reachability/index.js.map +1 -1
  134. package/dist/reachability/reachability.types.js +2 -0
  135. package/dist/reachability/reachability.types.js.map +1 -1
  136. package/dist/reachability/util.js +45 -0
  137. package/dist/reachability/util.js.map +1 -1
  138. package/dist/reactions/reactions.type.js.map +1 -1
  139. package/dist/recording-controller/index.js +1 -3
  140. package/dist/recording-controller/index.js.map +1 -1
  141. package/dist/roap/turnDiscovery.js +8 -1
  142. package/dist/roap/turnDiscovery.js.map +1 -1
  143. package/dist/types/common/errors/webex-errors.d.ts +32 -2
  144. package/dist/types/config.d.ts +2 -2
  145. package/dist/types/constants.d.ts +13 -1
  146. package/dist/types/controls-options-manager/index.d.ts +16 -0
  147. package/dist/types/hashTree/constants.d.ts +1 -0
  148. package/dist/types/hashTree/hashTreeParser.d.ts +201 -22
  149. package/dist/types/hashTree/utils.d.ts +7 -0
  150. package/dist/types/index.d.ts +3 -0
  151. package/dist/types/interceptors/locusRetry.d.ts +4 -4
  152. package/dist/types/interpretation/interpretation.types.d.ts +10 -0
  153. package/dist/types/locus-info/index.d.ts +106 -8
  154. package/dist/types/locus-info/infoUtils.d.ts +8 -0
  155. package/dist/types/locus-info/types.d.ts +22 -1
  156. package/dist/types/media/MediaConnectionAwaiter.d.ts +10 -1
  157. package/dist/types/media/properties.d.ts +6 -2
  158. package/dist/types/meeting/in-meeting-actions.d.ts +4 -0
  159. package/dist/types/meeting/index.d.ts +178 -11
  160. package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
  161. package/dist/types/meeting/request.d.ts +1 -0
  162. package/dist/types/meeting/util.d.ts +9 -0
  163. package/dist/types/meeting-info/meeting-info-v2.d.ts +1 -0
  164. package/dist/types/meetings/index.d.ts +40 -19
  165. package/dist/types/meetings/meetings.types.d.ts +15 -0
  166. package/dist/types/meetings/request.d.ts +14 -0
  167. package/dist/types/member/index.d.ts +1 -0
  168. package/dist/types/member/types.d.ts +1 -0
  169. package/dist/types/member/util.d.ts +9 -0
  170. package/dist/types/members/index.d.ts +15 -2
  171. package/dist/types/members/util.d.ts +1 -5
  172. package/dist/types/metrics/constants.d.ts +6 -0
  173. package/dist/types/multistream/codec/constants.d.ts +7 -0
  174. package/dist/types/multistream/mediaRequestManager.d.ts +22 -5
  175. package/dist/types/multistream/remoteMediaManager.d.ts +18 -0
  176. package/dist/types/reachability/clusterReachability.d.ts +3 -3
  177. package/dist/types/reachability/index.d.ts +10 -3
  178. package/dist/types/reachability/reachability.types.d.ts +7 -0
  179. package/dist/types/reachability/util.d.ts +17 -0
  180. package/dist/types/reactions/reactions.type.d.ts +3 -0
  181. package/dist/webinar/index.js +307 -161
  182. package/dist/webinar/index.js.map +1 -1
  183. package/package.json +23 -23
  184. package/src/aiEnableRequest/ai-docs/ai-enable-request-spec.md +223 -0
  185. package/src/aiEnableRequest/index.ts +16 -0
  186. package/src/annotation/ai-docs/annotation-spec.md +236 -0
  187. package/src/annotation/index.ts +6 -4
  188. package/src/breakouts/ai-docs/breakouts-spec.md +324 -0
  189. package/src/breakouts/breakout.ts +3 -1
  190. package/src/breakouts/events.ts +33 -11
  191. package/src/breakouts/index.ts +122 -2
  192. package/src/common/errors/webex-errors.ts +50 -3
  193. package/src/config.ts +2 -2
  194. package/src/constants.ts +21 -3
  195. package/src/controls-options-manager/ai-docs/controls-options-manager-spec.md +243 -0
  196. package/src/controls-options-manager/index.ts +62 -10
  197. package/src/hashTree/ai-docs/hash-tree-spec.md +267 -0
  198. package/src/hashTree/constants.ts +7 -0
  199. package/src/hashTree/hashTreeParser.ts +861 -193
  200. package/src/hashTree/utils.ts +19 -0
  201. package/src/index.ts +6 -0
  202. package/src/interceptors/ai-docs/interceptors-spec.md +247 -0
  203. package/src/interceptors/dataChannelAuthToken.ts +88 -12
  204. package/src/interceptors/locusRetry.ts +26 -5
  205. package/src/interpretation/ai-docs/interpretation-spec.md +256 -0
  206. package/src/interpretation/index.ts +65 -10
  207. package/src/interpretation/interpretation.types.ts +11 -0
  208. package/src/locus-info/ai-docs/locus-info-spec.md +293 -0
  209. package/src/locus-info/controlsUtils.ts +3 -1
  210. package/src/locus-info/index.ts +566 -164
  211. package/src/locus-info/infoUtils.ts +41 -6
  212. package/src/locus-info/types.ts +26 -1
  213. package/src/media/MediaConnectionAwaiter.ts +21 -4
  214. package/src/media/ai-docs/media-spec.md +267 -0
  215. package/src/media/index.ts +10 -1
  216. package/src/media/properties.ts +8 -3
  217. package/src/meeting/ai-docs/meeting-spec.md +401 -0
  218. package/src/meeting/in-meeting-actions.ts +8 -0
  219. package/src/meeting/index.ts +944 -120
  220. package/src/meeting/locusMediaRequest.ts +106 -6
  221. package/src/meeting/muteState.ts +10 -1
  222. package/src/meeting/request.ts +11 -0
  223. package/src/meeting/util.ts +51 -7
  224. package/src/meeting/voicea-meeting.ts +1 -1
  225. package/src/meeting-info/ai-docs/meeting-info-spec.md +261 -0
  226. package/src/meeting-info/meeting-info-v2.ts +11 -4
  227. package/src/meetings/ai-docs/meetings-spec.md +296 -0
  228. package/src/meetings/index.ts +200 -80
  229. package/src/meetings/meetings.types.ts +19 -0
  230. package/src/meetings/request.ts +43 -0
  231. package/src/meetings/util.ts +117 -4
  232. package/src/member/ai-docs/member-spec.md +196 -0
  233. package/src/member/index.ts +10 -0
  234. package/src/member/types.ts +1 -0
  235. package/src/member/util.ts +29 -0
  236. package/src/members/ai-docs/members-spec.md +256 -0
  237. package/src/members/index.ts +70 -7
  238. package/src/members/util.ts +12 -4
  239. package/src/metrics/ai-docs/metrics-spec.md +185 -0
  240. package/src/metrics/constants.ts +6 -0
  241. package/src/multistream/ai-docs/multistream-spec.md +292 -0
  242. package/src/multistream/codec/constants.ts +58 -0
  243. package/src/multistream/mediaRequestManager.ts +119 -28
  244. package/src/multistream/receiveSlot.ts +18 -0
  245. package/src/multistream/remoteMediaManager.ts +23 -1
  246. package/src/personal-meeting-room/ai-docs/personal-meeting-room-spec.md +234 -0
  247. package/src/reachability/ai-docs/reachability-spec.md +261 -0
  248. package/src/reachability/clusterReachability.ts +3 -2
  249. package/src/reachability/index.ts +47 -16
  250. package/src/reachability/reachability.types.ts +11 -0
  251. package/src/reachability/util.ts +36 -0
  252. package/src/reactions/ai-docs/reactions-spec.md +198 -0
  253. package/src/reactions/reactions.type.ts +3 -0
  254. package/src/reconnection-manager/ai-docs/reconnection-manager-spec.md +272 -0
  255. package/src/recording-controller/ai-docs/recording-controller-spec.md +223 -0
  256. package/src/recording-controller/index.ts +1 -2
  257. package/src/roap/ai-docs/roap-spec.md +241 -0
  258. package/src/roap/turnDiscovery.ts +9 -1
  259. package/src/webinar/ai-docs/webinar-spec.md +243 -0
  260. package/src/webinar/index.ts +216 -38
  261. package/test/unit/spec/aiEnableRequest/index.ts +86 -0
  262. package/test/unit/spec/annotation/index.ts +3 -3
  263. package/test/unit/spec/breakouts/breakout.ts +9 -3
  264. package/test/unit/spec/breakouts/events.ts +120 -2
  265. package/test/unit/spec/breakouts/index.ts +223 -3
  266. package/test/unit/spec/common/errors/webex-errors.ts +78 -0
  267. package/test/unit/spec/controls-options-manager/index.js +139 -32
  268. package/test/unit/spec/hashTree/hashTreeParser.ts +2451 -184
  269. package/test/unit/spec/hashTree/utils.ts +37 -0
  270. package/test/unit/spec/interceptors/dataChannelAuthToken.ts +196 -0
  271. package/test/unit/spec/interceptors/locusRetry.ts +234 -5
  272. package/test/unit/spec/interpretation/index.ts +119 -4
  273. package/test/unit/spec/locus-info/controlsUtils.js +172 -57
  274. package/test/unit/spec/locus-info/index.js +1014 -58
  275. package/test/unit/spec/locus-info/infoUtils.js +184 -1
  276. package/test/unit/spec/media/MediaConnectionAwaiter.ts +55 -0
  277. package/test/unit/spec/media/index.ts +92 -0
  278. package/test/unit/spec/media/properties.ts +23 -23
  279. package/test/unit/spec/meeting/in-meeting-actions.ts +4 -0
  280. package/test/unit/spec/meeting/index.js +2834 -110
  281. package/test/unit/spec/meeting/locusMediaRequest.ts +406 -4
  282. package/test/unit/spec/meeting/muteState.js +81 -0
  283. package/test/unit/spec/meeting/request.js +12 -0
  284. package/test/unit/spec/meeting/utils.js +189 -17
  285. package/test/unit/spec/meeting/voicea-meeting.ts +85 -1
  286. package/test/unit/spec/meeting-info/meetinginfov2.js +88 -11
  287. package/test/unit/spec/meetings/index.js +544 -49
  288. package/test/unit/spec/meetings/request.js +141 -0
  289. package/test/unit/spec/meetings/utils.js +402 -51
  290. package/test/unit/spec/member/index.js +7 -0
  291. package/test/unit/spec/member/util.js +89 -0
  292. package/test/unit/spec/members/index.js +216 -0
  293. package/test/unit/spec/members/request.js +37 -1
  294. package/test/unit/spec/members/utils.js +63 -0
  295. package/test/unit/spec/multistream/mediaRequestManager.ts +501 -37
  296. package/test/unit/spec/multistream/remoteMediaManager.ts +46 -0
  297. package/test/unit/spec/reachability/index.ts +128 -46
  298. package/test/unit/spec/reachability/util.ts +31 -0
  299. package/test/unit/spec/recording-controller/index.js +9 -8
  300. package/test/unit/spec/roap/turnDiscovery.ts +20 -0
  301. package/test/unit/spec/webinar/index.ts +332 -31
@@ -34,6 +34,9 @@ import {
34
34
  ONLINE,
35
35
  OFFLINE,
36
36
  ROAP_OFFER_ANSWER_EXCHANGE_TIMEOUT,
37
+ LOCUS_LLM_EVENT,
38
+ LLM_PRACTICE_SESSION,
39
+ RECORDING_STATE,
37
40
  } from '@webex/plugin-meetings/src/constants';
38
41
  import {
39
42
  ConnectionState,
@@ -91,6 +94,7 @@ import {
91
94
  MeetingNotActiveError,
92
95
  UserInLobbyError,
93
96
  AddMediaFailed,
97
+ MediaConnectionTimedOutError,
94
98
  } from '../../../../src/common/errors/webex-errors';
95
99
  import WebExMeetingsErrors from '../../../../src/common/errors/webex-meetings-error';
96
100
  import ParameterError from '../../../../src/common/errors/parameter';
@@ -261,11 +265,26 @@ describe('plugin-meetings', () => {
261
265
  webex.meetings.uploadLogs = sinon.stub().returns(Promise.resolve());
262
266
  webex.meetings.reachability = {
263
267
  isAnyPublicClusterReachable: sinon.stub().resolves(true),
268
+ isAnyClusterReachableViaProtocol: sinon.stub().resolves(false),
264
269
  getReachabilityResults: sinon.stub().resolves(undefined),
265
270
  getReachabilityMetrics: sinon.stub().resolves({}),
266
271
  stopReachability: sinon.stub(),
267
272
  isSubnetReachable: sinon.stub().returns(true),
268
273
  };
274
+ webex.internal.llm.resolveSessionOwnership = sinon
275
+ .stub()
276
+ .callsFake((ownerMeetingId, sessionId) => {
277
+ const currentOwner = webex.internal.llm.getOwnerMeetingId
278
+ ? webex.internal.llm.getOwnerMeetingId(sessionId)
279
+ : undefined;
280
+ const canAssertOwnership = !!ownerMeetingId;
281
+
282
+ return {
283
+ currentOwner,
284
+ canAssertOwnership,
285
+ isOwner: !currentOwner || !canAssertOwnership || currentOwner === ownerMeetingId,
286
+ };
287
+ });
269
288
  webex.internal.llm.isDataChannelTokenEnabled = sinon.stub().resolves(false);
270
289
  webex.internal.llm.on = sinon.stub();
271
290
  webex.internal.voicea.announce = sinon.stub();
@@ -417,6 +436,161 @@ describe('plugin-meetings', () => {
417
436
  assert.instanceOf(meeting.mediaRequestManagers.screenShareVideo, MediaRequestManager);
418
437
  });
419
438
 
439
+ it('getIngressPayloadType on webrtcMediaConnection is invoked for H264 when sending multistream video requests', () => {
440
+ const getIngressPayloadType = sinon.stub().returns(97);
441
+
442
+ meeting.isMultistream = true;
443
+ meeting.mediaProperties.webrtcMediaConnection = {
444
+ getIngressPayloadType,
445
+ requestMedia: sinon.stub(),
446
+ };
447
+
448
+ const fakeReceiveSlot = {
449
+ on: sinon.stub(),
450
+ off: sinon.stub(),
451
+ sourceState: 'live',
452
+ mediaType: MediaType.VideoMain,
453
+ wcmeReceiveSlot: {id: 'fake-wcme-slot'},
454
+ };
455
+
456
+ meeting.mediaRequestManagers.video.addRequest(
457
+ {
458
+ policyInfo: {
459
+ policy: 'receiver-selected',
460
+ csi: 42,
461
+ },
462
+ receiveSlots: [fakeReceiveSlot],
463
+ codecInfo: {
464
+ codec: 'h264',
465
+ maxFs: 3600,
466
+ },
467
+ },
468
+ true
469
+ );
470
+
471
+ assert.calledOnceWithExactly(
472
+ getIngressPayloadType,
473
+ MediaType.VideoMain,
474
+ MediaCodecMimeType.H264
475
+ );
476
+ });
477
+
478
+ it('getIngressPayloadType on webrtcMediaConnection is invoked for H264 and AV1 for slides video when AV1 slides support is enabled', () => {
479
+ const localWebex = new MockWebex({
480
+ children: {
481
+ meetings: Meetings,
482
+ credentials: Credentials,
483
+ support: Support,
484
+ llm: LLM,
485
+ mercury: Mercury,
486
+ },
487
+ config: {
488
+ credentials: {
489
+ client_id: 'mock-client-id',
490
+ },
491
+ meetings: {
492
+ reconnection: {
493
+ enabled: false,
494
+ },
495
+ mediaSettings: {},
496
+ metrics: {},
497
+ stats: {},
498
+ experimental: {enableUnifiedMeetings: true},
499
+ degradationPreferences: {maxMacroblocksLimit: 8192},
500
+ enableAv1SlidesSupport: true,
501
+ },
502
+ metrics: {
503
+ type: ['behavioral'],
504
+ },
505
+ },
506
+ });
507
+
508
+ localWebex.internal.newMetrics.callDiagnosticMetrics.clearErrorCache = sinon.stub();
509
+ localWebex.internal.newMetrics.callDiagnosticMetrics.clearEventLimitsForCorrelationId =
510
+ sinon.stub();
511
+ localWebex.internal.support.submitLogs = sinon.stub().returns(Promise.resolve());
512
+ localWebex.internal.services = {get: sinon.stub().returns('locus-url')};
513
+ localWebex.credentials.getOrgId = sinon.stub().returns('fake-org-id');
514
+ localWebex.internal.metrics.submitClientMetrics = sinon.stub().returns(Promise.resolve());
515
+ localWebex.meetings.uploadLogs = sinon.stub().returns(Promise.resolve());
516
+ localWebex.meetings.reachability = {
517
+ isAnyPublicClusterReachable: sinon.stub().resolves(true),
518
+ isAnyClusterReachableViaProtocol: sinon.stub().resolves(false),
519
+ getReachabilityResults: sinon.stub().resolves(undefined),
520
+ getReachabilityMetrics: sinon.stub().resolves({}),
521
+ stopReachability: sinon.stub(),
522
+ isSubnetReachable: sinon.stub().returns(true),
523
+ };
524
+ localWebex.internal.llm.isDataChannelTokenEnabled = sinon.stub().resolves(false);
525
+ localWebex.internal.llm.on = sinon.stub();
526
+ localWebex.internal.voicea.announce = sinon.stub();
527
+ localWebex.internal.newMetrics.callDiagnosticLatencies = new CallDiagnosticLatencies(
528
+ {},
529
+ {parent: localWebex}
530
+ );
531
+
532
+ Metrics.initialSetup(localWebex);
533
+
534
+ const localMeeting = new Meeting(
535
+ {
536
+ userId: uuid1,
537
+ resource: uuid2,
538
+ deviceUrl: uuid3,
539
+ locus: {url: url1},
540
+ destination: testDestination,
541
+ destinationType: DESTINATION_TYPE.MEETING_ID,
542
+ correlationId,
543
+ selfId: uuid1,
544
+ },
545
+ {
546
+ parent: localWebex,
547
+ }
548
+ );
549
+
550
+ const getIngressPayloadType = sinon.stub().callsFake((_mediaType, codecMimeType) => {
551
+ if (codecMimeType === MediaCodecMimeType.H264) {
552
+ return 97;
553
+ }
554
+ if (codecMimeType === MediaCodecMimeType.AV1) {
555
+ return 98;
556
+ }
557
+
558
+ return undefined;
559
+ });
560
+
561
+ localMeeting.isMultistream = true;
562
+ localMeeting.mediaProperties.webrtcMediaConnection = {
563
+ getIngressPayloadType,
564
+ requestMedia: sinon.stub(),
565
+ };
566
+
567
+ const fakeReceiveSlot = {
568
+ on: sinon.stub(),
569
+ off: sinon.stub(),
570
+ sourceState: 'live',
571
+ mediaType: MediaType.VideoSlides,
572
+ wcmeReceiveSlot: {id: 'fake-wcme-slides-slot'},
573
+ };
574
+
575
+ localMeeting.mediaRequestManagers.screenShareVideo.addRequest(
576
+ {
577
+ policyInfo: {
578
+ policy: 'receiver-selected',
579
+ csi: 42,
580
+ },
581
+ receiveSlots: [fakeReceiveSlot],
582
+ codecInfo: {
583
+ codec: 'h264',
584
+ maxFs: 3600,
585
+ },
586
+ },
587
+ true
588
+ );
589
+
590
+ assert.calledWith(getIngressPayloadType, MediaType.VideoSlides, MediaCodecMimeType.H264);
591
+ assert.calledWith(getIngressPayloadType, MediaType.VideoSlides, MediaCodecMimeType.AV1);
592
+ });
593
+
420
594
  it('uses meeting id as correlation id if not provided in constructor', () => {
421
595
  const newMeeting = new Meeting(
422
596
  {
@@ -712,6 +886,81 @@ describe('plugin-meetings', () => {
712
886
  assert.deepEqual(args, [[uuid1], locusUrls]);
713
887
  });
714
888
  });
889
+ describe('#transfer', () => {
890
+ it('should have #transfer', () => {
891
+ assert.exists(meeting.transfer);
892
+ });
893
+
894
+ it('should transfer host using the current locus when the target member is in the current session', async () => {
895
+ sinon
896
+ .stub(meeting.members.membersCollection, 'get')
897
+ .withArgs(uuid2)
898
+ .returns({isInMeeting: true});
899
+ meeting.members.transferHostToMember = sinon.stub().resolves(test1);
900
+
901
+ await meeting.transfer(uuid2, false);
902
+
903
+ assert.calledOnceWithExactly(meeting.members.transferHostToMember, uuid2, false);
904
+ });
905
+
906
+ it('should transfer host using breakout locus when the target member is joined in a breakout session', async () => {
907
+ sinon
908
+ .stub(meeting.members.membersCollection, 'get')
909
+ .withArgs(uuid2)
910
+ .returns({isInMeeting: false});
911
+ meeting.members.transferHostToMember = sinon.stub().resolves(test1);
912
+ meeting.breakouts.breakouts = {
913
+ models: [
914
+ {
915
+ members: {
916
+ membersCollection: {
917
+ get: sinon.stub().withArgs(uuid2).returns({isInMeeting: true}),
918
+ },
919
+ },
920
+ breakoutRosterLocus: {url: 'https://example.com/breakout-locus'},
921
+ },
922
+ ],
923
+ };
924
+
925
+ await meeting.transfer(uuid2, false);
926
+
927
+ assert.calledOnceWithExactly(
928
+ meeting.members.transferHostToMember,
929
+ uuid2,
930
+ false,
931
+ 'https://example.com/breakout-locus'
932
+ );
933
+ });
934
+
935
+ it('should not use breakout locus when the breakout member is not in meeting', async () => {
936
+ sinon
937
+ .stub(meeting.members.membersCollection, 'get')
938
+ .withArgs(uuid2)
939
+ .returns({isInMeeting: false});
940
+ meeting.members.transferHostToMember = sinon.stub().resolves(test1);
941
+ meeting.breakouts.breakouts = {
942
+ models: [
943
+ {
944
+ members: {
945
+ membersCollection: {
946
+ get: sinon.stub().withArgs(uuid2).returns({isInMeeting: false}),
947
+ },
948
+ },
949
+ breakoutRosterLocus: {url: 'https://example.com/breakout-locus'},
950
+ },
951
+ ],
952
+ };
953
+
954
+ await meeting.transfer(uuid2, false);
955
+
956
+ assert.calledOnceWithExactly(
957
+ meeting.members.transferHostToMember,
958
+ uuid2,
959
+ false,
960
+ undefined
961
+ );
962
+ });
963
+ });
715
964
  describe('#getMembers', () => {
716
965
  it('should have #getMembers', () => {
717
966
  assert.exists(meeting.getMembers);
@@ -741,6 +990,8 @@ describe('plugin-meetings', () => {
741
990
  let addMediaInternalStub;
742
991
  let supportsRTCPeerConnectionStub;
743
992
 
993
+ let suspendDestroyMeetingStub;
994
+
744
995
  beforeEach(() => {
745
996
  supportsRTCPeerConnectionStub = sinon
746
997
  .stub(WebCapabilities, 'supportsRTCPeerConnection')
@@ -761,6 +1012,7 @@ describe('plugin-meetings', () => {
761
1012
  .stub(meeting.roap, 'handleTurnDiscoveryHttpResponse')
762
1013
  .resolves({turnServerInfo: fakeTurnServerInfo, turnDiscoverySkippedReason: undefined});
763
1014
  abortTurnDiscoveryStub = sinon.stub(meeting.roap, 'abortTurnDiscovery');
1015
+ suspendDestroyMeetingStub = sinon.stub(meeting.locusInfo, 'suspendDestroyMeeting');
764
1016
  });
765
1017
 
766
1018
  it('should work as expected', async () => {
@@ -783,8 +1035,9 @@ describe('plugin-meetings', () => {
783
1035
  assert.calledOnceWithExactly(
784
1036
  meeting.addMediaInternal,
785
1037
  sinon.match.any,
786
- fakeTurnServerInfo,
787
1038
  false,
1039
+ fakeTurnServerInfo,
1040
+ undefined,
788
1041
  mediaOptions
789
1042
  );
790
1043
 
@@ -792,9 +1045,14 @@ describe('plugin-meetings', () => {
792
1045
 
793
1046
  // resets joinWithMediaRetryInfo
794
1047
  assert.deepEqual(meeting.joinWithMediaRetryInfo, {
795
- isRetry: false,
1048
+ retryCount: 0,
796
1049
  prevJoinResponse: undefined,
797
1050
  });
1051
+
1052
+ // suspendDestroyMeeting should be called with true at start and false on success
1053
+ assert.calledTwice(suspendDestroyMeetingStub);
1054
+ assert.calledWith(suspendDestroyMeetingStub.firstCall, true);
1055
+ assert.calledWith(suspendDestroyMeetingStub.secondCall, false);
798
1056
  });
799
1057
 
800
1058
  it("should not call handleTurnDiscoveryHttpResponse if we don't send a TURN discovery request with join", async () => {
@@ -816,8 +1074,9 @@ describe('plugin-meetings', () => {
816
1074
  assert.calledOnceWithExactly(
817
1075
  meeting.addMediaInternal,
818
1076
  sinon.match.any,
819
- undefined,
820
1077
  false,
1078
+ undefined,
1079
+ undefined,
821
1080
  mediaOptions
822
1081
  );
823
1082
 
@@ -851,8 +1110,9 @@ describe('plugin-meetings', () => {
851
1110
  assert.calledOnceWithExactly(
852
1111
  meeting.addMediaInternal,
853
1112
  sinon.match.any,
854
- undefined,
855
1113
  false,
1114
+ undefined,
1115
+ undefined,
856
1116
  mediaOptions
857
1117
  );
858
1118
 
@@ -864,7 +1124,12 @@ describe('plugin-meetings', () => {
864
1124
  meeting.join = sinon.stub().returns(Promise.reject(error));
865
1125
  meeting.locusUrl = null; // when join fails, we end up with null locusUrl
866
1126
 
867
- await assert.isRejected(meeting.joinWithMedia({mediaOptions: {allowMediaInLobby: true}}));
1127
+ const thrownError = await assert.isRejected(
1128
+ meeting.joinWithMedia({mediaOptions: {allowMediaInLobby: true}})
1129
+ );
1130
+
1131
+ // should throw the first attempt's error
1132
+ assert.equal(thrownError, error);
868
1133
 
869
1134
  assert.calledTwice(abortTurnDiscoveryStub);
870
1135
 
@@ -902,11 +1167,158 @@ describe('plugin-meetings', () => {
902
1167
 
903
1168
  // resets joinWithMediaRetryInfo
904
1169
  assert.deepEqual(meeting.joinWithMediaRetryInfo, {
905
- isRetry: false,
1170
+ retryCount: 0,
1171
+ prevJoinResponse: undefined,
1172
+ firstError: undefined,
1173
+ prevError: undefined,
1174
+ });
1175
+
1176
+ // suspendDestroyMeeting(true) called at start of each attempt, (false) only on final failure
1177
+ // 1st attempt: suspendDestroyMeeting(true), 2nd attempt (retry): suspendDestroyMeeting(true), final failure: suspendDestroyMeeting(false)
1178
+ assert.calledThrice(suspendDestroyMeetingStub);
1179
+ assert.calledWith(suspendDestroyMeetingStub.firstCall, true);
1180
+ assert.calledWith(suspendDestroyMeetingStub.secondCall, true);
1181
+ assert.calledWith(suspendDestroyMeetingStub.thirdCall, false);
1182
+ });
1183
+
1184
+ it('should not retry if join() fails because the Locus user capacity is full', async () => {
1185
+ const error = new Error('Error Joining Meeting');
1186
+ error.error = {
1187
+ statusCode: 423,
1188
+ body: {errorCode: 2423001},
1189
+ };
1190
+ meeting.join = sinon.stub().rejects(error);
1191
+
1192
+ const thrownError = await assert.isRejected(
1193
+ meeting.joinWithMedia({joinOptions, mediaOptions})
1194
+ );
1195
+
1196
+ assert.equal(thrownError, error);
1197
+ assert.calledOnce(meeting.join);
1198
+ assert.calledOnce(generateTurnDiscoveryRequestMessageStub);
1199
+ assert.calledOnce(Metrics.sendBehavioralMetric);
1200
+ assert.calledTwice(suspendDestroyMeetingStub);
1201
+ assert.calledWith(suspendDestroyMeetingStub.firstCall, true);
1202
+ assert.calledWith(suspendDestroyMeetingStub.secondCall, false);
1203
+ });
1204
+
1205
+ it('should still retry if join() fails with another HTTP 423 Locus error', async () => {
1206
+ const error = new Error('Error Joining Meeting');
1207
+ error.error = {
1208
+ statusCode: 423,
1209
+ body: {errorCode: 2423028},
1210
+ };
1211
+ meeting.join = sinon.stub().rejects(error);
1212
+
1213
+ const thrownError = await assert.isRejected(
1214
+ meeting.joinWithMedia({joinOptions, mediaOptions})
1215
+ );
1216
+
1217
+ assert.equal(thrownError, error);
1218
+ assert.calledTwice(meeting.join);
1219
+ assert.calledTwice(generateTurnDiscoveryRequestMessageStub);
1220
+ assert.calledTwice(Metrics.sendBehavioralMetric);
1221
+ });
1222
+
1223
+ it('should throw the Locus user full error over firstError when the retry hits full capacity', async () => {
1224
+ const firstJoinError = new Error('first join error');
1225
+ const capacityError = new Error('Error Joining Meeting');
1226
+ capacityError.error = {
1227
+ statusCode: 423,
1228
+ body: {errorCode: 2423001},
1229
+ };
1230
+
1231
+ meeting.join = sinon
1232
+ .stub()
1233
+ .onFirstCall()
1234
+ .rejects(firstJoinError)
1235
+ .onSecondCall()
1236
+ .rejects(capacityError);
1237
+ meeting.locusUrl = null; // join never succeeds
1238
+
1239
+ const thrownError = await assert.isRejected(
1240
+ meeting.joinWithMedia({joinOptions, mediaOptions})
1241
+ );
1242
+
1243
+ // join() runs once for the first attempt and once for the re-join
1244
+ assert.calledTwice(meeting.join);
1245
+ // the capacity error must take precedence over the stored firstError
1246
+ assert.equal(thrownError, capacityError);
1247
+
1248
+ assert.deepEqual(meeting.joinWithMediaRetryInfo, {
1249
+ retryCount: 0,
906
1250
  prevJoinResponse: undefined,
1251
+ firstError: undefined,
1252
+ prevError: undefined,
907
1253
  });
908
1254
  });
909
1255
 
1256
+ it('should re-join on retry when join() fails on first attempt, and throw the first error if join fails again', async () => {
1257
+ const firstJoinError = new Error('first join error');
1258
+ const secondJoinError = new Error('second join error');
1259
+
1260
+ meeting.join = sinon
1261
+ .stub()
1262
+ .onFirstCall()
1263
+ .rejects(firstJoinError)
1264
+ .onSecondCall()
1265
+ .rejects(secondJoinError);
1266
+ meeting.locusUrl = null; // join never succeeds
1267
+
1268
+ const thrownError = await assert.isRejected(
1269
+ meeting.joinWithMedia({joinOptions, mediaOptions})
1270
+ );
1271
+
1272
+ // join() should be called twice — once for the first attempt, once for the re-join
1273
+ assert.calledTwice(meeting.join);
1274
+ // TURN discovery should be attempted twice (once per join)
1275
+ assert.calledTwice(generateTurnDiscoveryRequestMessageStub);
1276
+
1277
+ // should throw the first attempt's error, not the second
1278
+ assert.equal(thrownError, firstJoinError);
1279
+
1280
+ assert.calledTwice(Metrics.sendBehavioralMetric);
1281
+ assert.calledWith(
1282
+ Metrics.sendBehavioralMetric.firstCall,
1283
+ BEHAVIORAL_METRICS.JOIN_WITH_MEDIA_FAILURE,
1284
+ sinon.match({reason: firstJoinError.message, isRetry: false}),
1285
+ sinon.match.any
1286
+ );
1287
+ assert.calledWith(
1288
+ Metrics.sendBehavioralMetric.secondCall,
1289
+ BEHAVIORAL_METRICS.JOIN_WITH_MEDIA_FAILURE,
1290
+ sinon.match({reason: secondJoinError.message, isRetry: true}),
1291
+ sinon.match.any
1292
+ );
1293
+
1294
+ assert.deepEqual(meeting.joinWithMediaRetryInfo, {
1295
+ retryCount: 0,
1296
+ prevJoinResponse: undefined,
1297
+ firstError: undefined,
1298
+ prevError: undefined,
1299
+ });
1300
+ });
1301
+
1302
+ it('should NOT call join() again on retry when join() succeeded but addMediaInternal() failed', async () => {
1303
+ const addMediaError = new Error('addMedia error');
1304
+
1305
+ meeting.addMediaInternal = sinon
1306
+ .stub()
1307
+ .onFirstCall()
1308
+ .rejects(addMediaError)
1309
+ .onSecondCall()
1310
+ .resolves(test4);
1311
+
1312
+ const result = await meeting.joinWithMedia({joinOptions, mediaOptions});
1313
+
1314
+ assert.deepEqual(result, {join: fakeJoinResult, media: test4, multistreamEnabled: true});
1315
+
1316
+ // join() should only be called once — the successful join result is reused on retry
1317
+ assert.calledOnce(meeting.join);
1318
+ // TURN discovery request is only generated once (on the first attempt alongside join)
1319
+ assert.calledOnce(generateTurnDiscoveryRequestMessageStub);
1320
+ });
1321
+
910
1322
  it('should resolve if join() fails the first time but succeeds the second time', async () => {
911
1323
  const error = new Error('fake');
912
1324
  meeting.join = sinon
@@ -948,7 +1360,7 @@ describe('plugin-meetings', () => {
948
1360
 
949
1361
  // resets joinWithMediaRetryInfo
950
1362
  assert.deepEqual(meeting.joinWithMediaRetryInfo, {
951
- isRetry: false,
1363
+ retryCount: 0,
952
1364
  prevJoinResponse: undefined,
953
1365
  });
954
1366
  });
@@ -1017,6 +1429,127 @@ describe('plugin-meetings', () => {
1017
1429
  );
1018
1430
  });
1019
1431
 
1432
+ it('should throw the first attempt error when retry also fails with a different error', async () => {
1433
+ const firstError = new Error('first attempt error');
1434
+ const secondError = new Error('second attempt error');
1435
+
1436
+ const addMediaInternalResults = [];
1437
+ meeting.addMediaInternal = sinon.stub().callsFake(() => {
1438
+ const defer = new Defer();
1439
+ addMediaInternalResults.push(defer);
1440
+ return defer.promise;
1441
+ });
1442
+
1443
+ const leaveStub = sinon.stub(meeting, 'leave').resolves();
1444
+
1445
+ const result = meeting.joinWithMedia({joinOptions, mediaOptions});
1446
+
1447
+ await testUtils.flushPromises();
1448
+
1449
+ // 1st attempt fails
1450
+ addMediaInternalResults[0].reject(firstError);
1451
+ await testUtils.flushPromises();
1452
+
1453
+ // leave() should NOT be called after the 1st attempt (intermediate retry)
1454
+ assert.notCalled(leaveStub);
1455
+
1456
+ // 2nd (final) attempt fails
1457
+ addMediaInternalResults[1].reject(secondError);
1458
+ const thrownError = await assert.isRejected(result);
1459
+
1460
+ // should throw the first error, not the second
1461
+ assert.equal(thrownError, firstError);
1462
+
1463
+ // leave() should only be called after the last (2nd) attempt
1464
+ assert.calledOnce(leaveStub);
1465
+
1466
+ assert.calledTwice(Metrics.sendBehavioralMetric);
1467
+ });
1468
+
1469
+ it('should throw the UserNotJoinedError as firstError when it occurs on the 1st attempt and 2nd attempt fails differently', async () => {
1470
+ const userNotJoinedError = new UserNotJoinedError();
1471
+ const secondError = new Error('second attempt error');
1472
+
1473
+ const addMediaInternalResults = [];
1474
+ meeting.addMediaInternal = sinon.stub().callsFake(() => {
1475
+ const defer = new Defer();
1476
+ addMediaInternalResults.push(defer);
1477
+ return defer.promise;
1478
+ });
1479
+
1480
+ const leaveStub = sinon.stub(meeting, 'leave').resolves();
1481
+
1482
+ const result = meeting.joinWithMedia({joinOptions, mediaOptions});
1483
+
1484
+ await testUtils.flushPromises();
1485
+
1486
+ // 1st attempt fails with UserNotJoinedError — triggers a re-join
1487
+ addMediaInternalResults[0].reject(userNotJoinedError);
1488
+ await testUtils.flushPromises();
1489
+
1490
+ // leave() should NOT be called after the 1st attempt (intermediate retry)
1491
+ assert.notCalled(leaveStub);
1492
+
1493
+ // 2nd (final) attempt fails
1494
+ addMediaInternalResults[1].reject(secondError);
1495
+ const thrownError = await assert.isRejected(result);
1496
+
1497
+ // should throw the first (UserNotJoinedError), not the second
1498
+ assert.equal(thrownError, userNotJoinedError);
1499
+
1500
+ // join() called twice: original + re-join triggered by UserNotJoinedError in prevError
1501
+ assert.calledTwice(meeting.join);
1502
+ // leave() should only be called after the last (2nd) attempt
1503
+ assert.calledOnce(leaveStub);
1504
+ assert.calledTwice(Metrics.sendBehavioralMetric);
1505
+ });
1506
+
1507
+ it('should throw the first UserNotJoinedError when it occurs on both 1st and 2nd attempts and a 3rd attempt also fails', async () => {
1508
+ const firstUserNotJoinedError = new UserNotJoinedError('first');
1509
+ const secondUserNotJoinedError = new UserNotJoinedError('second');
1510
+ const thirdError = new Error('third attempt error');
1511
+
1512
+ const addMediaInternalResults = [];
1513
+ meeting.addMediaInternal = sinon.stub().callsFake(() => {
1514
+ const defer = new Defer();
1515
+ addMediaInternalResults.push(defer);
1516
+ return defer.promise;
1517
+ });
1518
+
1519
+ const leaveStub = sinon.stub(meeting, 'leave').resolves();
1520
+
1521
+ const result = meeting.joinWithMedia({joinOptions, mediaOptions});
1522
+
1523
+ await testUtils.flushPromises();
1524
+
1525
+ // 1st attempt fails with UserNotJoinedError — triggers a re-join
1526
+ addMediaInternalResults[0].reject(firstUserNotJoinedError);
1527
+ await testUtils.flushPromises();
1528
+
1529
+ // leave() should NOT be called after the 1st attempt (intermediate retry)
1530
+ assert.notCalled(leaveStub);
1531
+
1532
+ // 2nd attempt fails with UserNotJoinedError again — triggers another re-join
1533
+ addMediaInternalResults[1].reject(secondUserNotJoinedError);
1534
+ await testUtils.flushPromises();
1535
+
1536
+ // leave() should NOT be called after the 2nd attempt (intermediate retry)
1537
+ assert.notCalled(leaveStub);
1538
+
1539
+ // 3rd (final) attempt fails
1540
+ addMediaInternalResults[2].reject(thirdError);
1541
+ const thrownError = await assert.isRejected(result);
1542
+
1543
+ // should throw the very first error across all 3 attempts
1544
+ assert.equal(thrownError, firstUserNotJoinedError);
1545
+
1546
+ // join() called 3 times: original + 2 re-joins triggered by prevError being UserNotJoinedError
1547
+ assert.calledThrice(meeting.join);
1548
+ // leave() should only be called after the last (3rd) attempt
1549
+ assert.calledOnce(leaveStub);
1550
+ assert.calledThrice(Metrics.sendBehavioralMetric);
1551
+ });
1552
+
1020
1553
  it('should call leave() if addMediaInternal() fails with a browser media error (TypeError)', async () => {
1021
1554
  const addMediaError = new Error('fake addMedia error');
1022
1555
  addMediaError.name = 'TypeError'; // This makes it a browser media error
@@ -1212,8 +1745,9 @@ describe('plugin-meetings', () => {
1212
1745
  assert.calledWith(
1213
1746
  meeting.addMediaInternal.firstCall,
1214
1747
  sinon.match.any,
1215
- fakeTurnServerInfo,
1216
1748
  false,
1749
+ fakeTurnServerInfo,
1750
+ undefined,
1217
1751
  mediaOptions
1218
1752
  );
1219
1753
 
@@ -1221,8 +1755,9 @@ describe('plugin-meetings', () => {
1221
1755
  assert.calledWith(
1222
1756
  meeting.addMediaInternal.secondCall,
1223
1757
  sinon.match.any,
1224
- undefined,
1225
1758
  true,
1759
+ undefined,
1760
+ undefined,
1226
1761
  mediaOptions
1227
1762
  );
1228
1763
 
@@ -1240,7 +1775,7 @@ describe('plugin-meetings', () => {
1240
1775
 
1241
1776
  meeting.addMediaInternal = sinon
1242
1777
  .stub()
1243
- .callsFake((icePhaseCallback, _turnServerInfo, _forceTurnDiscovery) => {
1778
+ .callsFake((icePhaseCallback, _forceTurnDiscovery, _turnServerInfo) => {
1244
1779
  const defer = new Defer();
1245
1780
 
1246
1781
  icePhaseCallbacks.push(icePhaseCallback);
@@ -1262,16 +1797,127 @@ describe('plugin-meetings', () => {
1262
1797
  // now trigger the failure, so that joinWithMedia() does a retry
1263
1798
  addMediaInternalResults[0].reject(addMediaError);
1264
1799
 
1265
- await testUtils.flushPromises();
1800
+ await testUtils.flushPromises();
1801
+
1802
+ // check the callback works correctly on the 2nd attempt:
1803
+ // retryCount=1 with a non-UserNotJoinedError is terminal, so icePhase must be JOIN_MEETING_FINAL
1804
+ assert.equal(icePhaseCallbacks.length, 2);
1805
+ assert.equal(icePhaseCallbacks[1](), 'JOIN_MEETING_FINAL');
1806
+
1807
+ // trigger 2nd failure
1808
+ addMediaInternalResults[1].reject(addMediaError);
1809
+
1810
+ await assert.isRejected(result);
1811
+ });
1812
+
1813
+ it('should allow an additional retry when UserNotJoinedError occurs and return JOIN_MEETING_FINAL on the 3rd attempt', async () => {
1814
+ const genericError = new Error('generic error');
1815
+ const userNotJoinedError = new UserNotJoinedError();
1816
+ const thirdError = new Error('third error');
1817
+
1818
+ const icePhaseCallbacks = [];
1819
+ const addMediaInternalResults = [];
1820
+
1821
+ meeting.addMediaInternal = sinon.stub().callsFake((icePhaseCallback) => {
1822
+ const defer = new Defer();
1823
+
1824
+ icePhaseCallbacks.push(icePhaseCallback);
1825
+ addMediaInternalResults.push(defer);
1826
+ return defer.promise;
1827
+ });
1828
+
1829
+ const leaveStub = sinon.stub(meeting, 'leave').resolves();
1830
+
1831
+ const result = meeting.joinWithMedia({
1832
+ joinOptions,
1833
+ mediaOptions,
1834
+ });
1835
+
1836
+ await testUtils.flushPromises();
1837
+
1838
+ // 1st attempt: retryCount=0 → JOIN_MEETING_RETRY
1839
+ assert.equal(icePhaseCallbacks.length, 1);
1840
+ assert.equal(icePhaseCallbacks[0](), 'JOIN_MEETING_RETRY');
1841
+ addMediaInternalResults[0].reject(genericError);
1842
+
1843
+ await testUtils.flushPromises();
1844
+
1845
+ // leave() should NOT be called after the 1st attempt (intermediate retry)
1846
+ assert.notCalled(leaveStub);
1847
+
1848
+ // 2nd attempt: retryCount=1 → JOIN_MEETING_FINAL
1849
+ // (In real usage this callback is never invoked when UserNotJoinedError is thrown,
1850
+ // because UserNotJoinedError is thrown before waitForMediaConnectionConnected() is reached.)
1851
+ assert.equal(icePhaseCallbacks.length, 2);
1852
+ assert.equal(icePhaseCallbacks[1](), 'JOIN_MEETING_FINAL');
1853
+ addMediaInternalResults[1].reject(userNotJoinedError);
1854
+
1855
+ await testUtils.flushPromises();
1856
+
1857
+ // leave() should NOT be called after the 2nd attempt (intermediate retry)
1858
+ assert.notCalled(leaveStub);
1859
+
1860
+ // 3rd attempt: retryCount=2 → JOIN_MEETING_FINAL
1861
+ assert.equal(icePhaseCallbacks.length, 3);
1862
+ assert.equal(icePhaseCallbacks[2](), 'JOIN_MEETING_FINAL');
1863
+ addMediaInternalResults[2].reject(thirdError);
1864
+
1865
+ const thrownError = await assert.isRejected(result);
1866
+
1867
+ // should throw the first error
1868
+ assert.equal(thrownError, genericError);
1869
+
1870
+ // leave() should only be called once, after the last (3rd) attempt
1871
+ assert.calledOnce(leaveStub);
1872
+ });
1873
+
1874
+ it('should re-join when retrying after a UserNotJoinedError', async () => {
1875
+ const userNotJoinedError = new UserNotJoinedError();
1876
+
1877
+ const leaveStub = sinon.stub(meeting, 'leave').resolves();
1878
+
1879
+ meeting.addMediaInternal = sinon
1880
+ .stub()
1881
+ .onFirstCall()
1882
+ .rejects(userNotJoinedError)
1883
+ .onSecondCall()
1884
+ .resolves(test4);
1885
+
1886
+ const result = await meeting.joinWithMedia({joinOptions, mediaOptions});
1887
+
1888
+ assert.deepEqual(result, {join: fakeJoinResult, media: test4, multistreamEnabled: true});
1889
+
1890
+ // join() should be called twice — once for the first attempt, once for the re-join after UserNotJoinedError
1891
+ assert.calledTwice(meeting.join);
1892
+ // TURN discovery should be attempted twice (once per join)
1893
+ assert.calledTwice(generateTurnDiscoveryRequestMessageStub);
1894
+ // leave() should never be called when retrying after UserNotJoinedError
1895
+ assert.notCalled(leaveStub);
1896
+ });
1897
+
1898
+ it('should re-join when isUserInLeftState returns true on retry', async () => {
1899
+ const addMediaError = new Error('addMedia error');
1900
+
1901
+ sinon.stub(MeetingUtil, 'isUserInLeftState').returns(true);
1902
+
1903
+ const leaveStub = sinon.stub(meeting, 'leave').resolves();
1904
+
1905
+ meeting.addMediaInternal = sinon
1906
+ .stub()
1907
+ .onFirstCall()
1908
+ .rejects(addMediaError)
1909
+ .onSecondCall()
1910
+ .resolves(test4);
1266
1911
 
1267
- // check the callback works correctly on the 2nd attempt
1268
- assert.equal(icePhaseCallbacks.length, 2);
1269
- assert.equal(icePhaseCallbacks[1](), 'JOIN_MEETING_FINAL');
1912
+ const result = await meeting.joinWithMedia({joinOptions, mediaOptions});
1270
1913
 
1271
- // trigger 2nd failure
1272
- addMediaInternalResults[1].reject(addMediaError);
1914
+ assert.deepEqual(result, {join: fakeJoinResult, media: test4, multistreamEnabled: true});
1273
1915
 
1274
- await assert.isRejected(result);
1916
+ // join() should be called twice — once for the first attempt, once because the user is in left state
1917
+ assert.calledTwice(meeting.join);
1918
+ assert.calledTwice(generateTurnDiscoveryRequestMessageStub);
1919
+ // leave() should never be called when retrying after isUserInLeftState returns true
1920
+ assert.notCalled(leaveStub);
1275
1921
  });
1276
1922
 
1277
1923
  [
@@ -1341,6 +1987,7 @@ describe('plugin-meetings', () => {
1341
1987
  sinon.match.any,
1342
1988
  sinon.match.any,
1343
1989
  sinon.match.any,
1990
+ sinon.match.any,
1344
1991
  sinon.match.has('videoEnabled', false).and(sinon.match.has('allowMediaInLobby', true))
1345
1992
  );
1346
1993
  });
@@ -1361,6 +2008,7 @@ describe('plugin-meetings', () => {
1361
2008
  sinon.match.any,
1362
2009
  sinon.match.any,
1363
2010
  sinon.match.any,
2011
+ sinon.match.any,
1364
2012
  sinon.match.has('audioEnabled', false).and(sinon.match.has('allowMediaInLobby', true))
1365
2013
  );
1366
2014
  });
@@ -1382,6 +2030,7 @@ describe('plugin-meetings', () => {
1382
2030
  sinon.match.any,
1383
2031
  sinon.match.any,
1384
2032
  sinon.match.any,
2033
+ sinon.match.any,
1385
2034
  sinon.match({
1386
2035
  sendVideo: true,
1387
2036
  receiveVideo: false,
@@ -1391,6 +2040,101 @@ describe('plugin-meetings', () => {
1391
2040
  );
1392
2041
  });
1393
2042
 
2043
+ describe('shouldRetryMediaWithOnlyTurnTLS', () => {
2044
+ it('should pass iceTransportPolicy=relay for multistream when previous error is DTLS failure over UDP and TLS is reachable', async () => {
2045
+ meeting.isMultistream = true;
2046
+ const dtlsError = new AddMediaFailed({iceConnected: true, connectionType: 'UDP'});
2047
+
2048
+ webex.meetings.reachability.isAnyClusterReachableViaProtocol = sinon
2049
+ .stub()
2050
+ .resolves(true);
2051
+
2052
+ addMediaInternalStub.onFirstCall().rejects(dtlsError);
2053
+ addMediaInternalStub.onSecondCall().resolves(test4);
2054
+
2055
+ await meeting.joinWithMedia({joinOptions, mediaOptions});
2056
+
2057
+ assert.calledWith(
2058
+ meeting.addMediaInternal.secondCall,
2059
+ sinon.match.any,
2060
+ sinon.match.any,
2061
+ sinon.match.any,
2062
+ 'relay',
2063
+ mediaOptions
2064
+ );
2065
+ });
2066
+
2067
+ [
2068
+ {
2069
+ title: 'TLS is not reachable',
2070
+ prevError: new AddMediaFailed({iceConnected: true, connectionType: 'UDP'}),
2071
+ tlsReachable: false,
2072
+ isMultistream: true,
2073
+ },
2074
+ {
2075
+ title: 'error is not AddMediaFailed',
2076
+ prevError: new Error('generic error'),
2077
+ tlsReachable: true,
2078
+ isMultistream: true,
2079
+ },
2080
+ {
2081
+ title: 'error is AddMediaFailed but not DTLS failure',
2082
+ prevError: new AddMediaFailed({iceConnected: false, connectionType: 'UDP'}),
2083
+ tlsReachable: true,
2084
+ isMultistream: true,
2085
+ },
2086
+ {
2087
+ title: 'error is DTLS failure but connectionType is not UDP',
2088
+ prevError: new AddMediaFailed({iceConnected: true, connectionType: 'TURN-TLS'}),
2089
+ tlsReachable: true,
2090
+ isMultistream: true,
2091
+ },
2092
+ {
2093
+ title: 'isMultistream is false',
2094
+ prevError: new AddMediaFailed({iceConnected: true, connectionType: 'UDP'}),
2095
+ tlsReachable: true,
2096
+ isMultistream: false,
2097
+ },
2098
+ ].forEach(({title, prevError, tlsReachable, isMultistream}) => {
2099
+ it(`should pass iceTransportPolicy=undefined when ${title}`, async () => {
2100
+ meeting.join = sinon.stub().callsFake(() => {
2101
+ meeting.isMultistream = isMultistream;
2102
+ return Promise.resolve(fakeJoinResult);
2103
+ });
2104
+ webex.meetings.reachability.isAnyClusterReachableViaProtocol = sinon
2105
+ .stub()
2106
+ .resolves(tlsReachable);
2107
+
2108
+ addMediaInternalStub.onFirstCall().rejects(prevError);
2109
+ addMediaInternalStub.onSecondCall().resolves(test4);
2110
+
2111
+ await meeting.joinWithMedia({joinOptions, mediaOptions});
2112
+
2113
+ assert.calledWith(
2114
+ meeting.addMediaInternal.secondCall,
2115
+ sinon.match.any,
2116
+ sinon.match.any,
2117
+ sinon.match.any,
2118
+ undefined,
2119
+ mediaOptions
2120
+ );
2121
+ });
2122
+ });
2123
+
2124
+ it('should pass iceTransportPolicy=undefined on first attempt (no prevError)', async () => {
2125
+ await meeting.joinWithMedia({joinOptions, mediaOptions});
2126
+
2127
+ assert.calledWith(
2128
+ meeting.addMediaInternal.firstCall,
2129
+ sinon.match.any,
2130
+ sinon.match.any,
2131
+ sinon.match.any,
2132
+ undefined,
2133
+ mediaOptions
2134
+ );
2135
+ });
2136
+ });
2137
+
1394
2138
  it('should throw immediately if RTCPeerConnection is not available', async () => {
1395
2139
  supportsRTCPeerConnectionStub.returns(CapabilityState.NOT_CAPABLE);
1396
2140
 
@@ -1402,9 +2146,97 @@ describe('plugin-meetings', () => {
1402
2146
  Errors.WebrtcApiNotAvailableError
1403
2147
  );
1404
2148
 
2149
+ assert.notCalled(suspendDestroyMeetingStub);
1405
2150
  assert.notCalled(meeting.join);
1406
2151
  assert.notCalled(meeting.addMediaInternal);
1407
2152
  });
2153
+
2154
+ [
2155
+ {description: '409 error from join()', statusCode: 409, useCause: false},
2156
+ {description: '403 error from join()', statusCode: 403, useCause: false},
2157
+ {
2158
+ description: '409 error in cause (e.g. AddMediaFailed)',
2159
+ statusCode: 409,
2160
+ useCause: true,
2161
+ },
2162
+ {
2163
+ description: '403 error in cause (e.g. AddMediaFailed)',
2164
+ statusCode: 403,
2165
+ useCause: true,
2166
+ },
2167
+ ].forEach(({description, statusCode, useCause}) => {
2168
+ it(`should re-join on retry when ${description}`, async () => {
2169
+ const error = useCause
2170
+ ? Object.assign(new Error('wrapped error'), {cause: {statusCode}})
2171
+ : Object.assign(new Error('locus error'), {statusCode});
2172
+
2173
+ meeting.addMediaInternal = sinon
2174
+ .stub()
2175
+ .onFirstCall()
2176
+ .rejects(error)
2177
+ .onSecondCall()
2178
+ .resolves(test4);
2179
+
2180
+ const result = await meeting.joinWithMedia({joinOptions, mediaOptions});
2181
+
2182
+ assert.deepEqual(result, {
2183
+ join: fakeJoinResult,
2184
+ media: test4,
2185
+ multistreamEnabled: true,
2186
+ });
2187
+
2188
+ // join() should be called twice — once for the first attempt, once for the re-join
2189
+ assert.calledTwice(meeting.join);
2190
+ assert.calledTwice(generateTurnDiscoveryRequestMessageStub);
2191
+ });
2192
+ });
2193
+
2194
+ it('should allow up to JOIN_WITH_MEDIA_RETRY_MAX_COUNT retries for 409 errors', async () => {
2195
+ const error409 = Object.assign(new Error('locus dropped us'), {statusCode: 409});
2196
+
2197
+ meeting.addMediaInternal = sinon.stub().rejects(error409);
2198
+ meeting.join = sinon.stub().callsFake(() => Promise.resolve(fakeJoinResult));
2199
+ sinon.stub(meeting, 'leave').resolves();
2200
+
2201
+ await assert.isRejected(meeting.joinWithMedia({joinOptions, mediaOptions}));
2202
+
2203
+ // JOIN_WITH_MEDIA_RETRY_MAX_COUNT is 2, so we expect 3 attempts total (initial + 2 retries)
2204
+ assert.callCount(meeting.join, 3);
2205
+ assert.callCount(meeting.addMediaInternal, 3);
2206
+ });
2207
+
2208
+ it('should not retry on 1-1 calls', async () => {
2209
+ const addMediaError = new Error('addMedia error');
2210
+
2211
+ sinon.stub(MeetingsUtil, 'isOneOnOneCall').returns(true);
2212
+
2213
+ meeting.addMediaInternal = sinon.stub().rejects(addMediaError);
2214
+ sinon.stub(meeting, 'leave').resolves();
2215
+
2216
+ await assert.isRejected(
2217
+ meeting.joinWithMedia({joinOptions, mediaOptions}),
2218
+ addMediaError
2219
+ );
2220
+
2221
+ // should not retry - only 1 attempt
2222
+ assert.calledOnce(meeting.join);
2223
+ assert.calledOnce(meeting.addMediaInternal);
2224
+ assert.calledOnceWithExactly(
2225
+ Metrics.sendBehavioralMetric,
2226
+ BEHAVIORAL_METRICS.JOIN_WITH_MEDIA_FAILURE,
2227
+ {
2228
+ correlation_id: meeting.correlationId,
2229
+ locus_id: meeting.locusUrl.split('/').pop(),
2230
+ reason: addMediaError.message,
2231
+ stack: addMediaError.stack,
2232
+ leaveErrorReason: undefined,
2233
+ isRetry: false,
2234
+ },
2235
+ {
2236
+ type: addMediaError.name,
2237
+ }
2238
+ );
2239
+ });
1408
2240
  });
1409
2241
  describe('#isTranscriptionSupported', () => {
1410
2242
  it('should return false if the feature is not supported for the meeting', () => {
@@ -1977,12 +2809,120 @@ describe('plugin-meetings', () => {
1977
2809
  fakeProcessedReaction
1978
2810
  );
1979
2811
  });
2812
+
2813
+ [
2814
+ {
2815
+ title:
2816
+ 'should skip a reaction when the default relay route does not match the LLM binding',
2817
+ isPracticeSessionConnected: false,
2818
+ route: 'wrong-default-route',
2819
+ defaultBinding: 'default-route',
2820
+ practiceBinding: 'practice-route',
2821
+ shouldProcess: false,
2822
+ expectedSessionLabel: 'default session',
2823
+ },
2824
+ {
2825
+ title: 'should process a reaction when the default relay route matches the LLM binding',
2826
+ isPracticeSessionConnected: false,
2827
+ route: 'default-route',
2828
+ defaultBinding: 'default-route',
2829
+ practiceBinding: 'practice-route',
2830
+ shouldProcess: true,
2831
+ },
2832
+ {
2833
+ title:
2834
+ 'should process a reaction when the practice-session relay route matches the practice-session LLM binding',
2835
+ isPracticeSessionConnected: true,
2836
+ route: 'practice-route',
2837
+ defaultBinding: 'default-route',
2838
+ practiceBinding: 'practice-route',
2839
+ shouldProcess: true,
2840
+ },
2841
+ {
2842
+ title:
2843
+ 'should skip a reaction when the practice-session relay route does not match the practice-session LLM binding',
2844
+ isPracticeSessionConnected: true,
2845
+ route: 'default-route',
2846
+ defaultBinding: 'default-route',
2847
+ practiceBinding: 'practice-route',
2848
+ shouldProcess: false,
2849
+ expectedSessionLabel: 'practice session',
2850
+ },
2851
+ ].forEach(
2852
+ ({
2853
+ title,
2854
+ isPracticeSessionConnected,
2855
+ route,
2856
+ defaultBinding,
2857
+ practiceBinding,
2858
+ shouldProcess,
2859
+ expectedSessionLabel,
2860
+ }) => {
2861
+ it(title, () => {
2862
+ meeting.isReactionsSupported = sinon.stub().returns(true);
2863
+ meeting.config.receiveReactions = true;
2864
+ const fakeSendersName = 'Fake reactors name';
2865
+ meeting.members.membersCollection.get = sinon.stub().returns({name: fakeSendersName});
2866
+ webex.internal.llm.isConnected = sinon.stub().callsFake((llmSessionId) => {
2867
+ return llmSessionId === LLM_PRACTICE_SESSION && isPracticeSessionConnected;
2868
+ });
2869
+ webex.internal.llm.getBinding = sinon.stub().callsFake((llmSessionId) => {
2870
+ if (llmSessionId === LLM_PRACTICE_SESSION) {
2871
+ return practiceBinding;
2872
+ }
2873
+
2874
+ return defaultBinding;
2875
+ });
2876
+ const fakeReactionPayload = {
2877
+ type: 'fake_type',
2878
+ codepoints: 'fake_codepoints',
2879
+ shortcodes: 'fake_shortcodes',
2880
+ };
2881
+ const fakeSenderPayload = {
2882
+ participantId: 'fake_participant_id',
2883
+ };
2884
+ const fakeRelayEvent = {
2885
+ headers: {route},
2886
+ data: {
2887
+ relayType: REACTION_RELAY_TYPES.REACTION,
2888
+ reaction: fakeReactionPayload,
2889
+ sender: fakeSenderPayload,
2890
+ },
2891
+ };
2892
+ const fakeProcessedReaction = {
2893
+ reaction: fakeReactionPayload,
2894
+ sender: {
2895
+ id: fakeSenderPayload.participantId,
2896
+ name: fakeSendersName,
2897
+ },
2898
+ };
2899
+
2900
+ TriggerProxy.trigger.resetHistory();
2901
+ meeting.processRelayEvent(fakeRelayEvent);
2902
+
2903
+ if (shouldProcess) {
2904
+ assert.calledWith(
2905
+ TriggerProxy.trigger,
2906
+ sinon.match.instanceOf(Meeting),
2907
+ {
2908
+ file: 'meeting/index',
2909
+ function: 'join',
2910
+ },
2911
+ EVENT_TRIGGERS.MEETING_RECEIVE_REACTIONS,
2912
+ fakeProcessedReaction
2913
+ );
2914
+ } else {
2915
+ assert.notCalled(TriggerProxy.trigger);
2916
+ }
2917
+ });
2918
+ }
2919
+ );
1980
2920
  });
1981
2921
 
1982
2922
  describe('#handleLLMOnline', () => {
1983
2923
  beforeEach(() => {
1984
2924
  webex.internal.llm.off = sinon.stub();
1985
- webex.internal.voicea.getIsCaptionBoxOn = sinon.stub().returns(false);
2925
+ webex.internal.voicea.getKeepTranscriptionSubscribed = sinon.stub().returns(false);
1986
2926
  webex.internal.voicea.updateSubchannelSubscriptions = sinon.stub();
1987
2927
  });
1988
2928
 
@@ -2000,7 +2940,7 @@ describe('plugin-meetings', () => {
2000
2940
  });
2001
2941
 
2002
2942
  it('restores transcription subscription when caption intent is enabled', () => {
2003
- webex.internal.voicea.getIsCaptionBoxOn.returns(true);
2943
+ webex.internal.voicea.getKeepTranscriptionSubscribed.returns(true);
2004
2944
 
2005
2945
  meeting.handleLLMOnline();
2006
2946
 
@@ -2010,12 +2950,20 @@ describe('plugin-meetings', () => {
2010
2950
  });
2011
2951
 
2012
2952
  it('does not restore transcription subscription when caption intent is disabled', () => {
2013
- webex.internal.voicea.getIsCaptionBoxOn.returns(false);
2953
+ webex.internal.voicea.getKeepTranscriptionSubscribed.returns(false);
2014
2954
 
2015
2955
  meeting.handleLLMOnline();
2016
2956
 
2017
2957
  assert.notCalled(webex.internal.voicea.updateSubchannelSubscriptions);
2018
2958
  });
2959
+
2960
+ it('calls syncAllHashTreeDatasets on locusInfo', () => {
2961
+ sinon.stub(meeting.locusInfo, 'syncAllHashTreeDatasets').resolves();
2962
+
2963
+ meeting.handleLLMOnline();
2964
+
2965
+ assert.calledOnceWithExactly(meeting.locusInfo.syncAllHashTreeDatasets, {onlyLLM: true});
2966
+ });
2019
2967
  });
2020
2968
 
2021
2969
  describe('#join', () => {
@@ -2096,6 +3044,8 @@ describe('plugin-meetings', () => {
2096
3044
  regionCode: 'EU',
2097
3045
  },
2098
3046
  preferTranscoding: !enableMultistream,
3047
+ getCurrentSelfUrl: sinon.match.func,
3048
+ waitForSelfUrlChange: sinon.match.func,
2099
3049
  },
2100
3050
  {
2101
3051
  parent: meeting.webex,
@@ -2340,6 +3290,221 @@ describe('plugin-meetings', () => {
2340
3290
  );
2341
3291
  });
2342
3292
 
3293
+ it('emits breakout join response metric only once per breakoutMoveId', async () => {
3294
+ sinon.stub(meeting, 'isJoined').returns(true);
3295
+ sinon.stub(meeting.webex.internal.llm, 'isConnected').returns(false);
3296
+ sinon.stub(meeting.webex.internal.llm, 'registerAndConnect').resolves({
3297
+ clientLLMDatachannelResponseTime: 10,
3298
+ clientLLMWebSocketConnectTime: 20,
3299
+ });
3300
+
3301
+ meeting.meetingInfo.enableConvergedArchitecture = true;
3302
+ meeting.breakouts.set('breakoutMoveId', 'move-id-1');
3303
+ meeting.breakouts.set('sessionType', 'BREAKOUT');
3304
+ meeting.breakouts.set('status', 'OPEN');
3305
+ meeting.breakouts.set('currentBreakoutSession', {
3306
+ sessionId: 'session-id-1',
3307
+ groupId: 'group-id-1',
3308
+ });
3309
+
3310
+ webex.internal.newMetrics.submitClientEvent.resetHistory();
3311
+ meeting.updateLLMConnection.restore();
3312
+
3313
+ await meeting.updateLLMConnection();
3314
+ await meeting.updateLLMConnection();
3315
+
3316
+ const joinResponseCalls = webex.internal.newMetrics.submitClientEvent
3317
+ .getCalls()
3318
+ .filter((call) => call.args[0]?.name === 'client.breakout-session.join.response');
3319
+
3320
+ assert.lengthOf(joinResponseCalls, 1);
3321
+ assert.equal(joinResponseCalls[0].args[0].options.meetingId, meeting.id);
3322
+ });
3323
+
3324
+ it('does not emit breakout join response metric when breakout session is missing', async () => {
3325
+ sinon.stub(meeting, 'isJoined').returns(true);
3326
+ sinon.stub(meeting.webex.internal.llm, 'isConnected').returns(false);
3327
+ sinon.stub(meeting.webex.internal.llm, 'registerAndConnect').resolves({
3328
+ clientLLMDatachannelResponseTime: 10,
3329
+ clientLLMWebSocketConnectTime: 20,
3330
+ });
3331
+
3332
+ meeting.meetingInfo.enableConvergedArchitecture = true;
3333
+ meeting.breakouts.set('breakoutMoveId', 'move-id-1');
3334
+
3335
+ webex.internal.newMetrics.submitClientEvent.resetHistory();
3336
+ meeting.updateLLMConnection.restore();
3337
+
3338
+ await meeting.updateLLMConnection();
3339
+
3340
+ const joinResponseCalls = webex.internal.newMetrics.submitClientEvent
3341
+ .getCalls()
3342
+ .filter((call) => call.args[0]?.name === 'client.breakout-session.join.response');
3343
+
3344
+ assert.lengthOf(joinResponseCalls, 0);
3345
+ });
3346
+
3347
+ it('does not emit failed breakout join response metric when breakout session is missing', async () => {
3348
+ sinon.stub(meeting, 'isJoined').returns(true);
3349
+ sinon.stub(meeting.webex.internal.llm, 'isConnected').returns(false);
3350
+ sinon
3351
+ .stub(meeting.webex.internal.llm, 'registerAndConnect')
3352
+ .rejects(new Error('failed to connect LLM'));
3353
+
3354
+ meeting.meetingInfo.enableConvergedArchitecture = true;
3355
+ meeting.breakouts.set('breakoutMoveId', 'move-id-1');
3356
+
3357
+ webex.internal.newMetrics.submitClientEvent.resetHistory();
3358
+ meeting.updateLLMConnection.restore();
3359
+
3360
+ try {
3361
+ await meeting.updateLLMConnection();
3362
+ assert.fail('Expected updateLLMConnection to reject');
3363
+ } catch (error) {
3364
+ assert.equal(error.message, 'failed to connect LLM');
3365
+ }
3366
+
3367
+ const joinResponseCalls = webex.internal.newMetrics.submitClientEvent
3368
+ .getCalls()
3369
+ .filter((call) => call.args[0]?.name === 'client.breakout-session.join.response');
3370
+
3371
+ assert.lengthOf(joinResponseCalls, 0);
3372
+ });
3373
+
3374
+ it('emits llm breakout join response metric after suppressing join response without llmLatency', async () => {
3375
+ sinon.stub(meeting, 'isJoined').returns(true);
3376
+ sinon.stub(meeting.webex.internal.llm, 'isConnected').returns(false);
3377
+ sinon.stub(meeting.webex.internal.llm, 'registerAndConnect').resolves({
3378
+ clientLLMDatachannelResponseTime: 10,
3379
+ clientLLMWebSocketConnectTime: 20,
3380
+ });
3381
+
3382
+ meeting.config.enableAutomaticLLM = true;
3383
+ meeting.meetingInfo.enableConvergedArchitecture = true;
3384
+ meeting.breakouts.set('breakoutMoveId', 'move-id-1');
3385
+ meeting.breakouts.set('sessionType', 'BREAKOUT');
3386
+ meeting.breakouts.set('status', 'OPEN');
3387
+ meeting.breakouts.set('currentBreakoutSession', {
3388
+ sessionId: 'session-id-1',
3389
+ groupId: 'group-id-1',
3390
+ });
3391
+
3392
+ assert.isFalse(meeting.shouldEmitBreakoutJoinResponseMetric('move-id-1'));
3393
+
3394
+ webex.internal.newMetrics.submitClientEvent.resetHistory();
3395
+ meeting.updateLLMConnection.restore();
3396
+
3397
+ await meeting.updateLLMConnection();
3398
+
3399
+ const joinResponseCalls = webex.internal.newMetrics.submitClientEvent
3400
+ .getCalls()
3401
+ .filter((call) => call.args[0]?.name === 'client.breakout-session.join.response');
3402
+
3403
+ assert.lengthOf(joinResponseCalls, 1);
3404
+ assert.deepEqual(joinResponseCalls[0].args[0].payload.llmLatency, {
3405
+ clientLLMDatachannelResponseTime: 10,
3406
+ clientLLMWebSocketConnectTime: 20,
3407
+ });
3408
+ });
3409
+
3410
+ it('emits breakout join response metric with llmLatency when returning to main session', async () => {
3411
+ sinon.stub(meeting, 'isJoined').returns(true);
3412
+ sinon.stub(meeting.webex.internal.llm, 'isConnected').returns(false);
3413
+ sinon.stub(meeting.webex.internal.llm, 'registerAndConnect').resolves({
3414
+ clientLLMDatachannelResponseTime: 10,
3415
+ clientLLMWebSocketConnectTime: 20,
3416
+ });
3417
+
3418
+ meeting.meetingInfo.enableConvergedArchitecture = true;
3419
+ meeting.breakouts.set('breakoutMoveId', 'move-id-1');
3420
+ meeting.breakouts.set('sessionType', 'MAIN');
3421
+ meeting.breakouts.set('status', 'OPEN');
3422
+ meeting.breakouts.set('currentBreakoutSession', {
3423
+ sessionId: 'session-id-1',
3424
+ groupId: 'group-id-1',
3425
+ });
3426
+
3427
+ webex.internal.newMetrics.submitClientEvent.resetHistory();
3428
+ meeting.updateLLMConnection.restore();
3429
+
3430
+ await meeting.updateLLMConnection();
3431
+
3432
+ const joinResponseCalls = webex.internal.newMetrics.submitClientEvent
3433
+ .getCalls()
3434
+ .filter((call) => call.args[0]?.name === 'client.breakout-session.join.response');
3435
+
3436
+ assert.lengthOf(joinResponseCalls, 1);
3437
+ assert.deepEqual(joinResponseCalls[0].args[0].payload.llmLatency, {
3438
+ clientLLMDatachannelResponseTime: 10,
3439
+ clientLLMWebSocketConnectTime: 20,
3440
+ });
3441
+ });
3442
+
3443
+ it('uses the partial datachannel timing from the error when the websocket connect fails', async () => {
3444
+ sinon.stub(meeting, 'isJoined').returns(true);
3445
+ sinon.stub(meeting.webex.internal.llm, 'isConnected').returns(false);
3446
+ const connectError = new Error('failed to connect LLM');
3447
+ connectError.timing = {clientLLMDatachannelResponseTime: 42};
3448
+ sinon.stub(meeting.webex.internal.llm, 'registerAndConnect').rejects(connectError);
3449
+
3450
+ meeting.meetingInfo.enableConvergedArchitecture = true;
3451
+ meeting.breakouts.set('breakoutMoveId', 'move-id-1');
3452
+ meeting.breakouts.set('sessionType', 'BREAKOUT');
3453
+ meeting.breakouts.set('status', 'OPEN');
3454
+ meeting.breakouts.set('currentBreakoutSession', {
3455
+ sessionId: 'session-id-1',
3456
+ groupId: 'group-id-1',
3457
+ });
3458
+
3459
+ webex.internal.newMetrics.submitClientEvent.resetHistory();
3460
+ meeting.updateLLMConnection.restore();
3461
+
3462
+ try {
3463
+ await meeting.updateLLMConnection();
3464
+ assert.fail('Expected updateLLMConnection to reject');
3465
+ } catch (error) {
3466
+ assert.equal(error, connectError);
3467
+ }
3468
+
3469
+ const joinResponseCalls = webex.internal.newMetrics.submitClientEvent
3470
+ .getCalls()
3471
+ .filter((call) => call.args[0]?.name === 'client.breakout-session.join.response');
3472
+
3473
+ assert.lengthOf(joinResponseCalls, 1);
3474
+ assert.deepEqual(joinResponseCalls[0].args[0].payload.llmLatency, {
3475
+ clientLLMDatachannelResponseTime: 42,
3476
+ clientLLMWebSocketConnectTime: 0,
3477
+ });
3478
+ });
3479
+
3480
+ it('reports the partial datachannel timing on client.llm.connect.response when the websocket connect fails during initial join', async () => {
3481
+ sinon.stub(meeting, 'isJoined').returns(true);
3482
+ sinon.stub(meeting.webex.internal.llm, 'isConnected').returns(false);
3483
+ const connectError = new Error('failed to connect LLM');
3484
+ connectError.timing = {clientLLMDatachannelResponseTime: 42};
3485
+ sinon.stub(meeting.webex.internal.llm, 'registerAndConnect').rejects(connectError);
3486
+
3487
+ webex.internal.newMetrics.submitClientEvent.resetHistory();
3488
+ meeting.updateLLMConnection.restore();
3489
+
3490
+ try {
3491
+ await meeting.updateLLMConnection({isInitialJoinPhase: true});
3492
+ assert.fail('Expected updateLLMConnection to reject');
3493
+ } catch (error) {
3494
+ assert.equal(error, connectError);
3495
+ }
3496
+
3497
+ const connectResponseCalls = webex.internal.newMetrics.submitClientEvent
3498
+ .getCalls()
3499
+ .filter((call) => call.args[0]?.name === 'client.llm.connect.response');
3500
+
3501
+ assert.lengthOf(connectResponseCalls, 1);
3502
+ assert.deepEqual(connectResponseCalls[0].args[0].payload.llmLatency, {
3503
+ clientLLMDatachannelResponseTime: 42,
3504
+ clientLLMWebSocketConnectTime: 0,
3505
+ });
3506
+ });
3507
+
2343
3508
  it('clears the LLM health check timer when disconnecting LLM', async () => {
2344
3509
  const isJoinedStub = sinon.stub(meeting, 'isJoined');
2345
3510
  sinon.stub(meeting.webex.internal.llm, 'isConnected');
@@ -2467,7 +3632,6 @@ describe('plugin-meetings', () => {
2467
3632
  });
2468
3633
  });
2469
3634
 
2470
-
2471
3635
  describe('#addMedia', () => {
2472
3636
  const muteStateStub = {
2473
3637
  handleClientRequest: sinon.stub().returns(Promise.resolve(true)),
@@ -2517,6 +3681,41 @@ describe('plugin-meetings', () => {
2517
3681
  assert.exists(meeting.addMedia);
2518
3682
  });
2519
3683
 
3684
+ it('logs a compact remote media manager configuration', async () => {
3685
+ const loggerInfoStub = sinon.stub(LoggerProxy.logger, 'info');
3686
+ const remoteMediaManagerConfig = {
3687
+ audio: {
3688
+ numOfActiveSpeakerStreams: 3,
3689
+ numOfScreenShareStreams: 1,
3690
+ },
3691
+ video: {
3692
+ preferLiveVideo: true,
3693
+ initialLayoutId: 'initial',
3694
+ layouts: {
3695
+ initial: {activeSpeakerVideoPaneGroups: []},
3696
+ excluded: {activeSpeakerVideoPaneGroups: []},
3697
+ },
3698
+ },
3699
+ };
3700
+
3701
+ const error = await assert.isRejected(
3702
+ meeting.addMediaInternal(() => 'JOIN_MEETING_FINAL', false, undefined, undefined, {
3703
+ remoteMediaManagerConfig,
3704
+ })
3705
+ );
3706
+
3707
+ assert.instanceOf(error, MeetingNotActiveError);
3708
+ assert.calledOnceWithExactly(
3709
+ loggerInfoStub,
3710
+ `Meeting:index#addMedia --> called with: options=${JSON.stringify({
3711
+ remoteMediaManagerConfig:
3712
+ RemoteMediaManagerModule.getRemoteMediaManagerConfigForLogging(
3713
+ remoteMediaManagerConfig
3714
+ ),
3715
+ })}, turnServerInfo=undefined, forceTurnDiscovery=false, iceTransportPolicy=undefined`
3716
+ );
3717
+ });
3718
+
2520
3719
  it('should reject promise if meeting is not active and the meeting in lobby is not enabled', async () => {
2521
3720
  const result = await assert.isRejected(meeting.addMedia({allowMediaInLobby: false}));
2522
3721
 
@@ -2614,9 +3813,11 @@ describe('plugin-meetings', () => {
2614
3813
  retriedWithTurnServer: false,
2615
3814
  isMultistream: false,
2616
3815
  isJoinWithMediaRetry: false,
3816
+ iceTransportPolicy: 'all',
2617
3817
  signalingState: 'unknown',
2618
3818
  connectionState: 'unknown',
2619
3819
  iceConnectionState: 'unknown',
3820
+ connectionType: 'udp',
2620
3821
  someReachabilityMetric1: 'some value1',
2621
3822
  someReachabilityMetric2: 'some value2',
2622
3823
  selectedCandidatePairChanges: 2,
@@ -2742,9 +3943,11 @@ describe('plugin-meetings', () => {
2742
3943
  retriedWithTurnServer: false,
2743
3944
  isMultistream: false,
2744
3945
  isJoinWithMediaRetry: false,
3946
+ iceTransportPolicy: 'all',
2745
3947
  signalingState: 'unknown',
2746
3948
  connectionState: 'unknown',
2747
3949
  iceConnectionState: 'unknown',
3950
+ connectionType: 'udp',
2748
3951
  someReachabilityMetric1: 'some value1',
2749
3952
  someReachabilityMetric2: 'some value2',
2750
3953
  selectedCandidatePairChanges: 2,
@@ -3178,6 +4381,7 @@ describe('plugin-meetings', () => {
3178
4381
  unpublishStream: sinon.stub(),
3179
4382
  setNamedMediaGroups: sinon.stub(),
3180
4383
  });
4384
+ sinon.spy(meeting.sendSlotManager, 'reset');
3181
4385
 
3182
4386
  await meeting.addMedia({
3183
4387
  allowMediaInLobby: true,
@@ -3190,6 +4394,7 @@ describe('plugin-meetings', () => {
3190
4394
  },
3191
4395
  });
3192
4396
 
4397
+ assert.calledOnce(meeting.sendSlotManager.reset);
3193
4398
  assert.notCalled(publishStreamStub);
3194
4399
  });
3195
4400
 
@@ -3213,6 +4418,7 @@ describe('plugin-meetings', () => {
3213
4418
  }
3214
4419
  return videoSlot;
3215
4420
  });
4421
+ sinon.spy(meeting.sendSlotManager, 'reset');
3216
4422
 
3217
4423
  await meeting.addMedia({
3218
4424
  allowMediaInLobby: true,
@@ -3225,6 +4431,7 @@ describe('plugin-meetings', () => {
3225
4431
  },
3226
4432
  });
3227
4433
 
4434
+ assert.calledOnce(meeting.sendSlotManager.reset);
3228
4435
  assert.calledOnceWithExactly(audioSlot.publishStream, fakeMicrophoneStream);
3229
4436
  assert.calledOnceWithExactly(videoSlot.publishStream, fakeCameraStream);
3230
4437
  });
@@ -3247,11 +4454,13 @@ describe('plugin-meetings', () => {
3247
4454
 
3248
4455
  meeting.meetingState = 'ACTIVE';
3249
4456
  meeting.isMultistream = true;
4457
+ sinon.spy(meeting.sendSlotManager, 'reset');
3250
4458
 
3251
4459
  await meeting.addMedia({
3252
4460
  mediaSettings: {},
3253
4461
  });
3254
4462
 
4463
+ assert.calledOnce(meeting.sendSlotManager.reset);
3255
4464
  // check that rtcMetrics was passed to Media.createMediaConnection
3256
4465
  assert.calledOnce(Media.createMediaConnection);
3257
4466
  assert.calledWith(
@@ -3512,9 +4721,11 @@ describe('plugin-meetings', () => {
3512
4721
  retriedWithTurnServer: true,
3513
4722
  isMultistream: false,
3514
4723
  isJoinWithMediaRetry: false,
4724
+ iceTransportPolicy: 'all',
3515
4725
  signalingState: 'unknown',
3516
4726
  connectionState: 'unknown',
3517
4727
  iceConnectionState: 'unknown',
4728
+ connectionType: 'udp',
3518
4729
  selectedCandidatePairChanges: 2,
3519
4730
  numTransports: 1,
3520
4731
  iceCandidatesCount: 0,
@@ -3539,6 +4750,173 @@ describe('plugin-meetings', () => {
3539
4750
  assert.isOk(errorThrown);
3540
4751
  });
3541
4752
 
4753
+ [
4754
+ {iceConnected: true, title: 'iceConnected=true'},
4755
+ {iceConnected: false, title: 'iceConnected=false'},
4756
+ ].forEach(({iceConnected, title}) => {
4757
+ it(`should propagate ${title} from waitForMediaConnectionConnected rejection to AddMediaFailed`, async () => {
4758
+ webex.meetings.reachability = {
4759
+ isWebexMediaBackendUnreachable: sinon.stub().resolves(false),
4760
+ getReachabilityMetrics: sinon.stub().resolves({}),
4761
+ stopReachability: sinon.stub(),
4762
+ isSubnetReachable: sinon.stub().returns(true),
4763
+ };
4764
+ webex.internal.newMetrics.callDiagnosticMetrics.getErrorPayloadForClientErrorCode =
4765
+ sinon.stub().returns({fatal: true});
4766
+ sinon.stub(CallDiagnosticUtils, 'generateClientErrorCodeForIceFailure').returns(2004);
4767
+
4768
+ meeting.meetingState = 'ACTIVE';
4769
+ const rejectedResult = {iceConnected};
4770
+ meeting.mediaProperties.waitForMediaConnectionConnected = sinon
4771
+ .stub()
4772
+ .rejects(rejectedResult);
4773
+
4774
+ meeting.roap.doTurnDiscovery = sinon.stub().returns({
4775
+ turnServerInfo: {urls: ['turns:fake:443'], username: 'u', password: 'p'},
4776
+ turnDiscoverySkippedReason: undefined,
4777
+ });
4778
+
4779
+ const forceRtcMetricsSend = sinon.stub().resolves();
4780
+ Media.createMediaConnection = sinon.stub().returns({
4781
+ close: sinon.stub(),
4782
+ forceRtcMetricsSend,
4783
+ getConnectionState: sinon.stub().returns(ConnectionState.Connected),
4784
+ initiateOffer: sinon.stub().resolves({}),
4785
+ on: sinon.stub(),
4786
+ });
4787
+
4788
+ let thrownError;
4789
+ await meeting.addMedia({mediaSettings: {}}).catch((err) => {
4790
+ thrownError = err;
4791
+ });
4792
+
4793
+ assert.instanceOf(thrownError, AddMediaFailed);
4794
+ assert.equal(thrownError.iceConnected, iceConnected);
4795
+ // the AddMediaFailed cause should be the MediaConnectionTimedOutError, which in turn should
4796
+ // preserve the original rejected result as its cause, so that the web client
4797
+ // can find the CA-reported error in the eventErrorCache via the cause chain
4798
+ assert.instanceOf(thrownError.cause, MediaConnectionTimedOutError);
4799
+ assert.equal(thrownError.cause.cause, rejectedResult);
4800
+ });
4801
+ });
4802
+
4803
+ describe('iceTransportPolicy=relay handling', () => {
4804
+ let createMediaConnectionStub;
4805
+
4806
+ beforeEach(() => {
4807
+ webex.meetings.reachability = {
4808
+ isWebexMediaBackendUnreachable: sinon.stub().resolves(false),
4809
+ isAnyClusterReachableViaProtocol: sinon.stub().resolves(true),
4810
+ getReachabilityMetrics: sinon.stub().resolves({}),
4811
+ stopReachability: sinon.stub(),
4812
+ isSubnetReachable: sinon.stub().returns(true),
4813
+ };
4814
+ webex.internal.newMetrics.callDiagnosticMetrics.getErrorPayloadForClientErrorCode =
4815
+ sinon.stub().returns({fatal: true});
4816
+ sinon.stub(CallDiagnosticUtils, 'generateClientErrorCodeForIceFailure').returns(2004);
4817
+
4818
+ meeting.meetingState = 'ACTIVE';
4819
+ meeting.mediaProperties.waitForMediaConnectionConnected = sinon.stub().resolves();
4820
+
4821
+ createMediaConnectionStub = sinon.stub().returns({
4822
+ close: sinon.stub(),
4823
+ forceRtcMetricsSend: sinon.stub().resolves(),
4824
+ getConnectionState: sinon.stub().returns(ConnectionState.Connected),
4825
+ initiateOffer: sinon.stub().resolves({}),
4826
+ on: sinon.stub(),
4827
+ });
4828
+ Media.createMediaConnection = createMediaConnectionStub;
4829
+ });
4830
+
4831
+ [
4832
+ {
4833
+ title:
4834
+ 'should drop iceTransportPolicy=relay when TURN discovery returns no turn server info',
4835
+ turnServerInfo: undefined,
4836
+ turnDiscoverySkippedReason: 'reachability',
4837
+ },
4838
+ {
4839
+ title:
4840
+ 'should drop iceTransportPolicy=relay when TURN discovery returns turnServerInfo with empty urls',
4841
+ turnServerInfo: {urls: [], username: 'u', password: 'p'},
4842
+ turnDiscoverySkippedReason: undefined,
4843
+ },
4844
+ ].forEach(({title, turnServerInfo, turnDiscoverySkippedReason}) => {
4845
+ it(title, async () => {
4846
+ meeting.roap.doTurnDiscovery = sinon.stub().returns({
4847
+ turnServerInfo,
4848
+ turnDiscoverySkippedReason,
4849
+ });
4850
+
4851
+ await meeting.addMediaInternal(
4852
+ () => 'JOIN_MEETING_FINAL',
4853
+ false,
4854
+ undefined,
4855
+ 'relay',
4856
+ {mediaSettings: {}}
4857
+ );
4858
+
4859
+ assert.calledOnce(createMediaConnectionStub);
4860
+ const config = createMediaConnectionStub.firstCall.args[3];
4861
+ assert.isUndefined(config.iceTransportPolicy);
4862
+
4863
+ const successCall = Metrics.sendBehavioralMetric
4864
+ .getCalls()
4865
+ .find((call) => call.args[0] === BEHAVIORAL_METRICS.ADD_MEDIA_SUCCESS);
4866
+ assert.isDefined(successCall);
4867
+ assert.equal(successCall.args[1].iceTransportPolicy, 'all');
4868
+ });
4869
+ });
4870
+
4871
+ it('should send ADD_MEDIA_SUCCESS metric with iceTransportPolicy=relay when relay is used', async () => {
4872
+ meeting.roap.doTurnDiscovery = sinon.stub().returns({
4873
+ turnServerInfo: {
4874
+ urls: ['turns:turn-server:443?transport=tcp'],
4875
+ username: 'u',
4876
+ password: 'p',
4877
+ },
4878
+ turnDiscoverySkippedReason: undefined,
4879
+ });
4880
+
4881
+ await meeting.addMediaInternal(() => 'JOIN_MEETING_FINAL', false, undefined, 'relay', {
4882
+ mediaSettings: {},
4883
+ });
4884
+
4885
+ const successCall = Metrics.sendBehavioralMetric
4886
+ .getCalls()
4887
+ .find((call) => call.args[0] === BEHAVIORAL_METRICS.ADD_MEDIA_SUCCESS);
4888
+ assert.isDefined(successCall);
4889
+ assert.equal(successCall.args[1].iceTransportPolicy, 'relay');
4890
+ });
4891
+
4892
+ it('should send ADD_MEDIA_FAILURE metric with iceTransportPolicy=relay when relay attempt fails', async () => {
4893
+ meeting.roap.doTurnDiscovery = sinon.stub().returns({
4894
+ turnServerInfo: {
4895
+ urls: ['turns:turn-server:443?transport=tcp'],
4896
+ username: 'u',
4897
+ password: 'p',
4898
+ },
4899
+ turnDiscoverySkippedReason: undefined,
4900
+ });
4901
+
4902
+ meeting.mediaProperties.waitForMediaConnectionConnected = sinon
4903
+ .stub()
4904
+ .rejects(new MediaConnectionTimedOutError('timed out', true));
4905
+
4906
+ await assert.isRejected(
4907
+ meeting.addMediaInternal(() => 'JOIN_MEETING_FINAL', false, undefined, 'relay', {
4908
+ mediaSettings: {},
4909
+ })
4910
+ );
4911
+
4912
+ const failureCall = Metrics.sendBehavioralMetric
4913
+ .getCalls()
4914
+ .find((call) => call.args[0] === BEHAVIORAL_METRICS.ADD_MEDIA_FAILURE);
4915
+ assert.isDefined(failureCall);
4916
+ assert.equal(failureCall.args[1].iceTransportPolicy, 'relay');
4917
+ });
4918
+ });
4919
+
3542
4920
  it('should resolve if waitForMediaConnectionConnected() rejects the first time but resolves the second time', async () => {
3543
4921
  const FAKE_ERROR = {fatal: true};
3544
4922
  webex.meetings.reachability = {
@@ -3728,6 +5106,7 @@ describe('plugin-meetings', () => {
3728
5106
  isMultistream: false,
3729
5107
  retriedWithTurnServer: true,
3730
5108
  isJoinWithMediaRetry: false,
5109
+ iceTransportPolicy: 'all',
3731
5110
  iceCandidatesCount: 0,
3732
5111
  subnet_reachable: null,
3733
5112
  selected_cluster: null,
@@ -3891,6 +5270,7 @@ describe('plugin-meetings', () => {
3891
5270
  isMultistream: false,
3892
5271
  retriedWithTurnServer: false,
3893
5272
  isJoinWithMediaRetry: false,
5273
+ iceTransportPolicy: 'all',
3894
5274
  someReachabilityMetric1: 'some value1',
3895
5275
  someReachabilityMetric2: 'some value2',
3896
5276
  iceCandidatesCount: 3,
@@ -3956,9 +5336,11 @@ describe('plugin-meetings', () => {
3956
5336
  retriedWithTurnServer: false,
3957
5337
  isMultistream: false,
3958
5338
  isJoinWithMediaRetry: false,
5339
+ iceTransportPolicy: 'all',
3959
5340
  signalingState: 'unknown',
3960
5341
  connectionState: 'unknown',
3961
5342
  iceConnectionState: 'unknown',
5343
+ connectionType: 'udp',
3962
5344
  selectedCandidatePairChanges: 2,
3963
5345
  numTransports: 1,
3964
5346
  subnet_reachable: null,
@@ -4019,9 +5401,11 @@ describe('plugin-meetings', () => {
4019
5401
  retriedWithTurnServer: false,
4020
5402
  isMultistream: false,
4021
5403
  isJoinWithMediaRetry: false,
5404
+ iceTransportPolicy: 'all',
4022
5405
  signalingState: 'unknown',
4023
5406
  connectionState: 'unknown',
4024
5407
  iceConnectionState: 'unknown',
5408
+ connectionType: 'udp',
4025
5409
  selectedCandidatePairChanges: 2,
4026
5410
  numTransports: 1,
4027
5411
  '701_error': 2,
@@ -4083,6 +5467,7 @@ describe('plugin-meetings', () => {
4083
5467
  isMultistream: false,
4084
5468
  retriedWithTurnServer: false,
4085
5469
  isJoinWithMediaRetry: false,
5470
+ iceTransportPolicy: 'all',
4086
5471
  iceCandidatesCount: 0,
4087
5472
  reachability_public_udp_success: 5,
4088
5473
  subnet_reachable: false,
@@ -4148,9 +5533,11 @@ describe('plugin-meetings', () => {
4148
5533
  retriedWithTurnServer: false,
4149
5534
  isMultistream: false,
4150
5535
  isJoinWithMediaRetry: false,
5536
+ iceTransportPolicy: 'all',
4151
5537
  signalingState: 'unknown',
4152
5538
  connectionState: 'unknown',
4153
5539
  iceConnectionState: 'unknown',
5540
+ connectionType: 'udp',
4154
5541
  selectedCandidatePairChanges: 2,
4155
5542
  numTransports: 1,
4156
5543
  reachability_public_udp_success: 5,
@@ -4534,6 +5921,297 @@ describe('plugin-meetings', () => {
4534
5921
  },
4535
5922
  });
4536
5923
  });
5924
+
5925
+ describe('handles STATS_UPDATE event for SRTP cipher detection', () => {
5926
+ it('emits MEETING_SRTP_CIPHER_UPDATED event when srtpCipher is found in transport stats', async () => {
5927
+ const fakeStats = new Map([
5928
+ [
5929
+ 'transport-1',
5930
+ {
5931
+ type: 'transport',
5932
+ srtpCipher: 'AES_CM_128_HMAC_SHA1_80',
5933
+ dtlsCipher: 'TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256',
5934
+ },
5935
+ ],
5936
+ [
5937
+ 'outbound-rtp-1',
5938
+ {
5939
+ type: 'outbound-rtp',
5940
+ ssrc: 12345,
5941
+ },
5942
+ ],
5943
+ ]);
5944
+
5945
+ statsAnalyzerStub.emit(
5946
+ {file: 'test', function: 'test'},
5947
+ StatsAnalyzerEventNames.STATS_UPDATE,
5948
+ {stats: fakeStats}
5949
+ );
5950
+
5951
+ assert.calledWith(
5952
+ TriggerProxy.trigger,
5953
+ sinon.match.instanceOf(Meeting),
5954
+ {
5955
+ file: 'meeting/index',
5956
+ function: 'setupStatsAnalyzerEventHandlers',
5957
+ },
5958
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
5959
+ {srtpCipher: 'AES_CM_128_HMAC_SHA1_80'}
5960
+ );
5961
+
5962
+ assert.equal(meeting.mediaProperties.srtpCipher, 'AES_CM_128_HMAC_SHA1_80');
5963
+ });
5964
+
5965
+ it('updates meeting.mediaProperties.srtpCipher when cipher changes', async () => {
5966
+ const firstStats = new Map([
5967
+ [
5968
+ 'transport-1',
5969
+ {
5970
+ type: 'transport',
5971
+ srtpCipher: 'AES_CM_128_HMAC_SHA1_80',
5972
+ },
5973
+ ],
5974
+ ]);
5975
+
5976
+ statsAnalyzerStub.emit(
5977
+ {file: 'test', function: 'test'},
5978
+ StatsAnalyzerEventNames.STATS_UPDATE,
5979
+ {stats: firstStats}
5980
+ );
5981
+
5982
+ assert.equal(meeting.mediaProperties.srtpCipher, 'AES_CM_128_HMAC_SHA1_80');
5983
+
5984
+ const secondStats = new Map([
5985
+ [
5986
+ 'transport-1',
5987
+ {
5988
+ type: 'transport',
5989
+ srtpCipher: 'AEAD_AES_256_GCM',
5990
+ },
5991
+ ],
5992
+ ]);
5993
+
5994
+ TriggerProxy.trigger.resetHistory();
5995
+
5996
+ statsAnalyzerStub.emit(
5997
+ {file: 'test', function: 'test'},
5998
+ StatsAnalyzerEventNames.STATS_UPDATE,
5999
+ {stats: secondStats}
6000
+ );
6001
+
6002
+ assert.calledWith(
6003
+ TriggerProxy.trigger,
6004
+ sinon.match.instanceOf(Meeting),
6005
+ {
6006
+ file: 'meeting/index',
6007
+ function: 'setupStatsAnalyzerEventHandlers',
6008
+ },
6009
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
6010
+ {srtpCipher: 'AEAD_AES_256_GCM'}
6011
+ );
6012
+
6013
+ assert.equal(meeting.mediaProperties.srtpCipher, 'AEAD_AES_256_GCM');
6014
+ });
6015
+
6016
+ it('does not emit event when srtpCipher has not changed', async () => {
6017
+ const firstStats = new Map([
6018
+ [
6019
+ 'transport-1',
6020
+ {
6021
+ type: 'transport',
6022
+ srtpCipher: 'AES_CM_128_HMAC_SHA1_80',
6023
+ },
6024
+ ],
6025
+ ]);
6026
+
6027
+ statsAnalyzerStub.emit(
6028
+ {file: 'test', function: 'test'},
6029
+ StatsAnalyzerEventNames.STATS_UPDATE,
6030
+ {stats: firstStats}
6031
+ );
6032
+
6033
+ assert.equal(meeting.mediaProperties.srtpCipher, 'AES_CM_128_HMAC_SHA1_80');
6034
+
6035
+ TriggerProxy.trigger.resetHistory();
6036
+
6037
+ // Emit same cipher again
6038
+ statsAnalyzerStub.emit(
6039
+ {file: 'test', function: 'test'},
6040
+ StatsAnalyzerEventNames.STATS_UPDATE,
6041
+ {stats: firstStats}
6042
+ );
6043
+
6044
+ // Should not trigger event again
6045
+ assert.neverCalledWith(
6046
+ TriggerProxy.trigger,
6047
+ sinon.match.instanceOf(Meeting),
6048
+ sinon.match.any,
6049
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
6050
+ sinon.match.any
6051
+ );
6052
+
6053
+ // Cipher should remain the same
6054
+ assert.equal(meeting.mediaProperties.srtpCipher, 'AES_CM_128_HMAC_SHA1_80');
6055
+ });
6056
+
6057
+ it('does not emit event when stats contain no transport with srtpCipher', async () => {
6058
+ const fakeStats = new Map([
6059
+ [
6060
+ 'outbound-rtp-1',
6061
+ {
6062
+ type: 'outbound-rtp',
6063
+ ssrc: 12345,
6064
+ },
6065
+ ],
6066
+ [
6067
+ 'inbound-rtp-1',
6068
+ {
6069
+ type: 'inbound-rtp',
6070
+ ssrc: 67890,
6071
+ },
6072
+ ],
6073
+ ]);
6074
+
6075
+ statsAnalyzerStub.emit(
6076
+ {file: 'test', function: 'test'},
6077
+ StatsAnalyzerEventNames.STATS_UPDATE,
6078
+ {stats: fakeStats}
6079
+ );
6080
+
6081
+ assert.neverCalledWith(
6082
+ TriggerProxy.trigger,
6083
+ sinon.match.instanceOf(Meeting),
6084
+ sinon.match.any,
6085
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
6086
+ sinon.match.any
6087
+ );
6088
+
6089
+ assert.isUndefined(meeting.mediaProperties.srtpCipher);
6090
+ });
6091
+
6092
+ it('does not emit event when transport stat has no srtpCipher property', async () => {
6093
+ const fakeStats = new Map([
6094
+ [
6095
+ 'transport-1',
6096
+ {
6097
+ type: 'transport',
6098
+ dtlsCipher: 'TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256',
6099
+ // no srtpCipher property
6100
+ },
6101
+ ],
6102
+ ]);
6103
+
6104
+ statsAnalyzerStub.emit(
6105
+ {file: 'test', function: 'test'},
6106
+ StatsAnalyzerEventNames.STATS_UPDATE,
6107
+ {stats: fakeStats}
6108
+ );
6109
+
6110
+ assert.neverCalledWith(
6111
+ TriggerProxy.trigger,
6112
+ sinon.match.instanceOf(Meeting),
6113
+ sinon.match.any,
6114
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
6115
+ sinon.match.any
6116
+ );
6117
+
6118
+ assert.isUndefined(meeting.mediaProperties.srtpCipher);
6119
+ });
6120
+
6121
+ it('uses first transport with srtpCipher when multiple transports exist', async () => {
6122
+ const fakeStats = new Map([
6123
+ [
6124
+ 'transport-1',
6125
+ {
6126
+ type: 'transport',
6127
+ srtpCipher: 'AES_CM_128_HMAC_SHA1_80',
6128
+ },
6129
+ ],
6130
+ [
6131
+ 'transport-2',
6132
+ {
6133
+ type: 'transport',
6134
+ srtpCipher: 'AEAD_AES_256_GCM',
6135
+ },
6136
+ ],
6137
+ [
6138
+ 'outbound-rtp-1',
6139
+ {
6140
+ type: 'outbound-rtp',
6141
+ ssrc: 12345,
6142
+ },
6143
+ ],
6144
+ ]);
6145
+
6146
+ statsAnalyzerStub.emit(
6147
+ {file: 'test', function: 'test'},
6148
+ StatsAnalyzerEventNames.STATS_UPDATE,
6149
+ {stats: fakeStats}
6150
+ );
6151
+
6152
+ assert.calledWith(
6153
+ TriggerProxy.trigger,
6154
+ sinon.match.instanceOf(Meeting),
6155
+ {
6156
+ file: 'meeting/index',
6157
+ function: 'setupStatsAnalyzerEventHandlers',
6158
+ },
6159
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
6160
+ {srtpCipher: 'AES_CM_128_HMAC_SHA1_80'}
6161
+ );
6162
+
6163
+ assert.equal(meeting.mediaProperties.srtpCipher, 'AES_CM_128_HMAC_SHA1_80');
6164
+ });
6165
+
6166
+ it('handles empty stats map without errors', async () => {
6167
+ const emptyStats = new Map();
6168
+
6169
+ statsAnalyzerStub.emit(
6170
+ {file: 'test', function: 'test'},
6171
+ StatsAnalyzerEventNames.STATS_UPDATE,
6172
+ {stats: emptyStats}
6173
+ );
6174
+
6175
+ assert.neverCalledWith(
6176
+ TriggerProxy.trigger,
6177
+ sinon.match.instanceOf(Meeting),
6178
+ sinon.match.any,
6179
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
6180
+ sinon.match.any
6181
+ );
6182
+
6183
+ assert.isUndefined(meeting.mediaProperties.srtpCipher);
6184
+ });
6185
+
6186
+ it('logs cipher change when cipher is updated', async () => {
6187
+ const loggerSpy = sinon.spy(LoggerProxy.logger, 'info');
6188
+
6189
+ meeting.mediaProperties.srtpCipher = 'AES_CM_128_HMAC_SHA1_80';
6190
+
6191
+ const newStats = new Map([
6192
+ [
6193
+ 'transport-1',
6194
+ {
6195
+ type: 'transport',
6196
+ srtpCipher: 'AEAD_AES_256_GCM',
6197
+ },
6198
+ ],
6199
+ ]);
6200
+
6201
+ statsAnalyzerStub.emit(
6202
+ {file: 'test', function: 'test'},
6203
+ StatsAnalyzerEventNames.STATS_UPDATE,
6204
+ {stats: newStats}
6205
+ );
6206
+
6207
+ assert.calledWithMatch(
6208
+ loggerSpy,
6209
+ sinon.match(/SRTP cipher changed from AES_CM_128_HMAC_SHA1_80 to AEAD_AES_256_GCM/)
6210
+ );
6211
+
6212
+ loggerSpy.restore();
6213
+ });
6214
+ });
4537
6215
  });
4538
6216
 
4539
6217
  describe('handles StatsMonitor events', () => {
@@ -4633,10 +6311,55 @@ describe('plugin-meetings', () => {
4633
6311
  isAudioMuted: false,
4634
6312
  };
4635
6313
  meeting.members.membersCollection.getAll = sinon.stub().returns({
4636
- member1: mutedMember,
4637
- member2: unmutedMember,
4638
- member3: selfMember,
6314
+ member1: mutedMember,
6315
+ member2: unmutedMember,
6316
+ member3: selfMember,
6317
+ });
6318
+ meeting.isUserUnadmitted = false;
6319
+
6320
+ // Reset the stub to clear any previous calls
6321
+ TriggerProxy.trigger.resetHistory();
6322
+
6323
+ // Emit the event from statsMonitor
6324
+ listeners[StatsMonitorEventNames.INBOUND_AUDIO_ISSUE](fakeEventData);
6325
+
6326
+ assert.calledWith(
6327
+ TriggerProxy.trigger,
6328
+ meeting,
6329
+ sinon.match.object,
6330
+ EVENT_TRIGGERS.MEDIA_INBOUND_AUDIO_ISSUE_DETECTED,
6331
+ fakeEventData
6332
+ );
6333
+
6334
+ assert.calledOnceWithExactly(
6335
+ meeting.mediaProperties.sendMediaIssueMetric,
6336
+ 'inbound_audio',
6337
+ fakeEventData.issueSubType,
6338
+ {
6339
+ correlationId: meeting.correlationId,
6340
+ isMultistream: meeting.isMultistream,
6341
+ }
6342
+ );
6343
+ });
6344
+
6345
+ it('should not trigger event or metric when the user is in the lobby', () => {
6346
+ const fakeEventData = {issueSubType: 'DECODE_RESULTS_IN_ZERO_AUDIO_LEVEL'};
6347
+
6348
+ const unmutedMember = {
6349
+ isSelf: false,
6350
+ isPairedWithSelf: false,
6351
+ isAudioMuted: false,
6352
+ };
6353
+ const selfMember = {
6354
+ isSelf: true,
6355
+ isPairedWithSelf: false,
6356
+ isAudioMuted: false,
6357
+ };
6358
+ meeting.members.membersCollection.getAll = sinon.stub().returns({
6359
+ member1: unmutedMember,
6360
+ member2: selfMember,
4639
6361
  });
6362
+ meeting.isUserUnadmitted = true;
4640
6363
 
4641
6364
  // Reset the stub to clear any previous calls
4642
6365
  TriggerProxy.trigger.resetHistory();
@@ -4644,20 +6367,14 @@ describe('plugin-meetings', () => {
4644
6367
  // Emit the event from statsMonitor
4645
6368
  listeners[StatsMonitorEventNames.INBOUND_AUDIO_ISSUE](fakeEventData);
4646
6369
 
4647
- assert.calledWith(
6370
+ assert.neverCalledWith(
4648
6371
  TriggerProxy.trigger,
4649
6372
  meeting,
4650
6373
  sinon.match.object,
4651
6374
  EVENT_TRIGGERS.MEDIA_INBOUND_AUDIO_ISSUE_DETECTED,
4652
6375
  fakeEventData
4653
6376
  );
4654
-
4655
- assert.calledOnceWithExactly(
4656
- meeting.mediaProperties.sendMediaIssueMetric,
4657
- 'inbound_audio',
4658
- fakeEventData.issueSubType,
4659
- meeting.correlationId
4660
- );
6377
+ assert.notCalled(meeting.mediaProperties.sendMediaIssueMetric);
4661
6378
  });
4662
6379
  });
4663
6380
  });
@@ -6192,13 +7909,14 @@ describe('plugin-meetings', () => {
6192
7909
  sinon.stub(meeting.locusMediaRequest, 'downgradeFromMultistreamToTranscoded');
6193
7910
  });
6194
7911
 
6195
- const runCheck = async (turnServerInfo, forceTurnDiscovery) => {
7912
+ const runCheck = async (turnServerInfo, forceTurnDiscovery, iceTransportPolicy) => {
6196
7913
  // we're calling addMediaInternal() with mic stream,
6197
7914
  // so that we also verify that audioMute, videoMute info is correctly sent to backend
6198
7915
  const addMediaPromise = meeting.addMediaInternal(
6199
7916
  () => '',
6200
- turnServerInfo,
6201
7917
  forceTurnDiscovery,
7918
+ turnServerInfo,
7919
+ iceTransportPolicy,
6202
7920
  {
6203
7921
  localStreams: {microphone: fakeMicrophoneStream},
6204
7922
  }
@@ -6252,6 +7970,10 @@ describe('plugin-meetings', () => {
6252
7970
  // at this point the meeting should have been downgraded to transcoded
6253
7971
  assert.equal(meeting.isMultistream, false);
6254
7972
 
7973
+ // iceTransportPolicy must be reset to undefined on downgrade to transcoded,
7974
+ // otherwise the transcoded retry could gather direct candidates while metrics report relay
7975
+ assert.isUndefined(meeting.addMediaData.iceTransportPolicy);
7976
+
6255
7977
  // old stats analyzer stopped and new one created
6256
7978
  assert.calledOnce(initialStatsAnalyzer.stopAnalyzer);
6257
7979
  assert.calledOnceWithExactly(
@@ -6342,6 +8064,11 @@ describe('plugin-meetings', () => {
6342
8064
  true
6343
8065
  );
6344
8066
  });
8067
+
8068
+ it('resets iceTransportPolicy to undefined when falling back from multistream (relay) to transcoded', async () => {
8069
+ // simulate a relay-only retry falling back to transcoded and verify iceTransportPolicy is reset
8070
+ await runCheck(undefined, false, 'relay');
8071
+ });
6345
8072
  });
6346
8073
  }
6347
8074
  })
@@ -6429,6 +8156,9 @@ describe('plugin-meetings', () => {
6429
8156
 
6430
8157
  meeting.annotation.deregisterEvents = sinon.stub();
6431
8158
  webex.internal.llm.off = sinon.stub();
8159
+ webex.internal.mercury.off = sinon.stub();
8160
+ meeting.mercuryOnlineHandler = sinon.stub();
8161
+ meeting.mercuryOfflineHandler = sinon.stub();
6432
8162
 
6433
8163
  // A meeting needs to be joined to leave
6434
8164
  meeting.meetingState = 'ACTIVE';
@@ -6452,6 +8182,67 @@ describe('plugin-meetings', () => {
6452
8182
  assert.calledOnce(meeting.clearMeetingData);
6453
8183
  });
6454
8184
 
8185
+ it('stops listening for LLM/Mercury and tears down transcription and annotation before calling Locus /leave', async () => {
8186
+ const onlineHandler = meeting.mercuryOnlineHandler;
8187
+ const offlineHandler = meeting.mercuryOfflineHandler;
8188
+
8189
+ await meeting.leave();
8190
+
8191
+ // All llm/mercury consumers (direct listeners, voicea transcription,
8192
+ // annotation) must be detached before the /leave request so that
8193
+ // in-flight events do not trigger unnecessary Locus syncs
8194
+ // (per Locus team recommendation).
8195
+ assert.callOrder(
8196
+ webex.internal.llm.off,
8197
+ webex.internal.mercury.off,
8198
+ meeting.stopTranscription,
8199
+ meeting.annotation.deregisterEvents,
8200
+ meeting.meetingRequest.leaveMeeting
8201
+ );
8202
+ assert.calledWithExactly(
8203
+ webex.internal.llm.off,
8204
+ 'event:relay.event',
8205
+ meeting.processRelayEvent
8206
+ );
8207
+ assert.calledWithExactly(
8208
+ webex.internal.llm.off,
8209
+ LOCUS_LLM_EVENT,
8210
+ meeting.processLocusLLMEvent
8211
+ );
8212
+ assert.calledWithExactly(webex.internal.mercury.off, ONLINE, onlineHandler);
8213
+ assert.calledWithExactly(webex.internal.mercury.off, OFFLINE, offlineHandler);
8214
+ assert.isUndefined(meeting.mercuryOnlineHandler);
8215
+ assert.isUndefined(meeting.mercuryOfflineHandler);
8216
+ assert.calledOnceWithExactly(meeting.stopTranscription);
8217
+ assert.calledOnceWithExactly(meeting.annotation.deregisterEvents);
8218
+ assert.isUndefined(meeting.transcription);
8219
+ });
8220
+
8221
+ it('tears down llm/mercury/transcription/annotation even when /leave rejects', async () => {
8222
+ const onlineHandler = meeting.mercuryOnlineHandler;
8223
+ const offlineHandler = meeting.mercuryOfflineHandler;
8224
+ meeting.meetingRequest.leaveMeeting = sinon
8225
+ .stub()
8226
+ .returns(Promise.reject(new Error('leave failed')));
8227
+
8228
+ await meeting.leave().catch(() => {});
8229
+
8230
+ assert.calledWithExactly(
8231
+ webex.internal.llm.off,
8232
+ 'event:relay.event',
8233
+ meeting.processRelayEvent
8234
+ );
8235
+ assert.calledWithExactly(
8236
+ webex.internal.llm.off,
8237
+ LOCUS_LLM_EVENT,
8238
+ meeting.processLocusLLMEvent
8239
+ );
8240
+ assert.calledWithExactly(webex.internal.mercury.off, ONLINE, onlineHandler);
8241
+ assert.calledWithExactly(webex.internal.mercury.off, OFFLINE, offlineHandler);
8242
+ assert.calledOnceWithExactly(meeting.stopTranscription);
8243
+ assert.calledOnceWithExactly(meeting.annotation.deregisterEvents);
8244
+ });
8245
+
6455
8246
  it('should reset call diagnostic latencies correctly', async () => {
6456
8247
  const leave = meeting.leave();
6457
8248
 
@@ -7349,7 +9140,11 @@ describe('plugin-meetings', () => {
7349
9140
  beforeEach(() => {
7350
9141
  meeting.locusId = 'locus-id';
7351
9142
  meeting.id = 'meeting-id';
7352
- FAKE_OPTIONS = {meetingId: meeting.id, sendCAevents: true};
9143
+ FAKE_OPTIONS = {
9144
+ meetingId: meeting.id,
9145
+ sendCAevents: true,
9146
+ correlationId: meeting.correlationId,
9147
+ };
7353
9148
  });
7354
9149
 
7355
9150
  it('calls meetingInfoProvider with all the right parameters and parses the result', async () => {
@@ -7434,7 +9229,11 @@ describe('plugin-meetings', () => {
7434
9229
  undefined,
7435
9230
  meeting.locusId,
7436
9231
  {},
7437
- {meetingId: meeting.id, sendCAevents: false}
9232
+ {
9233
+ meetingId: meeting.id,
9234
+ sendCAevents: false,
9235
+ correlationId: meeting.correlationId,
9236
+ }
7438
9237
  );
7439
9238
 
7440
9239
  // parseMeeting info
@@ -7520,7 +9319,11 @@ describe('plugin-meetings', () => {
7520
9319
  undefined,
7521
9320
  'locus-id',
7522
9321
  {},
7523
- {meetingId: meeting.id, sendCAevents: true}
9322
+ {
9323
+ meetingId: meeting.id,
9324
+ sendCAevents: true,
9325
+ correlationId: meeting.correlationId,
9326
+ }
7524
9327
  );
7525
9328
 
7526
9329
  assert.deepEqual(meeting.meetingInfo, FAKE_MEETING_INFO);
@@ -7556,7 +9359,11 @@ describe('plugin-meetings', () => {
7556
9359
  undefined,
7557
9360
  'locus-id',
7558
9361
  {},
7559
- {meetingId: meeting.id, sendCAevents: true}
9362
+ {
9363
+ meetingId: meeting.id,
9364
+ sendCAevents: true,
9365
+ correlationId: meeting.correlationId,
9366
+ }
7560
9367
  );
7561
9368
 
7562
9369
  assert.deepEqual(meeting.meetingInfo, FAKE_MEETING_INFO);
@@ -7585,7 +9392,11 @@ describe('plugin-meetings', () => {
7585
9392
  undefined,
7586
9393
  'locus-id',
7587
9394
  {},
7588
- {meetingId: meeting.id, sendCAevents: true}
9395
+ {
9396
+ meetingId: meeting.id,
9397
+ sendCAevents: true,
9398
+ correlationId: meeting.correlationId,
9399
+ }
7589
9400
  );
7590
9401
 
7591
9402
  assert.deepEqual(meeting.meetingInfo, FAKE_MEETING_INFO);
@@ -7620,7 +9431,11 @@ describe('plugin-meetings', () => {
7620
9431
  undefined,
7621
9432
  'locus-id',
7622
9433
  {},
7623
- {meetingId: meeting.id, sendCAevents: true}
9434
+ {
9435
+ meetingId: meeting.id,
9436
+ sendCAevents: true,
9437
+ correlationId: meeting.correlationId,
9438
+ }
7624
9439
  );
7625
9440
 
7626
9441
  assert.deepEqual(meeting.meetingInfo, {});
@@ -7666,7 +9481,11 @@ describe('plugin-meetings', () => {
7666
9481
  undefined,
7667
9482
  'locus-id',
7668
9483
  {},
7669
- {meetingId: meeting.id, sendCAevents: true}
9484
+ {
9485
+ meetingId: meeting.id,
9486
+ sendCAevents: true,
9487
+ correlationId: meeting.correlationId,
9488
+ }
7670
9489
  );
7671
9490
 
7672
9491
  assert.deepEqual(meeting.meetingInfo, {});
@@ -7700,7 +9519,11 @@ describe('plugin-meetings', () => {
7700
9519
  undefined,
7701
9520
  'locus-id',
7702
9521
  {},
7703
- {meetingId: meeting.id, sendCAevents: true}
9522
+ {
9523
+ meetingId: meeting.id,
9524
+ sendCAevents: true,
9525
+ correlationId: meeting.correlationId,
9526
+ }
7704
9527
  );
7705
9528
 
7706
9529
  assert.deepEqual(meeting.meetingInfo, {
@@ -7753,7 +9576,11 @@ describe('plugin-meetings', () => {
7753
9576
  undefined,
7754
9577
  'locus-id',
7755
9578
  {},
7756
- {meetingId: meeting.id, sendCAevents: true}
9579
+ {
9580
+ meetingId: meeting.id,
9581
+ sendCAevents: true,
9582
+ correlationId: meeting.correlationId,
9583
+ }
7757
9584
  );
7758
9585
 
7759
9586
  assert.deepEqual(meeting.meetingInfo, FAKE_MEETING_INFO);
@@ -8042,7 +9869,11 @@ describe('plugin-meetings', () => {
8042
9869
  'fake-installed-org-id',
8043
9870
  'locus-id',
8044
9871
  {extraParam1: 'value1', permissionToken: FAKE_PERMISSION_TOKEN},
8045
- {meetingId: meeting.id, sendCAevents: true},
9872
+ {
9873
+ meetingId: meeting.id,
9874
+ sendCAevents: true,
9875
+ correlationId: meeting.correlationId,
9876
+ },
8046
9877
  null,
8047
9878
  null,
8048
9879
  null
@@ -8090,7 +9921,11 @@ describe('plugin-meetings', () => {
8090
9921
  'fake-installed-org-id',
8091
9922
  'locus-id',
8092
9923
  {extraParam1: 'value1', permissionToken: FAKE_PERMISSION_TOKEN},
8093
- {meetingId: meeting.id, sendCAevents: true},
9924
+ {
9925
+ meetingId: meeting.id,
9926
+ sendCAevents: true,
9927
+ correlationId: meeting.correlationId,
9928
+ },
8094
9929
  null,
8095
9930
  null,
8096
9931
  null
@@ -8147,7 +9982,11 @@ describe('plugin-meetings', () => {
8147
9982
  extraParam1: 'value1',
8148
9983
  permissionToken: FAKE_PERMISSION_TOKEN,
8149
9984
  },
8150
- {meetingId: meeting.id, sendCAevents: true},
9985
+ {
9986
+ meetingId: meeting.id,
9987
+ sendCAevents: true,
9988
+ correlationId: meeting.correlationId,
9989
+ },
8151
9990
  null,
8152
9991
  null,
8153
9992
  null
@@ -8459,6 +10298,9 @@ describe('plugin-meetings', () => {
8459
10298
 
8460
10299
  meeting.annotation.deregisterEvents = sinon.stub();
8461
10300
  webex.internal.llm.off = sinon.stub();
10301
+ webex.internal.mercury.off = sinon.stub();
10302
+ meeting.mercuryOnlineHandler = sinon.stub();
10303
+ meeting.mercuryOfflineHandler = sinon.stub();
8462
10304
 
8463
10305
  // A meeting needs to be joined to end
8464
10306
  meeting.meetingState = 'ACTIVE';
@@ -8481,6 +10323,66 @@ describe('plugin-meetings', () => {
8481
10323
  assert.calledOnce(meeting?.unsetPeerConnections);
8482
10324
  assert.calledOnce(meeting?.clearMeetingData);
8483
10325
  });
10326
+
10327
+ it('stops listening for LLM/Mercury and tears down transcription and annotation before calling Locus /end', async () => {
10328
+ const onlineHandler = meeting.mercuryOnlineHandler;
10329
+ const offlineHandler = meeting.mercuryOfflineHandler;
10330
+
10331
+ await meeting.endMeetingForAll();
10332
+
10333
+ // All llm/mercury consumers (direct listeners, voicea transcription,
10334
+ // annotation) must be detached before the /end request so that
10335
+ // in-flight events do not trigger unnecessary Locus syncs
10336
+ // (per Locus team recommendation).
10337
+ assert.callOrder(
10338
+ webex.internal.llm.off,
10339
+ webex.internal.mercury.off,
10340
+ meeting.stopTranscription,
10341
+ meeting.annotation.deregisterEvents,
10342
+ meeting.meetingRequest.endMeetingForAll
10343
+ );
10344
+ assert.calledWithExactly(
10345
+ webex.internal.llm.off,
10346
+ 'event:relay.event',
10347
+ meeting.processRelayEvent
10348
+ );
10349
+ assert.calledWithExactly(
10350
+ webex.internal.llm.off,
10351
+ LOCUS_LLM_EVENT,
10352
+ meeting.processLocusLLMEvent
10353
+ );
10354
+ assert.calledWithExactly(webex.internal.mercury.off, ONLINE, onlineHandler);
10355
+ assert.calledWithExactly(webex.internal.mercury.off, OFFLINE, offlineHandler);
10356
+ assert.isUndefined(meeting.mercuryOnlineHandler);
10357
+ assert.isUndefined(meeting.mercuryOfflineHandler);
10358
+ assert.calledOnceWithExactly(meeting.stopTranscription);
10359
+ assert.calledOnceWithExactly(meeting.annotation.deregisterEvents);
10360
+ });
10361
+
10362
+ it('tears down llm/mercury/transcription/annotation even when /end rejects', async () => {
10363
+ const onlineHandler = meeting.mercuryOnlineHandler;
10364
+ const offlineHandler = meeting.mercuryOfflineHandler;
10365
+ meeting.meetingRequest.endMeetingForAll = sinon
10366
+ .stub()
10367
+ .returns(Promise.reject(new Error('end failed')));
10368
+
10369
+ await meeting.endMeetingForAll().catch(() => {});
10370
+
10371
+ assert.calledWithExactly(
10372
+ webex.internal.llm.off,
10373
+ 'event:relay.event',
10374
+ meeting.processRelayEvent
10375
+ );
10376
+ assert.calledWithExactly(
10377
+ webex.internal.llm.off,
10378
+ LOCUS_LLM_EVENT,
10379
+ meeting.processLocusLLMEvent
10380
+ );
10381
+ assert.calledWithExactly(webex.internal.mercury.off, ONLINE, onlineHandler);
10382
+ assert.calledWithExactly(webex.internal.mercury.off, OFFLINE, offlineHandler);
10383
+ assert.calledOnceWithExactly(meeting.stopTranscription);
10384
+ assert.calledOnceWithExactly(meeting.annotation.deregisterEvents);
10385
+ });
8484
10386
  });
8485
10387
 
8486
10388
  describe('#moveTo', () => {
@@ -9262,7 +11164,9 @@ describe('plugin-meetings', () => {
9262
11164
  MediaCodecMimeType.OPUS,
9263
11165
  ['maxaveragebitrate', 'maxplaybackrate']
9264
11166
  );
9265
- assert.notCalled(meeting.sendSlotManager.getSlot(MediaType.AudioMain).setCustomCodecParameters);
11167
+ assert.notCalled(
11168
+ meeting.sendSlotManager.getSlot(MediaType.AudioMain).setCustomCodecParameters
11169
+ );
9266
11170
  });
9267
11171
  });
9268
11172
 
@@ -9990,6 +11894,8 @@ describe('plugin-meetings', () => {
9990
11894
  });
9991
11895
 
9992
11896
  it('handles REMOTE_SDP_ANSWER_PROCESSED correctly', () => {
11897
+ // capture the start timestamp before any fake timers are installed
11898
+ const localSdpGeneratedTimestamp = Date.now() - 100;
9993
11899
  const clock = sinon.useFakeTimers();
9994
11900
  sinon.spy(clock, 'clearTimeout');
9995
11901
  meeting.deferSDPAnswer = {
@@ -9997,24 +11903,29 @@ describe('plugin-meetings', () => {
9997
11903
  };
9998
11904
  meeting.sdpResponseTimer = '1234';
9999
11905
 
11906
+ // latency is computed as Date.now() - the stored local-sdp-generated timestamp,
11907
+ // so it is unaffected by any earlier remote-sdp-received timestamp saved on timeout
11908
+ webex.internal.newMetrics.callDiagnosticLatencies.latencyTimestamps = new Map([
11909
+ ['client.media-engine.local-sdp-generated', localSdpGeneratedTimestamp],
11910
+ ]);
11911
+
10000
11912
  eventListeners[MediaConnectionEventNames.REMOTE_SDP_ANSWER_PROCESSED]();
10001
11913
 
10002
11914
  assert.calledOnce(webex.internal.newMetrics.submitClientEvent);
10003
11915
  assert.calledWithMatch(webex.internal.newMetrics.submitClientEvent, {
10004
11916
  name: 'client.media-engine.remote-sdp-received',
11917
+ payload: {
11918
+ eventData: {
11919
+ localSDPGenRemoteSDPRecv: sinon.match(
11920
+ (value) => typeof value === 'number' && value >= 100 && value < 5000
11921
+ ),
11922
+ },
11923
+ },
10005
11924
  options: {meetingId: meeting.id},
10006
11925
  });
10007
11926
 
10008
- assert.calledOnce(Metrics.sendBehavioralMetric);
10009
- assert.calledWith(
10010
- Metrics.sendBehavioralMetric,
10011
- BEHAVIORAL_METRICS.ROAP_OFFER_TO_ANSWER_LATENCY,
10012
- {
10013
- correlation_id: meeting.correlationId,
10014
- meetingId: meeting.id,
10015
- latency: undefined,
10016
- }
10017
- );
11927
+ // the high-volume ROAP_OFFER_TO_ANSWER_LATENCY behavioral metric is no longer sent
11928
+ assert.notCalled(Metrics.sendBehavioralMetric);
10018
11929
 
10019
11930
  assert.calledOnce(meeting.deferSDPAnswer.resolve);
10020
11931
  assert.calledOnce(clock.clearTimeout);
@@ -10022,6 +11933,28 @@ describe('plugin-meetings', () => {
10022
11933
  assert.equal(meeting.sdpResponseTimer, undefined);
10023
11934
  });
10024
11935
 
11936
+ it('sends undefined localSDPGenRemoteSDPRecv when the local-sdp-generated timestamp is missing', () => {
11937
+ meeting.deferSDPAnswer = {
11938
+ resolve: sinon.stub(),
11939
+ };
11940
+
11941
+ // no local-sdp-generated timestamp stored -> latency cannot be computed
11942
+ webex.internal.newMetrics.callDiagnosticLatencies.latencyTimestamps = new Map();
11943
+
11944
+ eventListeners[MediaConnectionEventNames.REMOTE_SDP_ANSWER_PROCESSED]();
11945
+
11946
+ assert.calledOnce(webex.internal.newMetrics.submitClientEvent);
11947
+ assert.calledWithMatch(webex.internal.newMetrics.submitClientEvent, {
11948
+ name: 'client.media-engine.remote-sdp-received',
11949
+ payload: {
11950
+ eventData: {
11951
+ localSDPGenRemoteSDPRecv: undefined,
11952
+ },
11953
+ },
11954
+ options: {meetingId: meeting.id},
11955
+ });
11956
+ });
11957
+
10025
11958
  it('handles LOCAL_SDP_OFFER_GENERATED correctly', () => {
10026
11959
  assert.equal(meeting.deferSDPAnswer, undefined);
10027
11960
 
@@ -10417,16 +12350,16 @@ describe('plugin-meetings', () => {
10417
12350
  );
10418
12351
  done();
10419
12352
  });
10420
- it('listens to the self admitted guest event without blocking on token prefetch', async () => {
12353
+ it('listens to the self admitted guest event and waits for token prefetch before reconnecting LLM', async () => {
10421
12354
  meeting.stopKeepAlive = sinon.stub();
10422
12355
  meeting.updateLLMConnection = sinon.stub();
10423
12356
  let resolvePrefetch;
10424
12357
 
10425
- meeting.ensureDefaultDatachannelTokenAfterAdmit = sinon
10426
- .stub()
10427
- .returns(new Promise((resolve) => {
12358
+ meeting.ensureDefaultDatachannelTokenAfterAdmit = sinon.stub().returns(
12359
+ new Promise((resolve) => {
10428
12360
  resolvePrefetch = resolve;
10429
- }));
12361
+ })
12362
+ );
10430
12363
  meeting.rtcMetrics = {
10431
12364
  sendNextMetrics: sinon.stub(),
10432
12365
  };
@@ -10443,7 +12376,7 @@ describe('plugin-meetings', () => {
10443
12376
  'meeting:self:guestAdmitted',
10444
12377
  {payload: test1}
10445
12378
  );
10446
- assert.calledOnce(meeting.updateLLMConnection);
12379
+ assert.notCalled(meeting.updateLLMConnection);
10447
12380
  assert.calledOnceWithExactly(meeting.rtcMetrics.sendNextMetrics);
10448
12381
 
10449
12382
  assert.calledOnceWithExactly(
@@ -10456,6 +12389,7 @@ describe('plugin-meetings', () => {
10456
12389
 
10457
12390
  resolvePrefetch(false);
10458
12391
  await Promise.resolve();
12392
+ await Promise.resolve();
10459
12393
 
10460
12394
  assert.calledOnce(meeting.updateLLMConnection);
10461
12395
  });
@@ -10971,6 +12905,106 @@ describe('plugin-meetings', () => {
10971
12905
  );
10972
12906
  });
10973
12907
 
12908
+ const recordingTestCases = [
12909
+ {
12910
+ description: 'triggers MEETING_STARTED_RECORDING when state is RECORDING',
12911
+ state: RECORDING_STATE.RECORDING,
12912
+ expectedEvent: EVENT_TRIGGERS.MEETING_STARTED_RECORDING,
12913
+ expectedRecordingState: RECORDING_STATE.RECORDING,
12914
+ },
12915
+ {
12916
+ description: 'triggers MEETING_STOPPED_RECORDING when state is IDLE',
12917
+ state: RECORDING_STATE.IDLE,
12918
+ expectedEvent: EVENT_TRIGGERS.MEETING_STOPPED_RECORDING,
12919
+ expectedRecordingState: RECORDING_STATE.IDLE,
12920
+ },
12921
+ {
12922
+ description: 'triggers MEETING_PAUSED_RECORDING when state is PAUSED',
12923
+ state: RECORDING_STATE.PAUSED,
12924
+ expectedEvent: EVENT_TRIGGERS.MEETING_PAUSED_RECORDING,
12925
+ expectedRecordingState: RECORDING_STATE.PAUSED,
12926
+ },
12927
+ {
12928
+ description:
12929
+ 'triggers MEETING_RESUMED_RECORDING and sets state to RECORDING when state is RESUMED',
12930
+ state: RECORDING_STATE.RESUMED,
12931
+ expectedEvent: EVENT_TRIGGERS.MEETING_RESUMED_RECORDING,
12932
+ expectedRecordingState: RECORDING_STATE.RECORDING,
12933
+ },
12934
+ ];
12935
+
12936
+ recordingTestCases.forEach(
12937
+ ({description, state, expectedEvent, expectedRecordingState}) => {
12938
+ it(`listens to CONTROLS_RECORDING_UPDATED - ${description}`, async () => {
12939
+ const modifiedBy = 'user-id-123';
12940
+ const lastModified = '2026-01-01T00:00:00Z';
12941
+
12942
+ await meeting.locusInfo.emitScoped(
12943
+ {function: 'test', file: 'test'},
12944
+ LOCUSINFO.EVENTS.CONTROLS_RECORDING_UPDATED,
12945
+ {
12946
+ state,
12947
+ modifiedBy,
12948
+ lastModified,
12949
+ modifiedByServiceAppName: undefined,
12950
+ modifiedByServiceAppId: undefined,
12951
+ }
12952
+ );
12953
+
12954
+ assert.deepEqual(meeting.recording, {
12955
+ state: expectedRecordingState,
12956
+ modifiedBy,
12957
+ lastModified,
12958
+ modifiedByServiceAppName: undefined,
12959
+ modifiedByServiceAppId: undefined,
12960
+ });
12961
+
12962
+ assert.calledWith(
12963
+ TriggerProxy.trigger,
12964
+ meeting,
12965
+ {file: 'meeting/index', function: 'setupLocusControlsListener'},
12966
+ expectedEvent,
12967
+ meeting.recording
12968
+ );
12969
+ });
12970
+ }
12971
+ );
12972
+
12973
+ it('listens to CONTROLS_RECORDING_UPDATED and includes modifiedByServiceAppName and modifiedByServiceAppId when present', async () => {
12974
+ const modifiedBy = 'user-id-123';
12975
+ const lastModified = '2026-01-01T00:00:00Z';
12976
+ const modifiedByServiceAppName = 'My Bot';
12977
+ const modifiedByServiceAppId = 'app-id-123';
12978
+
12979
+ await meeting.locusInfo.emitScoped(
12980
+ {function: 'test', file: 'test'},
12981
+ LOCUSINFO.EVENTS.CONTROLS_RECORDING_UPDATED,
12982
+ {
12983
+ state: RECORDING_STATE.RECORDING,
12984
+ modifiedBy,
12985
+ lastModified,
12986
+ modifiedByServiceAppName,
12987
+ modifiedByServiceAppId,
12988
+ }
12989
+ );
12990
+
12991
+ assert.deepEqual(meeting.recording, {
12992
+ state: RECORDING_STATE.RECORDING,
12993
+ modifiedBy,
12994
+ lastModified,
12995
+ modifiedByServiceAppName,
12996
+ modifiedByServiceAppId,
12997
+ });
12998
+
12999
+ assert.calledWith(
13000
+ TriggerProxy.trigger,
13001
+ meeting,
13002
+ {file: 'meeting/index', function: 'setupLocusControlsListener'},
13003
+ EVENT_TRIGGERS.MEETING_STARTED_RECORDING,
13004
+ meeting.recording
13005
+ );
13006
+ });
13007
+
10974
13008
  it('listens to the locus interpretation update event', () => {
10975
13009
  const interpretation = {
10976
13010
  siLanguages: [{languageCode: 20, languageName: 'en'}],
@@ -11024,6 +13058,7 @@ describe('plugin-meetings', () => {
11024
13058
  meeting.annotation.locusUrlUpdate = sinon.stub();
11025
13059
  meeting.simultaneousInterpretation.locusUrlUpdate = sinon.stub();
11026
13060
  meeting.webinar.locusUrlUpdate = sinon.stub();
13061
+ meeting.aiEnableRequest.locusUrlUpdate = sinon.stub();
11027
13062
 
11028
13063
  meeting.locusInfo.emit(
11029
13064
  {function: 'test', file: 'test'},
@@ -11038,6 +13073,7 @@ describe('plugin-meetings', () => {
11038
13073
  assert.calledWith(meeting.controlsOptionsManager.setLocusUrl, newLocusUrl, false);
11039
13074
  assert.calledWith(meeting.simultaneousInterpretation.locusUrlUpdate, newLocusUrl);
11040
13075
  assert.calledWith(meeting.webinar.locusUrlUpdate, newLocusUrl);
13076
+ assert.calledWith(meeting.aiEnableRequest.locusUrlUpdate, newLocusUrl);
11041
13077
  assert.equal(meeting.locusUrl, newLocusUrl);
11042
13078
  assert(meeting.locusId, '12345');
11043
13079
 
@@ -11353,6 +13389,109 @@ describe('plugin-meetings', () => {
11353
13389
  });
11354
13390
  });
11355
13391
 
13392
+ describe('#finalizeMeetingAfterInitialLocusSetup', () => {
13393
+ it('refreshes destination from synced locus when destination type is LOCUS_ID', () => {
13394
+ const syncedLocus = {url: 'https://locus.example.com/locus/123', info: {topic: 'x'}};
13395
+
13396
+ meeting.destinationType = DESTINATION_TYPE.LOCUS_ID;
13397
+ meeting.destination = {info: {topic: 'old'}};
13398
+
13399
+ meeting.finalizeMeetingAfterInitialLocusSetup(syncedLocus);
13400
+
13401
+ assert.equal(meeting.destination, syncedLocus);
13402
+ });
13403
+
13404
+ it('does not refresh destination when destination type is not LOCUS_ID', () => {
13405
+ const syncedLocus = {url: 'https://locus.example.com/locus/123', info: {topic: 'x'}};
13406
+ const originalDestination = {destination: 'original-destination'};
13407
+
13408
+ meeting.destinationType = DESTINATION_TYPE.CONVERSATION_URL;
13409
+ meeting.destination = originalDestination;
13410
+
13411
+ meeting.finalizeMeetingAfterInitialLocusSetup(syncedLocus);
13412
+
13413
+ assert.equal(meeting.destination, originalDestination);
13414
+ });
13415
+
13416
+ it('fetches meeting info when meetingInfo is empty and destination has info', () => {
13417
+ const fetchMeetingInfoStub = sinon.stub(meeting, 'fetchMeetingInfo').resolves();
13418
+
13419
+ meeting.meetingInfo = {};
13420
+ meeting.destination = {url: 'https://locus.example.com/locus/123', info: {topic: 'x'}};
13421
+
13422
+ meeting.finalizeMeetingAfterInitialLocusSetup({});
13423
+
13424
+ assert.calledOnceWithExactly(fetchMeetingInfoStub, {});
13425
+ });
13426
+
13427
+ it('does not fetch meeting info when destination has no info', () => {
13428
+ const fetchMeetingInfoStub = sinon.stub(meeting, 'fetchMeetingInfo').resolves();
13429
+
13430
+ meeting.meetingInfo = {};
13431
+ meeting.destination = {url: 'https://locus.example.com/locus/123'};
13432
+
13433
+ meeting.finalizeMeetingAfterInitialLocusSetup({});
13434
+
13435
+ assert.notCalled(fetchMeetingInfoStub);
13436
+ });
13437
+
13438
+ it('does not fetch meeting info when meetingInfo is already populated', () => {
13439
+ const fetchMeetingInfoStub = sinon.stub(meeting, 'fetchMeetingInfo').resolves();
13440
+
13441
+ meeting.meetingInfo = {meetingJoinUrl: 'https://example.com/join/abc'};
13442
+ meeting.destination = {url: 'https://locus.example.com/locus/123', info: {topic: 'x'}};
13443
+
13444
+ meeting.finalizeMeetingAfterInitialLocusSetup({});
13445
+
13446
+ assert.notCalled(fetchMeetingInfoStub);
13447
+ });
13448
+
13449
+ it('does not fetch meeting info when delayed fetch timer is already scheduled', () => {
13450
+ const fetchMeetingInfoStub = sinon.stub(meeting, 'fetchMeetingInfo').resolves();
13451
+
13452
+ meeting.meetingInfo = {};
13453
+ meeting.destination = {url: 'https://locus.example.com/locus/123', info: {topic: 'x'}};
13454
+ meeting.fetchMeetingInfoTimeoutId = 42;
13455
+
13456
+ meeting.finalizeMeetingAfterInitialLocusSetup({});
13457
+
13458
+ assert.notCalled(fetchMeetingInfoStub);
13459
+ });
13460
+
13461
+ ['CALL', 'SIP_BRIDGE', 'SPACE_SHARE'].forEach((fullStateType) => {
13462
+ it(`does not fetch meeting info when destination is a 1:1 call (fullState.type ${fullStateType})`, () => {
13463
+ const fetchMeetingInfoStub = sinon.stub(meeting, 'fetchMeetingInfo').resolves();
13464
+
13465
+ meeting.meetingInfo = {};
13466
+ meeting.destination = {
13467
+ url: 'https://locus.example.com/locus/123',
13468
+ info: {topic: 'x'},
13469
+ };
13470
+
13471
+ meeting.finalizeMeetingAfterInitialLocusSetup({fullState: {type: fullStateType}});
13472
+
13473
+ assert.notCalled(fetchMeetingInfoStub);
13474
+ });
13475
+ });
13476
+
13477
+ it('swallows async fetchMeetingInfo errors and logs info', async () => {
13478
+ const error = new Error('fetch failed');
13479
+
13480
+ meeting.meetingInfo = {};
13481
+ meeting.destination = {url: 'https://locus.example.com/locus/123', info: {topic: 'x'}};
13482
+ sinon.stub(meeting, 'fetchMeetingInfo').returns(Promise.reject(error));
13483
+ const loggerInfoStub = sinon.stub(LoggerProxy.logger, 'info');
13484
+
13485
+ await meeting.finalizeMeetingAfterInitialLocusSetup({});
13486
+
13487
+ assert.calledOnce(loggerInfoStub);
13488
+ assert.match(
13489
+ loggerInfoStub.firstCall.args[0],
13490
+ /Meeting:index#finalizeMeetingAfterInitialLocusSetup --> deferred fetchMeetingInfo failed: fetch failed/
13491
+ );
13492
+ });
13493
+ });
13494
+
11356
13495
  describe('#emailInput', () => {
11357
13496
  it('should set the email input', () => {
11358
13497
  assert.notOk(meeting.emailInput);
@@ -11955,6 +14094,7 @@ describe('plugin-meetings', () => {
11955
14094
  let showAutoEndMeetingWarningSpy;
11956
14095
  let canAttendeeRequestAiAssistantEnabledSpy;
11957
14096
  let attendeeRequestAiAssistantDeclinedAllSpy;
14097
+ let isAnonymizeDisplayNamesEnabledSpy;
11958
14098
  // Due to import tree issues, hasHints must be stubed within the scope of the `it`.
11959
14099
 
11960
14100
  beforeEach(() => {
@@ -12003,6 +14143,10 @@ describe('plugin-meetings', () => {
12003
14143
  MeetingUtil,
12004
14144
  'attendeeRequestAiAssistantDeclinedAll'
12005
14145
  );
14146
+ isAnonymizeDisplayNamesEnabledSpy = sinon.spy(
14147
+ MeetingUtil,
14148
+ 'isAnonymizeDisplayNamesEnabled'
14149
+ );
12006
14150
  });
12007
14151
 
12008
14152
  afterEach(() => {
@@ -12011,6 +14155,7 @@ describe('plugin-meetings', () => {
12011
14155
  showAutoEndMeetingWarningSpy.restore();
12012
14156
  canAttendeeRequestAiAssistantEnabledSpy.restore();
12013
14157
  attendeeRequestAiAssistantDeclinedAllSpy.restore();
14158
+ isAnonymizeDisplayNamesEnabledSpy.restore();
12014
14159
  });
12015
14160
 
12016
14161
  forEach(
@@ -12568,6 +14713,7 @@ describe('plugin-meetings', () => {
12568
14713
  meeting.roles
12569
14714
  );
12570
14715
  assert.calledWith(attendeeRequestAiAssistantDeclinedAllSpy, userDisplayHints);
14716
+ assert.calledWith(isAnonymizeDisplayNamesEnabledSpy, userDisplayHints);
12571
14717
 
12572
14718
  assert.calledWith(ControlsOptionsUtil.hasHints, {
12573
14719
  requiredHints: [DISPLAY_HINTS.MUTE_ALL],
@@ -12782,6 +14928,10 @@ describe('plugin-meetings', () => {
12782
14928
  describe('#saveDataChannelToken', () => {
12783
14929
  beforeEach(() => {
12784
14930
  webex.internal.llm.setDatachannelToken = sinon.stub();
14931
+ webex.internal.llm.resolveSessionOwnership = sinon
14932
+ .stub()
14933
+ .returns({currentOwner: undefined, isOwner: true});
14934
+ webex.internal.llm.isConnected = sinon.stub().returns(false);
12785
14935
  });
12786
14936
 
12787
14937
  it('saves datachannelToken into LLM as Default', () => {
@@ -12794,7 +14944,8 @@ describe('plugin-meetings', () => {
12794
14944
  assert.calledWithExactly(
12795
14945
  webex.internal.llm.setDatachannelToken,
12796
14946
  'default-token',
12797
- 'llm-default-session'
14947
+ 'llm-default-session',
14948
+ meeting.id
12798
14949
  );
12799
14950
  });
12800
14951
 
@@ -12808,7 +14959,8 @@ describe('plugin-meetings', () => {
12808
14959
  assert.calledWithExactly(
12809
14960
  webex.internal.llm.setDatachannelToken,
12810
14961
  'ps-token',
12811
- 'llm-practice-session'
14962
+ 'llm-practice-session',
14963
+ meeting.id
12812
14964
  );
12813
14965
  });
12814
14966
 
@@ -12826,12 +14978,14 @@ describe('plugin-meetings', () => {
12826
14978
  assert.calledWithExactly(
12827
14979
  webex.internal.llm.setDatachannelToken,
12828
14980
  'default-token',
12829
- 'llm-default-session'
14981
+ 'llm-default-session',
14982
+ meeting.id
12830
14983
  );
12831
14984
  assert.calledWithExactly(
12832
14985
  webex.internal.llm.setDatachannelToken,
12833
14986
  'ps-token',
12834
- 'llm-practice-session'
14987
+ 'llm-practice-session',
14988
+ meeting.id
12835
14989
  );
12836
14990
  });
12837
14991
 
@@ -12850,19 +15004,44 @@ describe('plugin-meetings', () => {
12850
15004
  it('handles missing locus.self gracefully', () => {
12851
15005
  meeting.saveDataChannelToken({locus: {}});
12852
15006
 
12853
- assert.notCalled(webex.internal.llm.setDatachannelToken);
15007
+ assert.notCalled(webex.internal.llm.setDatachannelToken);
15008
+ });
15009
+
15010
+ it('writes token with meeting id as owner', () => {
15011
+ meeting.saveDataChannelToken({
15012
+ locus: {
15013
+ self: {datachannelToken: 'default-token'},
15014
+ },
15015
+ });
15016
+
15017
+ assert.calledOnceWithExactly(
15018
+ webex.internal.llm.setDatachannelToken,
15019
+ 'default-token',
15020
+ 'llm-default-session',
15021
+ meeting.id
15022
+ );
12854
15023
  });
12855
15024
  });
12856
15025
 
12857
15026
  describe('#clearDataChannelToken', () => {
12858
15027
  beforeEach(() => {
12859
- webex.internal.llm.resetDatachannelTokens = sinon.stub();
15028
+ webex.internal.llm.clearDatachannelToken = sinon.stub();
12860
15029
  });
12861
15030
 
12862
- it('calls resetDatachannelTokens on LLM', () => {
15031
+ it('delegates default and practice token clears to llm with meeting ownership id', () => {
12863
15032
  meeting.clearDataChannelToken();
12864
15033
 
12865
- assert.calledOnce(webex.internal.llm.resetDatachannelTokens);
15034
+ assert.calledWithExactly(
15035
+ webex.internal.llm.clearDatachannelToken,
15036
+ 'llm-default-session',
15037
+ meeting.id
15038
+ );
15039
+ assert.calledWithExactly(
15040
+ webex.internal.llm.clearDatachannelToken,
15041
+ 'llm-practice-session',
15042
+ meeting.id
15043
+ );
15044
+ assert.callCount(webex.internal.llm.clearDatachannelToken, 2);
12866
15045
  });
12867
15046
  });
12868
15047
 
@@ -12872,6 +15051,7 @@ describe('plugin-meetings', () => {
12872
15051
  webex.internal.llm.getLocusUrl = sinon.stub();
12873
15052
  webex.internal.llm.getDatachannelUrl = sinon.stub();
12874
15053
  webex.internal.llm.registerAndConnect = sinon.stub().resolves('something');
15054
+ webex.internal.llm.setRefreshHandler = sinon.stub();
12875
15055
  webex.internal.llm.disconnectLLM = sinon.stub().resolves();
12876
15056
  webex.internal.llm.on = sinon.stub();
12877
15057
  webex.internal.llm.off = sinon.stub();
@@ -12889,7 +15069,11 @@ describe('plugin-meetings', () => {
12889
15069
  meeting.joinedWith = {state: 'any other state'};
12890
15070
  webex.internal.llm.getLocusUrl.returns('a url');
12891
15071
 
12892
- meeting.locusInfo = {url: 'a url', info: {datachannelUrl: 'a datachannel url'}};
15072
+ meeting.locusInfo = {
15073
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
15074
+ url: 'a url',
15075
+ info: {datachannelUrl: 'a datachannel url'},
15076
+ };
12893
15077
 
12894
15078
  const result = await meeting.updateLLMConnection();
12895
15079
 
@@ -12901,6 +15085,7 @@ describe('plugin-meetings', () => {
12901
15085
  it('returns undefined if llm is already connected and the locus url is unchanged', async () => {
12902
15086
  meeting.joinedWith = {state: 'JOINED'};
12903
15087
  meeting.locusInfo = {
15088
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
12904
15089
  url: 'a url',
12905
15090
  info: {datachannelUrl: 'a datachannel url'},
12906
15091
  };
@@ -12937,7 +15122,11 @@ describe('plugin-meetings', () => {
12937
15122
  });
12938
15123
  it('connects if not already connected', async () => {
12939
15124
  meeting.joinedWith = {state: 'JOINED'};
12940
- meeting.locusInfo = {url: 'a url', info: {datachannelUrl: 'a datachannel url'}};
15125
+ meeting.locusInfo = {
15126
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
15127
+ url: 'a url',
15128
+ info: {datachannelUrl: 'a datachannel url'},
15129
+ };
12941
15130
 
12942
15131
  const result = await meeting.updateLLMConnection();
12943
15132
 
@@ -12948,7 +15137,14 @@ describe('plugin-meetings', () => {
12948
15137
  'a datachannel url',
12949
15138
  undefined
12950
15139
  );
15140
+ assert.calledOnceWithExactly(
15141
+ webex.internal.llm.setRefreshHandler,
15142
+ sinon.match.func,
15143
+ 'llm-default-session',
15144
+ meeting.id
15145
+ );
12951
15146
  assert.equal(result, 'something');
15147
+ assert.calledOnceWithExactly(meeting.locusInfo.syncAllHashTreeDatasets, {onlyLLM: true});
12952
15148
  });
12953
15149
  it('disconnects if the locus url has changed', async () => {
12954
15150
  meeting.joinedWith = {state: 'JOINED'};
@@ -12957,6 +15153,7 @@ describe('plugin-meetings', () => {
12957
15153
  webex.internal.llm.getLocusUrl.returns('a url');
12958
15154
 
12959
15155
  meeting.locusInfo = {
15156
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
12960
15157
  url: 'a different url',
12961
15158
  info: {datachannelUrl: 'a datachannel url'},
12962
15159
  self: {},
@@ -12964,10 +15161,15 @@ describe('plugin-meetings', () => {
12964
15161
 
12965
15162
  const result = await meeting.updateLLMConnection();
12966
15163
 
12967
- assert.calledWithExactly(webex.internal.llm.disconnectLLM, {
12968
- code: 3050,
12969
- reason: 'done (permanent)',
12970
- });
15164
+ assert.calledWithExactly(
15165
+ webex.internal.llm.disconnectLLM,
15166
+ {
15167
+ code: 3050,
15168
+ reason: 'done (permanent)',
15169
+ },
15170
+ 'llm-default-session',
15171
+ meeting.id
15172
+ );
12971
15173
 
12972
15174
  assert.calledWithExactly(
12973
15175
  webex.internal.llm.registerAndConnect,
@@ -13010,6 +15212,7 @@ describe('plugin-meetings', () => {
13010
15212
  webex.internal.llm.getLocusUrl.returns('a url');
13011
15213
 
13012
15214
  meeting.locusInfo = {
15215
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
13013
15216
  url: 'a url',
13014
15217
  info: {datachannelUrl: 'a different datachannel url'},
13015
15218
  self: {},
@@ -13017,10 +15220,15 @@ describe('plugin-meetings', () => {
13017
15220
 
13018
15221
  const result = await meeting.updateLLMConnection();
13019
15222
 
13020
- assert.calledWithExactly(webex.internal.llm.disconnectLLM, {
13021
- code: 3050,
13022
- reason: 'done (permanent)',
13023
- });
15223
+ assert.calledWithExactly(
15224
+ webex.internal.llm.disconnectLLM,
15225
+ {
15226
+ code: 3050,
15227
+ reason: 'done (permanent)',
15228
+ },
15229
+ 'llm-default-session',
15230
+ meeting.id
15231
+ );
13024
15232
 
13025
15233
  assert.calledWithExactly(
13026
15234
  webex.internal.llm.registerAndConnect,
@@ -13061,14 +15269,23 @@ describe('plugin-meetings', () => {
13061
15269
  webex.internal.llm.isConnected.returns(true);
13062
15270
  webex.internal.llm.getLocusUrl.returns('a url');
13063
15271
 
13064
- meeting.locusInfo = {url: 'a url', info: {datachannelUrl: 'a datachannel url'}};
15272
+ meeting.locusInfo = {
15273
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
15274
+ url: 'a url',
15275
+ info: {datachannelUrl: 'a datachannel url'},
15276
+ };
13065
15277
 
13066
15278
  const result = await meeting.updateLLMConnection();
13067
15279
 
13068
- assert.calledWith(webex.internal.llm.disconnectLLM, {
13069
- code: 3050,
13070
- reason: 'done (permanent)',
13071
- });
15280
+ assert.calledWith(
15281
+ webex.internal.llm.disconnectLLM,
15282
+ {
15283
+ code: 3050,
15284
+ reason: 'done (permanent)',
15285
+ },
15286
+ 'llm-default-session',
15287
+ meeting.id
15288
+ );
13072
15289
  assert.notCalled(webex.internal.llm.registerAndConnect);
13073
15290
  assert.equal(result, undefined);
13074
15291
  assert.isFalse(
@@ -13084,6 +15301,7 @@ describe('plugin-meetings', () => {
13084
15301
  webex.internal.llm.disconnectLLM.rejects(disconnectError);
13085
15302
 
13086
15303
  meeting.locusInfo = {
15304
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
13087
15305
  url: 'a different url',
13088
15306
  info: {datachannelUrl: 'a datachannel url'},
13089
15307
  self: {},
@@ -13115,6 +15333,7 @@ describe('plugin-meetings', () => {
13115
15333
  it('still need connect main session data channel when PS started', async () => {
13116
15334
  meeting.joinedWith = {state: 'JOINED'};
13117
15335
  meeting.locusInfo = {
15336
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
13118
15337
  url: 'a url',
13119
15338
  info: {
13120
15339
  datachannelUrl: 'a datachannel url',
@@ -13135,11 +15354,14 @@ describe('plugin-meetings', () => {
13135
15354
  it('passes dataChannelToken from LLM to registerAndConnect', async () => {
13136
15355
  meeting.joinedWith = {state: 'JOINED'};
13137
15356
  meeting.locusInfo = {
15357
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
13138
15358
  url: 'a url',
13139
15359
  info: {datachannelUrl: 'a datachannel url'},
13140
15360
  };
13141
15361
 
13142
- webex.internal.llm.getDatachannelToken.withArgs('llm-default-session').returns('token-123');
15362
+ webex.internal.llm.getDatachannelToken
15363
+ .withArgs('llm-default-session', meeting.id)
15364
+ .returns('token-123');
13143
15365
 
13144
15366
  await meeting.updateLLMConnection();
13145
15367
 
@@ -13154,6 +15376,7 @@ describe('plugin-meetings', () => {
13154
15376
  it('passes undefined token when LLM has no token stored', async () => {
13155
15377
  meeting.joinedWith = {state: 'JOINED'};
13156
15378
  meeting.locusInfo = {
15379
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
13157
15380
  url: 'a url',
13158
15381
  info: {datachannelUrl: 'a datachannel url'},
13159
15382
  };
@@ -13175,6 +15398,7 @@ describe('plugin-meetings', () => {
13175
15398
  it('does not pass token when data channel with jwt token is disabled', async () => {
13176
15399
  meeting.joinedWith = {state: 'JOINED'};
13177
15400
  meeting.locusInfo = {
15401
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
13178
15402
  url: 'a url',
13179
15403
  info: {datachannelUrl: 'a datachannel url'},
13180
15404
  };
@@ -13193,6 +15417,209 @@ describe('plugin-meetings', () => {
13193
15417
  assert.notCalled(webex.internal.llm.setDatachannelToken);
13194
15418
  });
13195
15419
 
15420
+ describe('ownership tag', () => {
15421
+ beforeEach(() => {
15422
+ // Make the owner stub dynamic so setOwnerMeetingId() writes
15423
+ // propagate back to getOwnerMeetingId() reads. This mirrors the
15424
+ // real LLM singleton behavior so the finally-block release in
15425
+ // cleanupLLMConneciton is reflected in subsequent reads.
15426
+ webex.internal.llm.getOwnerMeetingId = sinon.stub().returns(undefined);
15427
+ webex.internal.llm.setOwnerMeetingId = sinon.stub().callsFake((id) => {
15428
+ webex.internal.llm.getOwnerMeetingId.returns(id);
15429
+ });
15430
+ });
15431
+
15432
+ it('skips disconnect and reconnect when LLM is connected and owned by another meeting (regardless of URL)', async () => {
15433
+ meeting.joinedWith = {state: 'JOINED'};
15434
+ webex.internal.llm.isConnected.returns(true);
15435
+ webex.internal.llm.getOwnerMeetingId.returns('some-other-meeting-id');
15436
+ // Locus/datachannel URL mismatch is the *normal* case when
15437
+ // another meeting owns the live socket -- each meeting has its
15438
+ // own locus URL. URL mismatch must NOT trigger a reclaim,
15439
+ // because doing so would tear down the owning meeting's healthy
15440
+ // LLM socket and break its data channel.
15441
+ webex.internal.llm.getLocusUrl.returns('owner-locus-url');
15442
+ webex.internal.llm.getDatachannelUrl.returns('owner-dc-url');
15443
+ meeting.locusInfo = {
15444
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
15445
+ url: 'a different url',
15446
+ info: {datachannelUrl: 'a different datachannel url'},
15447
+ self: {},
15448
+ };
15449
+
15450
+ const result = await meeting.updateLLMConnection();
15451
+
15452
+ assert.equal(result, undefined);
15453
+ assert.notCalled(webex.internal.llm.disconnectLLM);
15454
+ assert.notCalled(webex.internal.llm.registerAndConnect);
15455
+ assert.notCalled(webex.internal.llm.setOwnerMeetingId);
15456
+ assert.notCalled(meeting.startLLMHealthCheckTimer);
15457
+ });
15458
+
15459
+ it('clears stale owner tag in cleanup finally block even when disconnectLLM rejects', async () => {
15460
+ meeting.joinedWith = {state: 'JOINED'};
15461
+ webex.internal.llm.isConnected.returns(true);
15462
+ webex.internal.llm.getOwnerMeetingId.returns(meeting.id);
15463
+ webex.internal.llm.getLocusUrl.returns('a url');
15464
+ webex.internal.llm.getDatachannelUrl.returns('a datachannel url');
15465
+ webex.internal.llm.disconnectLLM.rejects(new Error('disconnect failed'));
15466
+ meeting.locusInfo = {
15467
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
15468
+ url: 'a different url',
15469
+ info: {datachannelUrl: 'a datachannel url'},
15470
+ self: {},
15471
+ };
15472
+
15473
+ try {
15474
+ await meeting.updateLLMConnection();
15475
+ } catch (e) {
15476
+ /* updateLLMConnection may reject when cleanup throws */
15477
+ }
15478
+
15479
+ // The owner-eligible finally branch must release the tag so a
15480
+ // subsequent reconnect attempt from any meeting is not blocked.
15481
+ assert.calledWith(webex.internal.llm.setOwnerMeetingId, undefined);
15482
+ });
15483
+
15484
+ it('does not clear owner tag when ownership changes during cleanup disconnect await', async () => {
15485
+ meeting.joinedWith = {state: 'JOINED'};
15486
+ webex.internal.llm.isConnected.returns(true);
15487
+ webex.internal.llm.getOwnerMeetingId.returns(meeting.id);
15488
+ webex.internal.llm.getLocusUrl.returns('a url');
15489
+ webex.internal.llm.getDatachannelUrl.returns('a datachannel url');
15490
+ webex.internal.llm.disconnectLLM.callsFake(async () => {
15491
+ webex.internal.llm.getOwnerMeetingId.returns('new-owner-id');
15492
+ throw new Error('disconnect failed');
15493
+ });
15494
+ meeting.locusInfo = {
15495
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
15496
+ url: 'a different url',
15497
+ info: {datachannelUrl: 'a datachannel url'},
15498
+ self: {},
15499
+ };
15500
+
15501
+ try {
15502
+ await meeting.updateLLMConnection();
15503
+ } catch (e) {
15504
+ /* updateLLMConnection may reject when cleanup throws */
15505
+ }
15506
+
15507
+ assert.notCalled(webex.internal.llm.setOwnerMeetingId);
15508
+ assert.equal(webex.internal.llm.getOwnerMeetingId(), 'new-owner-id');
15509
+ });
15510
+
15511
+ it('proceeds normally when LLM is connected and owned by this meeting with URL change', async () => {
15512
+ meeting.joinedWith = {state: 'JOINED'};
15513
+ webex.internal.llm.isConnected.returns(true);
15514
+ webex.internal.llm.getOwnerMeetingId.returns(meeting.id);
15515
+ webex.internal.llm.getLocusUrl.returns('a url');
15516
+ webex.internal.llm.getDatachannelUrl.returns('a datachannel url');
15517
+ meeting.locusInfo = {
15518
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
15519
+ url: 'a different url',
15520
+ info: {datachannelUrl: 'a datachannel url'},
15521
+ self: {},
15522
+ };
15523
+
15524
+ await meeting.updateLLMConnection();
15525
+
15526
+ assert.calledOnceWithExactly(
15527
+ webex.internal.llm.disconnectLLM,
15528
+ {
15529
+ code: 3050,
15530
+ reason: 'done (permanent)',
15531
+ },
15532
+ 'llm-default-session',
15533
+ meeting.id
15534
+ );
15535
+ assert.calledWithExactly(
15536
+ webex.internal.llm.registerAndConnect,
15537
+ 'a different url',
15538
+ 'a datachannel url',
15539
+ undefined
15540
+ );
15541
+ // setOwnerMeetingId is called twice: first with undefined in
15542
+ // cleanupLLMConneciton's finally block (so a failed disconnect
15543
+ // cannot leave a stale owner), then with this meeting's id
15544
+ // after registerAndConnect resolves.
15545
+ assert.calledTwice(webex.internal.llm.setOwnerMeetingId);
15546
+ assert.calledWith(webex.internal.llm.setOwnerMeetingId.firstCall, undefined);
15547
+ assert.calledWith(webex.internal.llm.setOwnerMeetingId.lastCall, meeting.id);
15548
+ });
15549
+
15550
+ it('claims ownership after successful registerAndConnect on initial connect', async () => {
15551
+ meeting.joinedWith = {state: 'JOINED'};
15552
+ webex.internal.llm.isConnected.returns(false);
15553
+ webex.internal.llm.getOwnerMeetingId.returns(undefined);
15554
+ meeting.locusInfo = {
15555
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
15556
+ url: 'a url',
15557
+ info: {datachannelUrl: 'a datachannel url'},
15558
+ };
15559
+
15560
+ await meeting.updateLLMConnection();
15561
+
15562
+ assert.calledOnce(webex.internal.llm.registerAndConnect);
15563
+ assert.calledOnceWithExactly(
15564
+ webex.internal.llm.setRefreshHandler,
15565
+ sinon.match.func,
15566
+ 'llm-default-session',
15567
+ meeting.id
15568
+ );
15569
+ assert.calledOnceWithExactly(webex.internal.llm.setOwnerMeetingId, meeting.id);
15570
+ });
15571
+
15572
+ it('proceeds to connect when LLM is not connected even if another ownerId lingers', async () => {
15573
+ // Defensive path: if the LLM reports not-connected but an old
15574
+ // ownerId is still present (e.g. race before a successful
15575
+ // connections.delete), this meeting can still claim a fresh
15576
+ // connection.
15577
+ meeting.joinedWith = {state: 'JOINED'};
15578
+ webex.internal.llm.isConnected.returns(false);
15579
+ webex.internal.llm.getOwnerMeetingId.returns('stale-owner-id');
15580
+ webex.internal.llm.getDatachannelToken.onFirstCall().returns(undefined);
15581
+ webex.internal.llm.getDatachannelToken.onSecondCall().returns('recovered-token');
15582
+ meeting.locusInfo = {
15583
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
15584
+ url: 'a url',
15585
+ info: {datachannelUrl: 'a datachannel url'},
15586
+ };
15587
+
15588
+ await meeting.updateLLMConnection();
15589
+
15590
+ assert.calledTwice(webex.internal.llm.getDatachannelToken);
15591
+ assert.calledWithExactly(
15592
+ webex.internal.llm.getDatachannelToken.firstCall,
15593
+ 'llm-default-session',
15594
+ meeting.id
15595
+ );
15596
+ assert.calledWithExactly(
15597
+ webex.internal.llm.getDatachannelToken.secondCall,
15598
+ 'llm-default-session'
15599
+ );
15600
+ assert.calledOnceWithExactly(
15601
+ webex.internal.llm.registerAndConnect,
15602
+ 'a url',
15603
+ 'a datachannel url',
15604
+ 'recovered-token'
15605
+ );
15606
+ assert.calledWithExactly(
15607
+ webex.internal.llm.setRefreshHandler.firstCall,
15608
+ sinon.match.func,
15609
+ 'llm-default-session',
15610
+ undefined
15611
+ );
15612
+ assert.calledTwice(webex.internal.llm.setRefreshHandler);
15613
+ assert.calledWithExactly(
15614
+ webex.internal.llm.setRefreshHandler.secondCall,
15615
+ sinon.match.func,
15616
+ 'llm-default-session',
15617
+ meeting.id
15618
+ );
15619
+ assert.calledOnceWithExactly(webex.internal.llm.setOwnerMeetingId, meeting.id);
15620
+ });
15621
+ });
15622
+
13196
15623
  describe('#clearMeetingData', () => {
13197
15624
  beforeEach(() => {
13198
15625
  webex.internal.llm.isConnected = sinon.stub().returns(true);
@@ -13208,10 +15635,15 @@ describe('plugin-meetings', () => {
13208
15635
  it('disconnects llm and removes online and relay listeners during meeting data cleanup', async () => {
13209
15636
  await meeting.clearMeetingData();
13210
15637
 
13211
- assert.calledOnceWithExactly(webex.internal.llm.disconnectLLM, {
13212
- code: 3050,
13213
- reason: 'done (permanent)',
13214
- });
15638
+ assert.calledOnceWithExactly(
15639
+ webex.internal.llm.disconnectLLM,
15640
+ {
15641
+ code: 3050,
15642
+ reason: 'done (permanent)',
15643
+ },
15644
+ 'llm-default-session',
15645
+ meeting.id
15646
+ );
13215
15647
  assert.calledWithExactly(webex.internal.llm.off, 'online', meeting.handleLLMOnline);
13216
15648
  assert.calledWithExactly(
13217
15649
  webex.internal.llm.off,
@@ -13224,10 +15656,13 @@ describe('plugin-meetings', () => {
13224
15656
  meeting.processLocusLLMEvent
13225
15657
  );
13226
15658
  assert.calledOnce(meeting.clearLLMHealthCheckTimer);
13227
- assert.calledOnce(meeting.stopTranscription);
13228
- assert.isUndefined(meeting.transcription);
13229
15659
  assert.calledOnce(meeting.clearDataChannelToken);
13230
- assert.calledOnce(meeting.annotation.deregisterEvents);
15660
+ // stopTranscription and annotation.deregisterEvents are not
15661
+ // called here: they run in stopListeningForMeetingEvents()
15662
+ // before /leave to avoid double-emitting
15663
+ // MEETING_STOPPED_RECEIVING_TRANSCRIPTION.
15664
+ assert.notCalled(meeting.stopTranscription);
15665
+ assert.notCalled(meeting.annotation.deregisterEvents);
13231
15666
  });
13232
15667
  it('continues cleanup when disconnectLLM fails during meeting data cleanup', async () => {
13233
15668
  webex.internal.llm.disconnectLLM.rejects(new Error('disconnect failed'));
@@ -13246,19 +15681,234 @@ describe('plugin-meetings', () => {
13246
15681
  meeting.processLocusLLMEvent
13247
15682
  );
13248
15683
  assert.calledOnce(meeting.clearLLMHealthCheckTimer);
13249
- assert.calledOnce(meeting.stopTranscription);
13250
- assert.isUndefined(meeting.transcription);
13251
15684
  assert.calledOnce(meeting.clearDataChannelToken);
13252
- assert.calledOnce(meeting.annotation.deregisterEvents);
15685
+ assert.notCalled(meeting.stopTranscription);
15686
+ assert.notCalled(meeting.annotation.deregisterEvents);
13253
15687
  });
13254
- it('always calls stopTranscription even when transcription is undefined', async () => {
13255
- meeting.transcription = undefined;
13256
15688
 
13257
- await meeting.clearMeetingData();
15689
+ describe('ownership tag', () => {
15690
+ beforeEach(() => {
15691
+ webex.internal.llm.getOwnerMeetingId = sinon.stub();
15692
+ });
13258
15693
 
13259
- assert.calledOnce(meeting.stopTranscription);
13260
- assert.isUndefined(meeting.transcription);
13261
- assert.calledOnce(meeting.clearDataChannelToken);
15694
+ it('skips disconnectLLM but still removes this meeting listeners when another meeting owns the LLM', async () => {
15695
+ webex.internal.llm.getOwnerMeetingId.returns('some-other-meeting-id');
15696
+
15697
+ await meeting.clearMeetingData();
15698
+
15699
+ assert.notCalled(webex.internal.llm.disconnectLLM);
15700
+ // clearDataChannelToken is always delegated; llm enforces
15701
+ // ownership and no-ops for non-owners internally.
15702
+ assert.calledOnce(meeting.clearDataChannelToken);
15703
+ // Listeners owned by *this* Meeting instance must still be
15704
+ // removed so a leaving subordinate meeting stops receiving
15705
+ // relay/locus events from the shared singleton.
15706
+ assert.calledWithExactly(webex.internal.llm.off, 'online', meeting.handleLLMOnline);
15707
+ assert.calledWithExactly(
15708
+ webex.internal.llm.off,
15709
+ 'event:relay.event',
15710
+ meeting.processRelayEvent
15711
+ );
15712
+ assert.calledWithExactly(
15713
+ webex.internal.llm.off,
15714
+ 'event:locus.state_message',
15715
+ meeting.processLocusLLMEvent
15716
+ );
15717
+ assert.calledOnce(meeting.clearLLMHealthCheckTimer);
15718
+ });
15719
+
15720
+ it('calls disconnectLLM and clears data channel token when this meeting is the owner', async () => {
15721
+ webex.internal.llm.getOwnerMeetingId.returns(meeting.id);
15722
+
15723
+ await meeting.clearMeetingData();
15724
+
15725
+ assert.calledOnceWithExactly(
15726
+ webex.internal.llm.disconnectLLM,
15727
+ {
15728
+ code: 3050,
15729
+ reason: 'done (permanent)',
15730
+ },
15731
+ 'llm-default-session',
15732
+ meeting.id
15733
+ );
15734
+ assert.calledOnce(meeting.clearDataChannelToken);
15735
+ });
15736
+
15737
+ it('calls disconnectLLM and clears data channel token when no owner is recorded (first-claim / legacy)', async () => {
15738
+ webex.internal.llm.getOwnerMeetingId.returns(undefined);
15739
+
15740
+ await meeting.clearMeetingData();
15741
+
15742
+ assert.calledOnceWithExactly(
15743
+ webex.internal.llm.disconnectLLM,
15744
+ {
15745
+ code: 3050,
15746
+ reason: 'done (permanent)',
15747
+ },
15748
+ 'llm-default-session',
15749
+ meeting.id
15750
+ );
15751
+ assert.calledOnce(meeting.clearDataChannelToken);
15752
+ });
15753
+ });
15754
+ });
15755
+ });
15756
+
15757
+ describe('#processLocusLLMEvent', () => {
15758
+ it('routes the LLM event through locusInfo.parse and records the LLM message with the top-level tracking id', () => {
15759
+ const event = {
15760
+ data: {
15761
+ eventType: 'locus.state_message',
15762
+ dataSets: [],
15763
+ },
15764
+ trackingId: 'envelope-tracking-id',
15765
+ };
15766
+
15767
+ meeting.locusInfo.parse = sinon.stub();
15768
+ meeting.onLocusSyncLlmMessage = sinon.stub();
15769
+
15770
+ meeting.processLocusLLMEvent(event);
15771
+
15772
+ // The LLM message is parsed without the tracking id - completion is driven from the
15773
+ // meeting's LLM handler, not threaded through locusInfo.
15774
+ assert.calledOnceWithExactly(meeting.locusInfo.parse, meeting, event.data);
15775
+ // Only the client whose /sync request tracking id matches the tracking id echoed back on
15776
+ // the top-level LLM event envelope records the LLM arrival; onLocusSyncLlmMessage is a
15777
+ // no-op otherwise.
15778
+ assert.calledOnceWithExactly(meeting.onLocusSyncLlmMessage, meeting.id, event.trackingId);
15779
+ });
15780
+
15781
+ it('does not attempt sync completion when the tracking id is missing', () => {
15782
+ const event = {
15783
+ data: {
15784
+ eventType: 'locus.state_message',
15785
+ dataSets: [],
15786
+ },
15787
+ };
15788
+
15789
+ meeting.locusInfo.parse = sinon.stub();
15790
+ meeting.onLocusSyncLlmMessage = sinon.stub();
15791
+
15792
+ meeting.processLocusLLMEvent(event);
15793
+
15794
+ assert.calledOnceWithExactly(meeting.locusInfo.parse, meeting, event.data);
15795
+ assert.notCalled(meeting.onLocusSyncLlmMessage);
15796
+ });
15797
+ });
15798
+
15799
+ describe('#onLocusSyncLlmMessage', () => {
15800
+ it('records the LLM arrival time and then tries to complete the metric', () => {
15801
+ webex.internal.newMetrics.callDiagnosticLatencies.recordLocusSyncMessageReceived =
15802
+ sinon.stub();
15803
+ meeting.tryCompleteLocusSyncLatency = sinon.stub();
15804
+
15805
+ meeting.onLocusSyncLlmMessage('meeting-1', 'sync-tracking-id');
15806
+
15807
+ assert.calledOnceWithExactly(
15808
+ webex.internal.newMetrics.callDiagnosticLatencies.recordLocusSyncMessageReceived,
15809
+ 'meeting-1',
15810
+ 'sync-tracking-id'
15811
+ );
15812
+ assert.calledOnceWithExactly(
15813
+ meeting.tryCompleteLocusSyncLatency,
15814
+ 'meeting-1',
15815
+ 'sync-tracking-id'
15816
+ );
15817
+ // the arrival time must be recorded before completion is attempted
15818
+ assert.callOrder(
15819
+ webex.internal.newMetrics.callDiagnosticLatencies.recordLocusSyncMessageReceived,
15820
+ meeting.tryCompleteLocusSyncLatency
15821
+ );
15822
+ });
15823
+ });
15824
+
15825
+ describe('#tryCompleteLocusSyncLatency', () => {
15826
+ beforeEach(() => {
15827
+ meeting.emitLocusSyncCompleteMetric = sinon.stub();
15828
+ });
15829
+
15830
+ it('emits the metric when both milestones are in (completion succeeds)', () => {
15831
+ const completed = {dataSet: 'main', syncLatency: {totalTime: 50}};
15832
+ webex.internal.newMetrics.callDiagnosticLatencies.completeLocusSyncLatency = sinon
15833
+ .stub()
15834
+ .returns(completed);
15835
+
15836
+ meeting.tryCompleteLocusSyncLatency('meeting-1', 'sync-tracking-id');
15837
+
15838
+ assert.calledOnceWithExactly(
15839
+ webex.internal.newMetrics.callDiagnosticLatencies.completeLocusSyncLatency,
15840
+ 'meeting-1',
15841
+ 'sync-tracking-id'
15842
+ );
15843
+ assert.calledOnceWithExactly(meeting.emitLocusSyncCompleteMetric, 'meeting-1', completed);
15844
+ });
15845
+
15846
+ it('does not emit when completion returns undefined (only one milestone is in)', () => {
15847
+ webex.internal.newMetrics.callDiagnosticLatencies.completeLocusSyncLatency = sinon
15848
+ .stub()
15849
+ .returns(undefined);
15850
+
15851
+ meeting.tryCompleteLocusSyncLatency('meeting-1', 'sync-tracking-id');
15852
+
15853
+ assert.calledOnceWithExactly(
15854
+ webex.internal.newMetrics.callDiagnosticLatencies.completeLocusSyncLatency,
15855
+ 'meeting-1',
15856
+ 'sync-tracking-id'
15857
+ );
15858
+ assert.notCalled(meeting.emitLocusSyncCompleteMetric);
15859
+ });
15860
+ });
15861
+
15862
+ describe('#emitLocusSyncCompleteMetric', () => {
15863
+ it('submits client.locus.sync.complete with the llm websocket url and sync latency', () => {
15864
+ webex.internal.newMetrics.submitClientEvent.resetHistory();
15865
+ webex.internal.llm.getWebSocketUrl = sinon.stub().returns('wss://llm-websocket-url');
15866
+
15867
+ meeting.emitLocusSyncCompleteMetric('meeting-1', {
15868
+ dataSet: 'main',
15869
+ syncLatency: {totalTime: 50},
15870
+ });
15871
+
15872
+ assert.calledOnceWithExactly(webex.internal.newMetrics.submitClientEvent, {
15873
+ name: 'client.locus.sync.complete',
15874
+ payload: {
15875
+ identifiers: {
15876
+ llmWebsocketUrl: 'wss://llm-websocket-url',
15877
+ },
15878
+ llmInfo: {
15879
+ dataSet: 'main',
15880
+ },
15881
+ syncLatency: {totalTime: 50},
15882
+ },
15883
+ options: {
15884
+ meetingId: 'meeting-1',
15885
+ },
15886
+ });
15887
+ });
15888
+
15889
+ it('submits with an undefined llm websocket url when it is unavailable', () => {
15890
+ webex.internal.newMetrics.submitClientEvent.resetHistory();
15891
+ webex.internal.llm.getWebSocketUrl = sinon.stub().returns(undefined);
15892
+
15893
+ meeting.emitLocusSyncCompleteMetric('meeting-1', {
15894
+ dataSet: 'main',
15895
+ syncLatency: {totalTime: 50},
15896
+ });
15897
+
15898
+ assert.calledOnceWithExactly(webex.internal.newMetrics.submitClientEvent, {
15899
+ name: 'client.locus.sync.complete',
15900
+ payload: {
15901
+ identifiers: {
15902
+ llmWebsocketUrl: undefined,
15903
+ },
15904
+ llmInfo: {
15905
+ dataSet: 'main',
15906
+ },
15907
+ syncLatency: {totalTime: 50},
15908
+ },
15909
+ options: {
15910
+ meetingId: 'meeting-1',
15911
+ },
13262
15912
  });
13263
15913
  });
13264
15914
  });
@@ -13298,6 +15948,71 @@ describe('plugin-meetings', () => {
13298
15948
  });
13299
15949
  });
13300
15950
 
15951
+ describe('#waitForSelfUrlChange', () => {
15952
+ let waitForSelfUrlChange;
15953
+ let locusMediaRequestStub;
15954
+
15955
+ beforeEach(async () => {
15956
+ locusMediaRequestStub = sinon
15957
+ .stub(LocusMediaRequestModule, 'LocusMediaRequest')
15958
+ .returns({id: 'fake LocusMediaRequest instance'});
15959
+
15960
+ meeting.setLocus = sinon.stub().returns(true);
15961
+ webex.meetings.registered = true;
15962
+ sandbox.stub(MeetingUtil, 'joinMeeting').returns(Promise.resolve('JOIN_RESULT'));
15963
+ sinon.stub(meeting, 'updateLLMConnection').returns(Promise.resolve());
15964
+
15965
+ await meeting.join();
15966
+
15967
+ waitForSelfUrlChange = locusMediaRequestStub.firstCall.args[0].waitForSelfUrlChange;
15968
+ });
15969
+
15970
+ it('should resolve immediately when joinWithMediaRetryInfo.retryCount > 0', async () => {
15971
+ meeting.joinWithMediaRetryInfo = {retryCount: 1, prevJoinResponse: undefined};
15972
+
15973
+ const result = waitForSelfUrlChange();
15974
+
15975
+ assert.instanceOf(result, Promise);
15976
+ await result;
15977
+ });
15978
+
15979
+ it('should not resolve before the timeout when retryCount is 0', async () => {
15980
+ meeting.joinWithMediaRetryInfo = {retryCount: 0, prevJoinResponse: undefined};
15981
+
15982
+ let resolved = false;
15983
+ waitForSelfUrlChange().then(() => {
15984
+ resolved = true;
15985
+ });
15986
+
15987
+ await testUtils.flushPromises();
15988
+ assert.isFalse(resolved);
15989
+ });
15990
+
15991
+ it('should resolve after the 5s timeout when retryCount is 0', async () => {
15992
+ meeting.joinWithMediaRetryInfo = {retryCount: 0, prevJoinResponse: undefined};
15993
+
15994
+ let resolved = false;
15995
+ const promise = waitForSelfUrlChange();
15996
+ promise.then(() => {
15997
+ resolved = true;
15998
+ });
15999
+
16000
+ fakeClock.tick(5000);
16001
+ await promise;
16002
+
16003
+ assert.isTrue(resolved);
16004
+ });
16005
+
16006
+ it('should return the same promise when called multiple times', () => {
16007
+ meeting.joinWithMediaRetryInfo = {retryCount: 0, prevJoinResponse: undefined};
16008
+
16009
+ const firstPromise = waitForSelfUrlChange();
16010
+ const secondPromise = waitForSelfUrlChange();
16011
+
16012
+ assert.equal(firstPromise, secondPromise);
16013
+ });
16014
+ });
16015
+
13301
16016
  describe('preferred video device', () => {
13302
16017
  describe('#getVideoDeviceId', () => {
13303
16018
  it('returns the preferred video device', () => {
@@ -15012,16 +17727,25 @@ describe('plugin-meetings', () => {
15012
17727
  assert.notCalled(meeting.meetingRequest.sendReaction);
15013
17728
  });
15014
17729
 
15015
- it('should fail sending a reaction if reactionType is invalid ', async () => {
17730
+ it('should send a custom reaction type not in the known list', async () => {
15016
17731
  meeting.locusInfo.controls = {reactions: {reactionChannelUrl: 'Fake URL'}};
15017
17732
 
15018
- await assert.isRejected(
15019
- meeting.sendReaction('invalid_reaction', 'light'),
15020
- Error,
15021
- 'invalid_reaction is not a valid reaction.'
15022
- );
17733
+ const reactionPromise = meeting.sendReaction('custom_reaction', 'light');
15023
17734
 
15024
- assert.notCalled(meeting.meetingRequest.sendReaction);
17735
+ assert.exists(reactionPromise.then);
17736
+ await reactionPromise;
17737
+ assert.calledOnceWithExactly(meeting.meetingRequest.sendReaction, {
17738
+ reactionChannelUrl: 'Fake URL',
17739
+ reaction: {
17740
+ type: 'custom_reaction',
17741
+ tone: {
17742
+ type: 'light_skin_tone',
17743
+ codepoints: '1F3FB',
17744
+ shortcodes: ':skin-tone-2:',
17745
+ },
17746
+ },
17747
+ participantId: meeting.members.selfId,
17748
+ });
15025
17749
  });
15026
17750
 
15027
17751
  it('should send a reaction with default skin tone if provided skinToneType is invalid ', async () => {