Replace tmux popups with split windows for better log navigation
Some checks failed
Build and Release / build-and-release (push) Failing after 1m9s

- Change J/L log commands from popups to split windows for scrolling support
- Change rebuild command from popup to split window with consistent 30% height
- Add auto-close behavior with bash -c "command; exit" wrapper for logs
- Add "press any key to close" prompt with visual separators for rebuild
- Enable proper tmux copy mode and navigation in all split windows

Users can now scroll through logs, copy text, and resize windows while
maintaining clean auto-close behavior for all operations.
This commit is contained in:
Christoffer Martinsson 2025-10-30 15:30:58 +01:00
parent 6fedf4c7fc
commit e4469a0ebf
5 changed files with 31 additions and 32 deletions

6
Cargo.lock generated
View File

@ -270,7 +270,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
[[package]] [[package]]
name = "cm-dashboard" name = "cm-dashboard"
version = "0.1.50" version = "0.1.51"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono", "chrono",
@ -291,7 +291,7 @@ dependencies = [
[[package]] [[package]]
name = "cm-dashboard-agent" name = "cm-dashboard-agent"
version = "0.1.50" version = "0.1.51"
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.50" version = "0.1.51"
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.51" version = "0.1.52"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

View File

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

View File

@ -244,14 +244,20 @@ impl TuiApp {
KeyCode::Char('r') => { KeyCode::Char('r') => {
// System rebuild command - works on any panel for current host // System rebuild command - works on any panel for current host
if let Some(hostname) = self.current_host.clone() { if let Some(hostname) = self.current_host.clone() {
// Create command that shows CM Dashboard logo and then rebuilds // Create command that shows logo, rebuilds, and waits for user input
let logo_and_rebuild = format!( let logo_and_rebuild = format!(
r"cat << 'EOF' r"bash -c 'cat << \"EOF\"
NixOS System Rebuild NixOS System Rebuild
Target: {} Target: {}
EOF EOF
ssh -tt {}@{} 'bash -ic {}'", ssh -tt {}@{} \"bash -ic {}\"
echo
echo \"========================================\"
echo \"Rebuild completed. Press any key to close...\"
echo \"========================================\"
read -n 1 -s
exit'",
hostname, hostname,
self.config.ssh.rebuild_user, self.config.ssh.rebuild_user,
hostname, hostname,
@ -259,11 +265,10 @@ ssh -tt {}@{} 'bash -ic {}'",
); );
std::process::Command::new("tmux") std::process::Command::new("tmux")
.arg("display-popup") .arg("split-window")
.arg("-w") .arg("-v")
.arg("80%") .arg("-p")
.arg("-h") .arg("30")
.arg("80%")
.arg(&logo_and_rebuild) .arg(&logo_and_rebuild)
.spawn() .spawn()
.ok(); // Ignore errors, tmux will handle them .ok(); // Ignore errors, tmux will handle them
@ -286,49 +291,43 @@ ssh -tt {}@{} 'bash -ic {}'",
} }
} }
KeyCode::Char('J') => { KeyCode::Char('J') => {
// Show service logs via journalctl in tmux popup // Show service logs via journalctl in tmux split window
if let (Some(service_name), Some(hostname)) = (self.get_selected_service(), self.current_host.clone()) { if let (Some(service_name), Some(hostname)) = (self.get_selected_service(), self.current_host.clone()) {
let journalctl_command = format!( let journalctl_command = format!(
"ssh -tt {}@{} 'sudo journalctl -u {}.service -f --no-pager -n 50'", "bash -c \"ssh -tt {}@{} 'sudo journalctl -u {}.service -f --no-pager -n 50'; exit\"",
self.config.ssh.rebuild_user, self.config.ssh.rebuild_user,
hostname, hostname,
service_name service_name
); );
std::process::Command::new("tmux") std::process::Command::new("tmux")
.arg("display-popup") .arg("split-window")
.arg("-w") .arg("-v")
.arg("80%") .arg("-p")
.arg("-h") .arg("30")
.arg("80%")
.arg("-T")
.arg(format!("Logs: {}", service_name))
.arg(&journalctl_command) .arg(&journalctl_command)
.spawn() .spawn()
.ok(); // Ignore errors, tmux will handle them .ok(); // Ignore errors, tmux will handle them
} }
} }
KeyCode::Char('L') => { KeyCode::Char('L') => {
// Show custom service log file in tmux popup // Show custom service log file in tmux split window
if let (Some(service_name), Some(hostname)) = (self.get_selected_service(), self.current_host.clone()) { if let (Some(service_name), Some(hostname)) = (self.get_selected_service(), self.current_host.clone()) {
// Check if this service has a custom log file configured // Check if this service has a custom log file configured
if let Some(host_logs) = self.config.service_logs.get(&hostname) { if let Some(host_logs) = self.config.service_logs.get(&hostname) {
if let Some(log_config) = host_logs.iter().find(|config| config.service_name == service_name) { if let Some(log_config) = host_logs.iter().find(|config| config.service_name == service_name) {
let tail_command = format!( let tail_command = format!(
"ssh -tt {}@{} 'sudo tail -n 50 -f {}'", "bash -c \"ssh -tt {}@{} 'sudo tail -n 50 -f {}'; exit\"",
self.config.ssh.rebuild_user, self.config.ssh.rebuild_user,
hostname, hostname,
log_config.log_file_path log_config.log_file_path
); );
std::process::Command::new("tmux") std::process::Command::new("tmux")
.arg("display-popup") .arg("split-window")
.arg("-w") .arg("-v")
.arg("80%") .arg("-p")
.arg("-h") .arg("30")
.arg("80%")
.arg("-T")
.arg(format!("Custom Log: {}", service_name))
.arg(&tail_command) .arg(&tail_command)
.spawn() .spawn()
.ok(); // Ignore errors, tmux will handle them .ok(); // Ignore errors, tmux will handle them

View File

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