fix(consult): changes for EPDN consult transfer#4948
Conversation
Changeset
|
Changeset
|
|
|
||
| const wasConsultedTask = Boolean(task?.data?.isConsulted); | ||
| const computeWrapUpRequired = () => { | ||
| const pending = message.data.agentsPendingWrapUp; |
There was a problem hiding this comment.
Inline note: this transfer-specific wrap-up derivation prioritizes agentsPendingWrapUp and participant isWrapUp for the current agent before fallback heuristics. That prevents Agent-2 from staying on active controls when backend transfer payloads don’t set wrapUpRequired consistently.
|
|
||
| const participantWrapUp = taskData.interaction?.participants?.[selfId]?.isWrapUp === true; | ||
| if (participantWrapUp) return true; | ||
| const participants = taskData.interaction?.participants; |
There was a problem hiding this comment.
Inline note: shouldForceWrapUpForCurrentAgent() intentionally treats missing/self-left participant entries as wrap-up signals. In transfer races this makes UI state deterministic (WRAPPING_UP) even when machine state or payload flags arrive out of order.
| }, | ||
| // Wrapped-up can arrive while machine still reflects CONNECTED/CONSULTING due event ordering. | ||
| // Accept it globally so completion cleanup always runs and task is removed from collection. | ||
| [TaskEvent.WRAPUP_COMPLETE]: { |
There was a problem hiding this comment.
Inline note: this root-level WRAPUP_COMPLETE transition is added to handle event-ordering gaps where wrapped-up arrives before state reaches WRAPPING_UP; it guarantees completion/cleanup instead of leaving stale task cards.
| // Stale relationshipType=consult often remains after consult transfer to a new primary owner. | ||
| // Only treat it as an active consult session for UI when the interaction is consulting or this | ||
| // task is the secondary (EP-DN) consult leg — not a warm-transferred main call. | ||
| const consultRelationshipAffectsConsultingUi = Boolean( |
There was a problem hiding this comment.
Inline note: consultRelationshipAffectsConsultingUi narrows stale relationshipType=consult handling so only true consult contexts get consult controls. This avoids showing consult-only UI to a newly transferred primary owner.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 64400163b2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const normalizedPayload: TaskData = { | ||
| ...taskData, | ||
| isConsulted: this.resolveIsConsultedTaskFlag(taskData), | ||
| }; |
There was a problem hiding this comment.
Preserve consulted flag when updates omit isConsulted
updateTaskData() now unconditionally rewrites isConsulted from resolveIsConsultedTaskFlag(taskData), which returns false whenever incoming payloads omit isConsulted (common for non-consult-specific updates like recording/contact refresh events). For an already-consulted task, this clears consulted status and enables full main-call controls incorrectly until another event restores it, changing transfer/end behavior for the consulted agent.
Useful? React with 👍 / 👎.
| @@ -236,6 +250,26 @@ export const isSecondaryEpDnAgent = (interaction: Interaction): boolean => { | |||
| return interaction.mediaType === 'telephony' && isSecondaryAgent(interaction); | |||
There was a problem hiding this comment.
Inline note: owner-aware consulted detection is critical after consult transfer. Secondary EP-DN shape can still be present, but if interaction.owner is self, this task is now primary and must not remain in consulted-only UI/state handling.
| service.send({type: TaskEvent.WRAPUP_COMPLETE}); | ||
| expect(service.getSnapshot().value).toBe(TaskState.COMPLETED); | ||
| }); | ||
|
|
There was a problem hiding this comment.
Inline note: this test locks the transfer regression: if wrap-up completion arrives before explicit WRAPPING_UP, machine must still reach COMPLETED so cleanup/removal happens deterministically.
| const state = this.getStateMachineSnapshot(); | ||
| // Validate consult is allowed (use effective state when machine lags IDLE after transfer) | ||
| const effectiveState = this.getEffectiveVoiceTaskStateForOperation(); | ||
| const canConsult = |
There was a problem hiding this comment.
Inline note: consult validation here intentionally uses effective state (not raw snapshot) to handle post-transfer ordering where machine can temporarily lag at IDLE while payload already reflects an active voice leg.
| data: wrapupPayload, | ||
| }); | ||
|
|
||
| // Some transfer flows can miss or delay AGENT_WRAPPEDUP; complete locally on API success. |
There was a problem hiding this comment.
Inline note: local WRAPUP_COMPLETE dispatch on wrapup API success is a reliability guard. It prevents stale wrapup dropdown/task cards when websocket AGENT_WRAPPEDUP is delayed or dropped.
COMPLETES #N/A (EP-DN consult transfer defect fix)
This pull request addresses
EP-DN consult transfer regressions where task state and UI controls could drift after transfer-related event ordering differences. In affected flows, agents could see incorrect controls (consult/transfer/end visibility), incorrect consulted-role inference, or miss wrap-up progression after transfer.
by making the following changes
wrapUpRequiredandisConsultedinference), including owner-aware EP-DN consulted detection.TRANSFER_SUCCESSrouting andWRAPUP_COMPLETEcompletion handling).Change Type
The following scenarios were tested
uiControlsComputerconsult-leg visibility and control enablement in EP-DN/partial-payload shapes.TaskStateMachinetransfer/wrap-up lifecycle behavior, includingWRAPUP_COMPLETEprogression.effectiveVoiceTaskStatewrap-up forcing and non-wrap-up fallbacks.TaskUtilsEP-DN consulted-recipient inference.The GAI Coding Policy And Copyright Annotation Best Practices
I certified that
Make sure to have followed the contributing guidelines before submitting.