fix(task-refactor): add explicit on/off methods to ITask interface#4812
fix(task-refactor): add explicit on/off methods to ITask interface#4812akulakum wants to merge 6 commits intowebex:task-refactorfrom
Conversation
| * Extends EventEmitter to support event-driven task updates | ||
| */ | ||
| export interface ITask extends EventEmitter { | ||
| /** |
There was a problem hiding this comment.
Why do we need this change ? If this was a problem then how did we have widgets working till now ?
…/webex-js-sdk into ADD_MISSING_EVENT_EMITTER_TYPES
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cdcdbab86e
ℹ️ 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".
| guard: ({context}) => context.consultInitiator === true && context.transferRequested !== true, | ||
| target: TaskState.HELD, | ||
| actions: ['logStateTransition', 'updateTaskData', 'clearConsultState', 'clearPendingEndConsult'], |
There was a problem hiding this comment.
Keep CONSULT_FAILED from leaving active consult state
The new CONSULT_FAILED transition in CONSULTING moves initiators directly to HELD and clears pending retry state. Voice.endConsult() now emits CONSULT_FAILED on API errors, so a transient failure (timeout/5xx) can push the machine out of CONSULTING even though the consult leg is still active server-side. This desynchronizes UI/state (consult controls disappear, retry-on-CONSULTING_ACTIVE is bypassed) and can leave the task in the wrong lifecycle state until another backend transition corrects it.
Useful? React with 👍 / 👎.
| // Dispatch TRANSFER event to state machine to set transferRequested flag | ||
| // This tracks that a transfer is in progress, used for dial number consult transfers | ||
| // where backend may send CONSULT_END before TRANSFER_SUCCESS | ||
| this.sendStateMachineEvent({type: TaskEvent.TRANSFER}); |
There was a problem hiding this comment.
Clear transferRequested when transfer API call fails
This sets transferRequested before the transfer API call completes, but the new catch path does not clear it when the request fails locally (e.g., network error or immediate HTTP rejection with no websocket TRANSFER_FAILED). That leaves transferRequested=true in context and later guards like shouldWrapUpOrIsInitiator can misclassify unrelated TRANSFER_SUCCESS events as locally initiated, causing incorrect wrapup/transition behavior.
Useful? React with 👍 / 👎.
COMPLETES #https://jira-eng-sjc12.cisco.com/jira/browse/CAI-7779
This pull request addresses
As part of the task-refactor, the SDK's ITask interface extends Node's EventEmitter for on()/off() methods, but consumers like CC Widgets whose tsconfig.json restricts type resolution to "types": ["jest"] cannot resolve @types/node — resulting in TS2339: Property 'on'/'off' does not exist on type 'ITask' errors on every task.on() / task.off() call.
The SDK's package.json maps "main" and "exports" to dist/webex.js, which only exported the Webex class as default. All named exports (TASK_EVENTS, getDefaultUIControls, AGENT_EVENTS, ContactCenter, etc.) were properly defined in dist/index.js but unreachable at runtime for consumers using import { TASK_EVENTS } from '@webex/contact-center'.
TypeScript compilation passed because types resolved from dist/types/index.d.ts, masking the fact that the runtime values were undefined. This caused the CC Widgets' addEventListeners() to crash silently on agent:dnRegistered, meaning no task event listeners (task:incoming, agent:stateChange, etc.) were ever registered — breaking incoming task rendering, modal popups, and RONA state updates.
by making the following changes
Fix 1: Self-contained ITask event methods
Fix 2: Re-export named exports from webex.js
Change Type
The following scenarios were tested
< ENUMERATE TESTS PERFORMED, WHETHER MANUAL OR AUTOMATED >
The GAI Coding Policy And Copyright Annotation Best Practices
I certified that
Make sure to have followed the contributing guidelines before submitting.