Compare commits

..

2 Commits

Author SHA1 Message Date
a847674004 Remove service restart functionality and make R always rebuild host
All checks were successful
Build and Release / build-and-release (push) Successful in 2m6s
Simplified keyboard controls by removing service restart functionality:

- Removed 'r' key restart functionality from Services panel
- Made 'R' key always trigger system rebuild regardless of focused panel
- Updated context shortcuts to show 'R: Rebuild Host' globally
- Removed all ServiceRestart enum variants and associated code:
  - UiCommand::ServiceRestart
  - CommandType::ServiceRestart
  - ServiceAction::Restart
- Cleaned up pending transition logic to only handle Start/Stop commands

The 'R' key now consistently rebuilds the current host from any panel,
while 's' and 'S' continue to handle service start/stop in Services panel.
2025-10-28 15:26:15 +01:00
2618f6b62f Fix transitional icons and selection highlighting visibility
All checks were successful
Build and Release / build-and-release (push) Successful in 1m15s
Resolved issues with transitional service icons not being properly visible:

- Removed 3-second timeout that was clearing pending transitions prematurely
- Fixed selection highlighting disappearing when transitional icons appeared
- Implemented conditional coloring for transitional icons:
  - Blue when service is not selected
  - Dark background color when service is selected (for visibility against blue selection)
- Transitions now persist until actual service status changes occur

Both selection highlighting and transitional icons are now visible simultaneously.
2025-10-28 15:14:49 +01:00
11 changed files with 41 additions and 70 deletions

6
Cargo.lock generated
View File

@@ -270,7 +270,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
[[package]] [[package]]
name = "cm-dashboard" name = "cm-dashboard"
version = "0.1.27" version = "0.1.29"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono", "chrono",
@@ -291,7 +291,7 @@ dependencies = [
[[package]] [[package]]
name = "cm-dashboard-agent" name = "cm-dashboard-agent"
version = "0.1.27" version = "0.1.29"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@@ -314,7 +314,7 @@ dependencies = [
[[package]] [[package]]
name = "cm-dashboard-shared" name = "cm-dashboard-shared"
version = "0.1.27" version = "0.1.29"
dependencies = [ dependencies = [
"chrono", "chrono",
"serde", "serde",

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "cm-dashboard-agent" name = "cm-dashboard-agent"
version = "0.1.28" version = "0.1.30"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View File

@@ -274,7 +274,6 @@ impl Agent {
let action_str = match action { let action_str = match action {
ServiceAction::Start => "start", ServiceAction::Start => "start",
ServiceAction::Stop => "stop", ServiceAction::Stop => "stop",
ServiceAction::Restart => "restart",
ServiceAction::Status => "status", ServiceAction::Status => "status",
}; };
@@ -299,7 +298,7 @@ impl Agent {
} }
// Force refresh metrics after service control to update service status // Force refresh metrics after service control to update service status
if matches!(action, ServiceAction::Start | ServiceAction::Stop | ServiceAction::Restart) { if matches!(action, ServiceAction::Start | ServiceAction::Stop) {
info!("Triggering immediate metric refresh after service control"); info!("Triggering immediate metric refresh after service control");
if let Err(e) = self.collect_metrics_only().await { if let Err(e) = self.collect_metrics_only().await {
error!("Failed to refresh metrics after service control: {}", e); error!("Failed to refresh metrics after service control: {}", e);

View File

@@ -112,6 +112,5 @@ pub enum AgentCommand {
pub enum ServiceAction { pub enum ServiceAction {
Start, Start,
Stop, Stop,
Restart,
Status, Status,
} }

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "cm-dashboard" name = "cm-dashboard"
version = "0.1.28" version = "0.1.30"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View File

@@ -294,14 +294,6 @@ impl Dashboard {
/// Execute a UI command by sending it to the appropriate agent /// Execute a UI command by sending it to the appropriate agent
async fn execute_ui_command(&self, command: UiCommand) -> Result<()> { async fn execute_ui_command(&self, command: UiCommand) -> Result<()> {
match command { match command {
UiCommand::ServiceRestart { hostname, service_name } => {
info!("Sending restart command for service {} on {}", service_name, hostname);
let agent_command = AgentCommand::ServiceControl {
service_name,
action: ServiceAction::Restart,
};
self.zmq_command_sender.send_command(&hostname, agent_command).await?;
}
UiCommand::ServiceStart { hostname, service_name } => { UiCommand::ServiceStart { hostname, service_name } => {
info!("Sending start command for service {} on {}", service_name, hostname); info!("Sending start command for service {} on {}", service_name, hostname);
let agent_command = AgentCommand::ServiceControl { let agent_command = AgentCommand::ServiceControl {

View File

@@ -35,7 +35,6 @@ pub enum AgentCommand {
pub enum ServiceAction { pub enum ServiceAction {
Start, Start,
Stop, Stop,
Restart,
Status, Status,
} }

View File

@@ -14,7 +14,7 @@ use app::Dashboard;
/// Get hardcoded version /// Get hardcoded version
fn get_version() -> &'static str { fn get_version() -> &'static str {
"v0.1.28" "v0.1.30"
} }
/// Check if running inside tmux session /// Check if running inside tmux session

View File

@@ -22,7 +22,6 @@ use widgets::{BackupWidget, ServicesWidget, SystemWidget, Widget};
/// Commands that can be triggered from the UI /// Commands that can be triggered from the UI
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum UiCommand { pub enum UiCommand {
ServiceRestart { hostname: String, service_name: String },
ServiceStart { hostname: String, service_name: String }, ServiceStart { hostname: String, service_name: String },
ServiceStop { hostname: String, service_name: String }, ServiceStop { hostname: String, service_name: String },
TriggerBackup { hostname: String }, TriggerBackup { hostname: String },
@@ -32,7 +31,6 @@ pub enum UiCommand {
/// Types of commands for status tracking /// Types of commands for status tracking
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum CommandType { pub enum CommandType {
ServiceRestart,
ServiceStart, ServiceStart,
ServiceStop, ServiceStop,
BackupTrigger, BackupTrigger,
@@ -256,35 +254,20 @@ impl TuiApp {
self.navigate_host(1); self.navigate_host(1);
} }
KeyCode::Char('r') => { KeyCode::Char('r') => {
match self.focused_panel { // System rebuild command - works on any panel for current host
PanelType::System => { if let Some(hostname) = self.current_host.clone() {
// Simple tmux popup with SSH rebuild using configured user and alias // Launch tmux popup with SSH using config values
if let Some(hostname) = self.current_host.clone() { let ssh_command = format!(
// Launch tmux popup with SSH using config values "ssh -tt {}@{} 'bash -ic {}'",
let ssh_command = format!( self.config.ssh.rebuild_user,
"ssh -tt {}@{} 'bash -ic {}'", hostname,
self.config.ssh.rebuild_user, self.config.ssh.rebuild_alias
hostname, );
self.config.ssh.rebuild_alias std::process::Command::new("tmux")
); .arg("display-popup")
std::process::Command::new("tmux") .arg(&ssh_command)
.arg("display-popup") .spawn()
.arg(&ssh_command) .ok(); // Ignore errors, tmux will handle them
.spawn()
.ok(); // Ignore errors, tmux will handle them
}
}
PanelType::Services => {
// Service restart command
if let (Some(service_name), Some(hostname)) = (self.get_selected_service(), self.current_host.clone()) {
if self.start_command(&hostname, CommandType::ServiceRestart, service_name.clone()) {
return Ok(Some(UiCommand::ServiceRestart { hostname, service_name }));
}
}
}
_ => {
info!("Manual refresh requested");
}
} }
} }
KeyCode::Char('s') => { KeyCode::Char('s') => {
@@ -431,7 +414,6 @@ impl TuiApp {
let should_execute = match (&command_type, current_status.as_deref()) { let should_execute = match (&command_type, current_status.as_deref()) {
(CommandType::ServiceStart, Some("inactive") | Some("failed") | Some("dead")) => true, (CommandType::ServiceStart, Some("inactive") | Some("failed") | Some("dead")) => true,
(CommandType::ServiceStop, Some("active")) => true, (CommandType::ServiceStop, Some("active")) => true,
(CommandType::ServiceRestart, Some("active") | Some("inactive") | Some("failed") | Some("dead")) => true,
(CommandType::ServiceStart, Some("active")) => { (CommandType::ServiceStart, Some("active")) => {
// Already running - don't execute // Already running - don't execute
false false
@@ -462,15 +444,9 @@ impl TuiApp {
fn clear_completed_transitions(&mut self, hostname: &str, service_metrics: &[&Metric]) { fn clear_completed_transitions(&mut self, hostname: &str, service_metrics: &[&Metric]) {
if let Some(host_widgets) = self.host_widgets.get_mut(hostname) { if let Some(host_widgets) = self.host_widgets.get_mut(hostname) {
let mut completed_services = Vec::new(); let mut completed_services = Vec::new();
let now = Instant::now();
// Check each pending transition to see if real status has changed or timed out // Check each pending transition to see if real status has changed
for (service_name, (command_type, original_status, start_time)) in &host_widgets.pending_service_transitions { for (service_name, (command_type, original_status, _start_time)) in &host_widgets.pending_service_transitions {
// Clear if too much time has passed (3 seconds for redundant commands)
if now.duration_since(*start_time).as_secs() > 3 {
completed_services.push(service_name.clone());
continue;
}
// Look for status metric for this service // Look for status metric for this service
for metric in service_metrics { for metric in service_metrics {
@@ -483,7 +459,6 @@ impl TuiApp {
let expected_change = match command_type { let expected_change = match command_type {
CommandType::ServiceStart => &new_status == "active", CommandType::ServiceStart => &new_status == "active",
CommandType::ServiceStop => &new_status != "active", CommandType::ServiceStop => &new_status != "active",
CommandType::ServiceRestart => true, // Any change indicates restart completed
_ => false, _ => false,
}; };
@@ -760,19 +735,19 @@ impl TuiApp {
// Scroll shortcuts (always available) // Scroll shortcuts (always available)
shortcuts.push("↑↓: Scroll".to_string()); shortcuts.push("↑↓: Scroll".to_string());
// Global rebuild shortcut (works on any panel)
shortcuts.push("R: Rebuild Host".to_string());
// Panel-specific shortcuts // Panel-specific shortcuts
match self.focused_panel { match self.focused_panel {
PanelType::System => {
shortcuts.push("R: Rebuild".to_string());
}
PanelType::Services => { PanelType::Services => {
shortcuts.push("S: Start".to_string()); shortcuts.push("S: Start".to_string());
shortcuts.push("Shift+S: Stop".to_string()); shortcuts.push("Shift+S: Stop".to_string());
shortcuts.push("R: Restart".to_string());
} }
PanelType::Backup => { PanelType::Backup => {
shortcuts.push("B: Trigger Backup".to_string()); shortcuts.push("B: Trigger Backup".to_string());
} }
_ => {}
} }
// Always show quit // Always show quit

View File

@@ -134,7 +134,6 @@ impl ServicesWidget {
if let Some((command_type, _original_status, _start_time)) = pending_transitions.get(service_name) { if let Some((command_type, _original_status, _start_time)) = pending_transitions.get(service_name) {
// Show transitional icons for pending commands // Show transitional icons for pending commands
let (icon, status_text) = match command_type { let (icon, status_text) = match command_type {
CommandType::ServiceRestart => ("", "restarting"),
CommandType::ServiceStart => ("", "starting"), CommandType::ServiceStart => ("", "starting"),
CommandType::ServiceStop => ("", "stopping"), CommandType::ServiceStop => ("", "stopping"),
_ => return (StatusIcons::get_icon(info.widget_status).to_string(), info.status.clone(), Theme::status_color(info.widget_status)), // Not a service command _ => return (StatusIcons::get_icon(info.widget_status).to_string(), info.status.clone(), Theme::status_color(info.widget_status)), // Not a service command
@@ -559,17 +558,25 @@ impl ServicesWidget {
// Parent services - check if this parent service has a pending transition using RAW service name // Parent services - check if this parent service has a pending transition using RAW service name
if pending_transitions.contains_key(raw_service_name) { if pending_transitions.contains_key(raw_service_name) {
// Create spans with transitional status // Create spans with transitional status
let (icon, status_text, status_color) = self.get_service_icon_and_status(raw_service_name, &ServiceInfo { let (icon, status_text, _) = self.get_service_icon_and_status(raw_service_name, &ServiceInfo {
status: "".to_string(), status: "".to_string(),
memory_mb: None, memory_mb: None,
disk_gb: None, disk_gb: None,
latency_ms: None, latency_ms: None,
widget_status: *line_status widget_status: *line_status
}, pending_transitions); }, pending_transitions);
// Use blue for transitional icons when not selected, background color when selected
let icon_color = if is_selected && !*is_sub && is_focused {
Theme::background() // Dark background color for visibility against blue selection
} else {
Theme::highlight() // Blue for normal case
};
vec![ vec![
ratatui::text::Span::styled(format!("{} ", icon), Style::default().fg(status_color)), ratatui::text::Span::styled(format!("{} ", icon), Style::default().fg(icon_color)),
ratatui::text::Span::styled(line_text.clone(), Style::default().fg(Theme::primary_text())), ratatui::text::Span::styled(line_text.clone(), Style::default().fg(Theme::primary_text())),
ratatui::text::Span::styled(format!(" {}", status_text), Style::default().fg(status_color)), ratatui::text::Span::styled(format!(" {}", status_text), Style::default().fg(icon_color)),
] ]
} else { } else {
StatusIcons::create_status_spans(*line_status, line_text) StatusIcons::create_status_spans(*line_status, line_text)
@@ -578,8 +585,8 @@ impl ServicesWidget {
// Apply selection highlighting to parent services only, preserving status icon color // Apply selection highlighting to parent services only, preserving status icon color
// Only show selection when Services panel is focused // Only show selection when Services panel is focused
// IMPORTANT: Don't override transitional icons that show pending commands // Show selection highlighting even when transitional icons are present
if is_selected && !*is_sub && is_focused && !pending_transitions.contains_key(raw_service_name) { if is_selected && !*is_sub && is_focused {
for (i, span) in spans.iter_mut().enumerate() { for (i, span) in spans.iter_mut().enumerate() {
if i == 0 { if i == 0 {
// First span is the status icon - preserve its color // First span is the status icon - preserve its color

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "cm-dashboard-shared" name = "cm-dashboard-shared"
version = "0.1.28" version = "0.1.30"
edition = "2021" edition = "2021"
[dependencies] [dependencies]