fix: relay confirmation before merge and welcome (MIP-02/MIP-03)#46
Open
alltheseas wants to merge 1 commit intoVectorPrivacy:masterfrom
Open
fix: relay confirmation before merge and welcome (MIP-02/MIP-03)#46alltheseas wants to merge 1 commit intoVectorPrivacy:masterfrom
alltheseas wants to merge 1 commit intoVectorPrivacy:masterfrom
Conversation
Rewrite add_member_device and remove_member_device to defer
merge_pending_commit until after relay confirmation, matching
MDK's documented ordering requirement.
Before: merge locally → fire-and-forget publish → send welcomes
After: create commit → return immediately → background: relay
publish with retries → merge → send welcomes → UI update
The Tauri command returns immediately (no UX blocking). A new
publish_event_with_retries helper provides 5-attempt exponential
backoff matching pika core's pattern.
This prevents permanent group state divergence when all relays
reject the commit, and ensures welcomes reference a commit that
is actually available on relays (MIP-02).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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 this fixes
When you add someone to a group chat, Vector immediately updates its own local state as if everything worked — then tries to tell the relay network about it in the background with no retries. If the relay is down or rejects the message, the person you invited never gets their welcome message, and your group is now permanently broken. Messages you send won't decrypt for other members. The only fix is to create a new group.
After this fix, when you add someone to a group chat, the button clears instantly (no change in feel). Behind the scenes, Vector now waits for at least one relay to confirm it received the group update before finalizing. Only then does it send the welcome to the invited person. If all relays are down, nothing changes locally — your group stays in a working state and you can try again later.
Same thing for removing someone from a group.
Technical details
merge_pending_commituntil relay confirmation:add_member_deviceandremove_member_deviceno longer merge the pending commit before publishing. Instead, the commit is created, and a background task handles relay publish → merge → welcome delivery in the correct order.publish_event_with_retrieshelper: 5-attempt exponential backoff (250ms base) matching pika core's pattern, with NIP-42 auth retry handling.Before:
After:
merge_pending_commitdocstring says "This should be called AFTER publishing the Kind:445 message"Test plan
cargo checkinsrc-tauri/🤖 Generated with Claude Code