Skip to content

Conversation

@jmartinesp
Copy link
Contributor

@jmartinesp jmartinesp commented Nov 13, 2025

Changes:

  • In the live timeline, don't send read receipts for threaded events if hide_thread_events is enabled. EventMeta has now a thread_root_id field so we can know if the event is part of a thread, and TimelineController::latest_event_id filters those out if hide_thread_events is enabled.
    • Why do this instead of just filtering out non visible items? Because reactions, edits, replacements, etc. are also non-visible items that have to be taken into account for the read receipts. So it seems like we have 2 types of 'not visible' items in the timeline, those that aren't visible because we don't want to display them as separate items (aggregations), and those that aren't visible because they shouldn't be displayed at all.
    • Then why not avoid adding the items at all? Because some logic in the SDK depends on the threaded events being added to the remote events in the timeline, even if they aren't displayed because of hide_threaded_events, so some tests were broken.
  • Fix test that was consistently failing locally on main - not really related to this PR, but it also made it fail in CI. It looks like a race condition of some kind.
  • Modify ffi::Timeline::latest_event_id to use ui::Timeline::latest_event_id, which will return the value from TimelineController::latest_event_id.

Fixes element-hq/element-x-android#5639.

  • Public API changes documented in changelogs (optional)

Signed-off-by:

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 13, 2025

CodSpeed Performance Report

Merging #5864 will not alter performance

Comparing fix/sending-read-receipts-in-threads (ee2eca3) with main (5d396e4)1

Summary

✅ 50 untouched

Footnotes

  1. No successful run was found on main (ca43601) during the generation of this report, so 5d396e4 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@jmartinesp jmartinesp force-pushed the fix/sending-read-receipts-in-threads branch 2 times, most recently from 07141d7 to ef9278f Compare November 13, 2025 15:34
@codecov
Copy link

codecov bot commented Nov 13, 2025

Codecov Report

❌ Patch coverage is 92.30769% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.59%. Comparing base (9ab886f) to head (ee2eca3).
⚠️ Report is 13 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...rates/matrix-sdk-ui/src/timeline/controller/mod.rs 82.35% 3 Missing ⚠️
crates/matrix-sdk-ui/src/timeline/mod.rs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5864   +/-   ##
=======================================
  Coverage   88.59%   88.59%           
=======================================
  Files         363      363           
  Lines      102888   102926   +38     
  Branches   102888   102926   +38     
=======================================
+ Hits        91153    91188   +35     
- Misses       7496     7498    +2     
- Partials     4239     4240    +1     

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

…n a thread

Previously, this used the latest event in the thread as the event to mark as read, while this is not right if we're in a context that hides thread events
@jmartinesp jmartinesp force-pushed the fix/sending-read-receipts-in-threads branch from ef9278f to 635313a Compare November 13, 2025 21:19
…ne::latest_event_id`, instead of `ui::Timeline::latest_event`

This is important because `latest_event` would also return local events, which won't have an event id.
@jmartinesp jmartinesp marked this pull request as ready for review November 14, 2025 10:41
@jmartinesp jmartinesp requested a review from a team as a code owner November 14, 2025 10:41
@jmartinesp jmartinesp requested review from poljar and removed request for a team November 14, 2025 10:41
@jmartinesp jmartinesp changed the title fix(ui): Sending read receipt in thread timelines fix(ui): Sending read receipt in live timeline uses threaded event id instead Nov 14, 2025
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.

Looks good to me, modulo the small feedback. Thank you for the new test and for the fix!

/// remote event, but if it moves, it has an impact on this mapping.
pub timeline_item_index: Option<usize>,

pub thread_root_id: Option<OwnedEventId>,
Copy link
Member

Choose a reason for hiding this comment

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

Please add documentation for this field. Also —just a personal taste— I would put this field after event_id, not mandatory.

.iter()
.rev()
.filter_map(|item| {
if !filter_out_thread_events || item.thread_root_id.is_none() {
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain with an inline comment here why we want to filter out event with a thread root?

}
}

/// Get the latest of the timeline's event ids.
Copy link
Member

Choose a reason for hiding this comment

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

You may want to precise that, contrary to latest_event, this method only returns the ID of the last remote event (which is obvious for us because a local event doesn't have an event ID, only a transaction ID, but it's better to make it clear.

Also move `EventMeta::thread_root_id` next to `event_id`
@jmartinesp jmartinesp enabled auto-merge (rebase) November 18, 2025 11:01
@jmartinesp jmartinesp disabled auto-merge November 18, 2025 11:04
@jmartinesp jmartinesp enabled auto-merge (rebase) November 18, 2025 11:11
@jmartinesp jmartinesp merged commit 1c22d0b into main Nov 18, 2025
52 checks passed
@jmartinesp jmartinesp deleted the fix/sending-read-receipts-in-threads branch November 18, 2025 11:26
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.

Mark as read from notification action doesn't work on thread roots

3 participants