Repository navigation
feat(playback): share v2 playback capabilities and installation id - #376
Conversation
There was a problem hiding this comment.
Quick104 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Code review summaryReviewed head: Process: an adversarial review of this PR's diff with each candidate finding independently verified before any fix, a simplify pass for medium and larger PRs, and a whole-stack review across contract conformance, authority and failure handling, data integrity, user-visible behavior and cross-PR integration. Verified findings, all fixed on this branch:
Validation: this branch builds on its own for iOS, tvOS and macOS, and its focused tests passed. The completed stack passed the full iOS suite (1981 tests) and tvOS suite (1792 tests) with 0 failures, the macOS build and the v1 path guard. The final stack was also exercised on iOS and tvOS simulators against a v1/v2 bridge server: sign-in (password and QR), restore, browse, search, detail, favorites and watchlist, playback (direct play, transcode, subtitles, stop), audiobooks, downloads with offline playback, settings, requests, profiles, push registration and diagnostics. Server logs showed no Remaining: no open verified findings. Merge in stack order. Mergeability: 8/10 — conditional. The approach holds up and every verified finding is fixed. Conditions: this PR's CI must pass (it was pending at review time), and the owner still plans a physical-device check of the completed stack. Review by Claude Opus 5.5 ( |
ba81959 to
6375069
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6375069b7f
ℹ️ 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".
| let required = [PlaybackProtocolV3.planFeature, PlaybackProtocolV3.neutralContractFeature, | ||
| PlaybackProtocolV3.headerAuthenticatedMediaFeature, PlaybackSequencedContract.feature] | ||
| guard protocolVersions.contains(PlaybackProtocolV3.version), required.allSatisfy(features.contains) else { |
There was a problem hiding this comment.
Accept the v2 capability document the server actually returns
Remove this token from the v2 capability gate or coordinate a server-contract change first. The vendored Tests/Fixtures/APIv2/playback_capability_available.json, sourced from server commit 84ed9e596, does not include header_authenticated_media_v1; the new test manually appends it before exercising this guard. Consequently, an unmodified capability response from that server reaches this check and every video or audiobook start fails with server_upgrade_required, even though the document reports playback as available.
AGENTS.md reference: AGENTS.md:L12-L21
Useful? React with 👍 / 👎.
64e5328 to
0ae7311
Compare
Video and audiobook playback read their capability from GET /api/v1/playback/capability, which has no installation_id. Every v2 playback mutation must echo that id, and the server refuses a stale one with 409 installation_changed, so the v2 session cutover needs one place that owns the id and can refresh it. PlaybackV3CapabilityGate now reads GET /api/v2/playback/capabilities through the shared APIv2Client, under the captured owner. It requires state available, allowed, protocol 3, the neutral plan, header-authenticated media, sequenced progress and a non-empty installation_id, and hands out a non-optional installationID. It still caches only an available capability, per server, and re-probes after a refusal. A v1-only server and a server without a playback installation identity (409 capability_not_configured) become non-retryable terminal failures; the v1-only case shows the shared server-update message. withInstallationRefresh runs a start with the current capability and, on 409 installation_changed, drops the cached capability, probes again and runs the start once more. Both start paths now mint the attempt id and request inside that closure, so a refreshed start always carries a new playback_attempt_id. The starts still go to v1 until the session cutover, so the refresh path is exercised by tests only for now. Deletes SiloAPI.playbackV3Capability, PlaybackV3CapabilityResponse, supportsNeutralProtocolV3, isMissingProtocolV3Capability and the v1 capability_response.json fixture. Stack-PR: W2-A Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
withInstallationRefresh awaits the capability probe, which runs in an unstructured task and does not observe the caller's cancellation. After a 409 installation_changed, a player dismissed or an autoplay start that timed out during the re-probe still ran the start again. Once W2-B moves the starts to v2, that allocates a server session for a player that is already gone. The helper now checks for cancellation after each capability probe and before each start, and throws CancellationError instead. A new gate test cancels the caller while the re-probe is suspended and asserts the start ran once. Stack-PR: W2-A Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
6375069 to
83820f0
Compare
Video and audiobook playback now read their capability from
GET /api/v2/playback/capabilities, through one shared gate that also owns the server'sinstallation_idand refreshes it when the server reports409 installation_changed.Problem
PlaybackV3CapabilityGatereadGET /api/v1/playback/capability(row 78). That document has noinstallation_id. Every v2 playback mutation (start, replan, route-events, progress, stop) must send that id in its body. The server checks it against its persistedServerInstanceIDand refuses a mismatch with409 installation_changed("refresh capabilities"). Before the session cutover (W2-B) can land, one place has to own the id, hand it to both players, and refresh it on that 409.Solution
PlaybackV3CapabilityGatereads the v2 document throughSiloAPI.shared.apiV2Client.playbackCapabilities(auth:), under an owner captured fromTokenStore.playbackRequestfences the request and sendsX-Profile-Id. Video (PlaybackSessionBridge.stageProtocolV3Start) and audiobook (AudioPlayerViewModel.startSession) both use it.APIv2PlaybackCapabilities.requireAvailable()requiresstate == "available",allowed, protocol 3,playback_plan_v3,neutral_playback_v3_contract_v1,header_authenticated_media_v1,sequenced_progress_v1, and a non-emptyinstallation_id.NeutralProtocolV3Capability.installationIDis a non-optionalString(F14). The previous check also used v1enabled, which v2 does not send.serverUpdateRequiredverdict) becomes a non-retryableserver_upgrade_requiredfailure with the shared D7 copy ("This server needs to be updated before this version of Silo can use it."). Missing required features give the same failure and copy, replacing the older TestFlight-specific text.409 capability_not_configuredandstate: not_configuredboth giveplayback_not_configured.installation_changed.withInstallationRefreshruns a start with the current capability. On409 installation_changedit drops the cached capability for that installation, probes again, and runs the start once more. A second refusal is surfaced, so it never loops. The probe runs in its own task and does not see the caller's cancellation, so the helper checks for cancellation before each start: a player dismissed, or an autoplay start that timed out, during the refresh throwsCancellationErrorinstead of starting a session nobody owns. Both start paths now mintplayback_attempt_idand build the request inside the closure, so a refreshed start always gets a new attempt id (I18). The existing same-request retry after a transport error is unchanged and still reuses the same attempt id.SiloAPI.playbackV3Capability(the v1 path),PlaybackV3CapabilityResponse,PlaybackSessionBridge.supportsNeutralProtocolV3,isMissingProtocolV3Capability, the v1Tests/Fixtures/PlaybackV3/capability_response.jsonfixture and its assertions. The fixtureSOURCEnote records why that file is not vendored.This PR writes nothing to the server.
getPlaybackCapabilitiesis a read, so no failure-outcome table applies. The start mutations still use v1 here and move in W2-B.Validation
PlaybackCapabilityGateTests,PlaybackProtocolV3Tests,APIv2ContractTests,PlaybackProtocolV3ConformanceFixtureTestsandUpdateRequirementTests.scripts/ci/check-no-api-v1.shpassed. The ownership-fence line count iniosApp/iosAppstays at 64.PlaybackCapabilityGateTests(onStubURLProtocolthroughAPIv2TestStuband the vendored v2 fixtures) cover:not_configured, and a missinginstallation_idGETto/api/v2/playback/capabilitieswithX-Profile-Id409 capability_not_configuredand the legacy 404 mapping to terminal failures409 installation_changedrefetching and rerunning the start with the new installation, after which the cache holds the new oneinstallation_changedsurfacing instead of loopingCancellationError, with the start run only once. This test fails when the cancellation check is removed.installation_changed, so only the tests above exercise the refresh path on this branch.Risks and follow-ups
GET /api/v2/playback/capabilitiesand the v1 start/progress/stop routes. Bridge servers serve both. A v1-only server now shows the server-update message at Play instead of the old unsupported-server text.sequenced_progress_v1. Server84ed9e596always advertises it (playback_service.go), and W2-B needs it.capability.installationIDin all five mutation bodies, and keep the start insidewithInstallationRefresh. Replan, route-events, progress and stop also returninstallation_changed. Route-events does so even though openapi omits the 409 (S7). This PR does not decide how those in-session calls recover.84ed9e596always returnsallowed: truefor a valid profile, so this matches the previous behavior.AI disclosure
Code and description written by Claude Opus 5.5 (
claude-opus-5-5) agents in Claude Code (T3 Code), orchestrated by a Claude Code workflow.Part 28 of 50 in the Apple API v2 stack. Base:
apiv2-stack/27-progress-reread-v2. Merge in order from the bottom of the stack. The plan and full index are in PR 01.🤖 Generated with Claude Code