Skip to content

fix(store): attach SDK listeners on stationLoginSuccess#690

Open
vamshigovardhana wants to merge 2 commits into
webex:nextfrom
vamshigovardhana:mobius-reg-config
Open

fix(store): attach SDK listeners on stationLoginSuccess#690
vamshigovardhana wants to merge 2 commits into
webex:nextfrom
vamshigovardhana:mobius-reg-config

Conversation

@vamshigovardhana
Copy link
Copy Markdown
Contributor

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

This pull request addresses

UserState (and other CC widgets that depend on agent:stateChange) freeze in non-WebRTC tabs — e.g. Epic Hyperspace secondary windows that intentionally skip Mobius registration, or any Extension/AgentDN login where Mobius is not registered.

Root cause: addEventListeners() in storeEventsWrapper.setupIncomingTaskHandler was only invoked from the AGENT_DN_REGISTERED and AGENT_RELOGIN_SUCCESS handlers. When Mobius registration is skipped and silent relogin does not run, neither event fires, so the agent:stateChange (and related) listeners are never attached and the store never receives state updates from the SDK.

by making the following changes

  • Call addEventListeners() from the AGENT_STATION_LOGIN_SUCCESS handler (handleLogin) as well, guarded by the same listenersAdded flag so listeners are attached exactly once regardless of which event fires first.

Builds on the sample-app changes from #683 which add a "Disable WebRTC Registration" toggle for repro convenience.

Change Type

  • Bug fix (non-breaking change which fixes an issue)

The following scenarios were tested

  • Extension login (Mobius skipped) → agent:stateChange listener is attached on stationLoginSuccess; UserState updates propagate (no freeze).
  • Browser login with Mobius registered → listener attached exactly once (no duplicate via agent:dnRegistered).
  • Silent relogin path (agent:reloginSuccess) → listener attached exactly once.

The GAI Coding Policy And Copyright Annotation Best Practices

  • GAI was used to create a draft that was subsequently customized
  • Tool used for AI assistance
    • Other - Please Specify: Cursor (Claude)
  • This PR is related to
    • Defect fix

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

mkesavan13 and others added 2 commits May 8, 2026 11:05
addEventListeners() previously ran only in the AGENT_DN_REGISTERED and
AGENT_RELOGIN_SUCCESS handlers. When Mobius registration is skipped
(Epic Hyperspace non-calling windows, Extension/AgentDN logins) and
silent relogin does not run, neither event fires, so agent:stateChange
(and related) listeners were never attached and UserState froze.

Also invoke addEventListeners() from handleLogin, guarded by the
existing listenersAdded flag so listeners attach exactly once
regardless of which event fires first.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vamshigovardhana vamshigovardhana changed the title fix(store): CAI-7899 attach SDK listeners on stationLoginSuccess fix(store): Attach SDK listeners on stationLoginSuccess May 28, 2026
@vamshigovardhana vamshigovardhana marked this pull request as ready for review May 28, 2026 15:06
@vamshigovardhana vamshigovardhana requested a review from a team as a code owner May 28, 2026 15:06
@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-690.d1b38q61t1z947.amplifyapp.com

@Shreyas281299 Shreyas281299 added the validated Indicates that the PR is ready for actions label May 29, 2026
@Shreyas281299
Copy link
Copy Markdown
Contributor

Shreyas281299 commented May 29, 2026

AFAIK, in this scenario we would received AGENT_RELOGIN event and that should add the event listeners. Can you please share a testing video for this fix

Copy link
Copy Markdown
Contributor

@Shreyas281299 Shreyas281299 left a comment

Choose a reason for hiding this comment

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

Please add test cases and share a testing video for the fix

// @ts-expect-error To be fixed in SDK - https://jira-eng-sjc12.cisco.com/jira/browse/CAI-6762
this.setTeamId(payload.teamId);
});
// CAI-7899: Ensure CC SDK listeners (incl. agent:stateChange) are attached even when
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.

We dont need to put the CAI ID in code unless its a TODO

@Shreyas281299 Shreyas281299 added validated Indicates that the PR is ready for actions and removed validated Indicates that the PR is ready for actions labels May 29, 2026
@Shreyas281299 Shreyas281299 changed the title fix(store): Attach SDK listeners on stationLoginSuccess fix(store): attach SDK listeners on stationLoginSuccess May 29, 2026
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.

3 participants