Skip to content

Prevent iCloud sync data from crashing Pesty - #51

Merged
bifrost-proxy merged 1 commit into
mainfrom
codex/fix-sync-duplicate-crash
Aug 23, 2026
Merged

bifrost-proxy merged 1 commit into
mainfrom
codex/fix-sync-duplicate-crash

Conversation

@bifrost-proxy

Copy link
Copy Markdown
Owner

Summary

  • canonicalize duplicate history, tombstone, and Pinboard records before incremental sync
  • skip and retry unreadable batches and incomplete/corrupt checkpoints without terminating the app
  • add regressions for the production duplicate state and malformed remote sync data

Verification

  • swift build
  • incremental sync suite
  • deletion sync suite
  • isolated three-launch UI persistence test
  • localization, history settings, and updater verifiers
  • production state copy loads and renders successfully

@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: 0411c24644

ℹ️ 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 +1028 to +1030
guard seenIDs.insert(item.id).inserted else {
return false
}

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 Preserve distinct clips when repairing ID collisions

When malformed sync state contains two clips with the same UUID but different content, this guard discards the older clip solely because its ID was already seen. Since persisted state is normalized before initialSnapshot is exposed and is subsequently saved, the distinct clipboard content disappears without a deletion tombstone; repair the collision by assigning a new UUID rather than dropping the record.

AGENTS.md reference: AGENTS.md:L85-L88

Useful? React with 👍 / 👎.

Comment on lines +1082 to +1085
guard var existing = byID[board.id] else {
var normalized = board
normalized.items = canonicalHistory(board.items)
byID[board.id] = normalized

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 Preserve Pinboard insertion order during normalization

For iCloud-enabled users who pin an older history item after a newer one, saveToPinboard intentionally inserts the newly pinned item at index 0, but normalizing the board with canonicalHistory sorts its items by their original capture timestamps. On the next launch, loadPersistedState therefore moves the recently pinned older clip behind clips pinned earlier; deduplicate board items without reordering them, or track a separate pin-order timestamp.

Useful? React with 👍 / 👎.

Comment on lines +1031 to +1033
return seenContent.insert(
digestContentKey(legacyContentKey(item))
).inserted

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 Keep clips of different types when canonicalizing content

When history or a Pinboard legitimately contains the same textual payload as different ClipType values—for example, one .text item and one .link item—sameContent(as:) treats them as distinct, but this set uses legacyContentKey, whose default branch hashes both as the same txt: value. Loading or recording the snapshot therefore silently removes one valid entry; make the canonical content key include the clip type so it matches the app's existing content-equality semantics.

AGENTS.md reference: AGENTS.md:L85-L88

Useful? React with 👍 / 👎.

@bifrost-proxy
bifrost-proxy merged commit 159adea into main Aug 23, 2026
1 check passed
@bifrost-proxy
bifrost-proxy deleted the codex/fix-sync-duplicate-crash branch August 23, 2026 06:52
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