Conversation
Owner
Messages the user sends from another device are synced to chat.db without a sender handle, so until now most of the user's own messages came back with sender "me" and nothing to tie them to a conversation; a client could not thread them or tell who they were sent to. Each message now carries an "isPartOf" Conversation with the chat identifier, its display name (group chats) and its participants. Chats are looked up once per call and shared by their messages. Relies on Message.chatID and ChatPredicate.id from Madrid 0.5.0 (mattt/Madrid#18), which the project already depends on. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WYn7auXKTFrqS1PSR6rQKn
patp
force-pushed
the
messages-conversation
branch
from
September 4, 2026 02:05
092ba26 to
5bb2f72
Compare
patp
marked this pull request as ready for review
September 4, 2026 02:05
Contributor
Author
|
Rebased onto |
Owner
Owner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on Madrid 0.5.0 (mattt/Madrid#18), which
mainpins since #201. Rebased ontomainon 2026-09-03: the branch no longer touches the package pin, and the change sits on top of theFetchRequest<Message>adoption and theisReadoutput.Problem
Messages you send from another device (iPhone, iPad) are synced to
chat.dbwithout a sender handle (message.handle_id = 0). Todaymessages_fetchreturns them assender: "me"with nothing that ties them to a conversation, so a client cannot tell who they were sent to, cannot thread them, and cannot even filter for them byparticipants(on my database that is 1 660 of my 2 610 messages over six months — everything typed on the phone). Group messages have the same problem: an inbound group message looks exactly like a 1:1 message from that person.Change
Each message now names the conversation it belongs to, as a schema.org
isPartOf:{ "@id": "8B9C…", "sender": { "@id": "me" }, "text": "On my way", "createdAt": "2026-09-01T17:02:03Z", "isRead": true, "isPartOf": { "@type": "Conversation", "@id": "iMessage;-;+18002752273", "participant": [ { "@id": "+18002752273" } ] } }@idis the chat GUID (iMessage;-;<handle>for a 1:1,iMessage;+;chat…for a group);nameis present for named group chats;participantlists the other parties' handles.FetchRequest<Chat>withChatPredicate.id), so the extra cost is one small query per distinct conversation.chat_message_joinrow (rare) simply has noisPartOf.participants: [handle]also returns the messages you sent in chats that include that handle, which is what a caller asking for a conversation with someone expects;isPartOfis what lets the caller thread those messages.@context,@type: Conversation,hasPart) is unchanged, so existing clients keep working.Checks
swift format lint --strict --recursive App CLIclean.chat.dbbehind a sync client: every message that has a chat carriesisPartOf, phone-sent messages included.