Skip to content

fix(jellycompat): remember audio and subtitle choices from Jellyfin apps - #2332

Merged
Quick104 merged 14 commits into
mainfrom
fix/jellycompat-remembered-tracks
Nov 15, 2026
Merged

Quick104 merged 14 commits into
mainfrom
fix/jellycompat-remembered-tracks

Conversation

@Quick104

@Quick104 Quick104 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

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 AudioStreamIndex and SubtitleStreamIndex that 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 as PUT /api/v2/audio-prefs/{series_id} and PUT /api/v2/subtitle-prefs/{series_id}. That includes the canonical profile_series settings rows and change events. Audio saves the track's language and signature. Subtitles save the track's signature and language in mode always, 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: -1 saves mode off with 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:

  • Playing the offered defaults saves nothing. This includes the track the viewer's preferences select when PlaybackInfo offered a device fallback in its place (AC3 for TrueHD).
  • Nothing is saved for an audio switch the server refused, an index that names no track, a play that skipped PlaybackInfo (static direct play, which never saw Silo's defaults), or a repeated Stopped report for a finished play.
  • Each change is claimed on the play under the store's lock before it is written, so overlapping reports or a second API replica write it once. After writing, a report reads the play's latest claim back and writes it again until they match, so interleaved writes still leave the latest track, including when a newer Stopped report has already finished the play. A Stopped report, the play's last, is judged against the stored play rather than a replica's cached copy, and a play the stored row has finished saves nothing. A failed write is logged, not retried on every report.
  • Jellyfin's RememberAudioSelections and RememberSubtitleSelections user 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.md describes the rules and drops "remembered subtitle selections" from the list of Jellyfin behavior Silo does not provide.

Validation

  • Main is merged into the branch (04d59a5); it had changed Stopped handling, stored-subtitle URLs (fix(jellycompat): keep a stored subtitle's URL on that subtitle after an earlier one is deleted #4177) and session-store read failures under this code. Review fixes are in 44b1a73.
  • On a dev sandbox built from main (436f0fb), a Jellyfin client walk over the jellycompat API reproduces the bug. The walk calls PlaybackInfo on episode 1, fetches the offered stream, reports Playing on the defaults, reports Progress with English audio and then the full English subtitles, and reports Stopped. Episode 2 still starts on Japanese audio and the forced English subtitles, and no preference is stored.
  • Built from 44b1a73, the same walk starts episode 2 on English audio and the full English subtitles. GET /api/v2/audio-prefs/{series_id} and GET /api/v2/subtitle-prefs/{series_id} return the saved choice. Before the merge, with RememberAudioSelections off, only the subtitle choice was saved; that case was not rerun.
  • Focused Go tests cover the default tracks, a changed pick, subtitles off, the Remember settings, the device fallback, a refused audio switch, unknown indexes, terminal plays, overlapping reports, the source used when a report names none, and a downloaded subtitle reported after an earlier one is deleted. They do not build on main because they call the code this change adds; the sandbox run above is the failing case on main. The downloaded-subtitle test saves the wrong subtitle on 04d59a5 without its fix.
  • On 44b1a73: go test ./internal/jellycompat/... (track memory tests also under -race), go vet on internal/jellycompat and cmd/silo, gofmt and make lint-changed pass. This change does not touch web/.

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

  • A Jellyfin client that plays a track other than the one offered, from its own settings, now saves that track for the series, as Jellyfin itself does. A choice saved from one Jellyfin app also applies to Silo apps for that series.
  • Static direct-play clients that skip PlaybackInfo (Infuse, SenPlayer) still do not save choices.
  • Known gap, accepted: a preference write that stalls until after a later Stopped report has finished the play and its record is removed has no claim to read back, so the older choice can remain. Closing it needs ordering on the stored preference rows (a schema change); docs/jellycompat-api.md records it.
  • Subtitles off is saved as mode 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

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code (in T3 Code)
  • Tool(s): Claude Code subagents for code review; sandbox tooling for a dev Silo deployment
  • Model(s): claude-opus-5-5 (implementation and review finders); claude-sonnet-5-5 (cleanup finder and validation check)
  • Involvement: Fully AI-generated; a maintainer requested the work and has not yet reviewed it
  • Adversarial review: a multi-agent code review (diff and callers, contract and failure modes, cleanup) ran before opening; its confirmed findings are fixed in this branch. A background cross-provider review (gpt-6.1-sol via Codex, reviewed 896ee62) raised three findings: the stale-copy check on Stopped and the terminal-row check are fixed in 3cf87bd; the rolling-update concern is answered in its thread (the existing JSON envelope keeps the new fields, and older binaries fail safe). The Codex GitHub review's findings are fixed: the write-order race in 6718bee, the settings read failure and the bounded read-back in 52046cf, and the cached read-back and opted-out claims in 534be9c. Kody's review led to f4176f7: the play-session callbacks never return errors, because the durable store replays an update after a failed database write and a failing replay would block later writes of the play. The read-back after a Stopped report finished the play is fixed in 8db7648, and a replayed claim overwriting a newer one in 80d41cc. A maintainer review of 04d59a5 (Claude Code with claude-opus-5-5 subagents, and a gpt-6.1-sol round via Codex) fixed a downloaded subtitle saved by its shifted position and the shared write deadline in 44b1a73; whether a failed claim or write should be retried is left as a maintainer decision.

🤖 Generated with Claude Code

Note

Add audio and subtitle track memory for Jellyfin compatibility playback

  • Jellyfin clients now report track selections during playback, and changed audio or subtitle choices are saved as remembered preferences. Preferences are keyed by series ID for episodes and content ID for movies; other item types are skipped.
  • PlaybackInfo stores the item's preference key and offered downloaded-subtitle IDs in the session (playback_sessions.go). Reports are processed by rememberCompatTracks, which claims each change once against the stored play and writes preferences with a 10-second timeout (track_memory.go).
  • Subtitles off (index -1) saves an Off-mode preference. Downloaded subtitles are resolved by their offered ID, so a report stays correct after earlier items in the list are deleted.
  • Users can disable audio or subtitle remembrance in their saved configuration; unreadable settings suppress writes but allow a later retry. A refused audio switch (e.g. rejected by HLS remux limits) is not remembered.
  • Risk: claim callbacks run inside playback-store updates and must never return errors that disrupt store update replays — see claimCompatTrackChange in streams.go; overlapping reports reconcile to the latest claimed choice via read-back in latestCompatTrackClaim.

Macroscope summarized 44b1a73.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T00:11:05.516157Z 44b1a73 New commits
🔒 Security Review ✅ Completed 2026-11-15T00:16:23.671588Z 44b1a73 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Walkthrough

Jellyfin playback reports can now save changed audio and subtitle selections as remembered preferences for episodes and movies. Playback session state tracks the selected indexes, and profile settings control whether each type of preference is saved.

Changes: Jellyfin Track Preference Memory

Layer / File(s) Summary
Preference context and configuration
internal/jellycompat/track_memory.go, internal/jellycompat/server.go, internal/jellycompat/playback_sessions.go, internal/jellycompat/handlers_playback.go, internal/jellycompat/subtitle_selection.go, internal/jellycompat/router.go, cmd/silo/main.go
Playback dependencies now accept audio and subtitle preference writers. Negotiated sessions record a preference key, and configured user stores provide the preference handlers. Saved profile configuration includes optional audio and subtitle remembrance settings, which default to enabled when unset.
Playback report preference updates
internal/jellycompat/streams.go, internal/jellycompat/track_memory.go
Playback reports can claim changed, valid track indexes and save the resulting preferences. Episode preferences use the series key; movie preferences use the content key. The implementation resolves media sources, builds track metadata, and checks current play state before and after writes.
Behavior tests and API documentation
internal/jellycompat/track_memory_test.go, docs/jellycompat-api.md
Tests cover changed and default tracks, settings, failed writes, source selection, and overlapping reports. The API documentation describes saved track choices and includes Jellyfin client choices in the Always-mode description.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant JellyfinClient
  participant handlePlaybackReport
  participant compatSavedConfiguration
  participant PlaybackStore
  participant AudioPreferenceWriter
  participant SubtitlePreferenceWriter
  JellyfinClient->>handlePlaybackReport: Send playback report with track indexes
  handlePlaybackReport->>compatSavedConfiguration: Read profile remembrance settings
  handlePlaybackReport->>PlaybackStore: Claim changed track indexes
  handlePlaybackReport->>AudioPreferenceWriter: Save eligible audio preference
  handlePlaybackReport->>SubtitlePreferenceWriter: Save eligible subtitle preference
Loading

Suggested reviewers: tomislav

Merge Risk: Minimal · up to 534be

This change saves audio and subtitle choices reported by Jellyfin apps. The supplied evidence shows no remaining merge-blocking issue.

Pre-merge checks: Passed 4

Check name Status Explanation
Linked Issues check Passed The description links issue #2316 and the implementation directly addresses its requested Jellyfin audio, subtitle, and subtitles-off preference behavior.
Out of Scope Changes check Passed The code, tests, and documentation changes support the stated objective of remembering Jellyfin audio and subtitle choices. No unrelated changes are indicated.
Title check Passed The title clearly and concisely describes the main change: remembering audio and subtitle choices reported by Jellyfin apps.
Description check Passed The description is specific and on-topic. It explains the problem (Jellyfin clients report AudioStreamIndex and SubtitleStreamIndex that Silo discarded), the approach (saving reported tracks through t…
Full details: Description check

Explanation

The description is specific and on-topic. It explains the problem (Jellyfin clients report AudioStreamIndex and SubtitleStreamIndex that Silo discarded), the approach (saving reported tracks through the existing audio and subtitle preference handlers), the rules for defaults, refused switches, subtitles off, and Remember settings, plus validation and risks. It matches the changeset in the summary, including track_memory.go, streams.go, playback_sessions.go, and the docs update.

Finishing Touches

🧪 Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
ℹ️ Recent review info

⚙️ Run configuration

  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 314f8133-e752-4f04-9e09-f8789792b567
📥 Commits

Reviewing files that changed from the base of the PR and between 5eaeec8 and 534be9c.

📒 Files selected for processing (10)

  • cmd/silo/main.go
  • docs/jellycompat-api.md
  • internal/jellycompat/handlers_playback.go
  • internal/jellycompat/playback_sessions.go
  • internal/jellycompat/router.go
  • internal/jellycompat/server.go
  • internal/jellycompat/streams.go
  • internal/jellycompat/subtitle_selection.go
  • internal/jellycompat/track_memory.go
  • internal/jellycompat/track_memory_test.go

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

@silo-kody

silo-kody Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@silo-triage silo-triage Bot added bug Something isn't working go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish labels Oct 12, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread internal/jellycompat/track_memory.go Resolved

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread internal/jellycompat/track_memory.go Resolved
Comment thread internal/jellycompat/track_memory.go Resolved
// 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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread internal/jellycompat/track_memory.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread internal/jellycompat/track_memory.go Resolved
Comment thread internal/jellycompat/track_memory.go Resolved
Comment thread internal/jellycompat/track_memory.go Resolved
Comment thread internal/jellycompat/track_memory.go Resolved
Comment thread internal/jellycompat/track_memory.go Resolved
@silo-kody

silo-kody Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread internal/jellycompat/track_memory.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread internal/jellycompat/track_memory.go Resolved
@silo-kody

silo-kody Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread internal/jellycompat/track_memory.go Resolved
Quick104 and others added 10 commits November 4, 2026 22:35
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]>
Quick104 and others added 2 commits November 4, 2026 22:35
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]>
@Quick104
Quick104 force-pushed the fix/jellycompat-remembered-tracks branch from 80d41cc to 323c1bf Compare November 5, 2026 03:48
@silo-triage silo-triage Bot added the size/XXL 1000–2999 added + deleted lines (all files); change volume, not priority. label Nov 5, 2026
@silo-kody

silo-kody Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

Comment on lines +215 to +217
if returned.Load() {
return nil
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kody code-review Bug high

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.

​

​

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread internal/jellycompat/track_memory.go Outdated
Comment on lines +127 to +131
if audio != nil {
h.writeRememberedCompatAudio(ctx, session, playSession, source, *audio)
}
if subtitle != nil {
h.writeRememberedCompatSubtitle(ctx, session, playSession, source, *subtitle, subtitlePref)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kody code-review Bug high

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.

​

​

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Quick104 and others added 2 commits November 14, 2026 18:54
…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

silo-kody Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 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:

  1. 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.

  2. The audio and subtitle writes share one deadline (Kody's open thread on this). Confirmed, and I'm fixing it on this branch too.

  3. 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.

Comment thread internal/jellycompat/track_memory.go Resolved
@Quick104

Copy link
Copy Markdown
Contributor Author

🤖 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

  • Maintainer decision: retrying a failed save. A change is claimed on the play before its preference write lands, so a failed claim, a failed write or a failed read-back loses that choice for the rest of the play (Kody's open thread covers the claim case). Either accept this with the documented "a failed write is not retried" rule, or compare each report with the stored series preference so the next report retries. The second option also removes the claim, read-back and replay guard.
  • The rolling-update thread on playback_sessions.go is still open and waiting on a maintainer.
  • Minor items, not fixed:
    • compatCombinedSubtitleIndex re-implements the ordering that playback.BuildSubtitleInventoryV3 owns, and its test compares against a hard-coded map. The index is only a fallback after the signature match.
    • A viewer who turned remembering off and plays a non-default track has their settings read on every Progress report.
    • A play that DELETE /Videos/ActiveEncodings marks finished before the Stopped report arrives skips the Stopped check. It is unconfirmed which clients send them in that order.

Checks

  • Validated features: no passed 1.0 validation case reaches this code. Validation tasks: none stands.
  • Tests: the PR's tests do not build on main because they call code this change adds. The new downloaded-subtitle test fails on 04d59a5 without its fix.
  • User manual: it does not describe remembered tracks or list them among the Jellyfin differences, so no change is needed.
  • Other clients: none. Apple and Android already save through these endpoints, and this changes only what Jellyfin apps save.
  • Review method: Claude Code subagents (diff and callers, contract and failure modes, cleanup, validation impact), and one gpt-6.1-sol round via Codex on 04d59a5. Both found the deadline and claim-failure cases, and the Codex round found the downloaded-subtitle shift.

Evidence: https://evidence.siloserver.org/r/silo-server/pr-2332/

@Quick104
Quick104 merged commit 16d43dc into main Nov 15, 2026
20 checks passed
@Quick104
Quick104 deleted the fix/jellycompat-remembered-tracks branch November 15, 2026 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish size/XXL 1000–2999 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Jellyfin apps forget audio and subtitle choices on the next episode

1 participant