Skip to content

refactor(timeline): enhance the Timeline::send() and Timeline::send_reply() APIs when the timeline is threaded #5427

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

Merged
merged 6 commits into from
Jul 23, 2025

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Jul 21, 2025

This should make it simpler to send in-thread messages and in-thread replies in the future, but not mandating that the caller passes so much information.

  • To send a message in a threaded timeline, one can now use Timeline::send()
  • To send a reply in a threaded timeline, one can now use Timeline::send_reply() which only takes an OwnedEventId param instead of a Reply
  • (To start a new thread, you'd create a threaded timeline and use Timeline::send().)

The improvement is notable in the code of multiverse, for instance, where sending an event is now the same code between a regular or a threaded timeline.

If the threaded timeline isn't empty, it'll correctly use the latest in-thread event as the replied-to fallback event id (a check has been added in one test for that, and this avoids the mess observed in #5422). We could go one step further and trigger a pagination if the threaded timeline was empty; we'll see if we'll ever need it.

cc @Johennes, curious to get your thoughts on the new API!

Fixes #5216

@bnjbvr bnjbvr requested a review from a team as a code owner July 21, 2025 13:04
@bnjbvr bnjbvr requested review from andybalaam and stefanceriu and removed request for a team and andybalaam July 21, 2025 13:04
Copy link

codecov bot commented Jul 21, 2025

Codecov Report

Attention: Patch coverage is 79.71014% with 14 lines in your changes missing coverage. Please review.

Project coverage is 88.87%. Comparing base (37626b5) to head (f75dca2).
Report is 14 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
crates/matrix-sdk-ui/src/timeline/futures.rs 71.79% 6 Missing and 5 partials ⚠️
crates/matrix-sdk-ui/src/timeline/mod.rs 88.88% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5427      +/-   ##
==========================================
+ Coverage   88.85%   88.87%   +0.02%     
==========================================
  Files         333      333              
  Lines       91356    91400      +44     
  Branches    91356    91400      +44     
==========================================
+ Hits        81172    81231      +59     
+ Misses       6360     6347      -13     
+ Partials     3824     3822       -2     

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

@Johennes
Copy link
Contributor

This sounds sensible and much easier than fiddling with enforce_thread or reply_within_thread. 👍

@bnjbvr bnjbvr force-pushed the bnjbvr/thread-reply-api branch from aed804d to 0a75d73 Compare July 22, 2025 13:04
@bnjbvr
Copy link
Member Author

bnjbvr commented Jul 22, 2025

Stefan identified a few issues, so might as well add some tests later:

  • add tests for stickers
  • add tests for polls

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.

The new API looks great and I have a PR for EX adopting it here element-hq/element-x-ios#4344

I did leave a comment about polls not working as expected but that's not necessarily a blocker as we didn't have an API for sending them in threads before either.

Same would apply to stickers I guess if we were to ever implement sending support for them.

@bnjbvr bnjbvr merged commit cba711d into main Jul 23, 2025
44 checks passed
@bnjbvr bnjbvr deleted the bnjbvr/thread-reply-api branch July 23, 2025 13:05
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.

timeline: improve API of sending thread replies
3 participants