Repository navigation
feat(playback): adopt platform-neutral protocol v3 - #131
Conversation
Recover the exact six-file uncommitted worktree state from dev-builder so the interrupted platform-neutral playback v3 port can continue in an isolated local Codex worktree. This is an intentionally incomplete local checkpoint, not a finished implementation.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughPlayback Protocol V3 now drives iOS playback negotiation, session adoption, renewal, replanning, quality selection, subtitle handling, capability reporting, and conformance testing. Loopback playback supports video-only sessions and expanded audio container claims. ChangesPlayback Protocol V3
Estimated code review effort: 5 (Critical) | ~90+ minutes Sequence Diagram(s)sequenceDiagram
participant PlayerViewModel
participant PlaybackSessionBridge
participant PlaybackProtocolV3
participant ApplePlaybackV3PlanAdapter
PlayerViewModel->>PlaybackSessionBridge: startSession with subtitle intent and preferences
PlaybackSessionBridge->>PlaybackProtocolV3: send capability-rich start request
PlaybackProtocolV3-->>PlaybackSessionBridge: return playable plan and server qualities
PlaybackSessionBridge->>ApplePlaybackV3PlanAdapter: adapt the V3 plan
ApplePlaybackV3PlanAdapter-->>PlayerViewModel: return prepared playback and subtitle inventory
PlayerViewModel->>PlaybackSessionBridge: request quality, subtitle, or seek replan
PlaybackSessionBridge->>PlaybackProtocolV3: send operation-specific replan
PlaybackProtocolV3-->>PlayerViewModel: return replacement plan and output context
Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
Quick104
left a comment
There was a problem hiding this comment.
Code review — 10 confirmed findings
Review method: 8 independent finder angles over the full diff, candidates deduped, then each survivor adversarially verified against the PR-head code and the pinned server commit (63247a36) in the sibling silo-server checkout. Everything below is CONFIRMED (not speculative), ranked most severe first.
1. Intent replans are sent as failure_recovery — track/quality switches terminally kill playback
iosApp/iosApp/Screens/Player/PlayerViewModel.swift:1610
attemptProtocolV3Replan defaults operation: String = "failure_recovery". The bridge only consults the new replanOperation(forClassification:) mapper when operation is nil — which never happens, since the ViewModel always passes the non-nil default. All four intent call sites (quality 4354, audio 5388, subtitle 5415/5439) omit operation, so:
isIntent == false→ a fabricatedfailureblock is attached to a deliberate user action;invalidatesIntent == false→attemptedPlanKeysaccumulate andattemptCountincrements (onmain, these reset via the classification list).
Concretely: switching audio A→B→A returns the original plan whose plan_attempt_key is already in attemptedPlanKeys → replan_loop_detected terminal → finalizeTerminalPlaybackError kills playback on a plain track toggle. Independently, the 8th track/quality switch in one sitting trips the attemptCount < 8 guard → attempt_limit_reached. The new testIntentReplansCarryNoFailureAndUseNeutralOperations only exercises the static mapper, never this wiring.
Fix: default the ViewModel parameter to nil (matching the bridge) or pass the mapped operation explicitly.
2. Audiobook/music playback is broken: audio player still posts the legacy start body
iosApp/iosApp/Screens/Audio/AudioPlayerViewModel.swift:244
AudioPlayerViewModel.startSession still POSTs a legacy StartPlaybackRequest (no protocol_version field) to /api/v1/playback/start. At the pinned server commit, HandleStartPlayback rejects any body whose protocol_version is not 3 with HTTP 426 (LegacyUpgradeErrorV3), and there is no legacy sibling route. Every audiobook/music start fails on both iOS and tvOS against the coordinated server.
Migration nuance: the client's disableProgressPersistence: true (sent for audiobooks so file-local positions don't clobber the book-level resume point kept via /sync/progress) has no client-supplied v3 equivalent. The server derives it only for multipart files (PresentationPartTotal > 1); the single-file audiobook case regresses under a naive port — this needs server-side coordination.
3. macOS: all-false HDR claim makes the server terminally refuse every HDR title
iosApp/iosApp/Screens/Player/ProtocolV3/ApplePlaybackV3Capabilities.swift:250
The macOS branch now reports hdr10/hdr10Plus/hlg = false, no DV profiles (was true/true/true + DV 8 on main). The pinned server gives output HDR evidence precedence, and with no HDR claim, no DV route, and no tone-map recipe installed, planVideoTranscodeV3 terminates with hdr_transcode_unsupported for every non-SDR source (plan_v3.go:601, mirrored by the server's own test). Net: macOS goes from direct-playing HDR titles to a hard terminal error on all of them — unmentioned in the PR.
The comment's premise ("macOS does not expose AVPlayer.availableHDRModes") is true but incomplete: AVPlayer.eligibleForHDRPlayback (macOS 10.15+) and NSScreen EDR headroom exist for exactly this attestation. Also note availableHDRModes is deprecated as of iOS/tvOS 26 — the project's minimum — so eligibleForHDRPlayback would serve all three platforms uniformly.
4. System-caption subtitle policy (#122/#124) is disabled for all online playback
iosApp/iosApp/Screens/Player/PlayerViewModel.swift:3321
adoptProtocolV3RenewalIntent unconditionally sets hasExplicitSubtitleChoice = true, prefsForCurrentItem = nil, prefsResolvedForCurrentItem = true — immediately after beginFreshLoad computed the system-caption snapshot (3489–3493), and before the player opens. Since v3 is now the only online path, the guards at 7540 (applyAutoSubtitlePreferencesIfNeeded), 7570 (reapplySystemSubtitlePolicy), 1222 (caption-change observer), and 7417 (forced-sidecar auto-select) become unreachable for every server-backed playback.
The plan being deferred to can't compensate: initialProtocolV3SubtitleIntent builds its resolver inputs from watchDetail.effectiveSubtitle* only and never passes additionalPreferredLanguages / forcedOnly / preferAccessibilityTracks / disableWhenNoLanguageMatch — exactly the fields systemCaptionPrefsSnapshot() populates. SubtitleMode has no system case, so there is no server-side escape hatch. A user with "match system captions" + SDH/language prefs gets no track selected, and mid-playback caption-setting changes are ignored.
5. Seek-reanchor replans carry a failure block the vendored contract forbids
iosApp/iosApp/Screens/Player/PlaybackSessionBridge.swift:940
failure: is only nil'd for isIntent (track/quality change). A seek reanchor therefore ships failure: {classification: "seek_reanchor", …} — not a failure-taxonomy member — while all nine vendored replan vectors including seek_reanchor omit failure, PlaybackProtocolV3ConformanceFixtureTests.swift:101 asserts "track, quality, and seek-reanchor intent vectors must omit failure", and the PR description claims the same. The live client violates the contract its own tests vendored, on every out-of-window seek.
Fix: omit failure when operation == seekReanchor too.
6. Embedded-source sidecar inventory items produce duplicate subtitle rows and a double-apply
iosApp/iosApp/Screens/Player/ProtocolV3/ApplePlaybackV3PlanAdapter.swift:94 (+ PlayerViewModel.swift:1033)
playbackSession now emits a SubtitleUrl for every inventory item with delivery == "sidecar", including source == "embedded" ones (the PR's own decision_response.json shape: combined_index 1/2). subtitleUrlsForCurrentRoute only filters when activeRouteUsesEmbeddedAVPlayerSubtitleExtraction is true — false for .playerCoreDirect, the route original_http resolves to. PlayerCore enumerates the container's subtitle streams and appendSidecarTracks appends the same tracks as sidecar rows (no overlap check; the codec-ranked sort doesn't even keep the twins adjacent) → each embedded track appears twice in the menu.
Relatedly, adoptingProtocolV3Intent sets both pendingSubtitleFfIndex and pendingSidecarSubtitleTrackId for such items (the guards aren't mutually exclusive), and neither consumer clears the other's pending state: the embedded decoder is selected via applyTrackList, then torn down and replaced by the sidecar fetch — subtitle flicker plus a redundant network fetch on every V3 adopt/renewal.
Fix: give an embedded-sidecar item one identity per route — filter sidecar URLs on routes that enumerate container streams, or pick exactly one of ffIndex/sidecarTrackId in adoptingProtocolV3Intent.
7. AI-subtitle handoff and provider subtitle search break on media with zero subtitle tracks
iosApp/iosApp/Screens/Player/PlayerViewModel.swift:5662
The new guard … !inventory.isEmpty else { return nil } turns a correct baseTrackCount == 0 into a nil context. The pinned server always encodes a no-subtitle file's inventory as [] (never null, per subtitle_inventory_v3.go), and transcription is routed precisely when no text subtitle source exists — so the most common transcription input now soft-fails at handoff ("Translation finished but the track couldn't be added.") until the session restarts. The same nil context breaks downloadSearchedSubtitle on no-subtitle files. The old code (max(index) ?? -1) + 1 == 0) handled this correctly.
Fix: drop the !inventory.isEmpty clause; an empty inventory legitimately yields baseTrackCount = 0.
8. PlaybackV3AvailableQuality.height is non-optional — the canonical audio-only vector cannot decode
iosApp/iosApp/Screens/Player/ProtocolV3/PlaybackProtocolV3Models.swift:395
The vendored corpus's audio_only_original planner scenario omits height from available_qualities. Production decodes with synthesized Codable + convertFromSnakeCase, so that plan's entire decision response throws keyNotFound — and the conformance test hides it by mirroring the field as height: Int? in its own private struct (PlaybackProtocolV3ConformanceFixtureTests.swift:240). Latent today only because of finding 2; the moment audio migrates to v3 (or a server omits height on any rung), start throws instead of playing. Same class of gap the PR itself guarded for source.durationSeconds.
Fix: make height optional, and have the conformance test decode the production model rather than a lenient mirror.
9. Deleted 404/405 catch: old servers now surface a raw HTTP error instead of the upgrade message
iosApp/iosApp/Screens/Player/PlaybackSessionBridge.swift:583
A pre-v3 server has no /api/v1/playback/capability route, so the probe throws HTTPError.http(404, …) out of stageProtocolV3Start before the guard protocolV3Available == true that produces the new "Update the server to continue." terminal is ever reached. The exact population the message was written for sees "HTTP 404" instead — and protocolV3Available stays nil, so every start re-probes.
Fix: restore the 404/405 catch, set protocolV3Available = false, and let the existing guard throw the friendly terminal failure.
10. adoptSession is dead code — diagnostics reports lose playback session IDs
iosApp/iosApp/Screens/Player/PlaybackSessionBridge.swift:287
All three callers were deleted with the legacy paths; adoptProtocolV3Start assigns sessionId/currentSession directly. RecentSessionTracker.shared.record(sessionID:) (its only production call site is inside the dead function) and the "playback session adopted" breadcrumb never run, so every manual and crash/abnormal-exit diagnostics report now ships an empty playbackSessionIDs — playback bugs can no longer be correlated to server sessions. Secondary: the new renewDirectSession dropped the consecutiveProgressFailures = 0 / emittedOrphanedSessionWarning = false resets, so the orphaned-session escalation stays latched across a successful silent renewal until the next good progress tick.
Fix: fold the tracker/breadcrumb side effects into adoptProtocolV3Start and delete adoptSession.
Below the cut (verified, lower tier — happy to detail)
Cleanup-grade items that lost to the correctness findings above: route-event telemetry POSTs are awaited serially on the seek/replan critical path (2–3 extra RTTs per seek); the capability snapshot hand-rolls decode limits and silently drops the shared AppleDecodeCapabilities vocabulary (MPEG-2 claim diverges on device; the sim-only test can't see it); the four-delivery string allowlist is duplicated across ~7 sites while the new DeliveryClass constants go unused; restartCurrentTranscodeHLSForSeek is now unreachable-as-success for seeks (its guard bails on the only condition that reaches it) and logs a misleading warning; the "adopt prepared plan" state block is copy-pasted at four sites with divergent field subsets; server quality labels outside the local catalog are silently normalized to auto and dropped from the in-player menu; and the new Tests/Fixtures/PlaybackV3 set relies on XcodeGen inference instead of the explicit buildPhase declarations the SettingsContract precedent uses.
Review ran at high effort: 8 finder angles × up to 6 candidates, deduped, 1-vote adversarial verification per survivor; all 10 reported findings are CONFIRMED.
🤖 Generated with Claude Code
|
Addressed the full Quick104 correctness review at Apple head Resolved findings:
Contract parity:
Validation:
The only emitted warnings were existing actor-isolation, lock, deprecation, alignment, and AppIntents warnings outside this patch. |
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
iosApp/iosApp/Screens/Player/ProtocolV3/ApplePlaybackV3Capabilities.swift (1)
134-165: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy liftProgressive and HLS deliveries advertise a codec that AVPlayer cannot decode.
videoCodecsis nowvideoDecode.map(\.codec)(Line 40), andvideoDecodeAttestation()appendsAppleDecodeCapabilities.mpeg2VideoCodecwithdecoderName: "FFmpeg"on device (Lines 217-228). The same list is then reported for all three delivery classes.MPEG-2 is decodable only through the bundled FFmpeg loopback executor, which is exposed on
originalHTTP(apple_local_loopback,apple_playercore). Theprogressiveandhlsclasses expose AVPlayer only. If the server selectsserver_remux_progressiveor a remux HLS route with copied MPEG-2 video, the AVPlayer route cannot decode it and playback fails.Report the FFmpeg-only codec on the
originalHTTPclass only.🐛 Proposed fix to scope the software-decoded codec to the loopback delivery
let videoDecode = videoDecodeAttestation() let videoCodecs = videoDecode.map(\.codec) let hardwareVideoCodecs = videoDecode.filter(\.hardware).map(\.codec) + // AVPlayer-only deliveries cannot use the bundled FFmpeg software path. + let avPlayerVideoCodecs = videoDecode.filter(\.hardware).map(\.codec)PlaybackProtocolV3.DeliveryClass.progressive: PlaybackV3DeliveryCapability( ... containers: ["mp4", "mov", "m4v"], - videoCodecs: videoCodecs, + videoCodecs: avPlayerVideoCodecs,PlaybackProtocolV3.DeliveryClass.hls: PlaybackV3DeliveryCapability( ... containers: ["hls", "mpegts", "fmp4", "mp4"], - videoCodecs: videoCodecs, + videoCodecs: avPlayerVideoCodecs,🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@iosApp/iosApp/Screens/Player/ProtocolV3/ApplePlaybackV3Capabilities.swift` around lines 134 - 165, Restrict the software-decoded MPEG-2 codec to the originalHTTP capability, which exposes the FFmpeg loopback executor. In the delivery capability definitions, keep the full videoCodecs list for originalHTTP but filter out AppleDecodeCapabilities.mpeg2VideoCodec for the progressive and hls classes, preserving their AVPlayer-compatible codec advertisements.
🧹 Nitpick comments (3)
iosApp/Tests/PlaybackProtocolV3Tests.swift (1)
624-665: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winGate the simulator-specific capability assertions.
The test name states simulator expectations, but the body never checks the environment.
snapshot()derivescodecsVideofromvideoDecodeAttestation()andhdrfrom the live output snapshot. On a physical device the codec list includes HEVC andhdrcan be true, so lines 644-645 and line 651 fail. Add an explicit simulator guard so a device test run reports "skipped" instead of a false failure.♻️ Proposed guard
func testSimulatorCapabilitiesAreNeutralAttestedAndOutputScoped() throws { + try XCTSkipUnless( + AppleDecodeCapabilities.isSimulator, + "Attested codec and HDR values are device-specific; this vector pins the simulator profile." + ) let snapshot = ApplePlaybackV3Capabilities.snapshot()🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@iosApp/Tests/PlaybackProtocolV3Tests.swift` around lines 624 - 665, Add an explicit simulator-only guard at the start of testSimulatorCapabilitiesAreNeutralAttestedAndOutputScoped, using the test environment’s existing simulator detection and reporting the test as skipped when running on a physical device. Keep the current capability assertions unchanged for simulator runs.iosApp/Tests/PlaybackProtocolV3ConformanceFixtureTests.swift (1)
153-168: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDuplicated fixture-loading helpers in both Playback V3 test suites. Both suites define an identical snake-case
JSONDecoder,fixtureURL(named:), anddecodeFixture(_:named:). One shared helper keeps the bundle lookup and the decoding strategy in a single place.
iosApp/Tests/PlaybackProtocolV3ConformanceFixtureTests.swift#L153-L168: remove the localdecoder,fixtureURL(named:), anddecodeFixture(_:named:)and call the shared helper.iosApp/Tests/PlaybackProtocolV3Tests.swift#L829-L851: remove the same three members and keep only the suite-specificencoder,fixtureObject(named:),fixtureArray(named:), andencodedObject(_:).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@iosApp/Tests/PlaybackProtocolV3ConformanceFixtureTests.swift` around lines 153 - 168, Consolidate the duplicated fixture-loading helpers by removing decoder, fixtureURL(named:), and decodeFixture(_:named:) from iosApp/Tests/PlaybackProtocolV3ConformanceFixtureTests.swift lines 153-168 and iosApp/Tests/PlaybackProtocolV3Tests.swift lines 829-851, then update both suites to use the shared helper; retain only encoder, fixtureObject(named:), fixtureArray(named:), and encodedObject(_:) in PlaybackProtocolV3Tests.swift.iosApp/iosApp/Screens/Audio/AudioPlayerViewModel.swift (1)
16-16: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winShare the V3 capability gate with
PlaybackSessionBridge.This block duplicates
PlaybackSessionBridge.stageProtocolV3Start(Lines 617-637 ofiosApp/iosApp/Screens/Player/PlaybackSessionBridge.swift), including the cached flag, the 404/405 handling, and theserver_upgrade_requiredmessage. The two caches are independent, so the app probes/api/v1/playback/capabilityonce per view model instead of once per server.Extract one shared, actor-isolated capability gate and call it from both sites. That removes the duplicated terminal message and the second probe.
Also applies to: 244-262
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@iosApp/iosApp/Screens/Audio/AudioPlayerViewModel.swift` at line 16, Replace the separate protocolV3Available cache and duplicated capability-check logic in AudioPlayerViewModel and PlaybackSessionBridge.stageProtocolV3Start with one shared actor-isolated V3 capability gate. Centralize the capability probe, cached result, 404/405 handling, and server_upgrade_required terminal message, then have both call sites reuse that gate so each server is probed only once.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@iosApp/iosApp/Screens/Player/PlayerViewModel.swift`:
- Around line 7700-7720: Update replanAutomaticProtocolV3SubtitleSelection to
return true only when attemptProtocolV3Replan admits and starts the replan; when
protocolV3ReplanTask is already active or currentWatchDetail is unavailable,
return false before mutating selectedSubtitleId or the preferred subtitle index
so applyAutoSubtitle can execute its local fallback.
- Around line 5060-5069: Update the playback preparation flow around
adoptProtocolV3RenewalIntent so selectedSubtitleSnapshot is only restored to
pendingSidecarSubtitleTrackId when protocolV3.plan.subtitle.mode is "render";
preserve the V3 plan’s burn_in and off modes without re-enabling a sidecar, and
add a regression test covering this restoration path.
In `@iosApp/Tests/Fixtures/PlaybackV3/SOURCE`:
- Line 6: Update the regeneration instruction in the SOURCE fixture to
explicitly run XcodeGen from the iosApp working directory, using the established
`cd iosApp && xcodegen generate` command after refreshing the files.
---
Outside diff comments:
In `@iosApp/iosApp/Screens/Player/ProtocolV3/ApplePlaybackV3Capabilities.swift`:
- Around line 134-165: Restrict the software-decoded MPEG-2 codec to the
originalHTTP capability, which exposes the FFmpeg loopback executor. In the
delivery capability definitions, keep the full videoCodecs list for originalHTTP
but filter out AppleDecodeCapabilities.mpeg2VideoCodec for the progressive and
hls classes, preserving their AVPlayer-compatible codec advertisements.
---
Nitpick comments:
In `@iosApp/iosApp/Screens/Audio/AudioPlayerViewModel.swift`:
- Line 16: Replace the separate protocolV3Available cache and duplicated
capability-check logic in AudioPlayerViewModel and
PlaybackSessionBridge.stageProtocolV3Start with one shared actor-isolated V3
capability gate. Centralize the capability probe, cached result, 404/405
handling, and server_upgrade_required terminal message, then have both call
sites reuse that gate so each server is probed only once.
In `@iosApp/Tests/PlaybackProtocolV3ConformanceFixtureTests.swift`:
- Around line 153-168: Consolidate the duplicated fixture-loading helpers by
removing decoder, fixtureURL(named:), and decodeFixture(_:named:) from
iosApp/Tests/PlaybackProtocolV3ConformanceFixtureTests.swift lines 153-168 and
iosApp/Tests/PlaybackProtocolV3Tests.swift lines 829-851, then update both
suites to use the shared helper; retain only encoder, fixtureObject(named:),
fixtureArray(named:), and encodedObject(_:) in PlaybackProtocolV3Tests.swift.
In `@iosApp/Tests/PlaybackProtocolV3Tests.swift`:
- Around line 624-665: Add an explicit simulator-only guard at the start of
testSimulatorCapabilitiesAreNeutralAttestedAndOutputScoped, using the test
environment’s existing simulator detection and reporting the test as skipped
when running on a physical device. Keep the current capability assertions
unchanged for simulator runs.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f609d7a6-885e-4b9f-b034-c6548c657615
📒 Files selected for processing (23)
iosApp/Tests/DetailVersionSelectionTests.swiftiosApp/Tests/Fixtures/PlaybackV3/SOURCEiosApp/Tests/Fixtures/PlaybackV3/attempt_keys.jsoniosApp/Tests/Fixtures/PlaybackV3/capability_response.jsoniosApp/Tests/Fixtures/PlaybackV3/conformance_matrix.jsoniosApp/Tests/Fixtures/PlaybackV3/decision_response.jsoniosApp/Tests/Fixtures/PlaybackV3/error_response.jsoniosApp/Tests/Fixtures/PlaybackV3/replan_request.jsoniosApp/Tests/Fixtures/PlaybackV3/route_event.jsoniosApp/Tests/Fixtures/PlaybackV3/start_request.jsoniosApp/Tests/Fixtures/PlaybackV3/subtitle_inventory.jsoniosApp/Tests/PlaybackProtocolV3ConformanceFixtureTests.swiftiosApp/Tests/PlaybackProtocolV3Tests.swiftiosApp/iosApp/Screens/Audio/AudioPlayerViewModel.swiftiosApp/iosApp/Screens/Audio/AudiobookPlaybackContext.swiftiosApp/iosApp/Screens/Player/ApplePlaybackQuality.swiftiosApp/iosApp/Screens/Player/PlaybackSessionBridge.swiftiosApp/iosApp/Screens/Player/PlayerViewModel.swiftiosApp/iosApp/Screens/Player/ProtocolV3/ApplePlaybackV3Capabilities.swiftiosApp/iosApp/Screens/Player/ProtocolV3/ApplePlaybackV3PlanAdapter.swiftiosApp/iosApp/Screens/Player/ProtocolV3/PlaybackProtocolV3Models.swiftiosApp/iosApp/Screens/Player/Subtitles/SubtitleAIController.swiftiosApp/project.yml
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3706d5a100
ℹ️ 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".
|
Addressed #134 at What changed:
Validation:
Existing warnings were unchanged diagnostics, SwiftUI deprecation, lock-result, and linker-alignment warnings outside this patch. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b36267f44e
ℹ️ 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.
Actionable comments posted: 2
🧹 Nitpick comments (1)
iosApp/iosApp/Screens/Player/PlaybackExecutionPlan.swift (1)
116-132: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider renaming the
nonesentinel to avoid shadowingOptional.none.
SelectedAudio.nonecollides withOptional.nonewherever the contextual type isSelectedAudio?. Every current assignment site declares a non-optionallet selectedAudio: LoopbackSessionSpec.SelectedAudio, so resolution is unambiguous today.The hazard is in comparisons.
XCTAssertEqual(plan.loopbackSession?.selectedAudio, .none)compares againstnilinstead of the sentinel and passes whenloopbackSessionis nil.PlaybackMediaFixtureTests.testAppleLoopbackRouteSupportsVideoOnlyDolbyVisionavoids this only because it spells outLoopbackSessionSpec.SelectedAudio.none.A name such as
absentremoves the ambiguity.♻️ Proposed rename
- static let none = SelectedAudio( + static let absent = SelectedAudio( trackIndex: -1, ffIndex: nil, sourceCodec: nil, sourceChannelCount: nil, sourceChannelLayout: nil, outputMode: .copy, preservesAtmos: false )Update the assignment sites in
ApplePlaybackRoutePlanner.swift(Line 403),PlayerViewModel.swift(Line 7205), and the assertion inPlaybackMediaFixtureTests.swift.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@iosApp/iosApp/Screens/Player/PlaybackExecutionPlan.swift` around lines 116 - 132, Rename the `SelectedAudio.none` sentinel to `SelectedAudio.absent` to avoid ambiguity with `Optional.none`. Update its declaration and all references, including assignment sites in `ApplePlaybackRoutePlanner` and `PlayerViewModel`, plus the assertion in `PlaybackMediaFixtureTests`, preserving the sentinel’s existing semantics.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@iosApp/iosApp/Screens/Player/PlayerViewModel.swift`:
- Around line 5316-5322: Update the restoration logic around
armAdoptedProtocolV3TrackIntent to use protocolV3SidecarRestoreIntent, matching
attemptProtocolV3Replan and requiring the snapshot subtitle index to match
plan.selectedTracks.subtitle?.index before assigning
pendingSidecarSubtitleTrackId. If protocolV3RestoredSidecarTrackId becomes
unused, remove that helper and its associated test.
In `@iosApp/iosApp/Screens/Player/Subtitles/SidecarSubtitleFetcher.swift`:
- Around line 109-144: Update fetchFontBundle to reject oversized font-bundle
responses before buffering or decoding, using a defined maximum size and
validating Content-Length when available; enforce the same limit during body
retrieval or stream the response if necessary. Bound fontBundleCache with a
total byte limit and eviction policy, tracking each attachment bundle’s decoded
size and removing entries as needed so cached bundles cannot grow without limit.
---
Nitpick comments:
In `@iosApp/iosApp/Screens/Player/PlaybackExecutionPlan.swift`:
- Around line 116-132: Rename the `SelectedAudio.none` sentinel to
`SelectedAudio.absent` to avoid ambiguity with `Optional.none`. Update its
declaration and all references, including assignment sites in
`ApplePlaybackRoutePlanner` and `PlayerViewModel`, plus the assertion in
`PlaybackMediaFixtureTests`, preserving the sentinel’s existing semantics.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 025c2278-c7e1-48b7-8cb9-f1efe1b87b21
📒 Files selected for processing (16)
iosApp/Tests/Fixtures/PlaybackV3/SOURCEiosApp/Tests/PlaybackMediaFixtureTests.swiftiosApp/Tests/PlaybackProtocolV3Tests.swiftiosApp/iosApp/Networking/Models.swiftiosApp/iosApp/Screens/Audio/AudioPlayerViewModel.swiftiosApp/iosApp/Screens/Player/AVPlayerRoute/AVPlayerBackend.swiftiosApp/iosApp/Screens/Player/ApplePlaybackQuality.swiftiosApp/iosApp/Screens/Player/ApplePlaybackRoutePlanner.swiftiosApp/iosApp/Screens/Player/PlaybackExecutionPlan.swiftiosApp/iosApp/Screens/Player/PlaybackSessionBridge.swiftiosApp/iosApp/Screens/Player/PlayerView.swiftiosApp/iosApp/Screens/Player/PlayerViewModel.swiftiosApp/iosApp/Screens/Player/ProtocolV3/ApplePlaybackV3Capabilities.swiftiosApp/iosApp/Screens/Player/ProtocolV3/ApplePlaybackV3PlanAdapter.swiftiosApp/iosApp/Screens/Player/Subtitles/SidecarSubtitleFetcher.swiftiosApp/iosApp/Screens/Player/Subtitles/SubtitleSession.swift
🚧 Files skipped from review as they are similar to previous changes (6)
- iosApp/Tests/Fixtures/PlaybackV3/SOURCE
- iosApp/iosApp/Screens/Player/ProtocolV3/ApplePlaybackV3Capabilities.swift
- iosApp/iosApp/Screens/Player/ProtocolV3/ApplePlaybackV3PlanAdapter.swift
- iosApp/iosApp/Screens/Player/ApplePlaybackQuality.swift
- iosApp/iosApp/Screens/Player/PlaybackSessionBridge.swift
- iosApp/Tests/PlaybackProtocolV3Tests.swift
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e4c28de98d
ℹ️ 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.
💡 Codex Review
When a server advertises plan_source_duration_v1 but returns duration_seconds: null because the effective source duration is unknown, this fallback substitutes the catalog version's potentially stale duration. PlayerViewModel then treats that guess as authoritative for the displayed timeline and seek clamping, which can prevent access to content beyond the stale endpoint or report completion prematurely. Pass the negotiated server features into this conversion and use the catalog fallback only when the server lacks the duration feature.
ℹ️ 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".
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Review closeout —
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
iosApp/Tests/SidecarSubtitleFetcherTests.swift (1)
70-99: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExercise cache recency before asserting LRU eviction.
Each bundle decodes to two bytes, and the cache limit is two bytes. The second insertion must evict the first entry regardless of
markFontBundleRecentlyUsed(_:). A regression in recency tracking will still pass this test.Use a four-byte cache with three URLs. Fetch the first URL again before inserting the third URL. Then verify that the second URL is evicted and the first URL remains cached.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@iosApp/Tests/SidecarSubtitleFetcherTests.swift` around lines 70 - 99, Update testFontBundleCacheEvictsLeastRecentlyUsedEntryByDecodedBytes to use a four-byte cache and add a third URL. Fetch the first URL, then the second, fetch the first again to refresh recency, and insert the third; assert the second URL is requested twice while the first remains at two requests, confirming true LRU eviction.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@iosApp/iosApp/Screens/Player/ProtocolV3/ApplePlaybackV3Capabilities.swift`:
- Around line 170-172: Update the HLS capability construction in the ProtocolV3
Apple playback path to advertise only codecs supported by AVPlayer. Derive the
value from AppleDecodeCapabilities.videoCodecs while excluding
AppleDecodeCapabilities.mpeg2VideoCodec, leaving the broader codec list
unchanged for PlayerCore-only delivery.
---
Nitpick comments:
In `@iosApp/Tests/SidecarSubtitleFetcherTests.swift`:
- Around line 70-99: Update
testFontBundleCacheEvictsLeastRecentlyUsedEntryByDecodedBytes to use a four-byte
cache and add a third URL. Fetch the first URL, then the second, fetch the first
again to refresh recency, and insert the third; assert the second URL is
requested twice while the first remains at two requests, confirming true LRU
eviction.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: bb3b041e-990f-4911-90d7-993b51d338d4
📒 Files selected for processing (18)
iosApp/Tests/Fixtures/PlaybackV3/SOURCEiosApp/Tests/Fixtures/PlaybackV3/capability_response.jsoniosApp/Tests/Fixtures/PlaybackV3/conformance_matrix.jsoniosApp/Tests/Fixtures/PlaybackV3/decision_response.jsoniosApp/Tests/PlaybackMediaFixtureTests.swiftiosApp/Tests/PlaybackProtocolV3ConformanceFixtureTests.swiftiosApp/Tests/PlaybackProtocolV3Tests.swiftiosApp/Tests/PlaybackV3FixtureTestSupport.swiftiosApp/Tests/SidecarSubtitleFetcherTests.swiftiosApp/iosApp/Screens/Audio/AudioPlayerViewModel.swiftiosApp/iosApp/Screens/Player/ApplePlaybackRoutePlanner.swiftiosApp/iosApp/Screens/Player/PlaybackCoordinator.swiftiosApp/iosApp/Screens/Player/PlaybackExecutionPlan.swiftiosApp/iosApp/Screens/Player/PlaybackSessionBridge.swiftiosApp/iosApp/Screens/Player/PlayerViewModel.swiftiosApp/iosApp/Screens/Player/ProtocolV3/ApplePlaybackV3Capabilities.swiftiosApp/iosApp/Screens/Player/ProtocolV3/ApplePlaybackV3PlanAdapter.swiftiosApp/iosApp/Screens/Player/Subtitles/SidecarSubtitleFetcher.swift
🚧 Files skipped from review as they are similar to previous changes (11)
- iosApp/Tests/Fixtures/PlaybackV3/SOURCE
- iosApp/Tests/PlaybackMediaFixtureTests.swift
- iosApp/Tests/Fixtures/PlaybackV3/decision_response.json
- iosApp/Tests/Fixtures/PlaybackV3/capability_response.json
- iosApp/iosApp/Screens/Audio/AudioPlayerViewModel.swift
- iosApp/iosApp/Screens/Player/ApplePlaybackRoutePlanner.swift
- iosApp/iosApp/Screens/Player/ProtocolV3/ApplePlaybackV3PlanAdapter.swift
- iosApp/iosApp/Screens/Player/PlaybackSessionBridge.swift
- iosApp/iosApp/Screens/Player/PlayerViewModel.swift
- iosApp/Tests/PlaybackProtocolV3Tests.swift
- iosApp/iosApp/Screens/Player/PlaybackCoordinator.swift
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Post-review follow-up —
|
Problem
Part of Silo-Server/silo-server#135
The Apple player still implemented the platform-shaped playback-v3 draft and hard-coded old attempt tokens in contract tests. That left iOS, tvOS, and macOS without an exact executable binding to the server-owned neutral contract used by the web and Android clients.
Approach
failure, while real recovery requests carry a classification.Coordinated release train:
Risks and follow-up
Testing
ce2f3e6df084f52c62595db8e3011f55c3a925ef.git diff --check: passed.Review closeout (
a1eb44b)AI Disclosure
Summary by CodeRabbit
New Features
Bug Fixes
Issue #134 remediation
Fixes #134