Skip to content

Handle matrix.to room alias and room ID links. #531

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

tyreseluo
Copy link
Contributor

PR content

  1. Add support for clicking matrix.to links in room messages to navigate to rooms and resolve room aliases.
  2. Implement async room alias resolution with proper error handling and user feedback through popup notifications.

Related PR

1. Add support for clicking matrix.to links in room messages to navigate to rooms and resolve room aliases.
2. Implement async room alias resolution with proper error handling and user feedback through popup notifications.
@tyreseluo tyreseluo force-pushed the feature/handle_matrix_io_links_for_rooms branch from 4675675 to 24d8652 Compare June 28, 2025 06:23
@tyreseluo tyreseluo self-assigned this Jun 28, 2025
@tyreseluo tyreseluo added waiting-on-review This issue is waiting to be reviewed waiting-on-author This issue is waiting on the original author for a response and removed waiting-on-review This issue is waiting to be reviewed waiting-on-author This issue is waiting on the original author for a response labels Jun 28, 2025
Copy link
Member

@kevinaboos kevinaboos left a comment

Choose a reason for hiding this comment

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

Thanks for the PR.

I'm a bit confused about the title of this PR. When you "handle" room aliases and links, what do you mean by "handle"? I would expect the UI to open a new tab (in Desktop mode) and show that room's content if it's joined, or if it hasn't been joined yet, then show a new view with a preview of that room and a prompt asking the user to join it.

And then in Mobile mode, the same thing would happen, but you'd just show the new room in a view that replaces the existing RoomScreen, instead of opening a new tab (since there are no tabs). I was under the impression that we'd need Julian's new stack navigation PR in order to handle this properly, in which we're able to "push" the new room view onto the stack of existing views (such that you can navigate backwards to the rooms you viewed previously). Without that functionality, we can't really offer a good user experience of navigating between multiple rooms.

This PR doesn't really seem to do any of that, so I'm a bit confused about what you intended the scope of this to be.

Comment on lines 1830 to 1833
c.rooms().into_iter().find(|room| {
room.canonical_alias().as_ref() == Some(room_alias) ||
room.alt_aliases().contains(room_alias)
})
Copy link
Member

Choose a reason for hiding this comment

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

this is very expensive --- we cannot iterate over all rooms in the client on the main UI thread.

You deleted my comments, but those comments clearly stated what we needed to do. We do need to show a loading screen (like how I use the LoadingPane widget when looking for an old replied-to message) while waiting on a background task to resolve the room alias. This is not optional, and I left the same comment on your previous PR on this topic.

Copy link
Member

Choose a reason for hiding this comment

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

Recall that in general, we want to avoid doing as much work as possible on the main UI thread, and move as many things as possible to a background task/thread.

log!("TODO: jump to known room {}", room_id);
if let Some(known_room) = get_client().and_then(|c| c.get_room(room_id)) {
cx.widget_action(uid, &Scope::empty().path, RoomsListAction::Selected(
SelectedRoom::JoinedRoom {
Copy link
Member

Choose a reason for hiding this comment

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

how do you know the room is a Joined room here? what if it's an invite?

Comment on lines 1002 to 1003
// Only handle this action if it was requested by this widget
if *requester_uid == room_screen_widget_uid {
Copy link
Member

Choose a reason for hiding this comment

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

while it seems like a good idea to use the RoomScreen widget UID for this, we should use the Room ID instead. The reason for this is because if the user changes from Desktop to Mobile view (or simply closes the RoomScreen tab and opens it in a new tab), then the widget UID will change, so this condition will never occur.

We want any RoomScreen that is showing this room's Room ID to be able to handle this resolved room alias action.

@@ -995,6 +996,43 @@ impl Widget for RoomScreen {
);
}
}

// Handle resolved room alias actions - only for requests from this widget
if let Some(ResolveRoomAliasAction::Resolved { requester_uid, room_alias: _ , room_id, servers: _ }) = action.downcast_ref() {
Copy link
Member

Choose a reason for hiding this comment

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

you should use a match statement for all ResolveRoomAliasActions, not multiple separate if let blocks.

if let Some(known_room) = get_client().and_then(|c| c.get_room(room_id)) {
if known_room.is_space() {
enqueue_popup_notification(PopupItem {
message: format!("Found space {} but it is a space, not a regular room.", room_id),
Copy link
Member

Choose a reason for hiding this comment

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

This is fine, but the real reason that we can't do anything here is because we don't yet support showing a preview of a Space itself.

Suggested change
message: format!("Found space {} but it is a space, not a regular room.", room_id),
message: String::from("Showing a space's home page is not yet supported."),

});
} else {
cx.widget_action(room_screen_widget_uid, &scope.path, RoomsListAction::Selected(
SelectedRoom::JoinedRoom {
Copy link
Member

Choose a reason for hiding this comment

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

why are you assuming this is a joined room?

}
} else {
enqueue_popup_notification(PopupItem {
message: format!("Found room {} but you are not joined to it yet.", room_id),
Copy link
Member

Choose a reason for hiding this comment

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

i dont understand this error condition. Why is it a problem that the room hasn't been joined yet? Can't you request a preview of non-joined rooms?

(Note that my comment that you removed also mentioned this. I believe that Client::get_room_preview() will handle all of the cases here.)

Copy link
Member

Choose a reason for hiding this comment

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

The only conditions we'd want to notify the user of are:

  • an error if we cannot fetch the room preview
  • a notice if the room exists but cannot be previewed and must be joined instead

auto_dismissal_duration: Some(3.0)
});
} else {
cx.widget_action(uid, &Scope::empty().path, RoomsListAction::Selected(
Copy link
Member

Choose a reason for hiding this comment

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

you're assuming this room has been joined again.

@kevinaboos kevinaboos added waiting-on-author This issue is waiting on the original author for a response and removed waiting-on-review This issue is waiting to be reviewed labels Jul 1, 2025
@tyreseluo tyreseluo added the blocked-on-makepad Blocked on a Makepad bug or missing Makepad feature label Jul 8, 2025
@tyreseluo
Copy link
Contributor Author

Blocked on Makepad PR see: makepad/makepad#766

@tyreseluo tyreseluo removed the blocked-on-makepad Blocked on a Makepad bug or missing Makepad feature label Jul 16, 2025
@tyreseluo
Copy link
Contributor Author

tyreseluo commented Jul 16, 2025

@kevinaboos Need to update latest Makepad version, because Julian's PR about StackNavigation has been merged makepad/makepad#766, need to use something about that PR. Thanks. now i use my local latest makepad repo.

@kevinaboos
Copy link
Member

@kevinaboos Need to update latest Makepad version, because Julian's PR about StackNavigation has been merged makepad/makepad#766, need to use something about that PR. Thanks. now i use my local latest makepad repo.

Indeed, thanks for mentioning that. We have a PR already in progress that updates to the latest version of Makepad, which is #521. Once that is merged, you can proceed here.

@kevinaboos kevinaboos added the blocked Blocked on another issue or missing feature label Jul 18, 2025
@kevinaboos
Copy link
Member

Blocked on #521

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Blocked on another issue or missing feature waiting-on-author This issue is waiting on the original author for a response
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants