From a9f3aae928ad1d8ca5557b442f04dd86c1d01a28 Mon Sep 17 00:00:00 2001 From: Ralf Grubenmann Date: Thu, 22 Jan 2026 08:56:27 +0100 Subject: [PATCH] handle focus bettew between file and workload lists --- Cargo.lock | 2 +- coman/Cargo.toml | 2 +- coman/src/app/model.rs | 8 ++++++++ coman/src/components/workload_list.rs | 4 ++-- coman/src/main.rs | 20 +++++++++++++------- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fc337dd..0bfa737 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1201,7 +1201,7 @@ checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" [[package]] name = "coman" -version = "0.6.0" +version = "0.7.0" dependencies = [ "anyhow", "aws-sdk-s3", diff --git a/coman/Cargo.toml b/coman/Cargo.toml index f738936..45728c9 100644 --- a/coman/Cargo.toml +++ b/coman/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "coman" -version = "0.6.0" +version = "0.7.0" edition = "2024" description = "Compute Manager for managing HPC compute" authors = ["Ralf Grubenmann "] diff --git a/coman/src/app/model.rs b/coman/src/app/model.rs index 4bedab0..6fd3b02 100644 --- a/coman/src/app/model.rs +++ b/coman/src/app/model.rs @@ -410,6 +410,14 @@ where } fn change_view(&mut self, view: View) { self.current_view = view; + match self.current_view { + View::Workloads => { + assert!(self.app.active(&Id::WorkloadList).is_ok()); + } + View::Files => { + assert!(self.app.active(&Id::FileView).is_ok()); + } + } } } diff --git a/coman/src/components/workload_list.rs b/coman/src/components/workload_list.rs index 51ca092..1e609ac 100644 --- a/coman/src/components/workload_list.rs +++ b/coman/src/components/workload_list.rs @@ -11,7 +11,7 @@ use tuirealm::{ use crate::{ app::{ messages::{JobMsg, Msg}, - user_events::{CscsEvent, UserEvent}, + user_events::{CscsEvent, JobEvent, UserEvent}, }, cscs::api_client::types::Job, }; @@ -81,7 +81,7 @@ impl Component for WorkloadList { } self.perform(Cmd::Change) } - Event::User(UserEvent::Job(crate::app::user_events::JobEvent::Cancel)) => { + Event::User(UserEvent::Job(JobEvent::Cancel)) => { if let State::One(StateValue::Usize(index)) = self.state() && !self.jobs.is_empty() { diff --git a/coman/src/main.rs b/coman/src/main.rs index 5c5dc78..39f8b0f 100644 --- a/coman/src/main.rs +++ b/coman/src/main.rs @@ -16,7 +16,7 @@ use crate::{ ids::Id, messages::{Msg, View}, model::Model, - user_events::{CscsEvent, FileEvent, StatusEvent, UserEvent}, + user_events::{CscsEvent, FileEvent, JobEvent, StatusEvent, UserEvent}, }, cli::{ app::{ @@ -233,17 +233,23 @@ fn run_tui(tick_rate: f64) -> Result<()> { app.mount( Id::WorkloadList, Box::new(WorkloadList::default()), - vec![Sub::new( - SubEventClause::Any, - SubClause::AndMany(vec![SubClause::IsMounted(Id::WorkloadList), popup_exclusion_clause()]), - )], + vec![ + Sub::new( + SubEventClause::Discriminant(UserEvent::Cscs(CscsEvent::LoggedIn)), + SubClause::Always, + ), + Sub::new( + SubEventClause::Discriminant(UserEvent::Job(JobEvent::Cancel)), + SubClause::Always, + ), + ], )?; app.mount( Id::FileView, Box::new(FileTree::new(background_task_tx.clone())), vec![Sub::new( - SubEventClause::Any, - SubClause::AndMany(vec![SubClause::IsMounted(Id::FileView), popup_exclusion_clause()]), + SubEventClause::Discriminant(UserEvent::File(FileEvent::DownloadCurrentFile)), + SubClause::Always, )], )?; app.mount(