Skip to content

fix(web): fail offline profile edits instead of replaying them over newer changes - #4535

Merged
Quick104 merged 3 commits into
mainfrom
fix/offline-profile-update-overwrite
Nov 21, 2026
Merged

Quick104 merged 3 commits into
mainfrom
fix/offline-profile-update-overwrite

Conversation

@Quick104

@Quick104 Quick104 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: none (#1181's cases save profiles online, which this doesn't change)

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, a profile edit saved while the browser was offline could undo changes made to that profile from another browser. The editor showed "Saving..." and held the request until the connection came back, then sent the form as it was before going offline. The server stored it over whatever had changed in the meantime.

The profile editor sends every field in the form, not only the one that was edited. So the overwrite isn't limited to the field being edited. Reproduced on a dev sandbox:

  1. Browser A opens Settings → Profiles → Edit, goes offline, renames the profile and clicks Save profile. The button stays on "Saving...".
  2. Another client sets the same profile's maximum content rating to PG-13.
  3. Browser A reconnects. Its held save goes out, and the profile ends up with A's name and no rating limit. The PG-13 limit is gone.

The onboarding tour's profile steps (quality ceiling, subtitle mode) use the same save and were held the same way.

With this change, profile edits, avatar uploads and avatar removals fail right away while offline and show "Failed to save profile" (or the avatar equivalent). Nothing is held back and sent later. Profile save errors that aren't a server answer, such as a network error or a proxy error page, now show that translated message instead of the browser's "Failed to fetch".

Replacing an uploaded avatar no longer loses the old one when the upload fails. The editor used to clear the avatar in the profile save before uploading the new file, so a rejected or interrupted upload left the profile with no avatar. With saves now failing at once offline, a connection lost between the two requests did the same.

Approach

useUpdateProfile, useUploadProfileAvatar and useDeleteProfileAvatar in web/src/hooks/queries/profiles.ts now use networkMode: "always", as #4527 does for setting writes and #4534 for admin setting and track-preference saves. Each of these three replaces part of an existing profile, so a replayed request can overwrite a newer change. Creating a profile keeps the default: a held create adds a new profile and writes no old field values over a newer edit. Deleting a profile already fails at once offline since #4548.

All five profile mutation error toasts now go through v2ErrorText with the localized fallback each hook already had (#4529 did the same for setting saves). A server problem answer still shows the server's own message. No new interface text.

When a file is chosen, the profile editor (ProfileEditorDialog.tsx) now leaves avatar out of the PATCH. The upload sets the avatar itself.

The tour's profile-field control still shows the new choice after an offline failure, as it does on main for any failed save. Putting the previous choice back belongs to the follow-up to #4527, which is reworking that control's save path. This change makes the failure visible instead of silent.

Validation

  • Live on a dev sandbox, following the steps above, before (main) and after (this branch). On main, the held PATCH went out on reconnect and cleared the other client's PG-13 limit. With this change, the offline save failed at once with "Failed to save profile", the dialog stayed open with the edit, nothing was sent on reconnect, and the profile kept its name and the PG-13 limit.
  • The same steps at phone width (iPhone viewport) on a second sandbox, before and after: the same results.
  • Avatar replacement on a sandbox, starting from an uploaded avatar and saving with a file the server rejects: on main the profile ended with no avatar; with this change it kept the old one.
  • New hook test covering the three offline profile edits: fails on main (each mutation stays paused), and also fails with only the toast change reverted. Passes here.
  • Related profile, onboarding and settings page tests pass, as do the web typecheck, eslint and prettier.

Evidence

Before-and-after captures and recordings of the case above at desktop and phone width, the avatar replacement case, and the profile as stored at each step.

Evidence: https://evidence.siloserver.org/r/silo-server/offline-profile-edits/

Risks

Saving a profile edit offline now shows an error instead of waiting for the connection, matching the settings pages after #4527.

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

🤖 Generated with Claude Code

Note

Fail offline profile edits immediately instead of replaying them after reconnect

  • Sets profile-edit mutations (update, avatar upload, avatar delete) to networkMode: 'always' via a new PROFILE_EDIT_NETWORK_MODE constant in profiles.ts. They now run while offline, fail, and show their error toast instead of being queued by React Query for replay over newer changes.
  • Passes mutation errors through v2ErrorText with the existing save/upload/remove/delete-failed translations as fallback, for all five profile hooks.
  • Omits the avatar field from the update body in ProfileEditorDialog.tsx when a replacement avatar file is selected, so the request does not clear the avatar before the new file uploads.
  • Adds an offline test suite in profiles.offline.test.tsx covering all three profile-edit mutations, including failure-toast assertions.

Macroscope summarized f907ccb.

…ewer changes

A profile edit saved while the browser was offline was held by TanStack
Query's default "online" network mode and sent on reconnect. The editor
sends every field in its form, so the held PATCH replaced anything another
browser had changed on that profile meanwhile, including a rating limit.

Profile updates, avatar uploads and avatar removals now use networkMode
"always", as setting and track-preference writes do: offline they fail at
once with an error. Profile save errors that are not a server answer show
the hook's translated fallback through v2ErrorText instead of the browser's
"Failed to fetch".

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 4 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: 31767fb3-275c-43c3-a1a2-1158936f4ad5
Commits

Reviewing files that changed from the base of the PR and between bd40bd9 and f907ccb.

Files selected for processing: 3

  • web/src/components/profiles/ProfileEditorDialog.tsx
  • web/src/hooks/queries/profiles.offline.test.tsx
  • web/src/hooks/queries/profiles.ts
  • 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-19T15:57:36.779576Z f907ccb New commits
🔒 Security Review ✅ Completed 2026-11-19T16:00:43.183940Z f907ccb 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: data-loss User data deleted, corrupted, or unrecoverable priority: P0 Fix/merge first: data-loss, security, or widespread breakage labels Nov 18, 2026
@silo-triage

silo-triage Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Resolved: the added before-and-after phone-width captures cover the offline profile save/error state requested below.

Original request

The evidence covers desktop web only. Please add before-and-after phone-width captures of the offline profile save/error state, or explain why this change does not affect mobile web. 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 ae4e3cc)

AI-generated by gpt-6.2-sol via Codex.

Comment thread web/src/hooks/queries/profiles.ts Resolved
Comment thread web/src/hooks/queries/profiles.ts Resolved
When a file was chosen, the profile editor's PATCH cleared the current avatar
before uploading the new one, so a failed upload left the profile with no
avatar. Since profile edits now fail at once offline, a connection lost
between the two requests hit this too. The upload sets the avatar itself, so
the PATCH now leaves it alone when a file is chosen.

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

Copy link
Copy Markdown
Contributor Author

Added phone-width (iPhone viewport) before-and-after captures and recordings to the evidence page: the offline save held on "Saving..." on main, and failing at once with "Failed to save profile" on this branch. The stored profile behaves the same at both widths. The page also covers the avatar fix in f8fe3ba.

Evidence: https://evidence.siloserver.org/r/silo-server/offline-profile-edits/

@silo-triage silo-triage Bot removed the evidence-required Needs before-and-after evidence before the Evidence check passes label Nov 18, 2026
@Quick104

Copy link
Copy Markdown
Contributor Author

Review summary

Reviewed head: f907ccb (f8fe3ba with main merged in).

I found no defects. I merged main into the branch because #4548 changed useDeleteProfile in profiles.ts after this branch was cut. The merge was clean, and deletes now fail at once offline on main. I updated the Approach sentence in the PR body that said deletes keep the default.

What I checked:

  • networkMode: "always" on update, avatar upload, and avatar delete. App mutations default to retry: 0 (web/src/lib/query-client.ts), so an offline save fails once and isn't retried.
  • v2ErrorText keeps the server's message for problem answers and for session-refresh failures. Every other error, including a network error, a proxy page, or a stale request context, shows the translated fallback. All five hooks already had that fallback text.
  • Leaving out avatar when a file is chosen is safe. UploadAvatar writes the new avatar reference itself (internal/api/handlers/profile_avatars.go), so a failed upload leaves the old preset or upload in place. Create builds its body separately and isn't affected.
  • The tour's profile-field control still shows the new choice after a failed save. The PR body says so, and the same happens on main for any failed save.

Tests: profiles.offline.test.tsx fails on the base for all three hooks (each mutation stays paused, isError false) and passes on the head. The profile, onboarding, and profile-delete offline tests pass, and so does the web typecheck after the merge.

Earlier threads: F1 (avatar lost when its replacement fails) is fixed in f8fe3ba, and I traced the fix against the upload handler. I agree with keeping F2 as it is: the old toast showed untranslated developer text.

Validated features: the board wasn't readable from here. Of #1181's cases, the ones that save profiles online don't go through the changed offline path.
User manual: unaffected. The profiles guide doesn't describe saving while offline.
Other clients: web-only, as the PR says. The admin profile editor's offline replay is covered by #4542.
Evidence: the main merge only touched profile delete, so the existing captures still match this head.

Fit: 9/10 · Readiness: 9/10 — ready (assuming CI is green)

Fit: it stops offline saves from silently overwriting newer profile changes, matches #4527 and #4534, and adds no new setting or text. Readiness: the tests fail on the base, the change was shown live on a sandbox before and after, and no concern remains.

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

@Quick104
Quick104 merged commit 9136bbf into main Nov 21, 2026
18 checks passed
@Quick104
Quick104 deleted the fix/offline-profile-update-overwrite branch November 21, 2026 17:55
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: data-loss User data deleted, corrupted, or unrecoverable priority: P0 Fix/merge first: data-loss, security, or widespread breakage 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.

1 participant