Repository navigation
fix(jellycompat): remember audio and subtitle choices from Jellyfin apps - #2332
Conversation
Codex Review Summary: ✅ CompletedThis 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. |
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: 896ee62d45
ℹ️ 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".
Quick104
left a comment
There was a problem hiding this comment.
Adversarial review (gpt-6.1-sol, reviewed 896ee62)
Three new findings, verified against the pinned diff and its callers. The preference write-order race already reported in another review is omitted.
Reviewed against 729abf2. Focused go test ./internal/jellycompat/... passed with GOFLAGS=-p=4; database tests skipped because SILO_TEST_DATABASE_URL is unset. The replica and rolling-update failures below are verified from source; live clients and a running cluster were not exercised.
AI disclosure: gpt-6.1-sol via Codex in T3 Code.
| // and subtitle tracks are saved under; empty saves none. Only PlaybackInfo | ||
| // sets it: a static play never offered the client its defaults, so its | ||
| // reports cannot tell a pick from the client's own choice. | ||
| PreferenceKey string |
There was a problem hiding this comment.
[P2] Preserve the new metadata when older replicas rewrite a play
During a rolling update, negotiate PlaybackInfo on an upgraded replica and send the first stream request to a replica running the base version. The older replica's ensureUpstreamPlayback updates the shared playback session. Its durable store unmarshals the JSON into the old PlaybackSession type and rewrites the whole document through marshalPlaybackSession, which calls json.Marshal(session). That type has neither PreferenceKey nor the new remembered-index fields, so all three fields are discarded.
Once an upgraded replica reloads that row, rememberCompatTracks sees PreferenceKey == "" and saves nothing for the remainder of this negotiated play, including after the rolling update finishes. An ordinary upstream-session or audio-selection update on an older replica is sufficient; no failure is required.
Keep this metadata in storage older writers do not replace, or ship a compatibility bridge that preserves unknown fields before relying on these fields for eligibility and deduplication.
There was a problem hiding this comment.
I don't think this holds for the base version. marshalPlaybackSession calls json.Marshal(session), which goes through PlaybackSession.MarshalJSON and PlaybackMediaSource.MarshalJSON in internal/jellycompat/playback_sessions_json.go. Since bc10bd5 those capture keys the binary does not declare on read and re-emit them on write, so a main-based replica rewriting the row keeps PreferenceKey and both remembered indexes. Only a binary older than that envelope would drop them. In that case the play has an empty PreferenceKey and saves nothing, which fails safe: no wrong preference is written, and the next play negotiated on a current replica remembers normally. Leaving this thread open for a maintainer to judge whether that is enough.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3cf87bd898
ℹ️ 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
Here are some automated review suggestions for this pull request.
Reviewed commit: 52046cf081
ℹ️ 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".
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: f4176f7827
ℹ️ 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
Here are some automated review suggestions for this pull request.
Reviewed commit: 8db7648c81
ℹ️ 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".
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: 88c3be77c9
ℹ️ 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".
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Skip the device fallback and the preferred track as defaults, an audio switch the server refused, and an index that names no track. Claim each change on the play before writing it so overlapping reports write it once, match reports without MediaSourceId to the streamed version, and bound the writes with a timeout. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A later report could claim and save another track while an earlier one was still writing, so the earlier write landed last and the series kept the older track. Each write now reads the play's latest claim back and writes it again when it moved on. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… row A replica's cached copy of a play can lag the stored row by a few seconds. A Stopped report is the play's last, so its track change is now decided inside the claim against the stored row instead of the cached copy, and the claim refuses a stored row that is already terminal. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… write repair When the viewer's Remember settings cannot be read, nothing is claimed or written, so an opt-out is never ignored and the next report retries. The read-back after a preference write now repeats until the stored claim matches what was written, bounded by the report's deadline instead of a fixed round count. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ms from the stored play A track the viewer does not remember is no longer claimed on the play, so another report's read-back cannot write it. The read-back now goes through the store's Update, which ends on the stored row, instead of Get, which can serve a replica's cached copy. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…adds The durable play-session store replays an update after a failed database write, and a replayed callback that fails makes every later durable write of the play fail with it. The claim and read-back callbacks now only record what they found and return nil; the caller decides from that. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… play An older report's write could land after a newer Stopped report claimed, saved and finished the play; its read-back then found no play and kept the older track. The read-back now reads a finished play's final claim and writes it again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The durable play-session store replays an update after a failed database write, possibly after another replica saved a newer track claim. A claim callback now changes nothing once its own Update has returned, so a late replay cannot restore an older selection. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main now parses AudioStreamIndex and SubtitleStreamIndex in playback reports as compatIntValue and moved the audio switch into applyReportedAudioSelection. Track memory reads the indexes through get(), and the helper reports whether the server accepted the switch, so a refused one stays out of the remembered tracks. Main's lint config also enables gocyclo and predeclared: the preference write loops move into their own methods, and a test variable no longer shadows copy. Co-Authored-By: Claude Opus 5.5 <[email protected]>
80d41cc to
323c1bf
Compare
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:
|
| if returned.Load() { | ||
| return nil | ||
| } |
There was a problem hiding this comment.
A failed durable claim can permanently suppress the track preference
A failed durable claim stays in the playback cache, causing later reports of the same track to skip saving the preference. Restore the cached baseline on failure or make failed claims retryable without replaying them over newer claims.
Prompt for LLM
File internal/jellycompat/track_memory.go, lines 215-217:
A failed durable claim can permanently suppress the track preference
A failed durable claim remains in the local playback cache, but this guard discards its pending replay, so subsequent reports of the same track are treated as unchanged and never save the preference. Restore the cached baseline on failure or make failed claims retryable without replaying them over newer claims.
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.
🤖 Claude Code (claude-opus-5-5): Confirmed by trace. When the claim's database write fails, the durable store keeps the claimed copy in its cache and queues the callback, and the returned guard makes that replay a no-op. Later Progress reports on this replica then treat the track as unchanged, so the choice is saved only if a Stopped report carrying the indexes reaches the stored row. A failed preference write ends the same way, and the PR already accepts that. I've left this for the maintainers to decide in the review summary, together with a design that compares reports against the stored preference so a failed write is retried. I'm leaving this thread open.
There was a problem hiding this comment.
The finding remains valid, and leaving the thread open for a maintainer decision is appropriate. A failed durable claim can suppress later attempts on the same replica; a Stopped report carrying the indexes may still recover the choice.
Comparing reports against the stored preference could enable retries, but it needs to preserve ordering so a retry cannot overwrite a newer choice. That would also change the PR’s stated policy of not retrying failed preference writes.
No changes were made.
| if audio != nil { | ||
| h.writeRememberedCompatAudio(ctx, session, playSession, source, *audio) | ||
| } | ||
| if subtitle != nil { | ||
| h.writeRememberedCompatSubtitle(ctx, session, playSession, source, *subtitle, subtitlePref) |
There was a problem hiding this comment.
A slow audio write silently drops the claimed subtitle choice
If h.writeRememberedCompatAudio exhausts the shared deadline in ctx, the claimed subtitle choice is never written. Give each claimed track an independent deadline or leave an unattempted subtitle claim retryable.
Prompt for LLM
File internal/jellycompat/track_memory.go, lines 127-131:
A slow audio write silently drops the claimed subtitle choice
Audio and subtitle writes share one deadline after both choices have already been claimed, so an audio write that consumes the timeout causes the subtitle loop to exit without attempting its write. Give each claimed track an independent deadline or leave an unattempted subtitle claim retryable.
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.
🤖 Claude Code (claude-opus-5-5): Confirmed and fixed in 44b1a73. Once both tracks are claimed, each write gets its own 10s deadline and the two run side by side, so a slow audio write no longer leaves the subtitle claim unattempted. The worst-case report time is unchanged. The track memory tests pass under -race.
There was a problem hiding this comment.
Thanks for confirming. Based on your description, the independent deadlines address the concern: a slow audio write should no longer prevent the claimed subtitle choice from being attempted. I haven’t independently verified commit 44b1a73ff or the test results.
…track write its own deadline A downloaded subtitle's stream index is its position in the file's stored list. When an earlier one was deleted during a play, a report naming the index PlaybackInfo offered resolved to the next subtitle and saved its language and signature. PlaybackInfo now records the offered subtitle IDs on the play's source, and track memory resolves a reported index through them. Audio and subtitle preference writes shared one 10s deadline after both were claimed, so a slow audio write could leave the claimed subtitle unwritten for the rest of the play. Each write now gets its own deadline, and the two run side by side. 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:
|
Quick104
left a comment
There was a problem hiding this comment.
🤖 Claude Code (claude-opus-5-5): review of 04d59a5
Main had changed the code under this branch (Stopped handling, stored-subtitle URLs in #4177, session-store read failures), so I merged main into the branch first (04d59a5). On a sandbox built from that head, a Jellyfin client walk works as the PR describes: PlaybackInfo on episode 1, the stream request, Playing on the defaults, Progress with English audio and then the full English subtitles, and Stopped. Episode 2 then starts on English audio and the full English subtitles, and GET /api/v2/audio-prefs/{series_id} and GET /api/v2/subtitle-prefs/{series_id} return the saved tracks.
Findings:
-
A downloaded subtitle is saved by its current position, not the one PlaybackInfo offered (inline below). I'm fixing this in a commit on this branch, so there's no need to change it yourself.
-
The audio and subtitle writes share one deadline (Kody's open thread on this). Confirmed, and I'm fixing it on this branch too.
-
Maintainer decision: a claim stands in for a completed save. A change is recorded on the play before its preference write lands, and later reports skip anything already recorded. Any failure after the claim therefore loses that choice for the rest of the play:
- a claim whose database write fails stays in the replica's cached copy while its queued replay does nothing (Kody's other open thread);
- a preference write that fails;
- a read-back that cannot resolve the newest claim, for example when listing downloaded subtitles fails.
The PR already accepts that a failed write is logged and not retried; these cases belong to that class but have more ways in. A different design would compare each reported track with the stored series preference instead of with per-play claims. The write becomes idempotent, the next report retries a failed one, and the claim, read-back and replay guard go away. The cost is one preference read per report while a non-default track plays, plus a per-play flag so switching back to the offered default still saves. This is left for the maintainers to settle.
|
🤖 Claude Code (claude-opus-5-5): maintainer review summary, reviewed head 44b1a73 Fit: 8/10 · Readiness: 7/10 — conditional (assuming CI is green) Fit: Jellyfin apps now share the series' remembered tracks with Silo apps through the same preference writes, which closes a real gap for people coming from Jellyfin. The per-play claim and read-back machinery that orders those writes across replicas holds the score down: it is a lot of state for a best-effort preference. Readiness: a before and after walk on one sandbox shows the fix (evidence below), and the two defects this review found are fixed. One design question is open (below). What changed in this review
Left for the maintainers
Checks
|
Problem
Closes #2316
Related issue: N/A
Validation tasks: none
When a viewer switches to another audio track or changes subtitles in a Jellyfin app, Silo forgets it, and the next episode starts on the old default again. Silo already remembers each series' audio and subtitle choice and uses it when jellycompat picks default streams, but only Silo apps ever saved one. The
AudioStreamIndexandSubtitleStreamIndexthat Jellyfin clients report during playback were dropped, so Jellyfin apps and Silo apps also disagreed about which tracks a series uses.This change saves the tracks a Jellyfin client plays as the series' remembered tracks (for a movie, under the movie), the same way a pick in a Silo app is saved.
Approach
jellycompat's playback report handler (
/Sessions/Playing,/Progress,/Stopped) maps the reported stream indexes back to Silo tracks and writes them through the same handlers asPUT /api/v2/audio-prefs/{series_id}andPUT /api/v2/subtitle-prefs/{series_id}. That includes the canonicalprofile_seriessettings rows and change events. Audio saves the track's language and signature. Subtitles save the track's signature and language in modealways, so external and downloaded tracks match by source. A downloaded subtitle is resolved through the IDs PlaybackInfo offered, so deleting an earlier stored subtitle during a play cannot shift a report onto the next one.SubtitleStreamIndex: -1saves modeoffwith no track, as the web player does for subtitles off.Reports cannot tell a viewer's pick from a client's automatic choice, so a track is saved only when it differs from what the server offered for that play, or from the last track saved during it:
RememberAudioSelectionsandRememberSubtitleSelectionsuser settings turn either half off. A track the viewer does not remember is not even claimed on the play, and when the settings cannot be read nothing is saved and the next report tries again.Native apps are unaffected. They read the same stored preference, so a choice made in either kind of app now carries over to the other.
docs/jellycompat-api.mddescribes the rules and drops "remembered subtitle selections" from the list of Jellyfin behavior Silo does not provide.Validation
GET /api/v2/audio-prefs/{series_id}andGET /api/v2/subtitle-prefs/{series_id}return the saved choice. Before the merge, withRememberAudioSelectionsoff, only the subtitle choice was saved; that case was not rerun.go test ./internal/jellycompat/...(track memory tests also under-race),go vetoninternal/jellycompatandcmd/silo,gofmtandmake lint-changedpass. This change does not touchweb/.Evidence
Before and after Jellyfin protocol walks from the same sandbox and data, with the stored preference rows and the native endpoint responses.
Evidence: https://evidence.siloserver.org/r/silo-server/pr-2332/
Risks
docs/jellycompat-api.mdrecords it.off. With forced subtitles shown (the default), the next episode offers only a forced track, which is the same result as turning subtitles off in a Silo app.Follow-ups: none for silo-apple or silo-android, which already save through these endpoints. The user manual does not describe remembered tracks, so it needs no change.
Checklist
AI Disclosure
🤖 Generated with Claude Code
Note
Add audio and subtitle track memory for Jellyfin compatibility playback
rememberCompatTracks, which claims each change once against the stored play and writes preferences with a 10-second timeout (track_memory.go).claimCompatTrackChangein streams.go; overlapping reports reconcile to the latest claimed choice via read-back inlatestCompatTrackClaim.Macroscope summarized 44b1a73.