Skip to content

Save and restore the dock's display state from persistent storage #422

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 58 commits into
base: main
Choose a base branch
from

Conversation

alanpoon
Copy link
Contributor

@alanpoon alanpoon commented Mar 5, 2025

Fixes #414

Screen.Recording.2025-03-12.at.1.21.32.PM.mov
  • Save the layout when the Desktop UI view is being hidden, e.g., due to a resize event. (Save the UI layout when transitioning from Desktop --> Mobile layout #251)
  • Preserve the proportional size of each pane in the dock.
    If the user has resized a dock pane by dragging the splitter, that is currently not preserved.
  • When the user closes/exits the Robrix app, we should save the layout to the persistent settings on disk. Then, we can restore that saved layout automatically upon the next time the user re-opens Robrix.
    This can also be offered as a preference/setting in the settings pane, once that is implement.
  • [] Future Save the layout on demand (a future feature), such that the user can store a list of "favorite" layouts that they can easily switch between, on demand.

I have also explored saving and restoring the window dimension. Currently makepad does not have a solution resize the window dynamically.

@alanpoon alanpoon marked this pull request as ready for review March 12, 2025 05:28
@alanpoon alanpoon added the waiting-on-review This issue is waiting to be reviewed label Mar 12, 2025
@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 Mar 12, 2025
@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 Mar 14, 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.

a few nits about naming clarity:

  • The word "prompt" should be something like "notice" instead, since a prompt implies that we're asking the user to input some info. But really, we're just showing the user a notice that something is happening in the background.
  • Similarly, the word "timeout" should be replaced with "failure"/"failed"/"error", since timing out is just one potential error that could occur when loading a room.

See my other comments about how to potentially redesign the action handling logic for Pending, Success, and Timeout.

@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 Mar 20, 2025
@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 Mar 27, 2025
@alanpoon alanpoon 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 blocked-on-makepad Blocked on a Makepad bug or missing Makepad feature 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 Apr 14, 2025
@kevinaboos
Copy link
Member

@alanpoon is this blocked on makepad/makepad#711?

@alanpoon
Copy link
Contributor Author

@alanpoon is this blocked on makepad/makepad#711?

Yes

@alanpoon alanpoon added blocked-on-makepad Blocked on a Makepad bug or missing Makepad feature and removed waiting-on-review This issue is waiting to be reviewed labels Apr 15, 2025
src/app.rs Outdated
/// it should show the room's timeline and hide its `Pending` message.
/// 2. When changing from the desktop to mobile view, we want to ensure that
/// all newly-restored rooms that were loaded in the background are properly displayed.
pub all_known_rooms_loaded: bool,
Copy link
Contributor Author

@alanpoon alanpoon Apr 25, 2025

Choose a reason for hiding this comment

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

use cached widget rooms_list

@alanpoon alanpoon force-pushed the save_ui_persistent#414 branch from dad1373 to fc29024 Compare April 28, 2025 02:48
@alanpoon alanpoon force-pushed the save_ui_persistent#414 branch from 4a19157 to 88252db Compare April 28, 2025 07:05
@alanpoon
Copy link
Contributor Author

Waiting for this PR to enhancement to Makepad makepad/makepad#726

@alanpoon alanpoon force-pushed the save_ui_persistent#414 branch from 8e19eeb to 35ab460 Compare May 20, 2025 04:57
@alanpoon alanpoon removed the blocked-on-makepad Blocked on a Makepad bug or missing Makepad feature label May 20, 2025
@alanpoon alanpoon force-pushed the save_ui_persistent#414 branch from 0e23051 to 480813f Compare May 20, 2025 09:28
@aaravlu aaravlu requested a review from Copilot May 20, 2025 12:08
Copy link

@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

This PR introduces the functionality to persist and restore the dock's and window's layout state in the application. The changes save the layout when the UI view is hidden and upon app shutdown and then restore these states on startup. Key changes include:

  • Adding functions to load and restore the rooms panel and window geometry state.
  • Enhancing UI components (RoomScreen, MainDesktopUI, etc.) to handle state restoration.
  • Modifying persistent state management by introducing new serialization routines for the restored types.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/sliding_sync.rs Added asynchronous functions to load and restore panel/window state.
src/persistent_state.rs Introduced save/load functions for dock and window state.
src/home/rooms_list.rs Added helper methods to check room loading status.
src/home/room_screen.rs Updated logic to check room state and handle restoration actions.
src/home/main_desktop_ui.rs Updated UI logic to trigger dock state restoration on first draw.
src/app.rs Integrated persistent state saving on shutdown and state restoration actions.
Comments suppressed due to low confidence (1)

src/home/main_desktop_ui.rs:373

  • Consider revising this error message to provide clearer context about the failure and removing the 'BUG' prefix, as it may be confusing in production logs.
error!("BUG: failed to load dock state upon DockLoad action.");

// Obtain the current user's power levels for this room.
submit_async_request(MatrixRequest::GetRoomPowerLevels { room_id: room_id.clone() });

let state_opt = TIMELINE_STATES.lock().unwrap().remove(&room_id);
let (mut tl_state, first_time_showing_room) = if let Some(existing) = state_opt {
(existing, false)
} else {
let (update_sender, update_receiver, request_sender) = take_timeline_endpoints(&room_id)
.expect("BUG: couldn't get timeline state for first-viewed room.");
let Some((update_sender, update_receiver, request_sender)) = take_timeline_endpoints(&room_id) else {
Copy link
Preview

Copilot AI May 20, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider logging a warning when timeline endpoints are not available instead of silently returning, to help diagnose issues during the first view of a room.

Suggested change
let Some((update_sender, update_receiver, request_sender)) = take_timeline_endpoints(&room_id) else {
let Some((update_sender, update_receiver, request_sender)) = take_timeline_endpoints(&room_id) else {
warn!("Timeline endpoints are not available for room_id: {}", room_id);

Copilot uses AI. Check for mistakes.

Co-authored-by: Copilot <[email protected]>
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.

Tracking issue for dock save/restore improvements
2 participants