Skip to content
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

timeline: make use of the sending queue #3475

Merged
merged 12 commits into from
Jun 5, 2024
Merged

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented May 28, 2024

This is part 2 of #3465, extracted to make review easier. This integrates the new sending queue with the timeline, exposes FFI methods, and adds some way to quickly test the new queuing mechanism in multiverse.

Note to embedders: to allow cancelling a local echo, embedders should use Timeline::redact() instead of Room::redact(). This requires an EventTimelineItem, which can be retrieved using get_event_timeline_item_with_event_id (~for remote echoes) or get_event_timeline_item_with_transaction_id (for local echoes).

Part of #3361.

@bnjbvr bnjbvr requested a review from a team as a code owner May 28, 2024 13:38
@bnjbvr bnjbvr requested review from Hywan and removed request for a team May 28, 2024 13:38
@bnjbvr bnjbvr force-pushed the bnjbvr/send-q-in-timeline branch from 0d79bec to 125ffe4 Compare May 28, 2024 16:31
Copy link

codecov bot commented May 28, 2024

Codecov Report

Attention: Patch coverage is 74.77477% with 28 lines in your changes missing coverage. Please review.

Project coverage is 83.80%. Comparing base (3917ba6) to head (c0c5e5a).
Report is 12 commits behind head on main.

Files Patch % Lines
crates/matrix-sdk-ui/src/timeline/builder.rs 73.46% 13 Missing ⚠️
crates/matrix-sdk-ui/src/timeline/mod.rs 65.51% 10 Missing ⚠️
...rates/matrix-sdk-ui/src/timeline/event_item/mod.rs 57.14% 3 Missing ⚠️
crates/matrix-sdk-ui/src/timeline/inner/mod.rs 90.00% 1 Missing ⚠️
crates/matrix-sdk-ui/src/timeline/inner/state.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3475      +/-   ##
==========================================
+ Coverage   83.71%   83.80%   +0.09%     
==========================================
  Files         255      254       -1     
  Lines       25773    25729      -44     
==========================================
- Hits        21575    21562      -13     
+ Misses       4198     4167      -31     

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

@kegsay
Copy link
Member

kegsay commented May 30, 2024

Complement-Crypto is unhappy likely due to the same reason as #3261

@poljar poljar requested review from poljar and removed request for Hywan May 30, 2024 10:07
@bnjbvr bnjbvr closed this May 31, 2024
@bnjbvr bnjbvr reopened this May 31, 2024
@bnjbvr bnjbvr force-pushed the bnjbvr/send-q-in-timeline branch 2 times, most recently from e70e0e1 to 545e54d Compare June 3, 2024 13:32
@bnjbvr bnjbvr requested a review from Hywan June 3, 2024 13:40
@bnjbvr bnjbvr force-pushed the bnjbvr/send-q-in-timeline branch from 0941b60 to eca6f3e Compare June 3, 2024 13:45
@bnjbvr
Copy link
Member Author

bnjbvr commented Jun 3, 2024

(Note: will need a rebase after #3496 lands)

Copy link
Member

@stefanceriu stefanceriu left a comment

Choose a reason for hiding this comment

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

Tested this out on EXI and it works great! 👏

@Hywan
Copy link
Member

Hywan commented Jun 5, 2024

Note to embedders: to allow cancelling a local echo, embedders should use Timeline::redact() instead of Room::redact().

Can we delete Room::redact then?

@stefanceriu
Copy link
Member

stefanceriu commented Jun 5, 2024

Note to embedders: to allow cancelling a local echo, embedders should use Timeline::redact() instead of Room::redact().

Can we delete Room::redact then?

What should we do if we want to redact an item that's not loaded in any timeline? For example redacting a poll in which you have the pollStartEventID but the real event is somewhere in unloaded past history.

@bnjbvr
Copy link
Member Author

bnjbvr commented Jun 5, 2024

Note to embedders: to allow cancelling a local echo, embedders should use Timeline::redact() instead of Room::redact().

Can we delete Room::redact then?

No, Room::redact should still exist for SDK users not using the Timeline. My comment above is specific to embedders making use of the Timeline, and who don't want to have to remember SendAbortHandle returned by send.

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.

Well done. I really appreciate the clean up and the new tests! I've some feedback but nothing huge.

bindings/matrix-sdk-ffi/src/timeline/mod.rs Outdated Show resolved Hide resolved
bindings/matrix-sdk-ffi/src/timeline/mod.rs Outdated Show resolved Hide resolved
crates/matrix-sdk-ui/src/timeline/mod.rs Show resolved Hide resolved
crates/matrix-sdk-ui/src/timeline/builder.rs Outdated Show resolved Hide resolved
crates/matrix-sdk-ui/src/timeline/mod.rs Show resolved Hide resolved
crates/matrix-sdk-ui/src/timeline/inner/mod.rs Outdated Show resolved Hide resolved
crates/matrix-sdk-ui/src/timeline/event_item/mod.rs Outdated Show resolved Hide resolved
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.

Marking the PR as “Request changes” because of #3475 (comment), I think it's important.

@bnjbvr bnjbvr removed the request for review from poljar June 5, 2024 08:33
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.

After a short discussion, the pain point about having a Option<AbortSendHandle> isn't that terrible, and it's fine to merge as is.

@bnjbvr bnjbvr force-pushed the bnjbvr/send-q-in-timeline branch from eca6f3e to d846a58 Compare June 5, 2024 12:20
@bnjbvr bnjbvr enabled auto-merge (rebase) June 5, 2024 12:21
bnjbvr added 3 commits June 5, 2024 14:45
Technically, the test already passed before the change in the builder,
because `TimelineEventHandler::handle_event` already filters out local
events on non-live timelines, but it's a waste of resources to even
spawn the local echo listener task in that case, so let's not do it.
bnjbvr added 9 commits June 5, 2024 14:45
…cal echo

The test relied on the fact that sending an event from a given timeline
is not observable from another timeline. Indeed, it sent a message using
a first timeline object, then constructed a second timeline object and
expected only the remote event to be in there.

Now, the sending queue is shared across all instances of a Room, thus
all instances of a Timeline, and the second timeline can see the local
echo for the message sent by the first timeline.

The "fix" is thus in the test structure itself: when waiting for the
remote echo to be there, check that the timeline item doesn't pertain to
a local echo, i.e. is a remote echo.
It was used after a previous local echo couldn't be sent (i.e. the
sending queue failed to send it). However, it was slightly incorrect to
mark those as cancelled, since those local echoes would still have
corresponding items in the sending queue, and would be retried as soon
as the sending queue was reenabled and could send events.

Instead, this is removed: it means that previously cancelled events
would be in the NotSentYet state, which is correct. (At the limit, we
could even get rid of the SendingFailed variant, since the sending queue
will automatically retry as soon as possible.)
Also reunify two methods that did the same thing, with slightly
different semantics, and test the one that wasn't tested at all.

Note that `is_editable()` was already exposed to the FFI and used in EX
apps.
@bnjbvr bnjbvr force-pushed the bnjbvr/send-q-in-timeline branch from d846a58 to c0c5e5a Compare June 5, 2024 12:45
@bnjbvr bnjbvr merged commit 23cc1e3 into main Jun 5, 2024
38 checks passed
@bnjbvr bnjbvr deleted the bnjbvr/send-q-in-timeline branch June 5, 2024 12:58
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