Skip to content
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
439effd
docs(ai-docs): add task refactor migration documentation (old vs new)
akulakum Mar 9, 2026
4a534db
Merge branch 'next' into TASK_REFACTOR_MIGRATION_OLD_VS_NEW
akulakum Mar 10, 2026
45a1bd6
docs(ai-docs): address codex review comments
akulakum Mar 10, 2026
28397c2
docs(ai-docs): address codex second review comments
akulakum Mar 10, 2026
3bd613f
docs(ai-docs): address codex third review comments
akulakum Mar 10, 2026
606dcbf
docs(ai-docs): address codex fourth review comments
akulakum Mar 10, 2026
23c1fab
docs(ai-docs): address codex fifth review comments
akulakum Mar 10, 2026
e4ea922
docs(ai-docs): address codex sixth review comments
akulakum Mar 11, 2026
b35a8c3
Merge branch 'next' into TASK_REFACTOR_MIGRATION_OLD_VS_NEW
akulakum Mar 11, 2026
2313f1a
docs(ai-docs): address codex seventh review comments
akulakum Mar 11, 2026
0024a37
docs(ai-docs): split PR — retain only foundation docs (PR 1/4)
akulakum Mar 11, 2026
abbbaf3
docs(ai-docs): address codex eighth review — fix conference state der…
akulakum Mar 11, 2026
eabc80d
docs(ai-docs): add CC SDK task-refactor branch reference to 001-migra…
akulakum Mar 11, 2026
6e50dc5
docs(ai-docs): address codex ninth review — fix consult mapping, reco…
akulakum Mar 11, 2026
0d08a09
docs(ai-docs): address codex tenth review — add TaskState export, fix…
akulakum Mar 11, 2026
d576676
docs(ai-docs): address codex eleventh review — keep findHoldStatus in…
akulakum Mar 11, 2026
4a28a43
docs(ai-docs): address reviewer feedback — restructure 001 overview, …
akulakum Mar 11, 2026
91dd405
docs(ai-docs): consolidate PR 1 migration docs into single overview
akulakum Mar 12, 2026
319b843
Merge branch 'next' into TASK_REFACTOR_MIGRATION_OLD_VS_NEW
akulakum Mar 17, 2026
86ada36
docs(migration): SDK exports list/timeline, define gotcha
akulakum Mar 17, 2026
4471af5
Merge branch 'next' into TASK_REFACTOR_MIGRATION_OLD_VS_NEW
akulakum Mar 18, 2026
e6ce0da
Merge branch 'next' into TASK_REFACTOR_MIGRATION_OLD_VS_NEW
akulakum Mar 19, 2026
3c5f274
docs(migration): address — reorder sections, add consultTransfer meth…
akulakum Mar 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ yarn build
```
ccWidgets/
├── packages/contact-center/
│ ├── ai-docs/migration/ # Task refactor migration docs (old → new)
│ ├── station-login/ # Widget with ai-docs/
│ ├── user-state/ # Widget with ai-docs/
│ ├── task/ # Widget package
Expand Down Expand Up @@ -613,6 +614,7 @@ ccWidgets/

- **Repository Rules:** [RULES.md](./RULES.md)
- **Templates Overview:** [templates/README.md](./ai-docs/templates/README.md)
- **Task Refactor Migration (Contact Center):** [packages/contact-center/ai-docs/migration/migration-overview.md](./packages/contact-center/ai-docs/migration/migration-overview.md) — overview and entry point for CC SDK task-refactor migration docs

---

Expand Down
131 changes: 131 additions & 0 deletions packages/contact-center/ai-docs/migration/migration-overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# Task Refactor Migration Overview

## Purpose

Guide for migrating CC Widgets from ad-hoc task state management to the new SDK state-machine-driven architecture (`task-refactor` branch). This is the single entry point — it tells you what changed, which docs to follow in what order, and what to watch out for.

---

## Architectural Change: Old vs New

```
┌─────────────────────────────────────────────────────────────────────────────────┐
│ OLD (Current Widgets) │ NEW (After Migration) │
│ │ │
│ SDK emits 30+ task events │ SDK state machine transitions │
│ │ │ │ │
│ ▼ │ ▼ │
│ Store: refreshTaskList() │ SDK: computes TaskUIControls │
│ + update observables manually │ from (TaskState + TaskContext) │
│ │ │ │ │
│ ▼ │ ▼ │
│ Hooks: getControlsVisibility( │ SDK emits │
│ deviceType, featureFlags, │ 'task:ui-controls-updated' │
│ task, agentId, conferenceEnabled) │ │ │
│ │ │ ▼ │
│ ▼ │ Widgets read task.uiControls │
│ Components: flat ControlVisibility │ │ │
│ (22 controls + 7 state flags) │ ▼ │
│ │ Components: TaskUIControls │
│ Logic spread across: │ (17 controls, each │
│ task-util.ts, task-utils.ts, │ { isVisible, isEnabled }) │
│ timer-utils.ts, component utils │ │
│ │ Single source of truth: │
│ │ task.uiControls │
└─────────────────────────────────────────────────────────────────────────────────┘
```

### `TaskUIControls` Structure
Copy link
Contributor

Choose a reason for hiding this comment

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

Execution order and SDK related sections that we are covering here should come first, when we have already specified that this the change, that's when you talk about TaskUIControls structure. Also there is change in public method which we should capture in this doc as well as the speciifc migration file. consultTransfer is not a public method anymore, only one method for transfer always which .transfer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done both. Reordered: Execution Order and SDK sections now come before TaskUIControls Structure. Added a new "SDK Public Method Changes" section documenting task.consultTransfer() → task.transfer() — single .transfer() for all transfer types.


```typescript
type TaskUIControlState = { isVisible: boolean; isEnabled: boolean };

type TaskUIControls = {
accept, decline, hold, transfer, consult, end, recording, mute,
consultTransfer, endConsult, conference, exitConference,
transferConference, mergeToConference, wrapup,
switchToMainCall, switchToConsult

Choose a reason for hiding this comment

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

P2 Badge Use valid TypeScript syntax for TaskUIControls example

The TaskUIControls structure block is shown as a type definition but lists properties without : TaskUIControlState, which is invalid TypeScript and will fail if readers copy it into migration code. Because this section is positioned as the canonical contract, keeping it syntactically valid (or explicitly labeling it pseudocode) is important to prevent avoidable implementation errors during the migration.

Useful? React with 👍 / 👎.

// each: TaskUIControlState
};
```

Widgets no longer compute control visibility — `task.uiControls` is the single source of truth.

---

## Execution Order

Follow these docs in order. Each doc has old vs new code, before/after examples, and files to modify.

| Order | Document | What to Do |
|-------|----------|------------|
| 1 | [store-event-wiring-migration.md](./store-event-wiring-migration.md) | Simplify 30+ event handlers — remove `refreshTaskList()`, add `TASK_UI_CONTROLS_UPDATED` subscription |

Choose a reason for hiding this comment

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

P1 Badge Point execution-order links to existing migration docs

The execution-order table links to ./store-event-wiring-migration.md and five similar files that are not present in this commit, so readers following the "single entry point" guidance hit dead links immediately and cannot continue the migration workflow. I verified the scope under packages/contact-center/ai-docs/migration in this tree and only migration-overview.md exists, so these references need to be updated (or clearly marked as pending) to avoid blocking migration work.

Useful? React with 👍 / 👎.

| 2 | [store-task-utils-migration.md](./store-task-utils-migration.md) | Remove redundant utils (SDK handles), keep display/timer utils |
| 3 | [call-control-hook-migration.md](./call-control-hook-migration.md) | Replace `getControlsVisibility()` with `task.uiControls` in `useCallControl` + update timer utils |
| 4 | [incoming-task-migration.md](./incoming-task-migration.md) | Use `task.uiControls.accept/decline` instead of visibility functions |
| 5 | [task-list-migration.md](./task-list-migration.md) | Per-task `uiControls` for accept/decline |
| 6 | [component-layer-migration.md](./component-layer-migration.md) | Update `cc-components` props — `ControlVisibility` → `TaskUIControls`, rename control props |

---

## SDK Pending Exports (Prerequisites)

> **Status:** This section will be updated once the SDK team adds these exports. Migration can begin on items that don't depend on these, but full completion requires them.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we list what are the items that SDK isn't exporting today and when is that change going to happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. The doc now states what the SDK doesn’t export today (table) and has a ‘Before implementing’ note to check whether those exports are available from the SDK


These items are exported from SDK source files but not yet from the package entry point (`src/index.ts`):

| Item | SDK Change Needed |
|------|---|
| `TaskUIControls` type | Add to `src/index.ts` |
| `getDefaultUIControls()` | Add to `src/index.ts` |
| `TaskState` enum | Add to `src/index.ts` (needed for consult timer labeling) |
| `uiControls` on `ITask` | Add getter to `ITask` interface (currently only on concrete `Task` class) |
| `IVoice`, `IDigital`, `IWebRTC` | Add to `src/index.ts` (optional — for type narrowing) |

---

## Key Types from SDK

| Type | Purpose |
|------|---------|
| `TaskUIControls` | Pre-computed control states (17 controls) |
| `getDefaultUIControls()` | Fallback when no task: `task?.uiControls ?? getDefaultUIControls()` |
| `TASK_EVENTS` | Import from SDK — delete local enum in `store.types.ts` |

> Constants to delete/keep, event name mappings, and migration gotchas are documented in each migration doc above (PRs 2 and 3).
Copy link
Contributor

Choose a reason for hiding this comment

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

What is a migration gotcha?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. The doc now defines it in place: migration gotchas = non-obvious pitfalls or ordering constraints (e.g. ‘do not delete constant X until helper Y is rewritten’). The reference to PRs 2 and 3 is updated to point to the specific migration .md files instead.


---

## CC Widgets Files Affected
Copy link
Contributor

Choose a reason for hiding this comment

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

This section should be at the start maybe after Architectural change section

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved "CC Widgets Files Affected" to directly after the "Architectural Change" section.


| Area | Path |
|------|------|
| Task hooks | `packages/contact-center/task/src/helper.ts` |
| Task UI utils (OLD — to be removed) | `packages/contact-center/task/src/Utils/task-util.ts` |
| Task timer utils | `packages/contact-center/task/src/Utils/timer-utils.ts` |
| Hold timer hook | `packages/contact-center/task/src/Utils/useHoldTimer.ts` |
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this related to task-refactor change ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed — removed timer-utils.ts and useHoldTimer.ts from the files affected table. These are not directly impacted by the task-refactor SDK changes. Added a note: "Timer signature updates (if any) are tracked separately in the hook migration doc."

| Task types | `packages/contact-center/task/src/task.types.ts` |
| Store event wrapper | `packages/contact-center/store/src/storeEventsWrapper.ts` |
| Store task utils | `packages/contact-center/store/src/task-utils.ts` |
| Store constants | `packages/contact-center/store/src/constants.ts` |
| CC Components — CallControl | `packages/contact-center/cc-components/src/components/task/CallControl/` |
| CC Components — CallControlCAD | `packages/contact-center/cc-components/src/components/task/CallControlCAD/` |
| CC Components types | `packages/contact-center/cc-components/src/components/task/task.types.ts` |

Choose a reason for hiding this comment

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

P2 Badge Include web-component wrapper in affected-files list

This “CC Widgets Files Affected” inventory is used as migration planning input, but it omits packages/contact-center/cc-components/src/wc.ts, which still defines CallControl/CallControlCAD prop wiring (isHeld, setIsHeld, etc.) that must change when the component contract moves from ControlVisibility to TaskUIControls. Leaving it out makes the overview incomplete and can cause teams to skip a required migration surface, resulting in stale WC props after component-layer updates.

Useful? React with 👍 / 👎.


---

## CC SDK Reference

> **Repo:** [webex/webex-js-sdk (task-refactor)](https://github.com/webex/webex-js-sdk/tree/task-refactor)
Copy link
Contributor

Choose a reason for hiding this comment

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

Local path should not be put here because this will be different from each person cloning the repo and using this file. For now just add a TODO not that we need to provide local SDK code reference. Rankush has already done some invetsigation in this area so once we have some finalized approach, we shoyld provide the details of that approach to be able to read other repos locally

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the hardcoded local path. Added a TODO comment: "Provide local SDK cross-repo reference approach once finalized (Rankush is investigating). Do not use hardcoded local paths."

> **Local path:** `/Users/akulakum/Documents/CC_SDK/webex-js-sdk` (branch: `task-refactor`)

| File | Purpose |
|------|---------|
| `uiControlsComputer.ts` | Computes `TaskUIControls` from `TaskState` + `TaskContext` — the single source of truth |
| `Task.ts` | Task service exposing `task.uiControls` getter and `task:ui-controls-updated` event |
| `constants.ts` | `TaskState` and `TaskEvent` enums |

---

_Created: 2026-03-09_
_Updated: 2026-03-12 (consolidated and reordered per reviewer feedback)_
Loading