Skip to content

refactor(widget): rename some concepts #4967

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

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Apr 23, 2025

After reading the widget code for a long time this afternoon, I think I finally understand some things about it. It seems there are two channels between the widget and the "machine", and the direction is indicated in the name of some structs. For instance, ToWidgetRequest = "some request has been sent from the machine to the widget", aka it's always from the point of view of the sender. For the second channel, there's FromWidgetRequest, aka it's a request sent from the widget to the machine.

Now, this is where it gets confusing for me: ToWidgetResponse is the response from the widget to the machine. In other words, what I think motivated the name is that, this is the response to a request of kind "ToWidget". Bizarrely, there's no equivalent for responses to a FromWidgetRequest; the responses are plain serialized from their original types.

If I'm right, then I'm super super confused by this, because I'd imagine a response to a ToWidgetRequest (from machine to widget) would be named after the fact it's sent back by the machine to the widget, so I'd intuit it should be the FromWidgetResponse. But that's the opposite: it is the ToWidgetResponse, which I imagined was the response from the machine to the widget.

I think some renaming is due here, but I'm not sure how yet.

@bnjbvr bnjbvr changed the title Bnjbvr/rename widget driver stuff refactor(widget): rename some concepts Apr 23, 2025
Copy link

codecov bot commented Apr 23, 2025

Codecov Report

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

Project coverage is 85.98%. Comparing base (426a4ff) to head (ec69bd5).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
crates/matrix-sdk/src/widget/machine/mod.rs 89.33% 8 Missing ⚠️
crates/matrix-sdk/src/widget/machine/to_widget.rs 50.00% 3 Missing ⚠️
crates/matrix-sdk/src/widget/machine/driver_req.rs 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4967      +/-   ##
==========================================
- Coverage   85.98%   85.98%   -0.01%     
==========================================
  Files         325      325              
  Lines       35652    35660       +8     
==========================================
+ Hits        30656    30662       +6     
- Misses       4996     4998       +2     

☔ 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.

@bnjbvr
Copy link
Member Author

bnjbvr commented Apr 23, 2025

I realize there's a third concept called the Driver that's the SDK client being actually used; so my initial post is probably incorrect and should s/driver/machine. Oh well 🥲

@toger5
Copy link
Contributor

toger5 commented Apr 24, 2025

Your original post seems about right.

  • there are from_widget and to_widget actions
  • they can either be sent as a request or as a response (containing a response field vs not containing a response field) -> both actions can be sent in both directions... It uses directional terminology for a property that behaves more like a type.

This is how the widget MSC's are defining the actions as of now however. So I do think the naming should be as it is in the: MSC's ("not up to date general widget msc"), js-sdk, EW, matrix-widget-api

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