@webex/plugin-meetings 3.12.0-next.13 → 3.12.0-next.130

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 (232) hide show
  1. package/AGENTS.md +9 -0
  2. package/dist/aiEnableRequest/index.js +15 -2
  3. package/dist/aiEnableRequest/index.js.map +1 -1
  4. package/dist/annotation/index.js +2 -2
  5. package/dist/annotation/index.js.map +1 -1
  6. package/dist/breakouts/breakout.js +8 -3
  7. package/dist/breakouts/breakout.js.map +1 -1
  8. package/dist/breakouts/events.js +29 -14
  9. package/dist/breakouts/events.js.map +1 -1
  10. package/dist/breakouts/index.js +99 -4
  11. package/dist/breakouts/index.js.map +1 -1
  12. package/dist/common/errors/webex-errors.js +49 -5
  13. package/dist/common/errors/webex-errors.js.map +1 -1
  14. package/dist/config.js +2 -2
  15. package/dist/config.js.map +1 -1
  16. package/dist/constants.js +37 -10
  17. package/dist/constants.js.map +1 -1
  18. package/dist/controls-options-manager/index.js +46 -10
  19. package/dist/controls-options-manager/index.js.map +1 -1
  20. package/dist/hashTree/constants.js +4 -1
  21. package/dist/hashTree/constants.js.map +1 -1
  22. package/dist/hashTree/hashTreeParser.js +1045 -393
  23. package/dist/hashTree/hashTreeParser.js.map +1 -1
  24. package/dist/hashTree/utils.js +20 -0
  25. package/dist/hashTree/utils.js.map +1 -1
  26. package/dist/index.js +7 -0
  27. package/dist/index.js.map +1 -1
  28. package/dist/interceptors/dataChannelAuthToken.js +75 -15
  29. package/dist/interceptors/dataChannelAuthToken.js.map +1 -1
  30. package/dist/interceptors/locusRetry.js +23 -8
  31. package/dist/interceptors/locusRetry.js.map +1 -1
  32. package/dist/interpretation/index.js +10 -1
  33. package/dist/interpretation/index.js.map +1 -1
  34. package/dist/interpretation/interpretation.types.js +7 -0
  35. package/dist/interpretation/interpretation.types.js.map +1 -0
  36. package/dist/interpretation/siLanguage.js +1 -1
  37. package/dist/locus-info/controlsUtils.js +4 -1
  38. package/dist/locus-info/controlsUtils.js.map +1 -1
  39. package/dist/locus-info/index.js +409 -122
  40. package/dist/locus-info/index.js.map +1 -1
  41. package/dist/locus-info/infoUtils.js +36 -5
  42. package/dist/locus-info/infoUtils.js.map +1 -1
  43. package/dist/locus-info/types.js +19 -0
  44. package/dist/locus-info/types.js.map +1 -1
  45. package/dist/media/MediaConnectionAwaiter.js +15 -2
  46. package/dist/media/MediaConnectionAwaiter.js.map +1 -1
  47. package/dist/media/index.js +8 -2
  48. package/dist/media/index.js.map +1 -1
  49. package/dist/media/properties.js +4 -5
  50. package/dist/media/properties.js.map +1 -1
  51. package/dist/meeting/in-meeting-actions.js +5 -1
  52. package/dist/meeting/in-meeting-actions.js.map +1 -1
  53. package/dist/meeting/index.js +1669 -835
  54. package/dist/meeting/index.js.map +1 -1
  55. package/dist/meeting/locusMediaRequest.js +229 -82
  56. package/dist/meeting/locusMediaRequest.js.map +1 -1
  57. package/dist/meeting/muteState.js +10 -1
  58. package/dist/meeting/muteState.js.map +1 -1
  59. package/dist/meeting/request.js +5 -2
  60. package/dist/meeting/request.js.map +1 -1
  61. package/dist/meeting/util.js +34 -2
  62. package/dist/meeting/util.js.map +1 -1
  63. package/dist/meeting-info/meeting-info-v2.js +9 -3
  64. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  65. package/dist/meetings/index.js +281 -124
  66. package/dist/meetings/index.js.map +1 -1
  67. package/dist/meetings/meetings.types.js +6 -1
  68. package/dist/meetings/meetings.types.js.map +1 -1
  69. package/dist/meetings/request.js +39 -0
  70. package/dist/meetings/request.js.map +1 -1
  71. package/dist/meetings/util.js +116 -18
  72. package/dist/meetings/util.js.map +1 -1
  73. package/dist/member/index.js +10 -0
  74. package/dist/member/index.js.map +1 -1
  75. package/dist/member/types.js.map +1 -1
  76. package/dist/member/util.js +30 -0
  77. package/dist/member/util.js.map +1 -1
  78. package/dist/members/index.js +101 -43
  79. package/dist/members/index.js.map +1 -1
  80. package/dist/members/util.js +8 -1
  81. package/dist/members/util.js.map +1 -1
  82. package/dist/metrics/constants.js +7 -1
  83. package/dist/metrics/constants.js.map +1 -1
  84. package/dist/multistream/codec/constants.js +63 -0
  85. package/dist/multistream/codec/constants.js.map +1 -0
  86. package/dist/multistream/mediaRequestManager.js +62 -15
  87. package/dist/multistream/mediaRequestManager.js.map +1 -1
  88. package/dist/multistream/receiveSlot.js +9 -0
  89. package/dist/multistream/receiveSlot.js.map +1 -1
  90. package/dist/reachability/clusterReachability.js.map +1 -1
  91. package/dist/reachability/index.js +121 -83
  92. package/dist/reachability/index.js.map +1 -1
  93. package/dist/reachability/reachability.types.js +2 -0
  94. package/dist/reachability/reachability.types.js.map +1 -1
  95. package/dist/reachability/util.js +45 -0
  96. package/dist/reachability/util.js.map +1 -1
  97. package/dist/reactions/reactions.type.js.map +1 -1
  98. package/dist/recording-controller/index.js +1 -3
  99. package/dist/recording-controller/index.js.map +1 -1
  100. package/dist/roap/turnDiscovery.js +8 -1
  101. package/dist/roap/turnDiscovery.js.map +1 -1
  102. package/dist/types/common/errors/webex-errors.d.ts +32 -2
  103. package/dist/types/config.d.ts +2 -2
  104. package/dist/types/constants.d.ts +13 -1
  105. package/dist/types/controls-options-manager/index.d.ts +16 -0
  106. package/dist/types/hashTree/constants.d.ts +1 -0
  107. package/dist/types/hashTree/hashTreeParser.d.ts +189 -22
  108. package/dist/types/hashTree/utils.d.ts +7 -0
  109. package/dist/types/index.d.ts +3 -0
  110. package/dist/types/interceptors/locusRetry.d.ts +4 -4
  111. package/dist/types/interpretation/interpretation.types.d.ts +10 -0
  112. package/dist/types/locus-info/index.d.ts +61 -7
  113. package/dist/types/locus-info/infoUtils.d.ts +8 -0
  114. package/dist/types/locus-info/types.d.ts +21 -1
  115. package/dist/types/media/MediaConnectionAwaiter.d.ts +10 -1
  116. package/dist/types/media/properties.d.ts +6 -2
  117. package/dist/types/meeting/in-meeting-actions.d.ts +4 -0
  118. package/dist/types/meeting/index.d.ts +175 -11
  119. package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
  120. package/dist/types/meeting/request.d.ts +1 -0
  121. package/dist/types/meeting/util.d.ts +9 -0
  122. package/dist/types/meeting-info/meeting-info-v2.d.ts +1 -0
  123. package/dist/types/meetings/index.d.ts +38 -18
  124. package/dist/types/meetings/meetings.types.d.ts +15 -0
  125. package/dist/types/meetings/request.d.ts +14 -0
  126. package/dist/types/member/index.d.ts +1 -0
  127. package/dist/types/member/types.d.ts +1 -0
  128. package/dist/types/member/util.d.ts +9 -0
  129. package/dist/types/members/index.d.ts +15 -2
  130. package/dist/types/members/util.d.ts +1 -5
  131. package/dist/types/metrics/constants.d.ts +6 -0
  132. package/dist/types/multistream/codec/constants.d.ts +7 -0
  133. package/dist/types/multistream/mediaRequestManager.d.ts +22 -5
  134. package/dist/types/reachability/clusterReachability.d.ts +3 -3
  135. package/dist/types/reachability/index.d.ts +10 -3
  136. package/dist/types/reachability/reachability.types.d.ts +7 -0
  137. package/dist/types/reachability/util.d.ts +17 -0
  138. package/dist/types/reactions/reactions.type.d.ts +3 -0
  139. package/dist/webinar/index.js +307 -161
  140. package/dist/webinar/index.js.map +1 -1
  141. package/package.json +23 -23
  142. package/src/aiEnableRequest/index.ts +16 -0
  143. package/src/annotation/index.ts +6 -4
  144. package/src/breakouts/breakout.ts +3 -1
  145. package/src/breakouts/events.ts +33 -11
  146. package/src/breakouts/index.ts +122 -2
  147. package/src/common/errors/webex-errors.ts +50 -3
  148. package/src/config.ts +2 -2
  149. package/src/constants.ts +21 -3
  150. package/src/controls-options-manager/index.ts +62 -10
  151. package/src/hashTree/constants.ts +7 -0
  152. package/src/hashTree/hashTreeParser.ts +796 -192
  153. package/src/hashTree/utils.ts +19 -0
  154. package/src/index.ts +6 -0
  155. package/src/interceptors/dataChannelAuthToken.ts +88 -12
  156. package/src/interceptors/locusRetry.ts +25 -4
  157. package/src/interpretation/index.ts +27 -9
  158. package/src/interpretation/interpretation.types.ts +11 -0
  159. package/src/locus-info/controlsUtils.ts +3 -1
  160. package/src/locus-info/index.ts +413 -130
  161. package/src/locus-info/infoUtils.ts +41 -6
  162. package/src/locus-info/types.ts +25 -1
  163. package/src/media/MediaConnectionAwaiter.ts +21 -4
  164. package/src/media/index.ts +10 -1
  165. package/src/media/properties.ts +8 -3
  166. package/src/meeting/in-meeting-actions.ts +8 -0
  167. package/src/meeting/index.ts +923 -117
  168. package/src/meeting/locusMediaRequest.ts +106 -6
  169. package/src/meeting/muteState.ts +10 -1
  170. package/src/meeting/request.ts +11 -0
  171. package/src/meeting/util.ts +46 -5
  172. package/src/meeting-info/meeting-info-v2.ts +10 -4
  173. package/src/meetings/index.ts +178 -78
  174. package/src/meetings/meetings.types.ts +19 -0
  175. package/src/meetings/request.ts +43 -0
  176. package/src/meetings/util.ts +117 -4
  177. package/src/member/index.ts +10 -0
  178. package/src/member/types.ts +1 -0
  179. package/src/member/util.ts +29 -0
  180. package/src/members/index.ts +70 -7
  181. package/src/members/util.ts +12 -4
  182. package/src/metrics/constants.ts +6 -0
  183. package/src/multistream/codec/constants.ts +58 -0
  184. package/src/multistream/mediaRequestManager.ts +119 -28
  185. package/src/multistream/receiveSlot.ts +18 -0
  186. package/src/reachability/clusterReachability.ts +3 -2
  187. package/src/reachability/index.ts +47 -16
  188. package/src/reachability/reachability.types.ts +11 -0
  189. package/src/reachability/util.ts +36 -0
  190. package/src/reactions/reactions.type.ts +3 -0
  191. package/src/recording-controller/index.ts +1 -2
  192. package/src/roap/turnDiscovery.ts +9 -1
  193. package/src/webinar/index.ts +216 -38
  194. package/test/unit/spec/aiEnableRequest/index.ts +86 -0
  195. package/test/unit/spec/annotation/index.ts +3 -3
  196. package/test/unit/spec/breakouts/breakout.ts +9 -3
  197. package/test/unit/spec/breakouts/events.ts +120 -2
  198. package/test/unit/spec/breakouts/index.ts +223 -3
  199. package/test/unit/spec/common/errors/webex-errors.ts +78 -0
  200. package/test/unit/spec/controls-options-manager/index.js +139 -32
  201. package/test/unit/spec/hashTree/hashTreeParser.ts +2299 -243
  202. package/test/unit/spec/hashTree/utils.ts +37 -0
  203. package/test/unit/spec/interceptors/dataChannelAuthToken.ts +196 -0
  204. package/test/unit/spec/interceptors/locusRetry.ts +205 -4
  205. package/test/unit/spec/interpretation/index.ts +26 -4
  206. package/test/unit/spec/locus-info/controlsUtils.js +172 -57
  207. package/test/unit/spec/locus-info/index.js +671 -63
  208. package/test/unit/spec/locus-info/infoUtils.js +184 -1
  209. package/test/unit/spec/media/MediaConnectionAwaiter.ts +55 -0
  210. package/test/unit/spec/media/index.ts +92 -0
  211. package/test/unit/spec/media/properties.ts +23 -23
  212. package/test/unit/spec/meeting/in-meeting-actions.ts +4 -0
  213. package/test/unit/spec/meeting/index.js +2733 -116
  214. package/test/unit/spec/meeting/locusMediaRequest.ts +406 -4
  215. package/test/unit/spec/meeting/muteState.js +81 -0
  216. package/test/unit/spec/meeting/request.js +12 -0
  217. package/test/unit/spec/meeting/utils.js +153 -1
  218. package/test/unit/spec/meeting-info/meetinginfov2.js +76 -10
  219. package/test/unit/spec/meetings/index.js +486 -49
  220. package/test/unit/spec/meetings/request.js +141 -0
  221. package/test/unit/spec/meetings/utils.js +402 -51
  222. package/test/unit/spec/member/index.js +7 -0
  223. package/test/unit/spec/member/util.js +89 -0
  224. package/test/unit/spec/members/index.js +216 -0
  225. package/test/unit/spec/members/request.js +37 -1
  226. package/test/unit/spec/members/utils.js +63 -0
  227. package/test/unit/spec/multistream/mediaRequestManager.ts +501 -37
  228. package/test/unit/spec/reachability/index.ts +128 -46
  229. package/test/unit/spec/reachability/util.ts +31 -0
  230. package/test/unit/spec/recording-controller/index.js +9 -8
  231. package/test/unit/spec/roap/turnDiscovery.ts +20 -0
  232. 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,9 +1167,84 @@ describe('plugin-meetings', () => {
902
1167
 
903
1168
  // resets joinWithMediaRetryInfo
904
1169
  assert.deepEqual(meeting.joinWithMediaRetryInfo, {
905
- isRetry: false,
1170
+ retryCount: 0,
906
1171
  prevJoinResponse: undefined,
1172
+ firstError: undefined,
1173
+ prevError: undefined,
907
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 re-join on retry when join() fails on first attempt, and throw the first error if join fails again', async () => {
1185
+ const firstJoinError = new Error('first join error');
1186
+ const secondJoinError = new Error('second join error');
1187
+
1188
+ meeting.join = sinon
1189
+ .stub()
1190
+ .onFirstCall()
1191
+ .rejects(firstJoinError)
1192
+ .onSecondCall()
1193
+ .rejects(secondJoinError);
1194
+ meeting.locusUrl = null; // join never succeeds
1195
+
1196
+ const thrownError = await assert.isRejected(
1197
+ meeting.joinWithMedia({joinOptions, mediaOptions})
1198
+ );
1199
+
1200
+ // join() should be called twice — once for the first attempt, once for the re-join
1201
+ assert.calledTwice(meeting.join);
1202
+ // TURN discovery should be attempted twice (once per join)
1203
+ assert.calledTwice(generateTurnDiscoveryRequestMessageStub);
1204
+
1205
+ // should throw the first attempt's error, not the second
1206
+ assert.equal(thrownError, firstJoinError);
1207
+
1208
+ assert.calledTwice(Metrics.sendBehavioralMetric);
1209
+ assert.calledWith(
1210
+ Metrics.sendBehavioralMetric.firstCall,
1211
+ BEHAVIORAL_METRICS.JOIN_WITH_MEDIA_FAILURE,
1212
+ sinon.match({reason: firstJoinError.message, isRetry: false}),
1213
+ sinon.match.any
1214
+ );
1215
+ assert.calledWith(
1216
+ Metrics.sendBehavioralMetric.secondCall,
1217
+ BEHAVIORAL_METRICS.JOIN_WITH_MEDIA_FAILURE,
1218
+ sinon.match({reason: secondJoinError.message, isRetry: true}),
1219
+ sinon.match.any
1220
+ );
1221
+
1222
+ assert.deepEqual(meeting.joinWithMediaRetryInfo, {
1223
+ retryCount: 0,
1224
+ prevJoinResponse: undefined,
1225
+ firstError: undefined,
1226
+ prevError: undefined,
1227
+ });
1228
+ });
1229
+
1230
+ it('should NOT call join() again on retry when join() succeeded but addMediaInternal() failed', async () => {
1231
+ const addMediaError = new Error('addMedia error');
1232
+
1233
+ meeting.addMediaInternal = sinon
1234
+ .stub()
1235
+ .onFirstCall()
1236
+ .rejects(addMediaError)
1237
+ .onSecondCall()
1238
+ .resolves(test4);
1239
+
1240
+ const result = await meeting.joinWithMedia({joinOptions, mediaOptions});
1241
+
1242
+ assert.deepEqual(result, {join: fakeJoinResult, media: test4, multistreamEnabled: true});
1243
+
1244
+ // join() should only be called once — the successful join result is reused on retry
1245
+ assert.calledOnce(meeting.join);
1246
+ // TURN discovery request is only generated once (on the first attempt alongside join)
1247
+ assert.calledOnce(generateTurnDiscoveryRequestMessageStub);
908
1248
  });
909
1249
 
910
1250
  it('should resolve if join() fails the first time but succeeds the second time', async () => {
@@ -948,7 +1288,7 @@ describe('plugin-meetings', () => {
948
1288
 
949
1289
  // resets joinWithMediaRetryInfo
950
1290
  assert.deepEqual(meeting.joinWithMediaRetryInfo, {
951
- isRetry: false,
1291
+ retryCount: 0,
952
1292
  prevJoinResponse: undefined,
953
1293
  });
954
1294
  });
@@ -1017,6 +1357,127 @@ describe('plugin-meetings', () => {
1017
1357
  );
1018
1358
  });
1019
1359
 
1360
+ it('should throw the first attempt error when retry also fails with a different error', async () => {
1361
+ const firstError = new Error('first attempt error');
1362
+ const secondError = new Error('second attempt error');
1363
+
1364
+ const addMediaInternalResults = [];
1365
+ meeting.addMediaInternal = sinon.stub().callsFake(() => {
1366
+ const defer = new Defer();
1367
+ addMediaInternalResults.push(defer);
1368
+ return defer.promise;
1369
+ });
1370
+
1371
+ const leaveStub = sinon.stub(meeting, 'leave').resolves();
1372
+
1373
+ const result = meeting.joinWithMedia({joinOptions, mediaOptions});
1374
+
1375
+ await testUtils.flushPromises();
1376
+
1377
+ // 1st attempt fails
1378
+ addMediaInternalResults[0].reject(firstError);
1379
+ await testUtils.flushPromises();
1380
+
1381
+ // leave() should NOT be called after the 1st attempt (intermediate retry)
1382
+ assert.notCalled(leaveStub);
1383
+
1384
+ // 2nd (final) attempt fails
1385
+ addMediaInternalResults[1].reject(secondError);
1386
+ const thrownError = await assert.isRejected(result);
1387
+
1388
+ // should throw the first error, not the second
1389
+ assert.equal(thrownError, firstError);
1390
+
1391
+ // leave() should only be called after the last (2nd) attempt
1392
+ assert.calledOnce(leaveStub);
1393
+
1394
+ assert.calledTwice(Metrics.sendBehavioralMetric);
1395
+ });
1396
+
1397
+ it('should throw the UserNotJoinedError as firstError when it occurs on the 1st attempt and 2nd attempt fails differently', async () => {
1398
+ const userNotJoinedError = new UserNotJoinedError();
1399
+ const secondError = new Error('second attempt error');
1400
+
1401
+ const addMediaInternalResults = [];
1402
+ meeting.addMediaInternal = sinon.stub().callsFake(() => {
1403
+ const defer = new Defer();
1404
+ addMediaInternalResults.push(defer);
1405
+ return defer.promise;
1406
+ });
1407
+
1408
+ const leaveStub = sinon.stub(meeting, 'leave').resolves();
1409
+
1410
+ const result = meeting.joinWithMedia({joinOptions, mediaOptions});
1411
+
1412
+ await testUtils.flushPromises();
1413
+
1414
+ // 1st attempt fails with UserNotJoinedError — triggers a re-join
1415
+ addMediaInternalResults[0].reject(userNotJoinedError);
1416
+ await testUtils.flushPromises();
1417
+
1418
+ // leave() should NOT be called after the 1st attempt (intermediate retry)
1419
+ assert.notCalled(leaveStub);
1420
+
1421
+ // 2nd (final) attempt fails
1422
+ addMediaInternalResults[1].reject(secondError);
1423
+ const thrownError = await assert.isRejected(result);
1424
+
1425
+ // should throw the first (UserNotJoinedError), not the second
1426
+ assert.equal(thrownError, userNotJoinedError);
1427
+
1428
+ // join() called twice: original + re-join triggered by UserNotJoinedError in prevError
1429
+ assert.calledTwice(meeting.join);
1430
+ // leave() should only be called after the last (2nd) attempt
1431
+ assert.calledOnce(leaveStub);
1432
+ assert.calledTwice(Metrics.sendBehavioralMetric);
1433
+ });
1434
+
1435
+ it('should throw the first UserNotJoinedError when it occurs on both 1st and 2nd attempts and a 3rd attempt also fails', async () => {
1436
+ const firstUserNotJoinedError = new UserNotJoinedError('first');
1437
+ const secondUserNotJoinedError = new UserNotJoinedError('second');
1438
+ const thirdError = new Error('third attempt error');
1439
+
1440
+ const addMediaInternalResults = [];
1441
+ meeting.addMediaInternal = sinon.stub().callsFake(() => {
1442
+ const defer = new Defer();
1443
+ addMediaInternalResults.push(defer);
1444
+ return defer.promise;
1445
+ });
1446
+
1447
+ const leaveStub = sinon.stub(meeting, 'leave').resolves();
1448
+
1449
+ const result = meeting.joinWithMedia({joinOptions, mediaOptions});
1450
+
1451
+ await testUtils.flushPromises();
1452
+
1453
+ // 1st attempt fails with UserNotJoinedError — triggers a re-join
1454
+ addMediaInternalResults[0].reject(firstUserNotJoinedError);
1455
+ await testUtils.flushPromises();
1456
+
1457
+ // leave() should NOT be called after the 1st attempt (intermediate retry)
1458
+ assert.notCalled(leaveStub);
1459
+
1460
+ // 2nd attempt fails with UserNotJoinedError again — triggers another re-join
1461
+ addMediaInternalResults[1].reject(secondUserNotJoinedError);
1462
+ await testUtils.flushPromises();
1463
+
1464
+ // leave() should NOT be called after the 2nd attempt (intermediate retry)
1465
+ assert.notCalled(leaveStub);
1466
+
1467
+ // 3rd (final) attempt fails
1468
+ addMediaInternalResults[2].reject(thirdError);
1469
+ const thrownError = await assert.isRejected(result);
1470
+
1471
+ // should throw the very first error across all 3 attempts
1472
+ assert.equal(thrownError, firstUserNotJoinedError);
1473
+
1474
+ // join() called 3 times: original + 2 re-joins triggered by prevError being UserNotJoinedError
1475
+ assert.calledThrice(meeting.join);
1476
+ // leave() should only be called after the last (3rd) attempt
1477
+ assert.calledOnce(leaveStub);
1478
+ assert.calledThrice(Metrics.sendBehavioralMetric);
1479
+ });
1480
+
1020
1481
  it('should call leave() if addMediaInternal() fails with a browser media error (TypeError)', async () => {
1021
1482
  const addMediaError = new Error('fake addMedia error');
1022
1483
  addMediaError.name = 'TypeError'; // This makes it a browser media error
@@ -1212,8 +1673,9 @@ describe('plugin-meetings', () => {
1212
1673
  assert.calledWith(
1213
1674
  meeting.addMediaInternal.firstCall,
1214
1675
  sinon.match.any,
1215
- fakeTurnServerInfo,
1216
1676
  false,
1677
+ fakeTurnServerInfo,
1678
+ undefined,
1217
1679
  mediaOptions
1218
1680
  );
1219
1681
 
@@ -1221,8 +1683,9 @@ describe('plugin-meetings', () => {
1221
1683
  assert.calledWith(
1222
1684
  meeting.addMediaInternal.secondCall,
1223
1685
  sinon.match.any,
1224
- undefined,
1225
1686
  true,
1687
+ undefined,
1688
+ undefined,
1226
1689
  mediaOptions
1227
1690
  );
1228
1691
 
@@ -1240,7 +1703,7 @@ describe('plugin-meetings', () => {
1240
1703
 
1241
1704
  meeting.addMediaInternal = sinon
1242
1705
  .stub()
1243
- .callsFake((icePhaseCallback, _turnServerInfo, _forceTurnDiscovery) => {
1706
+ .callsFake((icePhaseCallback, _forceTurnDiscovery, _turnServerInfo) => {
1244
1707
  const defer = new Defer();
1245
1708
 
1246
1709
  icePhaseCallbacks.push(icePhaseCallback);
@@ -1253,25 +1716,136 @@ describe('plugin-meetings', () => {
1253
1716
  mediaOptions,
1254
1717
  });
1255
1718
 
1256
- await testUtils.flushPromises();
1719
+ await testUtils.flushPromises();
1720
+
1721
+ // check the callback works correctly on the 1st attempt
1722
+ assert.equal(icePhaseCallbacks.length, 1);
1723
+ assert.equal(icePhaseCallbacks[0](), 'JOIN_MEETING_RETRY');
1724
+
1725
+ // now trigger the failure, so that joinWithMedia() does a retry
1726
+ addMediaInternalResults[0].reject(addMediaError);
1727
+
1728
+ await testUtils.flushPromises();
1729
+
1730
+ // check the callback works correctly on the 2nd attempt:
1731
+ // retryCount=1 with a non-UserNotJoinedError is terminal, so icePhase must be JOIN_MEETING_FINAL
1732
+ assert.equal(icePhaseCallbacks.length, 2);
1733
+ assert.equal(icePhaseCallbacks[1](), 'JOIN_MEETING_FINAL');
1734
+
1735
+ // trigger 2nd failure
1736
+ addMediaInternalResults[1].reject(addMediaError);
1737
+
1738
+ await assert.isRejected(result);
1739
+ });
1740
+
1741
+ it('should allow an additional retry when UserNotJoinedError occurs and return JOIN_MEETING_FINAL on the 3rd attempt', async () => {
1742
+ const genericError = new Error('generic error');
1743
+ const userNotJoinedError = new UserNotJoinedError();
1744
+ const thirdError = new Error('third error');
1745
+
1746
+ const icePhaseCallbacks = [];
1747
+ const addMediaInternalResults = [];
1748
+
1749
+ meeting.addMediaInternal = sinon.stub().callsFake((icePhaseCallback) => {
1750
+ const defer = new Defer();
1751
+
1752
+ icePhaseCallbacks.push(icePhaseCallback);
1753
+ addMediaInternalResults.push(defer);
1754
+ return defer.promise;
1755
+ });
1756
+
1757
+ const leaveStub = sinon.stub(meeting, 'leave').resolves();
1758
+
1759
+ const result = meeting.joinWithMedia({
1760
+ joinOptions,
1761
+ mediaOptions,
1762
+ });
1763
+
1764
+ await testUtils.flushPromises();
1765
+
1766
+ // 1st attempt: retryCount=0 → JOIN_MEETING_RETRY
1767
+ assert.equal(icePhaseCallbacks.length, 1);
1768
+ assert.equal(icePhaseCallbacks[0](), 'JOIN_MEETING_RETRY');
1769
+ addMediaInternalResults[0].reject(genericError);
1770
+
1771
+ await testUtils.flushPromises();
1772
+
1773
+ // leave() should NOT be called after the 1st attempt (intermediate retry)
1774
+ assert.notCalled(leaveStub);
1775
+
1776
+ // 2nd attempt: retryCount=1 → JOIN_MEETING_FINAL
1777
+ // (In real usage this callback is never invoked when UserNotJoinedError is thrown,
1778
+ // because UserNotJoinedError is thrown before waitForMediaConnectionConnected() is reached.)
1779
+ assert.equal(icePhaseCallbacks.length, 2);
1780
+ assert.equal(icePhaseCallbacks[1](), 'JOIN_MEETING_FINAL');
1781
+ addMediaInternalResults[1].reject(userNotJoinedError);
1782
+
1783
+ await testUtils.flushPromises();
1784
+
1785
+ // leave() should NOT be called after the 2nd attempt (intermediate retry)
1786
+ assert.notCalled(leaveStub);
1787
+
1788
+ // 3rd attempt: retryCount=2 → JOIN_MEETING_FINAL
1789
+ assert.equal(icePhaseCallbacks.length, 3);
1790
+ assert.equal(icePhaseCallbacks[2](), 'JOIN_MEETING_FINAL');
1791
+ addMediaInternalResults[2].reject(thirdError);
1792
+
1793
+ const thrownError = await assert.isRejected(result);
1794
+
1795
+ // should throw the first error
1796
+ assert.equal(thrownError, genericError);
1797
+
1798
+ // leave() should only be called once, after the last (3rd) attempt
1799
+ assert.calledOnce(leaveStub);
1800
+ });
1801
+
1802
+ it('should re-join when retrying after a UserNotJoinedError', async () => {
1803
+ const userNotJoinedError = new UserNotJoinedError();
1804
+
1805
+ const leaveStub = sinon.stub(meeting, 'leave').resolves();
1806
+
1807
+ meeting.addMediaInternal = sinon
1808
+ .stub()
1809
+ .onFirstCall()
1810
+ .rejects(userNotJoinedError)
1811
+ .onSecondCall()
1812
+ .resolves(test4);
1813
+
1814
+ const result = await meeting.joinWithMedia({joinOptions, mediaOptions});
1815
+
1816
+ assert.deepEqual(result, {join: fakeJoinResult, media: test4, multistreamEnabled: true});
1817
+
1818
+ // join() should be called twice — once for the first attempt, once for the re-join after UserNotJoinedError
1819
+ assert.calledTwice(meeting.join);
1820
+ // TURN discovery should be attempted twice (once per join)
1821
+ assert.calledTwice(generateTurnDiscoveryRequestMessageStub);
1822
+ // leave() should never be called when retrying after UserNotJoinedError
1823
+ assert.notCalled(leaveStub);
1824
+ });
1257
1825
 
1258
- // check the callback works correctly on the 1st attempt
1259
- assert.equal(icePhaseCallbacks.length, 1);
1260
- assert.equal(icePhaseCallbacks[0](), 'JOIN_MEETING_RETRY');
1826
+ it('should re-join when isUserInLeftState returns true on retry', async () => {
1827
+ const addMediaError = new Error('addMedia error');
1261
1828
 
1262
- // now trigger the failure, so that joinWithMedia() does a retry
1263
- addMediaInternalResults[0].reject(addMediaError);
1829
+ sinon.stub(MeetingUtil, 'isUserInLeftState').returns(true);
1264
1830
 
1265
- await testUtils.flushPromises();
1831
+ const leaveStub = sinon.stub(meeting, 'leave').resolves();
1266
1832
 
1267
- // check the callback works correctly on the 2nd attempt
1268
- assert.equal(icePhaseCallbacks.length, 2);
1269
- assert.equal(icePhaseCallbacks[1](), 'JOIN_MEETING_FINAL');
1833
+ meeting.addMediaInternal = sinon
1834
+ .stub()
1835
+ .onFirstCall()
1836
+ .rejects(addMediaError)
1837
+ .onSecondCall()
1838
+ .resolves(test4);
1270
1839
 
1271
- // trigger 2nd failure
1272
- addMediaInternalResults[1].reject(addMediaError);
1840
+ const result = await meeting.joinWithMedia({joinOptions, mediaOptions});
1273
1841
 
1274
- await assert.isRejected(result);
1842
+ assert.deepEqual(result, {join: fakeJoinResult, media: test4, multistreamEnabled: true});
1843
+
1844
+ // join() should be called twice — once for the first attempt, once because the user is in left state
1845
+ assert.calledTwice(meeting.join);
1846
+ assert.calledTwice(generateTurnDiscoveryRequestMessageStub);
1847
+ // leave() should never be called when retrying after isUserInLeftState returns true
1848
+ assert.notCalled(leaveStub);
1275
1849
  });
1276
1850
 
1277
1851
  [
@@ -1341,6 +1915,7 @@ describe('plugin-meetings', () => {
1341
1915
  sinon.match.any,
1342
1916
  sinon.match.any,
1343
1917
  sinon.match.any,
1918
+ sinon.match.any,
1344
1919
  sinon.match.has('videoEnabled', false).and(sinon.match.has('allowMediaInLobby', true))
1345
1920
  );
1346
1921
  });
@@ -1361,6 +1936,7 @@ describe('plugin-meetings', () => {
1361
1936
  sinon.match.any,
1362
1937
  sinon.match.any,
1363
1938
  sinon.match.any,
1939
+ sinon.match.any,
1364
1940
  sinon.match.has('audioEnabled', false).and(sinon.match.has('allowMediaInLobby', true))
1365
1941
  );
1366
1942
  });
@@ -1382,6 +1958,7 @@ describe('plugin-meetings', () => {
1382
1958
  sinon.match.any,
1383
1959
  sinon.match.any,
1384
1960
  sinon.match.any,
1961
+ sinon.match.any,
1385
1962
  sinon.match({
1386
1963
  sendVideo: true,
1387
1964
  receiveVideo: false,
@@ -1391,6 +1968,101 @@ describe('plugin-meetings', () => {
1391
1968
  );
1392
1969
  });
1393
1970
 
1971
+ describe('shouldRetryMediaWithOnlyTurnTLS', () => {
1972
+ it('should pass iceTransportPolicy=relay for multistream when previous error is DTLS failure over UDP and TLS is reachable', async () => {
1973
+ meeting.isMultistream = true;
1974
+ const dtlsError = new AddMediaFailed({iceConnected: true, connectionType: 'UDP'});
1975
+
1976
+ webex.meetings.reachability.isAnyClusterReachableViaProtocol = sinon
1977
+ .stub()
1978
+ .resolves(true);
1979
+
1980
+ addMediaInternalStub.onFirstCall().rejects(dtlsError);
1981
+ addMediaInternalStub.onSecondCall().resolves(test4);
1982
+
1983
+ await meeting.joinWithMedia({joinOptions, mediaOptions});
1984
+
1985
+ assert.calledWith(
1986
+ meeting.addMediaInternal.secondCall,
1987
+ sinon.match.any,
1988
+ sinon.match.any,
1989
+ sinon.match.any,
1990
+ 'relay',
1991
+ mediaOptions
1992
+ );
1993
+ });
1994
+
1995
+ [
1996
+ {
1997
+ title: 'TLS is not reachable',
1998
+ prevError: new AddMediaFailed({iceConnected: true, connectionType: 'UDP'}),
1999
+ tlsReachable: false,
2000
+ isMultistream: true,
2001
+ },
2002
+ {
2003
+ title: 'error is not AddMediaFailed',
2004
+ prevError: new Error('generic error'),
2005
+ tlsReachable: true,
2006
+ isMultistream: true,
2007
+ },
2008
+ {
2009
+ title: 'error is AddMediaFailed but not DTLS failure',
2010
+ prevError: new AddMediaFailed({iceConnected: false, connectionType: 'UDP'}),
2011
+ tlsReachable: true,
2012
+ isMultistream: true,
2013
+ },
2014
+ {
2015
+ title: 'error is DTLS failure but connectionType is not UDP',
2016
+ prevError: new AddMediaFailed({iceConnected: true, connectionType: 'TURN-TLS'}),
2017
+ tlsReachable: true,
2018
+ isMultistream: true,
2019
+ },
2020
+ {
2021
+ title: 'isMultistream is false',
2022
+ prevError: new AddMediaFailed({iceConnected: true, connectionType: 'UDP'}),
2023
+ tlsReachable: true,
2024
+ isMultistream: false,
2025
+ },
2026
+ ].forEach(({title, prevError, tlsReachable, isMultistream}) => {
2027
+ it(`should pass iceTransportPolicy=undefined when ${title}`, async () => {
2028
+ meeting.join = sinon.stub().callsFake(() => {
2029
+ meeting.isMultistream = isMultistream;
2030
+ return Promise.resolve(fakeJoinResult);
2031
+ });
2032
+ webex.meetings.reachability.isAnyClusterReachableViaProtocol = sinon
2033
+ .stub()
2034
+ .resolves(tlsReachable);
2035
+
2036
+ addMediaInternalStub.onFirstCall().rejects(prevError);
2037
+ addMediaInternalStub.onSecondCall().resolves(test4);
2038
+
2039
+ await meeting.joinWithMedia({joinOptions, mediaOptions});
2040
+
2041
+ assert.calledWith(
2042
+ meeting.addMediaInternal.secondCall,
2043
+ sinon.match.any,
2044
+ sinon.match.any,
2045
+ sinon.match.any,
2046
+ undefined,
2047
+ mediaOptions
2048
+ );
2049
+ });
2050
+ });
2051
+
2052
+ it('should pass iceTransportPolicy=undefined on first attempt (no prevError)', async () => {
2053
+ await meeting.joinWithMedia({joinOptions, mediaOptions});
2054
+
2055
+ assert.calledWith(
2056
+ meeting.addMediaInternal.firstCall,
2057
+ sinon.match.any,
2058
+ sinon.match.any,
2059
+ sinon.match.any,
2060
+ undefined,
2061
+ mediaOptions
2062
+ );
2063
+ });
2064
+ });
2065
+
1394
2066
  it('should throw immediately if RTCPeerConnection is not available', async () => {
1395
2067
  supportsRTCPeerConnectionStub.returns(CapabilityState.NOT_CAPABLE);
1396
2068
 
@@ -1402,9 +2074,97 @@ describe('plugin-meetings', () => {
1402
2074
  Errors.WebrtcApiNotAvailableError
1403
2075
  );
1404
2076
 
2077
+ assert.notCalled(suspendDestroyMeetingStub);
1405
2078
  assert.notCalled(meeting.join);
1406
2079
  assert.notCalled(meeting.addMediaInternal);
1407
2080
  });
2081
+
2082
+ [
2083
+ {description: '409 error from join()', statusCode: 409, useCause: false},
2084
+ {description: '403 error from join()', statusCode: 403, useCause: false},
2085
+ {
2086
+ description: '409 error in cause (e.g. AddMediaFailed)',
2087
+ statusCode: 409,
2088
+ useCause: true,
2089
+ },
2090
+ {
2091
+ description: '403 error in cause (e.g. AddMediaFailed)',
2092
+ statusCode: 403,
2093
+ useCause: true,
2094
+ },
2095
+ ].forEach(({description, statusCode, useCause}) => {
2096
+ it(`should re-join on retry when ${description}`, async () => {
2097
+ const error = useCause
2098
+ ? Object.assign(new Error('wrapped error'), {cause: {statusCode}})
2099
+ : Object.assign(new Error('locus error'), {statusCode});
2100
+
2101
+ meeting.addMediaInternal = sinon
2102
+ .stub()
2103
+ .onFirstCall()
2104
+ .rejects(error)
2105
+ .onSecondCall()
2106
+ .resolves(test4);
2107
+
2108
+ const result = await meeting.joinWithMedia({joinOptions, mediaOptions});
2109
+
2110
+ assert.deepEqual(result, {
2111
+ join: fakeJoinResult,
2112
+ media: test4,
2113
+ multistreamEnabled: true,
2114
+ });
2115
+
2116
+ // join() should be called twice — once for the first attempt, once for the re-join
2117
+ assert.calledTwice(meeting.join);
2118
+ assert.calledTwice(generateTurnDiscoveryRequestMessageStub);
2119
+ });
2120
+ });
2121
+
2122
+ it('should allow up to JOIN_WITH_MEDIA_RETRY_MAX_COUNT retries for 409 errors', async () => {
2123
+ const error409 = Object.assign(new Error('locus dropped us'), {statusCode: 409});
2124
+
2125
+ meeting.addMediaInternal = sinon.stub().rejects(error409);
2126
+ meeting.join = sinon.stub().callsFake(() => Promise.resolve(fakeJoinResult));
2127
+ sinon.stub(meeting, 'leave').resolves();
2128
+
2129
+ await assert.isRejected(meeting.joinWithMedia({joinOptions, mediaOptions}));
2130
+
2131
+ // JOIN_WITH_MEDIA_RETRY_MAX_COUNT is 2, so we expect 3 attempts total (initial + 2 retries)
2132
+ assert.callCount(meeting.join, 3);
2133
+ assert.callCount(meeting.addMediaInternal, 3);
2134
+ });
2135
+
2136
+ it('should not retry on 1-1 calls', async () => {
2137
+ const addMediaError = new Error('addMedia error');
2138
+
2139
+ sinon.stub(MeetingsUtil, 'isOneOnOneCall').returns(true);
2140
+
2141
+ meeting.addMediaInternal = sinon.stub().rejects(addMediaError);
2142
+ sinon.stub(meeting, 'leave').resolves();
2143
+
2144
+ await assert.isRejected(
2145
+ meeting.joinWithMedia({joinOptions, mediaOptions}),
2146
+ addMediaError
2147
+ );
2148
+
2149
+ // should not retry - only 1 attempt
2150
+ assert.calledOnce(meeting.join);
2151
+ assert.calledOnce(meeting.addMediaInternal);
2152
+ assert.calledOnceWithExactly(
2153
+ Metrics.sendBehavioralMetric,
2154
+ BEHAVIORAL_METRICS.JOIN_WITH_MEDIA_FAILURE,
2155
+ {
2156
+ correlation_id: meeting.correlationId,
2157
+ locus_id: meeting.locusUrl.split('/').pop(),
2158
+ reason: addMediaError.message,
2159
+ stack: addMediaError.stack,
2160
+ leaveErrorReason: undefined,
2161
+ isRetry: false,
2162
+ },
2163
+ {
2164
+ type: addMediaError.name,
2165
+ }
2166
+ );
2167
+ });
1408
2168
  });
1409
2169
  describe('#isTranscriptionSupported', () => {
1410
2170
  it('should return false if the feature is not supported for the meeting', () => {
@@ -1977,12 +2737,120 @@ describe('plugin-meetings', () => {
1977
2737
  fakeProcessedReaction
1978
2738
  );
1979
2739
  });
2740
+
2741
+ [
2742
+ {
2743
+ title:
2744
+ 'should skip a reaction when the default relay route does not match the LLM binding',
2745
+ isPracticeSessionConnected: false,
2746
+ route: 'wrong-default-route',
2747
+ defaultBinding: 'default-route',
2748
+ practiceBinding: 'practice-route',
2749
+ shouldProcess: false,
2750
+ expectedSessionLabel: 'default session',
2751
+ },
2752
+ {
2753
+ title: 'should process a reaction when the default relay route matches the LLM binding',
2754
+ isPracticeSessionConnected: false,
2755
+ route: 'default-route',
2756
+ defaultBinding: 'default-route',
2757
+ practiceBinding: 'practice-route',
2758
+ shouldProcess: true,
2759
+ },
2760
+ {
2761
+ title:
2762
+ 'should process a reaction when the practice-session relay route matches the practice-session LLM binding',
2763
+ isPracticeSessionConnected: true,
2764
+ route: 'practice-route',
2765
+ defaultBinding: 'default-route',
2766
+ practiceBinding: 'practice-route',
2767
+ shouldProcess: true,
2768
+ },
2769
+ {
2770
+ title:
2771
+ 'should skip a reaction when the practice-session relay route does not match the practice-session LLM binding',
2772
+ isPracticeSessionConnected: true,
2773
+ route: 'default-route',
2774
+ defaultBinding: 'default-route',
2775
+ practiceBinding: 'practice-route',
2776
+ shouldProcess: false,
2777
+ expectedSessionLabel: 'practice session',
2778
+ },
2779
+ ].forEach(
2780
+ ({
2781
+ title,
2782
+ isPracticeSessionConnected,
2783
+ route,
2784
+ defaultBinding,
2785
+ practiceBinding,
2786
+ shouldProcess,
2787
+ expectedSessionLabel,
2788
+ }) => {
2789
+ it(title, () => {
2790
+ meeting.isReactionsSupported = sinon.stub().returns(true);
2791
+ meeting.config.receiveReactions = true;
2792
+ const fakeSendersName = 'Fake reactors name';
2793
+ meeting.members.membersCollection.get = sinon.stub().returns({name: fakeSendersName});
2794
+ webex.internal.llm.isConnected = sinon.stub().callsFake((llmSessionId) => {
2795
+ return llmSessionId === LLM_PRACTICE_SESSION && isPracticeSessionConnected;
2796
+ });
2797
+ webex.internal.llm.getBinding = sinon.stub().callsFake((llmSessionId) => {
2798
+ if (llmSessionId === LLM_PRACTICE_SESSION) {
2799
+ return practiceBinding;
2800
+ }
2801
+
2802
+ return defaultBinding;
2803
+ });
2804
+ const fakeReactionPayload = {
2805
+ type: 'fake_type',
2806
+ codepoints: 'fake_codepoints',
2807
+ shortcodes: 'fake_shortcodes',
2808
+ };
2809
+ const fakeSenderPayload = {
2810
+ participantId: 'fake_participant_id',
2811
+ };
2812
+ const fakeRelayEvent = {
2813
+ headers: {route},
2814
+ data: {
2815
+ relayType: REACTION_RELAY_TYPES.REACTION,
2816
+ reaction: fakeReactionPayload,
2817
+ sender: fakeSenderPayload,
2818
+ },
2819
+ };
2820
+ const fakeProcessedReaction = {
2821
+ reaction: fakeReactionPayload,
2822
+ sender: {
2823
+ id: fakeSenderPayload.participantId,
2824
+ name: fakeSendersName,
2825
+ },
2826
+ };
2827
+
2828
+ TriggerProxy.trigger.resetHistory();
2829
+ meeting.processRelayEvent(fakeRelayEvent);
2830
+
2831
+ if (shouldProcess) {
2832
+ assert.calledWith(
2833
+ TriggerProxy.trigger,
2834
+ sinon.match.instanceOf(Meeting),
2835
+ {
2836
+ file: 'meeting/index',
2837
+ function: 'join',
2838
+ },
2839
+ EVENT_TRIGGERS.MEETING_RECEIVE_REACTIONS,
2840
+ fakeProcessedReaction
2841
+ );
2842
+ } else {
2843
+ assert.notCalled(TriggerProxy.trigger);
2844
+ }
2845
+ });
2846
+ }
2847
+ );
1980
2848
  });
1981
2849
 
1982
2850
  describe('#handleLLMOnline', () => {
1983
2851
  beforeEach(() => {
1984
2852
  webex.internal.llm.off = sinon.stub();
1985
- webex.internal.voicea.getIsCaptionBoxOn = sinon.stub().returns(false);
2853
+ webex.internal.voicea.getKeepTranscriptionSubscribed = sinon.stub().returns(false);
1986
2854
  webex.internal.voicea.updateSubchannelSubscriptions = sinon.stub();
1987
2855
  });
1988
2856
 
@@ -2000,7 +2868,7 @@ describe('plugin-meetings', () => {
2000
2868
  });
2001
2869
 
2002
2870
  it('restores transcription subscription when caption intent is enabled', () => {
2003
- webex.internal.voicea.getIsCaptionBoxOn.returns(true);
2871
+ webex.internal.voicea.getKeepTranscriptionSubscribed.returns(true);
2004
2872
 
2005
2873
  meeting.handleLLMOnline();
2006
2874
 
@@ -2010,12 +2878,20 @@ describe('plugin-meetings', () => {
2010
2878
  });
2011
2879
 
2012
2880
  it('does not restore transcription subscription when caption intent is disabled', () => {
2013
- webex.internal.voicea.getIsCaptionBoxOn.returns(false);
2881
+ webex.internal.voicea.getKeepTranscriptionSubscribed.returns(false);
2014
2882
 
2015
2883
  meeting.handleLLMOnline();
2016
2884
 
2017
2885
  assert.notCalled(webex.internal.voicea.updateSubchannelSubscriptions);
2018
2886
  });
2887
+
2888
+ it('calls syncAllHashTreeDatasets on locusInfo', () => {
2889
+ sinon.stub(meeting.locusInfo, 'syncAllHashTreeDatasets').resolves();
2890
+
2891
+ meeting.handleLLMOnline();
2892
+
2893
+ assert.calledOnceWithExactly(meeting.locusInfo.syncAllHashTreeDatasets, {onlyLLM: true});
2894
+ });
2019
2895
  });
2020
2896
 
2021
2897
  describe('#join', () => {
@@ -2096,6 +2972,8 @@ describe('plugin-meetings', () => {
2096
2972
  regionCode: 'EU',
2097
2973
  },
2098
2974
  preferTranscoding: !enableMultistream,
2975
+ getCurrentSelfUrl: sinon.match.func,
2976
+ waitForSelfUrlChange: sinon.match.func,
2099
2977
  },
2100
2978
  {
2101
2979
  parent: meeting.webex,
@@ -2340,6 +3218,221 @@ describe('plugin-meetings', () => {
2340
3218
  );
2341
3219
  });
2342
3220
 
3221
+ it('emits breakout join response metric only once per breakoutMoveId', async () => {
3222
+ sinon.stub(meeting, 'isJoined').returns(true);
3223
+ sinon.stub(meeting.webex.internal.llm, 'isConnected').returns(false);
3224
+ sinon.stub(meeting.webex.internal.llm, 'registerAndConnect').resolves({
3225
+ clientLLMDatachannelResponseTime: 10,
3226
+ clientLLMWebSocketConnectTime: 20,
3227
+ });
3228
+
3229
+ meeting.meetingInfo.enableConvergedArchitecture = true;
3230
+ meeting.breakouts.set('breakoutMoveId', 'move-id-1');
3231
+ meeting.breakouts.set('sessionType', 'BREAKOUT');
3232
+ meeting.breakouts.set('status', 'OPEN');
3233
+ meeting.breakouts.set('currentBreakoutSession', {
3234
+ sessionId: 'session-id-1',
3235
+ groupId: 'group-id-1',
3236
+ });
3237
+
3238
+ webex.internal.newMetrics.submitClientEvent.resetHistory();
3239
+ meeting.updateLLMConnection.restore();
3240
+
3241
+ await meeting.updateLLMConnection();
3242
+ await meeting.updateLLMConnection();
3243
+
3244
+ const joinResponseCalls = webex.internal.newMetrics.submitClientEvent
3245
+ .getCalls()
3246
+ .filter((call) => call.args[0]?.name === 'client.breakout-session.join.response');
3247
+
3248
+ assert.lengthOf(joinResponseCalls, 1);
3249
+ assert.equal(joinResponseCalls[0].args[0].options.meetingId, meeting.id);
3250
+ });
3251
+
3252
+ it('does not emit breakout join response metric when breakout session is missing', async () => {
3253
+ sinon.stub(meeting, 'isJoined').returns(true);
3254
+ sinon.stub(meeting.webex.internal.llm, 'isConnected').returns(false);
3255
+ sinon.stub(meeting.webex.internal.llm, 'registerAndConnect').resolves({
3256
+ clientLLMDatachannelResponseTime: 10,
3257
+ clientLLMWebSocketConnectTime: 20,
3258
+ });
3259
+
3260
+ meeting.meetingInfo.enableConvergedArchitecture = true;
3261
+ meeting.breakouts.set('breakoutMoveId', 'move-id-1');
3262
+
3263
+ webex.internal.newMetrics.submitClientEvent.resetHistory();
3264
+ meeting.updateLLMConnection.restore();
3265
+
3266
+ await meeting.updateLLMConnection();
3267
+
3268
+ const joinResponseCalls = webex.internal.newMetrics.submitClientEvent
3269
+ .getCalls()
3270
+ .filter((call) => call.args[0]?.name === 'client.breakout-session.join.response');
3271
+
3272
+ assert.lengthOf(joinResponseCalls, 0);
3273
+ });
3274
+
3275
+ it('does not emit failed breakout join response metric when breakout session is missing', async () => {
3276
+ sinon.stub(meeting, 'isJoined').returns(true);
3277
+ sinon.stub(meeting.webex.internal.llm, 'isConnected').returns(false);
3278
+ sinon
3279
+ .stub(meeting.webex.internal.llm, 'registerAndConnect')
3280
+ .rejects(new Error('failed to connect LLM'));
3281
+
3282
+ meeting.meetingInfo.enableConvergedArchitecture = true;
3283
+ meeting.breakouts.set('breakoutMoveId', 'move-id-1');
3284
+
3285
+ webex.internal.newMetrics.submitClientEvent.resetHistory();
3286
+ meeting.updateLLMConnection.restore();
3287
+
3288
+ try {
3289
+ await meeting.updateLLMConnection();
3290
+ assert.fail('Expected updateLLMConnection to reject');
3291
+ } catch (error) {
3292
+ assert.equal(error.message, 'failed to connect LLM');
3293
+ }
3294
+
3295
+ const joinResponseCalls = webex.internal.newMetrics.submitClientEvent
3296
+ .getCalls()
3297
+ .filter((call) => call.args[0]?.name === 'client.breakout-session.join.response');
3298
+
3299
+ assert.lengthOf(joinResponseCalls, 0);
3300
+ });
3301
+
3302
+ it('emits llm breakout join response metric after suppressing join response without llmLatency', async () => {
3303
+ sinon.stub(meeting, 'isJoined').returns(true);
3304
+ sinon.stub(meeting.webex.internal.llm, 'isConnected').returns(false);
3305
+ sinon.stub(meeting.webex.internal.llm, 'registerAndConnect').resolves({
3306
+ clientLLMDatachannelResponseTime: 10,
3307
+ clientLLMWebSocketConnectTime: 20,
3308
+ });
3309
+
3310
+ meeting.config.enableAutomaticLLM = true;
3311
+ meeting.meetingInfo.enableConvergedArchitecture = true;
3312
+ meeting.breakouts.set('breakoutMoveId', 'move-id-1');
3313
+ meeting.breakouts.set('sessionType', 'BREAKOUT');
3314
+ meeting.breakouts.set('status', 'OPEN');
3315
+ meeting.breakouts.set('currentBreakoutSession', {
3316
+ sessionId: 'session-id-1',
3317
+ groupId: 'group-id-1',
3318
+ });
3319
+
3320
+ assert.isFalse(meeting.shouldEmitBreakoutJoinResponseMetric('move-id-1'));
3321
+
3322
+ webex.internal.newMetrics.submitClientEvent.resetHistory();
3323
+ meeting.updateLLMConnection.restore();
3324
+
3325
+ await meeting.updateLLMConnection();
3326
+
3327
+ const joinResponseCalls = webex.internal.newMetrics.submitClientEvent
3328
+ .getCalls()
3329
+ .filter((call) => call.args[0]?.name === 'client.breakout-session.join.response');
3330
+
3331
+ assert.lengthOf(joinResponseCalls, 1);
3332
+ assert.deepEqual(joinResponseCalls[0].args[0].payload.llmLatency, {
3333
+ clientLLMDatachannelResponseTime: 10,
3334
+ clientLLMWebSocketConnectTime: 20,
3335
+ });
3336
+ });
3337
+
3338
+ it('emits breakout join response metric with llmLatency when returning to main session', async () => {
3339
+ sinon.stub(meeting, 'isJoined').returns(true);
3340
+ sinon.stub(meeting.webex.internal.llm, 'isConnected').returns(false);
3341
+ sinon.stub(meeting.webex.internal.llm, 'registerAndConnect').resolves({
3342
+ clientLLMDatachannelResponseTime: 10,
3343
+ clientLLMWebSocketConnectTime: 20,
3344
+ });
3345
+
3346
+ meeting.meetingInfo.enableConvergedArchitecture = true;
3347
+ meeting.breakouts.set('breakoutMoveId', 'move-id-1');
3348
+ meeting.breakouts.set('sessionType', 'MAIN');
3349
+ meeting.breakouts.set('status', 'OPEN');
3350
+ meeting.breakouts.set('currentBreakoutSession', {
3351
+ sessionId: 'session-id-1',
3352
+ groupId: 'group-id-1',
3353
+ });
3354
+
3355
+ webex.internal.newMetrics.submitClientEvent.resetHistory();
3356
+ meeting.updateLLMConnection.restore();
3357
+
3358
+ await meeting.updateLLMConnection();
3359
+
3360
+ const joinResponseCalls = webex.internal.newMetrics.submitClientEvent
3361
+ .getCalls()
3362
+ .filter((call) => call.args[0]?.name === 'client.breakout-session.join.response');
3363
+
3364
+ assert.lengthOf(joinResponseCalls, 1);
3365
+ assert.deepEqual(joinResponseCalls[0].args[0].payload.llmLatency, {
3366
+ clientLLMDatachannelResponseTime: 10,
3367
+ clientLLMWebSocketConnectTime: 20,
3368
+ });
3369
+ });
3370
+
3371
+ it('uses the partial datachannel timing from the error when the websocket connect fails', async () => {
3372
+ sinon.stub(meeting, 'isJoined').returns(true);
3373
+ sinon.stub(meeting.webex.internal.llm, 'isConnected').returns(false);
3374
+ const connectError = new Error('failed to connect LLM');
3375
+ connectError.timing = {clientLLMDatachannelResponseTime: 42};
3376
+ sinon.stub(meeting.webex.internal.llm, 'registerAndConnect').rejects(connectError);
3377
+
3378
+ meeting.meetingInfo.enableConvergedArchitecture = true;
3379
+ meeting.breakouts.set('breakoutMoveId', 'move-id-1');
3380
+ meeting.breakouts.set('sessionType', 'BREAKOUT');
3381
+ meeting.breakouts.set('status', 'OPEN');
3382
+ meeting.breakouts.set('currentBreakoutSession', {
3383
+ sessionId: 'session-id-1',
3384
+ groupId: 'group-id-1',
3385
+ });
3386
+
3387
+ webex.internal.newMetrics.submitClientEvent.resetHistory();
3388
+ meeting.updateLLMConnection.restore();
3389
+
3390
+ try {
3391
+ await meeting.updateLLMConnection();
3392
+ assert.fail('Expected updateLLMConnection to reject');
3393
+ } catch (error) {
3394
+ assert.equal(error, connectError);
3395
+ }
3396
+
3397
+ const joinResponseCalls = webex.internal.newMetrics.submitClientEvent
3398
+ .getCalls()
3399
+ .filter((call) => call.args[0]?.name === 'client.breakout-session.join.response');
3400
+
3401
+ assert.lengthOf(joinResponseCalls, 1);
3402
+ assert.deepEqual(joinResponseCalls[0].args[0].payload.llmLatency, {
3403
+ clientLLMDatachannelResponseTime: 42,
3404
+ clientLLMWebSocketConnectTime: 0,
3405
+ });
3406
+ });
3407
+
3408
+ it('reports the partial datachannel timing on client.llm.connect.response when the websocket connect fails during initial join', async () => {
3409
+ sinon.stub(meeting, 'isJoined').returns(true);
3410
+ sinon.stub(meeting.webex.internal.llm, 'isConnected').returns(false);
3411
+ const connectError = new Error('failed to connect LLM');
3412
+ connectError.timing = {clientLLMDatachannelResponseTime: 42};
3413
+ sinon.stub(meeting.webex.internal.llm, 'registerAndConnect').rejects(connectError);
3414
+
3415
+ webex.internal.newMetrics.submitClientEvent.resetHistory();
3416
+ meeting.updateLLMConnection.restore();
3417
+
3418
+ try {
3419
+ await meeting.updateLLMConnection({isInitialJoinPhase: true});
3420
+ assert.fail('Expected updateLLMConnection to reject');
3421
+ } catch (error) {
3422
+ assert.equal(error, connectError);
3423
+ }
3424
+
3425
+ const connectResponseCalls = webex.internal.newMetrics.submitClientEvent
3426
+ .getCalls()
3427
+ .filter((call) => call.args[0]?.name === 'client.llm.connect.response');
3428
+
3429
+ assert.lengthOf(connectResponseCalls, 1);
3430
+ assert.deepEqual(connectResponseCalls[0].args[0].payload.llmLatency, {
3431
+ clientLLMDatachannelResponseTime: 42,
3432
+ clientLLMWebSocketConnectTime: 0,
3433
+ });
3434
+ });
3435
+
2343
3436
  it('clears the LLM health check timer when disconnecting LLM', async () => {
2344
3437
  const isJoinedStub = sinon.stub(meeting, 'isJoined');
2345
3438
  sinon.stub(meeting.webex.internal.llm, 'isConnected');
@@ -2467,7 +3560,6 @@ describe('plugin-meetings', () => {
2467
3560
  });
2468
3561
  });
2469
3562
 
2470
-
2471
3563
  describe('#addMedia', () => {
2472
3564
  const muteStateStub = {
2473
3565
  handleClientRequest: sinon.stub().returns(Promise.resolve(true)),
@@ -2614,9 +3706,11 @@ describe('plugin-meetings', () => {
2614
3706
  retriedWithTurnServer: false,
2615
3707
  isMultistream: false,
2616
3708
  isJoinWithMediaRetry: false,
3709
+ iceTransportPolicy: 'all',
2617
3710
  signalingState: 'unknown',
2618
3711
  connectionState: 'unknown',
2619
3712
  iceConnectionState: 'unknown',
3713
+ connectionType: 'udp',
2620
3714
  someReachabilityMetric1: 'some value1',
2621
3715
  someReachabilityMetric2: 'some value2',
2622
3716
  selectedCandidatePairChanges: 2,
@@ -2742,9 +3836,11 @@ describe('plugin-meetings', () => {
2742
3836
  retriedWithTurnServer: false,
2743
3837
  isMultistream: false,
2744
3838
  isJoinWithMediaRetry: false,
3839
+ iceTransportPolicy: 'all',
2745
3840
  signalingState: 'unknown',
2746
3841
  connectionState: 'unknown',
2747
3842
  iceConnectionState: 'unknown',
3843
+ connectionType: 'udp',
2748
3844
  someReachabilityMetric1: 'some value1',
2749
3845
  someReachabilityMetric2: 'some value2',
2750
3846
  selectedCandidatePairChanges: 2,
@@ -3178,6 +4274,7 @@ describe('plugin-meetings', () => {
3178
4274
  unpublishStream: sinon.stub(),
3179
4275
  setNamedMediaGroups: sinon.stub(),
3180
4276
  });
4277
+ sinon.spy(meeting.sendSlotManager, 'reset');
3181
4278
 
3182
4279
  await meeting.addMedia({
3183
4280
  allowMediaInLobby: true,
@@ -3190,6 +4287,7 @@ describe('plugin-meetings', () => {
3190
4287
  },
3191
4288
  });
3192
4289
 
4290
+ assert.calledOnce(meeting.sendSlotManager.reset);
3193
4291
  assert.notCalled(publishStreamStub);
3194
4292
  });
3195
4293
 
@@ -3213,6 +4311,7 @@ describe('plugin-meetings', () => {
3213
4311
  }
3214
4312
  return videoSlot;
3215
4313
  });
4314
+ sinon.spy(meeting.sendSlotManager, 'reset');
3216
4315
 
3217
4316
  await meeting.addMedia({
3218
4317
  allowMediaInLobby: true,
@@ -3225,6 +4324,7 @@ describe('plugin-meetings', () => {
3225
4324
  },
3226
4325
  });
3227
4326
 
4327
+ assert.calledOnce(meeting.sendSlotManager.reset);
3228
4328
  assert.calledOnceWithExactly(audioSlot.publishStream, fakeMicrophoneStream);
3229
4329
  assert.calledOnceWithExactly(videoSlot.publishStream, fakeCameraStream);
3230
4330
  });
@@ -3247,11 +4347,13 @@ describe('plugin-meetings', () => {
3247
4347
 
3248
4348
  meeting.meetingState = 'ACTIVE';
3249
4349
  meeting.isMultistream = true;
4350
+ sinon.spy(meeting.sendSlotManager, 'reset');
3250
4351
 
3251
4352
  await meeting.addMedia({
3252
4353
  mediaSettings: {},
3253
4354
  });
3254
4355
 
4356
+ assert.calledOnce(meeting.sendSlotManager.reset);
3255
4357
  // check that rtcMetrics was passed to Media.createMediaConnection
3256
4358
  assert.calledOnce(Media.createMediaConnection);
3257
4359
  assert.calledWith(
@@ -3512,9 +4614,11 @@ describe('plugin-meetings', () => {
3512
4614
  retriedWithTurnServer: true,
3513
4615
  isMultistream: false,
3514
4616
  isJoinWithMediaRetry: false,
4617
+ iceTransportPolicy: 'all',
3515
4618
  signalingState: 'unknown',
3516
4619
  connectionState: 'unknown',
3517
4620
  iceConnectionState: 'unknown',
4621
+ connectionType: 'udp',
3518
4622
  selectedCandidatePairChanges: 2,
3519
4623
  numTransports: 1,
3520
4624
  iceCandidatesCount: 0,
@@ -3539,6 +4643,173 @@ describe('plugin-meetings', () => {
3539
4643
  assert.isOk(errorThrown);
3540
4644
  });
3541
4645
 
4646
+ [
4647
+ {iceConnected: true, title: 'iceConnected=true'},
4648
+ {iceConnected: false, title: 'iceConnected=false'},
4649
+ ].forEach(({iceConnected, title}) => {
4650
+ it(`should propagate ${title} from waitForMediaConnectionConnected rejection to AddMediaFailed`, async () => {
4651
+ webex.meetings.reachability = {
4652
+ isWebexMediaBackendUnreachable: sinon.stub().resolves(false),
4653
+ getReachabilityMetrics: sinon.stub().resolves({}),
4654
+ stopReachability: sinon.stub(),
4655
+ isSubnetReachable: sinon.stub().returns(true),
4656
+ };
4657
+ webex.internal.newMetrics.callDiagnosticMetrics.getErrorPayloadForClientErrorCode =
4658
+ sinon.stub().returns({fatal: true});
4659
+ sinon.stub(CallDiagnosticUtils, 'generateClientErrorCodeForIceFailure').returns(2004);
4660
+
4661
+ meeting.meetingState = 'ACTIVE';
4662
+ const rejectedResult = {iceConnected};
4663
+ meeting.mediaProperties.waitForMediaConnectionConnected = sinon
4664
+ .stub()
4665
+ .rejects(rejectedResult);
4666
+
4667
+ meeting.roap.doTurnDiscovery = sinon.stub().returns({
4668
+ turnServerInfo: {urls: ['turns:fake:443'], username: 'u', password: 'p'},
4669
+ turnDiscoverySkippedReason: undefined,
4670
+ });
4671
+
4672
+ const forceRtcMetricsSend = sinon.stub().resolves();
4673
+ Media.createMediaConnection = sinon.stub().returns({
4674
+ close: sinon.stub(),
4675
+ forceRtcMetricsSend,
4676
+ getConnectionState: sinon.stub().returns(ConnectionState.Connected),
4677
+ initiateOffer: sinon.stub().resolves({}),
4678
+ on: sinon.stub(),
4679
+ });
4680
+
4681
+ let thrownError;
4682
+ await meeting.addMedia({mediaSettings: {}}).catch((err) => {
4683
+ thrownError = err;
4684
+ });
4685
+
4686
+ assert.instanceOf(thrownError, AddMediaFailed);
4687
+ assert.equal(thrownError.iceConnected, iceConnected);
4688
+ // the AddMediaFailed cause should be the MediaConnectionTimedOutError, which in turn should
4689
+ // preserve the original rejected result as its cause, so that the web client
4690
+ // can find the CA-reported error in the eventErrorCache via the cause chain
4691
+ assert.instanceOf(thrownError.cause, MediaConnectionTimedOutError);
4692
+ assert.equal(thrownError.cause.cause, rejectedResult);
4693
+ });
4694
+ });
4695
+
4696
+ describe('iceTransportPolicy=relay handling', () => {
4697
+ let createMediaConnectionStub;
4698
+
4699
+ beforeEach(() => {
4700
+ webex.meetings.reachability = {
4701
+ isWebexMediaBackendUnreachable: sinon.stub().resolves(false),
4702
+ isAnyClusterReachableViaProtocol: sinon.stub().resolves(true),
4703
+ getReachabilityMetrics: sinon.stub().resolves({}),
4704
+ stopReachability: sinon.stub(),
4705
+ isSubnetReachable: sinon.stub().returns(true),
4706
+ };
4707
+ webex.internal.newMetrics.callDiagnosticMetrics.getErrorPayloadForClientErrorCode =
4708
+ sinon.stub().returns({fatal: true});
4709
+ sinon.stub(CallDiagnosticUtils, 'generateClientErrorCodeForIceFailure').returns(2004);
4710
+
4711
+ meeting.meetingState = 'ACTIVE';
4712
+ meeting.mediaProperties.waitForMediaConnectionConnected = sinon.stub().resolves();
4713
+
4714
+ createMediaConnectionStub = sinon.stub().returns({
4715
+ close: sinon.stub(),
4716
+ forceRtcMetricsSend: sinon.stub().resolves(),
4717
+ getConnectionState: sinon.stub().returns(ConnectionState.Connected),
4718
+ initiateOffer: sinon.stub().resolves({}),
4719
+ on: sinon.stub(),
4720
+ });
4721
+ Media.createMediaConnection = createMediaConnectionStub;
4722
+ });
4723
+
4724
+ [
4725
+ {
4726
+ title:
4727
+ 'should drop iceTransportPolicy=relay when TURN discovery returns no turn server info',
4728
+ turnServerInfo: undefined,
4729
+ turnDiscoverySkippedReason: 'reachability',
4730
+ },
4731
+ {
4732
+ title:
4733
+ 'should drop iceTransportPolicy=relay when TURN discovery returns turnServerInfo with empty urls',
4734
+ turnServerInfo: {urls: [], username: 'u', password: 'p'},
4735
+ turnDiscoverySkippedReason: undefined,
4736
+ },
4737
+ ].forEach(({title, turnServerInfo, turnDiscoverySkippedReason}) => {
4738
+ it(title, async () => {
4739
+ meeting.roap.doTurnDiscovery = sinon.stub().returns({
4740
+ turnServerInfo,
4741
+ turnDiscoverySkippedReason,
4742
+ });
4743
+
4744
+ await meeting.addMediaInternal(
4745
+ () => 'JOIN_MEETING_FINAL',
4746
+ false,
4747
+ undefined,
4748
+ 'relay',
4749
+ {mediaSettings: {}}
4750
+ );
4751
+
4752
+ assert.calledOnce(createMediaConnectionStub);
4753
+ const config = createMediaConnectionStub.firstCall.args[3];
4754
+ assert.isUndefined(config.iceTransportPolicy);
4755
+
4756
+ const successCall = Metrics.sendBehavioralMetric
4757
+ .getCalls()
4758
+ .find((call) => call.args[0] === BEHAVIORAL_METRICS.ADD_MEDIA_SUCCESS);
4759
+ assert.isDefined(successCall);
4760
+ assert.equal(successCall.args[1].iceTransportPolicy, 'all');
4761
+ });
4762
+ });
4763
+
4764
+ it('should send ADD_MEDIA_SUCCESS metric with iceTransportPolicy=relay when relay is used', async () => {
4765
+ meeting.roap.doTurnDiscovery = sinon.stub().returns({
4766
+ turnServerInfo: {
4767
+ urls: ['turns:turn-server:443?transport=tcp'],
4768
+ username: 'u',
4769
+ password: 'p',
4770
+ },
4771
+ turnDiscoverySkippedReason: undefined,
4772
+ });
4773
+
4774
+ await meeting.addMediaInternal(() => 'JOIN_MEETING_FINAL', false, undefined, 'relay', {
4775
+ mediaSettings: {},
4776
+ });
4777
+
4778
+ const successCall = Metrics.sendBehavioralMetric
4779
+ .getCalls()
4780
+ .find((call) => call.args[0] === BEHAVIORAL_METRICS.ADD_MEDIA_SUCCESS);
4781
+ assert.isDefined(successCall);
4782
+ assert.equal(successCall.args[1].iceTransportPolicy, 'relay');
4783
+ });
4784
+
4785
+ it('should send ADD_MEDIA_FAILURE metric with iceTransportPolicy=relay when relay attempt fails', async () => {
4786
+ meeting.roap.doTurnDiscovery = sinon.stub().returns({
4787
+ turnServerInfo: {
4788
+ urls: ['turns:turn-server:443?transport=tcp'],
4789
+ username: 'u',
4790
+ password: 'p',
4791
+ },
4792
+ turnDiscoverySkippedReason: undefined,
4793
+ });
4794
+
4795
+ meeting.mediaProperties.waitForMediaConnectionConnected = sinon
4796
+ .stub()
4797
+ .rejects(new MediaConnectionTimedOutError('timed out', true));
4798
+
4799
+ await assert.isRejected(
4800
+ meeting.addMediaInternal(() => 'JOIN_MEETING_FINAL', false, undefined, 'relay', {
4801
+ mediaSettings: {},
4802
+ })
4803
+ );
4804
+
4805
+ const failureCall = Metrics.sendBehavioralMetric
4806
+ .getCalls()
4807
+ .find((call) => call.args[0] === BEHAVIORAL_METRICS.ADD_MEDIA_FAILURE);
4808
+ assert.isDefined(failureCall);
4809
+ assert.equal(failureCall.args[1].iceTransportPolicy, 'relay');
4810
+ });
4811
+ });
4812
+
3542
4813
  it('should resolve if waitForMediaConnectionConnected() rejects the first time but resolves the second time', async () => {
3543
4814
  const FAKE_ERROR = {fatal: true};
3544
4815
  webex.meetings.reachability = {
@@ -3728,6 +4999,7 @@ describe('plugin-meetings', () => {
3728
4999
  isMultistream: false,
3729
5000
  retriedWithTurnServer: true,
3730
5001
  isJoinWithMediaRetry: false,
5002
+ iceTransportPolicy: 'all',
3731
5003
  iceCandidatesCount: 0,
3732
5004
  subnet_reachable: null,
3733
5005
  selected_cluster: null,
@@ -3891,6 +5163,7 @@ describe('plugin-meetings', () => {
3891
5163
  isMultistream: false,
3892
5164
  retriedWithTurnServer: false,
3893
5165
  isJoinWithMediaRetry: false,
5166
+ iceTransportPolicy: 'all',
3894
5167
  someReachabilityMetric1: 'some value1',
3895
5168
  someReachabilityMetric2: 'some value2',
3896
5169
  iceCandidatesCount: 3,
@@ -3956,9 +5229,11 @@ describe('plugin-meetings', () => {
3956
5229
  retriedWithTurnServer: false,
3957
5230
  isMultistream: false,
3958
5231
  isJoinWithMediaRetry: false,
5232
+ iceTransportPolicy: 'all',
3959
5233
  signalingState: 'unknown',
3960
5234
  connectionState: 'unknown',
3961
5235
  iceConnectionState: 'unknown',
5236
+ connectionType: 'udp',
3962
5237
  selectedCandidatePairChanges: 2,
3963
5238
  numTransports: 1,
3964
5239
  subnet_reachable: null,
@@ -4019,9 +5294,11 @@ describe('plugin-meetings', () => {
4019
5294
  retriedWithTurnServer: false,
4020
5295
  isMultistream: false,
4021
5296
  isJoinWithMediaRetry: false,
5297
+ iceTransportPolicy: 'all',
4022
5298
  signalingState: 'unknown',
4023
5299
  connectionState: 'unknown',
4024
5300
  iceConnectionState: 'unknown',
5301
+ connectionType: 'udp',
4025
5302
  selectedCandidatePairChanges: 2,
4026
5303
  numTransports: 1,
4027
5304
  '701_error': 2,
@@ -4083,6 +5360,7 @@ describe('plugin-meetings', () => {
4083
5360
  isMultistream: false,
4084
5361
  retriedWithTurnServer: false,
4085
5362
  isJoinWithMediaRetry: false,
5363
+ iceTransportPolicy: 'all',
4086
5364
  iceCandidatesCount: 0,
4087
5365
  reachability_public_udp_success: 5,
4088
5366
  subnet_reachable: false,
@@ -4148,9 +5426,11 @@ describe('plugin-meetings', () => {
4148
5426
  retriedWithTurnServer: false,
4149
5427
  isMultistream: false,
4150
5428
  isJoinWithMediaRetry: false,
5429
+ iceTransportPolicy: 'all',
4151
5430
  signalingState: 'unknown',
4152
5431
  connectionState: 'unknown',
4153
5432
  iceConnectionState: 'unknown',
5433
+ connectionType: 'udp',
4154
5434
  selectedCandidatePairChanges: 2,
4155
5435
  numTransports: 1,
4156
5436
  reachability_public_udp_success: 5,
@@ -4534,6 +5814,297 @@ describe('plugin-meetings', () => {
4534
5814
  },
4535
5815
  });
4536
5816
  });
5817
+
5818
+ describe('handles STATS_UPDATE event for SRTP cipher detection', () => {
5819
+ it('emits MEETING_SRTP_CIPHER_UPDATED event when srtpCipher is found in transport stats', async () => {
5820
+ const fakeStats = new Map([
5821
+ [
5822
+ 'transport-1',
5823
+ {
5824
+ type: 'transport',
5825
+ srtpCipher: 'AES_CM_128_HMAC_SHA1_80',
5826
+ dtlsCipher: 'TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256',
5827
+ },
5828
+ ],
5829
+ [
5830
+ 'outbound-rtp-1',
5831
+ {
5832
+ type: 'outbound-rtp',
5833
+ ssrc: 12345,
5834
+ },
5835
+ ],
5836
+ ]);
5837
+
5838
+ statsAnalyzerStub.emit(
5839
+ {file: 'test', function: 'test'},
5840
+ StatsAnalyzerEventNames.STATS_UPDATE,
5841
+ {stats: fakeStats}
5842
+ );
5843
+
5844
+ assert.calledWith(
5845
+ TriggerProxy.trigger,
5846
+ sinon.match.instanceOf(Meeting),
5847
+ {
5848
+ file: 'meeting/index',
5849
+ function: 'setupStatsAnalyzerEventHandlers',
5850
+ },
5851
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
5852
+ {srtpCipher: 'AES_CM_128_HMAC_SHA1_80'}
5853
+ );
5854
+
5855
+ assert.equal(meeting.mediaProperties.srtpCipher, 'AES_CM_128_HMAC_SHA1_80');
5856
+ });
5857
+
5858
+ it('updates meeting.mediaProperties.srtpCipher when cipher changes', async () => {
5859
+ const firstStats = new Map([
5860
+ [
5861
+ 'transport-1',
5862
+ {
5863
+ type: 'transport',
5864
+ srtpCipher: 'AES_CM_128_HMAC_SHA1_80',
5865
+ },
5866
+ ],
5867
+ ]);
5868
+
5869
+ statsAnalyzerStub.emit(
5870
+ {file: 'test', function: 'test'},
5871
+ StatsAnalyzerEventNames.STATS_UPDATE,
5872
+ {stats: firstStats}
5873
+ );
5874
+
5875
+ assert.equal(meeting.mediaProperties.srtpCipher, 'AES_CM_128_HMAC_SHA1_80');
5876
+
5877
+ const secondStats = new Map([
5878
+ [
5879
+ 'transport-1',
5880
+ {
5881
+ type: 'transport',
5882
+ srtpCipher: 'AEAD_AES_256_GCM',
5883
+ },
5884
+ ],
5885
+ ]);
5886
+
5887
+ TriggerProxy.trigger.resetHistory();
5888
+
5889
+ statsAnalyzerStub.emit(
5890
+ {file: 'test', function: 'test'},
5891
+ StatsAnalyzerEventNames.STATS_UPDATE,
5892
+ {stats: secondStats}
5893
+ );
5894
+
5895
+ assert.calledWith(
5896
+ TriggerProxy.trigger,
5897
+ sinon.match.instanceOf(Meeting),
5898
+ {
5899
+ file: 'meeting/index',
5900
+ function: 'setupStatsAnalyzerEventHandlers',
5901
+ },
5902
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
5903
+ {srtpCipher: 'AEAD_AES_256_GCM'}
5904
+ );
5905
+
5906
+ assert.equal(meeting.mediaProperties.srtpCipher, 'AEAD_AES_256_GCM');
5907
+ });
5908
+
5909
+ it('does not emit event when srtpCipher has not changed', async () => {
5910
+ const firstStats = new Map([
5911
+ [
5912
+ 'transport-1',
5913
+ {
5914
+ type: 'transport',
5915
+ srtpCipher: 'AES_CM_128_HMAC_SHA1_80',
5916
+ },
5917
+ ],
5918
+ ]);
5919
+
5920
+ statsAnalyzerStub.emit(
5921
+ {file: 'test', function: 'test'},
5922
+ StatsAnalyzerEventNames.STATS_UPDATE,
5923
+ {stats: firstStats}
5924
+ );
5925
+
5926
+ assert.equal(meeting.mediaProperties.srtpCipher, 'AES_CM_128_HMAC_SHA1_80');
5927
+
5928
+ TriggerProxy.trigger.resetHistory();
5929
+
5930
+ // Emit same cipher again
5931
+ statsAnalyzerStub.emit(
5932
+ {file: 'test', function: 'test'},
5933
+ StatsAnalyzerEventNames.STATS_UPDATE,
5934
+ {stats: firstStats}
5935
+ );
5936
+
5937
+ // Should not trigger event again
5938
+ assert.neverCalledWith(
5939
+ TriggerProxy.trigger,
5940
+ sinon.match.instanceOf(Meeting),
5941
+ sinon.match.any,
5942
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
5943
+ sinon.match.any
5944
+ );
5945
+
5946
+ // Cipher should remain the same
5947
+ assert.equal(meeting.mediaProperties.srtpCipher, 'AES_CM_128_HMAC_SHA1_80');
5948
+ });
5949
+
5950
+ it('does not emit event when stats contain no transport with srtpCipher', async () => {
5951
+ const fakeStats = new Map([
5952
+ [
5953
+ 'outbound-rtp-1',
5954
+ {
5955
+ type: 'outbound-rtp',
5956
+ ssrc: 12345,
5957
+ },
5958
+ ],
5959
+ [
5960
+ 'inbound-rtp-1',
5961
+ {
5962
+ type: 'inbound-rtp',
5963
+ ssrc: 67890,
5964
+ },
5965
+ ],
5966
+ ]);
5967
+
5968
+ statsAnalyzerStub.emit(
5969
+ {file: 'test', function: 'test'},
5970
+ StatsAnalyzerEventNames.STATS_UPDATE,
5971
+ {stats: fakeStats}
5972
+ );
5973
+
5974
+ assert.neverCalledWith(
5975
+ TriggerProxy.trigger,
5976
+ sinon.match.instanceOf(Meeting),
5977
+ sinon.match.any,
5978
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
5979
+ sinon.match.any
5980
+ );
5981
+
5982
+ assert.isUndefined(meeting.mediaProperties.srtpCipher);
5983
+ });
5984
+
5985
+ it('does not emit event when transport stat has no srtpCipher property', async () => {
5986
+ const fakeStats = new Map([
5987
+ [
5988
+ 'transport-1',
5989
+ {
5990
+ type: 'transport',
5991
+ dtlsCipher: 'TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256',
5992
+ // no srtpCipher property
5993
+ },
5994
+ ],
5995
+ ]);
5996
+
5997
+ statsAnalyzerStub.emit(
5998
+ {file: 'test', function: 'test'},
5999
+ StatsAnalyzerEventNames.STATS_UPDATE,
6000
+ {stats: fakeStats}
6001
+ );
6002
+
6003
+ assert.neverCalledWith(
6004
+ TriggerProxy.trigger,
6005
+ sinon.match.instanceOf(Meeting),
6006
+ sinon.match.any,
6007
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
6008
+ sinon.match.any
6009
+ );
6010
+
6011
+ assert.isUndefined(meeting.mediaProperties.srtpCipher);
6012
+ });
6013
+
6014
+ it('uses first transport with srtpCipher when multiple transports exist', async () => {
6015
+ const fakeStats = new Map([
6016
+ [
6017
+ 'transport-1',
6018
+ {
6019
+ type: 'transport',
6020
+ srtpCipher: 'AES_CM_128_HMAC_SHA1_80',
6021
+ },
6022
+ ],
6023
+ [
6024
+ 'transport-2',
6025
+ {
6026
+ type: 'transport',
6027
+ srtpCipher: 'AEAD_AES_256_GCM',
6028
+ },
6029
+ ],
6030
+ [
6031
+ 'outbound-rtp-1',
6032
+ {
6033
+ type: 'outbound-rtp',
6034
+ ssrc: 12345,
6035
+ },
6036
+ ],
6037
+ ]);
6038
+
6039
+ statsAnalyzerStub.emit(
6040
+ {file: 'test', function: 'test'},
6041
+ StatsAnalyzerEventNames.STATS_UPDATE,
6042
+ {stats: fakeStats}
6043
+ );
6044
+
6045
+ assert.calledWith(
6046
+ TriggerProxy.trigger,
6047
+ sinon.match.instanceOf(Meeting),
6048
+ {
6049
+ file: 'meeting/index',
6050
+ function: 'setupStatsAnalyzerEventHandlers',
6051
+ },
6052
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
6053
+ {srtpCipher: 'AES_CM_128_HMAC_SHA1_80'}
6054
+ );
6055
+
6056
+ assert.equal(meeting.mediaProperties.srtpCipher, 'AES_CM_128_HMAC_SHA1_80');
6057
+ });
6058
+
6059
+ it('handles empty stats map without errors', async () => {
6060
+ const emptyStats = new Map();
6061
+
6062
+ statsAnalyzerStub.emit(
6063
+ {file: 'test', function: 'test'},
6064
+ StatsAnalyzerEventNames.STATS_UPDATE,
6065
+ {stats: emptyStats}
6066
+ );
6067
+
6068
+ assert.neverCalledWith(
6069
+ TriggerProxy.trigger,
6070
+ sinon.match.instanceOf(Meeting),
6071
+ sinon.match.any,
6072
+ EVENT_TRIGGERS.MEETING_SRTP_CIPHER_UPDATED,
6073
+ sinon.match.any
6074
+ );
6075
+
6076
+ assert.isUndefined(meeting.mediaProperties.srtpCipher);
6077
+ });
6078
+
6079
+ it('logs cipher change when cipher is updated', async () => {
6080
+ const loggerSpy = sinon.spy(LoggerProxy.logger, 'info');
6081
+
6082
+ meeting.mediaProperties.srtpCipher = 'AES_CM_128_HMAC_SHA1_80';
6083
+
6084
+ const newStats = new Map([
6085
+ [
6086
+ 'transport-1',
6087
+ {
6088
+ type: 'transport',
6089
+ srtpCipher: 'AEAD_AES_256_GCM',
6090
+ },
6091
+ ],
6092
+ ]);
6093
+
6094
+ statsAnalyzerStub.emit(
6095
+ {file: 'test', function: 'test'},
6096
+ StatsAnalyzerEventNames.STATS_UPDATE,
6097
+ {stats: newStats}
6098
+ );
6099
+
6100
+ assert.calledWithMatch(
6101
+ loggerSpy,
6102
+ sinon.match(/SRTP cipher changed from AES_CM_128_HMAC_SHA1_80 to AEAD_AES_256_GCM/)
6103
+ );
6104
+
6105
+ loggerSpy.restore();
6106
+ });
6107
+ });
4537
6108
  });
4538
6109
 
4539
6110
  describe('handles StatsMonitor events', () => {
@@ -4633,10 +6204,55 @@ describe('plugin-meetings', () => {
4633
6204
  isAudioMuted: false,
4634
6205
  };
4635
6206
  meeting.members.membersCollection.getAll = sinon.stub().returns({
4636
- member1: mutedMember,
4637
- member2: unmutedMember,
4638
- member3: selfMember,
6207
+ member1: mutedMember,
6208
+ member2: unmutedMember,
6209
+ member3: selfMember,
6210
+ });
6211
+ meeting.isUserUnadmitted = false;
6212
+
6213
+ // Reset the stub to clear any previous calls
6214
+ TriggerProxy.trigger.resetHistory();
6215
+
6216
+ // Emit the event from statsMonitor
6217
+ listeners[StatsMonitorEventNames.INBOUND_AUDIO_ISSUE](fakeEventData);
6218
+
6219
+ assert.calledWith(
6220
+ TriggerProxy.trigger,
6221
+ meeting,
6222
+ sinon.match.object,
6223
+ EVENT_TRIGGERS.MEDIA_INBOUND_AUDIO_ISSUE_DETECTED,
6224
+ fakeEventData
6225
+ );
6226
+
6227
+ assert.calledOnceWithExactly(
6228
+ meeting.mediaProperties.sendMediaIssueMetric,
6229
+ 'inbound_audio',
6230
+ fakeEventData.issueSubType,
6231
+ {
6232
+ correlationId: meeting.correlationId,
6233
+ isMultistream: meeting.isMultistream,
6234
+ }
6235
+ );
6236
+ });
6237
+
6238
+ it('should not trigger event or metric when the user is in the lobby', () => {
6239
+ const fakeEventData = {issueSubType: 'DECODE_RESULTS_IN_ZERO_AUDIO_LEVEL'};
6240
+
6241
+ const unmutedMember = {
6242
+ isSelf: false,
6243
+ isPairedWithSelf: false,
6244
+ isAudioMuted: false,
6245
+ };
6246
+ const selfMember = {
6247
+ isSelf: true,
6248
+ isPairedWithSelf: false,
6249
+ isAudioMuted: false,
6250
+ };
6251
+ meeting.members.membersCollection.getAll = sinon.stub().returns({
6252
+ member1: unmutedMember,
6253
+ member2: selfMember,
4639
6254
  });
6255
+ meeting.isUserUnadmitted = true;
4640
6256
 
4641
6257
  // Reset the stub to clear any previous calls
4642
6258
  TriggerProxy.trigger.resetHistory();
@@ -4644,20 +6260,14 @@ describe('plugin-meetings', () => {
4644
6260
  // Emit the event from statsMonitor
4645
6261
  listeners[StatsMonitorEventNames.INBOUND_AUDIO_ISSUE](fakeEventData);
4646
6262
 
4647
- assert.calledWith(
6263
+ assert.neverCalledWith(
4648
6264
  TriggerProxy.trigger,
4649
6265
  meeting,
4650
6266
  sinon.match.object,
4651
6267
  EVENT_TRIGGERS.MEDIA_INBOUND_AUDIO_ISSUE_DETECTED,
4652
6268
  fakeEventData
4653
6269
  );
4654
-
4655
- assert.calledOnceWithExactly(
4656
- meeting.mediaProperties.sendMediaIssueMetric,
4657
- 'inbound_audio',
4658
- fakeEventData.issueSubType,
4659
- meeting.correlationId
4660
- );
6270
+ assert.notCalled(meeting.mediaProperties.sendMediaIssueMetric);
4661
6271
  });
4662
6272
  });
4663
6273
  });
@@ -6192,13 +7802,14 @@ describe('plugin-meetings', () => {
6192
7802
  sinon.stub(meeting.locusMediaRequest, 'downgradeFromMultistreamToTranscoded');
6193
7803
  });
6194
7804
 
6195
- const runCheck = async (turnServerInfo, forceTurnDiscovery) => {
7805
+ const runCheck = async (turnServerInfo, forceTurnDiscovery, iceTransportPolicy) => {
6196
7806
  // we're calling addMediaInternal() with mic stream,
6197
7807
  // so that we also verify that audioMute, videoMute info is correctly sent to backend
6198
7808
  const addMediaPromise = meeting.addMediaInternal(
6199
7809
  () => '',
6200
- turnServerInfo,
6201
7810
  forceTurnDiscovery,
7811
+ turnServerInfo,
7812
+ iceTransportPolicy,
6202
7813
  {
6203
7814
  localStreams: {microphone: fakeMicrophoneStream},
6204
7815
  }
@@ -6252,6 +7863,10 @@ describe('plugin-meetings', () => {
6252
7863
  // at this point the meeting should have been downgraded to transcoded
6253
7864
  assert.equal(meeting.isMultistream, false);
6254
7865
 
7866
+ // iceTransportPolicy must be reset to undefined on downgrade to transcoded,
7867
+ // otherwise the transcoded retry could gather direct candidates while metrics report relay
7868
+ assert.isUndefined(meeting.addMediaData.iceTransportPolicy);
7869
+
6255
7870
  // old stats analyzer stopped and new one created
6256
7871
  assert.calledOnce(initialStatsAnalyzer.stopAnalyzer);
6257
7872
  assert.calledOnceWithExactly(
@@ -6342,6 +7957,11 @@ describe('plugin-meetings', () => {
6342
7957
  true
6343
7958
  );
6344
7959
  });
7960
+
7961
+ it('resets iceTransportPolicy to undefined when falling back from multistream (relay) to transcoded', async () => {
7962
+ // simulate a relay-only retry falling back to transcoded and verify iceTransportPolicy is reset
7963
+ await runCheck(undefined, false, 'relay');
7964
+ });
6345
7965
  });
6346
7966
  }
6347
7967
  })
@@ -6429,6 +8049,9 @@ describe('plugin-meetings', () => {
6429
8049
 
6430
8050
  meeting.annotation.deregisterEvents = sinon.stub();
6431
8051
  webex.internal.llm.off = sinon.stub();
8052
+ webex.internal.mercury.off = sinon.stub();
8053
+ meeting.mercuryOnlineHandler = sinon.stub();
8054
+ meeting.mercuryOfflineHandler = sinon.stub();
6432
8055
 
6433
8056
  // A meeting needs to be joined to leave
6434
8057
  meeting.meetingState = 'ACTIVE';
@@ -6452,6 +8075,67 @@ describe('plugin-meetings', () => {
6452
8075
  assert.calledOnce(meeting.clearMeetingData);
6453
8076
  });
6454
8077
 
8078
+ it('stops listening for LLM/Mercury and tears down transcription and annotation before calling Locus /leave', async () => {
8079
+ const onlineHandler = meeting.mercuryOnlineHandler;
8080
+ const offlineHandler = meeting.mercuryOfflineHandler;
8081
+
8082
+ await meeting.leave();
8083
+
8084
+ // All llm/mercury consumers (direct listeners, voicea transcription,
8085
+ // annotation) must be detached before the /leave request so that
8086
+ // in-flight events do not trigger unnecessary Locus syncs
8087
+ // (per Locus team recommendation).
8088
+ assert.callOrder(
8089
+ webex.internal.llm.off,
8090
+ webex.internal.mercury.off,
8091
+ meeting.stopTranscription,
8092
+ meeting.annotation.deregisterEvents,
8093
+ meeting.meetingRequest.leaveMeeting
8094
+ );
8095
+ assert.calledWithExactly(
8096
+ webex.internal.llm.off,
8097
+ 'event:relay.event',
8098
+ meeting.processRelayEvent
8099
+ );
8100
+ assert.calledWithExactly(
8101
+ webex.internal.llm.off,
8102
+ LOCUS_LLM_EVENT,
8103
+ meeting.processLocusLLMEvent
8104
+ );
8105
+ assert.calledWithExactly(webex.internal.mercury.off, ONLINE, onlineHandler);
8106
+ assert.calledWithExactly(webex.internal.mercury.off, OFFLINE, offlineHandler);
8107
+ assert.isUndefined(meeting.mercuryOnlineHandler);
8108
+ assert.isUndefined(meeting.mercuryOfflineHandler);
8109
+ assert.calledOnceWithExactly(meeting.stopTranscription);
8110
+ assert.calledOnceWithExactly(meeting.annotation.deregisterEvents);
8111
+ assert.isUndefined(meeting.transcription);
8112
+ });
8113
+
8114
+ it('tears down llm/mercury/transcription/annotation even when /leave rejects', async () => {
8115
+ const onlineHandler = meeting.mercuryOnlineHandler;
8116
+ const offlineHandler = meeting.mercuryOfflineHandler;
8117
+ meeting.meetingRequest.leaveMeeting = sinon
8118
+ .stub()
8119
+ .returns(Promise.reject(new Error('leave failed')));
8120
+
8121
+ await meeting.leave().catch(() => {});
8122
+
8123
+ assert.calledWithExactly(
8124
+ webex.internal.llm.off,
8125
+ 'event:relay.event',
8126
+ meeting.processRelayEvent
8127
+ );
8128
+ assert.calledWithExactly(
8129
+ webex.internal.llm.off,
8130
+ LOCUS_LLM_EVENT,
8131
+ meeting.processLocusLLMEvent
8132
+ );
8133
+ assert.calledWithExactly(webex.internal.mercury.off, ONLINE, onlineHandler);
8134
+ assert.calledWithExactly(webex.internal.mercury.off, OFFLINE, offlineHandler);
8135
+ assert.calledOnceWithExactly(meeting.stopTranscription);
8136
+ assert.calledOnceWithExactly(meeting.annotation.deregisterEvents);
8137
+ });
8138
+
6455
8139
  it('should reset call diagnostic latencies correctly', async () => {
6456
8140
  const leave = meeting.leave();
6457
8141
 
@@ -7349,7 +9033,11 @@ describe('plugin-meetings', () => {
7349
9033
  beforeEach(() => {
7350
9034
  meeting.locusId = 'locus-id';
7351
9035
  meeting.id = 'meeting-id';
7352
- FAKE_OPTIONS = {meetingId: meeting.id, sendCAevents: true};
9036
+ FAKE_OPTIONS = {
9037
+ meetingId: meeting.id,
9038
+ sendCAevents: true,
9039
+ correlationId: meeting.correlationId,
9040
+ };
7353
9041
  });
7354
9042
 
7355
9043
  it('calls meetingInfoProvider with all the right parameters and parses the result', async () => {
@@ -7434,7 +9122,11 @@ describe('plugin-meetings', () => {
7434
9122
  undefined,
7435
9123
  meeting.locusId,
7436
9124
  {},
7437
- {meetingId: meeting.id, sendCAevents: false}
9125
+ {
9126
+ meetingId: meeting.id,
9127
+ sendCAevents: false,
9128
+ correlationId: meeting.correlationId,
9129
+ }
7438
9130
  );
7439
9131
 
7440
9132
  // parseMeeting info
@@ -7520,7 +9212,11 @@ describe('plugin-meetings', () => {
7520
9212
  undefined,
7521
9213
  'locus-id',
7522
9214
  {},
7523
- {meetingId: meeting.id, sendCAevents: true}
9215
+ {
9216
+ meetingId: meeting.id,
9217
+ sendCAevents: true,
9218
+ correlationId: meeting.correlationId,
9219
+ }
7524
9220
  );
7525
9221
 
7526
9222
  assert.deepEqual(meeting.meetingInfo, FAKE_MEETING_INFO);
@@ -7556,7 +9252,11 @@ describe('plugin-meetings', () => {
7556
9252
  undefined,
7557
9253
  'locus-id',
7558
9254
  {},
7559
- {meetingId: meeting.id, sendCAevents: true}
9255
+ {
9256
+ meetingId: meeting.id,
9257
+ sendCAevents: true,
9258
+ correlationId: meeting.correlationId,
9259
+ }
7560
9260
  );
7561
9261
 
7562
9262
  assert.deepEqual(meeting.meetingInfo, FAKE_MEETING_INFO);
@@ -7585,7 +9285,11 @@ describe('plugin-meetings', () => {
7585
9285
  undefined,
7586
9286
  'locus-id',
7587
9287
  {},
7588
- {meetingId: meeting.id, sendCAevents: true}
9288
+ {
9289
+ meetingId: meeting.id,
9290
+ sendCAevents: true,
9291
+ correlationId: meeting.correlationId,
9292
+ }
7589
9293
  );
7590
9294
 
7591
9295
  assert.deepEqual(meeting.meetingInfo, FAKE_MEETING_INFO);
@@ -7620,7 +9324,11 @@ describe('plugin-meetings', () => {
7620
9324
  undefined,
7621
9325
  'locus-id',
7622
9326
  {},
7623
- {meetingId: meeting.id, sendCAevents: true}
9327
+ {
9328
+ meetingId: meeting.id,
9329
+ sendCAevents: true,
9330
+ correlationId: meeting.correlationId,
9331
+ }
7624
9332
  );
7625
9333
 
7626
9334
  assert.deepEqual(meeting.meetingInfo, {});
@@ -7666,7 +9374,11 @@ describe('plugin-meetings', () => {
7666
9374
  undefined,
7667
9375
  'locus-id',
7668
9376
  {},
7669
- {meetingId: meeting.id, sendCAevents: true}
9377
+ {
9378
+ meetingId: meeting.id,
9379
+ sendCAevents: true,
9380
+ correlationId: meeting.correlationId,
9381
+ }
7670
9382
  );
7671
9383
 
7672
9384
  assert.deepEqual(meeting.meetingInfo, {});
@@ -7700,7 +9412,11 @@ describe('plugin-meetings', () => {
7700
9412
  undefined,
7701
9413
  'locus-id',
7702
9414
  {},
7703
- {meetingId: meeting.id, sendCAevents: true}
9415
+ {
9416
+ meetingId: meeting.id,
9417
+ sendCAevents: true,
9418
+ correlationId: meeting.correlationId,
9419
+ }
7704
9420
  );
7705
9421
 
7706
9422
  assert.deepEqual(meeting.meetingInfo, {
@@ -7753,7 +9469,11 @@ describe('plugin-meetings', () => {
7753
9469
  undefined,
7754
9470
  'locus-id',
7755
9471
  {},
7756
- {meetingId: meeting.id, sendCAevents: true}
9472
+ {
9473
+ meetingId: meeting.id,
9474
+ sendCAevents: true,
9475
+ correlationId: meeting.correlationId,
9476
+ }
7757
9477
  );
7758
9478
 
7759
9479
  assert.deepEqual(meeting.meetingInfo, FAKE_MEETING_INFO);
@@ -8042,7 +9762,11 @@ describe('plugin-meetings', () => {
8042
9762
  'fake-installed-org-id',
8043
9763
  'locus-id',
8044
9764
  {extraParam1: 'value1', permissionToken: FAKE_PERMISSION_TOKEN},
8045
- {meetingId: meeting.id, sendCAevents: true},
9765
+ {
9766
+ meetingId: meeting.id,
9767
+ sendCAevents: true,
9768
+ correlationId: meeting.correlationId,
9769
+ },
8046
9770
  null,
8047
9771
  null,
8048
9772
  null
@@ -8090,7 +9814,11 @@ describe('plugin-meetings', () => {
8090
9814
  'fake-installed-org-id',
8091
9815
  'locus-id',
8092
9816
  {extraParam1: 'value1', permissionToken: FAKE_PERMISSION_TOKEN},
8093
- {meetingId: meeting.id, sendCAevents: true},
9817
+ {
9818
+ meetingId: meeting.id,
9819
+ sendCAevents: true,
9820
+ correlationId: meeting.correlationId,
9821
+ },
8094
9822
  null,
8095
9823
  null,
8096
9824
  null
@@ -8147,7 +9875,11 @@ describe('plugin-meetings', () => {
8147
9875
  extraParam1: 'value1',
8148
9876
  permissionToken: FAKE_PERMISSION_TOKEN,
8149
9877
  },
8150
- {meetingId: meeting.id, sendCAevents: true},
9878
+ {
9879
+ meetingId: meeting.id,
9880
+ sendCAevents: true,
9881
+ correlationId: meeting.correlationId,
9882
+ },
8151
9883
  null,
8152
9884
  null,
8153
9885
  null
@@ -8459,6 +10191,9 @@ describe('plugin-meetings', () => {
8459
10191
 
8460
10192
  meeting.annotation.deregisterEvents = sinon.stub();
8461
10193
  webex.internal.llm.off = sinon.stub();
10194
+ webex.internal.mercury.off = sinon.stub();
10195
+ meeting.mercuryOnlineHandler = sinon.stub();
10196
+ meeting.mercuryOfflineHandler = sinon.stub();
8462
10197
 
8463
10198
  // A meeting needs to be joined to end
8464
10199
  meeting.meetingState = 'ACTIVE';
@@ -8481,6 +10216,66 @@ describe('plugin-meetings', () => {
8481
10216
  assert.calledOnce(meeting?.unsetPeerConnections);
8482
10217
  assert.calledOnce(meeting?.clearMeetingData);
8483
10218
  });
10219
+
10220
+ it('stops listening for LLM/Mercury and tears down transcription and annotation before calling Locus /end', async () => {
10221
+ const onlineHandler = meeting.mercuryOnlineHandler;
10222
+ const offlineHandler = meeting.mercuryOfflineHandler;
10223
+
10224
+ await meeting.endMeetingForAll();
10225
+
10226
+ // All llm/mercury consumers (direct listeners, voicea transcription,
10227
+ // annotation) must be detached before the /end request so that
10228
+ // in-flight events do not trigger unnecessary Locus syncs
10229
+ // (per Locus team recommendation).
10230
+ assert.callOrder(
10231
+ webex.internal.llm.off,
10232
+ webex.internal.mercury.off,
10233
+ meeting.stopTranscription,
10234
+ meeting.annotation.deregisterEvents,
10235
+ meeting.meetingRequest.endMeetingForAll
10236
+ );
10237
+ assert.calledWithExactly(
10238
+ webex.internal.llm.off,
10239
+ 'event:relay.event',
10240
+ meeting.processRelayEvent
10241
+ );
10242
+ assert.calledWithExactly(
10243
+ webex.internal.llm.off,
10244
+ LOCUS_LLM_EVENT,
10245
+ meeting.processLocusLLMEvent
10246
+ );
10247
+ assert.calledWithExactly(webex.internal.mercury.off, ONLINE, onlineHandler);
10248
+ assert.calledWithExactly(webex.internal.mercury.off, OFFLINE, offlineHandler);
10249
+ assert.isUndefined(meeting.mercuryOnlineHandler);
10250
+ assert.isUndefined(meeting.mercuryOfflineHandler);
10251
+ assert.calledOnceWithExactly(meeting.stopTranscription);
10252
+ assert.calledOnceWithExactly(meeting.annotation.deregisterEvents);
10253
+ });
10254
+
10255
+ it('tears down llm/mercury/transcription/annotation even when /end rejects', async () => {
10256
+ const onlineHandler = meeting.mercuryOnlineHandler;
10257
+ const offlineHandler = meeting.mercuryOfflineHandler;
10258
+ meeting.meetingRequest.endMeetingForAll = sinon
10259
+ .stub()
10260
+ .returns(Promise.reject(new Error('end failed')));
10261
+
10262
+ await meeting.endMeetingForAll().catch(() => {});
10263
+
10264
+ assert.calledWithExactly(
10265
+ webex.internal.llm.off,
10266
+ 'event:relay.event',
10267
+ meeting.processRelayEvent
10268
+ );
10269
+ assert.calledWithExactly(
10270
+ webex.internal.llm.off,
10271
+ LOCUS_LLM_EVENT,
10272
+ meeting.processLocusLLMEvent
10273
+ );
10274
+ assert.calledWithExactly(webex.internal.mercury.off, ONLINE, onlineHandler);
10275
+ assert.calledWithExactly(webex.internal.mercury.off, OFFLINE, offlineHandler);
10276
+ assert.calledOnceWithExactly(meeting.stopTranscription);
10277
+ assert.calledOnceWithExactly(meeting.annotation.deregisterEvents);
10278
+ });
8484
10279
  });
8485
10280
 
8486
10281
  describe('#moveTo', () => {
@@ -9262,7 +11057,9 @@ describe('plugin-meetings', () => {
9262
11057
  MediaCodecMimeType.OPUS,
9263
11058
  ['maxaveragebitrate', 'maxplaybackrate']
9264
11059
  );
9265
- assert.notCalled(meeting.sendSlotManager.getSlot(MediaType.AudioMain).setCustomCodecParameters);
11060
+ assert.notCalled(
11061
+ meeting.sendSlotManager.getSlot(MediaType.AudioMain).setCustomCodecParameters
11062
+ );
9266
11063
  });
9267
11064
  });
9268
11065
 
@@ -9990,6 +11787,8 @@ describe('plugin-meetings', () => {
9990
11787
  });
9991
11788
 
9992
11789
  it('handles REMOTE_SDP_ANSWER_PROCESSED correctly', () => {
11790
+ // capture the start timestamp before any fake timers are installed
11791
+ const localSdpGeneratedTimestamp = Date.now() - 100;
9993
11792
  const clock = sinon.useFakeTimers();
9994
11793
  sinon.spy(clock, 'clearTimeout');
9995
11794
  meeting.deferSDPAnswer = {
@@ -9997,24 +11796,29 @@ describe('plugin-meetings', () => {
9997
11796
  };
9998
11797
  meeting.sdpResponseTimer = '1234';
9999
11798
 
11799
+ // latency is computed as Date.now() - the stored local-sdp-generated timestamp,
11800
+ // so it is unaffected by any earlier remote-sdp-received timestamp saved on timeout
11801
+ webex.internal.newMetrics.callDiagnosticLatencies.latencyTimestamps = new Map([
11802
+ ['client.media-engine.local-sdp-generated', localSdpGeneratedTimestamp],
11803
+ ]);
11804
+
10000
11805
  eventListeners[MediaConnectionEventNames.REMOTE_SDP_ANSWER_PROCESSED]();
10001
11806
 
10002
11807
  assert.calledOnce(webex.internal.newMetrics.submitClientEvent);
10003
11808
  assert.calledWithMatch(webex.internal.newMetrics.submitClientEvent, {
10004
11809
  name: 'client.media-engine.remote-sdp-received',
11810
+ payload: {
11811
+ eventData: {
11812
+ localSDPGenRemoteSDPRecv: sinon.match(
11813
+ (value) => typeof value === 'number' && value >= 100 && value < 5000
11814
+ ),
11815
+ },
11816
+ },
10005
11817
  options: {meetingId: meeting.id},
10006
11818
  });
10007
11819
 
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
- );
11820
+ // the high-volume ROAP_OFFER_TO_ANSWER_LATENCY behavioral metric is no longer sent
11821
+ assert.notCalled(Metrics.sendBehavioralMetric);
10018
11822
 
10019
11823
  assert.calledOnce(meeting.deferSDPAnswer.resolve);
10020
11824
  assert.calledOnce(clock.clearTimeout);
@@ -10022,6 +11826,28 @@ describe('plugin-meetings', () => {
10022
11826
  assert.equal(meeting.sdpResponseTimer, undefined);
10023
11827
  });
10024
11828
 
11829
+ it('sends undefined localSDPGenRemoteSDPRecv when the local-sdp-generated timestamp is missing', () => {
11830
+ meeting.deferSDPAnswer = {
11831
+ resolve: sinon.stub(),
11832
+ };
11833
+
11834
+ // no local-sdp-generated timestamp stored -> latency cannot be computed
11835
+ webex.internal.newMetrics.callDiagnosticLatencies.latencyTimestamps = new Map();
11836
+
11837
+ eventListeners[MediaConnectionEventNames.REMOTE_SDP_ANSWER_PROCESSED]();
11838
+
11839
+ assert.calledOnce(webex.internal.newMetrics.submitClientEvent);
11840
+ assert.calledWithMatch(webex.internal.newMetrics.submitClientEvent, {
11841
+ name: 'client.media-engine.remote-sdp-received',
11842
+ payload: {
11843
+ eventData: {
11844
+ localSDPGenRemoteSDPRecv: undefined,
11845
+ },
11846
+ },
11847
+ options: {meetingId: meeting.id},
11848
+ });
11849
+ });
11850
+
10025
11851
  it('handles LOCAL_SDP_OFFER_GENERATED correctly', () => {
10026
11852
  assert.equal(meeting.deferSDPAnswer, undefined);
10027
11853
 
@@ -10417,16 +12243,16 @@ describe('plugin-meetings', () => {
10417
12243
  );
10418
12244
  done();
10419
12245
  });
10420
- it('listens to the self admitted guest event without blocking on token prefetch', async () => {
12246
+ it('listens to the self admitted guest event and waits for token prefetch before reconnecting LLM', async () => {
10421
12247
  meeting.stopKeepAlive = sinon.stub();
10422
12248
  meeting.updateLLMConnection = sinon.stub();
10423
12249
  let resolvePrefetch;
10424
12250
 
10425
- meeting.ensureDefaultDatachannelTokenAfterAdmit = sinon
10426
- .stub()
10427
- .returns(new Promise((resolve) => {
12251
+ meeting.ensureDefaultDatachannelTokenAfterAdmit = sinon.stub().returns(
12252
+ new Promise((resolve) => {
10428
12253
  resolvePrefetch = resolve;
10429
- }));
12254
+ })
12255
+ );
10430
12256
  meeting.rtcMetrics = {
10431
12257
  sendNextMetrics: sinon.stub(),
10432
12258
  };
@@ -10443,7 +12269,7 @@ describe('plugin-meetings', () => {
10443
12269
  'meeting:self:guestAdmitted',
10444
12270
  {payload: test1}
10445
12271
  );
10446
- assert.calledOnce(meeting.updateLLMConnection);
12272
+ assert.notCalled(meeting.updateLLMConnection);
10447
12273
  assert.calledOnceWithExactly(meeting.rtcMetrics.sendNextMetrics);
10448
12274
 
10449
12275
  assert.calledOnceWithExactly(
@@ -10456,6 +12282,7 @@ describe('plugin-meetings', () => {
10456
12282
 
10457
12283
  resolvePrefetch(false);
10458
12284
  await Promise.resolve();
12285
+ await Promise.resolve();
10459
12286
 
10460
12287
  assert.calledOnce(meeting.updateLLMConnection);
10461
12288
  });
@@ -10971,6 +12798,106 @@ describe('plugin-meetings', () => {
10971
12798
  );
10972
12799
  });
10973
12800
 
12801
+ const recordingTestCases = [
12802
+ {
12803
+ description: 'triggers MEETING_STARTED_RECORDING when state is RECORDING',
12804
+ state: RECORDING_STATE.RECORDING,
12805
+ expectedEvent: EVENT_TRIGGERS.MEETING_STARTED_RECORDING,
12806
+ expectedRecordingState: RECORDING_STATE.RECORDING,
12807
+ },
12808
+ {
12809
+ description: 'triggers MEETING_STOPPED_RECORDING when state is IDLE',
12810
+ state: RECORDING_STATE.IDLE,
12811
+ expectedEvent: EVENT_TRIGGERS.MEETING_STOPPED_RECORDING,
12812
+ expectedRecordingState: RECORDING_STATE.IDLE,
12813
+ },
12814
+ {
12815
+ description: 'triggers MEETING_PAUSED_RECORDING when state is PAUSED',
12816
+ state: RECORDING_STATE.PAUSED,
12817
+ expectedEvent: EVENT_TRIGGERS.MEETING_PAUSED_RECORDING,
12818
+ expectedRecordingState: RECORDING_STATE.PAUSED,
12819
+ },
12820
+ {
12821
+ description:
12822
+ 'triggers MEETING_RESUMED_RECORDING and sets state to RECORDING when state is RESUMED',
12823
+ state: RECORDING_STATE.RESUMED,
12824
+ expectedEvent: EVENT_TRIGGERS.MEETING_RESUMED_RECORDING,
12825
+ expectedRecordingState: RECORDING_STATE.RECORDING,
12826
+ },
12827
+ ];
12828
+
12829
+ recordingTestCases.forEach(
12830
+ ({description, state, expectedEvent, expectedRecordingState}) => {
12831
+ it(`listens to CONTROLS_RECORDING_UPDATED - ${description}`, async () => {
12832
+ const modifiedBy = 'user-id-123';
12833
+ const lastModified = '2026-01-01T00:00:00Z';
12834
+
12835
+ await meeting.locusInfo.emitScoped(
12836
+ {function: 'test', file: 'test'},
12837
+ LOCUSINFO.EVENTS.CONTROLS_RECORDING_UPDATED,
12838
+ {
12839
+ state,
12840
+ modifiedBy,
12841
+ lastModified,
12842
+ modifiedByServiceAppName: undefined,
12843
+ modifiedByServiceAppId: undefined,
12844
+ }
12845
+ );
12846
+
12847
+ assert.deepEqual(meeting.recording, {
12848
+ state: expectedRecordingState,
12849
+ modifiedBy,
12850
+ lastModified,
12851
+ modifiedByServiceAppName: undefined,
12852
+ modifiedByServiceAppId: undefined,
12853
+ });
12854
+
12855
+ assert.calledWith(
12856
+ TriggerProxy.trigger,
12857
+ meeting,
12858
+ {file: 'meeting/index', function: 'setupLocusControlsListener'},
12859
+ expectedEvent,
12860
+ meeting.recording
12861
+ );
12862
+ });
12863
+ }
12864
+ );
12865
+
12866
+ it('listens to CONTROLS_RECORDING_UPDATED and includes modifiedByServiceAppName and modifiedByServiceAppId when present', async () => {
12867
+ const modifiedBy = 'user-id-123';
12868
+ const lastModified = '2026-01-01T00:00:00Z';
12869
+ const modifiedByServiceAppName = 'My Bot';
12870
+ const modifiedByServiceAppId = 'app-id-123';
12871
+
12872
+ await meeting.locusInfo.emitScoped(
12873
+ {function: 'test', file: 'test'},
12874
+ LOCUSINFO.EVENTS.CONTROLS_RECORDING_UPDATED,
12875
+ {
12876
+ state: RECORDING_STATE.RECORDING,
12877
+ modifiedBy,
12878
+ lastModified,
12879
+ modifiedByServiceAppName,
12880
+ modifiedByServiceAppId,
12881
+ }
12882
+ );
12883
+
12884
+ assert.deepEqual(meeting.recording, {
12885
+ state: RECORDING_STATE.RECORDING,
12886
+ modifiedBy,
12887
+ lastModified,
12888
+ modifiedByServiceAppName,
12889
+ modifiedByServiceAppId,
12890
+ });
12891
+
12892
+ assert.calledWith(
12893
+ TriggerProxy.trigger,
12894
+ meeting,
12895
+ {file: 'meeting/index', function: 'setupLocusControlsListener'},
12896
+ EVENT_TRIGGERS.MEETING_STARTED_RECORDING,
12897
+ meeting.recording
12898
+ );
12899
+ });
12900
+
10974
12901
  it('listens to the locus interpretation update event', () => {
10975
12902
  const interpretation = {
10976
12903
  siLanguages: [{languageCode: 20, languageName: 'en'}],
@@ -11024,6 +12951,7 @@ describe('plugin-meetings', () => {
11024
12951
  meeting.annotation.locusUrlUpdate = sinon.stub();
11025
12952
  meeting.simultaneousInterpretation.locusUrlUpdate = sinon.stub();
11026
12953
  meeting.webinar.locusUrlUpdate = sinon.stub();
12954
+ meeting.aiEnableRequest.locusUrlUpdate = sinon.stub();
11027
12955
 
11028
12956
  meeting.locusInfo.emit(
11029
12957
  {function: 'test', file: 'test'},
@@ -11038,6 +12966,7 @@ describe('plugin-meetings', () => {
11038
12966
  assert.calledWith(meeting.controlsOptionsManager.setLocusUrl, newLocusUrl, false);
11039
12967
  assert.calledWith(meeting.simultaneousInterpretation.locusUrlUpdate, newLocusUrl);
11040
12968
  assert.calledWith(meeting.webinar.locusUrlUpdate, newLocusUrl);
12969
+ assert.calledWith(meeting.aiEnableRequest.locusUrlUpdate, newLocusUrl);
11041
12970
  assert.equal(meeting.locusUrl, newLocusUrl);
11042
12971
  assert(meeting.locusId, '12345');
11043
12972
 
@@ -11353,6 +13282,109 @@ describe('plugin-meetings', () => {
11353
13282
  });
11354
13283
  });
11355
13284
 
13285
+ describe('#finalizeMeetingAfterInitialLocusSetup', () => {
13286
+ it('refreshes destination from synced locus when destination type is LOCUS_ID', () => {
13287
+ const syncedLocus = {url: 'https://locus.example.com/locus/123', info: {topic: 'x'}};
13288
+
13289
+ meeting.destinationType = DESTINATION_TYPE.LOCUS_ID;
13290
+ meeting.destination = {info: {topic: 'old'}};
13291
+
13292
+ meeting.finalizeMeetingAfterInitialLocusSetup(syncedLocus);
13293
+
13294
+ assert.equal(meeting.destination, syncedLocus);
13295
+ });
13296
+
13297
+ it('does not refresh destination when destination type is not LOCUS_ID', () => {
13298
+ const syncedLocus = {url: 'https://locus.example.com/locus/123', info: {topic: 'x'}};
13299
+ const originalDestination = {destination: 'original-destination'};
13300
+
13301
+ meeting.destinationType = DESTINATION_TYPE.CONVERSATION_URL;
13302
+ meeting.destination = originalDestination;
13303
+
13304
+ meeting.finalizeMeetingAfterInitialLocusSetup(syncedLocus);
13305
+
13306
+ assert.equal(meeting.destination, originalDestination);
13307
+ });
13308
+
13309
+ it('fetches meeting info when meetingInfo is empty and destination has info', () => {
13310
+ const fetchMeetingInfoStub = sinon.stub(meeting, 'fetchMeetingInfo').resolves();
13311
+
13312
+ meeting.meetingInfo = {};
13313
+ meeting.destination = {url: 'https://locus.example.com/locus/123', info: {topic: 'x'}};
13314
+
13315
+ meeting.finalizeMeetingAfterInitialLocusSetup({});
13316
+
13317
+ assert.calledOnceWithExactly(fetchMeetingInfoStub, {});
13318
+ });
13319
+
13320
+ it('does not fetch meeting info when destination has no info', () => {
13321
+ const fetchMeetingInfoStub = sinon.stub(meeting, 'fetchMeetingInfo').resolves();
13322
+
13323
+ meeting.meetingInfo = {};
13324
+ meeting.destination = {url: 'https://locus.example.com/locus/123'};
13325
+
13326
+ meeting.finalizeMeetingAfterInitialLocusSetup({});
13327
+
13328
+ assert.notCalled(fetchMeetingInfoStub);
13329
+ });
13330
+
13331
+ it('does not fetch meeting info when meetingInfo is already populated', () => {
13332
+ const fetchMeetingInfoStub = sinon.stub(meeting, 'fetchMeetingInfo').resolves();
13333
+
13334
+ meeting.meetingInfo = {meetingJoinUrl: 'https://example.com/join/abc'};
13335
+ meeting.destination = {url: 'https://locus.example.com/locus/123', info: {topic: 'x'}};
13336
+
13337
+ meeting.finalizeMeetingAfterInitialLocusSetup({});
13338
+
13339
+ assert.notCalled(fetchMeetingInfoStub);
13340
+ });
13341
+
13342
+ it('does not fetch meeting info when delayed fetch timer is already scheduled', () => {
13343
+ const fetchMeetingInfoStub = sinon.stub(meeting, 'fetchMeetingInfo').resolves();
13344
+
13345
+ meeting.meetingInfo = {};
13346
+ meeting.destination = {url: 'https://locus.example.com/locus/123', info: {topic: 'x'}};
13347
+ meeting.fetchMeetingInfoTimeoutId = 42;
13348
+
13349
+ meeting.finalizeMeetingAfterInitialLocusSetup({});
13350
+
13351
+ assert.notCalled(fetchMeetingInfoStub);
13352
+ });
13353
+
13354
+ ['CALL', 'SIP_BRIDGE', 'SPACE_SHARE'].forEach((fullStateType) => {
13355
+ it(`does not fetch meeting info when destination is a 1:1 call (fullState.type ${fullStateType})`, () => {
13356
+ const fetchMeetingInfoStub = sinon.stub(meeting, 'fetchMeetingInfo').resolves();
13357
+
13358
+ meeting.meetingInfo = {};
13359
+ meeting.destination = {
13360
+ url: 'https://locus.example.com/locus/123',
13361
+ info: {topic: 'x'},
13362
+ };
13363
+
13364
+ meeting.finalizeMeetingAfterInitialLocusSetup({fullState: {type: fullStateType}});
13365
+
13366
+ assert.notCalled(fetchMeetingInfoStub);
13367
+ });
13368
+ });
13369
+
13370
+ it('swallows async fetchMeetingInfo errors and logs info', async () => {
13371
+ const error = new Error('fetch failed');
13372
+
13373
+ meeting.meetingInfo = {};
13374
+ meeting.destination = {url: 'https://locus.example.com/locus/123', info: {topic: 'x'}};
13375
+ sinon.stub(meeting, 'fetchMeetingInfo').returns(Promise.reject(error));
13376
+ const loggerInfoStub = sinon.stub(LoggerProxy.logger, 'info');
13377
+
13378
+ await meeting.finalizeMeetingAfterInitialLocusSetup({});
13379
+
13380
+ assert.calledOnce(loggerInfoStub);
13381
+ assert.match(
13382
+ loggerInfoStub.firstCall.args[0],
13383
+ /Meeting:index#finalizeMeetingAfterInitialLocusSetup --> deferred fetchMeetingInfo failed: fetch failed/
13384
+ );
13385
+ });
13386
+ });
13387
+
11356
13388
  describe('#emailInput', () => {
11357
13389
  it('should set the email input', () => {
11358
13390
  assert.notOk(meeting.emailInput);
@@ -11955,6 +13987,7 @@ describe('plugin-meetings', () => {
11955
13987
  let showAutoEndMeetingWarningSpy;
11956
13988
  let canAttendeeRequestAiAssistantEnabledSpy;
11957
13989
  let attendeeRequestAiAssistantDeclinedAllSpy;
13990
+ let isAnonymizeDisplayNamesEnabledSpy;
11958
13991
  // Due to import tree issues, hasHints must be stubed within the scope of the `it`.
11959
13992
 
11960
13993
  beforeEach(() => {
@@ -12003,6 +14036,10 @@ describe('plugin-meetings', () => {
12003
14036
  MeetingUtil,
12004
14037
  'attendeeRequestAiAssistantDeclinedAll'
12005
14038
  );
14039
+ isAnonymizeDisplayNamesEnabledSpy = sinon.spy(
14040
+ MeetingUtil,
14041
+ 'isAnonymizeDisplayNamesEnabled'
14042
+ );
12006
14043
  });
12007
14044
 
12008
14045
  afterEach(() => {
@@ -12011,6 +14048,7 @@ describe('plugin-meetings', () => {
12011
14048
  showAutoEndMeetingWarningSpy.restore();
12012
14049
  canAttendeeRequestAiAssistantEnabledSpy.restore();
12013
14050
  attendeeRequestAiAssistantDeclinedAllSpy.restore();
14051
+ isAnonymizeDisplayNamesEnabledSpy.restore();
12014
14052
  });
12015
14053
 
12016
14054
  forEach(
@@ -12568,6 +14606,7 @@ describe('plugin-meetings', () => {
12568
14606
  meeting.roles
12569
14607
  );
12570
14608
  assert.calledWith(attendeeRequestAiAssistantDeclinedAllSpy, userDisplayHints);
14609
+ assert.calledWith(isAnonymizeDisplayNamesEnabledSpy, userDisplayHints);
12571
14610
 
12572
14611
  assert.calledWith(ControlsOptionsUtil.hasHints, {
12573
14612
  requiredHints: [DISPLAY_HINTS.MUTE_ALL],
@@ -12782,6 +14821,10 @@ describe('plugin-meetings', () => {
12782
14821
  describe('#saveDataChannelToken', () => {
12783
14822
  beforeEach(() => {
12784
14823
  webex.internal.llm.setDatachannelToken = sinon.stub();
14824
+ webex.internal.llm.resolveSessionOwnership = sinon
14825
+ .stub()
14826
+ .returns({currentOwner: undefined, isOwner: true});
14827
+ webex.internal.llm.isConnected = sinon.stub().returns(false);
12785
14828
  });
12786
14829
 
12787
14830
  it('saves datachannelToken into LLM as Default', () => {
@@ -12794,7 +14837,8 @@ describe('plugin-meetings', () => {
12794
14837
  assert.calledWithExactly(
12795
14838
  webex.internal.llm.setDatachannelToken,
12796
14839
  'default-token',
12797
- 'llm-default-session'
14840
+ 'llm-default-session',
14841
+ meeting.id
12798
14842
  );
12799
14843
  });
12800
14844
 
@@ -12808,7 +14852,8 @@ describe('plugin-meetings', () => {
12808
14852
  assert.calledWithExactly(
12809
14853
  webex.internal.llm.setDatachannelToken,
12810
14854
  'ps-token',
12811
- 'llm-practice-session'
14855
+ 'llm-practice-session',
14856
+ meeting.id
12812
14857
  );
12813
14858
  });
12814
14859
 
@@ -12826,12 +14871,14 @@ describe('plugin-meetings', () => {
12826
14871
  assert.calledWithExactly(
12827
14872
  webex.internal.llm.setDatachannelToken,
12828
14873
  'default-token',
12829
- 'llm-default-session'
14874
+ 'llm-default-session',
14875
+ meeting.id
12830
14876
  );
12831
14877
  assert.calledWithExactly(
12832
14878
  webex.internal.llm.setDatachannelToken,
12833
14879
  'ps-token',
12834
- 'llm-practice-session'
14880
+ 'llm-practice-session',
14881
+ meeting.id
12835
14882
  );
12836
14883
  });
12837
14884
 
@@ -12850,19 +14897,44 @@ describe('plugin-meetings', () => {
12850
14897
  it('handles missing locus.self gracefully', () => {
12851
14898
  meeting.saveDataChannelToken({locus: {}});
12852
14899
 
12853
- assert.notCalled(webex.internal.llm.setDatachannelToken);
14900
+ assert.notCalled(webex.internal.llm.setDatachannelToken);
14901
+ });
14902
+
14903
+ it('writes token with meeting id as owner', () => {
14904
+ meeting.saveDataChannelToken({
14905
+ locus: {
14906
+ self: {datachannelToken: 'default-token'},
14907
+ },
14908
+ });
14909
+
14910
+ assert.calledOnceWithExactly(
14911
+ webex.internal.llm.setDatachannelToken,
14912
+ 'default-token',
14913
+ 'llm-default-session',
14914
+ meeting.id
14915
+ );
12854
14916
  });
12855
14917
  });
12856
14918
 
12857
14919
  describe('#clearDataChannelToken', () => {
12858
14920
  beforeEach(() => {
12859
- webex.internal.llm.resetDatachannelTokens = sinon.stub();
14921
+ webex.internal.llm.clearDatachannelToken = sinon.stub();
12860
14922
  });
12861
14923
 
12862
- it('calls resetDatachannelTokens on LLM', () => {
14924
+ it('delegates default and practice token clears to llm with meeting ownership id', () => {
12863
14925
  meeting.clearDataChannelToken();
12864
14926
 
12865
- assert.calledOnce(webex.internal.llm.resetDatachannelTokens);
14927
+ assert.calledWithExactly(
14928
+ webex.internal.llm.clearDatachannelToken,
14929
+ 'llm-default-session',
14930
+ meeting.id
14931
+ );
14932
+ assert.calledWithExactly(
14933
+ webex.internal.llm.clearDatachannelToken,
14934
+ 'llm-practice-session',
14935
+ meeting.id
14936
+ );
14937
+ assert.callCount(webex.internal.llm.clearDatachannelToken, 2);
12866
14938
  });
12867
14939
  });
12868
14940
 
@@ -12872,6 +14944,7 @@ describe('plugin-meetings', () => {
12872
14944
  webex.internal.llm.getLocusUrl = sinon.stub();
12873
14945
  webex.internal.llm.getDatachannelUrl = sinon.stub();
12874
14946
  webex.internal.llm.registerAndConnect = sinon.stub().resolves('something');
14947
+ webex.internal.llm.setRefreshHandler = sinon.stub();
12875
14948
  webex.internal.llm.disconnectLLM = sinon.stub().resolves();
12876
14949
  webex.internal.llm.on = sinon.stub();
12877
14950
  webex.internal.llm.off = sinon.stub();
@@ -12889,7 +14962,11 @@ describe('plugin-meetings', () => {
12889
14962
  meeting.joinedWith = {state: 'any other state'};
12890
14963
  webex.internal.llm.getLocusUrl.returns('a url');
12891
14964
 
12892
- meeting.locusInfo = {url: 'a url', info: {datachannelUrl: 'a datachannel url'}};
14965
+ meeting.locusInfo = {
14966
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
14967
+ url: 'a url',
14968
+ info: {datachannelUrl: 'a datachannel url'},
14969
+ };
12893
14970
 
12894
14971
  const result = await meeting.updateLLMConnection();
12895
14972
 
@@ -12901,6 +14978,7 @@ describe('plugin-meetings', () => {
12901
14978
  it('returns undefined if llm is already connected and the locus url is unchanged', async () => {
12902
14979
  meeting.joinedWith = {state: 'JOINED'};
12903
14980
  meeting.locusInfo = {
14981
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
12904
14982
  url: 'a url',
12905
14983
  info: {datachannelUrl: 'a datachannel url'},
12906
14984
  };
@@ -12937,7 +15015,11 @@ describe('plugin-meetings', () => {
12937
15015
  });
12938
15016
  it('connects if not already connected', async () => {
12939
15017
  meeting.joinedWith = {state: 'JOINED'};
12940
- meeting.locusInfo = {url: 'a url', info: {datachannelUrl: 'a datachannel url'}};
15018
+ meeting.locusInfo = {
15019
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
15020
+ url: 'a url',
15021
+ info: {datachannelUrl: 'a datachannel url'},
15022
+ };
12941
15023
 
12942
15024
  const result = await meeting.updateLLMConnection();
12943
15025
 
@@ -12948,7 +15030,14 @@ describe('plugin-meetings', () => {
12948
15030
  'a datachannel url',
12949
15031
  undefined
12950
15032
  );
15033
+ assert.calledOnceWithExactly(
15034
+ webex.internal.llm.setRefreshHandler,
15035
+ sinon.match.func,
15036
+ 'llm-default-session',
15037
+ meeting.id
15038
+ );
12951
15039
  assert.equal(result, 'something');
15040
+ assert.calledOnceWithExactly(meeting.locusInfo.syncAllHashTreeDatasets, {onlyLLM: true});
12952
15041
  });
12953
15042
  it('disconnects if the locus url has changed', async () => {
12954
15043
  meeting.joinedWith = {state: 'JOINED'};
@@ -12957,6 +15046,7 @@ describe('plugin-meetings', () => {
12957
15046
  webex.internal.llm.getLocusUrl.returns('a url');
12958
15047
 
12959
15048
  meeting.locusInfo = {
15049
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
12960
15050
  url: 'a different url',
12961
15051
  info: {datachannelUrl: 'a datachannel url'},
12962
15052
  self: {},
@@ -12964,10 +15054,15 @@ describe('plugin-meetings', () => {
12964
15054
 
12965
15055
  const result = await meeting.updateLLMConnection();
12966
15056
 
12967
- assert.calledWithExactly(webex.internal.llm.disconnectLLM, {
12968
- code: 3050,
12969
- reason: 'done (permanent)',
12970
- });
15057
+ assert.calledWithExactly(
15058
+ webex.internal.llm.disconnectLLM,
15059
+ {
15060
+ code: 3050,
15061
+ reason: 'done (permanent)',
15062
+ },
15063
+ 'llm-default-session',
15064
+ meeting.id
15065
+ );
12971
15066
 
12972
15067
  assert.calledWithExactly(
12973
15068
  webex.internal.llm.registerAndConnect,
@@ -13010,6 +15105,7 @@ describe('plugin-meetings', () => {
13010
15105
  webex.internal.llm.getLocusUrl.returns('a url');
13011
15106
 
13012
15107
  meeting.locusInfo = {
15108
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
13013
15109
  url: 'a url',
13014
15110
  info: {datachannelUrl: 'a different datachannel url'},
13015
15111
  self: {},
@@ -13017,10 +15113,15 @@ describe('plugin-meetings', () => {
13017
15113
 
13018
15114
  const result = await meeting.updateLLMConnection();
13019
15115
 
13020
- assert.calledWithExactly(webex.internal.llm.disconnectLLM, {
13021
- code: 3050,
13022
- reason: 'done (permanent)',
13023
- });
15116
+ assert.calledWithExactly(
15117
+ webex.internal.llm.disconnectLLM,
15118
+ {
15119
+ code: 3050,
15120
+ reason: 'done (permanent)',
15121
+ },
15122
+ 'llm-default-session',
15123
+ meeting.id
15124
+ );
13024
15125
 
13025
15126
  assert.calledWithExactly(
13026
15127
  webex.internal.llm.registerAndConnect,
@@ -13061,14 +15162,23 @@ describe('plugin-meetings', () => {
13061
15162
  webex.internal.llm.isConnected.returns(true);
13062
15163
  webex.internal.llm.getLocusUrl.returns('a url');
13063
15164
 
13064
- meeting.locusInfo = {url: 'a url', info: {datachannelUrl: 'a datachannel url'}};
15165
+ meeting.locusInfo = {
15166
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
15167
+ url: 'a url',
15168
+ info: {datachannelUrl: 'a datachannel url'},
15169
+ };
13065
15170
 
13066
15171
  const result = await meeting.updateLLMConnection();
13067
15172
 
13068
- assert.calledWith(webex.internal.llm.disconnectLLM, {
13069
- code: 3050,
13070
- reason: 'done (permanent)',
13071
- });
15173
+ assert.calledWith(
15174
+ webex.internal.llm.disconnectLLM,
15175
+ {
15176
+ code: 3050,
15177
+ reason: 'done (permanent)',
15178
+ },
15179
+ 'llm-default-session',
15180
+ meeting.id
15181
+ );
13072
15182
  assert.notCalled(webex.internal.llm.registerAndConnect);
13073
15183
  assert.equal(result, undefined);
13074
15184
  assert.isFalse(
@@ -13084,6 +15194,7 @@ describe('plugin-meetings', () => {
13084
15194
  webex.internal.llm.disconnectLLM.rejects(disconnectError);
13085
15195
 
13086
15196
  meeting.locusInfo = {
15197
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
13087
15198
  url: 'a different url',
13088
15199
  info: {datachannelUrl: 'a datachannel url'},
13089
15200
  self: {},
@@ -13115,6 +15226,7 @@ describe('plugin-meetings', () => {
13115
15226
  it('still need connect main session data channel when PS started', async () => {
13116
15227
  meeting.joinedWith = {state: 'JOINED'};
13117
15228
  meeting.locusInfo = {
15229
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
13118
15230
  url: 'a url',
13119
15231
  info: {
13120
15232
  datachannelUrl: 'a datachannel url',
@@ -13135,11 +15247,14 @@ describe('plugin-meetings', () => {
13135
15247
  it('passes dataChannelToken from LLM to registerAndConnect', async () => {
13136
15248
  meeting.joinedWith = {state: 'JOINED'};
13137
15249
  meeting.locusInfo = {
15250
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
13138
15251
  url: 'a url',
13139
15252
  info: {datachannelUrl: 'a datachannel url'},
13140
15253
  };
13141
15254
 
13142
- webex.internal.llm.getDatachannelToken.withArgs('llm-default-session').returns('token-123');
15255
+ webex.internal.llm.getDatachannelToken
15256
+ .withArgs('llm-default-session', meeting.id)
15257
+ .returns('token-123');
13143
15258
 
13144
15259
  await meeting.updateLLMConnection();
13145
15260
 
@@ -13154,6 +15269,7 @@ describe('plugin-meetings', () => {
13154
15269
  it('passes undefined token when LLM has no token stored', async () => {
13155
15270
  meeting.joinedWith = {state: 'JOINED'};
13156
15271
  meeting.locusInfo = {
15272
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
13157
15273
  url: 'a url',
13158
15274
  info: {datachannelUrl: 'a datachannel url'},
13159
15275
  };
@@ -13175,6 +15291,7 @@ describe('plugin-meetings', () => {
13175
15291
  it('does not pass token when data channel with jwt token is disabled', async () => {
13176
15292
  meeting.joinedWith = {state: 'JOINED'};
13177
15293
  meeting.locusInfo = {
15294
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
13178
15295
  url: 'a url',
13179
15296
  info: {datachannelUrl: 'a datachannel url'},
13180
15297
  };
@@ -13193,6 +15310,209 @@ describe('plugin-meetings', () => {
13193
15310
  assert.notCalled(webex.internal.llm.setDatachannelToken);
13194
15311
  });
13195
15312
 
15313
+ describe('ownership tag', () => {
15314
+ beforeEach(() => {
15315
+ // Make the owner stub dynamic so setOwnerMeetingId() writes
15316
+ // propagate back to getOwnerMeetingId() reads. This mirrors the
15317
+ // real LLM singleton behavior so the finally-block release in
15318
+ // cleanupLLMConneciton is reflected in subsequent reads.
15319
+ webex.internal.llm.getOwnerMeetingId = sinon.stub().returns(undefined);
15320
+ webex.internal.llm.setOwnerMeetingId = sinon.stub().callsFake((id) => {
15321
+ webex.internal.llm.getOwnerMeetingId.returns(id);
15322
+ });
15323
+ });
15324
+
15325
+ it('skips disconnect and reconnect when LLM is connected and owned by another meeting (regardless of URL)', async () => {
15326
+ meeting.joinedWith = {state: 'JOINED'};
15327
+ webex.internal.llm.isConnected.returns(true);
15328
+ webex.internal.llm.getOwnerMeetingId.returns('some-other-meeting-id');
15329
+ // Locus/datachannel URL mismatch is the *normal* case when
15330
+ // another meeting owns the live socket -- each meeting has its
15331
+ // own locus URL. URL mismatch must NOT trigger a reclaim,
15332
+ // because doing so would tear down the owning meeting's healthy
15333
+ // LLM socket and break its data channel.
15334
+ webex.internal.llm.getLocusUrl.returns('owner-locus-url');
15335
+ webex.internal.llm.getDatachannelUrl.returns('owner-dc-url');
15336
+ meeting.locusInfo = {
15337
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
15338
+ url: 'a different url',
15339
+ info: {datachannelUrl: 'a different datachannel url'},
15340
+ self: {},
15341
+ };
15342
+
15343
+ const result = await meeting.updateLLMConnection();
15344
+
15345
+ assert.equal(result, undefined);
15346
+ assert.notCalled(webex.internal.llm.disconnectLLM);
15347
+ assert.notCalled(webex.internal.llm.registerAndConnect);
15348
+ assert.notCalled(webex.internal.llm.setOwnerMeetingId);
15349
+ assert.notCalled(meeting.startLLMHealthCheckTimer);
15350
+ });
15351
+
15352
+ it('clears stale owner tag in cleanup finally block even when disconnectLLM rejects', async () => {
15353
+ meeting.joinedWith = {state: 'JOINED'};
15354
+ webex.internal.llm.isConnected.returns(true);
15355
+ webex.internal.llm.getOwnerMeetingId.returns(meeting.id);
15356
+ webex.internal.llm.getLocusUrl.returns('a url');
15357
+ webex.internal.llm.getDatachannelUrl.returns('a datachannel url');
15358
+ webex.internal.llm.disconnectLLM.rejects(new Error('disconnect failed'));
15359
+ meeting.locusInfo = {
15360
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
15361
+ url: 'a different url',
15362
+ info: {datachannelUrl: 'a datachannel url'},
15363
+ self: {},
15364
+ };
15365
+
15366
+ try {
15367
+ await meeting.updateLLMConnection();
15368
+ } catch (e) {
15369
+ /* updateLLMConnection may reject when cleanup throws */
15370
+ }
15371
+
15372
+ // The owner-eligible finally branch must release the tag so a
15373
+ // subsequent reconnect attempt from any meeting is not blocked.
15374
+ assert.calledWith(webex.internal.llm.setOwnerMeetingId, undefined);
15375
+ });
15376
+
15377
+ it('does not clear owner tag when ownership changes during cleanup disconnect await', async () => {
15378
+ meeting.joinedWith = {state: 'JOINED'};
15379
+ webex.internal.llm.isConnected.returns(true);
15380
+ webex.internal.llm.getOwnerMeetingId.returns(meeting.id);
15381
+ webex.internal.llm.getLocusUrl.returns('a url');
15382
+ webex.internal.llm.getDatachannelUrl.returns('a datachannel url');
15383
+ webex.internal.llm.disconnectLLM.callsFake(async () => {
15384
+ webex.internal.llm.getOwnerMeetingId.returns('new-owner-id');
15385
+ throw new Error('disconnect failed');
15386
+ });
15387
+ meeting.locusInfo = {
15388
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
15389
+ url: 'a different url',
15390
+ info: {datachannelUrl: 'a datachannel url'},
15391
+ self: {},
15392
+ };
15393
+
15394
+ try {
15395
+ await meeting.updateLLMConnection();
15396
+ } catch (e) {
15397
+ /* updateLLMConnection may reject when cleanup throws */
15398
+ }
15399
+
15400
+ assert.notCalled(webex.internal.llm.setOwnerMeetingId);
15401
+ assert.equal(webex.internal.llm.getOwnerMeetingId(), 'new-owner-id');
15402
+ });
15403
+
15404
+ it('proceeds normally when LLM is connected and owned by this meeting with URL change', async () => {
15405
+ meeting.joinedWith = {state: 'JOINED'};
15406
+ webex.internal.llm.isConnected.returns(true);
15407
+ webex.internal.llm.getOwnerMeetingId.returns(meeting.id);
15408
+ webex.internal.llm.getLocusUrl.returns('a url');
15409
+ webex.internal.llm.getDatachannelUrl.returns('a datachannel url');
15410
+ meeting.locusInfo = {
15411
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
15412
+ url: 'a different url',
15413
+ info: {datachannelUrl: 'a datachannel url'},
15414
+ self: {},
15415
+ };
15416
+
15417
+ await meeting.updateLLMConnection();
15418
+
15419
+ assert.calledOnceWithExactly(
15420
+ webex.internal.llm.disconnectLLM,
15421
+ {
15422
+ code: 3050,
15423
+ reason: 'done (permanent)',
15424
+ },
15425
+ 'llm-default-session',
15426
+ meeting.id
15427
+ );
15428
+ assert.calledWithExactly(
15429
+ webex.internal.llm.registerAndConnect,
15430
+ 'a different url',
15431
+ 'a datachannel url',
15432
+ undefined
15433
+ );
15434
+ // setOwnerMeetingId is called twice: first with undefined in
15435
+ // cleanupLLMConneciton's finally block (so a failed disconnect
15436
+ // cannot leave a stale owner), then with this meeting's id
15437
+ // after registerAndConnect resolves.
15438
+ assert.calledTwice(webex.internal.llm.setOwnerMeetingId);
15439
+ assert.calledWith(webex.internal.llm.setOwnerMeetingId.firstCall, undefined);
15440
+ assert.calledWith(webex.internal.llm.setOwnerMeetingId.lastCall, meeting.id);
15441
+ });
15442
+
15443
+ it('claims ownership after successful registerAndConnect on initial connect', async () => {
15444
+ meeting.joinedWith = {state: 'JOINED'};
15445
+ webex.internal.llm.isConnected.returns(false);
15446
+ webex.internal.llm.getOwnerMeetingId.returns(undefined);
15447
+ meeting.locusInfo = {
15448
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
15449
+ url: 'a url',
15450
+ info: {datachannelUrl: 'a datachannel url'},
15451
+ };
15452
+
15453
+ await meeting.updateLLMConnection();
15454
+
15455
+ assert.calledOnce(webex.internal.llm.registerAndConnect);
15456
+ assert.calledOnceWithExactly(
15457
+ webex.internal.llm.setRefreshHandler,
15458
+ sinon.match.func,
15459
+ 'llm-default-session',
15460
+ meeting.id
15461
+ );
15462
+ assert.calledOnceWithExactly(webex.internal.llm.setOwnerMeetingId, meeting.id);
15463
+ });
15464
+
15465
+ it('proceeds to connect when LLM is not connected even if another ownerId lingers', async () => {
15466
+ // Defensive path: if the LLM reports not-connected but an old
15467
+ // ownerId is still present (e.g. race before a successful
15468
+ // connections.delete), this meeting can still claim a fresh
15469
+ // connection.
15470
+ meeting.joinedWith = {state: 'JOINED'};
15471
+ webex.internal.llm.isConnected.returns(false);
15472
+ webex.internal.llm.getOwnerMeetingId.returns('stale-owner-id');
15473
+ webex.internal.llm.getDatachannelToken.onFirstCall().returns(undefined);
15474
+ webex.internal.llm.getDatachannelToken.onSecondCall().returns('recovered-token');
15475
+ meeting.locusInfo = {
15476
+ syncAllHashTreeDatasets: sinon.stub().resolves(),
15477
+ url: 'a url',
15478
+ info: {datachannelUrl: 'a datachannel url'},
15479
+ };
15480
+
15481
+ await meeting.updateLLMConnection();
15482
+
15483
+ assert.calledTwice(webex.internal.llm.getDatachannelToken);
15484
+ assert.calledWithExactly(
15485
+ webex.internal.llm.getDatachannelToken.firstCall,
15486
+ 'llm-default-session',
15487
+ meeting.id
15488
+ );
15489
+ assert.calledWithExactly(
15490
+ webex.internal.llm.getDatachannelToken.secondCall,
15491
+ 'llm-default-session'
15492
+ );
15493
+ assert.calledOnceWithExactly(
15494
+ webex.internal.llm.registerAndConnect,
15495
+ 'a url',
15496
+ 'a datachannel url',
15497
+ 'recovered-token'
15498
+ );
15499
+ assert.calledWithExactly(
15500
+ webex.internal.llm.setRefreshHandler.firstCall,
15501
+ sinon.match.func,
15502
+ 'llm-default-session',
15503
+ undefined
15504
+ );
15505
+ assert.calledTwice(webex.internal.llm.setRefreshHandler);
15506
+ assert.calledWithExactly(
15507
+ webex.internal.llm.setRefreshHandler.secondCall,
15508
+ sinon.match.func,
15509
+ 'llm-default-session',
15510
+ meeting.id
15511
+ );
15512
+ assert.calledOnceWithExactly(webex.internal.llm.setOwnerMeetingId, meeting.id);
15513
+ });
15514
+ });
15515
+
13196
15516
  describe('#clearMeetingData', () => {
13197
15517
  beforeEach(() => {
13198
15518
  webex.internal.llm.isConnected = sinon.stub().returns(true);
@@ -13208,10 +15528,15 @@ describe('plugin-meetings', () => {
13208
15528
  it('disconnects llm and removes online and relay listeners during meeting data cleanup', async () => {
13209
15529
  await meeting.clearMeetingData();
13210
15530
 
13211
- assert.calledOnceWithExactly(webex.internal.llm.disconnectLLM, {
13212
- code: 3050,
13213
- reason: 'done (permanent)',
13214
- });
15531
+ assert.calledOnceWithExactly(
15532
+ webex.internal.llm.disconnectLLM,
15533
+ {
15534
+ code: 3050,
15535
+ reason: 'done (permanent)',
15536
+ },
15537
+ 'llm-default-session',
15538
+ meeting.id
15539
+ );
13215
15540
  assert.calledWithExactly(webex.internal.llm.off, 'online', meeting.handleLLMOnline);
13216
15541
  assert.calledWithExactly(
13217
15542
  webex.internal.llm.off,
@@ -13224,10 +15549,13 @@ describe('plugin-meetings', () => {
13224
15549
  meeting.processLocusLLMEvent
13225
15550
  );
13226
15551
  assert.calledOnce(meeting.clearLLMHealthCheckTimer);
13227
- assert.calledOnce(meeting.stopTranscription);
13228
- assert.isUndefined(meeting.transcription);
13229
15552
  assert.calledOnce(meeting.clearDataChannelToken);
13230
- assert.calledOnce(meeting.annotation.deregisterEvents);
15553
+ // stopTranscription and annotation.deregisterEvents are not
15554
+ // called here: they run in stopListeningForMeetingEvents()
15555
+ // before /leave to avoid double-emitting
15556
+ // MEETING_STOPPED_RECEIVING_TRANSCRIPTION.
15557
+ assert.notCalled(meeting.stopTranscription);
15558
+ assert.notCalled(meeting.annotation.deregisterEvents);
13231
15559
  });
13232
15560
  it('continues cleanup when disconnectLLM fails during meeting data cleanup', async () => {
13233
15561
  webex.internal.llm.disconnectLLM.rejects(new Error('disconnect failed'));
@@ -13246,19 +15574,234 @@ describe('plugin-meetings', () => {
13246
15574
  meeting.processLocusLLMEvent
13247
15575
  );
13248
15576
  assert.calledOnce(meeting.clearLLMHealthCheckTimer);
13249
- assert.calledOnce(meeting.stopTranscription);
13250
- assert.isUndefined(meeting.transcription);
13251
15577
  assert.calledOnce(meeting.clearDataChannelToken);
13252
- assert.calledOnce(meeting.annotation.deregisterEvents);
15578
+ assert.notCalled(meeting.stopTranscription);
15579
+ assert.notCalled(meeting.annotation.deregisterEvents);
13253
15580
  });
13254
- it('always calls stopTranscription even when transcription is undefined', async () => {
13255
- meeting.transcription = undefined;
13256
15581
 
13257
- await meeting.clearMeetingData();
15582
+ describe('ownership tag', () => {
15583
+ beforeEach(() => {
15584
+ webex.internal.llm.getOwnerMeetingId = sinon.stub();
15585
+ });
13258
15586
 
13259
- assert.calledOnce(meeting.stopTranscription);
13260
- assert.isUndefined(meeting.transcription);
13261
- assert.calledOnce(meeting.clearDataChannelToken);
15587
+ it('skips disconnectLLM but still removes this meeting listeners when another meeting owns the LLM', async () => {
15588
+ webex.internal.llm.getOwnerMeetingId.returns('some-other-meeting-id');
15589
+
15590
+ await meeting.clearMeetingData();
15591
+
15592
+ assert.notCalled(webex.internal.llm.disconnectLLM);
15593
+ // clearDataChannelToken is always delegated; llm enforces
15594
+ // ownership and no-ops for non-owners internally.
15595
+ assert.calledOnce(meeting.clearDataChannelToken);
15596
+ // Listeners owned by *this* Meeting instance must still be
15597
+ // removed so a leaving subordinate meeting stops receiving
15598
+ // relay/locus events from the shared singleton.
15599
+ assert.calledWithExactly(webex.internal.llm.off, 'online', meeting.handleLLMOnline);
15600
+ assert.calledWithExactly(
15601
+ webex.internal.llm.off,
15602
+ 'event:relay.event',
15603
+ meeting.processRelayEvent
15604
+ );
15605
+ assert.calledWithExactly(
15606
+ webex.internal.llm.off,
15607
+ 'event:locus.state_message',
15608
+ meeting.processLocusLLMEvent
15609
+ );
15610
+ assert.calledOnce(meeting.clearLLMHealthCheckTimer);
15611
+ });
15612
+
15613
+ it('calls disconnectLLM and clears data channel token when this meeting is the owner', async () => {
15614
+ webex.internal.llm.getOwnerMeetingId.returns(meeting.id);
15615
+
15616
+ await meeting.clearMeetingData();
15617
+
15618
+ assert.calledOnceWithExactly(
15619
+ webex.internal.llm.disconnectLLM,
15620
+ {
15621
+ code: 3050,
15622
+ reason: 'done (permanent)',
15623
+ },
15624
+ 'llm-default-session',
15625
+ meeting.id
15626
+ );
15627
+ assert.calledOnce(meeting.clearDataChannelToken);
15628
+ });
15629
+
15630
+ it('calls disconnectLLM and clears data channel token when no owner is recorded (first-claim / legacy)', async () => {
15631
+ webex.internal.llm.getOwnerMeetingId.returns(undefined);
15632
+
15633
+ await meeting.clearMeetingData();
15634
+
15635
+ assert.calledOnceWithExactly(
15636
+ webex.internal.llm.disconnectLLM,
15637
+ {
15638
+ code: 3050,
15639
+ reason: 'done (permanent)',
15640
+ },
15641
+ 'llm-default-session',
15642
+ meeting.id
15643
+ );
15644
+ assert.calledOnce(meeting.clearDataChannelToken);
15645
+ });
15646
+ });
15647
+ });
15648
+ });
15649
+
15650
+ describe('#processLocusLLMEvent', () => {
15651
+ it('routes the LLM event through locusInfo.parse and records the LLM message with the top-level tracking id', () => {
15652
+ const event = {
15653
+ data: {
15654
+ eventType: 'locus.state_message',
15655
+ dataSets: [],
15656
+ },
15657
+ trackingId: 'envelope-tracking-id',
15658
+ };
15659
+
15660
+ meeting.locusInfo.parse = sinon.stub();
15661
+ meeting.onLocusSyncLlmMessage = sinon.stub();
15662
+
15663
+ meeting.processLocusLLMEvent(event);
15664
+
15665
+ // The LLM message is parsed without the tracking id - completion is driven from the
15666
+ // meeting's LLM handler, not threaded through locusInfo.
15667
+ assert.calledOnceWithExactly(meeting.locusInfo.parse, meeting, event.data);
15668
+ // Only the client whose /sync request tracking id matches the tracking id echoed back on
15669
+ // the top-level LLM event envelope records the LLM arrival; onLocusSyncLlmMessage is a
15670
+ // no-op otherwise.
15671
+ assert.calledOnceWithExactly(meeting.onLocusSyncLlmMessage, meeting.id, event.trackingId);
15672
+ });
15673
+
15674
+ it('does not attempt sync completion when the tracking id is missing', () => {
15675
+ const event = {
15676
+ data: {
15677
+ eventType: 'locus.state_message',
15678
+ dataSets: [],
15679
+ },
15680
+ };
15681
+
15682
+ meeting.locusInfo.parse = sinon.stub();
15683
+ meeting.onLocusSyncLlmMessage = sinon.stub();
15684
+
15685
+ meeting.processLocusLLMEvent(event);
15686
+
15687
+ assert.calledOnceWithExactly(meeting.locusInfo.parse, meeting, event.data);
15688
+ assert.notCalled(meeting.onLocusSyncLlmMessage);
15689
+ });
15690
+ });
15691
+
15692
+ describe('#onLocusSyncLlmMessage', () => {
15693
+ it('records the LLM arrival time and then tries to complete the metric', () => {
15694
+ webex.internal.newMetrics.callDiagnosticLatencies.recordLocusSyncMessageReceived =
15695
+ sinon.stub();
15696
+ meeting.tryCompleteLocusSyncLatency = sinon.stub();
15697
+
15698
+ meeting.onLocusSyncLlmMessage('meeting-1', 'sync-tracking-id');
15699
+
15700
+ assert.calledOnceWithExactly(
15701
+ webex.internal.newMetrics.callDiagnosticLatencies.recordLocusSyncMessageReceived,
15702
+ 'meeting-1',
15703
+ 'sync-tracking-id'
15704
+ );
15705
+ assert.calledOnceWithExactly(
15706
+ meeting.tryCompleteLocusSyncLatency,
15707
+ 'meeting-1',
15708
+ 'sync-tracking-id'
15709
+ );
15710
+ // the arrival time must be recorded before completion is attempted
15711
+ assert.callOrder(
15712
+ webex.internal.newMetrics.callDiagnosticLatencies.recordLocusSyncMessageReceived,
15713
+ meeting.tryCompleteLocusSyncLatency
15714
+ );
15715
+ });
15716
+ });
15717
+
15718
+ describe('#tryCompleteLocusSyncLatency', () => {
15719
+ beforeEach(() => {
15720
+ meeting.emitLocusSyncCompleteMetric = sinon.stub();
15721
+ });
15722
+
15723
+ it('emits the metric when both milestones are in (completion succeeds)', () => {
15724
+ const completed = {dataSet: 'main', syncLatency: {totalTime: 50}};
15725
+ webex.internal.newMetrics.callDiagnosticLatencies.completeLocusSyncLatency = sinon
15726
+ .stub()
15727
+ .returns(completed);
15728
+
15729
+ meeting.tryCompleteLocusSyncLatency('meeting-1', 'sync-tracking-id');
15730
+
15731
+ assert.calledOnceWithExactly(
15732
+ webex.internal.newMetrics.callDiagnosticLatencies.completeLocusSyncLatency,
15733
+ 'meeting-1',
15734
+ 'sync-tracking-id'
15735
+ );
15736
+ assert.calledOnceWithExactly(meeting.emitLocusSyncCompleteMetric, 'meeting-1', completed);
15737
+ });
15738
+
15739
+ it('does not emit when completion returns undefined (only one milestone is in)', () => {
15740
+ webex.internal.newMetrics.callDiagnosticLatencies.completeLocusSyncLatency = sinon
15741
+ .stub()
15742
+ .returns(undefined);
15743
+
15744
+ meeting.tryCompleteLocusSyncLatency('meeting-1', 'sync-tracking-id');
15745
+
15746
+ assert.calledOnceWithExactly(
15747
+ webex.internal.newMetrics.callDiagnosticLatencies.completeLocusSyncLatency,
15748
+ 'meeting-1',
15749
+ 'sync-tracking-id'
15750
+ );
15751
+ assert.notCalled(meeting.emitLocusSyncCompleteMetric);
15752
+ });
15753
+ });
15754
+
15755
+ describe('#emitLocusSyncCompleteMetric', () => {
15756
+ it('submits client.locus.sync.complete with the llm websocket url and sync latency', () => {
15757
+ webex.internal.newMetrics.submitClientEvent.resetHistory();
15758
+ webex.internal.llm.getWebSocketUrl = sinon.stub().returns('wss://llm-websocket-url');
15759
+
15760
+ meeting.emitLocusSyncCompleteMetric('meeting-1', {
15761
+ dataSet: 'main',
15762
+ syncLatency: {totalTime: 50},
15763
+ });
15764
+
15765
+ assert.calledOnceWithExactly(webex.internal.newMetrics.submitClientEvent, {
15766
+ name: 'client.locus.sync.complete',
15767
+ payload: {
15768
+ identifiers: {
15769
+ llmWebsocketUrl: 'wss://llm-websocket-url',
15770
+ },
15771
+ llmInfo: {
15772
+ dataSet: 'main',
15773
+ },
15774
+ syncLatency: {totalTime: 50},
15775
+ },
15776
+ options: {
15777
+ meetingId: 'meeting-1',
15778
+ },
15779
+ });
15780
+ });
15781
+
15782
+ it('submits with an undefined llm websocket url when it is unavailable', () => {
15783
+ webex.internal.newMetrics.submitClientEvent.resetHistory();
15784
+ webex.internal.llm.getWebSocketUrl = sinon.stub().returns(undefined);
15785
+
15786
+ meeting.emitLocusSyncCompleteMetric('meeting-1', {
15787
+ dataSet: 'main',
15788
+ syncLatency: {totalTime: 50},
15789
+ });
15790
+
15791
+ assert.calledOnceWithExactly(webex.internal.newMetrics.submitClientEvent, {
15792
+ name: 'client.locus.sync.complete',
15793
+ payload: {
15794
+ identifiers: {
15795
+ llmWebsocketUrl: undefined,
15796
+ },
15797
+ llmInfo: {
15798
+ dataSet: 'main',
15799
+ },
15800
+ syncLatency: {totalTime: 50},
15801
+ },
15802
+ options: {
15803
+ meetingId: 'meeting-1',
15804
+ },
13262
15805
  });
13263
15806
  });
13264
15807
  });
@@ -13298,6 +15841,71 @@ describe('plugin-meetings', () => {
13298
15841
  });
13299
15842
  });
13300
15843
 
15844
+ describe('#waitForSelfUrlChange', () => {
15845
+ let waitForSelfUrlChange;
15846
+ let locusMediaRequestStub;
15847
+
15848
+ beforeEach(async () => {
15849
+ locusMediaRequestStub = sinon
15850
+ .stub(LocusMediaRequestModule, 'LocusMediaRequest')
15851
+ .returns({id: 'fake LocusMediaRequest instance'});
15852
+
15853
+ meeting.setLocus = sinon.stub().returns(true);
15854
+ webex.meetings.registered = true;
15855
+ sandbox.stub(MeetingUtil, 'joinMeeting').returns(Promise.resolve('JOIN_RESULT'));
15856
+ sinon.stub(meeting, 'updateLLMConnection').returns(Promise.resolve());
15857
+
15858
+ await meeting.join();
15859
+
15860
+ waitForSelfUrlChange = locusMediaRequestStub.firstCall.args[0].waitForSelfUrlChange;
15861
+ });
15862
+
15863
+ it('should resolve immediately when joinWithMediaRetryInfo.retryCount > 0', async () => {
15864
+ meeting.joinWithMediaRetryInfo = {retryCount: 1, prevJoinResponse: undefined};
15865
+
15866
+ const result = waitForSelfUrlChange();
15867
+
15868
+ assert.instanceOf(result, Promise);
15869
+ await result;
15870
+ });
15871
+
15872
+ it('should not resolve before the timeout when retryCount is 0', async () => {
15873
+ meeting.joinWithMediaRetryInfo = {retryCount: 0, prevJoinResponse: undefined};
15874
+
15875
+ let resolved = false;
15876
+ waitForSelfUrlChange().then(() => {
15877
+ resolved = true;
15878
+ });
15879
+
15880
+ await testUtils.flushPromises();
15881
+ assert.isFalse(resolved);
15882
+ });
15883
+
15884
+ it('should resolve after the 5s timeout when retryCount is 0', async () => {
15885
+ meeting.joinWithMediaRetryInfo = {retryCount: 0, prevJoinResponse: undefined};
15886
+
15887
+ let resolved = false;
15888
+ const promise = waitForSelfUrlChange();
15889
+ promise.then(() => {
15890
+ resolved = true;
15891
+ });
15892
+
15893
+ fakeClock.tick(5000);
15894
+ await promise;
15895
+
15896
+ assert.isTrue(resolved);
15897
+ });
15898
+
15899
+ it('should return the same promise when called multiple times', () => {
15900
+ meeting.joinWithMediaRetryInfo = {retryCount: 0, prevJoinResponse: undefined};
15901
+
15902
+ const firstPromise = waitForSelfUrlChange();
15903
+ const secondPromise = waitForSelfUrlChange();
15904
+
15905
+ assert.equal(firstPromise, secondPromise);
15906
+ });
15907
+ });
15908
+
13301
15909
  describe('preferred video device', () => {
13302
15910
  describe('#getVideoDeviceId', () => {
13303
15911
  it('returns the preferred video device', () => {
@@ -15012,16 +17620,25 @@ describe('plugin-meetings', () => {
15012
17620
  assert.notCalled(meeting.meetingRequest.sendReaction);
15013
17621
  });
15014
17622
 
15015
- it('should fail sending a reaction if reactionType is invalid ', async () => {
17623
+ it('should send a custom reaction type not in the known list', async () => {
15016
17624
  meeting.locusInfo.controls = {reactions: {reactionChannelUrl: 'Fake URL'}};
15017
17625
 
15018
- await assert.isRejected(
15019
- meeting.sendReaction('invalid_reaction', 'light'),
15020
- Error,
15021
- 'invalid_reaction is not a valid reaction.'
15022
- );
17626
+ const reactionPromise = meeting.sendReaction('custom_reaction', 'light');
15023
17627
 
15024
- assert.notCalled(meeting.meetingRequest.sendReaction);
17628
+ assert.exists(reactionPromise.then);
17629
+ await reactionPromise;
17630
+ assert.calledOnceWithExactly(meeting.meetingRequest.sendReaction, {
17631
+ reactionChannelUrl: 'Fake URL',
17632
+ reaction: {
17633
+ type: 'custom_reaction',
17634
+ tone: {
17635
+ type: 'light_skin_tone',
17636
+ codepoints: '1F3FB',
17637
+ shortcodes: ':skin-tone-2:',
17638
+ },
17639
+ },
17640
+ participantId: meeting.members.selfId,
17641
+ });
15025
17642
  });
15026
17643
 
15027
17644
  it('should send a reaction with default skin tone if provided skinToneType is invalid ', async () => {