Repository navigation
Sync the dictionary and snippets with the iPhone through iCloud - #25
Conversation
End-to-end encrypted sync with no accounts: one device makes a secret, others pair by scanning its QR code or typing the code. HushtypeCore gets the shared format (SyncVocabulary with per-item merge and tombstones), the keys and AES-GCM sealing (SyncKeys) and the client (SyncClient). The Mac app adds a Your devices section in Settings > General. sync-server/ is the Cloudflare Worker + D1 server with tests and the protocol spec. iCloud sync leaves the dictionary and snippets alone while this is on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01H6HfURkfdoEWCjjJLphzQX
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01H6HfURkfdoEWCjjJLphzQX
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01H6HfURkfdoEWCjjJLphzQX
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With Sync with iCloud on, DeviceSync keeps a per-word SyncVocabulary in iCloud key-value storage (key vocabulary.v1) and merges it the same way as the sync server, so Macs and iPhones on one Apple ID sync with no pairing and iCloud and the server can both be on. CloudSync now only carries the style settings; the old whole-list dictionary and snippets values are merged in once and no longer written. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01H6HfURkfdoEWCjjJLphzQX
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01H6HfURkfdoEWCjjJLphzQX
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # Sources/Hushtype/CloudSync.swift # Sources/Hushtype/DeviceSync.swift # Sources/Hushtype/DeviceSyncViews.swift # Sources/Hushtype/SettingsWindow.swift
syncNow reconciled Settings against the ledger after merging iCloud in, so every word that had just arrived looked removed and was tombstoned and written back. Reconcile against this device's own ledger instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01H6HfURkfdoEWCjjJLphzQX
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e667557889
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let ledger = localLedger() | ||
| do { | ||
| let merged = try await SyncClient(keys: joined).sync(ledger, joining: true) |
There was a problem hiding this comment.
Merge iCloud data before joining the server group
When iCloud sync is on and this Mac has vocabulary that exists only in iCloud, joining a server group sends only localLedger() to the server. apply() then writes the server/local result back to vocabulary.v1, replacing those iCloud-only words and snippets. Merge the iCloud ledger into the join input before syncing so pairing does not discard existing shared data.
Useful? React with 👍 / 👎.
| /// added here once, so nothing an older Mac synced is lost. | ||
| private func importLegacyICloudOnce() { | ||
| guard !defaults.bool(forKey: Self.legacyImportedKey) else { return } | ||
| defaults.set(true, forKey: Self.legacyImportedKey) |
There was a problem hiding this comment.
Wait for iCloud's initial download before marking legacy data imported
On a Mac whose iCloud key-value store has not received its initial download, this permanently sets the migration flag before reading legacy values; the subsequent initial-sync notification calls syncNow() again, but the flag then prevents importing them. Apple's synchronize() documentation notes that initial values need not be immediately available, so defer marking the migration complete until the legacy values are available to avoid skipping an existing dictionary or snippets on a new device.
Useful? React with 👍 / 👎.
Requested by Chiranjeeb · project thread
What
CloudVocabulary(HushtypeCore) keeps the same per-wordSyncVocabularythat the sync server uses, stored in iCloud key-value storage under the keyvocabulary.v1. The Mac and the iPhone app share one store (<team>.app.hushtype.Hushtype), so a Mac and an iPhone on the same Apple ID sync with no pairing.DeviceSyncmerges iCloud and the server (when paired) in each round. Both use the same merge, so both can be on at once.CloudSyncnow carries only the style settings. The old whole-listdictionaryandsnippetsiCloud values are merged in once and no longer written.SyncApplyTestsguards this.Testing
On the Mac,
swift testpasses 58 tests with 0 failures. The signed iCloud build is installed on the Mac and the iPhone 17 (keyboard branch of the same name). The Mac's dictionary was restored after the bug and has stayed stable. iPhone to Mac was confirmed by the user.Generated by Claude Code