Skip to content

Conversation

alanpoon
Copy link
Contributor

@alanpoon alanpoon commented May 16, 2025

Unknown

Screen.Recording.2025-07-26.at.11.24.11.AM.mov

@alanpoon alanpoon requested a review from aaravlu May 16, 2025 04:31
@aaravlu aaravlu requested a review from Copilot May 16, 2025 04:54
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds support for searching messages via the Matrix Search API and integrates UI hooks for initiating and clearing searches.

  • Extends MatrixRequest with SearchMessages and implements async handling, pagination, and UI signaling
  • Updates the room filter input bar to emit click events and clears the filter when switching rooms
  • Introduces a new room_search_result module and wires it into live_design alongside related minor refactors and generics updates

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/sliding_sync.rs Implements SearchMessages request handling and task management
src/shared/room_filter_input_bar.rs Emits Click action and handles Clear in the filter bar
src/home/rooms_list.rs Adds is_room_encrypted flag and getters
src/home/room_read_receipt.rs Generalizes populate_read_receipts with Eventable
src/home/new_message_context_menu.rs Makes from_user_power_and_event generic
src/home/mod.rs Registers the new room_search_result module
src/home/main_desktop_ui.rs Clears filter input on room tab close
src/event_preview.rs Updates text_preview_of_other_state signature
Cargo.toml Pins ruma dependency for search API
Comments suppressed due to low confidence (2)

src/home/new_message_context_menu.rs:249

  • [nitpick] The _generic suffix on the function name is redundant and may be confusing. Consider renaming it back to from_user_power_and_event now that it’s generic.
pub fn from_user_power_and_event_generic<T: Eventable, M: MsgTypeAble>(

src/sliding_sync.rs:1115

  • [nitpick] There are no tests covering the new search workflow (including pagination and error paths). Consider adding unit tests or integration tests for SearchMessages handling.
MatrixRequest::SearchMessages { room_id, search_term, include_all_rooms, next_batch, abort_previous_search }

}
}
});
register_core_task(CoreTask::Search, handle.abort_handle());
Copy link
Preview

Copilot AI May 16, 2025

Choose a reason for hiding this comment

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

handle is a JoinHandle, which does not expose an abort_handle() method. You need to either store the JoinHandle itself and call abort(), or wrap the future in a cancelable AbortHandle.

Suggested change
register_core_task(CoreTask::Search, handle.abort_handle());
}, abort_registration);
let handle = Handle::current().spawn(abortable_future);
register_core_task(CoreTask::Search, abort_handle);

Copilot uses AI. Check for mistakes.

dock.close_tab(cx, tab_id);
self.tab_to_close = None;
self.open_rooms.remove(&tab_id);
cx.widget_action(self.widget_uid(), &Scope::empty().path, RoomFilterAction::Clear);
Copy link
Preview

Copilot AI May 16, 2025

Choose a reason for hiding this comment

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

[nitpick] Using Scope::empty().path may not target the filter widget correctly. You may need to reference the actual scope path where the RoomFilterInputBar lives.

Suggested change
cx.widget_action(self.widget_uid(), &Scope::empty().path, RoomFilterAction::Clear);
cx.widget_action(self.widget_uid(), &scope.path, RoomFilterAction::Clear);

Copilot uses AI. Check for mistakes.

Copy link
Contributor

@aaravlu aaravlu May 16, 2025

Choose a reason for hiding this comment

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

May be there is better to use action() if we dont want an actual Scope rather than widget_action()?

@alanpoon alanpoon changed the title Added functionality for searching messages in a room Searching messages in a room (not encrypted) May 16, 2025
@alanpoon alanpoon force-pushed the search_messages_3#122 branch from d5763a4 to ca2ca78 Compare May 19, 2025 09:31
@alanpoon alanpoon force-pushed the search_messages_3#122 branch from a88c44b to 4a7d12c Compare May 21, 2025 11:24
@alanpoon alanpoon marked this pull request as ready for review May 21, 2025 12:05
@smarizvi110
Copy link
Contributor

smarizvi110 commented May 22, 2025

MUTED_2025-05-22.18-27-24.mp4

Hi @alanpoon! This PR looks wonderful! I checked it out after your request to do so on #395 and found a few issues. The attached video walks through them (please skip to 0:19)

Firstly, the initial start up sequence looks very different from what the program looks like when cloned from the original repo's main branch. Secondly, several icons seem to be missing too. I checked out the commits ahead of your branch on project-robius/robrix:main and it doesn't seem like there was any file changed that would lead to this issue, but I could be wrong on this.

Third, the search feature itself seems to work! The only problem is that when you attempt to search all rooms while initiating a search in an encrypted room, it does not seem to search in any available unencrypted rooms either and simply tells me that searching unencrypted rooms is currently not supported. Furthermore, the little notification that tells me this seems to never go away, and just stays there in the top right corner. Perhaps that should be tweaked to disappear in a few seconds?

One last thing is that the mermaid diagram you attached to the PR here makes sense, but I don't quite understand why there are 4 edges coming out of the Check Room Encryption node. Shouldn't there just be 2, one for encrypted room searching flow and one for unencrypted room search flow? If I'm misunderstanding something, please do let me know!

For reference, the second video shows what Robrix looks like currently on project-robius/robrix:main where the icons are not missing and the startup screen looks a little more user-friendly.

Please note that in both cases, I gave Robrix my credentials through the CLI when using cargo run.

2025-05-22.18-30-28.mp4

Thank you!

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 your effort on this feature! I know it's quite complicated so I appreciate the work.

I like the new design that re-uses a lot of the RoomScreen/Message widgets and functions for the search panel. That's the right way of doing things.

I have one general question about a UI/UX design choice:
There is a lot of code scattered everywhere that seemingly exists only to hide the message search view when a room is deselected. Why? I don't think we should do that. You can make the code a lot simpler by always showing the search view, and making it default to searching only the current room (if one is selected/focused) or all rooms if none are selected.

I didn't exhaustively test everything yet. Before I do so, kindly ensure you have tested it thoroughly.

Also, please clean up and polish the UI a bit. The spacing of items looks a little bit messy/unprofessional. Keep in mind that we want Robrix to serve as the flagship example of a complex Makepad app, so it's important to spend the extra time to make the UI as perfect & beautiful as we can.

src/app.rs Outdated
&Scope::default().path,
StackNavigationAction::Push(live_id!(main_content_view))
);
self.ui.view(id!(message_search_input_view)).set_visible(cx, true);
Copy link
Member

Choose a reason for hiding this comment

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

for this (and the other two places where you call set_visible() on message_search_input_view), we ideally should not query and access/modify views or states that are far outside of the bounds of the current widget/module. That violates separation of concerns and typical best practices surrounding abstraction layers.

Instead, you should access the message_search_input_view within the widget/module code where it is defined (or its immediate parent). You can do this in one of two ways:

  1. By creating a new actions (e.g., MessageSearchInputAction::Show/Hide) and emitting the appropriate action here.
  2. By directly handling the existing actions (RoomsListAction::Selected, AppStateAction::RoomFocused/FocusNone) within the other widget or its parent.

In my opinion, #1 is much better because it is much more clear about expressing the intent of the action.

Copy link
Contributor Author

@alanpoon alanpoon Aug 12, 2025

Choose a reason for hiding this comment

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

Fixed. Previously Homescreen was just a view and couldn't handle action.

Comment on lines 65 to 74
message_search_input_view = <View> {
width: Fill, height: Fit,
visible: false,
align: {x: 1.0},
<CachedWidget> {
message_search_input_bar = <MessageSearchInputBar> {
width: 300,
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

don't we want the outer message_search_input_view to be the CachedWidget itself, instead of the inner message_search_input_bar? That way, the visibility state (whether it is currently visible) will automatically be preserved across changes in AdaptiveView from Mobile <--> Desktop.

I think that would simplify a lot of the code too. If you tried that already and it didn't work, or there is some other reason why that design is not desirable, please let me know.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The cachedWidget also cached the width of the width, causing a singleton for the width. I want the search input bar to display shorter in the mobile mode. So there is an extra view wrapper for that. Also the cached visibility is not useful as the search input bar should always appear at the room screen stack navigation view. While in the desktop, search input bar should not appear in the welcome screen.

Comment on lines 1031 to 1032
index.saturating_sub(2),
index.saturating_sub(2).abs_diff(current_first_index) as f64 / SMOOTH_SCROLL_TIME,
Copy link
Member

Choose a reason for hiding this comment

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

unfortunately you cannot do this. I tried to do the same thing in some earlier code, and it breaks the smooth scroll functionality if any of the earlier messages (index-1 or index-2) are really long. You won't be able to see the target message at index if those messages are long enough to push it off-screen.

Copy link
Contributor Author

@alanpoon alanpoon Aug 12, 2025

Choose a reason for hiding this comment

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

Changed to index.saturating_sub(1)

}
}
items.push_back(right_panel::search_message::SearchResultItem::Event{ event:
Box::new(event), formatted_content: Box::new(message_option)}
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 we boxing up these two states?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Clippy warns of large_enum_variant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change to using Arc

Comment on lines 1159 to 1161
room_id,
search_term,
include_all_rooms,
Copy link
Member

Choose a reason for hiding this comment

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

I think this request should just directly accept the v3::Criteria type. All you're doing here is using 3 separate states (room ID, search keyword, and include all rooms boolean) to act as a worse version of the Criteria struct.

The UI should be responsible for creating the Criteria struct and passing it to this request handler background task. That offers two benefits:

  1. The UI can easily support more advanced criteria (both now, or in the future) without needing to change the backend.
  2. This task doesn't have to concern itself with configuring the search criteria properly.

You can keep the room_id for the sake of convenience (for now), since we only support searching either one room or all rooms.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed self created Criteria struct.

@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 Aug 11, 2025
@alanpoon alanpoon force-pushed the search_messages_3#122 branch from 130952f to da4c301 Compare August 20, 2025 03:06
@alanpoon alanpoon force-pushed the search_messages_3#122 branch from 4f5552d to bef4f9b Compare August 22, 2025 09:21
@alanpoon alanpoon force-pushed the search_messages_3#122 branch from bef4f9b to 8144a44 Compare August 26, 2025 13:14
@alanpoon alanpoon force-pushed the search_messages_3#122 branch from 9f40f3c to e541b3e Compare August 27, 2025 05:58
@alanpoon alanpoon added waiting-on-review This issue is waiting to be reviewed and removed waiting-on-author This issue is waiting on the original author for a response labels Aug 27, 2025
@alanpoon
Copy link
Contributor Author

@smarizvi110 Hi, Could you also help to test this search feature? Search result is now being displayed at the right drawer.

@alanpoon alanpoon 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 Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

5 participants