Repository navigation
fix(web): re-read the series page after the player's stop lands - #4423
Conversation
Leaving the player marked the catalog queries stale in the same commit that unmounted it, so the page the viewer returned to read its episodes and Next Up while the session stop was still on its way. The stop writes more than the last progress report: it marks the later episodes of a multi-episode file watched. When the stop took longer than the page's reads, those episodes stayed unwatched on the series page until a reload. The player config gains an optional onSessionStopped callback, called once the unmount stop settles. The watch chrome uses it to mark the playback surfaces stale again, so the page reads them once more after the stop. Leaving the player still does not wait on the network. Closes Silo-Server#4374
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:
|
Invalidating a query that has no data yet reuses its in-flight fetch, so a series page whose cache expired during playback could keep a read that started before the stop was written. The post-stop refresh now cancels those first fetches before invalidating, so they read again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Quick104
left a comment
There was a problem hiding this comment.
🤖 Claude Code (claude-opus-5-5)
I found one defect in the post-stop refresh. It's inline below, and I'm fixing it in a commit on this branch, so there's no need to change it yourself.
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:
|
|
🤖 Claude Code (claude-opus-5-5) Review summaryReviewed head: The approach holds up. The player reports when its unmount stop settles, and the watch host reads the playback surfaces again, the same way Silo-Server/silo-android#954 handles it on Android TV. An episode switch inside the player stops the old session in place ( Addressed
Follow-ups
Validation
Other checks
Fit: 9/10 · Readiness: 9/10 — ready (assuming CI is green) Fit: this fixes stale watch state in the main browse-and-watch flow with one optional callback and no new setting or API surface. Readiness: the fix is shown live and by tests that fail without it. The narrower |
Problem
Closes #4374
Related issue: N/A
Validation tasks: changes #1252 C4 and C9 (both Not run)
Other clients: Apple N/A (already safe: on iOS and macOS the detail page waits for the player's cleanup, which awaits the stop, before it reloads; on tvOS the player reloads the cached detail pages after the stop); Android: Silo-Server/silo-android#954 fixed Android TV; the phone app isn't handled here and doesn't wait for the stop either, Silo-Server/silo-android#985; Roku N/A (the detail screen already reads again a few seconds after the player closes because the stop may still be on its way,
refreshAfterPlaybackincomponents/screens/detail/DetailPlayback.bs)After you leave the web player, the series page can keep showing old watch state until you reload it. The page reads its episodes and Next Up while the player's session stop is still on its way to the server, and nothing reads them again once the stop lands.
Most of a play is already saved by then, because the player waits up to 1 s for its final progress report before it closes, and that report sets the watched mark. The stop writes more, though. For a multi-episode file (say
S01E05-E06in one file) only the stop marks the later episodes watched. When the stop takes longer than the page's reads, episode 6 stays unwatched on the series page until a reload. Season cards read the sameseasonsendpoint at the same moment, so their watched counts would lag the same way; my test show has one season, so I didn't see that directly. In my runs Next Up already pointed at episode 7 before the fix, so the visible failure was the later episode's watched mark. The fix also covers a single-episode file whose last progress report misses the 1 s window, which I didn't reproduce.I reproduced it on a local server by putting a proxy in front of Postgres that delays each packet:
Approach
PlayerConfiggets an optionalonSessionStoppedcallback.usePlaybackSessioncalls it once the stop it sends on unmount settles, whether it lands or gives up after its own retry budget. A page that is unloading doesn't call it.WatchPlaybackChromepasses a callback that runsinvalidatePlaybackSurfaceQueriesagain, so whatever page you returned to reads its catalog, progress and history queries once more after the stop.The existing invalidation when the player unmounts stays. The page still updates straight away from what the progress report wrote, and the second pass picks up what the stop wrote. Leaving the player never waits on the network. This is the web version of what Silo-Server/silo-android#954 did on Android TV.
Validation
usePlaybackSession.test.tsholds the stop's response and checks the host is told only after it arrives. It fails onmain(the callback never runs) and passes with the fix.vitest runonusePlaybackSession.test.tsandsrc/playback: 155 passed.tsc -b: clean (ESLint keeps one existing warning inPlayerConfigContext.tsxonmain).mainand six with the fix; at phone width, four onmainand six with the fix. Everymainrun left episode 6 unwatched; every run with the fix showed it watched within about 0.7 s of leaving the player. With the fix I also left through the Up Next screen's Close button, which goes to the episode's own page; that page showed episode 6 watched as well (2 runs).Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/pr-4423/
Surface and build: web app series page, at desktop (1280 px) and phone (390 px) width, straight after leaving the player with the Exit button. Before is upstream
mainat217ff25ab; after is this branch at3dc97cb0d. Both ran against the same local backend built from217ff25ab, with Postgres reached through a proxy that adds 1 ms each way. The test server has no online metadata, so I added episode 6's row the way a metadata provider's season listing would.Risks
Each exit from the player triggers one more round of reads for the queries the current page has open (four small catalog reads on a series page). When the player unmounts to switch items, the callback marks the same queries stale that the existing unmount invalidation already marks at that moment. Nothing else changes.
Checklist
AI Disclosure
Note
Refresh playback-surface queries after the player's stop request settles
onSessionStoppedtoPlayerConfigso the host gets notified when a non-unloading session stop settles (success or failure); unloading stops do not notify (PlayerConfigContext.tsx)WatchPlaybackHostContentwires the callback to a newrefreshPlaybackSurfaceQuerieshelper, which cancels in-flight first fetches across the playback-surface query filters before invalidating those queries (playbackSurfaceRefresh.ts)Macroscope summarized 7eb1981.