Commit Graph

14300 Commits

Author SHA1 Message Date
Ivan Enderlin
203a3783ae feat(sdk): Support m.room.membership with membership: "invite" as latest event. 2025-10-03 11:26:45 +02:00
Ivan Enderlin
8eb7264e5d test(sdk): Test that m.room.member for an invite can be a latest event candidate. 2025-10-03 11:26:45 +02:00
Kévin Commaille
a4bd36cbe8 fix(ci): Fix cargo-codspeed command
A new release occurred which has a breaking change in the syntax used to
select a benchmark.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-10-02 21:33:24 +02:00
Stefan Ceriu
8e8ad0167a change(spaces): return a reference to the rooms vector from the leave handle
well now
2025-10-02 12:41:42 +03:00
Stefan Ceriu
0f78959c9a change(spaces): compute LeaveSpaceRooms for the LeaveSpaceHandle asynchronously in its constructor 2025-10-02 12:41:42 +03:00
Stefan Ceriu
7a431a3afd change(spaces): have the leave space rooms interface take a filter
This helps make sure the rooms to be left were actually part of the space graph as they are stored inside the `LeaveRoomHandle` and filtered from there. On the FFI layer on the other hand, we still take plain strings as working around the limitations would've significantly complicated things.
2025-10-02 12:41:42 +03:00
Stefan Ceriu
a6d033ea4c chore(spaces): move joined_rooms and the SpaceGraph underneath the same Arc Mutex 2025-10-02 12:41:42 +03:00
Stefan Ceriu
ad41cbc368 chore(spaces): remove unused Unknown Space Error variant 2025-10-02 12:41:42 +03:00
Stefan Ceriu
cf0c3e7009 chore(spaces): move the LeaveSpaceRoom struct to the top of the file 2025-10-02 12:41:42 +03:00
Stefan Ceriu
3a60d34f3f feat(ffi): expose the space service leaving interfaces
fix newline ffi
2025-10-02 12:41:42 +03:00
Stefan Ceriu
9114c22b70 feat(spaces): add mechanism for _ordely_ leaving a space and its children
When leaving a space the user should be informed of which rooms are DMs (already part of the `SpaceRoom`)
and in which they might be the last admin, where leaving would prevent anybody else for taking control.
2025-10-02 12:41:42 +03:00
Stefan Ceriu
8655afd117 chore(spaces): store the built space graph in between the various updates so it can be used for leaving spaces 2025-10-02 12:41:42 +03:00
Stefan Ceriu
f5ec9b6427 feat(spaces): add graph method for retrieving a flat list of nodes belonging to a subtree ordered in bottom up dfs visiting order. 2025-10-02 12:41:42 +03:00
Ivan Enderlin
2eab7cf818 fix(ui): RoomListItem refreshes its cache_is_space. 2025-10-02 09:45:14 +02:00
Kévin Commaille
6072618e85 Add changelog for caption change
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-10-02 08:15:56 +02:00
Kévin Commaille
70b19cc907 refactor(sdk): Use TextMessageEventContent to send a caption
It doesn't make sense to send a formatted caption without a plain text
caption so using TextMessageEventContent forces the latter to be present.

This also allows to use the helpful constructors of
TextMessageEventContent.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-10-02 08:15:56 +02:00
Hubert Chathi
57d21ccdf6 Create a separate error variant to indicate a failure importing a secret. (#5647)
Part of the fix to
https://github.com/element-hq/element-x-android/issues/5099

Allows applications to distinguish between errors that occur when
unlocking Secret Storage, or errors that occur when importing a secret,
so that they can display appropriate feedback (or not) to the user.

- [ ] Public API changes documented in changelogs (optional)

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

---------

Signed-off-by: Hubert Chathi <hubertc@matrix.org>
2025-10-02 08:14:46 +02:00
Benjamin Bouvier
37ee5d5075 refactor(stores): get rid of the temporary compute_filter_strings now that Ruma has been updated
This was a local fix for a bug in Ruma, that has been fixed upstream since then, so we can get rid of the workaround now.
2025-10-01 16:50:23 +00:00
Benjamin Bouvier
681b22142f refactor(timeline): add more logs when we couldn't create an embedded event
This should help figuring out why some thread's latest replies are
marked as "unsupported events".
2025-10-01 10:54:00 +02:00
Benjamin Bouvier
248d77a4d9 refactor(ffi): add debug logging when a latest event is not a standalone content item 2025-10-01 10:54:00 +02:00
Benjamin Bouvier
f4451b5c82 refactor(timeline): TimelineAction::from_content always returns Something now 2025-10-01 10:54:00 +02:00
Mathieu Velten
59b7da247c Add some doc to add_event_handler for invites and stripped state (#5705)
Signed-off-by: Mathieu Velten <mathieu@velten.xyz>
Co-authored-by: Damir Jelić <poljar@termina.org.uk>
2025-09-30 14:25:17 +00:00
Benjamin Bouvier
be5bd449b5 test(timeline): ensure unthreaded receipts are loaded in the main timeline view mode 2025-09-30 15:09:57 +02:00
Benjamin Bouvier
2eb29518dc refactor(timeline): no need to look at the receipt timestamp
I was wrong in a previous commit: both receipts are on the same event
anyways, so we can safely override the keys in the read receipts map
(overriding would mean both receipts point to the same event, which is
fine, as we're displaying only one of those).
2025-09-30 15:09:57 +02:00
Benjamin Bouvier
16d0840115 refactor(timeline): move code around for loading initial main|unthreaded receipts 2025-09-30 15:09:57 +02:00
Benjamin Bouvier
d90576bf0d fix(timeline): when loading initial receipts for main|unthreaded, load both kinds
This is a fix, because some other code elsewhere will use both kinds of
receipts whenever they're received over sync. The code that's modified
in this patch is called for the initial load of receipts, that happens
whenever we see a new event. Since the two code paths were not doing the
same thing, this would affect the displayed receipts, depending on
whether we received them during sync, or after loading the timeline for
the first time.
2025-09-30 15:09:57 +02:00
Benjamin Bouvier
bbeb2d21b1 refactor(timeline): slightly rearrange code so as to remove a dubious comment 2025-09-30 14:29:27 +02:00
Benjamin Bouvier
187b646c07 refactor(event cache): have the room pagination handle waiting for the previous pagination token from sync
This case is very specific to the room pagination, and will not apply to
the thread pagination; by removing it from the generic pagination logic,
we'll be able to use the generic pagination logic for threads.
2025-09-30 14:29:27 +02:00
Benjamin Bouvier
8a47e3cd1c refactor(event cache): inline conclude_load_more_for_fully_loaded_chunk into its only caller
And that's one overlong function name less!
2025-09-30 14:29:27 +02:00
Benjamin Bouvier
973d71f54e docs(event cache): add comments to clarify when None can be returned from internal pagination methods 2025-09-30 14:29:27 +02:00
dependabot[bot]
943b048fa0 chore(deps): bump bnjbvr/cargo-machete
Bumps [bnjbvr/cargo-machete](https://github.com/bnjbvr/cargo-machete) from cb0995971182a3babbea3f086bf306d5509cac47 to 7c2dc36a6fe4a75848d9397e34c95474f38c82ef.
- [Release notes](https://github.com/bnjbvr/cargo-machete/releases)
- [Changelog](https://github.com/bnjbvr/cargo-machete/blob/main/CHANGELOG.md)
- [Commits](cb09959711...7c2dc36a6f)

---
updated-dependencies:
- dependency-name: bnjbvr/cargo-machete
  dependency-version: 7c2dc36a6fe4a75848d9397e34c95474f38c82ef
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-30 09:36:57 +01:00
dependabot[bot]
2c70c31c56 chore(deps): bump crate-ci/typos from 1.36.2 to 1.36.3
Bumps [crate-ci/typos](https://github.com/crate-ci/typos) from 1.36.2 to 1.36.3.
- [Release notes](https://github.com/crate-ci/typos/releases)
- [Changelog](https://github.com/crate-ci/typos/blob/master/CHANGELOG.md)
- [Commits](https://github.com/crate-ci/typos/compare/v1.36.2...v1.36.3)

---
updated-dependencies:
- dependency-name: crate-ci/typos
  dependency-version: 1.36.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-30 07:36:48 +03:00
Ivan Enderlin
be7129bacc chore(ui): Remove an unnecessary Arc in SpaceRoomList.
`SharedObservable` is already shareable, no need for an `Arc` here.
2025-09-29 09:54:54 +03:00
Ivan Enderlin
2ec33183c4 doc(sqlite): Fix formatting and typo. 2025-09-26 16:07:20 +02:00
Doug
d6d720c015 ffi: Expose a room list filter for spaces. 2025-09-26 10:22:53 +01:00
Stefan Ceriu
5b52c729a5 feat(spaces): automatically subscribe to SpaceRoomList "parent" space room info updates (#5712)
… when known to the client and forward updates through the existing
`subscribe_to_space_updates` mechanisms.

This allows clients to listen to updates without having to resort to a
separate room info subscription on their side.
2025-09-25 13:05:29 +03:00
Benjamin Bouvier
7d649e92d4 fix(timeline): don't listen to live thread events when the timeline is focused on a thread permalink 2025-09-25 11:27:18 +02:00
Benjamin Bouvier
021d3fb5d7 test(timeline): add a test to show that threaded permalink timeline receives thread live updates 2025-09-25 11:27:18 +02:00
Jorge Martín
5f02212312 fix(ffi): ffi::Room::load_or_fetch_event fails with missing room_id
The raw event was being deserialized in a wrong way and it could have a missing room id in some cases, returning an error even when the event was found
2025-09-25 10:57:48 +02:00
Benjamin Bouvier
e158e8abc0 refactor(timeline): in thread permalinks, avoid back-paginating if the root event is part of the /context response
For thread permalinks, we start with a /context query that will load the
focused event, and maybe a few other in-thread events. In fact, it can
also include the thread root event, which was excluded before. Instead,
we would get a previous-token for back-paginations, which would be used
in /relations. When the request to /relations returns an empty previous
token, that means we've reached the start of the thread, and in this
case we would manually load the root with /event.

We can do better, if the root event is part of the initial /context
response: skip the back-paginations altogether, and make sure to include
the root event in `init_focus()`.
2025-09-25 10:21:19 +02:00
Damir Jelić
e2ec8bcbd6 ci: Install clippy for the test-crypto CI run 2025-09-25 10:14:21 +02:00
Benjamin Bouvier
36e0d4bfb8 ci: don't compile the benchmarks in a separate CI step
They're built as part of the codspeed run these days, so this is
duplicated wasteful work.
2025-09-25 10:05:27 +02:00
Benjamin Bouvier
05362be89a ci: use the latest bnjbvr/cargo-machete action
It's much faster now as it downloads the latest version of the
precompiled binary from Github, and it will use the latest tagged
version of cargo-machete by default.
2025-09-25 10:05:27 +02:00
Ivan Enderlin
03fc5dacbe feat(ui): The recency sorter handles recency stamp _and_ latest event's timestamp.
This patch revisits a feature we have disabled a couple of days ago:
the `recency` sorter was initially only supporting the recency stamp,
then later the recency stamp _and_ the latest event's timestamp. It was
however buggy and we had to revert it. Now it's time to re-introduce it
but with a different approach.

The previous rules were:

1. if two rooms have a latest event, use their latest event's timestamps
   as their _scores,
2. if one of room has a latest event, use the recency stamp as their
   _scores_ for both rooms.

Rule 2 was buggy because one room was sometimes using its latest
event's timestamp, and sometimes its recency stamp, based on what it was
compared to. It was an error!

The new rules are the following:

1. unchanged
2. if one room has a latest event, use its latest event's timestamp as
   its _score_, and use no _score_ for the other room,
3. if two rooms have NO latest event, use the recency stamp as their
   _scores_.

It means that a room with no latest event will always be sorted _after_
a room with a latest event. It can feel cruel, but it should be an edge
case. When a room is synchronised, it should receive events, which
should trigger the computation of a latest event.

Note that this patch also renames _rank_ to _score_, as I consider it's
a better vocabulary. It could be confusing to use _rank_ as one can
expect all rooms to be indexed and get a rank, but it's not the case.
_Score_ sounds better.
2025-09-24 17:51:38 +02:00
Alexis Loiseau
0a0e31af83 feat(ui): add custom events to timeline when explicitly filtered
This allows custom message-like events (created by the `EventContent` macro from ruma) to be added to the timeline if they are explicitly allowed when building the timeline with a custom `event_filter`.

The custom event content is not available directly to the consumer, but it can still fetch it from the matrix-sdk client with its `event_id`, or display a "this type of event is not supported". 

Signed-off-by: Itess <me@aloiseau.com>

Fixes #5598.
2025-09-24 15:50:50 +00:00
Ivan Enderlin
290f27a343 doc(base): Update CHANGELOG.md. 2025-09-24 16:12:09 +02:00
Ivan Enderlin
0033de1f49 refactor(base): Rename sync_lock to state_store_lock.
This patch renames the `sync_lock` to `state_store_lock` because it is
what it is. It's not about the sync, it's about the state store.
2025-09-24 16:12:09 +02:00
Ivan Enderlin
688eb6880d refactor(sdk): Move the RoomLatestEvents* types in their own module.
This patch moves the `RoomLatestEvents*` types in their own new
`room_latest_events` module.
2025-09-24 14:26:14 +02:00
Ivan Enderlin
07704c7835 feat(sdk): Put locks around RoomLatestEvents.
This patch tries to solve a problem raised by Complement Crypto. In
`compute_latest_events`, in two places, `RegisteredRooms::rooms` was
locked with an exclusive write access. Then, during the updates of
the latest events (via `RoomLatestEvents::update_with_event_cache` and
`RoomLatestEvents::update_with_send_queue`), the state store lock is
acquired to update the state store. At the same time, in the sync, the
state store lock can **already** be taken to store the new updates, and
the function `subscribe_to_room_latest_events` is called, which waits
on the lock around `RegisteredRooms::rooms` to be available. We have a
dead lock:

- `compute_latest_events` waits on the state store lock while the lock
  on `RegisteredRooms::rooms` is taken with an exclusive access,
- the sync has acquired the state store lock while it waits on the lock
  on `RegisteredRooms::rooms`

This patch introduces a lock inside `RoomLatestEvents`. A new
`RoomLatestEventsState` type is introduced to be the lockable value. A
new `RoomLatestEvents::read()` and `RoomLatestEvents::write()` methods
are introduced to respectively return a `RoomLatestEventsReadGuard` and
a `RoomLatestEventsWriteGuard` type. The idea is to abstract a bit the
owned lock guard and to distribute the methods that were previously on
`RoomLatestEvents` in the new guard types, so that we keep the `&self`
and `&mut self` semantics, plus we take a lock for multiple operations.

The deadlock is fixed because of all the following reasons combined:

- only `RegisteredRooms::room_latest_event`,
  `RegisteredRooms::forget_room` and `RegisteredRooms::forget_thread`
  take a write lock over `RegisteredRooms::rooms`,
- `compute_latest_events` no longer takes a write lock over
  `RegisteredRoooms::rooms`, but it also has a short-lived lock:
  its read lock is dropped as soon as the **owned** write lock over
  `RoomLatestEvents` is taken.

Now, `subscribe_to_room_latest_events` can acquire a write lock over
`RegisteredRooms::rooms` while `compute_latest_events` is doing the
updates. If the state store lock is acquired here, it will just wait
its availability: the sync flow can finish and release the lock without
being blocked by `subscribe_to_room_latest_events`.
2025-09-24 14:26:14 +02:00
Ivan Enderlin
60c3b3dd43 chore(base): Scope the lock guard to a block.
This patch ensures that the state store lock guard (`_sync_lock`) is
scoped to a block so that it cannot live too long.
2025-09-24 14:26:14 +02:00