Repository navigation
fix(web): keep a marker change when an older watch-detail read finishes after it - #4124
Conversation
…es after it The web player replaced its markers with whatever watch-detail read finished last. A read that began before an in-player save or a markers_updated event could finish after it, and the seek bar and Skip prompts went back to the older markers while the server kept the new ones. The player now counts the marker changes it applies. The read it starts when the playback control socket connects reads again when a change landed while it ran, or when it joined a read that was already running. A page read in flight at a change is started over, and a page snapshot the query cache already holds but the player has not rendered yet gets the change applied on top. Closes #4100 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Next included review available in 1 minute. View limit details
|
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:
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
| const landed = queryClient.getQueryData<WatchDetail>(pageKey); | ||
| if (landed && landed.versions !== versions) { | ||
| queryClient.setQueryData<WatchDetail>(pageKey, { | ||
| ...landed, | ||
| versions: change(landed.versions), | ||
| }); |
There was a problem hiding this comment.
Marker changes leave the normal watch-detail cache entry stale
Other consumers and a remounted player can receive old markers when cached versions matches the current prop. Update the cached versions whenever landed exists, even if the arrays are identical.
Prompt for LLM
File web/src/player/components/WatchPage.tsx, lines 231-236:
Marker changes leave the normal watch-detail cache entry stale
When the cache contains the same `versions` array as the current prop, a marker save updates only player state and leaves the shared watch-detail cache unchanged. Other consumers and a remounted player can therefore receive the old markers; patch the cached versions whenever cached detail exists, including when the arrays are identical.
Suggested code:
if (landed) {
queryClient.setQueryData<WatchDetail>(pageKey, {
...landed,
versions: change(landed.versions),
});
}
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 this here. Two reasons, both from reading the source:
- It is the same on
main. A marker change there never touches the cached watch detail, so a remounted player or another reader of this key already starts from the older markers.useWatchDetailusesstaleTime: 0, so it refetches on mount and the older markers last until that read lands. I have not measured that window. - Patching the cache every time would cost more than it fixes. The player copies the
versionsprop whenever it changes, so writing to the cache on each marker change would replace the player's state with the cached snapshot. That snapshot lacks the marker and chapter images thatmarker_thumbnail_readyandchapter_thumbnail_readyadd only to the player's state, so each marker change would drop them. The branch at this line is limited to a snapshot the player was about to copy anyway, where nothing more is lost.
Keeping the cached copy current needs the image events applied to the cache too, which is a larger change than this fix.
🤖 Claude Code in T3 Code (claude-fable-5-2)
There was a problem hiding this comment.
Understood. I withdraw the suggestion to patch the cache unconditionally: it could cause the player to replace its local versions with a snapshot that lacks thumbnail updates.
The stale-cache behavior also predates this PR, so addressing it separately—while preserving thumbnail updates—seems reasonable. No changes were made.
WatchPage.tsx crossed the 800-line file limit. The marker-change count, the function that applies a marker change, and the read that reconciles the player's versions when the control socket connects move to useMarkerChangeGuard. The hook is called where the reconnect effect was, so effects run in the same order. No behavior change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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:
|
Problem
Closes #4100
Related issue: N/A
Validation tasks: unblocks #1149 C1; unblocks #1153 C1
Other clients: Apple N/A (its player already reads again when a marker event lands during its reconnect read); Android N/A (phone and TV already discard a reconnect read that is older than a marker event); Roku N/A (it neither saves markers nor handles marker events during playback)
In the web player, a watch-detail read that started before a marker change and finished after it put the older markers back. The seek bar, the Skip prompts and the Edit markers panel then used markers the server no longer had, until the player reloaded or another marker update arrived. The change it undid was either a save from the player's Edit markers panel or a
markers_updatedevent for the playing file.The player now keeps the newer change and reads again, so the older answer is never applied.
Approach
The player holds its own copy of the file versions and replaced that copy with whichever watch-detail read finished last. There are two such reads: the reconnect read, which the player starts each time its playback control socket connects, and the page read, which is the page's own watch-detail query and which the player copies whenever it changes. Marker events carry no revision, so a read cannot be ordered against a change by its content; only the client knows which came first.
The player now counts the marker changes it applies. That count, and the two rules that use it, live in a new hook,
useMarkerChangeGuard, soWatchPage.tsxstays under the file size limit.Reading again keeps what else the read carries: chapters, other versions, and anything missed while the socket was down. Cancelling the older reads would drop those.
Only the web app changes. Nothing in
/api/v2, the realtime events, or jellycompat changes.Validation
mainatb6b7dd38, with the order forced in the browser: the reported steps, the same with the recap saved from outside the page (amarkers_updatedevent), and the page's own refetch held across a save. In all three the recap left the seek bar, Skip Recap was not offered inside it, and the reopened panel showed Recap as not set, while the server still had it. On a build of this branch (8c476033) the same three runs keep the recap in all three places. No console errors in any run.8c476033, locally and in CI, with the file size, bidi, local-path, and case-collision checks. On the first commit one of three local runs of the suite had a failure insrc/components/GlobalSearch.test.tsx, which this change does not touch and which passed alone four times. The Go gate was not run; the diff has no Go or generated-contract changes.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/issue-4100/
Surface and build: web app in headless Chromium at 1440×900; before on
b6b7dd38, after on8c476033.Risks
markers_updatedevent, so it counts as two changes.User manual: unaffected. The manual's marker page already says that players that are already open pick up a saved change without a rescan.
Checklist
AI Disclosure
978dfc19adversarially from the source, the tests, and its own query-client harness, with no browser run, and reported no findings; that covered the joined-read check, which the finders had not seen. The move into the hook (8c476033) came after that review and was checked by the tests, CI, and a repeat of the three live runs.🤖 Generated with Claude Code