Skip to content

Fix reactions and DM messages lost during iCloud sync - #262

Open
FrankBStack wants to merge 1 commit into
OpenBubbles:rustpushfrom
FrankBStack:fix/cloud-reactions-chat-identifier
Open

Fix reactions and DM messages lost during iCloud sync#262
FrankBStack wants to merge 1 commit into
OpenBubbles:rustpushfrom
FrankBStack:fix/cloud-reactions-chat-identifier

Conversation

@FrankBStack

@FrankBStack FrankBStack commented Sep 6, 2026

Copy link
Copy Markdown

Two related problems with messages pulled from iCloud:

Reactions never attached. The cloud stores the reaction target as p:<part>/<guid>, but locally reactions are linked by the bare guid, so every restored tapback ended up orphaned. Message.fromCloud now strips the prefix and uses the part number from it when present (falling back to the attributedBody range lookup as before).

DM messages were dropped. Cloud sync routes DM messages by chatIdentifier, which chats created live in the app never populated. Those messages were silently skipped while the sync checkpoint still advanced, so they were never retried.

  • createChat now sets chatIdentifier to the participant address for 1:1 chats.
  • When a synced message still doesn't resolve to a chat, fall back to matching a non-group chat by participant address, then to the group id carried in proto4, and only then skip with a warning.

One-time repair on startup (guarded by prefs flags so it runs once):

  • Rewrites any already-stored reactions with a prefixed associatedMessageGuid.
  • Backfills chatIdentifier on existing single-handle chats.
  • Clears the chat/attachment/message sync tokens so the next sync re-pages from the start and picks up the messages that were previously skipped.

That last point means the first sync after updating will walk the full cloud history again. I couldn't see a cheaper way to recover the dropped messages since the checkpoint had already moved past them, but happy to gate it differently if you'd rather.

Likely addresses the empty-chat symptom in #212.

Will fix: #212 (the "some chats pop up empty" symptom is the dropped-DM case above).

Reactions pulled from iCloud carry Apple's "p:<part>/<guid>" form in
associatedMessageGuid, but locally reactions are linked by the bare
guid, so restored tapbacks never attached to their message. Strip the
prefix on sync and use the part number from it when present.

Cloud sync also routes DM messages by chatIdentifier, which chats
created live in the app never set. Set it at creation time, and when a
synced message still doesn't resolve, fall back to matching a DM by
participant address and then to the group id in proto4 before giving up.

A one-time repair on startup rewrites any already-stored prefixed
reaction guids, backfills chatIdentifier on existing DMs, and clears the
sync checkpoints so previously skipped messages get picked up on the
next pass.
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.

Syncing not working right

1 participant