Skip to content

feat(frontend): preserve unsaved form state across 503 error transitions #245

Description

@fpindej

Problem

When the backend goes down while a user has unsaved form input (e.g. profile name, phone number, bio), invalidateAll() triggers the 503 error page which destroys all client-side state. After the backend recovers and the page auto-reloads, the user has to re-enter everything they typed.

Discovered during PR #244 testing — the 503 auto-recovery flow works correctly but is destructive to in-progress work.

Proposed approach

Persist dirty form fields to sessionStorage before the 503 transition and restore them after recovery:

  1. Create a $lib/state/form-persistence.svelte.ts utility (e.g. useFormPersistence(key, fields))
  2. On 503 detection (before invalidateAll()), snapshot dirty fields to sessionStorage
  3. On page mount, check for a saved snapshot and restore field values
  4. Clear the snapshot after successful form submission or on explicit discard

Open questions

  • Should this be opt-in per form, or automatic for all forms?
  • Should it use sessionStorage (tab-scoped) or localStorage (persistent)?
  • How long should snapshots be retained? TTL-based cleanup?

Affected areas

  • src/lib/components/profile/ProfileForm.svelte
  • src/lib/components/settings/ChangePasswordForm.svelte
  • src/lib/components/admin/ — create/edit dialogs
  • Any future forms

Context

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfeatureNew feature or enhancementfrontendFrontend (SvelteKit)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions