Skip to content

feat: expose m.fully_read event ID on RoomInfo#6569

Merged
stefanceriu merged 3 commits into
matrix-org:mainfrom
danderson-cont:danderson-cont/expose-fully-read-event-id
May 20, 2026
Merged

feat: expose m.fully_read event ID on RoomInfo#6569
stefanceriu merged 3 commits into
matrix-org:mainfrom
danderson-cont:danderson-cont/expose-fully-read-event-id

Conversation

@danderson-cont
Copy link
Copy Markdown
Contributor

@danderson-cont danderson-cont commented May 13, 2026

Exposes the m.fully_read event ID on RoomInfo for clients' "jump-to-unread" button

See element-hq/element-x-ios#4766

  • I've documented the public API Changes in the appropriate CHANGELOG.md files.
  • This PR was made with the help of AI.

Signed-off-by: Daniel Anderson daniel.anderson@toptal.com

@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

❌ Patch coverage is 95.72650% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.94%. Comparing base (4a26af8) to head (703da91).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
crates/matrix-sdk-base/src/sliding_sync.rs 93.97% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6569      +/-   ##
==========================================
- Coverage   89.95%   89.94%   -0.01%     
==========================================
  Files         382      382              
  Lines      107797   107914     +117     
  Branches   107797   107914     +117     
==========================================
+ Hits        96964    97066     +102     
- Misses       7165     7180      +15     
  Partials     3668     3668              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 13, 2026

Merging this PR will not alter performance

✅ 50 untouched benchmarks


Comparing danderson-cont:danderson-cont/expose-fully-read-event-id (703da91) with main (4a26af8)

Open in CodSpeed

Comment on lines +88 to +93
AnyRoomAccountDataEvent::FullyRead(_) => {
context
.room_info_notable_updates
.entry(room_id.to_owned())
.or_default()
.insert(RoomInfoNotableUpdateReasons::READ_RECEIPT);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fully read marker isn't a read receipt, is it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. I've added a new flag FULLY_READ, which required switching the field from a u8 to u16

Comment thread crates/matrix-sdk-base/src/response_processors/account_data/room.rs Outdated
Comment thread bindings/matrix-sdk-ffi/src/room/room_info.rs Outdated
Copy link
Copy Markdown
Member

@Hywan Hywan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,

Thank you for your contribution.

First and foremost, did you read our AI policy? I'm almost certain that this PR has been vibe-coded.

Second, the pull request template asks a couple of questions that you've apparently erased, so I'm copying them here:

<!-- description of the changes in this PR -->

- [ ] I've documented the public API Changes in the appropriate `CHANGELOG.md` files.
- [ ] This PR was made with the help of AI.

<!-- Sign-off, if not part of the commits -->
<!-- See CONTRIBUTING.md if you don't know what this is -->
Signed-off-by: 

About the code now: please can you add tests for the new feature?

Comment thread bindings/matrix-sdk-ffi/src/room/room_info.rs
.room_info_notable_updates
.entry(room_id.to_owned())
.or_default()
.insert(RoomInfoNotableUpdateReasons::READ_RECEIPT);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test to ensure the notable update reasons is emitted as expected.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a test

@stefanceriu
Copy link
Copy Markdown
Member

Thanks for looking into this 🙏
I left some comments inline but a couple more general notes:

  • the description is super long but the commits themselves have close to no info. Let the code and git history talk not the PR, it easier on everybody
  • please link a final client/meta issue if possible. For this kind of feature there most likely is one
  • there's formatting errors that need fixing, which is fine but there's a lot of checks on the CI and you probably want to start with a draft PR to avoid notifying everybody fixing them
  • the FFI layer is supposed to only be used for converting the data types and it shouldn't have business logic in it

@danderson-cont
Copy link
Copy Markdown
Contributor Author

@stefanceriu @Hywan
Could you chime in on the "Open question for reviewers"

I can shorten it for you here:
The "mark as read" button in the UI takes too long to propagate it's effect for the iOS UI.

This can be fixed in iOS or on the SDK side (optimistic write). Which would you prefer?

@stefanceriu
Copy link
Copy Markdown
Member

I can shorten it for you here: The "mark as read" button in the UI takes too long to propagate it's effect for the iOS UI.

This can be fixed in iOS or on the SDK side (optimistic write). Which would you prefer?

Why is that a concern for this PR? Do we even have UI anywhere that requires this to be fast? As a paralel manually marking rooms as unread/read seems fine even without "local echoes".

@danderson-cont danderson-cont marked this pull request as draft May 13, 2026 17:18
@danderson-cont danderson-cont force-pushed the danderson-cont/expose-fully-read-event-id branch 2 times, most recently from 60d7404 to 4fcd2cd Compare May 13, 2026 20:14
@danderson-cont
Copy link
Copy Markdown
Contributor Author

I can shorten it for you here: The "mark as read" button in the UI takes too long to propagate it's effect for the iOS UI.
This can be fixed in iOS or on the SDK side (optimistic write). Which would you prefer?

Why is that a concern for this PR? Do we even have UI anywhere that requires this to be fast? As a paralel manually marking rooms as unread/read seems fine even without "local echoes".

Agreed, out of scope. Dropping it from the PR description.

@stefanceriu stefanceriu marked this pull request as ready for review May 14, 2026 06:29
@stefanceriu
Copy link
Copy Markdown
Member

Looks good to me now but I'll let Ivan have the final say as he was the original reviewer.

Comment thread bindings/matrix-sdk-ffi/CHANGELOG.md Outdated
Comment on lines +9 to +13
### Features

- Add `RoomInfo::fully_read_event_id` to expose the user's `m.fully_read` event ID.
([#6569](https://github.com/matrix-org/matrix-rust-sdk/pull/6569))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We switched to a towncrier-based setup for changelogs. Sorry for the inconvenience but please move this to the changelog.d folder as a Towncrier fragment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@poljar Okay I've made these changes

Comment thread crates/matrix-sdk-base/CHANGELOG.md Outdated
Comment on lines +15 to +20
- [**breaking**] `RoomInfoNotableUpdateReasons` is now a `u16` to include a `FULLY_READ` flag to notify on changes of the `m.fully_read` marker.
([#6569](https://github.com/matrix-org/matrix-rust-sdk/pull/6569))

- Add `RoomInfo::fully_read_event_id` and `Room::fully_read_event_id` to expose the user's `m.fully_read` event ID.
([#6569](https://github.com/matrix-org/matrix-rust-sdk/pull/6569))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for those changelog entries.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@poljar done

@danderson-cont danderson-cont force-pushed the danderson-cont/expose-fully-read-event-id branch from 4fcd2cd to d82786c Compare May 14, 2026 16:31
@danderson-cont danderson-cont requested a review from poljar May 14, 2026 16:48
@danderson-cont
Copy link
Copy Markdown
Contributor Author

Seems like the fixup thing is intended while in progress, and will go away when the commits are squashed. The rust tests failed on setup?

Copy link
Copy Markdown
Member

@Hywan Hywan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! It looks much better.

Can you rebase all your fixup commits please?

@@ -0,0 +1 @@
- Add `RoomInfo::fully_read_event_id` and `Room::fully_read_event_id` to expose the user's `m.fully_read` event ID.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Add `RoomInfo::fully_read_event_id` and `Room::fully_read_event_id` to expose the user's `m.fully_read` event ID.
Add `RoomInfo::fully_read_event_id` and `Room::fully_read_event_id` to expose the user's `m.fully_read` event ID.

The format defined in the CONTRIBUTING.md file was incorrect. I've fixed it, sowwy for the inconvenience.

@@ -0,0 +1 @@
- [**breaking**] `RoomInfoNotableUpdateReasons` is now a `u16` to include a `FULLY_READ` flag to notify on changes of the `m.fully_read` marker.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [**breaking**] `RoomInfoNotableUpdateReasons` is now a `u16` to include a `FULLY_READ` flag to notify on changes of the `m.fully_read` marker.
[**breaking**] `RoomInfoNotableUpdateReasons` is now a `u16` to include a `FULLY_READ` flag to notify on changes of the `m.fully_read` marker.

/// Ultimately, we want to clearly identify all the notable update reasons, and
/// remove this one.
const NONE = 0b1000_0000;
const NONE = 0b0000_0000_1000_0000;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be a good idea to use 0b1000_0000_0000_0000 for NONE, but not mandatory. Do it if you find the motivation, but not necessary here.

);
assert!(room_info_notable_update_stream.is_empty());

// …Unless the event id changes!
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking:

Suggested change
// …Unless the event id changes!
// … Unless the event ID changes!

Add `RoomInfoNotableUpdateReasons::FULLY_READ`, used for
when the `m.fully_read` marker for a room changes.

Breaking change: the backing bitflag widens from `u8` to `u16`
for the new flag to not alter the existing bit positions.

Signed-off-by: Daniel Anderson <daniel.anderson@toptal.com>
Persist `m.fully_read` on `BaseRoomInfo` and expose it
on `RoomInfo::fully_read_event_id` and `Room::fully_read_event_id`.

The `m.fully_read` response processor now stores the event ID
on the room info and emits `RoomInfoNotableUpdateReasons::FULLY_READ`

Signed-off-by: Daniel Anderson <daniel.anderson@toptal.com>
`m.fully_read` is now available on the FFI `RoomInfo` record

Signed-off-by: Daniel Anderson <daniel.anderson@toptal.com>
@danderson-cont danderson-cont force-pushed the danderson-cont/expose-fully-read-event-id branch from d82786c to 703da91 Compare May 19, 2026 17:32
@danderson-cont
Copy link
Copy Markdown
Contributor Author

Rebased the fixups into the three feature commits, dropped the leading - from the changelog fragments (including the FFI one), and fixed the test comment. Skipped the NONE bit-position move since you marked it optional.

Copy link
Copy Markdown
Member

@stefanceriu stefanceriu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alrighty, I think this one's good to go now, thank you for taking care of it! 👍

@stefanceriu stefanceriu merged commit 10c0a86 into matrix-org:main May 20, 2026
60 of 61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants