Skip to content

fix: stale client state and silent request failures - #321

Merged
hieunc229 merged 14 commits into
hieunc229:mainfrom
bobmcdonald0:fix/ui-stale-state
Nov 18, 2026
Merged

hieunc229 merged 14 commits into
hieunc229:mainfrom
bobmcdonald0:fix/ui-stale-state

Conversation

@bobmcdonald0

Copy link
Copy Markdown
Contributor

Fixes for stale client state and requests that hang or fail silently.

  • Account switch: switching accounts reloads the mailbox list. Before, the selector stayed on its loading skeleton until a hard reload.
  • Drive: cached Drive listings are cleared on session change, so a stale listing isn't shown after switching accounts. A late Share response for a previous item is ignored.
  • Message list: error responses are no longer cached or shown as an empty folder.
  • Recovery email: saving it no longer rewrites the profile name with a stale value. name is now optional on PATCH /api/settings/profile.
  • Import: file import rejects cleanly when a proxy returns a non-JSON page, instead of hanging on "Importing". Takeout import stops when you leave the page.
  • First-run setup: register and onboarding reset their loading state when a request fails.
  • Contacts: the photo flag stays in sync while editing a contact.
  • Follow-ups: follow-up loaders ignore out-of-order responses.
  • Branding: the icon preview and file input clear after saving.
  • Turnstile: recovers when its script fails to load.
  • Forward icon: created once instead of on every render.

Tests: drive cache, message list cache, profile schema, import upload response, response JSON helper. The remaining changes are React effects with no component harness. Rebased on current main: tsc is clean, lint has 0 errors, and node --test passes 687 of 689 (2 skipped).

🤖 Generated with Claude Code

bobmcdonald0 and others added 14 commits November 16, 2026 17:43
bugs-mailbox-provider-no-refetch

The provider's fetch effect ran once; on an account switch the reset handler set isLoading=true and never refetched, leaving the skeleton and an empty mailbox until a hard reload.

No test: the fix lives in a React provider effect and the repo has no component test harness; verified by tsc and by tracing the reset path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bugs-drive-cache-not-cleared-on-session-change

Sign-out or account switch does not reload the page, so /drive could render a stale cached listing. Clear it on AUTH_SESSION_CHANGED_EVENT like the other caches.

Test: tests/drive-cache.test.mjs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bugs-message-list-caches-error-response

A JSON 4xx/5xx from /api/messages was cached as the list and blanked the open folder to 'no messages' on every remount. fetchMessageList now rejects non-OK responses without caching, and useMessages keeps the list already shown.

Sidebar counts are unchanged: a failed counts request is not cached, and keeping the previous mailbox's counts after a mailbox switch would be wrong.

Test: tests/message-list-cache.test.mjs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…le name

bugs-profile-recovery-stale-name

The recovery form re-sent the name loaded when the page opened, so renaming and then saving the recovery email reverted the name (user, primary mailbox, self contacts). name is now optional on PATCH /api/settings/profile and the recovery save omits it.

Test: tests/profile-schema.test.mjs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…equest aborts

bugs-import-upload-hangs-non-json

A proxy HTML 413/502 made JSON.parse throw inside onload, so the promise never settled and the import button stayed on 'Importing'. Parse defensively and reject on abort/timeout.

Test: tests/import-upload-response.test.mjs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… fails

bugs-setup-forms-stuck-loading

A dropped connection or an HTML 5xx during first-run setup made fetch or res.json() reject before setLoading(false)/setDomainChecking(false) ran, leaving the button disabled with no error. Handlers now use try/catch/finally with auth.serverUnreachable, and the setup utils tolerate non-JSON bodies via readResponseJson.

Test: tests/response-json.test.mjs (body parsing); the handlers are React event handlers with no component harness in the repo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bugs-contact-edit-stale-avatar-flag

The edit dialog read hasAvatar from the contact snapshot taken on open, so after uploading a photo 'Remove' never appeared, and after removing one it still did (a second remove errored).

No test: React state in a dialog form; no component harness in the repo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bugs-stale-response-loaders

After switching mailbox or message, a slow response for the previous id could land last and show its reminders/status (and act on the new id). Only the newest request now sets state.

No test: effect-local request counter in React components; no component harness in the repo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bugs-drive-share-stale-response

Opening Share on a second item while the first item's response was slow showed the first item's people and public link in the second dialog (and 'Disable link' then posted to the second item). Responses are now dropped once the item changes, and a network failure shows the existing error toast instead of an unhandled rejection.

No test: effect cleanup in a React dialog; no component harness in the repo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bugs-branding-preview-leak

After saving, the preview object URL stayed alive and the file input kept its value, so choosing the same file again fired no change event. The preview is now revoked and the input cleared after a save, and the URL is revoked on unmount.

No test: browser object-URL and file-input handling in a React page; no component harness in the repo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bugs-turnstile-loader-failure

A blocked script stayed in the DOM, so a second mount waited on its load event forever and the first caller raised an unhandled rejection. The failed script is now removed, waiters also reject on error, and the loader call has a catch so a later mount retries.

No test: DOM script loading in a client component; no component harness in the repo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bugs-takeout-continues-after-unmount

Navigating away mid-import left the upload loop running with no progress UI or Stop button, and a second import could then run concurrently. The controller is now aborted on unmount; progress is already saved for resuming.

No test: effect cleanup in a React component; no component harness in the repo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
perf-forward-icon-recreated-each-render

Forward called createIcon (forwardRef) on every render, a new component type each time, so React remounted the SVG on every parent render (message actions, rules rows). Hoisted to module scope; className now goes through cn() instead of rendering 'undefined scale-x-[-1]'.

No test: JSX icon wrapper; no component harness in the repo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hieunc229
hieunc229 merged commit e4fff61 into hieunc229:main Nov 18, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants