Skip to content

fix(task-refactor): add explicit on/off methods to ITask interface#4812

Open
akulakum wants to merge 4 commits intowebex:task-refactorfrom
akulakum:ADD_MISSING_EVENT_EMITTER_TYPES
Open

fix(task-refactor): add explicit on/off methods to ITask interface#4812
akulakum wants to merge 4 commits intowebex:task-refactorfrom
akulakum:ADD_MISSING_EVENT_EMITTER_TYPES

Conversation

@akulakum
Copy link
Copy Markdown
Contributor

@akulakum akulakum commented Mar 27, 2026

COMPLETES #https://jira-eng-sjc12.cisco.com/jira/browse/CAI-7779

This pull request addresses

  1. Missing on()/off() type declarations on ITask interface

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.

  1. Named exports unreachable from the SDK's main entry point

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

  • Added explicit on() and off() method declarations directly on the ITask interface, making it self-contained so consumers no longer depend on @types/node to resolve EventEmitter methods
  • Used (...args: any[]) => void for the listener parameter to match Node's EventEmitter signature and avoid type narrowing issues with existing consumer callbacks

Fix 2: Re-export named exports from webex.js

  • Added export * from './index' in src/webex.js so that all named exports from index.ts (enums, functions, classes, and constants) are forwarded through the main entry point (dist/webex.js)
  • This ensures import { TASK_EVENTS, getDefaultUIControls, AGENT_EVENTS } from '@webex/contact-center' resolves correctly at runtime, not just at compile time

Change Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Tooling change
  • Internal code refactor

The following scenarios were tested

< ENUMERATE TESTS PERFORMED, WHETHER MANUAL OR AUTOMATED >

The GAI Coding Policy And Copyright Annotation Best Practices

  • GAI was not used (or, no additional notation is required)
  • Code was generated entirely by GAI
  • GAI was used to create a draft that was subsequently customized or modified
  • Coder created a draft manually that was non-substantively modified by GAI (e.g., refactoring was performed by GAI on manually written code)
  • Tool used for AI assistance (GitHub Copilot / Other - specify)
    • Github Copilot
    • Other - Please Specify
  • This PR is related to
    • Feature
    • Defect fix
    • Tech Debt
    • Automation

I certified that

  • I have read and followed contributing guidelines
  • I discussed changes with code owners prior to submitting this pull request
  • I have not skipped any automated checks
  • All existing and new tests passed
  • I have updated the documentation accordingly

Make sure to have followed the contributing guidelines before submitting.

@akulakum akulakum requested a review from a team as a code owner March 27, 2026 06:32
@akulakum akulakum added the validated If the pull request is validated for automation. label Mar 27, 2026
* Extends EventEmitter to support event-driven task updates
*/
export interface ITask extends EventEmitter {
/**
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this change ? If this was a problem then how did we have widgets working till now ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

validated If the pull request is validated for automation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants