Skip to content

fix(home): refresh resume rows after watched changes - #628

Merged
Quick104 merged 1 commit into
Silo-Server:mainfrom
Rhainland:fix/home-resume-rows-refresh
Oct 6, 2026
Merged

Quick104 merged 1 commit into
Silo-Server:mainfrom
Rhainland:fix/home-resume-rows-refresh

Conversation

@Rhainland

@Rhainland Rhainland commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: changes #337 C4; changes #337 C9

Marking a series, season or episode watched or unwatched on its detail page left Home's Continue Watching and Next Up rows unchanged until a manual refresh. Home stays mounted under the detail page and only its cached response was dropped, so old cards such as "S02E01 · 2m left" stayed on screen. Home now re-reads its rows right away.

Approach

PersonalStateSync.invalidateDerivedLists posts homeSectionsShouldRefresh after dropping its caches. The iOS playback-write refresh and the tvOS player-dismiss refresh go through the same call, so progress and watched badges in library grids are also dropped after playback.

Validation

  • Unit tests for a watched change dropping Home and grid caches and refreshing a mounted Home, and a playback write dropping grid caches: pass.
  • Manual, iPhone simulator: marking Breaking Bad watched removed it from Continue Watching immediately and ticked its grid poster; closing the player updated Home at once.
  • scripts/ci/check-no-api-v1.sh: pass.
  • All 22 app fixes from this validation run, merged together on main (6242652): the full iOS unit suite ran 2,691 tests. The only failures are ArtworkURLTests.testDeliveryCapabilityOnIOSUsesV2RouteAndResets and ImageSizeCapabilityTests.testResetClearsCapability, which fail the same way on main. tvOS build-for-testing and the macOS build succeed.
  • Local builds used Swift 6.3.3, which needs the ThumbHash type annotations from fix(build): annotate ThumbHash cosine tables so Swift 6.3.3 can type-check them #608 to compile. That change was applied locally and is not part of this PR.

Simulator screenshots (iOS 26.5, tvOS 26.5):

a11-home

Risks

A watched change from a Home card now posts the refresh twice; Home's fetches share one request, so this costs nothing extra.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.

AI Disclosure

  • Harness: Claude Code, running in T3 Code
  • Tool(s): Claude Code subagents, xcodebuild, Xcode Simulator (simctl, Maestro), GitHub CLI
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: A separate Claude Code reviewer agent (claude-opus-5-5) read this branch's diff against main at medium effort, checking behaviour, platform guards (iOS, tvOS, macOS), tests and commit hygiene. It checked that the shared invalidation still covers everything the old code dropped and that the refresh does not run on every progress report. No findings.

Note

Fix stale Home rows after watched changes via shared cache invalidation

  • PersonalStateSync.invalidateDerivedLists now clears Home, recommendation, favorite, watchlist, browse, TV-library, library, and collection caches, and posts homeSectionsShouldRefresh so mounted Home rows reload with fresh state
  • PlayerView.swift and StartupContentPrefetcher.swift replace their direct Home invalidation with the shared call
  • Adds tests in HomeSectionsMutationTests.swift covering watched-state changes and playback-write refreshes
  • Behavioral Change: after playback cleanup, the player now clears all derived caches (not just Home) before the item-detail refresh; playback-write callbacks keep the profile-generation guard

Macroscope summarized 2113681.

Marking a series, season or episode watched or unwatched on its detail page left Home's Continue Watching and Next Up rows unchanged. Home stays mounted under the detail page, and PersonalStateSync.invalidateDerivedLists only dropped the cached Home response, so the old card (for example "S02E01 · 2m left") stayed on screen until a manual refresh.

PersonalStateSync.invalidateDerivedLists now posts homeSectionsShouldRefresh after dropping its caches, so a mounted Home re-reads its rows right away. The playback-write refresh on iOS and the tvOS player-dismiss refresh go through the same call, so progress and watched badges in library grids are dropped after playback too.

Tests cover a watched change dropping Home and grid caches and refreshing a mounted Home, and a playback write dropping grid caches.

Found during the Series validation, silo-apple#337.
@coderabbitai

coderabbitai Bot commented Oct 5, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7d8b1647-9127-40f7-b89c-3f68767bf90f
📥 Commits

Reviewing files that changed from the base of the PR and between 6242652 and 2113681.

📒 Files selected for processing (5)
  • iosApp/Tests/HomeSectionsMutationTests.swift
  • iosApp/iosApp/Components/PersonalStateSync.swift
  • iosApp/iosApp/Screens/Detail/ItemDetailViewModel.swift
  • iosApp/iosApp/Screens/Player/PlayerView.swift
  • iosApp/iosApp/Startup/StartupContentPrefetcher.swift
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@silo-kody

silo-kody Bot commented Oct 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 ❌

@Rhainland Rhainland mentioned this pull request Oct 5, 2026
11 tasks
NotificationCenter.default.post(name: .homeSectionsShouldRefresh, object: nil)
// Progress and watched state show on every derived list, not
// only Home: drop them all and refresh a mounted Home.
PersonalStateSync.invalidateDerivedLists()

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 Kody Rules high

Stale-result acceptance affects recommendations, library sections, and browse pages in iosApp/iosApp/Startup/StartupContentPrefetcher.swift: their readers validate only profileScopedGeneration, while invalidateDerivedListsInFlight() resets shared tasks without advancing a generation they check, and cancellation does not guarantee underlying request failure, allowing existing waiters to return pre-write rows and attempt to cache them after expanded playback invalidation. Add a derived-list invalidation generation, advance it when invalidating these lists, and have every affected reader capture and verify it after suspension and before returning or caching results.

Kody rule violation: Fence asynchronous results by scope and invalidation generation

Prompt for LLM

File iosApp/iosApp/Startup/StartupContentPrefetcher.swift:

Line 130:

Stale-result acceptance affects recommendations, library sections, and browse pages in iosApp/iosApp/Startup/StartupContentPrefetcher.swift: their readers validate only profileScopedGeneration, while invalidateDerivedListsInFlight() resets shared tasks without advancing a generation they check, and cancellation does not guarantee underlying request failure, allowing existing waiters to return pre-write rows and attempt to cache them after expanded playback invalidation. Add a derived-list invalidation generation, advance it when invalidating these lists, and have every affected reader capture and verify it after suspension and before returning or caching results.

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.

Not changing. The readers' profileScopedGeneration checks and invalidateDerivedListsInFlight() are unchanged from main; this PR only calls the existing PersonalStateSync.invalidateDerivedLists() after a playback write too, where main dropped none of these lists. Pre-write rows also cannot be cached: each reader writes with the writeToken its shared request captured when it started, and invalidateDerivedLists() removes the recommendations key and the browse:, tvlibrary: and library: prefixes right after resetting the shared tasks, so ResponseCache.set(_:for:fetchedAt:) drops the late write. A caller already waiting before the write still gets the rows it asked for, as it does on main for watched and favorite toggles.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Agreed—the cache-write portion of my suggestion was incorrect.

  • SharedFetch captures the request’s original writeToken, including for callers joining an existing request (iosApp/iosApp/Startup/StartupContentPrefetcher.swift:794–816).
  • invalidateDerivedLists() resets the shared tasks, then invalidates the relevant keys and prefixes (iosApp/iosApp/Components/PersonalStateSync.swift:189–198).
  • ResponseCache.set(_:for:fetchedAt:) rejects writes whose key or prefix was invalidated after that token, preventing late responses from repopulating memory or snapshots (iosApp/iosApp/Networking/ResponseCache.swift:60–76,99–109).

An existing waiter can still receive pre-write rows, but that is distinct from restoring invalidated cache entries. Without a concrete caller path demonstrating a new stale-UI regression from this PR, that possibility does not justify the high-severity finding or requiring a new generation fence here.

No code change needed for this suggestion.

@Quick104
Quick104 merged commit 52c90c4 into Silo-Server:main Oct 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants