Repository navigation
fix(web): fail offline profile edits instead of replaying them over newer changes - #4535
Conversation
…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>
|
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 4 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. |
|
Resolved: the added before-and-after phone-width captures cover the offline profile save/error state requested below. Original requestThe 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. |
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 — 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:
|
|
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/ |
Review summaryReviewed head: f907ccb (f8fe3ba with main merged in). I found no defects. I merged main into the branch because #4548 changed What I checked:
Tests: 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. 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) |
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:
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,useUploadProfileAvataranduseDeleteProfileAvatarinweb/src/hooks/queries/profiles.tsnow usenetworkMode: "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
v2ErrorTextwith 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 leavesavatarout 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
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
AI Disclosure
v2ErrorTexthelper. A single-pass code review changed nothing. A background adversarial review (gpt-6.2-sol, reviewed ae4e3cc) raised two findings: F1, a failed avatar replacement losing the old avatar, fixed in f8fe3ba; F2, the profile picker's account-change error now shows the translated save-failed message instead of untranslated English, kept as intended. It also found that the admin profile editor has the same offline replay; that is on main too and is being fixed separately.🤖 Generated with Claude Code
Note
Fail offline profile edits immediately instead of replaying them after reconnect
networkMode: 'always'via a newPROFILE_EDIT_NETWORK_MODEconstant 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.v2ErrorTextwith the existing save/upload/remove/delete-failed translations as fallback, for all five profile hooks.Macroscope summarized f907ccb.