@webex/plugin-meetings 3.12.0-next.15 → 3.12.0-next.150

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 (296) 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 +23 -8
  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 +7 -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 +9 -3
  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/reachability/clusterReachability.js.map +1 -1
  130. package/dist/reachability/index.js +121 -83
  131. package/dist/reachability/index.js.map +1 -1
  132. package/dist/reachability/reachability.types.js +2 -0
  133. package/dist/reachability/reachability.types.js.map +1 -1
  134. package/dist/reachability/util.js +45 -0
  135. package/dist/reachability/util.js.map +1 -1
  136. package/dist/reactions/reactions.type.js.map +1 -1
  137. package/dist/recording-controller/index.js +1 -3
  138. package/dist/recording-controller/index.js.map +1 -1
  139. package/dist/roap/turnDiscovery.js +8 -1
  140. package/dist/roap/turnDiscovery.js.map +1 -1
  141. package/dist/types/common/errors/webex-errors.d.ts +32 -2
  142. package/dist/types/config.d.ts +2 -2
  143. package/dist/types/constants.d.ts +13 -1
  144. package/dist/types/controls-options-manager/index.d.ts +16 -0
  145. package/dist/types/hashTree/constants.d.ts +1 -0
  146. package/dist/types/hashTree/hashTreeParser.d.ts +201 -22
  147. package/dist/types/hashTree/utils.d.ts +7 -0
  148. package/dist/types/index.d.ts +3 -0
  149. package/dist/types/interceptors/locusRetry.d.ts +4 -4
  150. package/dist/types/interpretation/interpretation.types.d.ts +10 -0
  151. package/dist/types/locus-info/index.d.ts +106 -8
  152. package/dist/types/locus-info/infoUtils.d.ts +8 -0
  153. package/dist/types/locus-info/types.d.ts +22 -1
  154. package/dist/types/media/MediaConnectionAwaiter.d.ts +10 -1
  155. package/dist/types/media/properties.d.ts +6 -2
  156. package/dist/types/meeting/in-meeting-actions.d.ts +6 -0
  157. package/dist/types/meeting/index.d.ts +176 -11
  158. package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
  159. package/dist/types/meeting/request.d.ts +1 -0
  160. package/dist/types/meeting/util.d.ts +9 -0
  161. package/dist/types/meeting-info/meeting-info-v2.d.ts +1 -0
  162. package/dist/types/meetings/index.d.ts +40 -19
  163. package/dist/types/meetings/meetings.types.d.ts +15 -0
  164. package/dist/types/meetings/request.d.ts +14 -0
  165. package/dist/types/member/index.d.ts +1 -0
  166. package/dist/types/member/types.d.ts +1 -0
  167. package/dist/types/member/util.d.ts +9 -0
  168. package/dist/types/members/index.d.ts +15 -2
  169. package/dist/types/members/util.d.ts +1 -5
  170. package/dist/types/metrics/constants.d.ts +6 -0
  171. package/dist/types/multistream/codec/constants.d.ts +7 -0
  172. package/dist/types/multistream/mediaRequestManager.d.ts +22 -5
  173. package/dist/types/reachability/clusterReachability.d.ts +3 -3
  174. package/dist/types/reachability/index.d.ts +10 -3
  175. package/dist/types/reachability/reachability.types.d.ts +7 -0
  176. package/dist/types/reachability/util.d.ts +17 -0
  177. package/dist/types/reactions/reactions.type.d.ts +3 -0
  178. package/dist/webinar/index.js +307 -161
  179. package/dist/webinar/index.js.map +1 -1
  180. package/package.json +23 -23
  181. package/src/aiEnableRequest/ai-docs/ai-enable-request-spec.md +223 -0
  182. package/src/aiEnableRequest/index.ts +16 -0
  183. package/src/annotation/ai-docs/annotation-spec.md +236 -0
  184. package/src/annotation/index.ts +6 -4
  185. package/src/breakouts/ai-docs/breakouts-spec.md +324 -0
  186. package/src/breakouts/breakout.ts +3 -1
  187. package/src/breakouts/events.ts +33 -11
  188. package/src/breakouts/index.ts +122 -2
  189. package/src/common/errors/webex-errors.ts +50 -3
  190. package/src/config.ts +2 -2
  191. package/src/constants.ts +21 -3
  192. package/src/controls-options-manager/ai-docs/controls-options-manager-spec.md +243 -0
  193. package/src/controls-options-manager/index.ts +62 -10
  194. package/src/hashTree/ai-docs/hash-tree-spec.md +267 -0
  195. package/src/hashTree/constants.ts +7 -0
  196. package/src/hashTree/hashTreeParser.ts +861 -193
  197. package/src/hashTree/utils.ts +19 -0
  198. package/src/index.ts +6 -0
  199. package/src/interceptors/ai-docs/interceptors-spec.md +247 -0
  200. package/src/interceptors/dataChannelAuthToken.ts +88 -12
  201. package/src/interceptors/locusRetry.ts +25 -4
  202. package/src/interpretation/ai-docs/interpretation-spec.md +256 -0
  203. package/src/interpretation/index.ts +65 -10
  204. package/src/interpretation/interpretation.types.ts +11 -0
  205. package/src/locus-info/ai-docs/locus-info-spec.md +293 -0
  206. package/src/locus-info/controlsUtils.ts +3 -1
  207. package/src/locus-info/index.ts +566 -164
  208. package/src/locus-info/infoUtils.ts +41 -6
  209. package/src/locus-info/types.ts +26 -1
  210. package/src/media/MediaConnectionAwaiter.ts +21 -4
  211. package/src/media/ai-docs/media-spec.md +267 -0
  212. package/src/media/index.ts +10 -1
  213. package/src/media/properties.ts +8 -3
  214. package/src/meeting/ai-docs/meeting-spec.md +401 -0
  215. package/src/meeting/in-meeting-actions.ts +12 -0
  216. package/src/meeting/index.ts +937 -119
  217. package/src/meeting/locusMediaRequest.ts +106 -6
  218. package/src/meeting/muteState.ts +10 -1
  219. package/src/meeting/request.ts +11 -0
  220. package/src/meeting/util.ts +51 -7
  221. package/src/meeting/voicea-meeting.ts +1 -1
  222. package/src/meeting-info/ai-docs/meeting-info-spec.md +261 -0
  223. package/src/meeting-info/meeting-info-v2.ts +10 -4
  224. package/src/meetings/ai-docs/meetings-spec.md +296 -0
  225. package/src/meetings/index.ts +200 -80
  226. package/src/meetings/meetings.types.ts +19 -0
  227. package/src/meetings/request.ts +43 -0
  228. package/src/meetings/util.ts +117 -4
  229. package/src/member/ai-docs/member-spec.md +196 -0
  230. package/src/member/index.ts +10 -0
  231. package/src/member/types.ts +1 -0
  232. package/src/member/util.ts +29 -0
  233. package/src/members/ai-docs/members-spec.md +256 -0
  234. package/src/members/index.ts +70 -7
  235. package/src/members/util.ts +12 -4
  236. package/src/metrics/ai-docs/metrics-spec.md +185 -0
  237. package/src/metrics/constants.ts +6 -0
  238. package/src/multistream/ai-docs/multistream-spec.md +292 -0
  239. package/src/multistream/codec/constants.ts +58 -0
  240. package/src/multistream/mediaRequestManager.ts +119 -28
  241. package/src/multistream/receiveSlot.ts +18 -0
  242. package/src/personal-meeting-room/ai-docs/personal-meeting-room-spec.md +234 -0
  243. package/src/reachability/ai-docs/reachability-spec.md +261 -0
  244. package/src/reachability/clusterReachability.ts +3 -2
  245. package/src/reachability/index.ts +47 -16
  246. package/src/reachability/reachability.types.ts +11 -0
  247. package/src/reachability/util.ts +36 -0
  248. package/src/reactions/ai-docs/reactions-spec.md +198 -0
  249. package/src/reactions/reactions.type.ts +3 -0
  250. package/src/reconnection-manager/ai-docs/reconnection-manager-spec.md +272 -0
  251. package/src/recording-controller/ai-docs/recording-controller-spec.md +223 -0
  252. package/src/recording-controller/index.ts +1 -2
  253. package/src/roap/ai-docs/roap-spec.md +241 -0
  254. package/src/roap/turnDiscovery.ts +9 -1
  255. package/src/webinar/ai-docs/webinar-spec.md +243 -0
  256. package/src/webinar/index.ts +216 -38
  257. package/test/unit/spec/aiEnableRequest/index.ts +86 -0
  258. package/test/unit/spec/annotation/index.ts +3 -3
  259. package/test/unit/spec/breakouts/breakout.ts +9 -3
  260. package/test/unit/spec/breakouts/events.ts +120 -2
  261. package/test/unit/spec/breakouts/index.ts +223 -3
  262. package/test/unit/spec/common/errors/webex-errors.ts +78 -0
  263. package/test/unit/spec/controls-options-manager/index.js +139 -32
  264. package/test/unit/spec/hashTree/hashTreeParser.ts +2451 -184
  265. package/test/unit/spec/hashTree/utils.ts +37 -0
  266. package/test/unit/spec/interceptors/dataChannelAuthToken.ts +196 -0
  267. package/test/unit/spec/interceptors/locusRetry.ts +205 -4
  268. package/test/unit/spec/interpretation/index.ts +119 -4
  269. package/test/unit/spec/locus-info/controlsUtils.js +172 -57
  270. package/test/unit/spec/locus-info/index.js +1014 -58
  271. package/test/unit/spec/locus-info/infoUtils.js +184 -1
  272. package/test/unit/spec/media/MediaConnectionAwaiter.ts +55 -0
  273. package/test/unit/spec/media/index.ts +92 -0
  274. package/test/unit/spec/media/properties.ts +23 -23
  275. package/test/unit/spec/meeting/in-meeting-actions.ts +6 -0
  276. package/test/unit/spec/meeting/index.js +2811 -117
  277. package/test/unit/spec/meeting/locusMediaRequest.ts +406 -4
  278. package/test/unit/spec/meeting/muteState.js +81 -0
  279. package/test/unit/spec/meeting/request.js +12 -0
  280. package/test/unit/spec/meeting/utils.js +179 -16
  281. package/test/unit/spec/meeting/voicea-meeting.ts +85 -1
  282. package/test/unit/spec/meeting-info/meetinginfov2.js +76 -10
  283. package/test/unit/spec/meetings/index.js +544 -49
  284. package/test/unit/spec/meetings/request.js +141 -0
  285. package/test/unit/spec/meetings/utils.js +402 -51
  286. package/test/unit/spec/member/index.js +7 -0
  287. package/test/unit/spec/member/util.js +89 -0
  288. package/test/unit/spec/members/index.js +216 -0
  289. package/test/unit/spec/members/request.js +37 -1
  290. package/test/unit/spec/members/utils.js +63 -0
  291. package/test/unit/spec/multistream/mediaRequestManager.ts +501 -37
  292. package/test/unit/spec/reachability/index.ts +128 -46
  293. package/test/unit/spec/reachability/util.ts +31 -0
  294. package/test/unit/spec/recording-controller/index.js +9 -8
  295. package/test/unit/spec/roap/turnDiscovery.ts +20 -0
  296. 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,
1250
+ prevJoinResponse: undefined,
1251
+ firstError: undefined,
1252
+ prevError: undefined,
1253
+ });
1254
+ });
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,
906
1296
  prevJoinResponse: undefined,
1297
+ firstError: undefined,
1298
+ prevError: undefined,
907
1299
  });
908
1300
  });
909
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);
@@ -1248,30 +1783,141 @@ describe('plugin-meetings', () => {
1248
1783
  return defer.promise;
1249
1784
  });
1250
1785
 
1251
- const result = meeting.joinWithMedia({
1252
- joinOptions,
1253
- mediaOptions,
1254
- });
1786
+ const result = meeting.joinWithMedia({
1787
+ joinOptions,
1788
+ mediaOptions,
1789
+ });
1790
+
1791
+ await testUtils.flushPromises();
1792
+
1793
+ // check the callback works correctly on the 1st attempt
1794
+ assert.equal(icePhaseCallbacks.length, 1);
1795
+ assert.equal(icePhaseCallbacks[0](), 'JOIN_MEETING_RETRY');
1796
+
1797
+ // now trigger the failure, so that joinWithMedia() does a retry
1798
+ addMediaInternalResults[0].reject(addMediaError);
1799
+
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
+ });
1255
1897
 
1256
- await testUtils.flushPromises();
1898
+ it('should re-join when isUserInLeftState returns true on retry', async () => {
1899
+ const addMediaError = new Error('addMedia error');
1257
1900
 
1258
- // check the callback works correctly on the 1st attempt
1259
- assert.equal(icePhaseCallbacks.length, 1);
1260
- assert.equal(icePhaseCallbacks[0](), 'JOIN_MEETING_RETRY');
1901
+ sinon.stub(MeetingUtil, 'isUserInLeftState').returns(true);
1261
1902
 
1262
- // now trigger the failure, so that joinWithMedia() does a retry
1263
- addMediaInternalResults[0].reject(addMediaError);
1903
+ const leaveStub = sinon.stub(meeting, 'leave').resolves();
1264
1904
 
1265
- await testUtils.flushPromises();
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)),
@@ -2614,9 +3778,11 @@ describe('plugin-meetings', () => {
2614
3778
  retriedWithTurnServer: false,
2615
3779
  isMultistream: false,
2616
3780
  isJoinWithMediaRetry: false,
3781
+ iceTransportPolicy: 'all',
2617
3782
  signalingState: 'unknown',
2618
3783
  connectionState: 'unknown',
2619
3784
  iceConnectionState: 'unknown',
3785
+ connectionType: 'udp',
2620
3786
  someReachabilityMetric1: 'some value1',
2621
3787
  someReachabilityMetric2: 'some value2',
2622
3788
  selectedCandidatePairChanges: 2,
@@ -2742,9 +3908,11 @@ describe('plugin-meetings', () => {
2742
3908
  retriedWithTurnServer: false,
2743
3909
  isMultistream: false,
2744
3910
  isJoinWithMediaRetry: false,
3911
+ iceTransportPolicy: 'all',
2745
3912
  signalingState: 'unknown',
2746
3913
  connectionState: 'unknown',
2747
3914
  iceConnectionState: 'unknown',
3915
+ connectionType: 'udp',
2748
3916
  someReachabilityMetric1: 'some value1',
2749
3917
  someReachabilityMetric2: 'some value2',
2750
3918
  selectedCandidatePairChanges: 2,
@@ -3178,6 +4346,7 @@ describe('plugin-meetings', () => {
3178
4346
  unpublishStream: sinon.stub(),
3179
4347
  setNamedMediaGroups: sinon.stub(),
3180
4348
  });
4349
+ sinon.spy(meeting.sendSlotManager, 'reset');
3181
4350
 
3182
4351
  await meeting.addMedia({
3183
4352
  allowMediaInLobby: true,
@@ -3190,6 +4359,7 @@ describe('plugin-meetings', () => {
3190
4359
  },
3191
4360
  });
3192
4361
 
4362
+ assert.calledOnce(meeting.sendSlotManager.reset);
3193
4363
  assert.notCalled(publishStreamStub);
3194
4364
  });
3195
4365
 
@@ -3213,6 +4383,7 @@ describe('plugin-meetings', () => {
3213
4383
  }
3214
4384
  return videoSlot;
3215
4385
  });
4386
+ sinon.spy(meeting.sendSlotManager, 'reset');
3216
4387
 
3217
4388
  await meeting.addMedia({
3218
4389
  allowMediaInLobby: true,
@@ -3225,6 +4396,7 @@ describe('plugin-meetings', () => {
3225
4396
  },
3226
4397
  });
3227
4398
 
4399
+ assert.calledOnce(meeting.sendSlotManager.reset);
3228
4400
  assert.calledOnceWithExactly(audioSlot.publishStream, fakeMicrophoneStream);
3229
4401
  assert.calledOnceWithExactly(videoSlot.publishStream, fakeCameraStream);
3230
4402
  });
@@ -3247,11 +4419,13 @@ describe('plugin-meetings', () => {
3247
4419
 
3248
4420
  meeting.meetingState = 'ACTIVE';
3249
4421
  meeting.isMultistream = true;
4422
+ sinon.spy(meeting.sendSlotManager, 'reset');
3250
4423
 
3251
4424
  await meeting.addMedia({
3252
4425
  mediaSettings: {},
3253
4426
  });
3254
4427
 
4428
+ assert.calledOnce(meeting.sendSlotManager.reset);
3255
4429
  // check that rtcMetrics was passed to Media.createMediaConnection
3256
4430
  assert.calledOnce(Media.createMediaConnection);
3257
4431
  assert.calledWith(
@@ -3512,9 +4686,11 @@ describe('plugin-meetings', () => {
3512
4686
  retriedWithTurnServer: true,
3513
4687
  isMultistream: false,
3514
4688
  isJoinWithMediaRetry: false,
4689
+ iceTransportPolicy: 'all',
3515
4690
  signalingState: 'unknown',
3516
4691
  connectionState: 'unknown',
3517
4692
  iceConnectionState: 'unknown',
4693
+ connectionType: 'udp',
3518
4694
  selectedCandidatePairChanges: 2,
3519
4695
  numTransports: 1,
3520
4696
  iceCandidatesCount: 0,
@@ -3539,6 +4715,173 @@ describe('plugin-meetings', () => {
3539
4715
  assert.isOk(errorThrown);
3540
4716
  });
3541
4717
 
4718
+ [
4719
+ {iceConnected: true, title: 'iceConnected=true'},
4720
+ {iceConnected: false, title: 'iceConnected=false'},
4721
+ ].forEach(({iceConnected, title}) => {
4722
+ it(`should propagate ${title} from waitForMediaConnectionConnected rejection to AddMediaFailed`, async () => {
4723
+ webex.meetings.reachability = {
4724
+ isWebexMediaBackendUnreachable: sinon.stub().resolves(false),
4725
+ getReachabilityMetrics: sinon.stub().resolves({}),
4726
+ stopReachability: sinon.stub(),
4727
+ isSubnetReachable: sinon.stub().returns(true),
4728
+ };
4729
+ webex.internal.newMetrics.callDiagnosticMetrics.getErrorPayloadForClientErrorCode =
4730
+ sinon.stub().returns({fatal: true});
4731
+ sinon.stub(CallDiagnosticUtils, 'generateClientErrorCodeForIceFailure').returns(2004);
4732
+
4733
+ meeting.meetingState = 'ACTIVE';
4734
+ const rejectedResult = {iceConnected};
4735
+ meeting.mediaProperties.waitForMediaConnectionConnected = sinon
4736
+ .stub()
4737
+ .rejects(rejectedResult);
4738
+
4739
+ meeting.roap.doTurnDiscovery = sinon.stub().returns({
4740
+ turnServerInfo: {urls: ['turns:fake:443'], username: 'u', password: 'p'},
4741
+ turnDiscoverySkippedReason: undefined,
4742
+ });
4743
+
4744
+ const forceRtcMetricsSend = sinon.stub().resolves();
4745
+ Media.createMediaConnection = sinon.stub().returns({
4746
+ close: sinon.stub(),
4747
+ forceRtcMetricsSend,
4748
+ getConnectionState: sinon.stub().returns(ConnectionState.Connected),
4749
+ initiateOffer: sinon.stub().resolves({}),
4750
+ on: sinon.stub(),
4751
+ });
4752
+
4753
+ let thrownError;
4754
+ await meeting.addMedia({mediaSettings: {}}).catch((err) => {
4755
+ thrownError = err;
4756
+ });
4757
+
4758
+ assert.instanceOf(thrownError, AddMediaFailed);
4759
+ assert.equal(thrownError.iceConnected, iceConnected);
4760
+ // the AddMediaFailed cause should be the MediaConnectionTimedOutError, which in turn should
4761
+ // preserve the original rejected result as its cause, so that the web client
4762
+ // can find the CA-reported error in the eventErrorCache via the cause chain
4763
+ assert.instanceOf(thrownError.cause, MediaConnectionTimedOutError);
4764
+ assert.equal(thrownError.cause.cause, rejectedResult);
4765
+ });
4766
+ });
4767
+
4768
+ describe('iceTransportPolicy=relay handling', () => {
4769
+ let createMediaConnectionStub;
4770
+
4771
+ beforeEach(() => {
4772
+ webex.meetings.reachability = {
4773
+ isWebexMediaBackendUnreachable: sinon.stub().resolves(false),
4774
+ isAnyClusterReachableViaProtocol: sinon.stub().resolves(true),
4775
+ getReachabilityMetrics: sinon.stub().resolves({}),
4776
+ stopReachability: sinon.stub(),
4777
+ isSubnetReachable: sinon.stub().returns(true),
4778
+ };
4779
+ webex.internal.newMetrics.callDiagnosticMetrics.getErrorPayloadForClientErrorCode =
4780
+ sinon.stub().returns({fatal: true});
4781
+ sinon.stub(CallDiagnosticUtils, 'generateClientErrorCodeForIceFailure').returns(2004);
4782
+
4783
+ meeting.meetingState = 'ACTIVE';
4784
+ meeting.mediaProperties.waitForMediaConnectionConnected = sinon.stub().resolves();
4785
+
4786
+ createMediaConnectionStub = sinon.stub().returns({
4787
+ close: sinon.stub(),
4788
+ forceRtcMetricsSend: sinon.stub().resolves(),
4789
+ getConnectionState: sinon.stub().returns(ConnectionState.Connected),
4790
+ initiateOffer: sinon.stub().resolves({}),
4791
+ on: sinon.stub(),
4792
+ });
4793
+ Media.createMediaConnection = createMediaConnectionStub;
4794
+ });
4795
+
4796
+ [
4797
+ {
4798
+ title:
4799
+ 'should drop iceTransportPolicy=relay when TURN discovery returns no turn server info',
4800
+ turnServerInfo: undefined,
4801
+ turnDiscoverySkippedReason: 'reachability',
4802
+ },
4803
+ {
4804
+ title:
4805
+ 'should drop iceTransportPolicy=relay when TURN discovery returns turnServerInfo with empty urls',
4806
+ turnServerInfo: {urls: [], username: 'u', password: 'p'},
4807
+ turnDiscoverySkippedReason: undefined,
4808
+ },
4809
+ ].forEach(({title, turnServerInfo, turnDiscoverySkippedReason}) => {
4810
+ it(title, async () => {
4811
+ meeting.roap.doTurnDiscovery = sinon.stub().returns({
4812
+ turnServerInfo,
4813
+ turnDiscoverySkippedReason,
4814
+ });
4815
+
4816
+ await meeting.addMediaInternal(
4817
+ () => 'JOIN_MEETING_FINAL',
4818
+ false,
4819
+ undefined,
4820
+ 'relay',
4821
+ {mediaSettings: {}}
4822
+ );
4823
+
4824
+ assert.calledOnce(createMediaConnectionStub);
4825
+ const config = createMediaConnectionStub.firstCall.args[3];
4826
+ assert.isUndefined(config.iceTransportPolicy);
4827
+
4828
+ const successCall = Metrics.sendBehavioralMetric
4829
+ .getCalls()
4830
+ .find((call) => call.args[0] === BEHAVIORAL_METRICS.ADD_MEDIA_SUCCESS);
4831
+ assert.isDefined(successCall);
4832
+ assert.equal(successCall.args[1].iceTransportPolicy, 'all');
4833
+ });
4834
+ });
4835
+
4836
+ it('should send ADD_MEDIA_SUCCESS metric with iceTransportPolicy=relay when relay is used', async () => {
4837
+ meeting.roap.doTurnDiscovery = sinon.stub().returns({
4838
+ turnServerInfo: {
4839
+ urls: ['turns:turn-server:443?transport=tcp'],
4840
+ username: 'u',
4841
+ password: 'p',
4842
+ },
4843
+ turnDiscoverySkippedReason: undefined,
4844
+ });
4845
+
4846
+ await meeting.addMediaInternal(() => 'JOIN_MEETING_FINAL', false, undefined, 'relay', {
4847
+ mediaSettings: {},
4848
+ });
4849
+
4850
+ const successCall = Metrics.sendBehavioralMetric
4851
+ .getCalls()
4852
+ .find((call) => call.args[0] === BEHAVIORAL_METRICS.ADD_MEDIA_SUCCESS);
4853
+ assert.isDefined(successCall);
4854
+ assert.equal(successCall.args[1].iceTransportPolicy, 'relay');
4855
+ });
4856
+
4857
+ it('should send ADD_MEDIA_FAILURE metric with iceTransportPolicy=relay when relay attempt fails', async () => {
4858
+ meeting.roap.doTurnDiscovery = sinon.stub().returns({
4859
+ turnServerInfo: {
4860
+ urls: ['turns:turn-server:443?transport=tcp'],
4861
+ username: 'u',
4862
+ password: 'p',
4863
+ },
4864
+ turnDiscoverySkippedReason: undefined,
4865
+ });
4866
+
4867
+ meeting.mediaProperties.waitForMediaConnectionConnected = sinon
4868
+ .stub()
4869
+ .rejects(new MediaConnectionTimedOutError('timed out', true));
4870
+
4871
+ await assert.isRejected(
4872
+ meeting.addMediaInternal(() => 'JOIN_MEETING_FINAL', false, undefined, 'relay', {
4873
+ mediaSettings: {},
4874
+ })
4875
+ );
4876
+
4877
+ const failureCall = Metrics.sendBehavioralMetric
4878
+ .getCalls()
4879
+ .find((call) => call.args[0] === BEHAVIORAL_METRICS.ADD_MEDIA_FAILURE);
4880
+ assert.isDefined(failureCall);
4881
+ assert.equal(failureCall.args[1].iceTransportPolicy, 'relay');
4882
+ });
4883
+ });
4884
+
3542
4885
  it('should resolve if waitForMediaConnectionConnected() rejects the first time but resolves the second time', async () => {
3543
4886
  const FAKE_ERROR = {fatal: true};
3544
4887
  webex.meetings.reachability = {
@@ -3728,6 +5071,7 @@ describe('plugin-meetings', () => {
3728
5071
  isMultistream: false,
3729
5072
  retriedWithTurnServer: true,
3730
5073
  isJoinWithMediaRetry: false,
5074
+ iceTransportPolicy: 'all',
3731
5075
  iceCandidatesCount: 0,
3732
5076
  subnet_reachable: null,
3733
5077
  selected_cluster: null,
@@ -3891,6 +5235,7 @@ describe('plugin-meetings', () => {
3891
5235
  isMultistream: false,
3892
5236
  retriedWithTurnServer: false,
3893
5237
  isJoinWithMediaRetry: false,
5238
+ iceTransportPolicy: 'all',
3894
5239
  someReachabilityMetric1: 'some value1',
3895
5240
  someReachabilityMetric2: 'some value2',
3896
5241
  iceCandidatesCount: 3,
@@ -3956,9 +5301,11 @@ describe('plugin-meetings', () => {
3956
5301
  retriedWithTurnServer: false,
3957
5302
  isMultistream: false,
3958
5303
  isJoinWithMediaRetry: false,
5304
+ iceTransportPolicy: 'all',
3959
5305
  signalingState: 'unknown',
3960
5306
  connectionState: 'unknown',
3961
5307
  iceConnectionState: 'unknown',
5308
+ connectionType: 'udp',
3962
5309
  selectedCandidatePairChanges: 2,
3963
5310
  numTransports: 1,
3964
5311
  subnet_reachable: null,
@@ -4019,9 +5366,11 @@ describe('plugin-meetings', () => {
4019
5366
  retriedWithTurnServer: false,
4020
5367
  isMultistream: false,
4021
5368
  isJoinWithMediaRetry: false,
5369
+ iceTransportPolicy: 'all',
4022
5370
  signalingState: 'unknown',
4023
5371
  connectionState: 'unknown',
4024
5372
  iceConnectionState: 'unknown',
5373
+ connectionType: 'udp',
4025
5374
  selectedCandidatePairChanges: 2,
4026
5375
  numTransports: 1,
4027
5376
  '701_error': 2,
@@ -4083,6 +5432,7 @@ describe('plugin-meetings', () => {
4083
5432
  isMultistream: false,
4084
5433
  retriedWithTurnServer: false,
4085
5434
  isJoinWithMediaRetry: false,
5435
+ iceTransportPolicy: 'all',
4086
5436
  iceCandidatesCount: 0,
4087
5437
  reachability_public_udp_success: 5,
4088
5438
  subnet_reachable: false,
@@ -4148,9 +5498,11 @@ describe('plugin-meetings', () => {
4148
5498
  retriedWithTurnServer: false,
4149
5499
  isMultistream: false,
4150
5500
  isJoinWithMediaRetry: false,
5501
+ iceTransportPolicy: 'all',
4151
5502
  signalingState: 'unknown',
4152
5503
  connectionState: 'unknown',
4153
5504
  iceConnectionState: 'unknown',
5505
+ connectionType: 'udp',
4154
5506
  selectedCandidatePairChanges: 2,
4155
5507
  numTransports: 1,
4156
5508
  reachability_public_udp_success: 5,
@@ -4534,6 +5886,297 @@ describe('plugin-meetings', () => {
4534
5886
  },
4535
5887
  });
4536
5888
  });
5889
+
5890
+ describe('handles STATS_UPDATE event for SRTP cipher detection', () => {
5891
+ it('emits MEETING_SRTP_CIPHER_UPDATED event when srtpCipher is found in transport stats', async () => {
5892
+ const fakeStats = new Map([
5893
+ [
5894
+ 'transport-1',
5895
+ {
5896
+ type: 'transport',
5897
+ srtpCipher: 'AES_CM_128_HMAC_SHA1_80',
5898
+ dtlsCipher: 'TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256',
5899
+ },
5900
+ ],
5901
+ [
5902
+ 'outbound-rtp-1',
5903
+ {
5904
+ type: 'outbound-rtp',
5905
+ ssrc: 12345,
5906
+ },
5907
+ ],
5908
+ ]);
5909
+
5910
+ statsAnalyzerStub.emit(
5911
+ {file: 'test', function: 'test'},
5912
+ StatsAnalyzerEventNames.STATS_UPDATE,
5913
+ {stats: fakeStats}
5914
+ );
5915
+
5916
+ assert.calledWith(
5917
+ TriggerProxy.trigger,
5918
+ sinon.match.instanceOf(Meeting),
5919
+ {
5920
+ file: 'meeting/index',
5921
+ function: 'setupStatsAnalyzerEventHandlers',
5922
+ },
5923
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
5924
+ {srtpCipher: 'AES_CM_128_HMAC_SHA1_80'}
5925
+ );
5926
+
5927
+ assert.equal(meeting.mediaProperties.srtpCipher, 'AES_CM_128_HMAC_SHA1_80');
5928
+ });
5929
+
5930
+ it('updates meeting.mediaProperties.srtpCipher when cipher changes', async () => {
5931
+ const firstStats = new Map([
5932
+ [
5933
+ 'transport-1',
5934
+ {
5935
+ type: 'transport',
5936
+ srtpCipher: 'AES_CM_128_HMAC_SHA1_80',
5937
+ },
5938
+ ],
5939
+ ]);
5940
+
5941
+ statsAnalyzerStub.emit(
5942
+ {file: 'test', function: 'test'},
5943
+ StatsAnalyzerEventNames.STATS_UPDATE,
5944
+ {stats: firstStats}
5945
+ );
5946
+
5947
+ assert.equal(meeting.mediaProperties.srtpCipher, 'AES_CM_128_HMAC_SHA1_80');
5948
+
5949
+ const secondStats = new Map([
5950
+ [
5951
+ 'transport-1',
5952
+ {
5953
+ type: 'transport',
5954
+ srtpCipher: 'AEAD_AES_256_GCM',
5955
+ },
5956
+ ],
5957
+ ]);
5958
+
5959
+ TriggerProxy.trigger.resetHistory();
5960
+
5961
+ statsAnalyzerStub.emit(
5962
+ {file: 'test', function: 'test'},
5963
+ StatsAnalyzerEventNames.STATS_UPDATE,
5964
+ {stats: secondStats}
5965
+ );
5966
+
5967
+ assert.calledWith(
5968
+ TriggerProxy.trigger,
5969
+ sinon.match.instanceOf(Meeting),
5970
+ {
5971
+ file: 'meeting/index',
5972
+ function: 'setupStatsAnalyzerEventHandlers',
5973
+ },
5974
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
5975
+ {srtpCipher: 'AEAD_AES_256_GCM'}
5976
+ );
5977
+
5978
+ assert.equal(meeting.mediaProperties.srtpCipher, 'AEAD_AES_256_GCM');
5979
+ });
5980
+
5981
+ it('does not emit event when srtpCipher has not changed', async () => {
5982
+ const firstStats = new Map([
5983
+ [
5984
+ 'transport-1',
5985
+ {
5986
+ type: 'transport',
5987
+ srtpCipher: 'AES_CM_128_HMAC_SHA1_80',
5988
+ },
5989
+ ],
5990
+ ]);
5991
+
5992
+ statsAnalyzerStub.emit(
5993
+ {file: 'test', function: 'test'},
5994
+ StatsAnalyzerEventNames.STATS_UPDATE,
5995
+ {stats: firstStats}
5996
+ );
5997
+
5998
+ assert.equal(meeting.mediaProperties.srtpCipher, 'AES_CM_128_HMAC_SHA1_80');
5999
+
6000
+ TriggerProxy.trigger.resetHistory();
6001
+
6002
+ // Emit same cipher again
6003
+ statsAnalyzerStub.emit(
6004
+ {file: 'test', function: 'test'},
6005
+ StatsAnalyzerEventNames.STATS_UPDATE,
6006
+ {stats: firstStats}
6007
+ );
6008
+
6009
+ // Should not trigger event again
6010
+ assert.neverCalledWith(
6011
+ TriggerProxy.trigger,
6012
+ sinon.match.instanceOf(Meeting),
6013
+ sinon.match.any,
6014
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
6015
+ sinon.match.any
6016
+ );
6017
+
6018
+ // Cipher should remain the same
6019
+ assert.equal(meeting.mediaProperties.srtpCipher, 'AES_CM_128_HMAC_SHA1_80');
6020
+ });
6021
+
6022
+ it('does not emit event when stats contain no transport with srtpCipher', async () => {
6023
+ const fakeStats = new Map([
6024
+ [
6025
+ 'outbound-rtp-1',
6026
+ {
6027
+ type: 'outbound-rtp',
6028
+ ssrc: 12345,
6029
+ },
6030
+ ],
6031
+ [
6032
+ 'inbound-rtp-1',
6033
+ {
6034
+ type: 'inbound-rtp',
6035
+ ssrc: 67890,
6036
+ },
6037
+ ],
6038
+ ]);
6039
+
6040
+ statsAnalyzerStub.emit(
6041
+ {file: 'test', function: 'test'},
6042
+ StatsAnalyzerEventNames.STATS_UPDATE,
6043
+ {stats: fakeStats}
6044
+ );
6045
+
6046
+ assert.neverCalledWith(
6047
+ TriggerProxy.trigger,
6048
+ sinon.match.instanceOf(Meeting),
6049
+ sinon.match.any,
6050
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
6051
+ sinon.match.any
6052
+ );
6053
+
6054
+ assert.isUndefined(meeting.mediaProperties.srtpCipher);
6055
+ });
6056
+
6057
+ it('does not emit event when transport stat has no srtpCipher property', async () => {
6058
+ const fakeStats = new Map([
6059
+ [
6060
+ 'transport-1',
6061
+ {
6062
+ type: 'transport',
6063
+ dtlsCipher: 'TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256',
6064
+ // no srtpCipher property
6065
+ },
6066
+ ],
6067
+ ]);
6068
+
6069
+ statsAnalyzerStub.emit(
6070
+ {file: 'test', function: 'test'},
6071
+ StatsAnalyzerEventNames.STATS_UPDATE,
6072
+ {stats: fakeStats}
6073
+ );
6074
+
6075
+ assert.neverCalledWith(
6076
+ TriggerProxy.trigger,
6077
+ sinon.match.instanceOf(Meeting),
6078
+ sinon.match.any,
6079
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
6080
+ sinon.match.any
6081
+ );
6082
+
6083
+ assert.isUndefined(meeting.mediaProperties.srtpCipher);
6084
+ });
6085
+
6086
+ it('uses first transport with srtpCipher when multiple transports exist', async () => {
6087
+ const fakeStats = new Map([
6088
+ [
6089
+ 'transport-1',
6090
+ {
6091
+ type: 'transport',
6092
+ srtpCipher: 'AES_CM_128_HMAC_SHA1_80',
6093
+ },
6094
+ ],
6095
+ [
6096
+ 'transport-2',
6097
+ {
6098
+ type: 'transport',
6099
+ srtpCipher: 'AEAD_AES_256_GCM',
6100
+ },
6101
+ ],
6102
+ [
6103
+ 'outbound-rtp-1',
6104
+ {
6105
+ type: 'outbound-rtp',
6106
+ ssrc: 12345,
6107
+ },
6108
+ ],
6109
+ ]);
6110
+
6111
+ statsAnalyzerStub.emit(
6112
+ {file: 'test', function: 'test'},
6113
+ StatsAnalyzerEventNames.STATS_UPDATE,
6114
+ {stats: fakeStats}
6115
+ );
6116
+
6117
+ assert.calledWith(
6118
+ TriggerProxy.trigger,
6119
+ sinon.match.instanceOf(Meeting),
6120
+ {
6121
+ file: 'meeting/index',
6122
+ function: 'setupStatsAnalyzerEventHandlers',
6123
+ },
6124
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
6125
+ {srtpCipher: 'AES_CM_128_HMAC_SHA1_80'}
6126
+ );
6127
+
6128
+ assert.equal(meeting.mediaProperties.srtpCipher, 'AES_CM_128_HMAC_SHA1_80');
6129
+ });
6130
+
6131
+ it('handles empty stats map without errors', async () => {
6132
+ const emptyStats = new Map();
6133
+
6134
+ statsAnalyzerStub.emit(
6135
+ {file: 'test', function: 'test'},
6136
+ StatsAnalyzerEventNames.STATS_UPDATE,
6137
+ {stats: emptyStats}
6138
+ );
6139
+
6140
+ assert.neverCalledWith(
6141
+ TriggerProxy.trigger,
6142
+ sinon.match.instanceOf(Meeting),
6143
+ sinon.match.any,
6144
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
6145
+ sinon.match.any
6146
+ );
6147
+
6148
+ assert.isUndefined(meeting.mediaProperties.srtpCipher);
6149
+ });
6150
+
6151
+ it('logs cipher change when cipher is updated', async () => {
6152
+ const loggerSpy = sinon.spy(LoggerProxy.logger, 'info');
6153
+
6154
+ meeting.mediaProperties.srtpCipher = 'AES_CM_128_HMAC_SHA1_80';
6155
+
6156
+ const newStats = new Map([
6157
+ [
6158
+ 'transport-1',
6159
+ {
6160
+ type: 'transport',
6161
+ srtpCipher: 'AEAD_AES_256_GCM',
6162
+ },
6163
+ ],
6164
+ ]);
6165
+
6166
+ statsAnalyzerStub.emit(
6167
+ {file: 'test', function: 'test'},
6168
+ StatsAnalyzerEventNames.STATS_UPDATE,
6169
+ {stats: newStats}
6170
+ );
6171
+
6172
+ assert.calledWithMatch(
6173
+ loggerSpy,
6174
+ sinon.match(/SRTP cipher changed from AES_CM_128_HMAC_SHA1_80 to AEAD_AES_256_GCM/)
6175
+ );
6176
+
6177
+ loggerSpy.restore();
6178
+ });
6179
+ });
4537
6180
  });
4538
6181
 
4539
6182
  describe('handles StatsMonitor events', () => {
@@ -4637,6 +6280,51 @@ describe('plugin-meetings', () => {
4637
6280
  member2: unmutedMember,
4638
6281
  member3: selfMember,
4639
6282
  });
6283
+ meeting.isUserUnadmitted = false;
6284
+
6285
+ // Reset the stub to clear any previous calls
6286
+ TriggerProxy.trigger.resetHistory();
6287
+
6288
+ // Emit the event from statsMonitor
6289
+ listeners[StatsMonitorEventNames.INBOUND_AUDIO_ISSUE](fakeEventData);
6290
+
6291
+ assert.calledWith(
6292
+ TriggerProxy.trigger,
6293
+ meeting,
6294
+ sinon.match.object,
6295
+ EVENT_TRIGGERS.MEDIA_INBOUND_AUDIO_ISSUE_DETECTED,
6296
+ fakeEventData
6297
+ );
6298
+
6299
+ assert.calledOnceWithExactly(
6300
+ meeting.mediaProperties.sendMediaIssueMetric,
6301
+ 'inbound_audio',
6302
+ fakeEventData.issueSubType,
6303
+ {
6304
+ correlationId: meeting.correlationId,
6305
+ isMultistream: meeting.isMultistream,
6306
+ }
6307
+ );
6308
+ });
6309
+
6310
+ it('should not trigger event or metric when the user is in the lobby', () => {
6311
+ const fakeEventData = {issueSubType: 'DECODE_RESULTS_IN_ZERO_AUDIO_LEVEL'};
6312
+
6313
+ const unmutedMember = {
6314
+ isSelf: false,
6315
+ isPairedWithSelf: false,
6316
+ isAudioMuted: false,
6317
+ };
6318
+ const selfMember = {
6319
+ isSelf: true,
6320
+ isPairedWithSelf: false,
6321
+ isAudioMuted: false,
6322
+ };
6323
+ meeting.members.membersCollection.getAll = sinon.stub().returns({
6324
+ member1: unmutedMember,
6325
+ member2: selfMember,
6326
+ });
6327
+ meeting.isUserUnadmitted = true;
4640
6328
 
4641
6329
  // Reset the stub to clear any previous calls
4642
6330
  TriggerProxy.trigger.resetHistory();
@@ -4644,20 +6332,14 @@ describe('plugin-meetings', () => {
4644
6332
  // Emit the event from statsMonitor
4645
6333
  listeners[StatsMonitorEventNames.INBOUND_AUDIO_ISSUE](fakeEventData);
4646
6334
 
4647
- assert.calledWith(
6335
+ assert.neverCalledWith(
4648
6336
  TriggerProxy.trigger,
4649
6337
  meeting,
4650
6338
  sinon.match.object,
4651
6339
  EVENT_TRIGGERS.MEDIA_INBOUND_AUDIO_ISSUE_DETECTED,
4652
6340
  fakeEventData
4653
6341
  );
4654
-
4655
- assert.calledOnceWithExactly(
4656
- meeting.mediaProperties.sendMediaIssueMetric,
4657
- 'inbound_audio',
4658
- fakeEventData.issueSubType,
4659
- meeting.correlationId
4660
- );
6342
+ assert.notCalled(meeting.mediaProperties.sendMediaIssueMetric);
4661
6343
  });
4662
6344
  });
4663
6345
  });
@@ -6192,13 +7874,14 @@ describe('plugin-meetings', () => {
6192
7874
  sinon.stub(meeting.locusMediaRequest, 'downgradeFromMultistreamToTranscoded');
6193
7875
  });
6194
7876
 
6195
- const runCheck = async (turnServerInfo, forceTurnDiscovery) => {
7877
+ const runCheck = async (turnServerInfo, forceTurnDiscovery, iceTransportPolicy) => {
6196
7878
  // we're calling addMediaInternal() with mic stream,
6197
7879
  // so that we also verify that audioMute, videoMute info is correctly sent to backend
6198
7880
  const addMediaPromise = meeting.addMediaInternal(
6199
7881
  () => '',
6200
- turnServerInfo,
6201
7882
  forceTurnDiscovery,
7883
+ turnServerInfo,
7884
+ iceTransportPolicy,
6202
7885
  {
6203
7886
  localStreams: {microphone: fakeMicrophoneStream},
6204
7887
  }
@@ -6252,6 +7935,10 @@ describe('plugin-meetings', () => {
6252
7935
  // at this point the meeting should have been downgraded to transcoded
6253
7936
  assert.equal(meeting.isMultistream, false);
6254
7937
 
7938
+ // iceTransportPolicy must be reset to undefined on downgrade to transcoded,
7939
+ // otherwise the transcoded retry could gather direct candidates while metrics report relay
7940
+ assert.isUndefined(meeting.addMediaData.iceTransportPolicy);
7941
+
6255
7942
  // old stats analyzer stopped and new one created
6256
7943
  assert.calledOnce(initialStatsAnalyzer.stopAnalyzer);
6257
7944
  assert.calledOnceWithExactly(
@@ -6342,6 +8029,11 @@ describe('plugin-meetings', () => {
6342
8029
  true
6343
8030
  );
6344
8031
  });
8032
+
8033
+ it('resets iceTransportPolicy to undefined when falling back from multistream (relay) to transcoded', async () => {
8034
+ // simulate a relay-only retry falling back to transcoded and verify iceTransportPolicy is reset
8035
+ await runCheck(undefined, false, 'relay');
8036
+ });
6345
8037
  });
6346
8038
  }
6347
8039
  })
@@ -6429,6 +8121,9 @@ describe('plugin-meetings', () => {
6429
8121
 
6430
8122
  meeting.annotation.deregisterEvents = sinon.stub();
6431
8123
  webex.internal.llm.off = sinon.stub();
8124
+ webex.internal.mercury.off = sinon.stub();
8125
+ meeting.mercuryOnlineHandler = sinon.stub();
8126
+ meeting.mercuryOfflineHandler = sinon.stub();
6432
8127
 
6433
8128
  // A meeting needs to be joined to leave
6434
8129
  meeting.meetingState = 'ACTIVE';
@@ -6452,6 +8147,67 @@ describe('plugin-meetings', () => {
6452
8147
  assert.calledOnce(meeting.clearMeetingData);
6453
8148
  });
6454
8149
 
8150
+ it('stops listening for LLM/Mercury and tears down transcription and annotation before calling Locus /leave', async () => {
8151
+ const onlineHandler = meeting.mercuryOnlineHandler;
8152
+ const offlineHandler = meeting.mercuryOfflineHandler;
8153
+
8154
+ await meeting.leave();
8155
+
8156
+ // All llm/mercury consumers (direct listeners, voicea transcription,
8157
+ // annotation) must be detached before the /leave request so that
8158
+ // in-flight events do not trigger unnecessary Locus syncs
8159
+ // (per Locus team recommendation).
8160
+ assert.callOrder(
8161
+ webex.internal.llm.off,
8162
+ webex.internal.mercury.off,
8163
+ meeting.stopTranscription,
8164
+ meeting.annotation.deregisterEvents,
8165
+ meeting.meetingRequest.leaveMeeting
8166
+ );
8167
+ assert.calledWithExactly(
8168
+ webex.internal.llm.off,
8169
+ 'event:relay.event',
8170
+ meeting.processRelayEvent
8171
+ );
8172
+ assert.calledWithExactly(
8173
+ webex.internal.llm.off,
8174
+ LOCUS_LLM_EVENT,
8175
+ meeting.processLocusLLMEvent
8176
+ );
8177
+ assert.calledWithExactly(webex.internal.mercury.off, ONLINE, onlineHandler);
8178
+ assert.calledWithExactly(webex.internal.mercury.off, OFFLINE, offlineHandler);
8179
+ assert.isUndefined(meeting.mercuryOnlineHandler);
8180
+ assert.isUndefined(meeting.mercuryOfflineHandler);
8181
+ assert.calledOnceWithExactly(meeting.stopTranscription);
8182
+ assert.calledOnceWithExactly(meeting.annotation.deregisterEvents);
8183
+ assert.isUndefined(meeting.transcription);
8184
+ });
8185
+
8186
+ it('tears down llm/mercury/transcription/annotation even when /leave rejects', async () => {
8187
+ const onlineHandler = meeting.mercuryOnlineHandler;
8188
+ const offlineHandler = meeting.mercuryOfflineHandler;
8189
+ meeting.meetingRequest.leaveMeeting = sinon
8190
+ .stub()
8191
+ .returns(Promise.reject(new Error('leave failed')));
8192
+
8193
+ await meeting.leave().catch(() => {});
8194
+
8195
+ assert.calledWithExactly(
8196
+ webex.internal.llm.off,
8197
+ 'event:relay.event',
8198
+ meeting.processRelayEvent
8199
+ );
8200
+ assert.calledWithExactly(
8201
+ webex.internal.llm.off,
8202
+ LOCUS_LLM_EVENT,
8203
+ meeting.processLocusLLMEvent
8204
+ );
8205
+ assert.calledWithExactly(webex.internal.mercury.off, ONLINE, onlineHandler);
8206
+ assert.calledWithExactly(webex.internal.mercury.off, OFFLINE, offlineHandler);
8207
+ assert.calledOnceWithExactly(meeting.stopTranscription);
8208
+ assert.calledOnceWithExactly(meeting.annotation.deregisterEvents);
8209
+ });
8210
+
6455
8211
  it('should reset call diagnostic latencies correctly', async () => {
6456
8212
  const leave = meeting.leave();
6457
8213
 
@@ -7349,7 +9105,11 @@ describe('plugin-meetings', () => {
7349
9105
  beforeEach(() => {
7350
9106
  meeting.locusId = 'locus-id';
7351
9107
  meeting.id = 'meeting-id';
7352
- FAKE_OPTIONS = {meetingId: meeting.id, sendCAevents: true};
9108
+ FAKE_OPTIONS = {
9109
+ meetingId: meeting.id,
9110
+ sendCAevents: true,
9111
+ correlationId: meeting.correlationId,
9112
+ };
7353
9113
  });
7354
9114
 
7355
9115
  it('calls meetingInfoProvider with all the right parameters and parses the result', async () => {
@@ -7434,7 +9194,11 @@ describe('plugin-meetings', () => {
7434
9194
  undefined,
7435
9195
  meeting.locusId,
7436
9196
  {},
7437
- {meetingId: meeting.id, sendCAevents: false}
9197
+ {
9198
+ meetingId: meeting.id,
9199
+ sendCAevents: false,
9200
+ correlationId: meeting.correlationId,
9201
+ }
7438
9202
  );
7439
9203
 
7440
9204
  // parseMeeting info
@@ -7520,7 +9284,11 @@ describe('plugin-meetings', () => {
7520
9284
  undefined,
7521
9285
  'locus-id',
7522
9286
  {},
7523
- {meetingId: meeting.id, sendCAevents: true}
9287
+ {
9288
+ meetingId: meeting.id,
9289
+ sendCAevents: true,
9290
+ correlationId: meeting.correlationId,
9291
+ }
7524
9292
  );
7525
9293
 
7526
9294
  assert.deepEqual(meeting.meetingInfo, FAKE_MEETING_INFO);
@@ -7556,7 +9324,11 @@ describe('plugin-meetings', () => {
7556
9324
  undefined,
7557
9325
  'locus-id',
7558
9326
  {},
7559
- {meetingId: meeting.id, sendCAevents: true}
9327
+ {
9328
+ meetingId: meeting.id,
9329
+ sendCAevents: true,
9330
+ correlationId: meeting.correlationId,
9331
+ }
7560
9332
  );
7561
9333
 
7562
9334
  assert.deepEqual(meeting.meetingInfo, FAKE_MEETING_INFO);
@@ -7585,7 +9357,11 @@ describe('plugin-meetings', () => {
7585
9357
  undefined,
7586
9358
  'locus-id',
7587
9359
  {},
7588
- {meetingId: meeting.id, sendCAevents: true}
9360
+ {
9361
+ meetingId: meeting.id,
9362
+ sendCAevents: true,
9363
+ correlationId: meeting.correlationId,
9364
+ }
7589
9365
  );
7590
9366
 
7591
9367
  assert.deepEqual(meeting.meetingInfo, FAKE_MEETING_INFO);
@@ -7620,7 +9396,11 @@ describe('plugin-meetings', () => {
7620
9396
  undefined,
7621
9397
  'locus-id',
7622
9398
  {},
7623
- {meetingId: meeting.id, sendCAevents: true}
9399
+ {
9400
+ meetingId: meeting.id,
9401
+ sendCAevents: true,
9402
+ correlationId: meeting.correlationId,
9403
+ }
7624
9404
  );
7625
9405
 
7626
9406
  assert.deepEqual(meeting.meetingInfo, {});
@@ -7666,7 +9446,11 @@ describe('plugin-meetings', () => {
7666
9446
  undefined,
7667
9447
  'locus-id',
7668
9448
  {},
7669
- {meetingId: meeting.id, sendCAevents: true}
9449
+ {
9450
+ meetingId: meeting.id,
9451
+ sendCAevents: true,
9452
+ correlationId: meeting.correlationId,
9453
+ }
7670
9454
  );
7671
9455
 
7672
9456
  assert.deepEqual(meeting.meetingInfo, {});
@@ -7700,7 +9484,11 @@ describe('plugin-meetings', () => {
7700
9484
  undefined,
7701
9485
  'locus-id',
7702
9486
  {},
7703
- {meetingId: meeting.id, sendCAevents: true}
9487
+ {
9488
+ meetingId: meeting.id,
9489
+ sendCAevents: true,
9490
+ correlationId: meeting.correlationId,
9491
+ }
7704
9492
  );
7705
9493
 
7706
9494
  assert.deepEqual(meeting.meetingInfo, {
@@ -7753,7 +9541,11 @@ describe('plugin-meetings', () => {
7753
9541
  undefined,
7754
9542
  'locus-id',
7755
9543
  {},
7756
- {meetingId: meeting.id, sendCAevents: true}
9544
+ {
9545
+ meetingId: meeting.id,
9546
+ sendCAevents: true,
9547
+ correlationId: meeting.correlationId,
9548
+ }
7757
9549
  );
7758
9550
 
7759
9551
  assert.deepEqual(meeting.meetingInfo, FAKE_MEETING_INFO);
@@ -8042,7 +9834,11 @@ describe('plugin-meetings', () => {
8042
9834
  'fake-installed-org-id',
8043
9835
  'locus-id',
8044
9836
  {extraParam1: 'value1', permissionToken: FAKE_PERMISSION_TOKEN},
8045
- {meetingId: meeting.id, sendCAevents: true},
9837
+ {
9838
+ meetingId: meeting.id,
9839
+ sendCAevents: true,
9840
+ correlationId: meeting.correlationId,
9841
+ },
8046
9842
  null,
8047
9843
  null,
8048
9844
  null
@@ -8090,7 +9886,11 @@ describe('plugin-meetings', () => {
8090
9886
  'fake-installed-org-id',
8091
9887
  'locus-id',
8092
9888
  {extraParam1: 'value1', permissionToken: FAKE_PERMISSION_TOKEN},
8093
- {meetingId: meeting.id, sendCAevents: true},
9889
+ {
9890
+ meetingId: meeting.id,
9891
+ sendCAevents: true,
9892
+ correlationId: meeting.correlationId,
9893
+ },
8094
9894
  null,
8095
9895
  null,
8096
9896
  null
@@ -8147,7 +9947,11 @@ describe('plugin-meetings', () => {
8147
9947
  extraParam1: 'value1',
8148
9948
  permissionToken: FAKE_PERMISSION_TOKEN,
8149
9949
  },
8150
- {meetingId: meeting.id, sendCAevents: true},
9950
+ {
9951
+ meetingId: meeting.id,
9952
+ sendCAevents: true,
9953
+ correlationId: meeting.correlationId,
9954
+ },
8151
9955
  null,
8152
9956
  null,
8153
9957
  null
@@ -8459,6 +10263,9 @@ describe('plugin-meetings', () => {
8459
10263
 
8460
10264
  meeting.annotation.deregisterEvents = sinon.stub();
8461
10265
  webex.internal.llm.off = sinon.stub();
10266
+ webex.internal.mercury.off = sinon.stub();
10267
+ meeting.mercuryOnlineHandler = sinon.stub();
10268
+ meeting.mercuryOfflineHandler = sinon.stub();
8462
10269
 
8463
10270
  // A meeting needs to be joined to end
8464
10271
  meeting.meetingState = 'ACTIVE';
@@ -8481,6 +10288,66 @@ describe('plugin-meetings', () => {
8481
10288
  assert.calledOnce(meeting?.unsetPeerConnections);
8482
10289
  assert.calledOnce(meeting?.clearMeetingData);
8483
10290
  });
10291
+
10292
+ it('stops listening for LLM/Mercury and tears down transcription and annotation before calling Locus /end', async () => {
10293
+ const onlineHandler = meeting.mercuryOnlineHandler;
10294
+ const offlineHandler = meeting.mercuryOfflineHandler;
10295
+
10296
+ await meeting.endMeetingForAll();
10297
+
10298
+ // All llm/mercury consumers (direct listeners, voicea transcription,
10299
+ // annotation) must be detached before the /end request so that
10300
+ // in-flight events do not trigger unnecessary Locus syncs
10301
+ // (per Locus team recommendation).
10302
+ assert.callOrder(
10303
+ webex.internal.llm.off,
10304
+ webex.internal.mercury.off,
10305
+ meeting.stopTranscription,
10306
+ meeting.annotation.deregisterEvents,
10307
+ meeting.meetingRequest.endMeetingForAll
10308
+ );
10309
+ assert.calledWithExactly(
10310
+ webex.internal.llm.off,
10311
+ 'event:relay.event',
10312
+ meeting.processRelayEvent
10313
+ );
10314
+ assert.calledWithExactly(
10315
+ webex.internal.llm.off,
10316
+ LOCUS_LLM_EVENT,
10317
+ meeting.processLocusLLMEvent
10318
+ );
10319
+ assert.calledWithExactly(webex.internal.mercury.off, ONLINE, onlineHandler);
10320
+ assert.calledWithExactly(webex.internal.mercury.off, OFFLINE, offlineHandler);
10321
+ assert.isUndefined(meeting.mercuryOnlineHandler);
10322
+ assert.isUndefined(meeting.mercuryOfflineHandler);
10323
+ assert.calledOnceWithExactly(meeting.stopTranscription);
10324
+ assert.calledOnceWithExactly(meeting.annotation.deregisterEvents);
10325
+ });
10326
+
10327
+ it('tears down llm/mercury/transcription/annotation even when /end rejects', async () => {
10328
+ const onlineHandler = meeting.mercuryOnlineHandler;
10329
+ const offlineHandler = meeting.mercuryOfflineHandler;
10330
+ meeting.meetingRequest.endMeetingForAll = sinon
10331
+ .stub()
10332
+ .returns(Promise.reject(new Error('end failed')));
10333
+
10334
+ await meeting.endMeetingForAll().catch(() => {});
10335
+
10336
+ assert.calledWithExactly(
10337
+ webex.internal.llm.off,
10338
+ 'event:relay.event',
10339
+ meeting.processRelayEvent
10340
+ );
10341
+ assert.calledWithExactly(
10342
+ webex.internal.llm.off,
10343
+ LOCUS_LLM_EVENT,
10344
+ meeting.processLocusLLMEvent
10345
+ );
10346
+ assert.calledWithExactly(webex.internal.mercury.off, ONLINE, onlineHandler);
10347
+ assert.calledWithExactly(webex.internal.mercury.off, OFFLINE, offlineHandler);
10348
+ assert.calledOnceWithExactly(meeting.stopTranscription);
10349
+ assert.calledOnceWithExactly(meeting.annotation.deregisterEvents);
10350
+ });
8484
10351
  });
8485
10352
 
8486
10353
  describe('#moveTo', () => {
@@ -9262,7 +11129,9 @@ describe('plugin-meetings', () => {
9262
11129
  MediaCodecMimeType.OPUS,
9263
11130
  ['maxaveragebitrate', 'maxplaybackrate']
9264
11131
  );
9265
- assert.notCalled(meeting.sendSlotManager.getSlot(MediaType.AudioMain).setCustomCodecParameters);
11132
+ assert.notCalled(
11133
+ meeting.sendSlotManager.getSlot(MediaType.AudioMain).setCustomCodecParameters
11134
+ );
9266
11135
  });
9267
11136
  });
9268
11137
 
@@ -9990,6 +11859,8 @@ describe('plugin-meetings', () => {
9990
11859
  });
9991
11860
 
9992
11861
  it('handles REMOTE_SDP_ANSWER_PROCESSED correctly', () => {
11862
+ // capture the start timestamp before any fake timers are installed
11863
+ const localSdpGeneratedTimestamp = Date.now() - 100;
9993
11864
  const clock = sinon.useFakeTimers();
9994
11865
  sinon.spy(clock, 'clearTimeout');
9995
11866
  meeting.deferSDPAnswer = {
@@ -9997,24 +11868,29 @@ describe('plugin-meetings', () => {
9997
11868
  };
9998
11869
  meeting.sdpResponseTimer = '1234';
9999
11870
 
11871
+ // latency is computed as Date.now() - the stored local-sdp-generated timestamp,
11872
+ // so it is unaffected by any earlier remote-sdp-received timestamp saved on timeout
11873
+ webex.internal.newMetrics.callDiagnosticLatencies.latencyTimestamps = new Map([
11874
+ ['client.media-engine.local-sdp-generated', localSdpGeneratedTimestamp],
11875
+ ]);
11876
+
10000
11877
  eventListeners[MediaConnectionEventNames.REMOTE_SDP_ANSWER_PROCESSED]();
10001
11878
 
10002
11879
  assert.calledOnce(webex.internal.newMetrics.submitClientEvent);
10003
11880
  assert.calledWithMatch(webex.internal.newMetrics.submitClientEvent, {
10004
11881
  name: 'client.media-engine.remote-sdp-received',
11882
+ payload: {
11883
+ eventData: {
11884
+ localSDPGenRemoteSDPRecv: sinon.match(
11885
+ (value) => typeof value === 'number' && value >= 100 && value < 5000
11886
+ ),
11887
+ },
11888
+ },
10005
11889
  options: {meetingId: meeting.id},
10006
11890
  });
10007
11891
 
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
- );
11892
+ // the high-volume ROAP_OFFER_TO_ANSWER_LATENCY behavioral metric is no longer sent
11893
+ assert.notCalled(Metrics.sendBehavioralMetric);
10018
11894
 
10019
11895
  assert.calledOnce(meeting.deferSDPAnswer.resolve);
10020
11896
  assert.calledOnce(clock.clearTimeout);
@@ -10022,6 +11898,28 @@ describe('plugin-meetings', () => {
10022
11898
  assert.equal(meeting.sdpResponseTimer, undefined);
10023
11899
  });
10024
11900
 
11901
+ it('sends undefined localSDPGenRemoteSDPRecv when the local-sdp-generated timestamp is missing', () => {
11902
+ meeting.deferSDPAnswer = {
11903
+ resolve: sinon.stub(),
11904
+ };
11905
+
11906
+ // no local-sdp-generated timestamp stored -> latency cannot be computed
11907
+ webex.internal.newMetrics.callDiagnosticLatencies.latencyTimestamps = new Map();
11908
+
11909
+ eventListeners[MediaConnectionEventNames.REMOTE_SDP_ANSWER_PROCESSED]();
11910
+
11911
+ assert.calledOnce(webex.internal.newMetrics.submitClientEvent);
11912
+ assert.calledWithMatch(webex.internal.newMetrics.submitClientEvent, {
11913
+ name: 'client.media-engine.remote-sdp-received',
11914
+ payload: {
11915
+ eventData: {
11916
+ localSDPGenRemoteSDPRecv: undefined,
11917
+ },
11918
+ },
11919
+ options: {meetingId: meeting.id},
11920
+ });
11921
+ });
11922
+
10025
11923
  it('handles LOCAL_SDP_OFFER_GENERATED correctly', () => {
10026
11924
  assert.equal(meeting.deferSDPAnswer, undefined);
10027
11925
 
@@ -10417,16 +12315,16 @@ describe('plugin-meetings', () => {
10417
12315
  );
10418
12316
  done();
10419
12317
  });
10420
- it('listens to the self admitted guest event without blocking on token prefetch', async () => {
12318
+ it('listens to the self admitted guest event and waits for token prefetch before reconnecting LLM', async () => {
10421
12319
  meeting.stopKeepAlive = sinon.stub();
10422
12320
  meeting.updateLLMConnection = sinon.stub();
10423
12321
  let resolvePrefetch;
10424
12322
 
10425
- meeting.ensureDefaultDatachannelTokenAfterAdmit = sinon
10426
- .stub()
10427
- .returns(new Promise((resolve) => {
12323
+ meeting.ensureDefaultDatachannelTokenAfterAdmit = sinon.stub().returns(
12324
+ new Promise((resolve) => {
10428
12325
  resolvePrefetch = resolve;
10429
- }));
12326
+ })
12327
+ );
10430
12328
  meeting.rtcMetrics = {
10431
12329
  sendNextMetrics: sinon.stub(),
10432
12330
  };
@@ -10443,7 +12341,7 @@ describe('plugin-meetings', () => {
10443
12341
  'meeting:self:guestAdmitted',
10444
12342
  {payload: test1}
10445
12343
  );
10446
- assert.calledOnce(meeting.updateLLMConnection);
12344
+ assert.notCalled(meeting.updateLLMConnection);
10447
12345
  assert.calledOnceWithExactly(meeting.rtcMetrics.sendNextMetrics);
10448
12346
 
10449
12347
  assert.calledOnceWithExactly(
@@ -10456,6 +12354,7 @@ describe('plugin-meetings', () => {
10456
12354
 
10457
12355
  resolvePrefetch(false);
10458
12356
  await Promise.resolve();
12357
+ await Promise.resolve();
10459
12358
 
10460
12359
  assert.calledOnce(meeting.updateLLMConnection);
10461
12360
  });
@@ -10971,6 +12870,106 @@ describe('plugin-meetings', () => {
10971
12870
  );
10972
12871
  });
10973
12872
 
12873
+ const recordingTestCases = [
12874
+ {
12875
+ description: 'triggers MEETING_STARTED_RECORDING when state is RECORDING',
12876
+ state: RECORDING_STATE.RECORDING,
12877
+ expectedEvent: EVENT_TRIGGERS.MEETING_STARTED_RECORDING,
12878
+ expectedRecordingState: RECORDING_STATE.RECORDING,
12879
+ },
12880
+ {
12881
+ description: 'triggers MEETING_STOPPED_RECORDING when state is IDLE',
12882
+ state: RECORDING_STATE.IDLE,
12883
+ expectedEvent: EVENT_TRIGGERS.MEETING_STOPPED_RECORDING,
12884
+ expectedRecordingState: RECORDING_STATE.IDLE,
12885
+ },
12886
+ {
12887
+ description: 'triggers MEETING_PAUSED_RECORDING when state is PAUSED',
12888
+ state: RECORDING_STATE.PAUSED,
12889
+ expectedEvent: EVENT_TRIGGERS.MEETING_PAUSED_RECORDING,
12890
+ expectedRecordingState: RECORDING_STATE.PAUSED,
12891
+ },
12892
+ {
12893
+ description:
12894
+ 'triggers MEETING_RESUMED_RECORDING and sets state to RECORDING when state is RESUMED',
12895
+ state: RECORDING_STATE.RESUMED,
12896
+ expectedEvent: EVENT_TRIGGERS.MEETING_RESUMED_RECORDING,
12897
+ expectedRecordingState: RECORDING_STATE.RECORDING,
12898
+ },
12899
+ ];
12900
+
12901
+ recordingTestCases.forEach(
12902
+ ({description, state, expectedEvent, expectedRecordingState}) => {
12903
+ it(`listens to CONTROLS_RECORDING_UPDATED - ${description}`, async () => {
12904
+ const modifiedBy = 'user-id-123';
12905
+ const lastModified = '2026-01-01T00:00:00Z';
12906
+
12907
+ await meeting.locusInfo.emitScoped(
12908
+ {function: 'test', file: 'test'},
12909
+ LOCUSINFO.EVENTS.CONTROLS_RECORDING_UPDATED,
12910
+ {
12911
+ state,
12912
+ modifiedBy,
12913
+ lastModified,
12914
+ modifiedByServiceAppName: undefined,
12915
+ modifiedByServiceAppId: undefined,
12916
+ }
12917
+ );
12918
+
12919
+ assert.deepEqual(meeting.recording, {
12920
+ state: expectedRecordingState,
12921
+ modifiedBy,
12922
+ lastModified,
12923
+ modifiedByServiceAppName: undefined,
12924
+ modifiedByServiceAppId: undefined,
12925
+ });
12926
+
12927
+ assert.calledWith(
12928
+ TriggerProxy.trigger,
12929
+ meeting,
12930
+ {file: 'meeting/index', function: 'setupLocusControlsListener'},
12931
+ expectedEvent,
12932
+ meeting.recording
12933
+ );
12934
+ });
12935
+ }
12936
+ );
12937
+
12938
+ it('listens to CONTROLS_RECORDING_UPDATED and includes modifiedByServiceAppName and modifiedByServiceAppId when present', async () => {
12939
+ const modifiedBy = 'user-id-123';
12940
+ const lastModified = '2026-01-01T00:00:00Z';
12941
+ const modifiedByServiceAppName = 'My Bot';
12942
+ const modifiedByServiceAppId = 'app-id-123';
12943
+
12944
+ await meeting.locusInfo.emitScoped(
12945
+ {function: 'test', file: 'test'},
12946
+ LOCUSINFO.EVENTS.CONTROLS_RECORDING_UPDATED,
12947
+ {
12948
+ state: RECORDING_STATE.RECORDING,
12949
+ modifiedBy,
12950
+ lastModified,
12951
+ modifiedByServiceAppName,
12952
+ modifiedByServiceAppId,
12953
+ }
12954
+ );
12955
+
12956
+ assert.deepEqual(meeting.recording, {
12957
+ state: RECORDING_STATE.RECORDING,
12958
+ modifiedBy,
12959
+ lastModified,
12960
+ modifiedByServiceAppName,
12961
+ modifiedByServiceAppId,
12962
+ });
12963
+
12964
+ assert.calledWith(
12965
+ TriggerProxy.trigger,
12966
+ meeting,
12967
+ {file: 'meeting/index', function: 'setupLocusControlsListener'},
12968
+ EVENT_TRIGGERS.MEETING_STARTED_RECORDING,
12969
+ meeting.recording
12970
+ );
12971
+ });
12972
+
10974
12973
  it('listens to the locus interpretation update event', () => {
10975
12974
  const interpretation = {
10976
12975
  siLanguages: [{languageCode: 20, languageName: 'en'}],
@@ -11024,6 +13023,7 @@ describe('plugin-meetings', () => {
11024
13023
  meeting.annotation.locusUrlUpdate = sinon.stub();
11025
13024
  meeting.simultaneousInterpretation.locusUrlUpdate = sinon.stub();
11026
13025
  meeting.webinar.locusUrlUpdate = sinon.stub();
13026
+ meeting.aiEnableRequest.locusUrlUpdate = sinon.stub();
11027
13027
 
11028
13028
  meeting.locusInfo.emit(
11029
13029
  {function: 'test', file: 'test'},
@@ -11038,6 +13038,7 @@ describe('plugin-meetings', () => {
11038
13038
  assert.calledWith(meeting.controlsOptionsManager.setLocusUrl, newLocusUrl, false);
11039
13039
  assert.calledWith(meeting.simultaneousInterpretation.locusUrlUpdate, newLocusUrl);
11040
13040
  assert.calledWith(meeting.webinar.locusUrlUpdate, newLocusUrl);
13041
+ assert.calledWith(meeting.aiEnableRequest.locusUrlUpdate, newLocusUrl);
11041
13042
  assert.equal(meeting.locusUrl, newLocusUrl);
11042
13043
  assert(meeting.locusId, '12345');
11043
13044
 
@@ -11353,6 +13354,109 @@ describe('plugin-meetings', () => {
11353
13354
  });
11354
13355
  });
11355
13356
 
13357
+ describe('#finalizeMeetingAfterInitialLocusSetup', () => {
13358
+ it('refreshes destination from synced locus when destination type is LOCUS_ID', () => {
13359
+ const syncedLocus = {url: 'https://locus.example.com/locus/123', info: {topic: 'x'}};
13360
+
13361
+ meeting.destinationType = DESTINATION_TYPE.LOCUS_ID;
13362
+ meeting.destination = {info: {topic: 'old'}};
13363
+
13364
+ meeting.finalizeMeetingAfterInitialLocusSetup(syncedLocus);
13365
+
13366
+ assert.equal(meeting.destination, syncedLocus);
13367
+ });
13368
+
13369
+ it('does not refresh destination when destination type is not LOCUS_ID', () => {
13370
+ const syncedLocus = {url: 'https://locus.example.com/locus/123', info: {topic: 'x'}};
13371
+ const originalDestination = {destination: 'original-destination'};
13372
+
13373
+ meeting.destinationType = DESTINATION_TYPE.CONVERSATION_URL;
13374
+ meeting.destination = originalDestination;
13375
+
13376
+ meeting.finalizeMeetingAfterInitialLocusSetup(syncedLocus);
13377
+
13378
+ assert.equal(meeting.destination, originalDestination);
13379
+ });
13380
+
13381
+ it('fetches meeting info when meetingInfo is empty and destination has info', () => {
13382
+ const fetchMeetingInfoStub = sinon.stub(meeting, 'fetchMeetingInfo').resolves();
13383
+
13384
+ meeting.meetingInfo = {};
13385
+ meeting.destination = {url: 'https://locus.example.com/locus/123', info: {topic: 'x'}};
13386
+
13387
+ meeting.finalizeMeetingAfterInitialLocusSetup({});
13388
+
13389
+ assert.calledOnceWithExactly(fetchMeetingInfoStub, {});
13390
+ });
13391
+
13392
+ it('does not fetch meeting info when destination has no info', () => {
13393
+ const fetchMeetingInfoStub = sinon.stub(meeting, 'fetchMeetingInfo').resolves();
13394
+
13395
+ meeting.meetingInfo = {};
13396
+ meeting.destination = {url: 'https://locus.example.com/locus/123'};
13397
+
13398
+ meeting.finalizeMeetingAfterInitialLocusSetup({});
13399
+
13400
+ assert.notCalled(fetchMeetingInfoStub);
13401
+ });
13402
+
13403
+ it('does not fetch meeting info when meetingInfo is already populated', () => {
13404
+ const fetchMeetingInfoStub = sinon.stub(meeting, 'fetchMeetingInfo').resolves();
13405
+
13406
+ meeting.meetingInfo = {meetingJoinUrl: 'https://example.com/join/abc'};
13407
+ meeting.destination = {url: 'https://locus.example.com/locus/123', info: {topic: 'x'}};
13408
+
13409
+ meeting.finalizeMeetingAfterInitialLocusSetup({});
13410
+
13411
+ assert.notCalled(fetchMeetingInfoStub);
13412
+ });
13413
+
13414
+ it('does not fetch meeting info when delayed fetch timer is already scheduled', () => {
13415
+ const fetchMeetingInfoStub = sinon.stub(meeting, 'fetchMeetingInfo').resolves();
13416
+
13417
+ meeting.meetingInfo = {};
13418
+ meeting.destination = {url: 'https://locus.example.com/locus/123', info: {topic: 'x'}};
13419
+ meeting.fetchMeetingInfoTimeoutId = 42;
13420
+
13421
+ meeting.finalizeMeetingAfterInitialLocusSetup({});
13422
+
13423
+ assert.notCalled(fetchMeetingInfoStub);
13424
+ });
13425
+
13426
+ ['CALL', 'SIP_BRIDGE', 'SPACE_SHARE'].forEach((fullStateType) => {
13427
+ it(`does not fetch meeting info when destination is a 1:1 call (fullState.type ${fullStateType})`, () => {
13428
+ const fetchMeetingInfoStub = sinon.stub(meeting, 'fetchMeetingInfo').resolves();
13429
+
13430
+ meeting.meetingInfo = {};
13431
+ meeting.destination = {
13432
+ url: 'https://locus.example.com/locus/123',
13433
+ info: {topic: 'x'},
13434
+ };
13435
+
13436
+ meeting.finalizeMeetingAfterInitialLocusSetup({fullState: {type: fullStateType}});
13437
+
13438
+ assert.notCalled(fetchMeetingInfoStub);
13439
+ });
13440
+ });
13441
+
13442
+ it('swallows async fetchMeetingInfo errors and logs info', async () => {
13443
+ const error = new Error('fetch failed');
13444
+
13445
+ meeting.meetingInfo = {};
13446
+ meeting.destination = {url: 'https://locus.example.com/locus/123', info: {topic: 'x'}};
13447
+ sinon.stub(meeting, 'fetchMeetingInfo').returns(Promise.reject(error));
13448
+ const loggerInfoStub = sinon.stub(LoggerProxy.logger, 'info');
13449
+
13450
+ await meeting.finalizeMeetingAfterInitialLocusSetup({});
13451
+
13452
+ assert.calledOnce(loggerInfoStub);
13453
+ assert.match(
13454
+ loggerInfoStub.firstCall.args[0],
13455
+ /Meeting:index#finalizeMeetingAfterInitialLocusSetup --> deferred fetchMeetingInfo failed: fetch failed/
13456
+ );
13457
+ });
13458
+ });
13459
+
11356
13460
  describe('#emailInput', () => {
11357
13461
  it('should set the email input', () => {
11358
13462
  assert.notOk(meeting.emailInput);
@@ -11955,6 +14059,7 @@ describe('plugin-meetings', () => {
11955
14059
  let showAutoEndMeetingWarningSpy;
11956
14060
  let canAttendeeRequestAiAssistantEnabledSpy;
11957
14061
  let attendeeRequestAiAssistantDeclinedAllSpy;
14062
+ let isAnonymizeDisplayNamesEnabledSpy;
11958
14063
  // Due to import tree issues, hasHints must be stubed within the scope of the `it`.
11959
14064
 
11960
14065
  beforeEach(() => {
@@ -12003,6 +14108,10 @@ describe('plugin-meetings', () => {
12003
14108
  MeetingUtil,
12004
14109
  'attendeeRequestAiAssistantDeclinedAll'
12005
14110
  );
14111
+ isAnonymizeDisplayNamesEnabledSpy = sinon.spy(
14112
+ MeetingUtil,
14113
+ 'isAnonymizeDisplayNamesEnabled'
14114
+ );
12006
14115
  });
12007
14116
 
12008
14117
  afterEach(() => {
@@ -12011,6 +14120,7 @@ describe('plugin-meetings', () => {
12011
14120
  showAutoEndMeetingWarningSpy.restore();
12012
14121
  canAttendeeRequestAiAssistantEnabledSpy.restore();
12013
14122
  attendeeRequestAiAssistantDeclinedAllSpy.restore();
14123
+ isAnonymizeDisplayNamesEnabledSpy.restore();
12014
14124
  });
12015
14125
 
12016
14126
  forEach(
@@ -12137,6 +14247,11 @@ describe('plugin-meetings', () => {
12137
14247
  requiredDisplayHints: [],
12138
14248
  requiredPolicies: [SELF_POLICY.SUPPORT_ANNOTATION],
12139
14249
  },
14250
+ {
14251
+ actionName: 'isSupportParticipantList',
14252
+ requiredDisplayHints: [],
14253
+ requiredPolicies: [SELF_POLICY.SUPPORT_PARTICIPANT_LIST],
14254
+ },
12140
14255
  {
12141
14256
  actionName: 'canPollingAndQA',
12142
14257
  requiredDisplayHints: [],
@@ -12568,6 +14683,7 @@ describe('plugin-meetings', () => {
12568
14683
  meeting.roles
12569
14684
  );
12570
14685
  assert.calledWith(attendeeRequestAiAssistantDeclinedAllSpy, userDisplayHints);
14686
+ assert.calledWith(isAnonymizeDisplayNamesEnabledSpy, userDisplayHints);
12571
14687
 
12572
14688
  assert.calledWith(ControlsOptionsUtil.hasHints, {
12573
14689
  requiredHints: [DISPLAY_HINTS.MUTE_ALL],
@@ -12782,6 +14898,10 @@ describe('plugin-meetings', () => {
12782
14898
  describe('#saveDataChannelToken', () => {
12783
14899
  beforeEach(() => {
12784
14900
  webex.internal.llm.setDatachannelToken = sinon.stub();
14901
+ webex.internal.llm.resolveSessionOwnership = sinon
14902
+ .stub()
14903
+ .returns({currentOwner: undefined, isOwner: true});
14904
+ webex.internal.llm.isConnected = sinon.stub().returns(false);
12785
14905
  });
12786
14906
 
12787
14907
  it('saves datachannelToken into LLM as Default', () => {
@@ -12794,7 +14914,8 @@ describe('plugin-meetings', () => {
12794
14914
  assert.calledWithExactly(
12795
14915
  webex.internal.llm.setDatachannelToken,
12796
14916
  'default-token',
12797
- 'llm-default-session'
14917
+ 'llm-default-session',
14918
+ meeting.id
12798
14919
  );
12799
14920
  });
12800
14921
 
@@ -12808,7 +14929,8 @@ describe('plugin-meetings', () => {
12808
14929
  assert.calledWithExactly(
12809
14930
  webex.internal.llm.setDatachannelToken,
12810
14931
  'ps-token',
12811
- 'llm-practice-session'
14932
+ 'llm-practice-session',
14933
+ meeting.id
12812
14934
  );
12813
14935
  });
12814
14936
 
@@ -12826,12 +14948,14 @@ describe('plugin-meetings', () => {
12826
14948
  assert.calledWithExactly(
12827
14949
  webex.internal.llm.setDatachannelToken,
12828
14950
  'default-token',
12829
- 'llm-default-session'
14951
+ 'llm-default-session',
14952
+ meeting.id
12830
14953
  );
12831
14954
  assert.calledWithExactly(
12832
14955
  webex.internal.llm.setDatachannelToken,
12833
14956
  'ps-token',
12834
- 'llm-practice-session'
14957
+ 'llm-practice-session',
14958
+ meeting.id
12835
14959
  );
12836
14960
  });
12837
14961
 
@@ -12850,19 +14974,44 @@ describe('plugin-meetings', () => {
12850
14974
  it('handles missing locus.self gracefully', () => {
12851
14975
  meeting.saveDataChannelToken({locus: {}});
12852
14976
 
12853
- assert.notCalled(webex.internal.llm.setDatachannelToken);
14977
+ assert.notCalled(webex.internal.llm.setDatachannelToken);
14978
+ });
14979
+
14980
+ it('writes token with meeting id as owner', () => {
14981
+ meeting.saveDataChannelToken({
14982
+ locus: {
14983
+ self: {datachannelToken: 'default-token'},
14984
+ },
14985
+ });
14986
+
14987
+ assert.calledOnceWithExactly(
14988
+ webex.internal.llm.setDatachannelToken,
14989
+ 'default-token',
14990
+ 'llm-default-session',
14991
+ meeting.id
14992
+ );
12854
14993
  });
12855
14994
  });
12856
14995
 
12857
14996
  describe('#clearDataChannelToken', () => {
12858
14997
  beforeEach(() => {
12859
- webex.internal.llm.resetDatachannelTokens = sinon.stub();
14998
+ webex.internal.llm.clearDatachannelToken = sinon.stub();
12860
14999
  });
12861
15000
 
12862
- it('calls resetDatachannelTokens on LLM', () => {
15001
+ it('delegates default and practice token clears to llm with meeting ownership id', () => {
12863
15002
  meeting.clearDataChannelToken();
12864
15003
 
12865
- assert.calledOnce(webex.internal.llm.resetDatachannelTokens);
15004
+ assert.calledWithExactly(
15005
+ webex.internal.llm.clearDatachannelToken,
15006
+ 'llm-default-session',
15007
+ meeting.id
15008
+ );
15009
+ assert.calledWithExactly(
15010
+ webex.internal.llm.clearDatachannelToken,
15011
+ 'llm-practice-session',
15012
+ meeting.id
15013
+ );
15014
+ assert.callCount(webex.internal.llm.clearDatachannelToken, 2);
12866
15015
  });
12867
15016
  });
12868
15017
 
@@ -12872,6 +15021,7 @@ describe('plugin-meetings', () => {
12872
15021
  webex.internal.llm.getLocusUrl = sinon.stub();
12873
15022
  webex.internal.llm.getDatachannelUrl = sinon.stub();
12874
15023
  webex.internal.llm.registerAndConnect = sinon.stub().resolves('something');
15024
+ webex.internal.llm.setRefreshHandler = sinon.stub();
12875
15025
  webex.internal.llm.disconnectLLM = sinon.stub().resolves();
12876
15026
  webex.internal.llm.on = sinon.stub();
12877
15027
  webex.internal.llm.off = sinon.stub();
@@ -12889,7 +15039,11 @@ describe('plugin-meetings', () => {
12889
15039
  meeting.joinedWith = {state: 'any other state'};
12890
15040
  webex.internal.llm.getLocusUrl.returns('a url');
12891
15041
 
12892
- meeting.locusInfo = {url: 'a url', info: {datachannelUrl: 'a datachannel url'}};
15042
+ meeting.locusInfo = {
15043
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
15044
+ url: 'a url',
15045
+ info: {datachannelUrl: 'a datachannel url'},
15046
+ };
12893
15047
 
12894
15048
  const result = await meeting.updateLLMConnection();
12895
15049
 
@@ -12901,6 +15055,7 @@ describe('plugin-meetings', () => {
12901
15055
  it('returns undefined if llm is already connected and the locus url is unchanged', async () => {
12902
15056
  meeting.joinedWith = {state: 'JOINED'};
12903
15057
  meeting.locusInfo = {
15058
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
12904
15059
  url: 'a url',
12905
15060
  info: {datachannelUrl: 'a datachannel url'},
12906
15061
  };
@@ -12937,7 +15092,11 @@ describe('plugin-meetings', () => {
12937
15092
  });
12938
15093
  it('connects if not already connected', async () => {
12939
15094
  meeting.joinedWith = {state: 'JOINED'};
12940
- meeting.locusInfo = {url: 'a url', info: {datachannelUrl: 'a datachannel url'}};
15095
+ meeting.locusInfo = {
15096
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
15097
+ url: 'a url',
15098
+ info: {datachannelUrl: 'a datachannel url'},
15099
+ };
12941
15100
 
12942
15101
  const result = await meeting.updateLLMConnection();
12943
15102
 
@@ -12948,7 +15107,14 @@ describe('plugin-meetings', () => {
12948
15107
  'a datachannel url',
12949
15108
  undefined
12950
15109
  );
15110
+ assert.calledOnceWithExactly(
15111
+ webex.internal.llm.setRefreshHandler,
15112
+ sinon.match.func,
15113
+ 'llm-default-session',
15114
+ meeting.id
15115
+ );
12951
15116
  assert.equal(result, 'something');
15117
+ assert.calledOnceWithExactly(meeting.locusInfo.syncAllHashTreeDatasets, {onlyLLM: true});
12952
15118
  });
12953
15119
  it('disconnects if the locus url has changed', async () => {
12954
15120
  meeting.joinedWith = {state: 'JOINED'};
@@ -12957,6 +15123,7 @@ describe('plugin-meetings', () => {
12957
15123
  webex.internal.llm.getLocusUrl.returns('a url');
12958
15124
 
12959
15125
  meeting.locusInfo = {
15126
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
12960
15127
  url: 'a different url',
12961
15128
  info: {datachannelUrl: 'a datachannel url'},
12962
15129
  self: {},
@@ -12964,10 +15131,15 @@ describe('plugin-meetings', () => {
12964
15131
 
12965
15132
  const result = await meeting.updateLLMConnection();
12966
15133
 
12967
- assert.calledWithExactly(webex.internal.llm.disconnectLLM, {
12968
- code: 3050,
12969
- reason: 'done (permanent)',
12970
- });
15134
+ assert.calledWithExactly(
15135
+ webex.internal.llm.disconnectLLM,
15136
+ {
15137
+ code: 3050,
15138
+ reason: 'done (permanent)',
15139
+ },
15140
+ 'llm-default-session',
15141
+ meeting.id
15142
+ );
12971
15143
 
12972
15144
  assert.calledWithExactly(
12973
15145
  webex.internal.llm.registerAndConnect,
@@ -13010,6 +15182,7 @@ describe('plugin-meetings', () => {
13010
15182
  webex.internal.llm.getLocusUrl.returns('a url');
13011
15183
 
13012
15184
  meeting.locusInfo = {
15185
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
13013
15186
  url: 'a url',
13014
15187
  info: {datachannelUrl: 'a different datachannel url'},
13015
15188
  self: {},
@@ -13017,10 +15190,15 @@ describe('plugin-meetings', () => {
13017
15190
 
13018
15191
  const result = await meeting.updateLLMConnection();
13019
15192
 
13020
- assert.calledWithExactly(webex.internal.llm.disconnectLLM, {
13021
- code: 3050,
13022
- reason: 'done (permanent)',
13023
- });
15193
+ assert.calledWithExactly(
15194
+ webex.internal.llm.disconnectLLM,
15195
+ {
15196
+ code: 3050,
15197
+ reason: 'done (permanent)',
15198
+ },
15199
+ 'llm-default-session',
15200
+ meeting.id
15201
+ );
13024
15202
 
13025
15203
  assert.calledWithExactly(
13026
15204
  webex.internal.llm.registerAndConnect,
@@ -13061,14 +15239,23 @@ describe('plugin-meetings', () => {
13061
15239
  webex.internal.llm.isConnected.returns(true);
13062
15240
  webex.internal.llm.getLocusUrl.returns('a url');
13063
15241
 
13064
- meeting.locusInfo = {url: 'a url', info: {datachannelUrl: 'a datachannel url'}};
15242
+ meeting.locusInfo = {
15243
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
15244
+ url: 'a url',
15245
+ info: {datachannelUrl: 'a datachannel url'},
15246
+ };
13065
15247
 
13066
15248
  const result = await meeting.updateLLMConnection();
13067
15249
 
13068
- assert.calledWith(webex.internal.llm.disconnectLLM, {
13069
- code: 3050,
13070
- reason: 'done (permanent)',
13071
- });
15250
+ assert.calledWith(
15251
+ webex.internal.llm.disconnectLLM,
15252
+ {
15253
+ code: 3050,
15254
+ reason: 'done (permanent)',
15255
+ },
15256
+ 'llm-default-session',
15257
+ meeting.id
15258
+ );
13072
15259
  assert.notCalled(webex.internal.llm.registerAndConnect);
13073
15260
  assert.equal(result, undefined);
13074
15261
  assert.isFalse(
@@ -13084,6 +15271,7 @@ describe('plugin-meetings', () => {
13084
15271
  webex.internal.llm.disconnectLLM.rejects(disconnectError);
13085
15272
 
13086
15273
  meeting.locusInfo = {
15274
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
13087
15275
  url: 'a different url',
13088
15276
  info: {datachannelUrl: 'a datachannel url'},
13089
15277
  self: {},
@@ -13115,6 +15303,7 @@ describe('plugin-meetings', () => {
13115
15303
  it('still need connect main session data channel when PS started', async () => {
13116
15304
  meeting.joinedWith = {state: 'JOINED'};
13117
15305
  meeting.locusInfo = {
15306
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
13118
15307
  url: 'a url',
13119
15308
  info: {
13120
15309
  datachannelUrl: 'a datachannel url',
@@ -13135,11 +15324,14 @@ describe('plugin-meetings', () => {
13135
15324
  it('passes dataChannelToken from LLM to registerAndConnect', async () => {
13136
15325
  meeting.joinedWith = {state: 'JOINED'};
13137
15326
  meeting.locusInfo = {
15327
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
13138
15328
  url: 'a url',
13139
15329
  info: {datachannelUrl: 'a datachannel url'},
13140
15330
  };
13141
15331
 
13142
- webex.internal.llm.getDatachannelToken.withArgs('llm-default-session').returns('token-123');
15332
+ webex.internal.llm.getDatachannelToken
15333
+ .withArgs('llm-default-session', meeting.id)
15334
+ .returns('token-123');
13143
15335
 
13144
15336
  await meeting.updateLLMConnection();
13145
15337
 
@@ -13154,6 +15346,7 @@ describe('plugin-meetings', () => {
13154
15346
  it('passes undefined token when LLM has no token stored', async () => {
13155
15347
  meeting.joinedWith = {state: 'JOINED'};
13156
15348
  meeting.locusInfo = {
15349
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
13157
15350
  url: 'a url',
13158
15351
  info: {datachannelUrl: 'a datachannel url'},
13159
15352
  };
@@ -13175,6 +15368,7 @@ describe('plugin-meetings', () => {
13175
15368
  it('does not pass token when data channel with jwt token is disabled', async () => {
13176
15369
  meeting.joinedWith = {state: 'JOINED'};
13177
15370
  meeting.locusInfo = {
15371
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
13178
15372
  url: 'a url',
13179
15373
  info: {datachannelUrl: 'a datachannel url'},
13180
15374
  };
@@ -13193,6 +15387,209 @@ describe('plugin-meetings', () => {
13193
15387
  assert.notCalled(webex.internal.llm.setDatachannelToken);
13194
15388
  });
13195
15389
 
15390
+ describe('ownership tag', () => {
15391
+ beforeEach(() => {
15392
+ // Make the owner stub dynamic so setOwnerMeetingId() writes
15393
+ // propagate back to getOwnerMeetingId() reads. This mirrors the
15394
+ // real LLM singleton behavior so the finally-block release in
15395
+ // cleanupLLMConneciton is reflected in subsequent reads.
15396
+ webex.internal.llm.getOwnerMeetingId = sinon.stub().returns(undefined);
15397
+ webex.internal.llm.setOwnerMeetingId = sinon.stub().callsFake((id) => {
15398
+ webex.internal.llm.getOwnerMeetingId.returns(id);
15399
+ });
15400
+ });
15401
+
15402
+ it('skips disconnect and reconnect when LLM is connected and owned by another meeting (regardless of URL)', async () => {
15403
+ meeting.joinedWith = {state: 'JOINED'};
15404
+ webex.internal.llm.isConnected.returns(true);
15405
+ webex.internal.llm.getOwnerMeetingId.returns('some-other-meeting-id');
15406
+ // Locus/datachannel URL mismatch is the *normal* case when
15407
+ // another meeting owns the live socket -- each meeting has its
15408
+ // own locus URL. URL mismatch must NOT trigger a reclaim,
15409
+ // because doing so would tear down the owning meeting's healthy
15410
+ // LLM socket and break its data channel.
15411
+ webex.internal.llm.getLocusUrl.returns('owner-locus-url');
15412
+ webex.internal.llm.getDatachannelUrl.returns('owner-dc-url');
15413
+ meeting.locusInfo = {
15414
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
15415
+ url: 'a different url',
15416
+ info: {datachannelUrl: 'a different datachannel url'},
15417
+ self: {},
15418
+ };
15419
+
15420
+ const result = await meeting.updateLLMConnection();
15421
+
15422
+ assert.equal(result, undefined);
15423
+ assert.notCalled(webex.internal.llm.disconnectLLM);
15424
+ assert.notCalled(webex.internal.llm.registerAndConnect);
15425
+ assert.notCalled(webex.internal.llm.setOwnerMeetingId);
15426
+ assert.notCalled(meeting.startLLMHealthCheckTimer);
15427
+ });
15428
+
15429
+ it('clears stale owner tag in cleanup finally block even when disconnectLLM rejects', async () => {
15430
+ meeting.joinedWith = {state: 'JOINED'};
15431
+ webex.internal.llm.isConnected.returns(true);
15432
+ webex.internal.llm.getOwnerMeetingId.returns(meeting.id);
15433
+ webex.internal.llm.getLocusUrl.returns('a url');
15434
+ webex.internal.llm.getDatachannelUrl.returns('a datachannel url');
15435
+ webex.internal.llm.disconnectLLM.rejects(new Error('disconnect failed'));
15436
+ meeting.locusInfo = {
15437
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
15438
+ url: 'a different url',
15439
+ info: {datachannelUrl: 'a datachannel url'},
15440
+ self: {},
15441
+ };
15442
+
15443
+ try {
15444
+ await meeting.updateLLMConnection();
15445
+ } catch (e) {
15446
+ /* updateLLMConnection may reject when cleanup throws */
15447
+ }
15448
+
15449
+ // The owner-eligible finally branch must release the tag so a
15450
+ // subsequent reconnect attempt from any meeting is not blocked.
15451
+ assert.calledWith(webex.internal.llm.setOwnerMeetingId, undefined);
15452
+ });
15453
+
15454
+ it('does not clear owner tag when ownership changes during cleanup disconnect await', async () => {
15455
+ meeting.joinedWith = {state: 'JOINED'};
15456
+ webex.internal.llm.isConnected.returns(true);
15457
+ webex.internal.llm.getOwnerMeetingId.returns(meeting.id);
15458
+ webex.internal.llm.getLocusUrl.returns('a url');
15459
+ webex.internal.llm.getDatachannelUrl.returns('a datachannel url');
15460
+ webex.internal.llm.disconnectLLM.callsFake(async () => {
15461
+ webex.internal.llm.getOwnerMeetingId.returns('new-owner-id');
15462
+ throw new Error('disconnect failed');
15463
+ });
15464
+ meeting.locusInfo = {
15465
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
15466
+ url: 'a different url',
15467
+ info: {datachannelUrl: 'a datachannel url'},
15468
+ self: {},
15469
+ };
15470
+
15471
+ try {
15472
+ await meeting.updateLLMConnection();
15473
+ } catch (e) {
15474
+ /* updateLLMConnection may reject when cleanup throws */
15475
+ }
15476
+
15477
+ assert.notCalled(webex.internal.llm.setOwnerMeetingId);
15478
+ assert.equal(webex.internal.llm.getOwnerMeetingId(), 'new-owner-id');
15479
+ });
15480
+
15481
+ it('proceeds normally when LLM is connected and owned by this meeting with URL change', async () => {
15482
+ meeting.joinedWith = {state: 'JOINED'};
15483
+ webex.internal.llm.isConnected.returns(true);
15484
+ webex.internal.llm.getOwnerMeetingId.returns(meeting.id);
15485
+ webex.internal.llm.getLocusUrl.returns('a url');
15486
+ webex.internal.llm.getDatachannelUrl.returns('a datachannel url');
15487
+ meeting.locusInfo = {
15488
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
15489
+ url: 'a different url',
15490
+ info: {datachannelUrl: 'a datachannel url'},
15491
+ self: {},
15492
+ };
15493
+
15494
+ await meeting.updateLLMConnection();
15495
+
15496
+ assert.calledOnceWithExactly(
15497
+ webex.internal.llm.disconnectLLM,
15498
+ {
15499
+ code: 3050,
15500
+ reason: 'done (permanent)',
15501
+ },
15502
+ 'llm-default-session',
15503
+ meeting.id
15504
+ );
15505
+ assert.calledWithExactly(
15506
+ webex.internal.llm.registerAndConnect,
15507
+ 'a different url',
15508
+ 'a datachannel url',
15509
+ undefined
15510
+ );
15511
+ // setOwnerMeetingId is called twice: first with undefined in
15512
+ // cleanupLLMConneciton's finally block (so a failed disconnect
15513
+ // cannot leave a stale owner), then with this meeting's id
15514
+ // after registerAndConnect resolves.
15515
+ assert.calledTwice(webex.internal.llm.setOwnerMeetingId);
15516
+ assert.calledWith(webex.internal.llm.setOwnerMeetingId.firstCall, undefined);
15517
+ assert.calledWith(webex.internal.llm.setOwnerMeetingId.lastCall, meeting.id);
15518
+ });
15519
+
15520
+ it('claims ownership after successful registerAndConnect on initial connect', async () => {
15521
+ meeting.joinedWith = {state: 'JOINED'};
15522
+ webex.internal.llm.isConnected.returns(false);
15523
+ webex.internal.llm.getOwnerMeetingId.returns(undefined);
15524
+ meeting.locusInfo = {
15525
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
15526
+ url: 'a url',
15527
+ info: {datachannelUrl: 'a datachannel url'},
15528
+ };
15529
+
15530
+ await meeting.updateLLMConnection();
15531
+
15532
+ assert.calledOnce(webex.internal.llm.registerAndConnect);
15533
+ assert.calledOnceWithExactly(
15534
+ webex.internal.llm.setRefreshHandler,
15535
+ sinon.match.func,
15536
+ 'llm-default-session',
15537
+ meeting.id
15538
+ );
15539
+ assert.calledOnceWithExactly(webex.internal.llm.setOwnerMeetingId, meeting.id);
15540
+ });
15541
+
15542
+ it('proceeds to connect when LLM is not connected even if another ownerId lingers', async () => {
15543
+ // Defensive path: if the LLM reports not-connected but an old
15544
+ // ownerId is still present (e.g. race before a successful
15545
+ // connections.delete), this meeting can still claim a fresh
15546
+ // connection.
15547
+ meeting.joinedWith = {state: 'JOINED'};
15548
+ webex.internal.llm.isConnected.returns(false);
15549
+ webex.internal.llm.getOwnerMeetingId.returns('stale-owner-id');
15550
+ webex.internal.llm.getDatachannelToken.onFirstCall().returns(undefined);
15551
+ webex.internal.llm.getDatachannelToken.onSecondCall().returns('recovered-token');
15552
+ meeting.locusInfo = {
15553
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
15554
+ url: 'a url',
15555
+ info: {datachannelUrl: 'a datachannel url'},
15556
+ };
15557
+
15558
+ await meeting.updateLLMConnection();
15559
+
15560
+ assert.calledTwice(webex.internal.llm.getDatachannelToken);
15561
+ assert.calledWithExactly(
15562
+ webex.internal.llm.getDatachannelToken.firstCall,
15563
+ 'llm-default-session',
15564
+ meeting.id
15565
+ );
15566
+ assert.calledWithExactly(
15567
+ webex.internal.llm.getDatachannelToken.secondCall,
15568
+ 'llm-default-session'
15569
+ );
15570
+ assert.calledOnceWithExactly(
15571
+ webex.internal.llm.registerAndConnect,
15572
+ 'a url',
15573
+ 'a datachannel url',
15574
+ 'recovered-token'
15575
+ );
15576
+ assert.calledWithExactly(
15577
+ webex.internal.llm.setRefreshHandler.firstCall,
15578
+ sinon.match.func,
15579
+ 'llm-default-session',
15580
+ undefined
15581
+ );
15582
+ assert.calledTwice(webex.internal.llm.setRefreshHandler);
15583
+ assert.calledWithExactly(
15584
+ webex.internal.llm.setRefreshHandler.secondCall,
15585
+ sinon.match.func,
15586
+ 'llm-default-session',
15587
+ meeting.id
15588
+ );
15589
+ assert.calledOnceWithExactly(webex.internal.llm.setOwnerMeetingId, meeting.id);
15590
+ });
15591
+ });
15592
+
13196
15593
  describe('#clearMeetingData', () => {
13197
15594
  beforeEach(() => {
13198
15595
  webex.internal.llm.isConnected = sinon.stub().returns(true);
@@ -13208,10 +15605,15 @@ describe('plugin-meetings', () => {
13208
15605
  it('disconnects llm and removes online and relay listeners during meeting data cleanup', async () => {
13209
15606
  await meeting.clearMeetingData();
13210
15607
 
13211
- assert.calledOnceWithExactly(webex.internal.llm.disconnectLLM, {
13212
- code: 3050,
13213
- reason: 'done (permanent)',
13214
- });
15608
+ assert.calledOnceWithExactly(
15609
+ webex.internal.llm.disconnectLLM,
15610
+ {
15611
+ code: 3050,
15612
+ reason: 'done (permanent)',
15613
+ },
15614
+ 'llm-default-session',
15615
+ meeting.id
15616
+ );
13215
15617
  assert.calledWithExactly(webex.internal.llm.off, 'online', meeting.handleLLMOnline);
13216
15618
  assert.calledWithExactly(
13217
15619
  webex.internal.llm.off,
@@ -13224,10 +15626,13 @@ describe('plugin-meetings', () => {
13224
15626
  meeting.processLocusLLMEvent
13225
15627
  );
13226
15628
  assert.calledOnce(meeting.clearLLMHealthCheckTimer);
13227
- assert.calledOnce(meeting.stopTranscription);
13228
- assert.isUndefined(meeting.transcription);
13229
15629
  assert.calledOnce(meeting.clearDataChannelToken);
13230
- assert.calledOnce(meeting.annotation.deregisterEvents);
15630
+ // stopTranscription and annotation.deregisterEvents are not
15631
+ // called here: they run in stopListeningForMeetingEvents()
15632
+ // before /leave to avoid double-emitting
15633
+ // MEETING_STOPPED_RECEIVING_TRANSCRIPTION.
15634
+ assert.notCalled(meeting.stopTranscription);
15635
+ assert.notCalled(meeting.annotation.deregisterEvents);
13231
15636
  });
13232
15637
  it('continues cleanup when disconnectLLM fails during meeting data cleanup', async () => {
13233
15638
  webex.internal.llm.disconnectLLM.rejects(new Error('disconnect failed'));
@@ -13246,19 +15651,234 @@ describe('plugin-meetings', () => {
13246
15651
  meeting.processLocusLLMEvent
13247
15652
  );
13248
15653
  assert.calledOnce(meeting.clearLLMHealthCheckTimer);
13249
- assert.calledOnce(meeting.stopTranscription);
13250
- assert.isUndefined(meeting.transcription);
13251
15654
  assert.calledOnce(meeting.clearDataChannelToken);
13252
- assert.calledOnce(meeting.annotation.deregisterEvents);
15655
+ assert.notCalled(meeting.stopTranscription);
15656
+ assert.notCalled(meeting.annotation.deregisterEvents);
13253
15657
  });
13254
- it('always calls stopTranscription even when transcription is undefined', async () => {
13255
- meeting.transcription = undefined;
13256
15658
 
13257
- await meeting.clearMeetingData();
15659
+ describe('ownership tag', () => {
15660
+ beforeEach(() => {
15661
+ webex.internal.llm.getOwnerMeetingId = sinon.stub();
15662
+ });
13258
15663
 
13259
- assert.calledOnce(meeting.stopTranscription);
13260
- assert.isUndefined(meeting.transcription);
13261
- assert.calledOnce(meeting.clearDataChannelToken);
15664
+ it('skips disconnectLLM but still removes this meeting listeners when another meeting owns the LLM', async () => {
15665
+ webex.internal.llm.getOwnerMeetingId.returns('some-other-meeting-id');
15666
+
15667
+ await meeting.clearMeetingData();
15668
+
15669
+ assert.notCalled(webex.internal.llm.disconnectLLM);
15670
+ // clearDataChannelToken is always delegated; llm enforces
15671
+ // ownership and no-ops for non-owners internally.
15672
+ assert.calledOnce(meeting.clearDataChannelToken);
15673
+ // Listeners owned by *this* Meeting instance must still be
15674
+ // removed so a leaving subordinate meeting stops receiving
15675
+ // relay/locus events from the shared singleton.
15676
+ assert.calledWithExactly(webex.internal.llm.off, 'online', meeting.handleLLMOnline);
15677
+ assert.calledWithExactly(
15678
+ webex.internal.llm.off,
15679
+ 'event:relay.event',
15680
+ meeting.processRelayEvent
15681
+ );
15682
+ assert.calledWithExactly(
15683
+ webex.internal.llm.off,
15684
+ 'event:locus.state_message',
15685
+ meeting.processLocusLLMEvent
15686
+ );
15687
+ assert.calledOnce(meeting.clearLLMHealthCheckTimer);
15688
+ });
15689
+
15690
+ it('calls disconnectLLM and clears data channel token when this meeting is the owner', async () => {
15691
+ webex.internal.llm.getOwnerMeetingId.returns(meeting.id);
15692
+
15693
+ await meeting.clearMeetingData();
15694
+
15695
+ assert.calledOnceWithExactly(
15696
+ webex.internal.llm.disconnectLLM,
15697
+ {
15698
+ code: 3050,
15699
+ reason: 'done (permanent)',
15700
+ },
15701
+ 'llm-default-session',
15702
+ meeting.id
15703
+ );
15704
+ assert.calledOnce(meeting.clearDataChannelToken);
15705
+ });
15706
+
15707
+ it('calls disconnectLLM and clears data channel token when no owner is recorded (first-claim / legacy)', async () => {
15708
+ webex.internal.llm.getOwnerMeetingId.returns(undefined);
15709
+
15710
+ await meeting.clearMeetingData();
15711
+
15712
+ assert.calledOnceWithExactly(
15713
+ webex.internal.llm.disconnectLLM,
15714
+ {
15715
+ code: 3050,
15716
+ reason: 'done (permanent)',
15717
+ },
15718
+ 'llm-default-session',
15719
+ meeting.id
15720
+ );
15721
+ assert.calledOnce(meeting.clearDataChannelToken);
15722
+ });
15723
+ });
15724
+ });
15725
+ });
15726
+
15727
+ describe('#processLocusLLMEvent', () => {
15728
+ it('routes the LLM event through locusInfo.parse and records the LLM message with the top-level tracking id', () => {
15729
+ const event = {
15730
+ data: {
15731
+ eventType: 'locus.state_message',
15732
+ dataSets: [],
15733
+ },
15734
+ trackingId: 'envelope-tracking-id',
15735
+ };
15736
+
15737
+ meeting.locusInfo.parse = sinon.stub();
15738
+ meeting.onLocusSyncLlmMessage = sinon.stub();
15739
+
15740
+ meeting.processLocusLLMEvent(event);
15741
+
15742
+ // The LLM message is parsed without the tracking id - completion is driven from the
15743
+ // meeting's LLM handler, not threaded through locusInfo.
15744
+ assert.calledOnceWithExactly(meeting.locusInfo.parse, meeting, event.data);
15745
+ // Only the client whose /sync request tracking id matches the tracking id echoed back on
15746
+ // the top-level LLM event envelope records the LLM arrival; onLocusSyncLlmMessage is a
15747
+ // no-op otherwise.
15748
+ assert.calledOnceWithExactly(meeting.onLocusSyncLlmMessage, meeting.id, event.trackingId);
15749
+ });
15750
+
15751
+ it('does not attempt sync completion when the tracking id is missing', () => {
15752
+ const event = {
15753
+ data: {
15754
+ eventType: 'locus.state_message',
15755
+ dataSets: [],
15756
+ },
15757
+ };
15758
+
15759
+ meeting.locusInfo.parse = sinon.stub();
15760
+ meeting.onLocusSyncLlmMessage = sinon.stub();
15761
+
15762
+ meeting.processLocusLLMEvent(event);
15763
+
15764
+ assert.calledOnceWithExactly(meeting.locusInfo.parse, meeting, event.data);
15765
+ assert.notCalled(meeting.onLocusSyncLlmMessage);
15766
+ });
15767
+ });
15768
+
15769
+ describe('#onLocusSyncLlmMessage', () => {
15770
+ it('records the LLM arrival time and then tries to complete the metric', () => {
15771
+ webex.internal.newMetrics.callDiagnosticLatencies.recordLocusSyncMessageReceived =
15772
+ sinon.stub();
15773
+ meeting.tryCompleteLocusSyncLatency = sinon.stub();
15774
+
15775
+ meeting.onLocusSyncLlmMessage('meeting-1', 'sync-tracking-id');
15776
+
15777
+ assert.calledOnceWithExactly(
15778
+ webex.internal.newMetrics.callDiagnosticLatencies.recordLocusSyncMessageReceived,
15779
+ 'meeting-1',
15780
+ 'sync-tracking-id'
15781
+ );
15782
+ assert.calledOnceWithExactly(
15783
+ meeting.tryCompleteLocusSyncLatency,
15784
+ 'meeting-1',
15785
+ 'sync-tracking-id'
15786
+ );
15787
+ // the arrival time must be recorded before completion is attempted
15788
+ assert.callOrder(
15789
+ webex.internal.newMetrics.callDiagnosticLatencies.recordLocusSyncMessageReceived,
15790
+ meeting.tryCompleteLocusSyncLatency
15791
+ );
15792
+ });
15793
+ });
15794
+
15795
+ describe('#tryCompleteLocusSyncLatency', () => {
15796
+ beforeEach(() => {
15797
+ meeting.emitLocusSyncCompleteMetric = sinon.stub();
15798
+ });
15799
+
15800
+ it('emits the metric when both milestones are in (completion succeeds)', () => {
15801
+ const completed = {dataSet: 'main', syncLatency: {totalTime: 50}};
15802
+ webex.internal.newMetrics.callDiagnosticLatencies.completeLocusSyncLatency = sinon
15803
+ .stub()
15804
+ .returns(completed);
15805
+
15806
+ meeting.tryCompleteLocusSyncLatency('meeting-1', 'sync-tracking-id');
15807
+
15808
+ assert.calledOnceWithExactly(
15809
+ webex.internal.newMetrics.callDiagnosticLatencies.completeLocusSyncLatency,
15810
+ 'meeting-1',
15811
+ 'sync-tracking-id'
15812
+ );
15813
+ assert.calledOnceWithExactly(meeting.emitLocusSyncCompleteMetric, 'meeting-1', completed);
15814
+ });
15815
+
15816
+ it('does not emit when completion returns undefined (only one milestone is in)', () => {
15817
+ webex.internal.newMetrics.callDiagnosticLatencies.completeLocusSyncLatency = sinon
15818
+ .stub()
15819
+ .returns(undefined);
15820
+
15821
+ meeting.tryCompleteLocusSyncLatency('meeting-1', 'sync-tracking-id');
15822
+
15823
+ assert.calledOnceWithExactly(
15824
+ webex.internal.newMetrics.callDiagnosticLatencies.completeLocusSyncLatency,
15825
+ 'meeting-1',
15826
+ 'sync-tracking-id'
15827
+ );
15828
+ assert.notCalled(meeting.emitLocusSyncCompleteMetric);
15829
+ });
15830
+ });
15831
+
15832
+ describe('#emitLocusSyncCompleteMetric', () => {
15833
+ it('submits client.locus.sync.complete with the llm websocket url and sync latency', () => {
15834
+ webex.internal.newMetrics.submitClientEvent.resetHistory();
15835
+ webex.internal.llm.getWebSocketUrl = sinon.stub().returns('wss://llm-websocket-url');
15836
+
15837
+ meeting.emitLocusSyncCompleteMetric('meeting-1', {
15838
+ dataSet: 'main',
15839
+ syncLatency: {totalTime: 50},
15840
+ });
15841
+
15842
+ assert.calledOnceWithExactly(webex.internal.newMetrics.submitClientEvent, {
15843
+ name: 'client.locus.sync.complete',
15844
+ payload: {
15845
+ identifiers: {
15846
+ llmWebsocketUrl: 'wss://llm-websocket-url',
15847
+ },
15848
+ llmInfo: {
15849
+ dataSet: 'main',
15850
+ },
15851
+ syncLatency: {totalTime: 50},
15852
+ },
15853
+ options: {
15854
+ meetingId: 'meeting-1',
15855
+ },
15856
+ });
15857
+ });
15858
+
15859
+ it('submits with an undefined llm websocket url when it is unavailable', () => {
15860
+ webex.internal.newMetrics.submitClientEvent.resetHistory();
15861
+ webex.internal.llm.getWebSocketUrl = sinon.stub().returns(undefined);
15862
+
15863
+ meeting.emitLocusSyncCompleteMetric('meeting-1', {
15864
+ dataSet: 'main',
15865
+ syncLatency: {totalTime: 50},
15866
+ });
15867
+
15868
+ assert.calledOnceWithExactly(webex.internal.newMetrics.submitClientEvent, {
15869
+ name: 'client.locus.sync.complete',
15870
+ payload: {
15871
+ identifiers: {
15872
+ llmWebsocketUrl: undefined,
15873
+ },
15874
+ llmInfo: {
15875
+ dataSet: 'main',
15876
+ },
15877
+ syncLatency: {totalTime: 50},
15878
+ },
15879
+ options: {
15880
+ meetingId: 'meeting-1',
15881
+ },
13262
15882
  });
13263
15883
  });
13264
15884
  });
@@ -13298,6 +15918,71 @@ describe('plugin-meetings', () => {
13298
15918
  });
13299
15919
  });
13300
15920
 
15921
+ describe('#waitForSelfUrlChange', () => {
15922
+ let waitForSelfUrlChange;
15923
+ let locusMediaRequestStub;
15924
+
15925
+ beforeEach(async () => {
15926
+ locusMediaRequestStub = sinon
15927
+ .stub(LocusMediaRequestModule, 'LocusMediaRequest')
15928
+ .returns({id: 'fake LocusMediaRequest instance'});
15929
+
15930
+ meeting.setLocus = sinon.stub().returns(true);
15931
+ webex.meetings.registered = true;
15932
+ sandbox.stub(MeetingUtil, 'joinMeeting').returns(Promise.resolve('JOIN_RESULT'));
15933
+ sinon.stub(meeting, 'updateLLMConnection').returns(Promise.resolve());
15934
+
15935
+ await meeting.join();
15936
+
15937
+ waitForSelfUrlChange = locusMediaRequestStub.firstCall.args[0].waitForSelfUrlChange;
15938
+ });
15939
+
15940
+ it('should resolve immediately when joinWithMediaRetryInfo.retryCount > 0', async () => {
15941
+ meeting.joinWithMediaRetryInfo = {retryCount: 1, prevJoinResponse: undefined};
15942
+
15943
+ const result = waitForSelfUrlChange();
15944
+
15945
+ assert.instanceOf(result, Promise);
15946
+ await result;
15947
+ });
15948
+
15949
+ it('should not resolve before the timeout when retryCount is 0', async () => {
15950
+ meeting.joinWithMediaRetryInfo = {retryCount: 0, prevJoinResponse: undefined};
15951
+
15952
+ let resolved = false;
15953
+ waitForSelfUrlChange().then(() => {
15954
+ resolved = true;
15955
+ });
15956
+
15957
+ await testUtils.flushPromises();
15958
+ assert.isFalse(resolved);
15959
+ });
15960
+
15961
+ it('should resolve after the 5s timeout when retryCount is 0', async () => {
15962
+ meeting.joinWithMediaRetryInfo = {retryCount: 0, prevJoinResponse: undefined};
15963
+
15964
+ let resolved = false;
15965
+ const promise = waitForSelfUrlChange();
15966
+ promise.then(() => {
15967
+ resolved = true;
15968
+ });
15969
+
15970
+ fakeClock.tick(5000);
15971
+ await promise;
15972
+
15973
+ assert.isTrue(resolved);
15974
+ });
15975
+
15976
+ it('should return the same promise when called multiple times', () => {
15977
+ meeting.joinWithMediaRetryInfo = {retryCount: 0, prevJoinResponse: undefined};
15978
+
15979
+ const firstPromise = waitForSelfUrlChange();
15980
+ const secondPromise = waitForSelfUrlChange();
15981
+
15982
+ assert.equal(firstPromise, secondPromise);
15983
+ });
15984
+ });
15985
+
13301
15986
  describe('preferred video device', () => {
13302
15987
  describe('#getVideoDeviceId', () => {
13303
15988
  it('returns the preferred video device', () => {
@@ -15012,16 +17697,25 @@ describe('plugin-meetings', () => {
15012
17697
  assert.notCalled(meeting.meetingRequest.sendReaction);
15013
17698
  });
15014
17699
 
15015
- it('should fail sending a reaction if reactionType is invalid ', async () => {
17700
+ it('should send a custom reaction type not in the known list', async () => {
15016
17701
  meeting.locusInfo.controls = {reactions: {reactionChannelUrl: 'Fake URL'}};
15017
17702
 
15018
- await assert.isRejected(
15019
- meeting.sendReaction('invalid_reaction', 'light'),
15020
- Error,
15021
- 'invalid_reaction is not a valid reaction.'
15022
- );
17703
+ const reactionPromise = meeting.sendReaction('custom_reaction', 'light');
15023
17704
 
15024
- assert.notCalled(meeting.meetingRequest.sendReaction);
17705
+ assert.exists(reactionPromise.then);
17706
+ await reactionPromise;
17707
+ assert.calledOnceWithExactly(meeting.meetingRequest.sendReaction, {
17708
+ reactionChannelUrl: 'Fake URL',
17709
+ reaction: {
17710
+ type: 'custom_reaction',
17711
+ tone: {
17712
+ type: 'light_skin_tone',
17713
+ codepoints: '1F3FB',
17714
+ shortcodes: ':skin-tone-2:',
17715
+ },
17716
+ },
17717
+ participantId: meeting.members.selfId,
17718
+ });
15025
17719
  });
15026
17720
 
15027
17721
  it('should send a reaction with default skin tone if provided skinToneType is invalid ', async () => {