-
Notifications
You must be signed in to change notification settings - Fork 45
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
base: ccwidgets
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThe changes update the recording state management for the Contact Center task. The presentational component no longer maintains local state for recording; instead, it receives ✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this 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 stateThe
isRecording
state is initialized totrue
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
📒 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 propThe addition of the
setIsRecording
mock function todefaultProps
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 propsExtracting
isRecording
andsetIsRecording
from props aligns with lifting state up pattern, improving component reusability.
70-70
: LGTM: Simplified toggleRecording implementationThe 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 eventsThe test properly verifies that callback handlers are set up for the new recording pause and resume events.
523-523
: Expected test count updated correctlyThe 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 callbacksThe tests properly verify that recording callbacks are removed on component unmount.
791-793
: Proper state setup before testing toggleSetting the recording state before testing the toggle functionality ensures consistent behavior.
796-796
: LGTM: Updated toggleRecording test to match new signatureThe test correctly calls
toggleRecording()
without parameters, matching the updated implementation.
815-817
: Consistent state setup in error test caseSetting the recording state before testing error handling ensures the test accurately reflects real usage.
820-821
: Properly testing both action and event callbackTest 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 testSetting
isRecording
to false before testing ensures the test accurately triggers a resume operation.
844-845
: Complete testing of recording resume flowTest properly verifies the resume action and event handling flow.
863-865
: Consistent error testing for resume caseSetting 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 signatureRemoving 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 stateThe new properties are properly documented with JSDoc comments, making the API clear for developers.
216-217
: Updated presentation props to include recording stateCallControlPresentationalProps correctly includes the new recording-related properties, maintaining consistency across the codebase.
packages/contact-center/task/src/helper.ts (5)
150-156
: Callbacks look goodThese callback functions appropriately update the
isRecording
state based on the corresponding events.
165-170
: Event registration is properly implementedThe 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 implementedThe cleanup function properly removes the event listeners, preventing memory leaks when the component unmounts.
263-264
: Good addition to the hook's return valueExposing
isRecording
andsetIsRecording
in the hook's return value is consistent with the pattern used for other state in this hook (likeisHeld
) 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 tsxLength 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 fortoggleRecording
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.
This pull request is automatically being deployed by Amplify Hosting (learn more). |
There was a problem hiding this 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
There was a problem hiding this 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.
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