Skip to content

fix(tv): re-read the episode rail after the player's stop lands - #954

Merged
Quick104 merged 2 commits into
mainfrom
fix/tv-series-refresh-after-stop
Nov 15, 2026
Merged

Quick104 merged 2 commits into
mainfrom
fix/tv-series-refresh-after-stop

Conversation

@Quick104

@Quick104 Quick104 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem

On Android TV, coming back to a series page from the player could leave the episode rail out of date. The episode just played kept its old progress bar and had no watched badge, and the season's watched count stayed stale until the page resumed again. An episode page's rail had the same problem.

The player sends its final progress and stops the session in a background job after it closes. The detail page refreshes as soon as it resumes. #845 made the page's own detail read wait for that stop, but only when the page itself was the title played. A series page never qualified, because the player records its return under the episode, not the series. So the season list and the episode rail were read before the stop landed, and nothing read them again afterwards.

Found in review of #847. The defect itself is on main, from #845.

Solution

refreshOnReturn now tells quietRefresh when it consumed a playback return for this page: the series return, the Next Up episode's, or the page's own. In that case quietRefresh starts a job that waits for the stop, waits for the episode load already running to finish, and then reads the season list and the selected season's episodes again with fresh reads. The refresh at resume still runs first, so the rail picks up the local progress overlay right away.

The job waits for any running episode load before its fresh read, including one a season change starts during the wait, because a fresh read has no cache fallback. If it replaced the cache-backed load for a season the return or the viewer had just selected, and then failed (offline, or a flaky network), the season would snap back. A newer playback return replaces a read still waiting.

The rail refresh moved into refreshEpisodeRails. The code inside is unchanged.

Validation

  • New ViewModel test seriesReturnRereadsEpisodesAndSeasonsAfterThePlayerStopLands in TvNextUpSelectionHandoffTest. It opens a series page, records the player's returns, keeps the stop pending until the page's reads have answered, then lands the stop with episode 1 watched. It asserts that the rail shows episode 1 watched and that Season 1 counts as watched. It fails on the base (d1c36e7): it times out because nothing reads again after the stop. It passes with the fix.
  • :androidTvApp:testDebugUnitTest (1,403 tests), :androidTvApp:lintDebug, and :androidTvApp:assembleDebug pass.
  • Not reproduced on a device. The defect is a race between the player's background stop and the page's refresh, and a dev server answers the stop too quickly to lose it reliably. The test holds the stop open instead.
  • Devices: Android TV only. Phones, tablets, and foldables run the phone app, which this PR doesn't change.

Validation tasks: none

Evidence: https://evidence.siloserver.org/r/silo-android/tv-series-refresh-after-stop/

Risks

  • After a playback return, the page now reads seasons and episodes twice: once at resume and once fresh after the stop. That is one or two extra requests per return.
  • If the user marks something watched while the stop is still pending, the fresh read can briefly repaint the pre-write state until that write's own refresh lands. If that refresh fails too, the pre-write state stays until the next refresh.

Follow-ups

Other clients: Apple N/A (the player awaits ItemDetailCache.refreshAfterPlayback after its final progress write); Roku N/A (the detail screen reads again after a delay to cover a late stop); Web Silo-Server/silo-server#4374

Adversarial review

  • Plan round: gpt-6.1-sol attacked the plan and claude-opus-5-5 cut it. Opus dropped a wait and fresh read for the Next Up episode's detail, an inherited flag, and a change to the series detail read; none of them were needed for the reported symptoms. Sol asked that the deferred load keep favourite revalidation and read the selected season after the wait. Both are in.
  • Code review (high, three finders, a validation check, and a verifier): one finder showed that the fresh read could cancel the cache-backed load for a season the return had just selected and, offline, lose the return. The job now waits for that load first. The verifier found no remaining wrong final state. Bot review (Codex) then showed the same failure for a season the viewer picks during the wait; the job now waits for that load too (b87a0dc). Kody asked for an ownership generation; a newer return now replaces the pending read, and the per-request generations already own what gets published.
  • A simplify pass ran on the change and made no edits.
  • Background review (gpt-6.1-sol): the first round, on 20be046, stopped before posting because the head moved. It found that a finished season finale stays unwatched in the carousel after the page moves to the next season. That also happens on main, so it is tracked in fix(tv): the episode carousel keeps a finished season finale unwatched after returning from the player #956. The second round, on b87a0dc, found nothing.

AI disclosure

🤖 Generated with Claude Code

Back from the player, the series page (and an episode page's rail) read
seasons and episodes before the player's detached stop sent its final
progress, and never read them again. The rail could keep the episode's
pre-stop progress with no watched badge, and the season's watched count
stayed stale until the next resume.

When refreshOnReturn consumes a playback return (the series return, the
Next Up episode's, or the page's own), quietRefresh now waits for the
stop, lets the immediate episode load finish, and reads seasons and the
selected season's episodes again with fresh reads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-triage silo-triage Bot added the size/M 50–199 added + deleted lines (all files); change volume, not priority. label Nov 15, 2026
@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

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 49 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 100 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

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: ff315644-84e3-4855-9c42-ac0cbf1df53c
Commits

Reviewing files that changed from the base of the PR and between d1c36e7 and b87a0dc.

Files selected for processing: 2

  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/detail/TvItemDetailViewModel.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/detail/TvNextUpSelectionHandoffTest.kt
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@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 ❌

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 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-15T23:14:18.121606Z b87a0dc New commits
🔒 Security Review ✅ Completed 2026-11-15T23:16:06.784189Z b87a0dc 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.

@silo-triage silo-triage Bot added bug Something isn't working impact: polish Annoyance, cosmetic, or nice-to-have priority: P2 Limited scope, workaround exists, or polish labels Nov 15, 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: 20be046a37

ℹ️ 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".

A season change during the wait cancels the joined load and starts a
cache-backed one. The fresh read now waits for that one too, so its
failure cannot undo the change. A newer playback return replaces the
pending read instead of stacking another.

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 ❌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working impact: polish Annoyance, cosmetic, or nice-to-have priority: P2 Limited scope, workaround exists, or polish size/M 50–199 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant