10000 Pause resume record issue by rsarika · Pull Request #409 · webex/widgets · GitHub
[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pause resume record issue #409

Open
wants to merge 1 commit into
base: ccwidgets
Choose a base branch
from

Conversation

rsarika
Copy link
Contributor
@rsarika rsarika commented Mar 7, 2025

This PR is to fix pause/resume recording button sync in two tabs(multi session).

https://app.vidcast.io/share/0838cb46-2fe1-4589-a4bb-11abdef3edd3

@rsarika rsarika requested a review from mkesavan13 March 7, 2025 10:13
Copy link
coderabbitai bot commented Mar 7, 2025
📝 Walkthrough

Walkthrough

The changes update the recording state management for the Contact Center task. The presentational component no longer maintains local state for recording; instead, it receives isRecording and setIsRecording as props and directly calls toggleRecording without passing state. Within the useCallControl hook, a new state variable for isRecording is introduced along with callbacks (pauseRecordingCallback and resumeRecordingCallback) tied to the events CONTACT_RECORDING_PAUSED and CONTACT_RECORDING_RESUMED. The signature of toggleRecording is simplified to a parameterless function that relies on this internal state. The task type definitions are updated accordingly by adding the new properties in the ControlProps interface and CallControlPresentationalProps. Test files have been modified to use the new props and include additional assertions for the new event handling.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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

@rsarika
Copy link
Contributor Author
rsarika commented Mar 7, 2025

@coderabbitai review

Copy link
coderabbitai bot commented Mar 7, 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
@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/contact-center/task/src/helper.ts (1)

130-130: Consider synchronizing initial recording state

The isRecording state is initialized to true by default, assuming recording is always active initially. While this may be the typical case for contact centers, consider checking the actual recording state of the task when initializing this value, especially for scenarios where a task might be resumed with recording already paused.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2e91359 and 6d4f426.

📒 Files selected for processing (5)
  • packages/contact-center/task/src/CallControl/call-control.presentational.tsx (2 hunks)
  • packages/contact-center/task/src/helper.ts (4 hunks)
  • packages/contact-center/task/src/task.types.ts (3 hunks)
  • packages/contact-center/task/tests/CallControl/call-control.presentational.tsx (1 hunks)
  • packages/contact-center/task/tests/helper.ts (6 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: AWS Amplify Console Web Preview
🔇 Additional comments (21)
packages/contact-center/task/tests/CallControl/call-control.presentational.tsx (1)

52-52: Properly added mock function for new prop

The addition of the setIsRecording mock function to defaultProps correctly supports the updated component that now expects this prop.

packages/contact-center/task/src/CallControl/call-control.presentational.tsx (2)

24-25: LGTM: Adding isRecording state as props

Extracting isRecording and setIsRecording from props aligns with lifting state up pattern, improving component reusability.


70-70: LGTM: Simplified toggleRecording implementation

The recording toggle now directly calls the function without parameters, which simplifies the implementation and follows the new state management approach.

packages/contact-center/task/tests/helper.ts (10)

512-521: LGTM: Added tests for new recording events

The test properly verifies that callback handlers are set up for the new recording pause and resume events.


523-523: Expected test count updated correctly

The number of expected callbacks was appropriately updated from 5 to 7 to account for the two new event types.

Also applies to: 529-530


557-566: LGTM: Added cleanup tests for recording callbacks

The tests properly verify that recording callbacks are removed on component unmount.


791-793: Proper state setup before testing toggle

Setting the recording state before testing the toggle functionality ensures consistent behavior.


796-796: LGTM: Updated toggleRecording test to match new signature

The test correctly calls toggleRecording() without parameters, matching the updated implementation.


815-817: Consistent state setup in error test case

Setting the recording state before testing error handling ensures the test accurately reflects real usage.


820-821: Properly testing both action and event callback

Test correctly verifies that toggle action is called and then simulates the event callback to test the full flow.


839-841: LGTM: Setup for resume recording test

Setting isRecording to false before testing ensures the test accurately triggers a resume operation.


844-845: Complete testing of recording resume flow

Test properly verifies the resume action and event handling flow.


863-865: Consistent error testing for resume case

Setting up the recording state appropriately before testing the error case follows the same pattern as other tests.

packages/contact-center/task/src/task.types.ts (3)

158-160: LGTM: Simplified toggleRecording signature

Removing the boolean parameter simplifies the interface and makes the implementation more straightforward. The function now relies on the component's internal state to determine the action.


190-199: Well-documented new props for recording state

The new properties are properly documented with JSDoc comments, making the API clear for developers.


216-217: Updated presentation props to include recording state

CallControlPresentationalProps correctly includes the new recording-related properties, maintaining consistency across the codebase.

packages/contact-center/task/src/helper.ts (5)

150-156: Callbacks look good

These callback functions appropriately update the isRecording state based on the corresponding events.


165-170: Event registration is properly implemented

The event registration follows the same pattern as other events in this file and correctly links the events to the appropriate callbacks.


177-186: Cleanup logic is correctly implemented

The cleanup function properly removes the event listeners, preventing memory leaks when the component unmounts.


263-264: Good addition to the hook's return value

Exposing isRecording and setIsRecording in the hook's return value is consistent with the pattern used for other state in this hook (like isHeld) and allows components to react to recording state changes.


230-240:

❓ Verification inconclusive

Function signature change is clean and logical

The refactoring of toggleRecording to rely on internal state rather than a parameter simplifies the API and makes the function behavior more intuitive. This follows the pattern of state-based toggles commonly used in React.


🏁 Script executed:

#!/bin/bash
# Check if all consumers of toggleRecording have been updated to use the new signature
rg -A 2 -B 2 "toggleRecording\(" --type ts --type tsx

Length of output: 83


Revised Consumer ToggleRecording Verification Required

The refactoring of toggleRecording to use internal state remains clean and logical. However, the initial search command encountered an issue (unrecognized file type: tsx), making the verification of all consumers inconclusive. Please execute the updated search below to ensure that all call sites for toggleRecording have been updated to use the new signature:

  • Revised Search Command:
    rg -A 2 -B 2 "toggleRecording\(" -g "*.ts" -g "*.tsx"

Once you confirm that no outdated usages remain, the refactoring can be approved.

Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-409.d1b38q61t1z947.amplifyapp.com

Copy link
@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.

Logic looks good to me

Copy link
Contributor
@adhmenon adhmenon left a comment

Choose a reason for hiding this comment

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

Logic looks good, let's add some tests in the test doc and we should be good to go imo.

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.

3 participants
0