Repository navigation
Leave a line for apps from before MLS (GRYT-1508) - #244
Merged
Merged
Conversation
An MLS message never reached the messages table, so an app from before stage 1 got nothing for it. Now each application message sent with mls:send also writes a system line into the DM: "@kari sent an end-to-end encrypted message. Update Gryt to read it." The row carries mls_placeholder { seq, sender_server_id }, and apps that read MLS hide it. It's a system line because desktop 1.11.46 puts a red "Not encrypted" mark on any plain DM message, right next to text saying it was encrypted. System rows don't get the mark. A client passes placeholder: false for application messages that aren't a message, like reactions, edits and deletes. The sender's own sockets don't get the line live, a block hides it in history, and hasWrittenTo counts it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
What an old app shows
On desktop, checked on the web build of client 1.11.46 (9073ec7) against a server from this branch on :5003. A script sent an MLS message as Alice to a guest. The DM showed a quiet system row: the sign-in arrow, an @alice mention pill, then "sent an end-to-end encrypted message. Update Gryt to read it." and the time. The row had no "Not encrypted" mark, live or after a reload, and the DM icon got its unread 1.
On the phone (353440b, the build that went with 1.11.46), from reading the code rather than running it: a row headed "System" saying "@alice sent an end-to-end encrypted message. Update Gryt to read it." The phone skips system messages for its unread pill and its toast, so an old phone gets no nudge. The line is there when you open the DM.
Why a system line
A plain line from the sender reads worse on desktop.
ChatViewpassesunencrypted={conversationKind === "dm" && !m.sealed}, so the row would get a red edge and a "Not encrypted" chip right next to text saying it was encrypted. A sealed envelope nobody can open shows "This message could not be opened.", which gives no hint to update. And a system line doesn't put words in the sender's mouth, which also means their old app can't edit it.The marker
These rows carry
mls_placeholder: { seq, sender_server_id }, live inchat:newand in history.seqis the MLS log entry the line stands in for. An app that reads MLS drops any row that has it. Everything else about the row is an ordinary system message:sender_server_idis"system"andsealedis null.Unread counts and history
Both count MLS messages, through the line. The server keeps no unread counts, and apps count
chat:new, so an old app counts the line like any other message. REST history andchat:fetchreturn it too. An app that reads MLS drops the line and countsmls:messageinstead. So an old app sees one new row per message, and a new app has one rule: skipmls_placeholder. Doing that in the apps is GRYT-1517.What to look at
messages.mls_seqandmessages.mls_sender_server_id, NULL on every other row.mls_sender_server_idis inAUTHOR_COLUMNS, so a guest merge moves it.mls:sendtakesplaceholder: falsefor application messages a person doesn't read as a message: reactions, edits, deletes. Without it an old app shows a line for every reaction. It does tell the server which application messages are messages. Section 8 of the design already has the server counting messages, so it learns little new, but it's still metadata MLS would otherwise hide."system", a desktop would otherwise notify you about your own message.chat:fetchhides a line whose real sender you blocked, and the live line skips anybody who blocked them.hasWrittenTocounts the line, so contact settings and the friends fallback see MLS messages. Without that, somebody who only allows people they've written to could never get a reply to an MLS message.Tests
In
mls.test.ts: the other side gets the line as a system message with the marker, the sender doesn't, it's stored with its seq, andhasWrittenTosees it.placeholder: falseleaves no line and anything but a boolean is refused. A blocked sender's line is held back live and left out ofchat:fetch. Full suite: 1756 pass.Task: GRYT-1508. Docs: Gryt-chat/docs#141.
🤖 Generated with Claude Code