Skip to content

feat: compute and cache RoomInfo::active_service_members#6537

Open
jmartinesp wants to merge 13 commits intomainfrom
feat/cache-active-service-member-count-in-room-info
Open

feat: compute and cache RoomInfo::active_service_members#6537
jmartinesp wants to merge 13 commits intomainfrom
feat/cache-active-service-member-count-in-room-info

Conversation

@jmartinesp
Copy link
Copy Markdown
Contributor

@jmartinesp jmartinesp commented May 5, 2026

Changes

  • Add a new RoomSummary::active_room_members field that will be used as a cache.
  • Rename Room::active_service_members to Room::update_active_service_members, which will compute new values for the cache.
  • Also reset this cached value when the member counts change in sync responses.
  • Rename async fn Room::is_dm to Room::compute_is_dm and also trigger Room::update_active_service_members to re-calculate the cache.
  • Add a new synchronous Room::is_dm function that will use the cached active_service_members value or calculate an approximate value as a fallback.
  • Then expose this Room::compute_is_dm and Room::is_dm in RoomInfo, NotificationRoomInfo and SpaceRoom.

Motivation

For both the room list filtering and the SpaceRoom instances we can't rely on an accurate value computed in place, since those APIs are synchronous. The approximate value previously calculated could be wrong in several cases, so if we can compute a better one instead that should make the checks more accurate.

  • 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:

@jmartinesp jmartinesp force-pushed the feat/cache-active-service-member-count-in-room-info branch from 45f313e to 88a8cc5 Compare May 5, 2026 10:17
@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

❌ Patch coverage is 87.69231% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.91%. Comparing base (8b13e48) to head (20a48b4).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
crates/matrix-sdk-base/src/room/mod.rs 62.06% 8 Missing and 3 partials ⚠️
crates/matrix-sdk-base/src/room/room_info.rs 96.62% 3 Missing ⚠️
crates/matrix-sdk/src/room/mod.rs 84.21% 0 Missing and 3 partials ⚠️
crates/matrix-sdk-ui/src/notification_client.rs 0.00% 0 Missing and 2 partials ⚠️
crates/matrix-sdk-ui/src/spaces/room.rs 33.33% 0 Missing and 2 partials ⚠️
crates/matrix-sdk/src/message_search.rs 0.00% 0 Missing and 2 partials ⚠️
...x-sdk-ui/src/room_list_service/filters/category.rs 98.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6537      +/-   ##
==========================================
- Coverage   89.91%   89.91%   -0.01%     
==========================================
  Files         381      381              
  Lines      105914   106006      +92     
  Branches   105914   106006      +92     
==========================================
+ Hits        95237    95315      +78     
- Misses       7028     7038      +10     
- Partials     3649     3653       +4     

☔ 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 5, 2026

Merging this PR will not alter performance

✅ 50 untouched benchmarks


Comparing feat/cache-active-service-member-count-in-room-info (20a48b4) with main (2ec031b)

Open in CodSpeed

jmartinesp added 10 commits May 5, 2026 13:13
This will be used as a cache for the computed value.
…active_service_members`

The function will now store the computed value if it changed into the `RoomSummary` cache
…ing the room members of the room or when inviting someone
…the joined/invited user count or the heroes in a room change
This function will now also compute and store the active service members under the hood
This function will check the cached value and use it if available, falling back to using an approximate value that will be calculated synchronously if not.
Based on the cached and synchronous `Room::is_dm`
@jmartinesp jmartinesp force-pushed the feat/cache-active-service-member-count-in-room-info branch from 88a8cc5 to 1d7af29 Compare May 5, 2026 11:15
@jmartinesp jmartinesp force-pushed the feat/cache-active-service-member-count-in-room-info branch from 51c245a to 1a6b534 Compare May 5, 2026 11:53
@jmartinesp jmartinesp changed the title WIP: compute and cache RoomInfo::active_service_members feat: compute and cache RoomInfo::active_service_members May 5, 2026
@jmartinesp jmartinesp marked this pull request as ready for review May 5, 2026 12:01
@jmartinesp jmartinesp requested a review from a team as a code owner May 5, 2026 12:01
@jmartinesp jmartinesp requested review from poljar and removed request for a team May 5, 2026 12:01
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.

1 participant