Skip to content

feat(timeline): Expose method to send galleries in matrix-sdk-ui#5125

Merged
bnjbvr merged 16 commits intomatrix-org:mainfrom
Johennes:johannes/msc4274-step3
Jun 3, 2025
Merged

feat(timeline): Expose method to send galleries in matrix-sdk-ui#5125
bnjbvr merged 16 commits intomatrix-org:mainfrom
Johennes:johannes/msc4274-step3

Conversation

@Johennes
Copy link
Copy Markdown
Contributor

@Johennes Johennes commented May 28, 2025

This was broken out of #4838 and is a step towards implementing matrix-org/matrix-spec-proposals#4274. Building upon #4977, a new method Timeline::send_gallery in matrix-sdk-ui for sending galleries.

  • Public API changes documented in changelogs (optional)

@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2025

Codecov Report

Attention: Patch coverage is 20.00000% with 12 lines in your changes missing coverage. Please review.

Project coverage is 85.88%. Comparing base (edabb23) to head (22f1991).
Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
crates/matrix-sdk-ui/src/timeline/futures.rs 0.00% 10 Missing ⚠️
...rates/matrix-sdk-ui/src/timeline/controller/mod.rs 50.00% 1 Missing ⚠️
...rates/matrix-sdk-ui/src/timeline/event_item/mod.rs 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5125      +/-   ##
==========================================
- Coverage   85.90%   85.88%   -0.02%     
==========================================
  Files         335      335              
  Lines       36511    36522      +11     
==========================================
+ Hits        31364    31367       +3     
- Misses       5147     5155       +8     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Johennes Johennes marked this pull request as ready for review May 28, 2025 17:21
@Johennes Johennes requested a review from a team as a code owner May 28, 2025 17:21
@Johennes Johennes requested review from poljar and removed request for a team May 28, 2025 17:21
@bnjbvr bnjbvr requested review from bnjbvr and removed request for poljar June 2, 2025 08:34
Copy link
Copy Markdown
Member

@bnjbvr bnjbvr left a comment

Choose a reason for hiding this comment

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

Nice, thank you! Approving because my comments are mostly nits. Soo, is this the last patch, or maybe we need a bit more to display and send galleries at the FFI layer?

Comment thread crates/matrix-sdk-ui/src/timeline/futures.rs
Comment thread crates/matrix-sdk-ui/tests/integration/timeline/media.rs Outdated
}

// Eventually, the media is updated with the final MXC IDs…
sleep(Duration::from_secs(2)).await;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need the sleep, considering that below we're using assert_let_timeout! (which can be configured with a higher timeout than the default)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Interestingly I have to use 3 seconds inside assert_let_timeout to replace the 2 seconds from sleep but this still feels better because the code is shorter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh, looks like the sleepdelay was just increased from 2 to 4 seconds in 8a5d4f0.

| MessageType::Video(_)
| MessageType::VerificationRequest(_) => true,
#[cfg(feature = "unstable-msc4274")]
MessageType::Gallery(_) => false,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this should be true, so as to display galleries by default. Wouldn't this make the test you've added fail, since it'd filter out the gallery event from rendering into an item? Maybe that's why CI's failing now.

Copy link
Copy Markdown
Contributor Author

@Johennes Johennes Jun 2, 2025

Choose a reason for hiding this comment

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

Oh, right! 🤦‍♂️

Have switched it around. It didn't seem to affect the test, however, which is mildly concerning. 🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The test is likely not running; investigating.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hah:

  • CI didn't run the test because the feature flag isn't ever enabled for the UI crate. I think we could decide that we support galleries by default in the timeline, so we could get rid of it now. Alternatively, we could enable the feature just a bit ahead of time in the FFI layer Cargo.toml, so that it's enabled workspace-wide, and included in testing. I think the latter would be great, since the FFI layer likely will want it anyways.
  • @stefanceriu and I noticed a bug that local echoes never get filtered out based on content, and this is what's happening here, since the current is sending a gallery. Can you add, in this test or another one, a gallery message received via sync from another user, so we can make sure that the filtering actually works? (and temporarily revert the patch that switched this from false to true, to make sure it does filter? no need to add a specific test for the filtering)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh! 🤯

Ok, I hope I got all of this right. The test now does fail for me also locally (with the erroneous false). When I switch back to true, it succeeds.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does it? Looks like it's the sending of the media gallery that fails, not the filtering out…

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh, you're right. 🤦‍♂️ Ok, will have to look into what's going on there now. 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Looks like the media config requests need mocking after merging in main. Added those and switched back to false so the CI should now fail timing out waiting for the sent gallery.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, it seems to be failing as intended now: no item is pushed, while we expected one 🥳 Good job making the test meaningful and winning over CI!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Lets hope it actually turns green now. 😅🤞

@Johennes
Copy link
Copy Markdown
Contributor Author

Johennes commented Jun 2, 2025

Soo, is this the last patch, or maybe we need a bit more to display and send galleries at the FFI layer?

Yes indeed, there's one more PR needed to expose galleries on the FFI layer. I just tried to keep this one here as small as possible because the other one will probably have some lengthy mapping to FFI types again. 🙈

Copy link
Copy Markdown
Member

@bnjbvr bnjbvr left a comment

Choose a reason for hiding this comment

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

Requesting changes, because of the latest in-thread comment i've posted, to be super explicit. Let's test this in CI! :)

Comment thread testing/matrix-sdk-test/Cargo.toml
@Johennes Johennes requested a review from bnjbvr June 3, 2025 12:31
@bnjbvr bnjbvr merged commit ee06965 into matrix-org:main Jun 3, 2025
43 checks passed
@bnjbvr
Copy link
Copy Markdown
Member

bnjbvr commented Jun 3, 2025

Thanks @Johennes, and great job as usual!

bnjbvr pushed a commit that referenced this pull request Jun 4, 2025
Addendum to #5125 to
allow sending galleries from the FFI crate. This is the final PR for
galleries (apart from possible enhancements to report the upload status
in #5008).

This is somewhat lengthy again, apologies. Most of the changes are just
wrappers and type mapping, however. So I was hoping that it's relatively
straightforward to review in bulk. Happy to try and elaborate on the
changes or break them up into smaller commits if that helps, however.

---------

Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
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.

2 participants