Repository navigation
fix(web): fail offline admin setting and subtitle/audio saves instead of replaying them - #4534
Conversation
Admin user setting and device override writes, and a title's subtitle and audio choice (including Auto), used TanStack Query's default network mode. Started offline, they paused and ran on reconnect, replacing or deleting whatever another browser had saved meanwhile. They now use networkMode "always": the request fails at once and the hook's existing error toast shows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
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. |
|
The Evidence section covers desktop web only, but these shared save hooks also change offline error behavior on mobile web. Please add before-and-after phone-width captures for the affected web admin and title-page flows, plus a short recording showing offline save → reconnect, or explain why either surface is desktop-only. CONTRIBUTING.md treats desktop and mobile web as separate evidence surfaces. |
…a pending one Title track choices run in order behind earlier writes for the same title. The browser can report offline while one of those requests is still pending; a choice made then waited in line, went out after reconnect, and could replace a newer choice made in another browser. It now fails at once, like the request it would have sent. Co-Authored-By: Claude Opus 5.5 <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:
|
…e-writes-send-now
Quick104
left a comment
There was a problem hiding this comment.
One finding the guard introduced. I'm fixing it in a commit on this branch, so there's no need to change it yourself.
I also merged main into the branch (#4541 changed trackPreferences.ts); it merged cleanly.
🤖 Claude Code (claude-opus-5-5)
… was refused An audio pick refused offline now fails at once, ahead of an earlier pick still in flight. The selector rolled back to the last saved choice, and when the earlier pick then saved it was recorded but never shown, so the next Play asked for a track the server no longer held. Show it when no newer choice or file change has happened since the rollback. Co-Authored-By: Claude Opus 5.5 <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:
|
Review summaryReviewed head: beb0cf3 (main merged in at 94aebf7; fixes in 6af7388 and beb0cf3). Main since this branch was cut
Addressed
Tests that failed before the fix Live check Left for the maintainers (all happen on main too, so they don't block this PR)
Validated features: not checked against the validation board (the board query failed in this run). By trace, the saves behave as before while online (the offline check passes and the same request goes out), so the cases in the body's User manual: unaffected; no page covers saving web settings or track choices while offline. Apple and Android: not applicable; web only. Council: Sol (gpt-6.2-sol, xhigh) 8/10 then 9/10; Opus (claude-opus-5-5, high) 7.5/10 then 8.5/10; Gemini (gemini-4-neon, xhigh) 6/10 then 9/10. Round 1 reviewed 94aebf7 and round 2 reviewed 6af7388. Fit: 9/10 · Readiness: 9/10 — ready Fit: it stops offline saves from silently replacing newer choices made elsewhere and tells the user plainly, using the offline handling the settings pages already have, with no new setting or API. Readiness: the fix was shown live and by tests that fail without it, every council member scored it 8.5 or higher in round 2, and what remains happens on main too. 🤖 Claude Code (claude-opus-5-5) |
…e-writes-send-now #4538 replaced usePrePlayAudioSelection with the shared usePrePlayTrackSelection, which the Subs menu now uses too. The rule from 4070f66 (show an earlier pick that lands after a later one was refused offline) moves into the shared hook, so it covers both menus. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e notice The nine saves now use settingWriteOptions, the shared option #4527 gave setting writes: an offline save is refused in onMutate before anything is sent, with the localized "You're offline, so this change wasn't saved" message. Before, the admin saves were still sent while offline (one that reached the server could be stored while the page reported a failure), and the track choices were refused with a made-up TypeError whose toast showed the browser's "Failed to fetch" in English. The queue's own offline check goes, since an offline choice no longer reaches it, along with the two networkMode constants. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Quick104
left a comment
There was a problem hiding this comment.
Review of 94aebf7 (main merged in, see below). One finding the PR introduced, and I'm fixing it in a commit on this branch, so there's no need to change it yourself.
Main had moved on since this branch was cut: #4538 replaced usePrePlayAudioSelection with the shared usePrePlayTrackSelection, which the Subs menu also uses now, and #4527 added settingWriteOptions and SettingWriteOfflineError for setting writes. I merged main in (94aebf7) and moved the "show an earlier pick that lands after a refused one" rule from 4070f66 into the shared hook, so it now covers both menus. The EpisodeContent case still fails on main's version of the hook and passes with the port.
🤖 Claude Code (claude-opus-5-5)
…d fetch mock Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r's own subtitle errors The nine setting and track saves refuse an offline save with the translated offline notice (#4534), but each toasted it without an id, so picking several tracks or saving several admin settings offline stacked one toast per click. They now report it through reportOfflineSettingFailure, which shows it once for a burst, and otherwise toast the action's own message. The player's subtitle search and download still showed the browser's "Failed to fetch" beside the upload form this branch already fixed; they now use readableErrorText with the modal's existing fallbacks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…reach the server (#4537) * fix(web): show the action's own message when a preference save can't reach the server Admin setting and device override saves and resets, and a title's audio and subtitle choices, toasted error.message for any failure. When the request never got an answer, that is the browser's "Failed to fetch" (or a timeout or proxy-page message in developer English), untranslated in every language. The device reset embedded the same text in its "Reset stopped" message. v2ErrorText would hide the translated errors these actions throw on purpose (a value that doesn't parse, a reset that stopped part-way). Add readableErrorText, which keeps any Error's message except the ones in developer English (a failed fetch, V2TimeoutError, V2TransportError, and StaleApiRequestContextError) and uses the action's existing fallback for those. Subtitle downloads and uploads get the same treatment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(web): show the upload's own message in the subtitle upload form A failed subtitle upload toasted the translated message, but the upload form also caught the rejection and showed err.message ("Failed to fetch") as its inline alert. Use readableErrorText there with the form's existing fallback. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(web): show the action's own message when subtitle detect or search fails The upload form's language detection and the subtitle search dialog still showed a failed fetch's browser text. Use readableErrorText with each one's existing fallback, as the upload alert does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(web): drop the singular reason when a device reset stops offline With readableErrorText, a lost connection gave the reset-all message the fallback "The remaining override could not be reset.", which is wrong when more than one override is left. A failure without a readable reason now ends the message at the count. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(web): show one offline notice for a burst of saves, and the player's own subtitle errors The nine setting and track saves refuse an offline save with the translated offline notice (#4534), but each toasted it without an id, so picking several tracks or saving several admin settings offline stacked one toast per click. They now report it through reportOfflineSettingFailure, which shows it once for a burst, and otherwise toast the action's own message. The player's subtitle search and download still showed the browser's "Failed to fetch" beside the upload form this branch already fixed; they now use readableErrorText with the modal's existing fallbacks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(web): describe reportOfflineSettingFailure for its new caller Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Problem
Related issue: N/A
Validation tasks: none (#1221 C1 and #1159 C3 use these saves online, where nothing changes)
Other clients: N/A (web-only: the fix is to TanStack Query's offline queue in the web app; Apple, Android and Roku don't share this code)
On the web, an admin's setting change or a viewer's subtitle or audio choice made while the browser was offline could wipe out a newer change made in another browser. The save waited until the connection came back, then sent the value this page had built before going offline, and the server replaced whatever was stored.
Two cases from the review of #4527, both reproduced on a dev sandbox:
The same happens with the admin's device override saves and resets, "Reset all" for a device, and the title page's subtitle and audio picks.
With this change, these saves are refused right away while offline, without sending anything, and the page says "You're offline, so this change wasn't saved". Nothing is held back and sent later.
Approach
The nine mutations behind these saves used TanStack Query's default
networkMode("online"), which pauses a mutation started offline and runs it on reconnect. They now spreadsettingWriteOptions, the shared option #4527 added for setting writes:networkMode: "always"plus anonMutatethat throwsSettingWriteOfflineErrorwhile TanStack reports offline. The save is refused before any request goes out, and each hook's existingonErrortoast shows the localized "You're offline, so this change wasn't saved". Refusing before dispatch is what makes the failure certain: a request sent over a dropping connection could still be stored while the page reports a failure. The admin hooks are inhooks/queries/admin/users.ts; the subtitle and audio title-preference hooks are insubtitles.tsandtrackPreferences.ts.Title track choices also wait in a per-title queue behind earlier choices, so the last one sticks. The browser can report offline while an earlier request in that queue is still pending. Because
onMutaterefuses an offline choice beforemutationFnruns, it never joins the queue, so it can't wait in line and go out after reconnect.Because that refusal can settle before an earlier pick's save, the item page's track selector (
usePrePlayTrackSelection, which the Audio and Subs menus share since #4538) shows the earlier pick when it lands after the refused one rolled the menu back, unless the viewer has chosen again or changed version since.This isn't a global default in
lib/query-client.tsbecause other mutations keep the default pause on purpose: several admin mutations sendIf-Match, and tests assert they pause offline. The rest still need a look of their own (see Follow-ups). A revision check on the setting and track-preference endpoints would also catch two browsers saving at the same moment while online, but it would be an/api/v2change across every client and isn't needed to stop the replay.Validation
SettingWriteOfflineErrorwithout callingfetch. It fails on main (each mutation stays paused) and on 94aebf7 (the admin hooks sent their request and the track hooks rejected with a plainTypeError), and passes now. A second case, a reset made offline behind a pending save, fails on this PR's first commit (the reset waits in the queue) and passes now.EpisodeContentcase for an earlier audio pick landing after a refused one fails on main'susePrePlayTrackSelectionand passes here.hooks,pages/ItemDetail,pages/adminandplayerpass (174 files, 1932 tests);tsc -b, eslint and prettier pass on the changed files. The Go gate wasn't run; no Go code changed.Evidence
Before-and-after captures and recordings of both cases, the pending-save case, and the subtitle case at phone width, recaptured on 6af7388.
Evidence: https://evidence.siloserver.org/r/silo-server/offline-pref-writes/
Risks
An offline save on these pages now shows the offline notice instead of waiting. A save that fails for another reason (the server can't be reached while the browser reports online) still shows the browser's raw error text, as on main; #4537 handles that.
Follow-ups
Checklist
Council review
Rounds: 2, last reviewed 6af7388
Fixed: the hand-made offline check and raw toast text, by using
settingWriteOptions(6af7388); a test assertion and a comment (beb0cf3). Answered: replays across a disconnect of writes sent or queued while online, the in-player path, and other admin saves that still pause happen on main too and are listed under Follow-ups; repeated offline picks each show the same notice, left for #4537, which rewrites these toasts.AI Disclosure
🤖 Generated with Claude Code
Note
Fail offline admin setting and subtitle/audio preference saves instead of replaying them
settingWriteOptionsinto nine admin, subtitle, and audio preference mutation hooks in users.ts, subtitles.ts, and trackPreferences.ts. Offline writes now fail immediately with aSettingWriteOfflineErrorinstead of being queued and sent after reconnect.usePrePlayTrackSelectionin usePrePlayTrackSelection.ts: if a later choice fails while an earlier save is still pending and then succeeds, the selector now shows the saved choice instead of the rollback value.Macroscope summarized beb0cf3.