sync: report live events when rooms enter the sliding window - #537
Open
basnijholt wants to merge 1 commit into
Open
sync: report live events when rooms enter the sliding window#537basnijholt wants to merge 1 commit into
basnijholt wants to merge 1 commit into
Conversation
jevolk
approved these changes
Aug 6, 2026
Member
|
Your fix landed on main rebased as 704b6c4 with your authorship intact, but a history rewrite on our side meant your branch head itself was never merged, so GitHub shows this stranded open. We would re-point the branch ourselves, but organization-owned forks do not accept maintainer pushes. If you force-push the landed commit onto this branch, GitHub should be able to record the pull request as merged: Thanks for the fix, and sorry for the dance. |
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 does this PR do?
I ran into this through MindRoom: agents would answer normally in active rooms, but could go completely silent in an idle room after it fell outside the current Sliding Sync list window. When a new message brought the room back into the window, Tuwunel returned it with
initial: truebut withoutnum_live. The client therefore treated the entire returned timeline as history, including the message that had just arrived.The regression and its client-visible effect are captured in mindroom-ai/mindroom#1785.
The issue is that Tuwunel currently uses
roomsince == 0both to mark a room response as initial and, indirectly, to skipnum_live. Those are not opposites in MSC4186: on an incremental connection, a room can enter the list window for the first time and contain both historical context and a live suffix.This changes the calculation to use the previous connection-wide sync position and the positions of the timeline events actually returned to the client. Event positions stay attached through ignored-user filtering and response construction, then
num_liveis the consecutive suffix whose positions are newer than the previous connection position.A few details matter here:
num_live.num_live: 0if nothing changed.num_live.posis snapshotted before long-polling, so an empty wake-up cannot move the comparison boundary.This is the server-side MSC4186 behavior; there is no MindRoom-specific or client-side heuristic in the change.
Regression tests cover the first response, a newly visible room with one live event, range expansion of an unchanged room, mixed historical/live timelines, and a truncated live timeline.
Verified on top of current
main:cargo +nightly fmt --all -- --checkcargo test --locked -p tuwunel_api client::sync::v5— 11 passedcargo clippy --locked --workspace --all-targets --all-features -- -D warningscargo test --locked --workspace --all-targets --all-features— 329 passed, 2 ignored; 6 state-resolution tests and the state-resolution benches also passComplement was not run locally. The change corrects Sliding Sync response semantics and should not affect non-Sliding Sync endpoints.
Checklist
cargo fmtand satisfies clippy and rustc lints; any allowed lint is justified by an obvious reason or a comment.