Repository navigation
fix(home): refresh resume rows after watched changes - #628
Conversation
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.
|
Warning Review limit reachedYou'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. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (5)
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. Comment |
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
| 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() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Agreed—the cache-write portion of my suggestion was incorrect.
SharedFetchcaptures the request’s originalwriteToken, 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.
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.invalidateDerivedListspostshomeSectionsShouldRefreshafter 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
scripts/ci/check-no-api-v1.sh: pass.main(6242652): the full iOS unit suite ran 2,691 tests. The only failures areArtworkURLTests.testDeliveryCapabilityOnIOSUsesV2RouteAndResetsandImageSizeCapabilityTests.testResetClearsCapability, which fail the same way onmain. tvOSbuild-for-testingand the macOS build succeed.Simulator screenshots (iOS 26.5, tvOS 26.5):
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
AI Disclosure
mainat 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.invalidateDerivedListsnow clears Home, recommendation, favorite, watchlist, browse, TV-library, library, and collection caches, and postshomeSectionsShouldRefreshso mounted Home rows reload with fresh stateMacroscope summarized 2113681.