fix: avoid false early decode failures#233
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughCentralizes early video-decode end detection into an exported helper Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: de18a2f46f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/lib/exporter/streamingDecoder.test.ts (1)
4-40: Add guard-branch tests forcancelledand empty timeline.The helper has explicit early returns for
cancelledandsegmentsLength === 0, but they are not currently asserted.🧪 Proposed test additions
describe("shouldFailDecodeEndedEarly", () => { + it("does not fail when decode was cancelled", () => { + expect( + shouldFailDecodeEndedEarly({ + cancelled: true, + segmentsLength: 2, + completedSegments: 0, + lastDecodedFrameSec: null, + requiredEndSec: 10, + }), + ).toBe(false); + }); + + it("does not fail for an empty timeline", () => { + expect( + shouldFailDecodeEndedEarly({ + cancelled: false, + segmentsLength: 0, + completedSegments: 0, + lastDecodedFrameSec: null, + requiredEndSec: 0, + }), + ).toBe(false); + }); + it("does not fail once every segment has been satisfied", () => {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/lib/exporter/streamingDecoder.test.ts` around lines 4 - 40, Add two unit tests for shouldFailDecodeEndedEarly to cover the early-return branches: one where cancelled: true (verify it returns false regardless of other fields) and one where segmentsLength: 0 (empty timeline, verify it returns false even if lastDecodedFrameSec is null or requiredEndSec > 0). Locate the helper by its name shouldFailDecodeEndedEarly in streamingDecoder.test.ts and add small it(...) blocks that pass appropriate payloads asserting the expected false result.src/lib/exporter/streamingDecoder.ts (1)
44-44: Replace the hardcoded 1s tolerance with a named constant.Line 44 uses a magic number, which makes future tuning harder and less discoverable.
♻️ Proposed refactor
+const EARLY_DECODE_TOLERANCE_SEC = 1; + export function shouldFailDecodeEndedEarly({ cancelled, segmentsLength, completedSegments, lastDecodedFrameSec, requiredEndSec, }: EarlyDecodeEndCheck): boolean { @@ - return requiredEndSec - lastDecodedFrameSec > 1; + return requiredEndSec - lastDecodedFrameSec > EARLY_DECODE_TOLERANCE_SEC; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/lib/exporter/streamingDecoder.ts` at line 44, Replace the magic numeric literal in the expression "requiredEndSec - lastDecodedFrameSec > 1" with a named constant (e.g., FRAME_END_TOLERANCE_SEC or DECODING_TOLERANCE_SEC) declared at the top of streamingDecoder.ts (module- or file-scope) so the tolerance is discoverable and easy to tune; update the comparison to use that constant and add a brief comment on its units (seconds) where the constant is defined.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/lib/exporter/streamingDecoder.test.ts`:
- Around line 4-40: Add two unit tests for shouldFailDecodeEndedEarly to cover
the early-return branches: one where cancelled: true (verify it returns false
regardless of other fields) and one where segmentsLength: 0 (empty timeline,
verify it returns false even if lastDecodedFrameSec is null or requiredEndSec >
0). Locate the helper by its name shouldFailDecodeEndedEarly in
streamingDecoder.test.ts and add small it(...) blocks that pass appropriate
payloads asserting the expected false result.
In `@src/lib/exporter/streamingDecoder.ts`:
- Line 44: Replace the magic numeric literal in the expression "requiredEndSec -
lastDecodedFrameSec > 1" with a named constant (e.g., FRAME_END_TOLERANCE_SEC or
DECODING_TOLERANCE_SEC) declared at the top of streamingDecoder.ts (module- or
file-scope) so the tolerance is discoverable and easy to tune; update the
comparison to use that constant and add a brief comment on its units (seconds)
where the constant is defined.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b7ee5dcf-ffe3-4e09-9502-4c23defcfec6
📒 Files selected for processing (2)
src/lib/exporter/streamingDecoder.test.tssrc/lib/exporter/streamingDecoder.ts
Pull Request Template
Description
The problem is a mismatch between:
Motivation
Type of Change
Related Issue(s)
fixes #230
Screenshots / Video
Screenshot (if applicable):
Video (if applicable):
Testing
Checklist
Thank you for contributing!
Summary by CodeRabbit
Tests
Refactor
Bug Fix