Commit Graph

15401 Commits

Author SHA1 Message Date
Ivan Enderlin
e79f83e5cc fix(sdk): Re-compute the ThreadSummary when R2D2 redecrypts an event in a thread. 2026-05-29 15:15:56 +02:00
Ivan Enderlin
b79dcd6328 fix(sdk): Restore UTD resolution on threads.
This patch restores UTD resolution on the thread caches. It has been
disabled earlier during this refactoring, now it's back!
2026-05-29 15:15:56 +02:00
Ivan Enderlin
4943c18d53 doc(sdk): Fix a typo in the documentation of Caches::all_events. 2026-05-29 14:36:10 +02:00
Ivan Enderlin
1568963dac feat(sdk): Allow to reset an EventFocusedCache.
This patch updates `ResetCaches` to handle the event-focused caches.
2026-05-29 14:36:10 +02:00
Ivan Enderlin
c72753dca2 refactor(sdk): Rename EventFocusedCacheInner to EventFocusedCacheState.
This patch renames `EventFocusedCacheInner` to `EventFocusedCacheState`
because it contains the state of the `EventFocusedCacheState`.
2026-05-29 14:36:09 +02:00
Ivan Enderlin
2836812c24 chore(sdk): Reorganise imports.
This patch reorganises the imports. Notably, `RoomPagination` is a
submodule: no need to import it from `crate::event_cache`.
2026-05-29 14:36:09 +02:00
Ivan Enderlin
cc4c89eb4f test(sdk): Update the tests. 2026-05-29 14:36:09 +02:00
Ivan Enderlin
27c62c99dd chore(sdk): Remove EventFocusedCache from RoomEventCache.
Moohaha.
2026-05-29 14:36:09 +02:00
Ivan Enderlin
4cbabb0cef refactor(sdk): R2D2 uses Caches directly to resolve UTD on various caches.
This patch updates R2D2 to uses `Caches` via
`EventCache::inner::all_caches_for_room` to get a reference to all the
caches. It updates the way the event-focused cache was updated. No more
ABBA lock problem here. The code is simplified.
2026-05-29 14:36:09 +02:00
Ivan Enderlin
773d24e502 chore(ui): TimelineController::new uses EventCache::event_focused. 2026-05-29 14:36:08 +02:00
Ivan Enderlin
57e9053f08 refactor(sdk): Rename focused to focused_event_id in EventFocusedCacheKey.
This patch renames the `EventFocusedCacheKey::focused` field to
`focused_event_id` to clarify what is focused.
2026-05-29 14:36:08 +02:00
Ivan Enderlin
0c92070894 feat(sdk): Add EventCache::event_focused.
This patch stores all the `EventFocusedCache` in `Caches`.
2026-05-29 14:36:08 +02:00
Ivan Enderlin
49df4f5fa7 fix(sdk): Remove the room argument of EventFocusedCache::start_from.
This patch removes the `room` argument of
`EventFocusedCache(Inner)::start_from`. First off, this is not required
as the struct already has the `WeakRoom`. Second, this is dangerous as
the two rooms might differ, or different rooms might be used between
called. This can be really inconsistent.

This patch removes the `room` argument and the code uses the `WeakRoom`
in the struct instead.
2026-05-29 14:36:08 +02:00
Ivan Enderlin
b810426a6c chore(sdk): Save the creation of a WeakRoom from scratch since one already exists.
This patch clones an existing `WeakRoom` instead of creating another one
from scratch.
2026-05-29 14:36:08 +02:00
Ivan Enderlin
07aa61c295 feat(sdk): EventFocusedCacheKey implements Debug. 2026-05-29 14:36:07 +02:00
Ivan Enderlin
d9ce36163d refactor(sdk): Move EventFocusedCacheKey from room to event_focused.
This patch moves `EventFocusedCacheKey` from the `room` module into the
`event_focused` module because it's about the event-focused cache.
2026-05-29 14:36:07 +02:00
Ivan Enderlin
26fff112a4 chore: Remove an unused reload method. 2026-05-29 14:36:07 +02:00
Ivan Enderlin
788b80f3de test(sdk,ui): Update tests to the new API. 2026-05-29 14:36:07 +02:00
Ivan Enderlin
efa6bc9c8b chore(sdk): Remove PinnedEventsCache entirely from RoomEventCache.
This patch removes deadcode about `PinnedEventsCache` in `RoomEventCache`.
2026-05-29 14:36:06 +02:00
Ivan Enderlin
8d6ff18ef5 refactor(sdk): R2D2 replaces UTD on PinnedEventsCache without involving RoomEventCache.
This patch updates R2D2 to fetch the `PinnedEventsCache` from
`EventCache` without using `RoomEventCache`.
2026-05-29 14:36:06 +02:00
Ivan Enderlin
1047e14d2b chore(sdk): Remove subscribe_to_pinned_events.
This patch removes `subscribe_to_pinned_events`, it is now useless.
2026-05-29 14:36:06 +02:00
Ivan Enderlin
5ce4c667f3 feat(ui): TimelineFocusKind::PinnedEvents now uses PinnedEventsCache.
This patch updates `TimelineFocusKind::PinnedEvents { event_cache }` to
use a `PinnedEventsCache` instead of a `RoomEventCache`.
2026-05-29 14:36:06 +02:00
Ivan Enderlin
2c562ba20a chore(sdk): Simplify imports. 2026-05-29 14:36:05 +02:00
Ivan Enderlin
b1927f121c feat(sdk): PinnedEventsCache handles redaction.
This patch applies event redactions over pinned events.
2026-05-29 14:36:05 +02:00
Ivan Enderlin
8f287198eb feat(sdk): Deduplicate pinned events.
This patch runs the `filter_duplicate_events` function inside
`handle_sync` to deduplicate events related to pinned events.
2026-05-29 14:36:04 +02:00
Ivan Enderlin
9d0d609892 refactor(sdk): Handle the Timeline for pinned-events in Caches instead of RoomEventCache.
This patch moves `maybe_add_live_related_events` to `handle_timeline`.
`handle_timeline` is called by `handle_(joined|left)_room_update`, which
are themselves called by `Caches`.

This patch also removes other methods used by
`maybe_add_live_related_events` but are no longer useful since
we have the aggregator, namely `extract_relation_target` and
`extract_redaction_target`.

Finally, this patch removes the call to `maybe_add_live_related_events`
in `RoomEventCacheStateLockWriteGuard::post_process_new_events`, which
removes the need to acquire a write lock over the room' state here.
2026-05-29 14:36:04 +02:00
Ivan Enderlin
9d0826252c feat(sdk): Add aggregator_timeline_for_pinned_events.
This patch adds the pipeline for `PinnedEventsCache` via
`aggregator_timeline_for_pinned_events`.
2026-05-29 14:36:03 +02:00
Ivan Enderlin
ca84cf833a feat(sdk): Add EventCache::pinned_events.
This patch adds `EventCache::pinned_events` to get the `PinnedEventsCache`.

This patch adds `Caches::pinned_events`. `ResetCaches` also
handle the pinned-events cache. To make it works, this patch adds
`PinnedEventsCache::state`, `PinnedEventsCache::update_sender` and
`PinnedEventsCacheStateLockWriteGuard::reset`. This one is new as the
feature wasn't implemented before!
2026-05-29 14:36:03 +02:00
Ivan Enderlin
4d241089b7 feat(sdk): Add PinnedEventsCacheInner::update_sender.
This patch adds `PinnedEventsCacheInner::update_sender`, making
`PinnedEventsCacheState::update_sender` a clone of the former.

This is going to be useful in the next commit for handling pinned-events
in `ResetCaches`.
2026-05-29 14:36:03 +02:00
Ivan Enderlin
c853c77f8c refactor(sdk): Introduce PinnedEventsCacheInner.
This patch introduces the `PinnedEventsCacheInner` type that is used
inside `PinnedEventsCache` to make it cheap to clone. It was already the
case before with all the fields beind `Arc<_>` but we are about to move
data in their correct place, and thus it will add more `Arc<_>`, which
is not good. Let's adopt the same patterns as the other caches too for
the sake of consistency.
2026-05-29 14:36:02 +02:00
Ivan Enderlin
25abaefcb1 doc(sdk): Fix document in thread cache. 2026-05-29 14:36:02 +02:00
Ivan Enderlin
835ef77367 refactor(sdk): Introduce PinnedEventsCacheUpdateSender.
This patch introduces the new type `PinnedEventsCacheUpdateSender` _à
la_ `ThreadEventCacheUpdateSender` or `RoomEventCacheUpdateSender`. It
abstracts the channels to send updates about. Yes, for the moment, it
has a single channel, but it's better to provide the same abstractions
for all caches.
2026-05-29 14:36:02 +02:00
Ivan Enderlin
f87363a0a6 doc(sdk): Fix an intra-link. 2026-05-29 14:36:01 +02:00
Ivan Enderlin
fbbffda11f refactor(sdk): Rename PinnedEventsCacheStateLock to LockedPinnedEventsCacheState.
This patch renames `PinnedEventsCacheStateLock` to
`LockedPinnedEventsCacheState` to match other namings in
`RoomEventCache` and `ThreadEventCache` for the sake of consistency.
2026-05-29 14:36:01 +02:00
Ivan Enderlin
00e610cdd2 chore(sdk): PinnedEventsCache::new takes a WeakRoom instead of a Room.
This patch changes `PinnedEventsCache::new` to receive a `WeakRoom`
instead of a `Room`. It then returns a `Result<Self>`, with `Err` if the
`WeakRoom` doesn't point to the `Room` anymore. Thus, this patch changes
`get_or_init` by `get_or_try_init`, but this one is unstable. So this
patch switches from `OnceLock` to `OnceCell`, which provides a stable
one. Why this change? Because in a later refactoring, providing a `Room`
is a bit annoying: all we will have is a `WeakRoom`. We could do this
work of upgrading the `WeakRoom` to a `Room`, but it seems akward as all
caches are holding a `WeakRoom` if room is necessary.
2026-05-29 14:36:01 +02:00
Ivan Enderlin
3077d51ec8 refactor(sdk): Rename PinnedEventCache to PinnedEventsCache.
This patch renames `PinnedEventCache` to `PinnedEventsCache` (and same
for all types having `PinnedEventCache` as a prefix).

Why? Because it's a cache about _pinned-events_, not a single
_pinned-event_ :-).
2026-05-29 14:36:01 +02:00
Ivan Enderlin
48c1629791 doc(sdk): Remove a useless TODO. 2026-05-29 14:36:00 +02:00
Ivan Enderlin
f9df888cf3 chore(sdk): Implement Debug for PinnedEventCache. 2026-05-29 14:36:00 +02:00
Ivan Enderlin
d7f35742d4 test(sdj): Fix test_redact_touches_threads if async runtime is slow. 2026-05-29 14:36:00 +02:00
Ivan Enderlin
4d58a3c0db chore(sdk,ui): Fix typos. 2026-05-29 14:36:00 +02:00
Ivan Enderlin
8657a7788b test(sdk): Disable test_latest_thread_event_is_redecrypted_and_updated for now.
This test is not working because of R2D2 not updating threads for now.
This is normal. This is going to be refactored in a later PR.
2026-05-29 14:35:59 +02:00
Ivan Enderlin
e04f673ee7 chore(sdk): Make Clippy happy :-). 2026-05-29 14:35:59 +02:00
Ivan Enderlin
4fe1128385 fix(sdk): Restore the handling of bunlded_latest_thread_event in RoomEventCache. 2026-05-29 14:35:59 +02:00
Ivan Enderlin
58b0c5c893 test(sdk): Update to match the edit and redaction behaviours. 2026-05-29 14:35:59 +02:00
Ivan Enderlin
c5aad98768 feat(sdk): ThreadSummary uses the LatestEvent filtering API.
This patch updates the `compute_thread_summary` method on the thread
cache to use the `matrix_sdk::latest_events` API. It bends it, also
a crime. We don't use it at its full potential, but at least it fixes
several bugs and makes it more aligned with the room latest events: it
skips `m.room.redaction` (new), the majority of the state events (new),
mostly correctly handle edits (new) etc.

This patch also allows the system to erase the `ThreadSummary` if none
can be computed.
2026-05-29 14:35:58 +02:00
Ivan Enderlin
b352284e1a fix(ui): Updates from RoomEventCache are not forwarded to a Thread Timeline.
Previously, because a `ThreadEventCache` didn't receive all its events,
a `Timeline` with a `Thread` focus had to be updated via two sources:
updates from `RoomEventCache` and from `ThreadEventCache`. Now that this
problem is solved, i.e. a `ThreadEventCache` contains all its events,
a `Timeline` with a `Thread` focus doesn't have to be updated by two
sources. This is what this patch does.
2026-05-29 14:35:58 +02:00
Ivan Enderlin
4dc1a626ac feat(sdk): Annotations and redactions events are stored in their associated threads.
This patch stores all events with a relation to an in-thread event,
plus the `m.room.redaction` events targeting in-thread events, in their
respective thread cache.

This patch also introduces a new `extract_redaction_target` helper, that
is used in the `maybe_apply_new_redaction` methods of the room and the
thread cache.

The aggregator for the threads is updated to aggregate the
`m.room.redaction` event, and annotation relation type. A refactoring
is done to use a `match` over `RelationType`, instead of using multiple
`extract_*` helper, which clarifies the code I believe. A limitation has
been found and a `TODO` has been added to keep the commits “small”.
2026-05-29 14:35:58 +02:00
Ivan Enderlin
ef76aafdda test(sdk): Update tests to the new API. 2026-05-29 14:35:58 +02:00
Ivan Enderlin
dad3a7fb7a chore(sdk): Clean up the reset/clear API. 2026-05-29 14:35:57 +02:00
Ivan Enderlin
c855713638 refactor(ui): TimelineFocusKind holds the appropriate event cache.
This patch updates `TimelineFocusKind` to hold its own event cache type
for each kind of timeline. The idea is to stop fetching each cache for
every action and makes some path infallible. The performance are also
perceivably faster according to a real test by Jorge on Android.
2026-05-29 14:35:57 +02:00