matrix-rust-sdk icon indicating copy to clipboard operation
matrix-rust-sdk copied to clipboard

Focused timelines can't react to updates from the event cache

Open poljar opened this issue 2 weeks ago • 0 comments

The gist of the issue comes from the fact that the event cache uses indices to send out updates.

So if a new event comes around or an event replaces another in the event cache, you might get something like "Set this event at index 0" or "Replace event at index 7 with this event".

Now a focused timeline only shows a subset of all events. As of 2025.12.11. we have the following cases:

  • TimelineFocus::Live - The normal timeline, showing all events.
  • TimelineFocus::Event - A timeline focusing on a specific event and a number of contextual events around it.
  • TimelineFocus::Thread - A timeline focusing on a specific thread.
  • TimelineFocus::PinnedEvents - A timeline showing only the pinned events of a room.

The latter three are focused timelines and work differently from the normal Live timeline. Since the event cache works on all events and the focused timelines work on a subset of all events, the indices the event cache uses don't necessarily match the events and their indices in the timeline.

Meaning, the focused timelines can't really react to the event cache providing live updates.

This issue is briefly mentioned in https://github.com/matrix-org/matrix-rust-sdk/issues/5053#issuecomment-2891250594

I'll copy the relevant snippet over:

For the other timelines, though, it's a lie: we're still accumulating metadata from the events loaded in the context of those timelines, and putting them into all_remote_events, but they're not modeled after the live updates from the event cache. As a result, we can't apply the live updates in real-time (because the indices from the event cache updates won't match any of the events backing the non-live timeline), and have to complicate the implementation of handling live events related to a non-live timeline (see last commit in https://github.com/matrix-org/matrix-rust-sdk/pull/5060).

This has been the reason of at least the following workarounds and issues:

  • https://github.com/matrix-org/matrix-rust-sdk/pull/5060
  • https://github.com/matrix-org/matrix-rust-sdk/pull/4645
  • https://github.com/matrix-org/matrix-rust-sdk/issues/5703
  • https://github.com/matrix-org/matrix-rust-sdk/issues/5798

poljar avatar Dec 11 '25 14:12 poljar