@webex/contact-center 3.12.0-task-refactor.1 → 3.12.0-task-refactor.3

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.
@@ -109,7 +109,20 @@ const deriveTaskDataUpdates = (context: TaskContext, taskData: TaskData | undefi
109
109
  (p: any) => p?.isConsulted === true && !p?.hasLeft
110
110
  )
111
111
  );
112
- if (hasJoinedConsultee) updates.consultDestinationAgentJoined = true;
112
+ const cpd = taskData.interaction?.callProcessingDetails;
113
+ const backendSaysJoined = cpd?.consultDestinationAgentJoined === 'true';
114
+ if (hasJoinedConsultee || backendSaysJoined)
115
+ updates.consultDestinationAgentJoined = true;
116
+ }
117
+
118
+ if (!context.consultDestinationType && !updates.consultDestinationType) {
119
+ const hasEpDnParticipant = Boolean(
120
+ taskData.interaction.participants &&
121
+ Object.values(taskData.interaction.participants).some(
122
+ (p: any) => p?.pType === 'EP-DN' && !p?.hasLeft
123
+ )
124
+ );
125
+ if (hasEpDnParticipant) updates.consultDestinationType = 'entryPoint' as any;
113
126
  }
114
127
 
115
128
  const effectiveConsultInitiator = updates.consultInitiator ?? context.consultInitiator;
@@ -100,7 +100,15 @@ export const guards = {
100
100
  isInteractionConsulting: ({event}: GuardParams): boolean => {
101
101
  const taskData = getTaskDataFromEvent(event);
102
102
 
103
- return taskData?.interaction?.state === 'consulting';
103
+ if (taskData?.interaction?.state === 'consulting') return true;
104
+
105
+ // EP_DN consulted agent: backend reports state as 'connected' but CPD indicates consult
106
+ const cpd = taskData?.interaction?.callProcessingDetails;
107
+ if (cpd?.relationshipType === 'consult' && taskData?.interaction?.state === 'connected') {
108
+ return true;
109
+ }
110
+
111
+ return false;
104
112
  },
105
113
 
106
114
  isInteractionHeld: ({event}: GuardParams): boolean => {
@@ -112,10 +112,21 @@ function computeVoiceInteractionUIControls(
112
112
  // Note: ownership is used by some controls; keep computations local to those controls
113
113
 
114
114
  // Context flags (set by state machine actions)
115
- const {consultInitiator, consultDestinationAgentJoined, consultCallHeld, consultFromConference} =
116
- context;
115
+ const {
116
+ consultInitiator,
117
+ consultDestinationAgentJoined,
118
+ consultDestinationType,
119
+ consultCallHeld,
120
+ consultFromConference,
121
+ } = context;
117
122
  const {recordingControlsAvailable} = context;
118
123
 
124
+ // EP_DN consults are "ready" as soon as the consult is created (EP accepts routing immediately).
125
+ // Backend sends destinationType as 'EP-DN'; SDK method uses 'entryPoint' — check both.
126
+ const isEpDnConsult =
127
+ consultDestinationType === 'entryPoint' || consultDestinationType === ('EP-DN' as any);
128
+ const isConsultDestinationReady = consultDestinationAgentJoined || isEpDnConsult;
129
+
119
130
  const stateImpliesHeld = state === TaskState.HELD || state === TaskState.RESUME_INITIATING;
120
131
  const stateImpliesConnected =
121
132
  state === TaskState.CONNECTED || state === TaskState.HOLD_INITIATING;
@@ -217,7 +228,9 @@ function computeVoiceInteractionUIControls(
217
228
  // End: varies by state; during consulting only on main leg (consult held)
218
229
  end: (() => {
219
230
  if (!config.isEndTaskEnabled) return DISABLED;
220
- if (hasParallelConsultLeg) return VISIBLE_DISABLED;
231
+ if (hasParallelConsultLeg) {
232
+ return isConnected && isEpDnConsult ? VISIBLE_ENABLED : VISIBLE_DISABLED;
233
+ }
221
234
 
222
235
  if (isConsulting) {
223
236
  if (currentLeg === 'consult' && consultCallHeld) return DISABLED;
@@ -248,7 +261,7 @@ function computeVoiceInteractionUIControls(
248
261
  if (!consultInitiator) return DISABLED;
249
262
  if (consultLegOnHold) return VISIBLE_DISABLED;
250
263
 
251
- return consultDestinationAgentJoined ? VISIBLE_ENABLED : VISIBLE_DISABLED;
264
+ return isConsultDestinationReady ? VISIBLE_ENABLED : VISIBLE_DISABLED;
252
265
  }
253
266
  if (!hasFullControls || inConference) return DISABLED;
254
267
  if (state === TaskState.CONNECTED || state === TaskState.HELD) return VISIBLE_ENABLED;
@@ -316,7 +329,7 @@ function computeVoiceInteractionUIControls(
316
329
  if (!consultInitiator) return DISABLED;
317
330
  if (consultLegOnHold) return VISIBLE_DISABLED;
318
331
 
319
- return consultDestinationAgentJoined && !maxParticipants ? VISIBLE_ENABLED : VISIBLE_DISABLED;
332
+ return isConsultDestinationReady && !maxParticipants ? VISIBLE_ENABLED : VISIBLE_DISABLED;
320
333
  })(),
321
334
 
322
335
  // Wrapup: wrapping up state
@@ -337,7 +350,7 @@ function computeVoiceInteractionUIControls(
337
350
  if (!inConference || !isConsulting) return DISABLED;
338
351
  if (!consultInitiator || isConsulted) return DISABLED;
339
352
 
340
- return consultDestinationAgentJoined ? VISIBLE_ENABLED : VISIBLE_DISABLED;
353
+ return isConsultDestinationReady ? VISIBLE_ENABLED : VISIBLE_DISABLED;
341
354
  })(),
342
355
 
343
356
  // MergeToConference: mirrors conference control, enabled on both legs
@@ -345,7 +358,7 @@ function computeVoiceInteractionUIControls(
345
358
  if (!isConsulting || !consultInitiator) return DISABLED;
346
359
  if (consultLegOnHold) return VISIBLE_DISABLED;
347
360
 
348
- return consultDestinationAgentJoined && !maxParticipants ? VISIBLE_ENABLED : VISIBLE_DISABLED;
361
+ return isConsultDestinationReady && !maxParticipants ? VISIBLE_ENABLED : VISIBLE_DISABLED;
349
362
  })(),
350
363
 
351
364
  // Switch: visible only on the currently active leg
@@ -353,11 +366,11 @@ function computeVoiceInteractionUIControls(
353
366
  if (currentLeg === 'consult') {
354
367
  if (!isConsulting || !consultInitiator || consultCallHeld) return DISABLED;
355
368
 
356
- return consultDestinationAgentJoined ? VISIBLE_ENABLED : VISIBLE_DISABLED;
369
+ return isConsultDestinationReady ? VISIBLE_ENABLED : VISIBLE_DISABLED;
357
370
  }
358
371
 
359
372
  if (hasParallelConsultLeg && state === TaskState.CONNECTED) {
360
- return consultDestinationAgentJoined ? VISIBLE_ENABLED : VISIBLE_DISABLED;
373
+ return isConsultDestinationReady ? VISIBLE_ENABLED : VISIBLE_DISABLED;
361
374
  }
362
375
 
363
376
  return DISABLED;
@@ -714,6 +714,7 @@ describe('AgentConfigService', () => {
714
714
  const mockOrgInfo = {
715
715
  tenantId: 'tenant123',
716
716
  timezone: 'GMT',
717
+ environment: 'produs1',
717
718
  };
718
719
 
719
720
  const mockSiteInfo = {