Skip to content

fix(connections): keep Local only connections out of remote edits and deletions - #3178

Merged
datlechin merged 2 commits into
mainfrom
fix/local-only-connection-remote-changes
Sep 29, 2026
Merged

datlechin merged 2 commits into
mainfrom
fix/local-only-connection-remote-changes

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

  • A Local only connection still took edits made to its old iCloud copy on another device: host, port, database, username, SSH and SSL settings, Safe Mode level and AI policy were all overwritten on pull. Root cause: SyncCoordinator.applyRemoteConnection never read localOnly, so the Local only rule was enforced on push only and the pull replaced the stored connection with the remote record.
  • A Local only connection was deleted, along with its saved queries and query history, when another device deleted its old iCloud copy. Root cause: applyRemoteConnectionDeletions removed every id the pull named and ran ConnectionLocalState.purge(origin: .remote) on the same unfiltered set.

A connection can be made Local only after it has already synced, and that writes no tombstone, so its iCloud record stays live for other devices to edit or delete. Both pull paths now leave a stored Local only connection alone. The pull is still acknowledged and the record still goes into the record cache, so including the connection in sync again pushes with the server's current change tag and the local copy wins.

Tests

Two new cases in TableProTests/Core/Sync/SyncCoordinatorEchoTests.swift, both driving applyPullResult and reading storage back:

  • localOnlyConnectionIgnoresRemoteEdit: a pull carrying a changed copy of a Local only connection leaves its host, Safe Mode level and localOnly flag unchanged. Fails without the fix: stored.host came back "db.elsewhere" and stored.preferredSafeModeLevel came back .silent.
  • localOnlyConnectionKeepsSavedQueriesOnRemoteDeletion: a pull whose deletedRecordIDs names a Local only connection and a synced one removes only the synced one, and the Local only connection keeps its saved query while the synced one's is purged. Fails without the fix: the Local only connection came back nil. With the row kept but the purge given the unfiltered set, it fails on fetchFavorite(id: keptQuery.id) != nil.

SyncCoordinatorEchoTests, SyncCoordinatorSQLFavoritePullTests, SyncCoordinatorTokenExpiryTests, FavoriteDatabaseSyncTests and CredentialProfileSyncTests: 40 executed, 40 passed. swiftlint lint --strict on the changed Swift files: 0 violations.

Docs

The docs rewrite branch covers the user-facing text.

@datlechin
datlechin merged commit 953a92b into main Sep 29, 2026
9 checks passed
@datlechin
datlechin deleted the fix/local-only-connection-remote-changes branch September 29, 2026 10:04
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