Skip to content

fix(storage): read the iOS connection library per record and back up both apps' library as last saved - #4339

Merged
datlechin merged 4 commits into
mainfrom
feat/macos-connections-store-recovery
Nov 19, 2026
Merged

datlechin merged 4 commits into
mainfrom
feat/macos-connections-store-recovery

Conversation

@datlechin

@datlechin datlechin commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Summary

From #4273:

  • CS-08: the macOS app got per-record decoding and a backup in fix(edits): keep pending edits, transactions and saved connections from being lost without asking #4283. The iOS app still decoded connections.json, groups.json and tags.json all or nothing, so one record it could not read failed the whole library: no connections shown, every change refused, sync skipped, and every retry failed the same way. It now loads what decodes and writes the rest back as it was.
  • Both apps: the backup is a copy of the file as last saved, taken after each save, instead of the file before it. A restore no longer rolls back the last save, so it cannot drop a connection added in it or bring back one deleted elsewhere. A save that moves secrets out of the file (plugin secure fields on macOS, pasted SSH keys and MongoDB URI secrets on iOS) drops the old backup and any damaged copy first, or writes nothing.
  • Both apps: a record kept unread gives way when a save writes a record with its id, such as the same connection pulled again by sync, so the file never holds two records for one id.
  • iOS: the ids of records kept unread keep their Keychain items, certificate files, recents, favorites order and collapsed groups through the launch cleanup and preference prune, and their saved queries stay off iCloud in both directions. A pending pasted SSH key of such a record stays held. Tag presets fill in only a tag file with nothing in it.
  • iOS: the pasted SSH key migration read the same file all or nothing, so one record without an id hid every pending key and the next save dropped them. It reads per record now, and a key that reached the Keychain also leaves a record the app cannot read.
  • macOS: the Welcome list kept recents and favorites order only for connections it read, and emptied the favorites order when the library failed to load.
  • The record codec moves from IntegrityStampedFileStore into TableProConnectionLibrary (LibraryFileRecords), shared by both stores and the App Intents loader. ConnectionPersistence moves out of AppState.swift beside the group and tag persistence. .claude/rules/data-sync-storage.md covers these files and lists the iOS backup files.

Tests changed on purpose:

  • ConnectionStoreTagRemovalTests: saveKeepsThePreviousFileAsBackup becomes saveMirrorsTheFileAsTheBackup; damagedFileIsRestoredFromBackup, damagedFileNeverBecomesTheBackup and untaggedBackupIsRestoredUntrusted expect the last saved state back.
  • SyncLocalOnlyDependentsTests.unreadableConnectionStoreHoldsOwnedRecords and AIConnectionAccessGateTests.undecodableStoreRefuses delete the backup too, since a saved file now always has one.

Test plan

  • LibraryFileRecordsTests (swift test): unread records kept verbatim, entries that are not objects, a saved record superseding a kept one, a decode-only type, non-arrays throw.
  • AppStateLibraryTests (iOS): one bad connection, group or tag keeps the library writable and is written back; a damaged connections.json comes back as last saved with .unreadable kept; a moved SSH key leaves no copy in the backup, and stays in the file while the backup cannot be dropped; an unread preset tag is kept. Fail on main (the library is .failed).
  • AppStateSyncWiringTests, PastedSSHKeyMigrationTests (iOS): an unread owner's saved queries are neither pushed nor deleted by a pull; keys survive records with no id and entries that are not objects.
  • macOS: ConnectionStoreTagRemovalTests (mirror, secret-removing save that cannot drop the backup), WelcomeViewModelTests (recents and favorites order), plus the storage and sync suites around them.

Refs #4273

@datlechin
datlechin enabled auto-merge (squash) November 19, 2026 06:05
@datlechin
datlechin disabled auto-merge November 19, 2026 06:14
@datlechin
datlechin merged commit 1c0e3a9 into main Nov 19, 2026
41 of 45 checks passed
@datlechin
datlechin deleted the feat/macos-connections-store-recovery branch November 19, 2026 06:14
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.

1 participant