Repository navigation
feat(player): play embedded subtitles from the stream and switch them in place - #970
Conversation
… stream A server_remux_hls plan with an embedded text subtitle mounted the inventory sidecar, which the server extracts by reading the whole source file: minutes on network storage before the first cue. The client now sends hls_remux_subtitle_renditions_v1 next to hls_subtitle_renditions_v1, like the base token, in the static feature list (the server ignores it where unknown and strips it on /api/v1). The server then carries the selected track as subtitle.hls_rendition on the remux too. - The plan adapter accepts hls_rendition on server_remux_hls with the same checks as on server_transcode_hls. - The load spec and controller already treat the rendition by delivery class (no sidecar declared, the row resolves to AVPlayer's legible option), so the remote-HLS path plays it as it does a transcode's. - Picking another embedded text track on a remux replans instead of mounting its sidecar, but only when the decision's server_features list the remux token; otherwise the server would answer with the same sidecar and the pick stays local. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… row A mid-play pick of an embedded subtitle on the open file needs the row's FFmpeg stream index. The client derived it by counting embedded catalog tracks against embedded inventory rows, and any disagreement between the two lists named another stream or none. None meant the pick fell back to the inventory sidecar URL: a whole-file server extraction of a track Aether was already demuxing. The row now answers first: its stream_index when the server publishes it (contract C1), else the embedded_stream_index the server puts on every embedded sidecar URL. Ordinal matching remains the last resort, and the reverse lookup no longer maps a stream onto a row that names another one. The picker, the local-switch check, the plan intent and persistence all read the same resolution. container_track_id and native_selectable are decoded too; all three are optional, so plans from servers without them decode as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tream
On a server HLS plan only the selected embedded text track came in the
stream. Picking another one replanned and restarted the transcode or
remux, or mounted its sidecar, which the server extracts by reading the
whole source file.
A server that advertises hls_subtitle_renditions_all_v1 now gets it in
the start request, and every replan of the attempt repeats it. The
server then lists every cue-indexed embedded text track as a WebVTT
rendition of the stream, and each inventory row carries hls_rendition
{group_id, name, index}.
- Every listed row is a legible option of the stream. Rows match
AVPlayer's options by playlist NAME, read from each option's
m3u8/NAME metadata (displayName is a localized language name) and
kept for the item, and by the 1-based index until the names are read.
A pick made before its option appears waits for that row, and the
plan's selected rendition is the one playback starts on.
- A pick among those rows, or Off, switches the media selection at once,
then reports the change with a subtitle_track_changed replan that
shows no loading state. While one report is out, the next pick also
applies at once and its report waits, latest wins; the first answer
never selects over it. An answer that keeps the transport (same
session, stream, expiry, timeline origin, media, audio and renditions)
and selects a rendition or Off is adopted on the running item with no
reload; its first frame and plan summary are reported, and the
playback time is left alone. Any other answer loads as before, and a
failed report leaves playback running.
- Off on such a stream turns off AVPlayer's automatic media selection,
deselects the legible group, and holds that until a track is picked,
since every rendition is AUTOSELECT=YES. A sidecar or embedded pick
takes a showing rendition down.
- A listed row other than the one showing can still be the secondary
subtitle, from its inventory sidecar, timed on the movie timeline like
any sidecar.
- A queued seek still runs when the waiting report has nothing to send,
and a newer local pick drops a subtitle change queued behind a report.
- The media credential scope admits silo_rendition=subtitles with a
container track number in silo_track.
- A decision's hls_rendition that omits index names its row by NAME.
The server fixture for the decision is vendored from the server branch
that implements the feature.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Direct play of a .ts or .m2ts file with a PGS track got the track as a whole-file .sup sidecar, because the client declared native embedded subtitles only for Matroska, MP4 and WebM. Aether already demuxes every subtitle stream of the open source into its packet store, and reassembles a PGS display set that MPEG-TS splits across PES packets. The original_http capability now declares native_embedded for the scanner's ts and m2ts containers with hdmv_pgs_subtitle only. DVB, DVD and teletext subtitles in a transport stream keep the server's sidecar or burn-in route until they are checked on the same path. The automatic subtitle choice ranks transport-stream PGS like PGS in MKV, since it no longer needs a burn-in. Co-Authored-By: Claude Opus 5.5 <[email protected]>
AVPlayer draws a server HLS stream's subtitle renditions itself, so they never reached Silo's overlay and showed in AVPlayer's default style whatever the viewer chose in subtitle settings. The player now hands its appearance to AVPlayer as an AVTextStyleRule on every remote HLS item, and again when the appearance changes: text color and opacity, the box (transparent when there is none), size relative to AVPlayer's own, font family and text edge. An appearance that matches the device leaves AVPlayer on the device's caption style. Position and the caption window stay AVPlayer's, because a rule can move a cue line but not with the overlay's video-rect geometry. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Protocol features and rendition data iosApp/iosApp/Screens/Player/ProtocolV3/PlaybackProtocolV3Models.swift, iosApp/iosApp/Screens/Player/ProtocolV3/ApplePlaybackV3Capabilities.swift, iosApp/iosApp/Screens/Player/PlaybackSessionBridge.swift, iosApp/Tests/PlaybackProtocolV3Tests.swift, iosApp/Tests/Fixtures/PlaybackV3/* |
Protocol V3 models and capability negotiation include remux and all-rendition features, subtitle inventory identity, and rendition metadata. Tests and a decision-response fixture cover negotiation and response data. |
Plan validation and track mapping iosApp/iosApp/Screens/Player/ProtocolV3/ApplePlaybackV3PlanAdapter.swift, iosApp/iosApp/Screens/Player/ProtocolV3/ProtocolV3SubtitleSelection.swift, iosApp/iosApp/Screens/Player/AetherLoadSpec.swift, iosApp/Tests/PlaybackProtocolV3Tests.swift, iosApp/Tests/SubtitleAutoResolverTests.swift, iosApp/iosApp/Screens/Player/PlaybackPrefsResolver.swift |
Plan adaptation maps embedded stream identity and HLS rendition slots to picker tracks. It validates rendition selections and identifies same-transport plans. Transport-stream capabilities and PGS selection expectations are updated. |
Native rendition selection and styling iosApp/iosApp/Screens/Player/AetherPlaybackController.swift, iosApp/iosApp/Screens/Player/HLSRenditionTextStyle.swift, iosApp/iosApp/Screens/Player/PlaybackMediaAuthorization.swift, iosApp/Tests/HLSRenditionTextStyleTests.swift, iosApp/Tests/PlaybackMediaAuthorizationTests.swift |
The controller resolves rendition rows to AVPlayer options and handles primary and secondary selections. Subtitle appearance settings generate AVPlayer text-style rules. Authorization accepts track-specific subtitle rendition queries. |
Selection reports and same-transport updates iosApp/iosApp/Screens/Player/PlayerViewModel.swift, iosApp/Tests/PlaybackProtocolV3Tests.swift, iosApp/Tests/PlayerTerminalFailureRetryTests.swift |
The player reports rendition and Off selections, preserves newer local picks while a report is pending, and adopts same-transport plans without reloading. Tests cover selection, refusal handling, queued changes, and rendition switching. |
Unsupported subtitle format handling iosApp/iosApp/Networking/Models.swift, iosApp/iosApp/Screens/Detail/*, iosApp/iosApp/Screens/Player/PlayerTrack.swift, iosApp/iosApp/Screens/Player/PlaybackPrefsResolver.swift, iosApp/iosApp/Screens/Player/PlaybackSessionBridge.swift, iosApp/iosApp/Screens/Player/PlayerViewModel.swift, iosApp/Tests/DetailVersionSelectionTests.swift, iosApp/Tests/SubtitleAutoResolverTests.swift |
Embedded tracks without a usable codec are marked unsupported and filtered from automatic, remembered, default, and explicit selections. Detail and playback track pickers disable unsupported rows and display an unsupported-format label. |
Estimated code review effort: 4 (Complex) | ~60 minutes
Change: Feature
Sequence Diagram(s)
sequenceDiagram
participant PlayerViewModel
participant PlaybackSessionBridge
participant PlaybackV3Server
participant ApplePlaybackV3PlanAdapter
participant AetherPlaybackController
PlayerViewModel->>PlaybackSessionBridge: Submit subtitle rendition report
PlaybackSessionBridge->>PlaybackV3Server: Send Protocol V3 replan
PlaybackV3Server-->>PlaybackSessionBridge: Return playback plan
PlaybackSessionBridge-->>PlayerViewModel: Deliver playback plan
PlayerViewModel->>ApplePlaybackV3PlanAdapter: Check transport and resolve subtitle choice
PlayerViewModel->>AetherPlaybackController: Apply rendition or Off selection
Possibly related issues
- Silo-Server/silo-apple#880 — The changes add in-place switching among HLS subtitle renditions, but do not show the inventory update contract described in the issue.
- Silo-Server/silo-apple#978 — The changes filter unsupported tracks from saved selection matching, but do not establish that the candidate tie-order issue is fixed.
- Silo-Server/silo-apple#589 — The changes alter embedded subtitle identity and switching, but do not show black-frame recovery behavior.
Suggested labels: stacked
Suggested reviewers: zzebrahz
Merge Risk: 
Minimal · up to 52154
-
The reviewed change resolves the saved-preference issue; no actionable merge-blocking risk remains in scope.
Security architecture risk: 
Low · up to 52154
-
The update changes how subtitles are negotiated and switched while keeping credentials tied to the current playback session. No introduced security weakness was identified in the reviewed paths. Server compatibility and interrupted or concurrent switches retain validation gaps.
Retained concerns
No architecture-level concerns identified.Security review details
-
Security Blast Radius
- inferred — The newly admitted credential-bearing request shape is bounded to the validated playback source's origin and exact session master-playlist path. The inspected client change does not admit arbitrary endpoints or another session's path. Server-side asset authorization remains an external enforcement dependency.
Trust Boundaries and Controls
- observed — A playlist-controlled URL receives media headers only after scope admission. The new two-parameter form requires silo_rendition=subtitles and a one-to-twenty-digit silo_track value without a leading zero. Extra or duplicate parameters, other rendition values, and rendition queries on segment routes are not admitted by this form. Credential resolution also checks the captured account's server identity.
- observed — Reusing the existing transport requires unchanged session, stream, delivery, media file, nonempty expiry, timeline origin and offset, recipe, audio selection, and rendition map. This constrains when an existing media authorization context can remain attached to a subtitle-only update.
Resilience and Maintainability Implications
- observed — Recognized subtitle-switch refusals can preserve the current playback plan and undo the refused pick instead of terminating the session. Stale responses and abandoned candidates have explicit cleanup paths; cleanup failures remain best-effort with server timeout as the stated fallback.
-
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title "feat(player): play embedded subtitles from the stream and switch them in place" matches the main change. The PR adds playback of embedded subtitles as HLS renditions from the stream and in-place switching between them, which the changeset implements across the player, protocol V3, and tests.
Full details: Description check
-
Explanation
The description explains the problem (slow whole-file sidecar subtitles), the approach (negotiated server features, copy-remux renditions, row identity, all-track renditions with in-place switching, native PGS in TS/M2TS, rendition styling), validation, and risks. These match the changed files, including the AetherPlaybackController, PlaybackProtocolV3 models, PGS capability, and HLSRenditionTextStyle.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 57.97% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 69 functions across 25 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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. |
|
Evidence is missing:
Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
| for metadata in option.commonMetadata where metadata.identifier == identifier { | ||
| name = try? await metadata.load(.stringValue) | ||
| } |
There was a problem hiding this comment.
Playlist-name resolution fails because it searches commonMetadata for the format-specific m3u8/NAME identifier, leaving names unresolved and causing hlsSubtitleRenditionEngineIDs to select the wrong language through playlist-index fallback when AVFoundation reorders legible options. Read the NAME attribute from the option's available metadata formats before applying the index fallback.
Prompt for LLM
File iosApp/iosApp/Screens/Player/AetherPlaybackController.swift:
Line 881 to 883:
Playlist-name resolution fails because it searches `commonMetadata` for the format-specific `m3u8/NAME` identifier, leaving names unresolved and causing `hlsSubtitleRenditionEngineIDs` to select the wrong language through playlist-index fallback when AVFoundation reorders legible options. Read the NAME attribute from the option's available metadata formats before applying the index fallback.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
This lookup is correct as written. The pinned AetherEngine (df72cc59) reads the same attribute the same way, and Sources/AetherEngine/Native/RemoteHLSMediaSelection.swift:47 records that the verbatim NAME survives in commonMetadata under m3u8/NAME. That's where it was measured on device. metadata(forFormat:) isn't needed.
The index fallback next to it did have a gap when only some options carry a NAME. That's fixed in 58d1688 (see the review thread on line 864).
🤖 Claude Code in T3 Code (claude-opus-5-5)
There was a problem hiding this comment.
Thanks for the correction. Given the on-device observation documented in the pinned AetherEngine, my claim that commonMetadata cannot expose m3u8/NAME was incorrect. Switching to metadata(forFormat:) is not warranted.
I withdraw this finding as a false positive. The partial-NAME index-fallback gap is a separate issue, addressed in 58d1688c as you noted.
| uncommittedPrepared = nil | ||
| keepsCurrentPlan = true | ||
| self.adoptSameTransportProtocolV3Plan(next, selection: selection) | ||
| self.adoptBufferingPlan( |
There was a problem hiding this comment.
Race condition identified in buffering-plan adoption: the pre-await check cannot prevent a suspended commitPendingProtocolV3Transition from completing and installing an outgoing load's buffering state after another item replaces it. Call requireCurrentStreamLoad(currentStreamLoadGeneration) immediately after the await and before publishing the buffering plan to protect both adoptBufferingPlan calls.
Also found in:
iosApp/iosApp/Screens/Player/PlayerViewModel.swift:3077-3077
Kody rule violation: Finalize outgoing playback before publishing a replacement item
Prompt for LLM
File iosApp/iosApp/Screens/Player/PlayerViewModel.swift:
Line 3078:
Race condition identified in buffering-plan adoption: the pre-await check cannot prevent a suspended `commitPendingProtocolV3Transition` from completing and installing an outgoing load's buffering state after another item replaces it. Call `requireCurrentStreamLoad(currentStreamLoadGeneration)` immediately after the await and before publishing the buffering plan to protect both `adoptBufferingPlan` calls.
**Also found in:**
- `iosApp/iosApp/Screens/Player/PlayerViewModel.swift:3077-3077`
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
Already fixed on the head this thread now points at. This comment was raised on d31534d, and 59c6902 added the recheck. After commitPendingProtocolV3Transition returns, the branch calls requireCurrentStreamLoad(currentStreamLoadGeneration) and checks activeAetherLoadEpoch == priorAetherLoadEpoch before adoptSameTransportProtocolV3Plan or adoptBufferingPlan runs. A replacement item or teardown during the commit ends the replan without adopting this plan.
🤖 Claude Code in T3 Code (claude-opus-5-5)
There was a problem hiding this comment.
Thanks for clarifying. The post-await generation check and load-epoch guard you described address this race by preventing a superseded replan from publishing subtitle or buffering state.
The finding applies to d31534d and is addressed by 59c6902; no additional code change is needed for this finding.
| switch container { | ||
| case "mkv": return ["subrip", "ass", "ssa", "webvtt", "hdmv_pgs_subtitle", "dvd_subtitle", "dvb_subtitle"] | ||
| case "webm": return ["webvtt"] | ||
| case "ts", "m2ts": return ["hdmv_pgs_subtitle"] |
There was a problem hiding this comment.
Incorrect native capability declarations advertise embedded PGS support in TS/M2TS, although the reviewed Apple capability contract requires burn-in for bitmap subtitles in those containers. Remove PGS from these declarations so server planning cannot bypass the required burn-in route.
Also found in:
iosApp/Tests/PlaybackProtocolV3Tests.swift:1146-1146iosApp/Tests/SubtitleAutoResolverTests.swift:376-376iosApp/Tests/SubtitleAutoResolverTests.swift:370-370iosApp/Tests/PlaybackProtocolV3Tests.swift:1158-1158iosApp/Tests/SubtitleAutoResolverTests.swift:377-377iosApp/Tests/PlaybackProtocolV3Tests.swift:1150-1150
Kody rule violation: Rank subtitles using container capabilities and one stable cross-client policy
case "ts", "m2ts": return []
Prompt for LLM
File iosApp/iosApp/Screens/Player/ProtocolV3/ApplePlaybackV3Capabilities.swift:
Line 166:
Incorrect native capability declarations advertise embedded PGS support in TS/M2TS, although the reviewed Apple capability contract requires burn-in for bitmap subtitles in those containers. Remove PGS from these declarations so server planning cannot bypass the required burn-in route.
**Also found in:**
- `iosApp/Tests/PlaybackProtocolV3Tests.swift:1146-1146`
- `iosApp/Tests/SubtitleAutoResolverTests.swift:376-376`
- `iosApp/Tests/SubtitleAutoResolverTests.swift:370-370`
- `iosApp/Tests/PlaybackProtocolV3Tests.swift:1158-1158`
- `iosApp/Tests/SubtitleAutoResolverTests.swift:377-377`
- `iosApp/Tests/PlaybackProtocolV3Tests.swift:1150-1150`
Suggested Code:
case "ts", "m2ts": return []
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
This PR changes that capability on purpose, so I'm leaving it as is. The pinned AetherEngine reassembles PGS display sets that MPEG-TS splits across PES packets (splitDisplaySetSubtitleStreamIndices, AetherEngine+SubtitleOCR.swift:198). The server's scanner reports these containers as ts and m2ts (containerForFile in internal/scanner/probe.go). The claim covers hdmv_pgs_subtitle only, so DVB, DVD and teletext in a transport stream keep the sidecar or burn-in route. Removing it would bring back the whole-file .sup extraction this section removes.
SubtitleAutoResolverTests.testEmbeddedPGSLosesToExternalTextOnlyWhereItNeedsABurnIn fails on the base and passes here. PGS from a transport stream hasn't been played on a device yet; the PR lists that under Risks.
🤖 Claude Code in T3 Code (claude-opus-5-5)
There was a problem hiding this comment.
Agreed—my suggestion treated the previous capability contract as immutable, but this PR intentionally extends it. Based on the engine behavior and scanner identifiers you cited, advertising hdmv_pgs_subtitle for ts and m2ts is consistent with that change. Returning [] would undo it and restore the whole-file sidecar fallback.
I withdraw the suggested removal. The resolver test supports the intended selection policy; it does not establish device playback correctness. Transport-stream PGS playback remains an explicitly disclosed validation gap, not evidence that this declaration is wrong.
The referenced Kody rule may need a narrow update to recognize this PGS capability while preserving the existing fallback behavior for DVB, DVD, and teletext. I can make that update if you want; nothing has been changed.
…btitle plan Adopting a plan that keeps the running stream waits for the session bridge to commit it. A next episode or a teardown could replace the item during that wait, and the plan's subtitle choice and buffering state were then applied to the new item. The player now checks again after the commit that the same load is still current before it adopts anything. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
There was a problem hiding this comment.
Two findings on 59c6902, both fixed in a follow-up commit on this branch. Both came from a cross-provider review round (Codex, gpt-6.1-sol), and I verified each against the source. The summary comment covers the bot threads, the tests, validation, docs, and parity.
🤖 Claude Code in T3 Code (claude-opus-5-5)
…h rendition names first A live AI subtitle picked while a subtitle_track_changed report was out skipped the local-pick bookkeeping, so the report's same-transport answer selected the older rendition over it, and a failed report restored that rendition as the local selection. The pick now counts as newer than the report, and the rollback keeps the selection it left. Rendition rows matched legible options by NAME and fell back to their index in a single pass, so a row without a NAME match could take an option a later row named. Every NAME match is now placed first, and the index fallback skips options named for a row. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Review summaryReviewed 59c6902; fixes pushed as 58d1688, 66f5c00, 1d62916 and a045f41. 7df969e and eb1fc7d, pushed after them, extends the failure-during-report fix to every recovery path and drops a report's answer once its item failed. I read both, 7df969e against the replan's cancellation path, and found no defect. The branch wasn't rewritten. Fit: 8/10 · Readiness: 7/10 — conditional Fit. The change serves the core experience. Embedded subtitles show up without the server reading the whole source file, so the server does less work and the viewer waits less. Every new behaviour is negotiated, so an older server keeps today's path. Two things stretch it. It combines five former pull requests into one review at a maintainer's request. The all-track renditions also depend on Silo-Server/silo-server#3331, which hasn't merged. Android parity is covered by Silo-Server/silo-android#770, now linked in the body. Readiness. The approach is sound, and the six defects found by the review and the bots are fixed. Some of the change has been shown live: direct play and a transcode with in-place switching, on iPhone. Two of the tests fail on the base. These conditions remain:
Addressed findingsBoth came from a cross-provider review round (Codex, gpt-6.1-sol, on 59c6902). I verified both against the source and fixed them in 58d1688.
The Codex GitHub bot found two more on 58d1688. I verified both and fixed them in 66f5c00.
Both are verified by tracing the code and an iOS test build. Kody then found that a live AI pick during a report still let an older queued subtitle change run after it. That's fixed in 1d62916, which drops the queued subtitle change and keeps a queued audio one. CodeRabbit found that a stall during a report showed the loading spinner at once; that's fixed in a045f41. Its note on Bot threads
Tests that fail on the baseOn an iOS 27.0 simulator, with this PR's test files run against the base (1a7ccee):
On 58d1688 those four classes pass (159 tests). a045f41 compiles for iOS. CI passed on eb1fc7d, including the iOS, tvOS and macOS regression suites. Validated featuresNone found affected. The validation board wasn't readable from this review. Validation issues #313 and #314 show every case as not run, so no passed case can regress. The body's User manualNeeds an update once this and silo-server#3331 merge. Apple/Android paritySilo-Server/silo-android#770 makes the same change on Android (copy-remux renditions, row identity, all-track renditions with in-place switching). It's now linked from this PR's body. 🤖 Claude Code in T3 Code (claude-opus-5-5) |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 58d1688c9f
ℹ️ 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".
… recover an item that fails during one An in-place subtitle report still counted as a transport transition, so Watch Party published the member as buffering and not ready while playback continued, and a report slower than the grace period could pause the room. A report now counts as a transition only once its answer turns it into a load. An item that failed while a report was out had its recovery refused as busy, and a same-transport answer then kept the failed item in place. The failure is now held and recovered when the report settles, unless the answer loaded a new item. A report that becomes a load also stops letting local picks apply as if the running stream were kept. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…during a report A subtitle the server had to replan, picked while a report was out, waited behind it as a queued track change. A live AI pick after it still let that older change run once the report settled, replacing the AI subtitle. The AI pick now drops a queued subtitle change, as a local pick already does, and keeps a queued audio change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 2

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
ebe0444d-7397-4c41-9726-d5e6a40a6586
Files selected for processing: 17-
iosApp/Tests/Fixtures/PlaybackV3/SOURCEiosApp/Tests/Fixtures/PlaybackV3/hls-subtitle-renditions-all-decision_response.jsoniosApp/Tests/HLSRenditionTextStyleTests.swiftiosApp/Tests/PlaybackMediaAuthorizationTests.swiftiosApp/Tests/PlaybackProtocolV3Tests.swiftiosApp/Tests/SubtitleAutoResolverTests.swiftiosApp/iosApp/Screens/Player/AetherLoadSpec.swiftiosApp/iosApp/Screens/Player/AetherPlaybackController.swiftiosApp/iosApp/Screens/Player/HLSRenditionTextStyle.swiftiosApp/iosApp/Screens/Player/PlaybackMediaAuthorization.swiftiosApp/iosApp/Screens/Player/PlaybackPrefsResolver.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/ProtocolV3/ProtocolV3SubtitleSelection.swift
Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.
-
…itle report A subtitle report keeps the running stream, but it still counted as preparing a replacement, so a brief stall while it was out showed the loading state at once instead of after the frozen-playhead threshold. The stall classification and the Watch Party snapshot now share one predicate that leaves a report out until its answer turns it into a load. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
…ly server-adaptable ones Only the server-adaptable failure arm waited for a subtitle report in flight. A failure that reached handlePlaybackError's recovery still hit the busy replan gate and was dropped. Both arms now share one path: the failure is held for the report's exit, and playback shows that it stopped. The report's answer also no longer commits onto the failed item. It is dropped, and the held recovery replaces the item as the report exits. The rule that a newer subtitle pick drops a queued subtitle change, used by the local and live AI paths, is one helper with a test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
…rendition stream ends Deselecting a stream's subtitle renditions turned off appliesMediaSelectionCriteriaAutomatically on Aether's native player and never turned it back on. That player is kept across consecutive loads, so every later stream, with renditions or without, started with automatic selection off. The controller now records the player's value when it first turns it off and puts it back when the stream's rendition state resets: on a new load, a failed or cancelled one, a replacement, or stop. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
…974) * fix(player): keep playing when the server refuses a subtitle switch Picking an embedded subtitle the server can't deliver (for example a Matroska S_TEXT/WEBVTT track its probe stored with no codec) got a subtitle_codec_unsupported terminal back from the replan. The player treated it as a route dead end, reported a terminal route event, and tore playback down. A track-change replan for a viewer's subtitle pick now treats the server's subtitle refusals as ending only the switch. The bridge throws PlaybackV3SubtitleRefusal without reporting a terminal or touching its attempt state. The player keeps the current plan, puts the picker back to the selection the pick replaced, shows "This subtitle can't be shown", and logs [CMP-SUB] phase=replan_refused. The pick's preference is saved only once the server hasn't refused it, so a reload doesn't ask for the track again. The picker on iPhone, iPad, Apple TV and Mac shows an embedded track with no codec as disabled, labelled "Unsupported format", and automatic selection skips it. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(detail): don't offer or start on a subtitle the server can't deliver The player disabled an embedded track the server stored with no codec, but the detail page still offered it. Picking it there, or Auto landing on it as the file's default, put it in the start request, and the server refused the whole start with subtitle_codec_unsupported. - The detail page's subtitle list shows the track as unselectable, labelled "Unsupported format", on iPhone, iPad, Mac and Apple TV. - Detail candidates carry the same mark, so Auto never resolves to it, and the "leave it to the file" fallback skips it when it is the default track, in the detail preview and at the start alike. - A saved pick of it, by stream index or combined ordinal, starts without subtitles, and the detail page reads a remembered pick of it as Auto. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(player): save a subtitle pick only once its plan plays A pick's preference was saved when its replan settled, so a failed or abandoned replan still saved it. It's now saved only once its plan is adopted. A pick queued behind another one now learns how that one settled. If the older pick was adopted and the newer one is refused, the picker returns to the older pick and saves it. If the older pick was refused, the newer pick's refusal returns to what is actually playing. A pick that replaces a queued pick inherits its rollback. A queued audio pick that a subtitle pick replaced is asked for again if the server refuses the subtitle. The detail page no longer seeds a remembered pick of a track the server can't deliver. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(player): keep a queued subtitle pick when an audio pick follows it An audio pick made while a subtitle pick waited behind a replan replaced it in the queue. The audio request still carried the subtitle, but without the pick's rollback and refusal handling, so a refused subtitle ended playback. The audio pick now joins the queued subtitle pick's request. Both selections are restored before that request reads them back, audio first. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: zZebrahz <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c5401bdfea
ℹ️ 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".
| static func queuedTrackChangeAfterSubtitlePick( | ||
| _ queued: QueuedProtocolV3TrackChange? | ||
| ) -> QueuedProtocolV3TrackChange? { | ||
| if case .subtitle? = queued?.target { return nil } |
There was a problem hiding this comment.
Preserve joined audio picks when dropping a queued subtitle change
If a subtitle report is in flight, the viewer queues a server-switched subtitle, then selects audio, subtitleChange(_:joinedBy:) stores that audio target in the queued subtitle pick's audioPick. Selecting a live AI subtitle before the report finishes calls this helper and drops the entire queued change, including the audio target. The report's completion then republishes the original audio selection through adoptAetherInventory(), and no audio replan runs, even though the audio preference was already saved. When discarding a superseded subtitle change, retain its joined audioPick as an audio-only queued change.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed in 28dc141: when a newer subtitle pick drops a queued subtitle change, a joined audio pick now stays queued as an audio-only change. Added a row to testASubtitlePickDropsOnlyAQueuedSubtitleChange.
…s the queued change An audio pick made while a server-switched subtitle change was queued joins that change. A local or live AI subtitle pick made before the report in flight returned dropped the whole queued change, so the audio switch never ran even though its preference was saved. Keep the joined audio pick as an audio-only queued change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
| @@ -7858,7 +8181,13 @@ class PlayerViewModel { | |||
| /// track's teardown): a series preference records what the viewer | |||
There was a problem hiding this comment.
Subtitle cycling on macOS stalls when the unsupported-format early return prevents selectedSubtitleId from advancing: cycleSubtitleTrack repeatedly passes the same unsupported row, leaving later supported tracks and Off unreachable through the cycle command. Filter unsupported rows in cycleSubtitleTrack and toggleSubtitles before selecting the next or first candidate.
Prompt for LLM
File iosApp/iosApp/Screens/Player/PlayerViewModel.swift:
Line 8181 to 8181:
Subtitle cycling on macOS stalls when the unsupported-format early return prevents selectedSubtitleId from advancing: cycleSubtitleTrack repeatedly passes the same unsupported row, leaving later supported tracks and Off unreachable through the cycle command. Filter unsupported rows in cycleSubtitleTrack and toggleSubtitles before selecting the next or first candidate.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
There was a problem hiding this comment.
Confirmed: the unsupported-format early return in selectSubtitle is new in this PR, so cycling stalled on the first unsupported row. Fixed in the next commit: cycleSubtitleTrack and toggleSubtitles choose only among playable rows.
There was a problem hiding this comment.
Thanks for confirming—that explains why cycling stalled. Restricting both cycleSubtitleTrack and toggleSubtitles to playable rows should address the regression.
Please include regression tests covering unsupported rows before and between playable tracks, plus the case where no playable tracks exist, so both actions handle those cases gracefully.
There was a problem hiding this comment.
Not adding a test here: cycleSubtitleTrack/toggleSubtitles are instance methods on the full player view model with no existing test harness, and the fix only filters the candidate list.
There was a problem hiding this comment.
Understood—manual validation through the macOS shortcuts is reasonable for this small candidate-filter fix without an existing view-model test harness. No need to introduce one for this change.
The relevant cases are unsupported rows before and between playable tracks, cycling back to Off, and no playable tracks available.
…subtitles selectSubtitle refuses unsupported rows, so the macOS cycle command stalled on the first one and never reached later tracks or Off. Cycle and toggle now pick only among playable rows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

Minor · Exclude unsupported tracks in savedPickApplies. · PlaybackPrefsResolver.swift:263-266
iosApp/iosApp/Screens/Player/PlaybackPrefsResolver.swift:263-266
Minor · Functional Correctness · Quick win Exclude unsupported tracks in
savedPickApplies.When an unsupported embedded English track matches the saved pick,
startSessionsuppresses the device caption preferences.resolvethen removes English and does not select the available French track. Filter unsupported tracks before matching the saved pick.Suggested fix
static func savedPickApplies( _ signature: SubtitleTrackSignature?, to tracks: [SubtitleTrack] ) -> Bool { guard let signature else { return false } + let playableTracks = tracks.filter { !$0.hasUnsupportedFormat } if let language = signature.language, !language.isEmpty { - return tracks.contains { track in + return playableTracks.contains { track in guard let trackLanguage = track.language, !trackLanguage.isEmpty else { return false } return languagesMatch(trackLanguage, language) } } guard let label = signature.label, !label.isEmpty else { return false } - return tracks.contains { ($0.title ?? $0.embeddedTitle)?.localizedCaseInsensitiveContains(label) == true } + return playableTracks.contains { + ($0.title ?? $0.embeddedTitle)?.localizedCaseInsensitiveContains(label) == true + } }

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
89a45b98-98f6-40db-b77b-4203f01d74fa
Files selected for processing: 18-
iosApp/Tests/DetailVersionSelectionTests.swiftiosApp/Tests/PlaybackProtocolV3Tests.swiftiosApp/Tests/PlayerTerminalFailureRetryTests.swiftiosApp/Tests/SubtitleAutoResolverTests.swiftiosApp/iosApp/Networking/Models.swiftiosApp/iosApp/Screens/Detail/DetailPlaybackFormatting.swiftiosApp/iosApp/Screens/Detail/ItemDetailView.swiftiosApp/iosApp/Screens/Detail/SubtitleTrackCandidates.swiftiosApp/iosApp/Screens/Player/AetherPlaybackController.swiftiosApp/iosApp/Screens/Player/OfflinePreparedTrackInventory.swiftiosApp/iosApp/Screens/Player/PlaybackPrefsResolver.swiftiosApp/iosApp/Screens/Player/PlaybackSessionBridge.swiftiosApp/iosApp/Screens/Player/PlayerTrack.swiftiosApp/iosApp/Screens/Player/PlayerViewModel.swiftiosApp/iosApp/Screens/Player/ProtocolV3/ApplePlaybackV3PlanAdapter.swiftiosApp/iosApp/Screens/Player/Sheets/TrackSelectionSheet.swiftiosApp/iosApp/Screens/Player/tvOS/TVPlayerInfoHUD.swiftiosApp/iosApp/macOS/MacPlayerOptionsPanel.swift
Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.
-
… pick resolve drops unsupported tracks, so a saved pick that only matched one suppressed the device caption policy and left no subtitle selected. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Re CodeRabbit outside-diff finding on |
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
@Quick104 a note on #589 (embedded SRT drops after a brief black frame on Apple TV), since this PR works right next to it but doesn't close it. The diagnosis in #589 (comment) puts the cause in mid-playback reloads: What this PR changes there:
So #589 still looks open after this merge. The fix suggested in the issue still applies: arm the handover for any same-engine reload, not only fresh loads, so the old picture stays up until the swap. Worth a follow-up? |
Problem
Related issue: #600
Pairs with Silo-Server/silo-android#770
Validation tasks: changes #313 C1, C2, C3, C4; changes #314 C1, C2, C3, C4
The Apple apps get many embedded subtitles from a sidecar URL. The server builds that sidecar by reading the whole source file, which takes up to minutes for a large file on network storage, so the subtitle shows late or not at all. This affects every embedded text track on a server copy remux, every embedded track the app can't identify in the open file, PGS in TS and M2TS files, and every switch between embedded text tracks on a transcode or remux, which also restarts the stream.
This pull request plays those tracks from the stream the app already has, makes switching between them instant, and draws AVPlayer's subtitle renditions in the viewer's subtitle style. At a maintainer's request it combines #953, #954, #955, #956 and #957 into one review, with one commit per former pull request and one follow-up fix.
Approach
It needs no server change to build or run. The server features it uses are negotiated, so a server without them keeps today's behaviour. The all-track renditions and the inventory
stream_indexcome from Silo-Server/silo-server#3331, the combined server pull request. Silo-Server/AetherEngine#27 is a separate engine change that makes a subtitle declared at load fetch its sidecar once per selection, instead of twice; the AetherEngine pin bump follows once it merges and isn't part of this pull request. iOS, tvOS and macOS share all of it.Copy-remux renditions (was #953)
hls_remux_subtitle_renditions_v1, and the plan adapter acceptssubtitle.hls_renditiononserver_remux_hlswith the same checks as on a transcode. Picking another embedded text track on a remux asks the server, which carries it in the stream, instead of mounting its sidecar, but only when the server lists the remux token.X-TIMESTAMP-MAPagainst fMP4 segments.Row identity (was #954)
stream_indexwhen the server sends one, else theembedded_stream_indexthe server already puts on every embedded sidecar URL. Counting catalog tracks against inventory rows is the last resort.container_track_idandnative_selectableare decoded too; all three are optional.subtitle.embedded.stream_index.All-track renditions with in-place switching (was #957)
hls_subtitle_renditions_all_v1, the start request sends it and every replan repeats it. The server then carries every cue-indexed embedded text track as a WebVTT rendition, and each inventory row carrieshls_rendition.m3u8/NAME, sincedisplayNameis a localized language name), then by 1-based index.subtitle_track_changedreplan that shows no loading state. An answer that keeps the transport (same session, stream, expiry, timeline origin, media, audio and renditions) is adopted on the running item without a reload. A pick made while a report is out applies at once and is reported after it, latest wins.AUTOSELECT=YES, and a sidecar pick takes a showing rendition down.silo_rendition=subtitleswith a decimalsilo_track, on the master playlist path only.Native PGS in TS and M2TS (was #955)
tsandm2tscontainers withhdmv_pgs_subtitleonly. The automatic subtitle choice ranks that PGS like PGS in MKV..supsidecar.Rendition styling (was #956)
AVTextStyleRuleon every remote HLS item, and again when it changes: text color and opacity, the box, relative size, font family and text edge. An appearance that matches the device leaves AVPlayer on the system style.Validation
SiloTestssuite passed on an iOS 27.0 simulator (iPhone 17), ad-hoc signed: 3,682 tests, 0 failures./api/v1path guard and its test, Apple platform routing, subtitle packaging validation and build metadata tests passed locally.PlaybackProtocolV3Tests,PlaybackMediaAuthorizationTests,SubtitleAutoResolverTestsandHLSRenditionTextStyleTestspass on an iOS 27.0 simulator (159 tests). The live AI pick fix is verified by tracing the code; no test covers it.Evidence
Evidence: https://evidence.siloserver.org/r/silo-apple/pr-970/
Risks
hls_subtitle_renditions_all_v1keeps its old feature list until it is relaunched, so its switches still restart the stream. This is expected for a negotiated feature.Checklist
AI Disclosure
xcodebuild, XcodeGen) through a Mac build service; a shared simulator pool; agent-device for the iPhone runm3u8/NAMElookup incommonMetadatais where AetherEngine measured the attribute on device. A /silo review round (Codex, gpt-6.1-sol, on 59c6902) found two more, both fixed in 58d1688: a live AI subtitle picked during a subtitle report was replaced by the reported rendition, and the index fallback could take an option another row matched by NAME. The Codex review bot then found two on 58d1688, both fixed in 66f5c00: an in-place subtitle report showed the Watch Party member as buffering, and an item that failed during a report was never recovered. Kody then found that a live AI pick during a report let an older queued subtitle change run after it; that's fixed in 1d62916. CodeRabbit found that a stall during a report showed the loading spinner at once; that's fixed in a045f41. Its note on restoringappliesMediaSelectionCriteriaAutomaticallywas left as is, because the pinned AetherEngine sets that flag to false itself.🤖 Generated with Claude Code
Note
Play embedded HLS subtitle renditions in place with server-reported switching
...
Macroscope summarized 5215443.