Skip to content

fix(web): show the action's own message when a preference save can't reach the server - #4537

Merged
Quick104 merged 8 commits into
mainfrom
fix/web-localize-offline-preference-save-errors
Nov 22, 2026
Merged

Quick104 merged 8 commits into
mainfrom
fix/web-localize-offline-preference-save-errors

Conversation

@Quick104

@Quick104 Quick104 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

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-XA pseudo-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.message for any error. A rejected fetch is a TypeError, 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) in web/src/api/v2/request.ts, next to v2ErrorText, does the reverse. It keeps any Error'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) in settingWriteOffline.ts. It shows #4534's offline notice through reportOfflineSettingFailure, under one toast id so a burst of offline saves shows it once, and otherwise toasts readableErrorText(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 fetch rejects: 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-XA pseudo-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 Error these hooks see still shows its own message.

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.

Council review

Rounds: 2, last reviewed 355e296

Member Round 1 (1de0518) Round 2 (355e296)
Sol (gpt-6.2-sol) 7/10 (xhigh) 8/10 (medium)
Opus (claude-opus-5-5) 7/10 (high) 9/10 (medium)
Gemini (gemini-4-neon) 6/10 (xhigh) 9/10 (medium)

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

  • Harness: Claude Code in T3 Code
  • Tool(s): Claude Code, T3 Code, GitHub CLI, Playwright
  • Model(s): claude-opus-5-5 (implementation, code review), claude-sonnet-5-5 (code review)
  • Involvement: Fully AI-generated; human review pending
  • Adversarial review: the plan round was skipped as mechanical: the defect and its constraint came from fix(web): fail offline admin setting and subtitle/audio saves instead of replaying them #4534's plan and code reviews, and the change is a few lines in the onError handlers that show the text. A simplify pass tightened one test assertion. A multi-agent code review at high (claude-opus-5-5 and claude-sonnet-5-5) found that StaleApiRequestContextError still 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

  • Adds readableErrorText in request.ts. It replaces developer-facing errors (TypeError, V2TimeoutError, V2TransportError, StaleApiRequestContextError) and non-Error values with a supplied translated fallback. Other Error messages still show.
  • Adds toastSettingWriteError in settingWriteOffline.ts. It shows the shared offline notice for refused offline writes, deduplicated across bursts, and otherwise uses readableErrorText with the caller's fallback.
  • Applies both helpers across admin setting hooks in users.ts and preference/subtitle hooks in subtitles.ts and trackPreferences.ts, plus subtitle search/upload UI in SubtitleUploadForm, SubtitleSearchDialog, and SubtitleSearchModal.
  • Partial device reset stop messages now omit unreadable reasons and trim trailing whitespace.
  • Behavioral Change: server and validation error messages still display; only transport/timeout/stale errors and non-Error values switch to the fallback. Stale-context toast suppression in the subtitle hooks is unchanged.

Macroscope summarized 27c54d7.

…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>
@silo-triage silo-triage Bot added the size/M 50–199 added + deleted lines (all files); change volume, not priority. label Nov 18, 2026
@coderabbitai

coderabbitai Bot commented Nov 18, 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 9 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: d25d6cee-6f54-4265-9843-e14bba9140cb
Commits

Reviewing files that changed from the base of the PR and between 2b5425c and 27c54d7.

Files selected for processing: 9

  • web/src/api/v2/request.ts
  • web/src/components/subtitles/SubtitleUploadForm.tsx
  • web/src/hooks/queries/admin/users.ts
  • web/src/hooks/queries/settingWriteOffline.ts
  • web/src/hooks/queries/subtitles.ts
  • web/src/hooks/queries/trackPreferences.ts
  • web/src/hooks/queries/transportFailureToasts.test.tsx
  • web/src/pages/ItemDetail/components/SubtitleSearchDialog.tsx
  • web/src/player/components/SubtitleSearchModal.tsx
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@silo-kody

silo-kody Bot commented Nov 18, 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 18, 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-22T04:18:51.439606Z 355e296 New commits
🔒 Security Review ✅ Completed 2026-11-22T04:24:10.451586Z 27c54d7 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 evidence-required Needs before-and-after evidence before the Evidence check passes 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 18, 2026
@silo-triage

silo-triage Bot commented Nov 18, 2026

Copy link
Copy Markdown

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.

@Quick104 Quick104 left a comment

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.

Adversarial review (gpt-6.2-sol, reviewed 820f3f8)

AI-assisted review by gpt-6.2-sol via Codex in T3 Code.

Comment thread web/src/hooks/queries/subtitles.ts Resolved
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

silo-kody Bot commented Nov 18, 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 and others added 3 commits November 19, 2026 10:52
…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 Quick104 left a comment

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.

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)

Comment thread web/src/hooks/queries/admin/users.ts Resolved
@silo-triage silo-triage Bot added size/L 200–499 added + deleted lines (all files); change volume, not priority. and removed size/M 50–199 added + deleted lines (all files); change volume, not priority. labels Nov 19, 2026
@silo-kody

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

Copy link
Copy Markdown
Contributor Author

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". readableErrorText passes that message through, so the two changes fit together. The text this PR removes still showed whenever the browser reports online but the request fails: the server is down or unreachable, a proxy drops the request, or it times out.

Addressed in this review

  • Repeated offline saves each showed their own copy of the offline notice. fix(web): fail offline admin setting and subtitle/audio saves instead of replaying them #4534's review left that to this PR. The nine saves now report errors through toastSettingWriteError, which shows the offline notice under the shared toast id (one toast for a burst) and otherwise the action's own message (355e296).
  • The player's Add Subtitles dialog still showed "Failed to fetch" for search and download, right under the upload form this PR had already fixed. Both now use readableErrorText with the dialog's existing fallbacks (355e296).
  • A doc comment on reportOfflineSettingFailure described its old callers only (27c54d7).

Left for maintainers

  • The admin Home sections editor and the player's own audio choice toast have the same problem. They need this PR's helper, so [bug] Admin Home sections and player audio saves show the browser's error text when the server can't be reached #5101 tracks them for after this merges.
  • web.admin.common.users.resetAllRemainingFailed is no longer used in code. Removing it can wait for a later catalog change.
  • In Arabic and Hebrew, the "Reset stopped after…" message with no reason ends with a space and two invisible direction marks, because the formatter wraps even an empty value. Nothing visible changes, so this review leaves it.
  • These predate this PR and sit outside its lines: an admin subtitle appearance edit queued behind a stalled save can still go out after reconnect (fix(web): fail offline admin setting and subtitle/audio saves instead of replaying them #4534 listed it as left open); a failed upload on the title page shows both a toast and an inline alert; in the player dialog, a download whose response body fails to read closes as if it succeeded, and a token refresh during a download leaves its spinner running.
  • The triage bot's request for phone-width captures: phone and desktop web run the same hooks, and the change only alters toast and alert text, so this review adds none.

Verification

  • Live on a sandbox built from 355e296 (27c54d7 only changes a comment): a blocked admin setting save shows "Failed to save setting"; three Subs → Off picks made offline show one offline toast and send no request; in the player dialog, a blocked search shows "Search failed" and a blocked download "Download failed". The sandbox has no subtitle provider, so the provider check was answered as enabled for the player steps.
  • transportFailureToasts.test.tsx: the PR's three cases fail on main with Received: "Failed to fetch". The new offline case fails on 1de0518 (no shared toast id) and passes now.
  • The web tests for hooks, components, pages, player, and api pass, along with typecheck, ESLint, and Prettier. One 5-second timeout in an untouched admin collections test passed when rerun alone.

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.

  • Sol (gpt-6.2-sol): 7/10, then 8/10
  • Opus (claude-opus-5-5): 7/10, then 9/10
  • Gemini (gemini-4-neon): 6/10, then 9/10

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)

  • Fit: a narrow fix that keeps browser error text out of translated failure messages and shows the offline notice once. It adds no interface text or settings and reuses the existing request and offline helpers.
  • Readiness: the tests fail on the code before each fix for the reported reason, the fixed flows were shown live on the final build, and the board check found no affected case. What's left is tracked follow-up work, not a defect in this change.

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

@Quick104 Quick104 left a comment

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.

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)

Quick104 and others added 2 commits November 22, 2026 04:16
…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>
@Quick104
Quick104 merged commit 43fcb5a into main Nov 22, 2026
18 of 19 checks passed
@Quick104
Quick104 deleted the fix/web-localize-offline-preference-save-errors branch November 22, 2026 04:35
Quick104 pushed a commit that referenced this pull request Nov 23, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working evidence-required Needs before-and-after evidence before the Evidence check passes 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.

1 participant