[Feature] Post-trigger Replay Capture (aka. Leading Replay)#1341
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
Implements post-trigger replay capture (leading replay) to enable recording user actions after a trigger event occurs. This complements the existing pre-trigger (trailing) replay functionality with a configurable postDuration setting.
- Adds two-phase capture system: trailing (immediate) + leading (delayed by
postDuration) - Implements buffer cursor system to replace fragile event count-based boundaries
- Adds coordination between trailing and leading sends via state machine
Reviewed Changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/replay/util/recorder.js | New test utility for accessing recorder's ring buffer internals |
| test/replay/unit/replayManager.test.js | Updates method calls from add to capture and adds comprehensive tests for sendOrDiscardReplay |
| test/replay/unit/recorder.collectEvents.test.js | New unit tests for buffer cursor-based event collection methods |
| test/replay/unit/queue.replayManager.test.js | Refactors tests to use sendOrDiscardReplay instead of direct send/discard calls |
| test/replay/integration/sessionRecording.test.js | Updates method calls and spy names from add to capture |
| test/replay/integration/replayManager.test.js | Updates method calls and adds integration tests for sendOrDiscardReplay |
| test/replay/integration/replayManager.bufferIndex.test.js | New integration tests for buffer cursor system and leading replay functionality |
| test/replay/integration/replayManager.bufferIndex.checkoutResilience.test.js | New tests for buffer cursor resilience across checkout operations |
| test/replay/integration/queue.replayManager.test.js | Updates integration tests to use new sendOrDiscardReplay API |
| test/replay/integration/e2e.test.js | Updates method calls and adds E2E test for trailing/leading replay flow |
| test/browser.replay.recorder.test.js | Updates test expectations and adds postDuration to configuration tests |
| src/queue.js | Removes replay decision logic and delegates to ReplayManager.sendOrDiscardReplay |
| src/browser/replay/replayManager.js | Major refactor: renames add to capture, adds leading replay coordination, and implements sendOrDiscardReplay |
| src/browser/replay/recorder.js | Replaces event arrays with ring buffer system and implements cursor-based event collection |
| src/browser/replay/defaults.js | Adds default postDuration configuration option |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
waltjones
approved these changes
Oct 2, 2025
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
Implements post-trigger replay capture, enabling recording of user actions after a trigger event, such as an occurrence. Complements existing pre-trigger (trailing) replay with configurable
postDuration.Sub-PRs (All Approved)
Implementation Highlights
Architecture
postDuration).TrailingStatusstate machine (PENDING→SENT/FAILED).Buffer Cursor System
{slot: 0|1, offset: number}cursor._previousSlotgetter.Key Features
recorder.postDuration(seconds)Changes
Type of change
Related issues