Skip to content

feat(widget): Support for avatars in calls via msc4039#6354

Merged
stefanceriu merged 10 commits intomainfrom
valere/widget/download_file
Apr 2, 2026
Merged

feat(widget): Support for avatars in calls via msc4039#6354
stefanceriu merged 10 commits intomainfrom
valere/widget/download_file

Conversation

@BillCarsonFr
Copy link
Copy Markdown
Member

@BillCarsonFr BillCarsonFr commented Mar 26, 2026

Allows to get the avatars in Element Call widget !
Using MSC4039

Counter part of web support:

Needs a EC PR to support passing data as base64 via the widget json API

Signed-off-by:

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Mar 26, 2026

Merging this PR will improve performance by 48.26%

⚡ 1 improved benchmark
✅ 49 untouched benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation Restore session [memory store] 166.5 ms 112.3 ms +48.26%

Comparing valere/widget/download_file (d302a65) with main (32e9626)

Open in CodSpeed

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 26, 2026

Codecov Report

❌ Patch coverage is 91.66667% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.86%. Comparing base (32e9626) to head (d302a65).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
crates/matrix-sdk/src/widget/machine/mod.rs 85.29% 4 Missing and 1 partial ⚠️
...rates/matrix-sdk/src/widget/machine/from_widget.rs 75.00% 2 Missing ⚠️
crates/matrix-sdk/src/widget/capabilities.rs 90.90% 0 Missing and 1 partial ⚠️
crates/matrix-sdk/src/widget/matrix.rs 87.50% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6354      +/-   ##
==========================================
+ Coverage   89.85%   89.86%   +0.01%     
==========================================
  Files         378      378              
  Lines      103384   103491     +107     
  Branches   103384   103491     +107     
==========================================
+ Hits        92893    93001     +108     
+ Misses       6928     6924       -4     
- Partials     3563     3566       +3     

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

@BillCarsonFr BillCarsonFr marked this pull request as ready for review March 26, 2026 18:42
@BillCarsonFr BillCarsonFr requested a review from a team as a code owner March 26, 2026 18:42
@BillCarsonFr BillCarsonFr requested review from stefanceriu and removed request for a team March 26, 2026 18:42
Comment on lines +350 to +352
// Not used yet. Only support non-encrypted downloads (avatars)
// pub(crate) timeout_ms: Option<u64>,
// pub(crate) encryption: Option<EncryptedFile>,
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 would delete these for now. What even is an EncryptedFile in this context?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removed, details for that are in the MSC

pub(crate) struct DownloadFileResponse {
// The binary file content in a format that can cross the
// widget-driver-api boundary.
pub(crate) file: Base64,
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.

Suggested change
pub(crate) file: Base64,
pub(crate) file_data: Base64,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok, but then I have to use a #[serde(rename = "file")] to respect the spec.
If going that way, probably should call it file_data_base64

match matrix_driver_response {
MatrixDriverResponse::FileDownloaded(resp) => Some(Self { file: resp.file }),
_ => {
error!("bug in MatrixDriver, received wrong event response");
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 wonder if this should be a full on panic as it's a developer error.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Right, can this be a separate PR? because it is now the common pattern in the crate

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.

Sure thing 👍

assert_eq!(req.content_uri, "mxc://server/id");
}
#[test]
fn parse_download_file_widget_action_error() {
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.

Took me a while to realised what's different here. Let's perhaps call it parse_uri_validation_error or something

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

rename to parse_download_file_request_with_non_mxc_url

}
FromWidgetRequest::DownloadFile(req) => self
.process_download_file_request(req, raw_request)
.map(|a| vec![a])
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 anything in here actually return a list of actions or is always jsut the one?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

maybe some other widget requests returns several? I don't know

&mut self,
req: DownloadFileRequest,
raw_request: Raw<FromWidgetRequest>,
) -> Option<Action> {
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.

This shouldn't return an optional.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is the consistent pattern used in this file for all action handling. Maybe this can be another PR to discuss and change this pattern

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.

Fair enough 👍

Comment thread crates/matrix-sdk/CHANGELOG.md Outdated
to true will now trigger a download of all historical keys for the room in
question from the client's key backup.
([#6017](https://github.com/matrix-org/matrix-rust-sdk/pull/6017))
- Add widget support for MSC4039. Allows widgets to download files from the
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.

Perhaps we should mention it only works for non-encrypted files.

}

#[async_test]
async fn test_try_download_external() {
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.

Same comment as above I guess 🤷‍♂️

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

test_download_non_mxc_uri_should_fail ?

@BillCarsonFr BillCarsonFr requested a review from stefanceriu April 2, 2026 10:02
@stefanceriu stefanceriu enabled auto-merge (squash) April 2, 2026 10:35
@stefanceriu stefanceriu merged commit fcce02f into main Apr 2, 2026
53 checks passed
@stefanceriu stefanceriu deleted the valere/widget/download_file branch April 2, 2026 10:35
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