Repository navigation
fix(realtime): name the series on watched and progress events - #2504
Conversation
A series page refreshes its seasons and watched totals from user-state events, but since Silo-Server#857 only for items it can tie to the series from its cache. When another device marked or played an episode the page hadn't loaded, the event named only the episode, so the series and its seasons stayed stale until a reload (Silo-Server#796). The server now fills the event's existing series_id: watched marks take the season's or episode's series from the target they already resolve, and a progress sync looks up the batch's episodes in one query. The web refreshes the named series and its cached seasons, without the series' other episodes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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:
|
|
The realtime watched/progress refresh changes the series page’s watched totals and season progress ( Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness. Posted via Macroscope — Visible change evidence |
Main (Silo-Server#1966) replaced the progress and watched handlers' profile refresh with notifySignalsChanged. Keep that; the progress handler keeps its EpisodeLookup and both events keep their series_id. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Major validation change — #1252 C4 and C9 (Web). The #1252 rehearsal records the watched/season roll-up as passing; C4's cross-device resume portion remains blocked on #1249's progress-rule decision. This PR intentionally changes the displayed series/season roll-up after an uncached episode's watched/progress event, so C4 and C9 need re-validation after merge. The PR must explicitly explain why these recorded outcomes change; this does not unblock C4's separate progress-rule blocker. C3's playback/resume behavior and C8's hierarchy/grouping do not change. Suggested replacement:
Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
|
C4 and C9 need re-validation after merge. The Series — Web task comment records a rehearsal on server Suggested fix — no diff; update the PR description to: Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed. Posted via Macroscope — v1 validation impact |
…scing The v1 progress sync writes item IDs without an access check, so naming an episode's series could tell a restricted profile which series an out-of-scope episode belongs to. Name a series only for an episode the sync already checked, or one the viewer's scope allows; without a scope, unchecked IDs get none. On the web, a later event for the same item without a series no longer replaces the series an earlier event in the coalescing window named. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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:
|
Main (Silo-Server#2440) split the watched-target lookup out of resolveWatchedTargets and added a resume-position reset that publishes a progress event. Take its structure: resolveWatchedTargets returns the target's series through watchedTarget.seriesID, and the reset's event names it as well. On the web, keep both the event's series and main's known related IDs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main's Silo-Server#2511 regenerated contracts/api/v2/fixtures/ignore_unmatched_item_not_found.json, which was stale on main and failed TestContractFixtures here. Main's Silo-Server#2522 also lints new code more widely; its nestif check flagged episodeSeries, so the scope check moves into markInScope, unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The repository's size ratchet caps mediaSurfaceRefresh.test.ts at 800 lines, and this PR's three tests took it to 802. They cover events that name an uncached episode's series (Silo-Server#796), so they move, unchanged, to mediaSurfaceRefresh.series.test.ts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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:
|
Main now describes the eslint-disable comments in NotifiedSeriesList.tsx, which failed the web checks here. The merge is clean. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main's Silo-Server#3010 adds a recordRewatch parameter to SetWatchedState, and this branch has resolveWatchedTargets return the target's series. Keep both: main's signature, and the series the watched event names. This branch's unwatch test passes recordRewatch false, as main's own call there does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Quick104
left a comment
There was a problem hiding this comment.
Reviewed 3f2ce089ce6ea962dd34b2eda0292e03e377caa6 with no new actionable findings. The earlier access-filtering and coalesced-series-hint findings are fixed in the current source.
Focused progress tests, watched/clear-resume database tests, and all 71 selected frontend tests passed. The disposable database container and volume were removed and absence verified. No live client or multi-node test was performed.
Validation tasks: changes #1252 C4, C9. Re-validate their previously passing rehearsal roll-up portions after this change; C4's separate progress-rule block remains. The PR already explains this intentional change. Full board enumeration is unavailable because the token lacks read:project; dated rehearsal comments were included in the review.
Reviewed with Codex using gpt-6.1-sol at xhigh, including independent finders, verification and a final sweep.
Problem
Related issue: #796
Follows: #857 (merged), which left this case open: the uncached-episode thread. No other open PR depends on this.
Validation tasks: changes #1252 C4, C9
Why C4 and C9 change: Their recorded roll-up of watched state per series and season changes: after another device marks or plays an episode this page hasn't loaded, the open series page now updates its seasons instead of staying stale until a reload. Re-validate both after merge; this doesn't touch C4's separate block on #1249's progress rule. C3 (playback and resume) and C8 (hierarchy) don't change.
#857 made the web's realtime refresh targeted: a user-state event refreshes only the cached queries it can tie to the event's item. A series page caches the series, its season list, and the episodes of the season it shows. When another device plays or marks an episode outside those episodes, the event names only the episode. Nothing in the cache links it to the series, so the series' watched totals and its seasons' progress stay stale until a reload.
The event payload already has a
series_idfield, but the server leaves it empty for watched and progress events.Approach
Of the two options in #857's thread, this fills the existing
series_idand refreshes that series, instead of refreshing every aggregate list whenever the parent is unknown, which would bring back the unrelated refreshes #857 removed.SetWatchedState):resolveWatchedTargetsalready loads a season's or an episode's row to check access. It now also returns that row's series, and thewatchedevent carries it. A series mark still names only the series itself, and a movie names none.SyncProgress, v1 and v2): after the writes, the batch's item IDs are looked up in oneepisodesquery, and each episode's event carries its series. A series is named only for an episode the viewer may see: one the v2 sync already access-checked, or, for the v1 sync's unchecked IDs, one the viewer's scope allows. If the lookup fails, the events still go out, without a series, as before.ClearResumePosition, from feat(progress): reset a partly watched item's resume position #2440): the reset'sprogressevent names an episode's series too, from the target it already loads.handleUserStateEventpassesseries_idto the surface refresh.relatedItemIdsthen counts the series and its cached seasons as related, so the series detail, the season list and the season pages refresh. The series' other cached episodes don't, because one episode's change doesn't move them.No API contract changes:
series_idis an existing, optional field of theuser_state.changedpayload.Validation
Run in WSL2 and on Windows:
TestSyncProgressEventsNameTheEpisodeSeries: one lookup for the batch, an episode's event names its series, a movie's doesn't, and a failed lookup still publishes.TestParentUnwatchClearsEpisodesWithoutLibraryFilePostgres: now also checks the watched event'sseries_idfor a season, for a series (empty) and for an episode, against Postgres.internal/api/handlersbuilds and vets; changed-package lint is clean.mediaSurfaceRefresh.test.ts: an uncached episode's event with a series refreshes the series detail, its season list, its season pages and its open season's episodes, but not the series' other episodes or another series.RealtimeEventsProvider.test.tsx: a progress event'sseries_idreaches the refresh.Evidence
The same local server data on both builds: a two-season show, with Season 1's episode list loaded by the page and Season 2's not. The series page is open in the browser, and a second session (another device, through the API) marks S2E1 watched. Desktop and phone width (375 px), dark theme.
mainat27310a5ef)On this branch, the page refetched the series and its seasons a moment after the event and left the "similar titles" row alone. On
main, the season stayed at "2 episodes" while the server's season list already reported one watched.Surface and build: web, Vite dev builds of
27310a5efand this branch, each against its own server build, on one local database with generated media.Risks
episodesquery per progress sync batch that publishes events. A batch is at most a few hundred items, and the query is by primary key.series_idare unaffected; it was already in the payload, just empty.Checklist
AI Disclosure
🤖 Generated with Claude Code
Note
Include parent series ID on watched and progress realtime events
ItemsHandler.resolveWatchedTargetsin items.go now returns the parent series ID for season and episode targets, and watch_state_service.go passes it into watched and resume-clear user-state eventsProgressHandler.SyncProgressin progress.go resolves series IDs for a batch in one episode lookup, scoped viaLibraryLookup.FilterAccessibleContentIDsfor unchecked items; lookup failures are logged and events publish without a series IDhandleUserStateEventin RealtimeEventsProvider.tsx andrelatedItemIds/scheduleMediaSurfaceInvalidationin mediaSurfaceRefresh.ts invalidate the named series, its seasons, and cached season details; coalescing keeps an earlier series ID when a later event omits itEpisodeLookupdependencyMacroscope summarized 3f2ce08.