feat(cc): add campaign preview#684
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c3cda98967
ℹ️ 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".
|
This pull request is automatically being deployed by Amplify Hosting (learn more). |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9a2feebe73
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 003596fba6
ℹ️ 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".
| const globalVariablesRef = useRef(latestGlobalVariables); | ||
| if (latestGlobalVariables.length > 0) { | ||
| globalVariablesRef.current = latestGlobalVariables; | ||
| } |
There was a problem hiding this comment.
Reset campaign CAD when a new preview contact arrives
When Skip/Remove advances the same campaign task to another contact and the SDK update omits or empties callAssociatedData, this ref never clears because it only writes non-empty values. The component already detects new contacts via timeoutTimestamp below, but GlobalVariablesPanel will keep showing the previous contact's global variables on the next preview; reset/key the ref when the offer changes, and mirror the same fix in the popover path.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 97c2c9dd1a
ℹ️ 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".
| }; | ||
|
|
||
| const CampaignTaskWithMetrics = withMetrics(CampaignTask, 'CampaignTask'); | ||
| export default CampaignTaskWithMetrics; |
There was a problem hiding this comment.
Should we wrap this with ErrorBoundary too? The other task components all have it and if something blows up in here it'd take down the whole TaskList.
There was a problem hiding this comment.
i added an ErrorBoundary to where CampaignTask is rendered
| @@ -648,6 +741,36 @@ class StoreWrapper implements IStoreWrapper { | |||
| this.refreshTaskList(); | |||
| }; | |||
|
|
|||
There was a problem hiding this comment.
nit: event is untyped here — should be ITask like the other handlers.
There was a problem hiding this comment.
should be resolved
| setIsAcceptClicked(true); | ||
| setHandleTimestamp(Date.now()); | ||
| disableAllButtons(); | ||
| logger?.info('CC-Widgets: CampaignTask: Auto-accept UI state set, awaiting backend', { |
There was a problem hiding this comment.
nit: This useState is way down here after a bunch of useEffects. Easy to miss — mind moving it up with the rest of the state declarations?
There was a problem hiding this comment.
there isn't a useState down here
97c2c9d to
e8a783a
Compare
| // Persist global variables across task updates — some store refreshes | ||
| // replace the task with a snapshot that omits callAssociatedData, | ||
| // which causes getAgentViewableGlobalVariables to return []. | ||
| // We intentionally keep the previous values when length === 0 because | ||
| // an empty array indicates missing data, not a legitimate clearing of | ||
| // variables. Variables are never cleared mid-call by the backend. | ||
| const globalVariablesRef = useRef(latestGlobalVariables); | ||
| if (latestGlobalVariables.length > 0) { | ||
| globalVariablesRef.current = latestGlobalVariables; | ||
| } | ||
| const globalVariables = globalVariablesRef.current; |
There was a problem hiding this comment.
If we need to persist variables across refrershed then ideally we should put the value in the store. But if its working then we dont need to make any changes
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1406aa2787
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 97626ebe20
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ca1781fcfc
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ac283aedbe
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a2cc5df298
ℹ️ 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".
| </div> | ||
| )} | ||
|
|
||
| {selectedWidgets.callControlCAD && ( |
There was a problem hiding this comment.
Restore current-task guard before mounting CallControlCAD
This branch now mounts CallControlCAD even when store.currentTask is null, but CallControlCADComponent still dereferences currentTask.data before its null check, so toggling the CAD widget with no active interaction can throw and repeatedly trip the error boundary. Keeping the previous store.currentTask gate here (or moving the null guard ahead of all dereferences in the component) avoids a startup/between-calls crash path in the sample app.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c620507371
ℹ️ 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".
| if (this.isCampaignPreview(task) && task.data.interaction.state === 'new') { | ||
| this.setState({ | ||
| developerName: RESERVED_LABEL, | ||
| name: RESERVED_USERNAME, | ||
| }); |
There was a problem hiding this comment.
Keep accepted preview assignments out of RESERVED state
handleTaskAssigned sets any campaign preview with interaction.state === 'new' to RESERVED, but accepted previews can remain in 'new' during SDK state lag (the same lag this change already handles via acceptedCampaignIds in setCurrentTask). In that window, an accepted preview can trigger task:assigned and this branch overwrites ENGAGED with RESERVED, so the agent state is incorrect while the accepted preview is active. Use the accepted-campaign guard here as well (for example, only set RESERVED when the interaction is 'new' and not in acceptedCampaignIds).
Useful? React with 👍 / 👎.
Shreyas281299
left a comment
There was a problem hiding this comment.
Minor changes required for the tests to use await while rendering. And removing a file. Please add await in all the tests before merging
There was a problem hiding this comment.
Can we remove this file
| }; | ||
|
|
||
| const renderComponent = (overrides: Partial<CampaignTaskListItemProps> = {}) => | ||
| render(<CampaignTaskListItem {...defaultProps} {...overrides} />); |
There was a problem hiding this comment.
I dont see these changes
| renderComponent({isAcceptClicked: false}); | ||
| expect(screen.getByTestId('campaign-popover-accept-button')).toBeInTheDocument(); |
There was a problem hiding this comment.
We have used await in some tests and some we dont. Can we use await while rendering all the time
COMPLETES #https://jira-eng-sjc12.cisco.com/jira/browse/CAI-7660 and https://jira-eng-sjc12.cisco.com/jira/browse/CAI-7662
This pull request addresses
Adds the UI for the campaign preview functionality
by making the following changes
creates new components for campaign preview
creates global variable component to share between call control cad and campaign components
makes changes to call control cad to render campaign preview ui
adds campaign preview to task list only when flag is enabled
Figma: https://www.figma.com/design/JvnDPHRIXlvZEiSSCBwtjk/WxCC-6242---Preview-Campaign?node-id=6473-173114&m=dev
Vidcast: https://app.vidcast.io/share/72f03823-417d-4417-8a5a-35032943f3d3
Change Type
The following scenarios were tested
The testing is done with the amplify link
< ENUMERATE TESTS PERFORMED, WHETHER MANUAL OR AUTOMATED >
Can accept campaign previews
Can skip campaign previews
Can remove campaign previews
Can disable skip/remove buttons based on campaign settings
Campaign auto action fires when campaign times out
The GAI Coding Policy And Copyright Annotation Best Practices
Checklist before merging
Make sure to have followed the contributing guidelines before submitting.