Skip to content

CAI-8656: Retain Idle state after wrap-up when agent selected it - #755

Open
mkesavan13 wants to merge 3 commits into
nextfrom
CAI-8656/epic-cti-desktop-agent-returns-to-available-after-wrap-up-despite-selecting-idle-before
Open

mkesavan13 wants to merge 3 commits into
nextfrom
CAI-8656/epic-cti-desktop-agent-returns-to-available-after-wrap-up-despite-selecting-idle-before

Conversation

@mkesavan13

@mkesavan13 mkesavan13 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

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

This pull request addresses

When an agent selects an Idle state during a call or wrap-up period, the Epic CTI Desktop widget incorrectly forces the agent back to Available once wrap-up completes and the task list empties. Native Agent Desktop retains the Idle selection; this fix corrects the widget regression.

Root Cause:
refreshTaskList in packages/contact-center/store/src/storeEventsWrapper.ts unconditionally called setCurrentState('0') (Available / DEFAULT_CODE) in the empty-task-list branch after wrap-up. This overwrote any agent-selected Idle aux-code, triggering useUserState to react and push an erroneous cc.setAgentState({state: 'Available'...}) call to the backend — the forced transition recorded in the ticket. The backend AGENT_STATE_CHANGE event (handleStateChange) is the authoritative post-wrap-up state source, and the unconditional reset overrode it.

by making the following changes

  • packages/contact-center/store/src/storeEventsWrapper.ts: Introduced module-level DEFAULT_CODE = '0' constant; guarded the setCurrentState('0') call in refreshTaskList to only fire when !this.currentState || this.currentState === DEFAULT_CODE; updated handleStateChange and handleLogin to reference the shared constant instead of inline literals.
  • packages/contact-center/store/tests/storeEventsWrapper.ts: Added three unit tests to the refreshTaskList suite — (1) Idle retention when task list empties, (2) Available reset preserved when no Idle was selected, (3) non-empty task list branch unchanged.
  • packages/contact-center/store/ai-docs/store-spec.md: Updated STORE-R-010 to reflect the Idle-retention conditional and point to the new test cases.

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

  • The testing is done with the amplify link
  • Unit test (RED): Three new refreshTaskList tests were written first; Test 1 ("retains agent-selected Idle state when task list empties after wrap-up") failed as expected before the fix.
  • Unit test (GREEN): After applying the guard, all 8 refreshTaskList tests pass.
  • Targeted regression: 13 tests across refreshTaskList, handleStateChange, handleTaskEnd, and task-rejection patterns all pass after the fix.
    Vidcast :
    https://app.vidcast.io/share/0cdf4504-3e58-4962-85bb-a9cfd567b883

Testing

  • Tests added: 3
  • Gate 1 verification: SKIPPED — skipped-missing-command — Gate 1 was not run because selected manifests do not declare commands.compile. Missing manifest paths: [".sdd/manifest.json"].
  • Gate 2 verification: SKIPPED — skipped-missing-command — Gate 2 was not run because selected manifests do not declare commands.unit-test. Missing manifest paths: [".sdd/manifest.json"].
  • Gate 3 verification: not run
  • Verification warning: Gates 1 and 2 were skipped because the repository manifest does not declare compile/unit-test commands. Tests were run manually via targeted Jest commands (see fix report) and all targeted tests pass.
  • Coverage outcome: skipped because role coverage-check is absent

Vidcast :
https://app.vidcast.io/share/0cdf4504-3e58-4962-85bb-a9cfd567b883

Verification limitations

  • Gate 1 compile: SKIPPED — skipped-missing-command — Gate 1 was not run because selected manifests do not declare commands.compile. Missing manifest paths: [".sdd/manifest.json"].
  • Gate 2 unit tests: SKIPPED — skipped-missing-command — Gate 2 was not run because selected manifests do not declare commands.unit-test. Missing manifest paths: [".sdd/manifest.json"].

Acceptance Criteria

ID Criterion Source JiraToPr status Evidence
AC-1 When an agent selects an Idle state during a call or wrap-up, the selected Idle state is retained after wrap-up completes and the task list empties, instead of the widget forcing the agent back to Available. Jira description: Acceptance Criteria Not validated — Gate 2 skipped (skipped-missing-command) Unit test "retains agent-selected Idle state when task list empties after wrap-up" passed in targeted Jest run; Gate 2 was not run

External Validation Required

  • AC-1 — Backend AGENT_STATE_CHANGE event emits correct post-wrap-up Idle state in production.
    • Reason: deployment-required
    • Details: Requires a production-like environment with the Webex CC SDK and backend agent-state service. Confirms that when an agent selects Idle during wrap-up, the backend emits AGENT_STATE_CHANGE with the correct Idle aux-code after the task list empties (native Agent Desktop behavior per ticket confirms this). The fix relies on the backend event as the authoritative post-wrap-up state source; cc.setAgentState is no longer called by the widget in this path.
    • Source: Jira description: CR-1 TASK-1:EXTERNAL-VALIDATION (packages/contact-center/store/src/storeEventsWrapper.ts:1078)

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 — Claude (Anthropic)
  • This PR is related to
    • Feature
    • Defect fix
    • Tech Debt
    • Automation

Checklist before merging

  • I have not skipped any automated checks
  • All existing and new tests passed
  • I have updated the testing document
  • I have tested the functionality with amplify link

Make sure to have followed the contributing guidelines before submitting.


Jira: https://jira-eng-sjc12.cisco.com/jira/browse/CAI-8656

JiraToPr added 3 commits October 30, 2026 07:27
…lected it

Guard the unconditional setCurrentState('0') in refreshTaskList so it only
fires when the agent is already in the default Available state. When a non-
default Idle aux-code is selected, the store retains it and defers to the
backend AGENT_STATE_CHANGE event as the authoritative post-wrap-up source.
@mkesavan13
mkesavan13 requested a review from a team as a code owner October 30, 2026 07:38
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T07:40:46.074466Z 48d94a2 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@aws-amplify-us-east-2

Copy link
Copy Markdown

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-755.d1b38q61t1z947.amplifyapp.com


const WELLNESS_NOTIFICATION_ACTIONS = new Set(Object.values(WELLNESS_BREAK_NOTIFICATION_ACTIONS));

const DEFAULT_CODE = '0'; // Default aux-code id representing the Available state

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.

Now that the PR introduces the module-level DEFAULT_CODE and converts the other call sites, but line 502 still has a bare literal:
this.store.legacyAuxCodeId = payload.auxCodeId?.trim() || this.store.legacyAuxCodeId || '0';

@rarajes2 rarajes2 added the validated Indicates that the PR is ready for actions label Nov 4, 2026

@rarajes2 rarajes2 left a comment

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.

LGTM. Please check what's wrong with the pipeline. Even after adding the validated label, it's failing for that particular reason.

This branch has not been deployed

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

Labels

validated Indicates that the PR is ready for actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants