diff --git a/Cargo.lock b/Cargo.lock index e83c35a..e4428ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -270,7 +270,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.43" +version = "0.1.44" dependencies = [ "anyhow", "chrono", @@ -291,7 +291,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.43" +version = "0.1.44" dependencies = [ "anyhow", "async-trait", @@ -314,7 +314,7 @@ dependencies = [ [[package]] name = "cm-dashboard-shared" -version = "0.1.43" +version = "0.1.44" dependencies = [ "chrono", "serde", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index 6127f4a..1f09651 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.44" +version = "0.1.45" edition = "2021" [dependencies] diff --git a/agent/src/agent.rs b/agent/src/agent.rs index 66f57a3..526f4dc 100644 --- a/agent/src/agent.rs +++ b/agent/src/agent.rs @@ -288,7 +288,7 @@ impl Agent { info!("Executing systemctl {} {} (user action: {})", action_str, service_name, is_user_action); - // Handle user-stopped service tracking before systemctl execution + // Handle user-stopped service tracking before systemctl execution (stop only) match action { ServiceAction::UserStop => { info!("Marking service '{}' as user-stopped", service_name); @@ -299,15 +299,6 @@ impl Agent { UserStoppedServiceTracker::update_global(&self.service_tracker); } } - ServiceAction::UserStart => { - info!("Clearing user-stopped flag for service '{}'", service_name); - if let Err(e) = self.service_tracker.clear_user_stopped(service_name) { - error!("Failed to clear user-stopped flag: {}", e); - } else { - // Sync to global tracker - UserStoppedServiceTracker::update_global(&self.service_tracker); - } - } _ => {} } @@ -323,6 +314,17 @@ impl Agent { if !output.stdout.is_empty() { debug!("stdout: {}", String::from_utf8_lossy(&output.stdout)); } + + // Clear user-stopped flag AFTER successful start command + if matches!(action, ServiceAction::UserStart) { + info!("Clearing user-stopped flag for service '{}' after successful start", service_name); + if let Err(e) = self.service_tracker.clear_user_stopped(service_name) { + error!("Failed to clear user-stopped flag: {}", e); + } else { + // Sync to global tracker + UserStoppedServiceTracker::update_global(&self.service_tracker); + } + } } else { let stderr = String::from_utf8_lossy(&output.stderr); error!("Service {} {} failed: {}", service_name, action_str, stderr); diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index 723f3b3..5d98112 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.44" +version = "0.1.45" edition = "2021" [dependencies] diff --git a/dashboard/src/ui/widgets/services.rs b/dashboard/src/ui/widgets/services.rs index bf15781..463b35f 100644 --- a/dashboard/src/ui/widgets/services.rs +++ b/dashboard/src/ui/widgets/services.rs @@ -113,13 +113,10 @@ impl ServicesWidget { name.to_string() }; - // Parent services always show active/inactive status + // Parent services always show actual systemctl status let status_str = match info.widget_status { - Status::Ok => "active".to_string(), Status::Pending => "pending".to_string(), - Status::Warning => "inactive".to_string(), - Status::Critical => "failed".to_string(), - Status::Unknown => "unknown".to_string(), + _ => info.status.clone(), // Use actual status from agent (active/inactive/failed) }; format!( diff --git a/shared/Cargo.toml b/shared/Cargo.toml index c153067..eee5899 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.44" +version = "0.1.45" edition = "2021" [dependencies]