Skip to content

fix(web): refuse a player track choice made offline instead of queuing it - #5485

Open
rangoDJ wants to merge 3 commits into
Silo-Server:mainfrom
rangoDJ:fix/4576-player-offline-track-choice
Open

rangoDJ wants to merge 3 commits into
Silo-Server:mainfrom
rangoDJ:fix/4576-player-offline-track-choice

Conversation

@rangoDJ

@rangoDJ rangoDJ commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Depends on: none. Merge order: none. Follows #4534 (merged), which refused offline choices on the item page.

Problem

Closes #4576
Related issue: #4534
Validation tasks: none

Other clients: Apple N/A (keeps and retries offline picks by design); Android N/A (same); Roku N/A (doesn't save track choices)

In the web player, a subtitle or audio choice made while the browser was offline could still be sent after the connection came back, and then replace a newer choice the same profile made in another browser:

  • Player track choices go through the shared per-title write queue (runPlayerTrackPreferenceWrite → runTrackPreferenceWrite in web/src/player/utils/trackPreferenceWrites.ts).
  • With an earlier save for the same title and track type still waiting for its response, an offline choice joined the queue behind it, and went out once that response arrived after reconnect.

#4534 refuses offline choices in the item page's hooks (settingWriteOptions), so the player was still affected.

Approach

  • runTrackPreferenceWrite, where every caller enters the queue, refuses a choice made offline at once, with the same SettingWriteOfflineError the item page's writes use. This is the move the issue suggests, adapted to where fix(web): fail offline admin setting and subtitle/audio saves instead of replaying them #4534 actually put its check.
  • The player callers already handle a failed write:
    • The audio choice shows the error's message in its existing failure toast; that message is the localized "change not saved" notice.
    • The subtitle choice was best effort and silent. It now shows the same offline notice settings pages use (reportOfflineSettingFailure, one toast for a burst); other failures stay silent.
  • A choice made online and waiting in line still goes out after the earlier write, as before.

Validation

  • New test in trackPreferenceWrites.test.ts, "a choice made offline is refused at once and not sent after the earlier write settles": with a slow earlier write pending, an offline choice rejects with SettingWriteOfflineError and is never sent after reconnect. On main it never rejects and the test times out; with this change it passes.
  • New test in transportFailureToasts.test.tsx, "show the offline notice for a player subtitle pick made offline": the pick shows the offline notice and sends nothing. It fails on d56748b (before the review fix). That file's usePlayerConfig mock now returns a full config, which the subtitle path reads; the audio test mocks its send and doesn't read it.
  • pnpm exec vitest run src/player src/hooks/queries src/pages/ItemDetail*: 131 files, 1404 tests passed (before the review fix). After it, src/hooks/queries src/player: 126 files, 1372 tests passed. tsc -b --noEmit, eslint and prettier on the changed files: clean.
  • Not tested: a browser going offline mid-playback with a slow save pending.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/pr-5485/ (before/after of a subtitle picked offline in the player)

In the browser (headless Edge, Vite dev server, local Silo server, offline by DevTools network emulation), picking a subtitle offline shows only "Playback unavailable" on main c24e4b2. With e37c0f5 it also shows "You're offline, so this change wasn't saved". The load failure is unchanged. Same on two runs of each.

The queued-write race itself needs a save held pending across a reconnect and a newer choice in another browser being replaced, which a still image can't show; the test above shows it. The audio choice's existing failure toast now reads the localized "change not saved" notice when offline instead of a transport error.

On main (0a631fb), with the new test:

 × is refused at once and not sent after the earlier write settles 5005ms
      Tests  1 failed | 2 passed (3)

With this PR: Tests 3 passed (3).

Risks

  • The item page's writes now pass the offline check twice (in the mutation and in the queue); both refuse the same way.
  • No API, schema or config change.

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 the Claude desktop app
  • Tool(s): Claude Code
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated, not yet human verified
  • Adversarial review: n/a

🤖 Generated with Claude Code

Note

Reject offline player track-preference writes instead of queuing them

  • runTrackPreferenceWrite in trackPreferenceWrites.ts now checks the online state before touching the per-key pending-write queue. Offline writes reject immediately with SettingWriteOfflineError and are never sent.
  • useTrackChoicePersistence in useTrackChoicePersistence.ts routes audio write failures through the shared setting-write error notifier and subtitle write failures through the shared offline-failure reporter, instead of swallowing errors or showing inline toast text.
  • Behavioral Change: subtitle write errors are no longer silently swallowed; offline track choices now surface the shared offline notice and skip the network request. Check the rejection handler in useTrackChoicePersistence.ts, which still does not propagate errors to the caller.

Macroscope summarized 93cb0ed.

…g it

A subtitle or audio choice made in the web player while offline joined the
per-title write queue behind an earlier save still waiting for its
response. Once that response arrived after reconnect, the offline choice
went out and could replace a newer choice the profile made in another
browser. Silo-Server#4534 refused offline choices only in the item page's hooks.

runTrackPreferenceWrite, which every caller enters, now refuses a choice
made offline at once with SettingWriteOfflineError, so nothing is sent
after reconnect. The player's audio choice shows that error's localized
notice in its existing failure toast; its subtitle choice stays best
effort and silent.

Closes Silo-Server#4576

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

This organization requires a seat for paid usage-based reviews, including automatic and on-demand reviews. Ask an admin to assign a seat or enable paid usage-based reviews for users without a seat in Billing.

Next included review available in 51 minutes.

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: 839e4667-db31-43b9-a717-f69d12c70c9f
Commits

Reviewing files that changed from the base of the PR and between 0a631fb and 93cb0ed.

Files selected for processing: 4

  • web/src/hooks/queries/transportFailureToasts.test.tsx
  • web/src/player/hooks/useTrackChoicePersistence.ts
  • web/src/player/utils/trackPreferenceWrites.test.ts
  • web/src/player/utils/trackPreferenceWrites.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@silo-triage silo-triage Bot added the size/S 0–49 added + deleted lines (all files); change volume, not priority. label Nov 27, 2026
@silo-kody

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

@silo-triage silo-triage Bot added bug Something isn't working javascript Pull requests that update javascript code priority: P2 Limited scope, workaround exists, or polish labels Nov 27, 2026
The player's subtitle save swallowed every failure, so the offline refusal
added for Silo-Server#4576 left the viewer with no notice. It now shows the offline
notice settings pages use; other failures stay best effort.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@silo-triage silo-triage Bot added size/M 50–199 added + deleted lines (all files); change volume, not priority. and removed size/S 0–49 added + deleted lines (all files); change volume, not priority. labels Nov 27, 2026
@silo-kody

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One finding from the maintainer review of e37c0f5. I'm pushing the fix as a commit on this branch, so there's no need to change it yourself.

Minor: an audio pick made offline doesn't share the offline notice's toast id (web/src/player/hooks/useTrackChoicePersistence.ts, saveAudioChoice, line 49; outside the diff's hunks, so it's here rather than inline).

Trigger: pick two audio tracks while offline, or an audio track and a subtitle track. Impact: since this PR, the audio pick's error is a SettingWriteOfflineError, and toast.error(readableErrorText(...)) shows its message with no id. Each offline audio pick stacks its own "You're offline, so this change wasn't saved" toast, and an audio pick plus a subtitle pick shows that sentence twice. The subtitle path and the settings pages show it once for a burst through the setting-write-offline id.

Repair: call toastSettingWriteError(err, t("web.player.tracks.saveAudioFailed")) from settingWriteOffline.ts. It shows the deduped offline notice for an offline refusal, and the same readableErrorText toast as now for everything else. The fix adds one assertion to the existing audio-pick test in transportFailureToasts.test.tsx.

🤖 Claude Code (claude-opus-5-5)

@silo-kody

silo-kody Bot commented Nov 28, 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 commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Maintainer review summary

Reviewed head: 93cb0ed (the PR's e37c0f5 plus one fix commit). Updated after a second pass on the same head.

Fit: 9/10 · Readiness: 9/10 — ready

A player track choice made offline could wait behind an unanswered save and go out after reconnect, replacing a newer choice the same profile made in another browser (#4576). Refusing offline choices in runTrackPreferenceWrite fixes it at the one place every caller enters, with the same SettingWriteOfflineError the item page has used since #4534. Choices made online that are waiting in line still go out after the earlier write.

Addressed

  • An audio pick made offline showed the offline notice without the shared setting-write-offline toast id, so several offline picks stacked duplicate notices. Fixed in 93cb0ed: the audio pick now uses toastSettingWriteError, and the existing audio-pick test checks the shared id.
  • Kody's thread on the silent subtitle failure: the author's fix holds, and the thread is resolved.
  • The earlier summary left one maintainer decision: whether a subtitle pick that is refused offline should show the offline notice. It should. Settings pages already show that notice whenever an offline change isn't saved, and without it this fix would drop the pick silently. The notice reuses existing text and its toast id, so the change adds no new UI. This is no longer an open decision.

Verification

  • The three new tests fail on the base (0a631fb) for the reported reasons. The queue test times out because the offline choice is never refused, and the two toast tests find no offline notice. All three pass on this head.
  • src/player, src/hooks/queries and src/pages/ItemDetail: 131 files, 1405 tests pass on this head. CI is green.
  • Not checked live: no sandbox could be started for this pass, because the sandbox host had no free network addresses. The published evidence page (subtitle pick made offline) still matches this head.
  • Main has moved since the branch point. The one later change to a helper this PR calls (fix(web): reconcile a restored preference when a replaced save may have landed #5458, in settingWriteOffline.ts) adds code without changing the helpers used here, and the branch merges into main cleanly.

Review notes

Code review and a council round on 93cb0ed found nothing that blocks merging. Answered without a change:

  • Re-check the offline state when a queued write leaves the line. That would not help [bug] Web player track choice made offline is sent after reconnect when an earlier save is pending #4576. The earlier save settles only after reconnect, so the check would see the browser online and send the offline pick anyway. The PR's queue test fails with an exit-only check. If the earlier save fails while the browser is still offline, the queued write fails too and stores nothing; only the wording of the notice differs.
  • Automatic subtitle handoffs (a finished translation, a reused stored track) can raise the notice. Both finish a pick the viewer asked for. They need a fresh subtitle list from the server, so they can't run while offline, except when the connection drops in the moment between that list arriving and the selection.

Optional nits, none needed for merge: the doc comment on runOrderedPreferenceWrite still names only the hook-side check, and the queue test's setTimeout(0) flush could go.

A similar gap that predates this PR exists in the subtitle delay control: a delay nudge made offline can queue behind a pending save and go out after reconnect. It is outside this PR and has been reported to the maintainers separately.

Validated features

Validation tasks: none. The passed web cases nearest the diff, #1181 C1 (independent preferences per profile) and #1221 C1 (device and override auditing), are unaffected. #1159 (subtitle playback, web) has no passed cases.

Other checks

  • User manual: unaffected. The subtitles page says Silo remembers the pick for the show and doesn't describe offline saves.
  • Other clients: Apple and Android keep and retry offline picks by design; Roku doesn't save track choices. The PR body's Other clients: line says so.
  • jellycompat: not involved; the change is in the web player only.
  • Council on 93cb0ed: Sol (gpt-6.2-sol, medium) 9/10, Opus (claude-opus-5-5, medium) 8.5/10, Gemini (gemini-4-neon, medium) 9/10. The earlier round on e37c0f5 flagged the audio notice fixed above.

🤖 Claude Code (claude-opus-5-5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working javascript Pull requests that update javascript code priority: P2 Limited scope, workaround exists, or polish size/M 50–199 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 track choice made offline is sent after reconnect when an earlier save is pending

2 participants