Skip to content

feat: Expose homeserver capabilities - #6371

Merged
jmartinesp merged 1 commit into
mainfrom
feat/homeserver-capabilities
Mar 31, 2026
Merged

jmartinesp merged 1 commit into
mainfrom
feat/homeserver-capabilities

Conversation

@jmartinesp

@jmartinesp jmartinesp commented Mar 30, 2026 •

Copy link
Copy Markdown
Contributor

Implements #6379.

This creates a new HomeserverCapabilities wrapper that handles the fetching, caching, loading cached values and refreshing them, also giving you a method to check every capability.

This wrapper is also exposed in the FFI layer so clients using the bindings can use them.

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

@codspeed

codspeed Bot commented Mar 30, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 49.78%

❌ 1 regressed benchmark
✅ 49 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Simulation Restore session [memory store] 112.1 ms 223.3 ms -49.78%

Comparing feat/homeserver-capabilities (7fda103) with main (ca91b6a)

Open in CodSpeed

@jmartinesp
jmartinesp force-pushed the feat/homeserver-capabilities branch from 9e1e6c9 to e7f4923 Compare March 30, 2026 11:30
@codecov

codecov Bot commented Mar 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 67.09677% with 51 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.82%. Comparing base (ca91b6a) to head (7fda103).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...s/matrix-sdk/src/client/homeserver_capabilities.rs 67.66% 37 Missing and 6 partials ⚠️
crates/matrix-sdk/src/event_handler/mod.rs 0.00% 0 Missing and 5 partials ⚠️
crates/matrix-sdk-sqlite/src/state_store.rs 0.00% 2 Missing ⚠️
crates/matrix-sdk-base/src/store/traits.rs 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6371      +/-   ##
==========================================
- Coverage   89.85%   89.82%   -0.03%     
==========================================
  Files         376      377       +1     
  Lines      103102   103253     +151     
  Branches   103102   103253     +151     
==========================================
+ Hits        92644    92749     +105     
- Misses       6889     6917      +28     
- Partials     3569     3587      +18     

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

@jmartinesp
jmartinesp force-pushed the feat/homeserver-capabilities branch 2 times, most recently from a8d412a to 92ec293 Compare March 31, 2026 06:59
@jmartinesp
jmartinesp marked this pull request as ready for review March 31, 2026 07:00
@jmartinesp
jmartinesp requested a review from a team as a code owner March 31, 2026 07:00
@jmartinesp
jmartinesp requested review from Hywan and removed request for a team March 31, 2026 07:00
Comment on lines +27 to +31
/// Forces a refresh of the cached value using the `/capabilities` endpoint.
pub async fn refresh(&self) -> crate::Result<()> {
self.get_and_cache_remote_capabilities().await?;
Ok(())
}

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.

Instead of adding a TtlCache or some other wrapper, that has proven problematic in the past, I thought we may want to just add a method we can call whenever we think these values should be reloaded, and we can decide when that time is best in the implementing clients.

@Hywan Hywan left a comment

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.

It looks great! Thank you! I've added a couple of feedback but no blocker.

Comment thread bindings/matrix-sdk-ffi/src/client.rs Outdated
.allowed
.unwrap_or_default()
.into_iter()
.map(|f| f.to_string())

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.

.map(ToString::to_string) should work too.

@jmartinesp jmartinesp Mar 31, 2026 •

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.

Ah, it does work if I use .iter() instead of .into_iter(). I tried using .map(ToString::to_string) at first and I didn't understand the error message (which I now realised was 'this expects a reference, not an owned value').

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.

Comment thread bindings/matrix-sdk-ffi/src/client.rs Outdated
.disallowed
.unwrap_or_default()
.into_iter()
.map(|f| f.to_string())

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.

.map(ToString::to_string) should work too.

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.

Comment thread crates/matrix-sdk/src/client/homeserver_capabilities.rs
Comment thread crates/matrix-sdk/src/client/homeserver_capabilities.rs
@jmartinesp

Copy link
Copy Markdown
Contributor Author

I've added a couple of feedback but no blocker.

Does this mean the PR should be approved? 😅

@jmartinesp
jmartinesp requested a review from Hywan March 31, 2026 12:54
This extracts the `/capabilities` logic to its own `HomeserverCapabilities` component in the SDK that can be manually asked to fetch, cache locally and return these capabilities.
@jmartinesp
jmartinesp force-pushed the feat/homeserver-capabilities branch from 895d20a to 7fda103 Compare March 31, 2026 12:59
@jmartinesp
jmartinesp merged commit 5d2eab1 into main Mar 31, 2026
58 of 60 checks passed
@jmartinesp
jmartinesp deleted the feat/homeserver-capabilities branch March 31, 2026 13:25
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.

Task: expose homeserver capabilities

2 participants