Skip to content

fix: prevent connection data loss on normal app quit#453

Merged
datlechin merged 2 commits intomainfrom
fix/452-connection-persistence
Mar 25, 2026
Merged

fix: prevent connection data loss on normal app quit#453
datlechin merged 2 commits intomainfrom
fix/452-connection-persistence

Conversation

@datlechin
Copy link
Collaborator

Summary

Fixes #452 — saved connections disappear after normal app quit (Cmd+Q) but persist after force quit.

  • Root cause: WelcomeWindowView.loadConnections() overwrites UserDefaults with an empty array when storage.loadConnections() returns empty during SwiftUI scene teardown on quit. Since DatabaseConnection.sampleConnections was [], this destructively erased valid saved data.
  • Remove the destructive overwrite — loadConnections() now simply reads from storage without writing back
  • Add UserDefaults.standard.synchronize() in applicationWillTerminate as a defensive flush
  • Replace broken sampleConnections (empty array indexed at [0] in previews) with a proper DatabaseConnection.preview static

Test plan

  • Create a new connection and connect successfully
  • Quit app normally (Cmd+Q), reopen — verify connection is still listed
  • Force quit app, reopen — verify connection is still listed
  • Fresh install (no saved connections) — verify welcome window shows empty state without errors

@datlechin datlechin merged commit a63c497 into main Mar 25, 2026
2 checks passed
@datlechin datlechin deleted the fix/452-connection-persistence branch March 25, 2026 05:58
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.

Saved connection does not displayed

1 participant