fix(web): avoid duplicate audiobook playback starts - #744
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Included review availability: 4 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour. 📝 WalkthroughWalkthroughAudiobook playback now waits for browser codec capability detection to settle before requesting a playback session. Test coverage verifies that pending detection causes no request and that playback starts once after detection resolves. The feature changelog documents this behavior. ChangesAudiobook playback initialization
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized change prevents duplicate audiobook playback starts while preserving existing cleanup behavior, with regression coverage and validation completed; no actionable merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 unsupported.) ✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6318c49c66
ℹ️ 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".
| playbackAttemptIdRef.current = null; | ||
| return; | ||
| } | ||
| if (!capabilitiesSettled) return; |
There was a problem hiding this comment.
Keep the active session alive while the probe refreshes
When a display-route matchMedia change invokes useCodecDetection.refresh, it first publishes settled: false and may leave decodingInfo() pending. This dependency change runs the previous effect's cleanup—deleting the active playback session—before this early return, while no replacement starts until the probe settles. Moving the browser between HDR and SDR displays can therefore interrupt a playing audiobook for the duration of a slow probe, or indefinitely if it stalls; retain the active session until the final capabilities are available.
AGENTS.md reference: AGENTS.md:L62-L64
Useful? React with 👍 / 👎.
Summary
Cause
Commit
4b6c05e18in PR #634 made the shared codec probe publish an explicit unsettled state and a final settled state. The video player waited for the final state, but the audiobook hook still started on every capability object change. One render therefore issued threePOST /playback/startrequests in CI.This change applies the same settled gate to audiobook startup while preserving the existing cleanup when no active file exists.
Validation
Passed:
pnpm exec vitest run src/pages/audiobooks/player/useAudiobookPlayback.test.ts— 16 testspnpm run lint— 0 errors; 155 existing warningspnpm run format:checkpnpm run buildmake test-web— 285 files, 2,067 testsgo build ./...gofmtcheckgo vet ./...golangci-lint run --new-from-merge-base="origin/main" ./...— 0 issuesmake verify-settings-bindings-allmake verify-playback-fixturesmake verify-local-pathsmake test-gocompleted all packages except two existing macOS process-lock tests ininternal/jellycompat:TestBeginWebOperationRecoversDeadProcessLockandTestBeginWebOperationRejectsLiveProcessLock. Both failures reproduce unchanged in a detached cleanorigin/mainworktree. The main-branch GitHub Actions Go job ata0a31e891passed on Linux.Manual browser playback was not run; the session-start lifecycle is covered at hook level.
Related issue: N/A — narrow regression after #634
AI Disclosure
Summary by CodeRabbit
Bug Fixes
Tests
Documentation