-
-
Notifications
You must be signed in to change notification settings - Fork 78
feat: add sliding sync (MSC4186) implementation #3673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pat-s
wants to merge
12
commits into
element-hq:main
Choose a base branch
from
pat-s:feat/sliding-sync
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
This commit adds native sliding sync support to Dendrite, implementing MSC4186 (Simplified Sliding Sync). Key features include: - New v4 sync endpoint at /_matrix/client/unstable/org.matrix.simplified_msc3575/sync - Sliding window room list with sorting and filtering - Room subscriptions for detailed room data - Extensions: to_device, e2ee, account_data, receipts, typing - Persistent connection state tracking - Support for lazy-loading room members - MSC3266 room summary endpoint - MSC4115 membership on events Also includes various fixes and improvements to existing sync functionality.
This commit includes several fixes for sliding sync receipt handling: - Clear receipt delivery state for specific rooms when timeline expansion is detected, ensuring receipts are re-delivered when the client resets its view of the room (initial:true with expanded_timeline:true) - Clear all connection receipts on fresh sliding sync connections - Copy-forward room configs to prevent perpetual limited:true state - Serialize m.read.private receipts under the correct type key - Extract invite_room_state from federated invite events properly - Populate timeline/state for NEVER rooms in incremental sync - Copy forward stream states for unchanged rooms in sliding sync These fixes address stuck unread badges in clients when rooms are entered/exited and timeline expansion occurs. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This should fix element-hq#3669 We'd potentially send an empty string to `GenerateCreateContent`, even if we set the correct `roomVersion` before. ### Pull Request Checklist <!-- Please read https://matrix-org.github.io/dendrite/development/contributing before submitting your pull request --> * [x] I have added Go unit tests or [Complement integration tests](https://github.com/matrix-org/complement) for this PR _or_ I have justified why this PR doesn't need tests * [x] Pull request includes a [sign off below](https://element-hq.github.io/dendrite/development/contributing#sign-off) _or_ I have already signed off privately --------- Signed-off-by: Till Faelligen <2353100+S7evinK@users.noreply.github.com>
This is to complement the existing [Purge Room Admin API](https://element-hq.github.io/dendrite/administration/adminapi#post-_dendriteadminpurgeroomroomid) ### Pull Request Checklist <!-- Please read https://matrix-org.github.io/dendrite/development/contributing before submitting your pull request --> * [x] I have added Go unit tests or [Complement integration tests](https://github.com/matrix-org/complement) for this PR _or_ I have justified why this PR doesn't need tests * [x] Pull request includes a [sign off below](https://element-hq.github.io/dendrite/development/contributing#sign-off) _or_ I have already signed off privately --------- Signed-off-by: Till Faelligen <2353100+S7evinK@users.noreply.github.com>
Add GetLatestRoomConfigsBatch method to query multiple room configs in a single database query instead of N+1 queries. PostgreSQL uses DISTINCT ON for efficient single-query operation. SQLite falls back to iterating through rooms (acceptable for smaller deployments).
Refactor timeline expansion detection to use single batch query instead of N+1 pattern when processing room subscriptions.
Create single database snapshot for all filter operations in ApplyRoomFilters instead of creating N snapshots per room. Add WithSnapshot variants of getRoomName, isRoomEncrypted, and getRoomType to reuse the shared snapshot.
Add processListsAndCollectRooms and populateRoomDataForLists helper functions to eliminate ~120 lines of duplicated code between timeout and disconnect handlers. The helpers handle: - Processing room lists and collecting rooms that need data - Building room data for rooms in list operations
Add efficient delta operations for sliding sync room lists per MSC4186: - INSERT: Add room at specific index - DELETE: Remove room at specific index Implementation: - Add GenerateListOperations() to compute minimal operations - Detect insertions/deletions and order changes - Fall back to SYNC when changes exceed threshold (5 ops) - Update room tracking to handle INSERT operations This reduces bandwidth for incremental syncs when only a few rooms have changed position in the list.
Add spaces filtering support per MSC4186: - Query m.space.child state events from specified space rooms - Filter room list to include only direct children of those spaces - Child rooms are identified by state_key of m.space.child events - Only include children with valid "via" content (not removed) This allows clients to request rooms belonging to specific spaces using the "spaces" filter parameter.
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.
This PR adds MSC4186, following the initial work by @jackmaninov from the discussion in #3236 (comment).
A image for testing is available at pats22/dendrite:sliding-sync.
I've used this image in an Dendrite instance of mine and got sliding sync to work, incl. Element X compatibility.
fix #3236
In addition to the work by @jackmaninov, several improvements to performance and maintainability were made:
Performance Improvements
Maintainability Improvements
Protocol Completeness
INSERT/DELETElist operations for efficient incremental updates (previously only SYNC was implemented)m.space.childstate events (previously returned an error)Technical Details
INSERT/DELETE Operations:
Spaces Filtering:
Pull Request Checklist
Signed-off-by:
Patrick Schratz <pat-s@mailbox.org>