[pdm-devel] [PATCH datacenter-manager] ui: main/main menu: fix handling of remote list cache

Wolfgang Bumiller w.bumiller at proxmox.com
Wed Sep 10 13:01:17 CEST 2025


On Wed, Sep 10, 2025 at 10:26:44AM +0200, Dominik Csapak wrote:
> Commit
> 0f84394 (ui: main menu: use initial remote list value from context)
> tried to handle the initial value of the RemoteList context.
> 
> While this fixed one race (loading of the remote list finished before
> the main menu was created) it introduced another race: if the load now
> takes longer than the creation, we'll overwrite the PersistentState
> (browser local storage) once with an empty list and once with the
> correct one. This leads to a refresh not keeping the route since at that
> time the route does not exists (since the remotelist is empty)
> 
> To properly fix this, we have to couple the remote list update with the
> cache update, as that is the only point in time where we want to do
> that.
> 
> For this we have to move the cache update logic to the main entrypoint
> (where we update the RemoteList context too) and give the main menu the
> list as a a property (from the cache). This way the main menu always has
> the view from the cache and this get's updated on every successful api
> call to update the remote list.
> 
> We still keep the remotelist context around, since other panels deeper
> might need it to query information (e.g. the RemoteSelector)
> 
> Fixes: 0f84394 (ui: main menu: use initial remote list value from context)
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  ui/src/lib.rs       | 11 ++++++++-
>  ui/src/main.rs      | 38 +++++++++++++++++++++++------
>  ui/src/main_menu.rs | 58 ++++++++++-----------------------------------
>  3 files changed, 53 insertions(+), 54 deletions(-)
> 
> diff --git a/ui/src/lib.rs b/ui/src/lib.rs
> index 37e6458..3628f41 100644
> --- a/ui/src/lib.rs
> +++ b/ui/src/lib.rs
> @@ -1,4 +1,7 @@
> -use pdm_api_types::resource::{PveLxcResource, PveQemuResource};
> +use pdm_api_types::{
> +    remotes::RemoteType,
> +    resource::{PveLxcResource, PveQemuResource},
> +};
>  use pdm_client::types::Resource;
>  use serde::{Deserialize, Serialize};
>  

Just a general note - can we please avoid multi-level braced import
lists in general? They make a lot more merge conflicts.

*IDEALLY* we'd use import-granularity="Item" style import lists, which,
I get, is annoying to do manually, and the option is not sable... but
let's not make it even worse? :S




More information about the pdm-devel mailing list