Skip to content

fix(call-timer): resolve-main-consult-conference-hold-timer-discrepancies - #569

Merged
akulakum merged 5 commits into
webex:nextfrom
akulakum:FIX_TIMER_ISSUES
Dec 15, 2025
Merged

fix(call-timer): resolve-main-consult-conference-hold-timer-discrepancies#569
akulakum merged 5 commits into
webex:nextfrom
akulakum:FIX_TIMER_ISSUES

Conversation

@akulakum

@akulakum akulakum commented Dec 9, 2025

Copy link
Copy Markdown
Contributor

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

Vidcast link: https://app.vidcast.io/share/9da711ea-687d-481f-9001-8ac74c6a2df3

This pull request addresses

The proper handling of wrap-up, post-call, consulting, and consult-on-hold timers along with their corresponding labels during the main call flow. It ensures timer visibility and synchronization are aligned with Agent Desktop behavior.

by making the following changes

< DESCRIBE YOUR CHANGES >

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.

@akulakum akulakum added the validated Indicates that the PR is ready for actions label Dec 9, 2025
@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-569.d1b38q61t1z947.amplifyapp.com

@adhmenon adhmenon 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.

Just few comments on a small logic change, if possible.

/**
* Timestamp when post-call state started.
*/
postCallTimestamp?: number;

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.

I feel we should not have so many timestamp props.
We should just have 2 - one for the state timer and one for consult timer.
The value can be calculated in Utils and passed into the prop.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed - Reduced timestamp props from 7 to 4 as requested:

  • State timer: stateTimerLabel + stateTimerTimestamp
  • Consult timer: consultTimerLabel + consultTimerTimestamp

Removed redundant props: consultStartTimeStamp, wrapUpTimestamp, postCallTimestamp, consultHoldTimestamp

All timestamp calculations moved to timer-utils.ts (calculateStateTimerData and calculateConsultTimerData functions).

Comment on lines +350 to +363
// Get holdTimestamp - prioritize consult hold over main call hold
// This ensures the hold timer shows the correct time for whichever call is currently on hold
const consultHoldTs = currentTask?.data?.interaction
? findHoldTimestamp(currentTask.data.interaction, 'consult')
: null;
const mainCallHoldTs = currentTask?.data?.interaction
? findHoldTimestamp(currentTask.data.interaction, 'mainCall')
: null;

if (holdTimestamp) {
const holdTimeMs = holdTimestamp < 10000000000 ? holdTimestamp * 1000 : holdTimestamp;
// Use consult hold timestamp if available, otherwise use main call hold timestamp
const activeHoldTimestamp = consultHoldTs || mainCallHoldTs;

if (activeHoldTimestamp) {
const holdTimeMs = activeHoldTimestamp < 10000000000 ? activeHoldTimestamp * 1000 : activeHoldTimestamp;

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.

As mentioned above - we cna move a lot of this logic into the Utils file...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed - Hold timer logic moved to Utils/useHoldTimer.ts as a custom hook.

  • Extracted all worker management, cleanup, and timestamp logic (65+ lines)
  • Worker script defined at module level for optimal performance
  • Hook returns holdTime value, auto-updates on currentTask changes
  • Includes comprehensive unit tests

Comment on lines +304 to +311
const [consultStartTimeStamp, setConsultStartTimeStamp] = useState<number>(0);
const [wrapUpTimestamp, setWrapUpTimestamp] = useState<number>(0);
const [postCallTimestamp, setPostCallTimestamp] = useState<number>(0);
const [consultHoldTimestamp, setConsultHoldTimestamp] = useState<number>(0);

// State timer labels and timestamps
const [stateTimerLabel, setStateTimerLabel] = useState<string | null>(null);
const [stateTimerTimestamp, setStateTimerTimestamp] = useState<number>(0);

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.

Right - rather than using all these states, is it possible to just use 2 - one for state and other for consult. Then we can get the value by migrating that logic into utils.

That ways we can reduce the number of states. Labels are alright - we need 2 anyways.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed - Reduced to exactly 2 timestamp states (+ 2 labels) as requested:

Before: 8 states (4 intermediate timestamps + 4 final timer states)

  • consultStartTimeStamp, wrapUpTimestamp, postCallTimestamp, consultHoldTimestamp
  • stateTimerLabel, stateTimerTimestamp, consultTimerLabel, consultTimerTimestamp

After: 4 states (2 timestamps + 2 labels)

  • stateTimerTimestamp + stateTimerLabel
  • consultTimerTimestamp + consultTimerLabel

All calculation logic migrated to timer-utils.ts (calculateStateTimerData & calculateConsultTimerData)

} else {
setConsultHoldTimestamp(0);
}
}, [currentTask, agentId, extractConsultingAgent]);

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.

Same for these methods, maybe move to a Util and then just update the timestamp and inject that as a prop rather than multiple ones.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed

@akulakum
akulakum requested a review from adhmenon December 12, 2025 11:03
@akulakum
akulakum merged commit 99f962d into webex:next Dec 15, 2025
8 checks passed
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