Repository navigation
fix(web): show the action's own message when a preference save can't reach the server - #4537
Conversation
…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>
|
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 9 minutes. 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. |
|
The before-and-after captures show the desktop toast changes, but these shared hooks also change the messages on mobile web. Please add before-and-after phone-width captures for the affected admin preferences and title-page error states, or explain why either flow is desktop-only. CONTRIBUTING.md treats desktop and mobile web as separate evidence surfaces. |
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>
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:
|
…h 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>
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>
Quick104
left a comment
There was a problem hiding this comment.
Review of 82672dd, which is this branch with main merged in (main's #4541 changed trackPreferences.ts next to these lines). Two findings. I'm fixing both in commits on this branch, so there's no need to change anything yourself.
[P3] The same subtitle dialog still shows the browser's error for language detection and search. SubtitleUploadForm.tsx:130 (language detection when a file is picked) and SubtitleSearchDialog.tsx:168 (subtitle search) still show err.message for any error. With detection's request rejected as TypeError("Failed to fetch"), the form's alert shows "Failed to fetch" on this head. Both now use readableErrorText with the fallbacks they already had (web.subtitles.upload.detectFailed, web.detail.subtitleSearch.failed).
The player's own request layer (web/src/player/player-v2.ts) has an older, related problem: when a proxy answers with an HTML error page, it puts the page's text into the error message. That predates this PR and affects every player request, so it goes to its own PR.
🤖 Claude Code (claude-opus-5-5)
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:
|
|
Maintainer review summary — reviewed head 27c54d7 This branch now includes main (merged in 1de0518). Main's #4534 changed the same nine setting and track saves: a save made while the browser reports offline is now refused before it's sent, with the translated "You're offline, so this change wasn't saved". Addressed in this review
Left for maintainers
Verification
Validated features: checked against the validation board. #1221 C1 (passed) covers successful saves, which this PR leaves alone. #1162 C2 (not run) relies on a server rejection, which still shows unchanged. No passed case is affected. User manual: unaffected. It doesn't document these failure messages. Other clients: web only. The text that leaked comes from the web app's own fetch errors. Translations: no interface text added or changed; every message is an existing catalog key. Council: round 1 on 1de0518, round 2 on 355e296.
All three found the stacked offline toasts and the player dialog in round 1; both are fixed. In round 2, none found a defect in this PR's code. Sol's two new items are in player download code this PR doesn't change. Evidence: https://evidence.siloserver.org/r/silo-server/pr-4537-review/ Fit: 9/10 · Readiness: 9/10 — ready (assuming CI is green)
🤖 Claude Code (claude-opus-5-5) |
Quick104
left a comment
There was a problem hiding this comment.
Review of 1de0518, which is this branch with main merged in. Main's #4534 changed the same hooks: the nine setting and track saves now refuse an offline save in onMutate with a translated SettingWriteOfflineError, and readableErrorText passes that message through. Two findings. I'm fixing both in a commit on this branch, so there's no need to change anything yourself.
[P3] The player's subtitle search and download still show the browser's error. web/src/player/components/SubtitleSearchModal.tsx lines 108 and 207 still render err.message. playerV2 lets a rejected fetch through as a TypeError, so a failed search or download inside the player reads "Failed to fetch" or "Load failed". That modal embeds SubtitleUploadForm, which this PR already fixed, so one dialog now shows translated text for upload and browser text for search right above it. Repair: use readableErrorText with the modal's existing web.subtitles.search.searchFailed and downloadFailed fallbacks. PlayerFetchError carries translated text, so the server's answers still show.
🤖 Claude Code (claude-opus-5-5)
…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>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…o save toasts (#5115) When a save never reached the server, the admin Home sections editor showed "Couldn't save Home sections: Failed to fetch" and the player's audio track pick toasted "Failed to fetch", the browser's English text in every interface language. Both now go through readableErrorText, as the other preference saves do since #4537: a failed fetch falls back to the existing "Couldn't save Home sections" and "Failed to save audio preference" messages, and a server refusal still shows its own reason. Closes #5101
Problem
Related issue: N/A
Validation tasks: none. #1221 C1 (passed) covers successful device-override and profile-setting saves, which this PR leaves alone; #1162 C2 (not run) relies on a malformed upload's server rejection, which still shows unchanged.
Other clients: N/A (web only: the leaked text is the web app's own fetch and request errors)
When the web app can't reach the server, saving or resetting a user's setting or device override in Admin → Users → Preferences, or picking a title's audio or subtitle track, shows the browser's raw error instead of the action's message. Chrome shows "Failed to fetch", Safari "Load failed", and Firefox "NetworkError when attempting to fetch resource.". The text is English in every language, and under the
en-XApseudo-locale it shows as unconverted text. Resetting all overrides for a device puts the same text at the end of its translated "Reset stopped after…" message. Subtitle search, download, upload, and upload language detection have the same problem.Each of these hooks showed
err.messagefor any error. A rejected fetch is aTypeError, and a timeout, a proxy's error page, or a stale request context comes back as an error whose message is developer English. #4534 (now on main) refuses a setting or track save made while the browser reports offline, before it is sent, with the translated "You're offline, so this change wasn't saved". That covers the offline case, and this PR keeps that message. The browser's text still showed whenever the browser reports online but the request fails: the server is down or unreachable, a proxy or firewall drops the request, or it times out. Repeated offline saves also showed one copy of the offline notice per click.Approach
v2ErrorText(#4529) can't be used here. It shows only the server's own answer and replaces everything else, so it would also hide translated errors these hooks throw on purpose: the admin editor's "must be valid JSON" and "must be a number", the device reset's "Reset stopped after…" message, and the subtitle "unsupported identifier" check.A new
readableErrorText(error, fallback)inweb/src/api/v2/request.ts, next tov2ErrorText, does the reverse. It keeps anyError's message except the ones written in developer English (TypeError,V2TimeoutError,V2TransportError,StaleApiRequestContextError), and those get the fallback text the action already had. The device reset uses it for the reason inside its message. When the failure has no readable reason, that message ends at the count ("Reset stopped after 1 of 3 overrides. Reload the settings before continuing.") instead of adding a reason. No interface text is added. The server's refusals and the hooks' own translated errors show exactly what they showed before.Changed: admin setting save and reset, device override save and reset, reset all overrides for a device, audio and subtitle choice save and reset, subtitle search, download, and upload (on the title page and in the player's Add Subtitles dialog), and the upload form's inline alert for both the upload and its language detection.
The nine setting and track saves share
toastSettingWriteError(error, fallback)insettingWriteOffline.ts. It shows #4534's offline notice throughreportOfflineSettingFailure, under one toast id so a burst of offline saves shows it once, and otherwise toastsreadableErrorText(error, fallback).Not changed here: the admin Home sections editor and the player's own audio choice toast have the same problem and need this helper, so #5101 tracks them after this merges.
#4530 covers Plex sign-in, browser notifications, and notification webhook saves, which have the same mix of error kinds. This PR leaves those alone.
Validation
Live on a Silo dev sandbox, before (main at 3151f9d) and after (this branch), with only the save request blocked in the browser so
fetchrejects: adding a setting under Admin → Users → Preferences toasts "Failed to fetch" before and "Failed to save setting" after. Choosing Subs → Off on a movie toasts "Failed to fetch" before and "Failed to save subtitle preference" after.Unit: a new hook-level test fails on main for all three cases (
Received: "Failed to fetch") and passes here. It also checks that a server refusal and the translated "must be valid JSON" error still show.Web lint, format check, typecheck, build, bundle budget, and the full web test suite: pass.
Not checked live: the
en-XApseudo-locale (the sandbox serves a production build without it). Every fallback is an existing catalog key.Maintainer review on 27c54d7: live on a sandbox built from 355e296 (the final head only changes a doc comment). A blocked admin setting save shows "Failed to save setting"; three Subs → Off picks made offline show one "You're offline, so this change wasn't saved" toast and send no request; in the player's Add Subtitles dialog, a blocked search shows "Search failed" and a blocked download "Download failed". A new test (two offline saves share the offline toast id) fails on 1de0518 and passes now. The full web suite for hooks, components, pages, player, and api passes, along with typecheck, ESLint, and Prettier.
Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/pr-4537-review/
Risks
A stale request context (switching profile or signing in again while a save is in flight) now shows the action's failure message instead of the English "The account or server changed before the queued request could be sent." Any other plain
Errorthese hooks see still shows its own message.Checklist
Council review
Rounds: 2, last reviewed 355e296
Visual review: not run (text-only change in toasts and alerts, reviewed without
verify).Fixed: repeated offline saves stacked identical toasts; the player's subtitle search and download still showed the browser's text (355e296). Answered: the reset-all message's empty reason keeps invisible bidi marks in Arabic and Hebrew (no visible effect); the denylist would pass a future developer-English
Error(no reachable case at these call sites). Predates this PR, outside its lines: an admin subtitle appearance edit queued behind a stalled save can still go out after reconnect, upload failures on the title page show both a toast and an inline alert, and two player download edge cases (a body read that fails after a 2xx, a token refresh mid-download).AI Disclosure
StaleApiRequestContextErrorstill leaked English through the new helper, now fixed. It also suggested an opt-in marker class for reader-facing errors instead of a list of developer-English ones; that design is [bug] Plex sign-in, browser notifications, and notification webhook saves show raw network errors #4530's to settle, so this PR keeps the narrower rule. The background adversarial review (gpt-6.2-sol, reviewed 820f3f8) found that the subtitle upload form's inline alert still showed "Failed to fetch" (F1); fixed in 0594090. A maintainer review on 82672dd (claude-opus-5-5, with a gpt-6.2-sol round) found that language detection and subtitle search still showed the browser's text, and that an offline reset-all gave a singular reason when several overrides remained; both are fixed in 4426881 and 0c4f427. That round also found that the player's request helper shows a proxy's raw error page, which predates this PR and goes to its own PR. A second maintainer review with a two-round council is summarized under Council review.🤖 Generated with Claude Code
Note
Fix developer-facing error text leaking into setting-write failure toasts
readableErrorTextin request.ts. It replaces developer-facing errors (TypeError,V2TimeoutError,V2TransportError,StaleApiRequestContextError) and non-Error values with a supplied translated fallback. OtherErrormessages still show.toastSettingWriteErrorin settingWriteOffline.ts. It shows the shared offline notice for refused offline writes, deduplicated across bursts, and otherwise usesreadableErrorTextwith the caller's fallback.SubtitleUploadForm,SubtitleSearchDialog, andSubtitleSearchModal.Macroscope summarized 27c54d7.