Move send replay from Queue to ReplayManager#1338
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the replay handling logic by moving responsibility for deciding whether to send or discard replays from the Queue class to the ReplayManager class. This centralization improves maintainability and separation of concerns.
- Added a new
sendOrDiscardReplaymethod toReplayManagerthat consolidates replay eligibility checks and error handling - Updated
Queueto delegate replay handling toReplayManager.sendOrDiscardReplayinstead of handling the logic internally - Comprehensively updated all test suites to reflect the new integration point and method signatures
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/browser/replay/replayManager.js | Added new sendOrDiscardReplay method with consolidated replay eligibility logic |
| src/queue.js | Removed internal replay handling methods and updated to call ReplayManager.sendOrDiscardReplay |
| test/replay/unit/replayManager.test.js | Added comprehensive unit tests for new sendOrDiscardReplay method |
| test/replay/unit/queue.replayManager.test.js | Updated tests to expect calls to sendOrDiscardReplay instead of direct send/discard calls |
| test/replay/integration/sessionRecording.test.js | Updated spy target from Queue to ReplayManager method |
| test/replay/integration/replayManager.test.js | Added integration tests for sendOrDiscardReplay scenarios |
| test/replay/integration/queue.replayManager.test.js | Updated integration tests to verify new method calls and argument passing |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
waltjones
approved these changes
Oct 1, 2025
matux
added a commit
that referenced
this pull request
Oct 2, 2025
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of the change
Note
PR Description written by Copilot
This PR refactors the replay handling logic by moving responsibility for deciding whether to send or discard replays from the
Queueclass to theReplayManagerclass. This centralization improves maintainability and separation of concerns.sendOrDiscardReplaymethod toReplayManagerthat consolidates replay eligibility checks and error handlingQueueto delegate replay handling toReplayManager.sendOrDiscardReplayinstead of handling the logic internallyRefactoring and Responsibility Shift:
Queue._sendOrDiscardReplayand_canSendReplayinto a new methodReplayManager.sendOrDiscardReplay, which now encapsulates all criteria and error handling for sending or discarding replays. (src/browser/replay/replayManager.js[1]src/queue.js[2]Queueto callReplayManager.sendOrDiscardReplaydirectly instead of handling replay logic internally, simplifyingQueueand improving separation of concerns. (src/queue.jssrc/queue.jsL118-R123)Test Suite Updates:
ReplayManager.sendOrDiscardReplayinstead of the previous direct calls tosendordiscard, ensuring tests accurately reflect the new flow. (test/replay/integration/queue.replayManager.test.js[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14];test/replay/unit/queue.replayManager.test.js[15]Integration Improvements:
ReplayManager.sendOrDiscardReplayto verify correct behavior for successful sends, API errors, and disabled replay scenarios. (test/replay/integration/replayManager.test.jstest/replay/integration/replayManager.test.jsR168-R231)test/replay/integration/sessionRecording.test.jstest/replay/integration/sessionRecording.test.jsL329-R329)These changes centralize replay handling, making the codebase easier to maintain and extend, and ensure that tests accurately verify the new replay flow.