Skip to content

feat(wasm): add feature support for indexedb and sqlite to matrix-sdk-ffi #5245

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
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

zzorba
Copy link
Contributor

@zzorba zzorba commented Jun 18, 2025

Expose a choice of session storage in the matrix-sdk-ffi crate. The initial choices are Sqlite (supported on non-Wasm platforms) and IndexedDb (Wasm only). It was agreed though that feature flags make more sense here, and make the code more maintainable.

The existing bundled-sqlite is setup to opt-in sqlite, however several methods for configuring a Sqlite store have been moved onto a sub-builder for organizational reasons.

This PR is stacked on top of https://github.com/matrix-org/matrix-rust-sdk/pull/5211/files, I will rebase it against main when that has landed.

Corresponding PR for complement-crypto: matrix-org/complement-crypto#195

  • Public API changes documented in changelogs (optional)

Signed-off-by: Daniel Salinas

@zzorba zzorba changed the title Wasm indexedb and sqlite feat(wasm): add feature support for indexedb and sqlite to matrix-sdk-ffi Jun 18, 2025
@zzorba zzorba marked this pull request as ready for review June 18, 2025 15:14
@zzorba zzorba requested a review from a team as a code owner June 18, 2025 15:14
@zzorba zzorba requested review from poljar and removed request for a team June 18, 2025 15:14
@Hywan
Copy link
Member

Hywan commented Jun 18, 2025

Waiting on #5211 to be merged before reviewing this one.

@zzorba
Copy link
Contributor Author

zzorba commented Jun 18, 2025

Would be nice to get opinions on the new session_store and client_builder changes. Those are wholly new, and structural feedback would be very welcome

@poljar
Copy link
Contributor

poljar commented Jun 19, 2025

Can this one be rebased as well?

@zzorba zzorba force-pushed the wasm_indexedb_and_sqlite branch from eacaec7 to f431d9a Compare June 19, 2025 22:17
@zzorba
Copy link
Contributor Author

zzorba commented Jun 19, 2025

Yep, rebased it to adopt the Cargo.toml changes. This PR now concerns only the configuration of the session store.

Let me know if a different approach would be preferred here, adding sub-builders seemed more self-documenting than having a large number of 'optional' methods on the main builder, but happy to do it a different way if you prefer.

Copy link

codecov bot commented Jun 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.18%. Comparing base (08e1d38) to head (5c93af9).
Report is 22 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5245   +/-   ##
=======================================
  Coverage   90.18%   90.18%           
=======================================
  Files         334      334           
  Lines      104822   104822           
  Branches   104822   104822           
=======================================
+ Hits        94534    94538    +4     
+ Misses       6236     6232    -4     
  Partials     4052     4052           

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

@zzorba
Copy link
Contributor Author

zzorba commented Jun 20, 2025

Here is a corresponding complement-crypto PR: matrix-org/complement-crypto#195

@zzorba zzorba force-pushed the wasm_indexedb_and_sqlite branch from 7ac8f7c to 474eb29 Compare June 20, 2025 14:12
@zzorba zzorba force-pushed the wasm_indexedb_and_sqlite branch from 474eb29 to fe98e31 Compare June 20, 2025 14:15
Copy link
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 for the patches. The general idea is good, but the patches deserve more work.

@@ -231,7 +231,7 @@ fn check_clippy() -> Result<()> {
"rustup run {NIGHTLY} cargo clippy --workspace --all-targets
--exclude matrix-sdk-crypto --exclude xtask
--no-default-features
--features native-tls,sso-login,testing
--features native-tls,sso-login,sqlite,testing
Copy link
Member

Choose a reason for hiding this comment

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

The same patch is mixing two things. Proof is your commit message contains “and”.

Please split this patch into two.

Copy link
Member

Choose a reason for hiding this comment

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

By the way, this change should be a fixup of the patch introducing the sqlite feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is not mixing two different things, it is adding support for indexedb which requires parameterizing the sqlite configuration. I do not believe these are separable changes.

@@ -55,15 +55,15 @@ mod sqlite_session_store {
/// capable of handling multiple users, however it is valid to use the
/// same path for both stores on a single session.
#[uniffi::constructor]
pub fn new(data_path: String, cache_path: String) -> Self {
Self {
pub fn new(data_path: String, cache_path: String) -> Arc<Self> {
Copy link
Member

Choose a reason for hiding this comment

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

Why?

It should be a fixup patch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know what that means. What is a fixup patch?

Copy link
Member

Choose a reason for hiding this comment

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

A fixup patch is a patch that is “melt”/“merged” with another one so that we end up with a single patch, see https://git-scm.com/docs/git-rebase.

Copy link
Contributor

Choose a reason for hiding this comment

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

Comment on lines +185 to +189
use std::sync::Arc;

use super::SessionStoreResult;
use crate::{client_builder::ClientBuildError, helpers::unwrap_or_clone_arc};

Copy link
Member

Choose a reason for hiding this comment

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

A fixup patch.

@Hywan Hywan self-assigned this Jun 23, 2025
@Hywan Hywan removed the request for review from poljar June 23, 2025 09:34
zzorba and others added 2 commits June 23, 2025 10:30
Co-authored-by: Ivan Enderlin <[email protected]>
Signed-off-by: Daniel Salinas <[email protected]>
Co-authored-by: Ivan Enderlin <[email protected]>
Signed-off-by: Daniel Salinas <[email protected]>
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