Skip to content

Conversation

@adhmenon
Copy link
Contributor

@adhmenon adhmenon commented Jun 24, 2025

COMPLETES #< CAI-6475 >

This pull request addresses

  • Completes the task refactor for the webRTC task

by making the following changes

  • Added code to handle state for webrtc events and update the task ui controls.
  • Added sample app changes and basic methods for webrtc.

Vidcast - https://app.vidcast.io/share/be1f9085-f773-4e66-8ecd-7cdf78d23c63

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

  • Tested basic call control in sample app via webrtc
  • Tested advanced call control in sample app via webrtc

I certified that

  • I have read and followed contributing guidelines

  • I discussed changes with code owners prior to submitting this pull request

  • I have not skipped any automated checks

  • All existing and new tests passed

  • I have updated the documentation accordingly


Make sure to have followed the contributing guidelines before submitting.

@adhmenon adhmenon requested a review from a team as a code owner June 24, 2025 03:47
@adhmenon adhmenon added the validated If the pull request is validated for automation. label Jun 24, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 24, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

The changes update logic and tests related to UI controls for telephony tasks in a contact center application. In the sample app, the condition for setting UI controls on incoming telephony calls was broadened by removing a restriction based on the login option. The WebRTC class was updated so that its constructor enables both accept and decline controls by default, and its UI control logic was refined to handle different task event types, specifically managing the mute and wrapup controls' visibility and enabled states. The test suite was expanded to cover these new UI control behaviors and WebRTC event handling.

Possibly related PRs


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@adhmenon
Copy link
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 24, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/@webex/plugin-cc/src/services/task/types.ts (1)

1250-1250: Fix inaccurate JSDoc comment.

The comment "Disables the button control" is misleading since the method accepts a boolean parameter and can both enable or disable the control based on the value passed.

-   * Disables the button control.
+   * Sets the enabled state of the button control.
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4fdf2a3 and 04f79a5.

📒 Files selected for processing (4)
  • docs/samples/contact-center/app.js (1 hunks)
  • packages/@webex/plugin-cc/src/services/task/types.ts (1 hunks)
  • packages/@webex/plugin-cc/src/services/task/voice/WebRTC.ts (2 hunks)
  • packages/@webex/plugin-cc/test/unit/spec/services/task/voice/WebRTC.ts (3 hunks)
🔇 Additional comments (7)
packages/@webex/plugin-cc/src/services/task/voice/WebRTC.ts (2)

24-24: LGTM! Good initialization of UI controls.

Enabling both accept and decline controls by default in the constructor ensures proper initialization of the WebRTC task UI state.


40-71: Well-structured UI control management with good event-driven logic.

The implementation properly calls the superclass method first and then applies WebRTC-specific UI control logic based on task event types. The logic for each case makes sense:

  • AGENT_CONTACT_ASSIGNED: Enables mute when call is active
  • AGENT_CONTACT_HELD: Disables mute during hold (logical UX decision)
  • AGENT_CONTACT_UNHELD: Re-enables mute when resuming
  • Default: Hides mute during wrapup state

The code follows a clear pattern and handles the different interaction states appropriately.

docs/samples/contact-center/app.js (1)

1280-1284: Good simplification of UI control logic.

Removing the browser login exclusion makes sense given that the WebRTC class constructor now handles UI control initialization properly. This ensures consistent UI control behavior for all telephony tasks regardless of login method, which aligns with the enhanced UI control management implemented in the WebRTC service.

packages/@webex/plugin-cc/test/unit/spec/services/task/voice/WebRTC.ts (4)

2-5: Good addition of necessary imports for enhanced test coverage.

The new imports for CALL_EVENT_KEYS, TASK_EVENTS, and CC_EVENTS are properly utilized in the expanded test suite to verify event handling and UI control management.


32-32: Good enhancement of test data structure.

Adding the interaction object with state property provides more realistic test data that aligns with the actual task data structure used in the implementation.


78-96: Excellent test coverage for internal WebRTC methods.

These tests properly verify:

  • Event listener registration for remote media
  • Proper event emission when handling remote media

The tests ensure the WebRTC service correctly handles calling service integration.


98-139: Comprehensive UI controls test suite with excellent coverage.

The test suite thoroughly validates the UI control behavior for different task event types:

  • Initial state verification (accept/decline enabled)
  • Event-specific behavior (assigned, held, unheld states)
  • Default case handling (wrapup state)

Each test case directly corresponds to the implementation logic in the setUIControls method, ensuring the UI control state management works correctly across all task lifecycle events.

case CC_EVENTS.AGENT_CONTACT_RESERVED:
this.taskUiControls.accept.setEnabled(true);
case CC_EVENTS.AGENT_CONTACT_ASSIGNED:
this.updateTaskUiControls({
Copy link
Contributor

Choose a reason for hiding this comment

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

We should set accept and decline to false right after the call is answered here and where are we setting them to true when we receive RESERVED

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't need RESERVED as during that event we create the new task.
Also we are calling super.updateTaskUiControls wherein we set accept and decline to false(visibility) and set the other call controls.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please point me towards where we are doing super. updateTaskUiControls

// hide mute when wrapup is active
if (this.taskUiControls.wrapup.visible) {
this.updateTaskUiControls({
mute: [false, false],
Copy link
Contributor

Choose a reason for hiding this comment

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

What about the mute handling when consult is active, cancelled, accepted, declined or ended?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In case of all ended cases we are handling it as seen above.
For consult cases... in agent desktop we are showing mute for all consulting flows... so it should work out of the box.
Declined would anyway have it working as we don't show mute before that itself.

});

it('setUIControls for AGENT_CONTACT_ASSIGNED shows mute', () => {
const assignedData = { ...data, type: CC_EVENTS.AGENT_CONTACT_ASSIGNED } as any;
Copy link
Contributor

Choose a reason for hiding this comment

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

If it's possible to avoid any, let's try to do that even in test files

@adhmenon adhmenon requested a review from Kesari3008 June 27, 2025 05:34
@adhmenon
Copy link
Contributor Author

@Kesari3008 , attaching video showing consult flow - https://app.vidcast.io/share/99684c4a-7dc9-437c-843f-808a766eeb93

Copy link
Contributor

@Kesari3008 Kesari3008 left a comment

Choose a reason for hiding this comment

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

Observed few issues while testing:

  1. After the consult is ended, we resume the customer interaction but mute button is still disabled.
  2. Customer side audio is not being received on the agent's end. One-way audio also observed for consult case. Please cross-check once
  3. Task List doesn't have the accept/decline button for comsult and transfer case for receiving agent side.

Approving it but would like to setup a call tomorrow to test the consult flows more thoroughly before we merge this.

case CC_EVENTS.AGENT_CONTACT_RESERVED:
this.taskUiControls.accept.setEnabled(true);
case CC_EVENTS.AGENT_CONTACT_ASSIGNED:
this.updateTaskUiControls({
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please point me towards where we are doing super. updateTaskUiControls

break;

// on consult accepted hide accept/decline and show mute
case CC_EVENTS.AGENT_CONSULTING:
Copy link
Contributor

Choose a reason for hiding this comment

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

What about the controls handling for initiating end for this case and consult end case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is done in the Voice class. It will always be enabled for webRTC case.

@adhmenon
Copy link
Contributor Author

adhmenon commented Jul 1, 2025

Merging this PR after chatting with Priya.
As noted, most issues can be handled in the Digital task refactor, one way audio is something we need to check (not sure if it was working before itself).

@adhmenon adhmenon merged commit 934f30a into webex:task-refactor Jul 1, 2025
12 checks passed
@adhmenon adhmenon deleted the webrtc branch July 1, 2025 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

validated If the pull request is validated for automation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants