Skip to content

Desktop: 40+ scattered UserDefaults keys without type safety or validation #5793

Closed

Description

@beastoin

Problem

Settings are stored across 40+ UserDefaults string keys spread across AppBuild, UpdaterViewModel, AuthService, ChatProvider, ConversationsPage, SettingsPage, and more. Each service uses its own key namespace with no type safety — all keys are raw strings.

Impact

  • Typos in key names cause silent resets to defaults
  • No settings migration when new versions add boolean settings (existing users stuck at unexpected defaults)
  • Refactoring a setting name silently breaks persistence
  • No single source of truth — settings come from UserDefaults, Firestore (SettingsSyncManager), local Rewind DB simultaneously

Suggested Fix

  • Create a centralized enum PreferenceKey with type-safe accessors
  • Add a settings version/migration mechanism
  • Consolidate to single source of truth per setting

Context

Found during desktop friction exploration (PR #5790).

Files: desktop/Desktop/Sources/MainWindow/Pages/SettingsPage.swift (5500+ lines), desktop/Desktop/Sources/AppState.swift, various providers

Activity

  1. added
    p3
    on Mar 18, 2026
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

    desktopp3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions