Skip to content

Sync the dictionary and snippets with the iPhone through iCloud - #25

Merged
chiranjeebhub merged 8 commits into
mainfrom
claude/project-thread-xh5lbz
Nov 24, 2026
Merged

chiranjeebhub merged 8 commits into
mainfrom
claude/project-thread-xh5lbz

Conversation

@chiranjeebhub

Copy link
Copy Markdown
Owner

Requested by Chiranjeeb · project thread

What

  • CloudVocabulary (HushtypeCore) keeps the same per-word SyncVocabulary that the sync server uses, stored in iCloud key-value storage under the key vocabulary.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.
  • With Sync with iCloud on, DeviceSync merges iCloud and the server (when paired) in each round. Both use the same merge, so both can be on at once.
  • CloudSync now carries only the style settings. The old whole-list dictionary and snippets iCloud values are merged in once and no longer written.
  • A fix found while testing on the devices: words arriving through iCloud were reconciled against the merged ledger, so they looked removed and were tombstoned everywhere. Settings are now reconciled against the device's own ledger, and SyncApplyTests guards this.

Testing

On the Mac, swift test passes 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

claude and others added 8 commits November 14, 2026 08:47
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
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T06:54:18.831495Z e667557 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chiranjeebhub
chiranjeebhub merged commit e2fef0d into main Nov 24, 2026
1 check passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +104 to 106
let ledger = localLedger()
do {
let merged = try await SyncClient(keys: joined).sync(ledger, joining: true)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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.

2 participants