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.
This commit is contained in:
2025-10-28 15:26:15 +01:00
parent 2618f6b62f
commit a847674004
11 changed files with 26 additions and 57 deletions

View File

@@ -22,7 +22,6 @@ use widgets::{BackupWidget, ServicesWidget, SystemWidget, Widget};
/// Commands that can be triggered from the UI
#[derive(Debug, Clone)]
pub enum UiCommand {
ServiceRestart { hostname: String, service_name: String },
ServiceStart { hostname: String, service_name: String },
ServiceStop { hostname: String, service_name: String },
TriggerBackup { hostname: String },
@@ -32,7 +31,6 @@ pub enum UiCommand {
/// Types of commands for status tracking
#[derive(Debug, Clone)]
pub enum CommandType {
ServiceRestart,
ServiceStart,
ServiceStop,
BackupTrigger,
@@ -256,35 +254,20 @@ impl TuiApp {
self.navigate_host(1);
}
KeyCode::Char('r') => {
match self.focused_panel {
PanelType::System => {
// Simple tmux popup with SSH rebuild using configured user and alias
if let Some(hostname) = self.current_host.clone() {
// Launch tmux popup with SSH using config values
let ssh_command = format!(
"ssh -tt {}@{} 'bash -ic {}'",
self.config.ssh.rebuild_user,
hostname,
self.config.ssh.rebuild_alias
);
std::process::Command::new("tmux")
.arg("display-popup")
.arg(&ssh_command)
.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");
}
// System rebuild command - works on any panel for current host
if let Some(hostname) = self.current_host.clone() {
// Launch tmux popup with SSH using config values
let ssh_command = format!(
"ssh -tt {}@{} 'bash -ic {}'",
self.config.ssh.rebuild_user,
hostname,
self.config.ssh.rebuild_alias
);
std::process::Command::new("tmux")
.arg("display-popup")
.arg(&ssh_command)
.spawn()
.ok(); // Ignore errors, tmux will handle them
}
}
KeyCode::Char('s') => {
@@ -431,7 +414,6 @@ impl TuiApp {
let should_execute = match (&command_type, current_status.as_deref()) {
(CommandType::ServiceStart, Some("inactive") | Some("failed") | Some("dead")) => true,
(CommandType::ServiceStop, Some("active")) => true,
(CommandType::ServiceRestart, Some("active") | Some("inactive") | Some("failed") | Some("dead")) => true,
(CommandType::ServiceStart, Some("active")) => {
// Already running - don't execute
false
@@ -477,7 +459,6 @@ impl TuiApp {
let expected_change = match command_type {
CommandType::ServiceStart => &new_status == "active",
CommandType::ServiceStop => &new_status != "active",
CommandType::ServiceRestart => true, // Any change indicates restart completed
_ => false,
};
@@ -754,19 +735,19 @@ impl TuiApp {
// Scroll shortcuts (always available)
shortcuts.push("↑↓: Scroll".to_string());
// Global rebuild shortcut (works on any panel)
shortcuts.push("R: Rebuild Host".to_string());
// Panel-specific shortcuts
match self.focused_panel {
PanelType::System => {
shortcuts.push("R: Rebuild".to_string());
}
PanelType::Services => {
shortcuts.push("S: Start".to_string());
shortcuts.push("Shift+S: Stop".to_string());
shortcuts.push("R: Restart".to_string());
}
PanelType::Backup => {
shortcuts.push("B: Trigger Backup".to_string());
}
_ => {}
}
// Always show quit