Skip to content

SettingsStore — disposition for remaining @AppStorage / UserDefaults sites #263

@eyelock

Description

@eyelock

Follow-up to refactor/settings-store (which migrated Tier A — the four audit-named drift fields — and Tier B — seven other globals already on SettingsStore). Tracks every remaining direct settings call site and what should happen to it.

Migrate to SettingsStore (next PR — ~25 LOC total)

  • copyOnSelectSettingsView.swift:39, TerminalHostView.swift:472. Same shape as the four named fields.
  • defaultWorkingDirectorySettingsView.swift:40, BoardViewModel.swift:697. Same shape, default NSHomeDirectory().
  • diagnosticsVerboseModeTermQLogBuffer.swift:14, 18, 22. Removes the only direct-UserDefaults pair in the diagnostics service.

Move to a different owner (each its own PR, mostly small)

  • marketplaceAutoRefreshMarketplaceStore (1 site).
  • defaultHarnessAuthorDirectoryHarnessAuthorPreferences or onto HarnessAuthor (5 sites: HarnessWizardSheet, ForkHarnessSheet, DuplicateHarnessSheet, SettingsMarketplacesView, HarnessesSidebarTab).
  • sidebar.selectedTabWorktreeSidebarViewModel or a small SidebarState (3 sites: SidebarView, HarnessDetailView, HarnessWizardSheet — three Views coordinating via @AppStorage is fragile).
  • protectedBranches → dedicated GitConfigStore or stays on WorktreeSidebarViewModel. Not user-pref-shaped; don't fold into SettingsStore.

Stays as-is (justified, no action)

  • dismissedTmuxSessions — runtime state on BoardViewModel+TmuxRecovery, not a preference.
  • repositories (expanded-repo / expanded-branch keys) — sidebar tree state on WorktreeSidebarViewModel. Could become @SceneStorage, not store-bound.
  • feature.harnessTab — feature flag. Move to a FeatureFlags type when there's a second flag.
  • sidebarCollapsed — ephemeral UI state on ContentView. Could become @SceneStorage.
  • SUAutomaticallyChecksForUpdates, SUIncludeBetaReleases — Sparkle-owned key names; we read but don't take ownership.
  • AppleLanguages — Cocoa system pref, mirrored from preferredLanguage.
  • preferredLanguage — paired with AppleLanguages in SupportedLanguage. Migration possible but low value.
  • BackupManager.Keys.* (backupFrequency, backupRetentionCount, lastBackupDate) — backup-domain, self-contained.
  • GlobalEnvironmentManager.storageKey — encrypted env-var blob.
  • YNHDetector.ynhHomeOverrideKey, capabilitiesMinOverrideKey — debug-only overrides.
  • DataDirectoryManager.userDefaultsKey — install config, runs at startup.
  • MarketplaceStore.defaultsSeedKey — first-run seed flag.

Pre-existing inconsistency (its own issue/PR, user-visible)

TerminalHostView.allowOscClipboard (Sources/TermQ/Views/TerminalHostView.swift:192) defaults to true when unset, while SettingsStore.Defaults.allowOscClipboard is false (matching SettingsView's pre-PR default). After this PR, SettingsView reads through the store; TerminalHostView still reads UserDefaults directly with a default-true fallback. So a never-touched user sees "Off" in Settings but TerminalHostView's runtime gate returns true until they explicitly toggle.

This is pre-existing — the audit didn't catch it, and it's beyond "drift fix" scope. Recommended fix: migrate TerminalHostView to SettingsStore.shared.allowOscClipboard, decide whether to preserve the default-true behavior for existing users via a one-shot migration, and CHANGELOG it. Worth its own issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions