Skip to content

fix(campaign-task): Add all global variables to campaign task#714

Open
zachraymer wants to merge 6 commits into
webex:nextfrom
zachraymer:next
Open

fix(campaign-task): Add all global variables to campaign task#714
zachraymer wants to merge 6 commits into
webex:nextfrom
zachraymer:next

Conversation

@zachraymer

@zachraymer zachraymer commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

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

This pull request addresses

Some global variables are missing from campaign task panel. Adding logic to display variables as we receive updates from the websocket, consistent with agent desktop

by making the following changes

Each websocket event triggers refreshTaskList() → setCurrentTask(), and the task snapshot's callAssociatedData may only contain variables from the latest payload, not the cumulative set. The existing code replaced the entire globalVariablesRef with whatever arrived, losing variables from earlier payloads.

Changes Made

  1. Data fix — merge instead of replace (3 files):

@/.../CallControlCAD/call-control-cad.tsx:101-104 — merge new global variables into existing ref by name key using a Map, so all variables seen during the interaction are accumulated
@/.../CampaignTask/campaign-task.tsx:69-72 — same merge fix
@/.../CampaignTaskPopover/campaign-task-popover.tsx:57-60 — same merge fix

  1. Regression tests (1 file):

@/.../tests/CallControlCAD/call-control-cad.tsx — 3 new tests:
Variables from separate payloads are accumulated (merged)
Same variable's value is updated on re-render
Variables reset when interaction ID changes (new call)

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
    < 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

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.

@zachraymer zachraymer requested a review from a team as a code owner July 1, 2026 16:00

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8dd0586cea

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 69 to +72
} else if (latestGlobalVariables.length > 0) {
globalVariablesRef.current = latestGlobalVariables;
const existingMap = new Map(globalVariablesRef.current.map((v) => [v.name, v]));
latestGlobalVariables.forEach((v) => existingMap.set(v.name, v));
globalVariablesRef.current = Array.from(existingMap.values());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reset cached CAD when campaign contact changes

When a preview campaign offer is skipped or removed, this component can receive a new contact on the same task/interaction; the component already detects that scenario below via campaignPreviewOfferTimeout. Because this accumulator only resets on interactionId changes and otherwise merges by variable name, any variable that was present only on the previous contact remains visible in the inline panel (and the mirrored popover accumulator has the same behavior) until unmount. For example, contact A's Global_Language will still display for contact B if B's payload contains only Global_Account, leaking stale customer data.

Useful? React with 👍 / 👎.

@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-714.d1b38q61t1z947.amplifyapp.com

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants