Skip to content

fix(web): keep a marker change when an older watch-detail read finishes after it - #4124

Merged
Quick104 merged 2 commits into
mainfrom
fix/issue-4100-stale-watch-detail-markers
Nov 13, 2026
Merged

Quick104 merged 2 commits into
mainfrom
fix/issue-4100-stale-watch-detail-markers

Conversation

@Quick104

@Quick104 Quick104 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

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_updated event 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, so WatchPage.tsx stays under the file size limit.

  • The reconnect read applies its answer only when no marker change landed while it ran. Otherwise it reads again. It also reads again when it joined a read that was already running, because that read may have started before the change.
  • A page read in flight at a marker change is started over, so what it brings in is newer than the change.
  • A page snapshot that the query cache already holds but the player has not rendered yet gets the change applied on top, so copying it into the player does not undo the change.

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

  • Reproduced on a dev deployment built from main at b6b7dd38, with the order forced in the browser: the reported steps, the same with the recap saved from outside the page (a markers_updated event), 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.
  • Four tests added to the watch page's test file. They cover the reconnect read finishing after a save, the socket dropping and returning while that read is out, a snapshot already in the cache reaching the page after a save, and a page read in flight at a save. All four fail on the base and pass here. They do not cover the browser's own network-reconnect refetch; the third live run does.
  • Web gate: lint, format check, typecheck and build, bundle budget, and the full web test suite pass on 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 in src/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.
  • Phone-width web was not captured. The change is in player state that both layouts share.

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 on 8c476033.

Risks

  • A marker change now costs extra watch-detail requests when a read is in flight: one restart of the page read, and one more reconnect read. A superseded request still finishes on the network; only its answer is ignored. A burst of marker events while the socket is reconnecting repeats this per event and stops when the events stop.
  • An in-player save reaches the player twice, once from the save and once as the server's markers_updated event, so it counts as two changes.
  • No migration, API, or compatibility impact.

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

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or how I checked a change nobody sees.

AI Disclosure

  • Harness: Claude Code in T3 Code
  • Tool(s): Claude Code, Codex (plan review), Playwright (headless Chromium), GitHub CLI
  • Model(s): claude-fable-5-2 (wrote the change), gpt-6.1-sol and claude-opus-5-5 (plan review), claude-sonnet-5-5 (one review finder and the validation check)
  • Involvement: Fully AI-generated; no person has reviewed it yet
  • Adversarial review: Before the change was written, gpt-6.1-sol attacked the plan and claude-opus-5-5 cut it. Opus found nothing to remove and showed the planned test would have passed on the unfixed code; the tests now use a real query client. Sol found three gaps in the plan (a snapshot already in the cache, a stranded chapter refresh, a cancel that reached another selection of the same title); all three are closed here. Its proposal to make the query cache the player's only copy was not taken, because the playback chrome feeds a background player from a further copy. A code review of the diff at high effort (three finders and a validation check, then two finders on the reworked diff) showed that cancelling older reads dropped what else they carried, which changed the fix to reading again, and found the socket-drop case, which is fixed and tested. The simplify pass renamed one parameter. After the pull request opened, gpt-6.1-sol reviewed head 978dfc19 adversarially 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

…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>
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

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.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dc970dc0-09eb-4758-a7a5-b19186970cd0
Commits

Reviewing files that changed from the base of the PR and between b6b7dd3 and 8c47603.

Files selected for processing: 3

  • web/src/player/components/WatchPage.test.ts
  • web/src/player/components/WatchPage.tsx
  • web/src/player/hooks/useMarkerChangeGuard.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@silo-triage silo-triage Bot added the size/L 200–499 added + deleted lines (all files); change volume, not priority. label Nov 13, 2026
@silo-kody

silo-kody Bot commented Nov 13, 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 ❌

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T21:27:12.661404Z 8c47603 New commits
🔒 Security Review ✅ Completed 2026-11-13T21:29:51.353509Z 8c47603 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@silo-triage silo-triage Bot added bug Something isn't working impact: polish Annoyance, cosmetic, or nice-to-have javascript Pull requests that update javascript code priority: P2 Limited scope, workaround exists, or polish labels Nov 13, 2026
Comment thread web/src/player/components/WatchPage.tsx Outdated
Comment on lines +231 to +236
const landed = queryClient.getQueryData<WatchDetail>(pageKey);
if (landed && landed.versions !== versions) {
queryClient.setQueryData<WatchDetail>(pageKey, {
...landed,
versions: change(landed.versions),
});

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 Bug high

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.

​

​

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 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. useWatchDetail uses staleTime: 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 versions prop 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 that marker_thumbnail_ready and chapter_thumbnail_ready add 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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

silo-kody Bot commented Nov 13, 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 ❌

@Quick104
Quick104 merged commit 40b1adb into main Nov 13, 2026
19 checks passed
@Quick104
Quick104 deleted the fix/issue-4100-stale-watch-detail-markers branch November 13, 2026 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working impact: polish Annoyance, cosmetic, or nice-to-have javascript Pull requests that update javascript code priority: P2 Limited scope, workaround exists, or polish size/L 200–499 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Web player goes back to older markers when a watch-detail read finishes after a marker change

1 participant