Skip to content

refactor(playback): make server the authority for default edition and version order - #5835

Merged
Quick104 merged 6 commits into
mainfrom
feat/server-selection-authority
Dec 4, 2026
Merged

Quick104 merged 6 commits into
mainfrom
feat/server-selection-authority

Conversation

@Quick104

@Quick104 Quick104 commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: none

Other clients: Apple Silo-Server/silo-apple#1357; Android Silo-Server/silo-android#1133; Roku Silo-Server/silo-roku#128

Default edition and version selection lived in five places that disagreed. On a multi-edition title where a non-default cut (such as a 4K Director's Cut) had a lower file ID than the Theatrical cut, /api/v2/catalog/items/{id} and /api/v2/watch/{id} ordered playback_variants by lowest file ID, Watch Together chose the lowest file ID directly, and each client re-ranked editions and versions locally. Direct-play paths and Watch Together rooms could open a different cut than the detail page, and every client duplicated the same edition and quality sorting rules.

This change makes the server the authority for default edition and version order via the existing playback_variants and versions arrays, reuses that order in Watch Together, removes the duplicate client ranking from the web app, and adds a shared cross-client subtitle selection conformance fixture.

Approach

  • internal/catalog/detail.go adds EditionPreferenceRank and OrderPlaybackVariants so playback_variants[0] is the server's recommended edition for the acting viewer: explicit remembered edition (effective_version_edition_key), then user_data.last_edition_key, then the edition holding user_data.last_file_id, then standard/unnamed editions, then theatrical editions, then other cuts, breaking ties by lowest file ID. Both catalog detail and watch-state builders apply this order.
  • internal/watchtogether/selection_resolver.go reuses OrderPlaybackVariants for default room selection so Watch Together picks the same default cut as catalog detail instead of the lowest file ID.
  • /api/v2 wire shapes stay unchanged; internal/apiv2/{catalog_items,watch,playback}.go, contracts/api/v2/openapi.json, web/src/api/v2/schema.ts, and docs/catalog-api.md document the server-owned ordering and concrete file_id start contract. Quality caps stay on the client because network tier is local to the device, and subtitle auto-resolution stays client-finalized because OS caption profiles and per-device burn-in support differ across platforms.
  • web/src/pages/ItemDetail/components/versionRankingUtils.ts and versionOptions.ts drop local edition preference and version re-sorting, opening on playback_variants[0] (or an explicit pick) and filtering that variant's server-ordered versions against the local quality cap.
  • contracts/playback/subtitle-selection-conformance.json defines 13 cross-client subtitle auto-selection cases exercised in web and mirrored in the paired Apple, Android, and Roku PRs.

Validation

  • Go build, formatting, vet, lint, and contracts: make embed-stub, go build ./..., gofmt -l ., go mod tidy -diff, go vet ./..., make lint-changed, make lint-router-recovery, make verify-fork-pins, verify-settings-bindings-all, verify-playback-fixtures, verify-route-inventory, verify-apiv2-openapi, verify-apiv2-web-types, verify-apiv2-contract (0 breaking changes), verify-apiv2-fixtures, TestCommittedArtifactMatchesRouter, verify-local-paths, verify-case-collisions, verify-size-ratchet, verify-bidi, and verify-migrations all passed.
  • Go test suite: make test-go passed across all packages (including new edition-ordering and Watch Together tests).
  • Web gates: pnpm run lint, pnpm run format:check, pnpm run build, pnpm run budget:check, and make test-web (375 files, 3,611 tests, including all 13 subtitle conformance cases) all passed.
  • Live sandbox end-to-end check: verified against an isolated server sandbox on multi-edition movies where a 4K alternate cut had a lower file ID than a 1080p Theatrical cut. Confirmed /api/v2/catalog/items/{id}, /api/v2/watch/{id}, and Watch Together room selection all chose Theatrical first; verified remembered-edition promotion flipped both /items and /watch after starting an Extended cut; verified the web detail page opened on Theatrical, listed editions in server order, and streamed playback with concrete file_id and omitted audio_track_index/subtitle_track_index. Desktop web was exercised live; phone-width web layout was not separately captured because this change alters selection order rather than responsive layout.

Evidence

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

Risks

  • Clients that have not updated yet still re-rank playback_variants locally and stay compatible because no /api/v2 field names, types, or statuses changed.
  • Clients running against an older server that orders playback_variants by lowest file ID will open on that server order until the server updates.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or how I checked a change nobody sees.

AI Disclosure

  • Harness: Antigravity in T3 Code
  • Tool(s): GitHub CLI; T3 Code browser preview; silo-dev-builder sandbox; silo-evidence
  • Model(s): gemini-4-neon-xhigh; architecture review council members claude-opus-5-5 (high) and gpt-6.2-sol (high)
  • Involvement: Fully AI-generated; human verification pending
  • Adversarial review: pre-implementation architecture review across claude-opus-5-5 and gpt-6.2-sol, which settled keeping concrete file_id at start, keeping quality caps and subtitle defaults client-finalized, reusing server edition ordering in Watch Together, and omitting automatic audio_track_index on Apple.

Note

Make the server authoritative for default edition and version ordering

  • Adds OrderPlaybackVariants in detail.go, which orders playback variants by explicit selected file, saved edition or file history, edition preference class, and first-part quality. Adds SelectPlaybackMarkers so all markers come from one source version instead of being filled from other cuts.
  • Applies the same ordering in the catalog, watch-detail, and Watch Together handlers. Watch Together room selection in selection_resolver.go now uses playback-variant order instead of picking the lowest file ID.
  • Removes client-side edition and file re-ranking in versionRankingUtils.ts. The client keeps only the local resolution cap within the server-ordered list; selectDefaultPlaybackVariantVersion falls back to the first server-ordered edition.
  • Adds resolveSubtitleAutoSelect filtering by isDeliverableSubtitleCodec in subtitleSort.ts, with a shared conformance fixture copied to the web app and a test keeping both copies in sync.
  • Updates API docs and OpenAPI schemas in catalog-api.md and openapi.json to describe server ordering, recommended file IDs, and part ordering.
  • Behavioral Change: nil markers on a chosen source version are no longer inherited from another cut; Watch Together defaults may differ when the lowest file ID was previously chosen; removed helpers include bestEditionAuto, editionPreference, compareServerOrder, playbackVersionExists, and selectedPlaybackMarker in the web and catalog packages.

Macroscope summarized b7400e2.

@silo-triage silo-triage Bot added the size/XL 500–999 added + deleted lines (all files); change volume, not priority. label Dec 3, 2026
@silo-kody

silo-kody Bot commented Dec 3, 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 commented Dec 3, 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-12-04T15:25:39.130222Z b7400e2 New commits
🔒 Security Review ✅ Completed 2026-12-04T15:26:56.922144Z b7400e2 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 Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 18 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

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: 5b6d62cc-9d6f-4231-b4a8-755caec32ac4
Commits

Reviewing files that changed from the base of the PR and between ae978da and b7400e2.

Files selected for processing: 20

  • contracts/api/v2/openapi.json
  • contracts/playback/subtitle-selection-conformance.json
  • docs/catalog-api.md
  • internal/api/handlers/catalog_resources.go
  • internal/api/handlers/watch_state_service.go
  • internal/apiv2/catalog_items.go
  • internal/apiv2/playback.go
  • internal/apiv2/watch.go
  • internal/catalog/detail.go
  • internal/catalog/playback_variant_order_test.go
  • internal/watchtogether/selection_resolver.go
  • internal/watchtogether/selection_resolver_test.go
  • web/src/api/v2/schema.ts
  • web/src/pages/ItemDetail/components/versionOptions.ts
  • web/src/pages/ItemDetail/components/versionRankingUtils.test.ts
  • web/src/pages/ItemDetail/components/versionRankingUtils.ts
  • web/src/player/utils/subtitleCodecs.ts
  • web/src/player/utils/subtitleSelectionConformance.json
  • web/src/player/utils/subtitleSort.test.ts
  • web/src/player/utils/subtitleSort.ts
Walkthrough

The server now orders playback variants using viewer and edition preferences. Watch Together and web clients use that order when selecting versions. The web subtitle selector filters undeliverable codecs and updates automatic track selection. API descriptions and a shared conformance fixture document these behaviors.

Changes: Playback variant ordering

Layer / File(s) Summary
Server variant ordering and API contract
internal/catalog/detail.go, internal/catalog/playback_variant_order_test.go, internal/api/handlers/*, internal/apiv2/*, contracts/api/v2/openapi.json, docs/catalog-api.md
The catalog orders variants by selected file, remembered edition or file, edition preference, and first-part quality. Marker selection uses the selected file or first ordered variant default. API descriptions document recommended files, version ordering, and client selection guidance.
Watch Together version selection
internal/watchtogether/selection_resolver.go, internal/watchtogether/selection_resolver_test.go
Watch Together checks readable versions in playback-variant order. Its fallback considers readability, presentation-part order, edition preference, and quality.
Web version selection
web/src/api/v2/schema.ts, web/src/pages/ItemDetail/components/*
The web client preserves server edition and version order when selecting defaults and building edition options. It applies the local quality cap to server-ordered versions.

Subtitle auto-selection

Layer / File(s) Summary
Subtitle selection and conformance
web/src/player/utils/subtitleCodecs.ts, web/src/player/utils/subtitleSort.ts, web/src/player/utils/subtitleSort.test.ts, contracts/playback/subtitle-selection-conformance.json, web/src/player/utils/subtitleSelectionConformance.json, internal/apiv2/playback.go, web/src/api/v2/schema.ts, contracts/api/v2/openapi.json
The web selector filters undeliverable codecs, checks exact track signatures, and applies language and forced-track rules. The shared fixture defines expected selections, and API descriptions explain omitted audio and subtitle selectors.

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

Change: Bug fix

Possibly related issues

  • Silo-Server/silo-server issue 1159 — The changes add shared conformance cases for automatic subtitle selection from audio and forced-track fixtures.
  • Silo-Server/silo-server issue 1157 — The changes cover automatic subtitle selection by detected audio language, but do not address the other stated criteria.
  • Silo-Server/silo-server issue 5738 — The changes define server-side version ordering that a preview could display, but do not add the requested preview endpoint.

Suggested reviewers: rhainland, rangodj, blurbery

Merge Risk: Minimal · previous review ae978

The server now decides the default playback edition and version order, and the web client, Watch Together and subtitle selection follow it. The markers and picker-default concerns raised earlier are fixed in this revision. No remaining merge-blocking issue was found.

Security architecture risk: Moderate · up to ae978

Centralizing playback recommendations makes the default more consistent across clients. The main risk is in Watch Together: a room can now default to a cut that a viewer cannot play, even when the cut previously selected would have worked. Automatic recovery stays within the selected cut, so the host may need to choose another file explicitly.

Retained concerns

  • Minor · reliability · inferred: A readable opening file is not necessarily playable under a viewer's device capabilities or server policy. For example, the new canonical order can choose an HDR-only cut ahead of a lower-ID SDR cut that the merge base would have selected. If playback refuses the HDR source and that cut has no eligible sibling, automatic fallback cannot choose the playable SDR cut and leaves the room on the refused file. Preserve the shared timeline once playback starts, but make the recovery path explicit when the newly chosen default cannot play and another cut requires a fresh host selection.

View findings in the submitted review

Security review details

Security Blast Radius

  • observed — A personalized recommendation affects the acting viewer's detail response. A room's resolved file affects every participant's shared timeline, but the room selection does not grant access to that file. Playback independently checks the requesting viewer's item and file access, and room attachment checks that the playback session matches the selected file.

Trust Boundaries and Controls

  • observed — The requested content, library, and file IDs influence room selection through the acting profile's catalog access filter. An explicitly requested file must occur in the returned versions. Playback start authorizes the supplied file again before probing or planning, so the recommendation does not substitute for authorization.

Dependencies

  • observed — Web Item Detail uses server order for its unpinned default after explicit and remembered choices. It applies the device's quality cap within the chosen edition; when known versions exist but none fit, it selects the lowest known resolution in that edition rather than comparing other cuts.

Data and control flow

  • observed — Top-level markers follow the explicitly selected or recommended file. When that file has no marker, the server no longer fills the gap with timestamps from another cut.

Resilience and Maintainability Implications

  • observed — Watch Together resolves the file before staging and checks host identity and lobby state before persisting it. After a playback refusal, only a connected member can trigger fallback for the current revision and failed file. A successful replacement advances the revision and resets attachment readiness; a missing replacement leaves the selection unchanged. This protects against stale reports and timeline switches, but cannot repair a newly preferred cut for which no eligible same-timeline version exists.

Rollout and rollback

  • inferred — Clients adopting server-order selection need a server that supplies recommendation order. If only the server is rolled back, those clients can consume the older ordering without a schema error and silently change the default cut. In Watch Together, the host can avoid the implicit default by selecting an accessible file explicitly; the player still decides whether each viewer can play that file.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the server becomes the authority for default edition and playback version order. The changeset matches this. It adds OrderPlaybackVariants and SelectPlaybackMarkers in…
Description check Passed The description states the problem, the approach, validation steps, risks, and a live evidence link. It covers the server-side ordering, the Watch Together change, the web client changes, and the shar…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the server becomes the authority for default edition and playback version order. The changeset matches this. It adds OrderPlaybackVariants and SelectPlaybackMarkers in detail.go, applies that order in catalog and watch handlers, reuses it in Watch Together, and removes client-side edition and version ranking in the web app. The title uses the conventional refactor(playback) prefix and is 83 characters, which is acceptable.

Full details: Description check

Explanation

The description states the problem, the approach, validation steps, risks, and a live evidence link. It covers the server-side ordering, the Watch Together change, the web client changes, and the shared subtitle conformance fixture. The description is clearly related to the changeset.

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

@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: 16ce9e3bb8

ℹ️ 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 web/src/player/utils/subtitleSort.ts Outdated
Comment on lines +255 to +256
if (showForcedSubtitles) {
const anyForced = playable.filter((track) => track.forced);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Match the audio language when falling back to forced subtitles

When Auto cannot find the preferred subtitle language and showForcedSubtitles is enabled, this fallback selects a forced track in any language. For example, English subtitle preferences with Japanese audio and only a French forced track now automatically enable French subtitles. It can also choose an unrelated-language track over an available audio-language forced track based on format priority. Use the existing audio-language-aware forcedForAudio() fallback instead of searching all forced tracks.

Useful? React with 👍 / 👎.

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.

Fixed in 384de309c6: replaced the unconditional forced-track fallback with forcedForAudio() and added two conformance cases in contracts/playback/subtitle-selection-conformance.json. 🤖 Antigravity (gemini-4-neon)

Comment thread internal/catalog/detail.go Outdated
Comment on lines +5078 to +5082
if effectiveEditionKey != nil {
k := strings.ToLower(strings.TrimSpace(*effectiveEditionKey))
rememberedKey = &k
} else if userData != nil && userData.LastEditionKey != nil {
k := strings.ToLower(strings.TrimSpace(*userData.LastEditionKey))

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 medium

Unavailable effective edition skips the remembered edition fallback

An unavailable effectiveEditionKey causes selection to skip an available LastEditionKey and fall back to LastFileID or default ranking. Try each remembered key in priority order, falling back only when it has no matching variant.

Prompt for LLM
File internal/catalog/detail.go, lines 5078-5082:

Unavailable effective edition skips the remembered edition fallback

When the effective edition key is unavailable among accessible variants, the code skips `LastEditionKey` and falls directly to `LastFileID` or default ranking, even if the last edition is still available. Try each remembered key in priority order and fall back only when the preceding key has no matching variant.

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.

Fixed in 1a2e591310: OrderPlaybackVariants now tries effectiveEditionKey, then userData.LastEditionKey, then userData.LastFileID in priority order, falling through whenever a hint matches no accessible variant (TestOrderPlaybackVariantsRememberedFallback). 🤖 Antigravity (gemini-4-neon)

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 the update. The described fallback order addresses the suggestion: if the effective edition is unavailable, selection tries the remembered edition before falling back to the last file. The added test is intended to cover that behavior.

I haven’t independently verified the commit or test.

}

resolved.FileID = new(preferredRoomVersion(detail.Versions).FileID)
resolved.FileID = new(preferredRoomVersion(detail).FileID)

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 medium

Watch Together ignores the host's remembered edition

A host who last watched a non-default cut can get a different edition than the catalog and watch endpoints recommend because DetailService.GetWatchDetail does not load that preference. Load and apply the host's edition preference before selecting the room version.

Prompt for LLM
File internal/watchtogether/selection_resolver.go, line 56:

Watch Together ignores the host's remembered edition

The room resolver receives variants from `DetailService.GetWatchDetail`, which never loads the host's remembered edition, so a host who last watched a non-default cut gets a different edition than the catalog and watch endpoints recommend. Load and apply the host's edition preference before selecting the room version.

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.

Intentional: Watch Together rooms use viewer-agnostic canonical edition order (detail.PlaybackVariants[0]) so a shared room starts on the canonical cut rather than one member's personal watch history. Clarified docs/catalog-api.md in 1a2e591310 to state this explicitly, and updated preferredVariantRoomVersion to prefer opening parts (PartIndex <= 1) over later-part-only variants. 🤖 Antigravity (gemini-4-neon)

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 clarifying. The suggestion to apply the host’s remembered edition is not applicable: Watch Together intentionally uses viewer-agnostic canonical ordering so the room does not inherit one participant’s personal history.

The opening-part preference also addresses the case where a variant contains only later parts. I haven’t independently verified the documentation or code changes.

Would you like me to save the viewer-agnostic selection decision as a repository memory for future reviews?

Comment on lines 190 to 193
parts.flatMap((p) => p.versions),
);
}
const order = new Map(versions.map((v, i) => [v.file_id, i]));
const position = (v: FileVersion) => order.get(v.file_id) ?? Number.MAX_SAFE_INTEGER;
for (const edition of editions.values()) {
edition.versions.sort((a, b) => position(a) - position(b));
}
} else {

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 medium

Merged presentations can select a lower-quality file under the local cap

Concatenating individually sorted presentations can cause a 1080p cap to select a 480p file before a later 1080p file. Restore the top-level versions ordering after merging each edition's first-part versions.

Prompt for LLM
File web/src/pages/ItemDetail/components/versionRankingUtils.ts, lines 190-193:

Merged presentations can select a lower-quality file under the local cap

When one edition has multiple presentations, concatenating their individually sorted versions leaves the merged list out of quality order, so a 1080p cap can select the first presentation's 480p file before a later presentation's 1080p file. Restore the top-level server ordering after merging each edition's first-part versions.

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.

Fixed in 384de309c6: merged edition version lists now restore the server's top-level versions order via byServerOrder, covered by versionRankingUtils.test.ts. 🤖 Antigravity (gemini-4-neon)

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 addressing the suggestion. The reported fix restores the server’s top-level version order after merging presentations, with a test covering the change. I haven’t independently verified the commit.

Comment on lines +243 to 246
const exactMatch = findExactSubtitleSignatureMatch(playable, signature);
if (exactMatch !== null) return exactMatch;
if (preferredLanguage === "") return null;
if (!preferredSubtitleLang || sameLanguageCode(audioLang, preferredSubtitleLang)) {

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

Saved subtitle signatures bypass Auto mode language checks

A saved track can override matching audio or an empty preferredLanguage that disables subtitles. Move findExactSubtitleSignatureMatch after Auto mode's language checks.

Prompt for LLM
File web/src/player/utils/subtitleSort.ts, lines 243-246:

Saved subtitle signatures bypass Auto mode language checks

A saved signature now selects a full subtitle track before Auto checks whether the audio already matches the preferred language or subtitles are explicitly disabled with an empty language. Move the signature match after the Auto mode's language checks so saved tracks do not override those settings.

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.

Intentional cross-client behavior: an exact saved track signature outranks same-language suppression in auto mode across Web, Apple, Android (AutoSubtitleResolver), and Roku (guarded by conformance case auto_exact_track_signature_wins_over_same_language_suppression) so an explicit series/movie pick such as English SDH on an English show is preserved; mode="off" disables it. 🤖 Antigravity (gemini-4-neon)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Understood. I withdraw the recommendation to move the signature match past the same-language check: the conformance case confirms that a saved exact track is intended to win in auto mode. Use mode="off" to disable it.

The empty preferredLanguage case is a separate question; the cited conformance case does not establish its intended behavior. Should an exact saved signature also take precedence when preferredLanguage is empty?

Would you like me to preserve the confirmed same-language behavior as a repository memory for future reviews?

Comment thread web/src/player/utils/subtitleSort.ts Outdated
Comment on lines +255 to +256
if (showForcedSubtitles) {
const anyForced = playable.filter((track) => track.forced);

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 medium

Auto mode selects forced subtitles in an unrelated language

Viewers can receive forced subtitles in a language unrelated to their audio. Restrict anyForced to tracks matching the appropriate audio language.

Prompt for LLM
File web/src/player/utils/subtitleSort.ts, lines 255-256:

Auto mode selects forced subtitles in an unrelated language

When no track matches the preferred subtitle language, this fallback selects any forced track regardless of its language, so an English-speaking viewer can receive forced subtitles in an unrelated language. Restrict forced-track fallback to the appropriate audio language.

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.

Fixed in 384de309c6: restricted the Auto forced-subtitle fallback to forcedForAudio() so unrelated-language forced tracks are ignored. 🤖 Antigravity (gemini-4-neon)

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 the update. The reported fix in 384de309c6 addresses the concern by limiting the fallback to forced subtitles matching the audio language. I haven’t independently verified the commit.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments

Major 1
  1. Make the shared fixture available to the web-test job.
Minor 6
  1. Limit the quality-order claim to video items.
  2. Document the quality comparison before the file-ID tie-break.
  3. Describe the single remembered-edition priority.
  4. The version picker can default to an unmeasured file while playback selects a measured file.
  5. Catalog detail keeps markers from the pre-promotion cut.
  6. Document how clients use default_file_id within each part.
Trivial 1
  1. Watch Together consumes catalog order but bypasses the viewer preference enrichment that gives that order its documented meaning. For a host whose remembered cut differs from the catalog's generic first playable cut, a room selection without a file ID can stage a different timeline even when both cuts are readable. The merge base already allowed disagreement by selecting the lowest-file-ID cut; the PR changes that rule without delivering the advertised shared default. Decide whether rooms should use the host's personalized recommendation or an explicitly documented room-specific default; keep the readable-source fallback explicit either way.
Nitpick 1
  1. Use a variant order that differs from flat fallback.
    internal/watchtogether/selection_resolver_test.go, lines 74 · 📐 Maintainability & Code Quality · ⚡ Quick win
    Both assertions expect standard file 2. If preferredRoomVersion stops reading PlaybackVariants, this test still passes because flat fallback also selects file 2.
    Add a case with Director's Cut first in the supplied variant order, as a remembered edition would produce. Expect file 1 with variants and file 2 without variants. This checks the resolver's new ordering contract independently of edition-name ranking.
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: 60d87002-3001-42e0-859e-279ec8caf0e1
Commits

Reviewing files that changed from the base of the PR and between a55887d and 16ce9e3.

Files selected for processing: 19

  • contracts/api/v2/openapi.json
  • contracts/playback/subtitle-selection-conformance.json
  • docs/catalog-api.md
  • internal/api/handlers/catalog_resources.go
  • internal/api/handlers/watch_state_service.go
  • internal/apiv2/catalog_items.go
  • internal/apiv2/playback.go
  • internal/apiv2/watch.go
  • internal/catalog/detail.go
  • internal/catalog/playback_variant_order_test.go
  • internal/watchtogether/selection_resolver.go
  • internal/watchtogether/selection_resolver_test.go
  • web/src/api/v2/schema.ts
  • web/src/pages/ItemDetail/components/versionOptions.ts
  • web/src/pages/ItemDetail/components/versionRankingUtils.test.ts
  • web/src/pages/ItemDetail/components/versionRankingUtils.ts
  • web/src/player/utils/subtitleCodecs.ts
  • web/src/player/utils/subtitleSort.test.ts
  • web/src/player/utils/subtitleSort.ts

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

Comment thread contracts/api/v2/openapi.json Resolved
Comment thread contracts/api/v2/openapi.json Resolved
Comment thread docs/catalog-api.md Resolved
Comment thread docs/catalog-api.md Resolved
@silo-triage silo-triage Bot added size/XXL 1000–2999 added + deleted lines (all files); change volume, not priority. and removed size/XL 500–999 added + deleted lines (all files); change volume, not priority. labels Dec 4, 2026
@silo-kody

silo-kody Bot commented Dec 4, 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 +159 to +162
detail.Intro, detail.Credits, detail.Recap, detail.Preview = catalog.SelectPlaybackMarkers(
detail.Versions, detail.PlaybackVariants, v.Access.SelectedFileID,
detail.Intro, detail.Credits, detail.Recap, detail.Preview,
)

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 medium

Preferred editions inherit markers from another cut

The catalog response can expose timestamps from a different cut when the preferred edition lacks intro or credits markers. Change selectedPlaybackMarker to use only the promoted variant's default file and leave missing markers unset.

Prompt for LLM
File internal/api/handlers/catalog_resources.go, lines 159-162:

Preferred editions inherit markers from another cut

When the viewer's preferred edition has no intro or credits marker, `selectedPlaybackMarker` scans subsequent editions and returns their marker, so the catalog response exposes timestamps from a different cut. Select markers only from the promoted variant's default file and leave missing markers unset rather than falling back to another edition.

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.

Fixed in 1a2e591310: SelectPlaybackMarkers now reads markers solely from selectedFileID or variants[0].DefaultFileID (including nil) instead of scanning subsequent cuts (TestSelectPlaybackMarkers). 🤖 Antigravity (gemini-4-neon)

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 the update. The described fix addresses the cross-edition marker fallback, and TestSelectPlaybackMarkers covers the selection behavior. I haven’t independently verified the commit or test results.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments

Major 1
  1. Test fixtures fail the web typecheck.
Trivial 2
  1. Watch Together shares the catalog comparator but not the viewer preference inputs. The API guide describes room defaults as reusing the acting viewer's order, yet a host whose remembered cut differs from the canonical cut can stage a different timeline when no file ID is supplied, even when both cuts are readable. Disagreement was possible in the merge base, but the new rule does not deliver the newly documented agreement. Should rooms use the host's personalized recommendation or explicitly promise a viewer-agnostic default? Keep the readable-source fallback explicit either way.
  2. The new room selector treats the first visible part of the first readable variant as an opening part. If only part two of a preferred cut is visible, it can now displace a complete, lower-ID cut that the merge base would have started from the beginning. The fallback used after a playback refusal is pinned to the selected presentation and part, so it cannot repair that choice. For implicit room starts, distinguish a readable opening part from a readable later part before committing the shared source.
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: ca512ee9-cd28-4adf-b5a3-f67a3df46091
Commits

Reviewing files that changed from the base of the PR and between 16ce9e3 and 384de30.

Files selected for processing: 11

  • contracts/playback/subtitle-selection-conformance.json
  • internal/api/handlers/catalog_resources.go
  • internal/api/handlers/watch_state_service.go
  • internal/catalog/detail.go
  • internal/catalog/playback_variant_order_test.go
  • internal/watchtogether/selection_resolver.go
  • web/src/pages/ItemDetail/components/versionRankingUtils.test.ts
  • web/src/pages/ItemDetail/components/versionRankingUtils.ts
  • web/src/player/utils/subtitleSelectionConformance.json
  • web/src/player/utils/subtitleSort.test.ts
  • web/src/player/utils/subtitleSort.ts
Files skipped from review as they are similar to previous changes: 1

  • internal/watchtogether/selection_resolver.go

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

@silo-kody

silo-kody Bot commented Dec 4, 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 ❌
⚠️ 4 Kody Rule(s) were not evaluated

These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:

  • Preserve optional store capabilities through production wrappers
  • Detach mandatory cleanup from request cancellation and bound its lifetime
  • Preserve durable media identity and share identity-evidence precedence
  • Bound decoder throughput trades and share direct-play eligibility

@silo-kody

silo-kody Bot commented Dec 4, 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 ❌
⚠️ 4 Kody Rule(s) were not evaluated

These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:

  • Preserve optional store capabilities through production wrappers
  • Detach mandatory cleanup from request cancellation and bound its lifetime
  • Preserve durable media identity and share identity-evidence precedence
  • Bound decoder throughput trades and share direct-play eligibility

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments

Minor 1
  1. A readable opening file is not necessarily playable under a viewer's device capabilities or server policy. For example, the new canonical order can choose an HDR-only cut ahead of a lower-ID SDR cut that the merge base would have selected. If playback refuses the HDR source and that cut has no eligible sibling, automatic fallback cannot choose the playable SDR cut and leaves the room on the refused file. Preserve the shared timeline once playback starts, but make the recovery path explicit when the newly chosen default cannot play and another cut requires a fresh host selection.
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: 6650a90f-263e-4286-a52f-eed9ad38d405
Commits

Reviewing files that changed from the base of the PR and between 618f8df and ae978da.

Files selected for processing: 11

  • contracts/api/v2/openapi.json
  • docs/catalog-api.md
  • internal/apiv2/catalog_items.go
  • internal/apiv2/watch.go
  • internal/catalog/detail.go
  • internal/catalog/playback_variant_order_test.go
  • internal/watchtogether/selection_resolver.go
  • internal/watchtogether/selection_resolver_test.go
  • web/src/api/v2/schema.ts
  • web/src/pages/ItemDetail/components/versionOptions.ts
  • web/src/pages/ItemDetail/components/versionRankingUtils.test.ts
Files skipped from review as they are similar to previous changes: 1

  • internal/apiv2/watch.go

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

@Quick104
Quick104 merged commit 94a3690 into main Dec 4, 2026
18 checks passed
@Quick104
Quick104 deleted the feat/server-selection-authority branch December 4, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

1 participant