Skip to content

fix(catalog): assign external subtitle track indexes#451

Open
RXWatcher wants to merge 2 commits into
Silo-Server:mainfrom
RXWatcher:fix/catalog-external-subtitle-index
Open

fix(catalog): assign external subtitle track indexes#451
RXWatcher wants to merge 2 commits into
Silo-Server:mainfrom
RXWatcher:fix/catalog-external-subtitle-index

Conversation

@RXWatcher

@RXWatcher RXWatcher commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • assign each external subtitle its ordinal in the playback combined-index space
  • preserve existing ffprobe indexes for embedded subtitle streams
  • add regression coverage for multiple external subtitles alongside embedded tracks

Without this, every external subtitle serialized with index 0, producing duplicate client keys and allowing the wrong subtitle track to be selected.

Verification

  • go test ./internal/catalog
  • git diff --check upstream/main...HEAD

Summary by CodeRabbit

  • Bug Fixes

    • Fixed external subtitle tracks receiving duplicate or ambiguous indexes.
    • Improved subtitle selection and URL resolution when media includes both embedded and external subtitles.
  • Tests

    • Added coverage verifying unique indexes and correct external-track identification.

buildVersionSubtitleTracks never set Index on external subtitle entries,
so every external sub in a version's subtitle_tracks serialized the zero
value. Any file with two external subs (or one external plus an embedded
stream index 0) published duplicate indexes; clients keying subtitle
rows on index crashed (Compose LazyColumn duplicate key) or resolved
selections against the wrong track. Externals now carry their
combined-space ordinal (externals occupy 0..n-1 in the playback
selection space — the same identity session subtitle_urls and
ResolveSubtitlePolicyV3 use); embedded entries keep their ffprobe stream
indexes unchanged.
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@RXWatcher, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 48 minutes

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

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e60d146b-edf4-4e73-8869-a184d07c776b

📥 Commits

Reviewing files that changed from the base of the PR and between 63be693 and 4825d3d.

📒 Files selected for processing (4)
  • internal/catalog/detail.go
  • internal/catalog/detail_subtitle_tracks_test.go
  • internal/jellycompat/streams.go
  • internal/jellycompat/subtitle_selection_test.go
📝 Walkthrough

Walkthrough

External subtitle tracks now receive deterministic sequential indexes during track construction. A new test verifies external index uniqueness, embedded index preservation, track count, and external-track marking.

Changes

Subtitle Track Indexing

Layer / File(s) Summary
External index assignment and validation
internal/catalog/detail.go, internal/catalog/detail_subtitle_tracks_test.go
buildVersionSubtitleTracks assigns sequential indexes to external subtitles, while the new test verifies combined track identity and preserved embedded indexes.

Estimated code review effort: 2 (Simple) | ~5 minutes

Suggested labels: v1

Suggested reviewers: quick104

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: assigning indexes to external subtitle tracks in catalog.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot added the v1 Silo v1 scope - auto-adds to the Silo v1 project label Jul 22, 2026

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/catalog/detail.go`:
- Around line 3415-3421: The external subtitle loop in
internal/catalog/detail.go lines 3415-3421 must assign collision-free full
playback indexes, not local ordinals: follow the same positive-index and
zero-fallback contract used by downstream selectors, accounting for video,
audio, and embedded subtitle indexes. Add collision cases and assert both
consumer-facing and serialized indexes in
internal/catalog/detail_subtitle_tracks_test.go lines 15-42.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f392177d-70fc-4d98-8437-81ae4c686a97

📥 Commits

Reviewing files that changed from the base of the PR and between 0a91444 and 63be693.

📒 Files selected for processing (2)
  • internal/catalog/detail.go
  • internal/catalog/detail_subtitle_tracks_test.go

Comment thread internal/catalog/detail.go Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v1 Silo v1 scope - auto-adds to the Silo v1 project

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant