From 11c9a5f9d2790c3c115249ce853b3f35a6f86bce Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Thu, 30 Oct 2025 11:21:14 +0100 Subject: [PATCH] Add service logs feature and improve tmux popup sizing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New Features: - Add journalctl service logs viewer via Shift+J key - Opens tmux popup with real-time log streaming using journalctl -f - Shows last 50 lines and follows new log entries for selected service - Popup titled 'Logs: service.service' for clear context Improvements: - Increase tmux popup size to 80% width and height for better readability - Applies to both rebuild (R) and logs (J) popups - Compact status line text to fit new J: Logs shortcut - Updated documentation with new key binding Navigation Updates: - J: Show service logs (journalctl in tmux popup) - Status line: Tab: Host • ↑↓/jk: Select • r: Rebuild • s/S: Start/Stop • J: Logs • q: Quit Bump version to v0.1.46 --- CLAUDE.md | 2 ++ Cargo.lock | 6 +++--- README.md | 1 + agent/Cargo.toml | 2 +- dashboard/Cargo.toml | 2 +- dashboard/src/ui/mod.rs | 36 ++++++++++++++++++++++++++++++++---- shared/Cargo.toml | 2 +- 7 files changed, 41 insertions(+), 10 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 0d44fa4..cfc3964 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -25,6 +25,7 @@ A high-performance Rust-based TUI dashboard for monitoring CMTEC infrastructure. - **Service Actions**: - `s` - Start service (sends UserStart command) - `S` - Stop service (sends UserStop command) + - `J` - Show service logs (journalctl in tmux popup) - `R` - Rebuild current host - **Visual Status**: Green ● (active), Yellow ◐ (inactive), Red ◯ (failed) - **Transitional Icons**: Blue arrows during operations @@ -32,6 +33,7 @@ A high-performance Rust-based TUI dashboard for monitoring CMTEC infrastructure. ### Navigation - **Tab**: Switch between hosts - **↑↓ or j/k**: Select services +- **J**: Show service logs (journalctl) - **q**: Quit dashboard ## Core Architecture Principles diff --git a/Cargo.lock b/Cargo.lock index e4428ad..da80b2e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -270,7 +270,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.44" +version = "0.1.45" dependencies = [ "anyhow", "chrono", @@ -291,7 +291,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.44" +version = "0.1.45" dependencies = [ "anyhow", "async-trait", @@ -314,7 +314,7 @@ dependencies = [ [[package]] name = "cm-dashboard-shared" -version = "0.1.44" +version = "0.1.45" dependencies = [ "chrono", "serde", diff --git a/README.md b/README.md index 39c803d..b49b38d 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,7 @@ cm-dashboard • ● cmbox ● srv01 ● srv02 ● steambox - **↑↓ or j/k**: Navigate services - **s**: Start selected service (UserStart) - **S**: Stop selected service (UserStop) +- **J**: Show service logs (journalctl in tmux popup) - **R**: Rebuild current host - **q**: Quit diff --git a/agent/Cargo.toml b/agent/Cargo.toml index 1f09651..94e1c34 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.45" +version = "0.1.46" edition = "2021" [dependencies] diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index 5d98112..ef1e773 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.45" +version = "0.1.46" edition = "2021" [dependencies] diff --git a/dashboard/src/ui/mod.rs b/dashboard/src/ui/mod.rs index 56dd39a..bcb2e1c 100644 --- a/dashboard/src/ui/mod.rs +++ b/dashboard/src/ui/mod.rs @@ -260,6 +260,10 @@ ssh -tt {}@{} 'bash -ic {}'", std::process::Command::new("tmux") .arg("display-popup") + .arg("-w") + .arg("80%") + .arg("-h") + .arg("80%") .arg(&logo_and_rebuild) .spawn() .ok(); // Ignore errors, tmux will handle them @@ -281,6 +285,29 @@ ssh -tt {}@{} 'bash -ic {}'", } } } + KeyCode::Char('J') => { + // Show service logs via journalctl in tmux popup + if let (Some(service_name), Some(hostname)) = (self.get_selected_service(), self.current_host.clone()) { + let journalctl_command = format!( + "ssh -tt {}@{} 'journalctl -u {}.service -f --no-pager -n 50'", + self.config.ssh.rebuild_user, + hostname, + service_name + ); + + std::process::Command::new("tmux") + .arg("display-popup") + .arg("-w") + .arg("80%") + .arg("-h") + .arg("80%") + .arg("-t") + .arg(format!("Logs: {}.service", service_name)) + .arg(&journalctl_command) + .spawn() + .ok(); // Ignore errors, tmux will handle them + } + } KeyCode::Char('b') => { // Trigger backup if let Some(hostname) = self.current_host.clone() { @@ -686,10 +713,11 @@ ssh -tt {}@{} 'bash -ic {}'", let mut shortcuts = Vec::new(); // Global shortcuts - shortcuts.push("Tab: Switch Host".to_string()); - shortcuts.push("↑↓/jk: Select Service".to_string()); - shortcuts.push("r: Rebuild Host".to_string()); - shortcuts.push("s/S: Start/Stop Service".to_string()); + shortcuts.push("Tab: Host".to_string()); + shortcuts.push("↑↓/jk: Select".to_string()); + shortcuts.push("r: Rebuild".to_string()); + shortcuts.push("s/S: Start/Stop".to_string()); + shortcuts.push("J: Logs".to_string()); // Always show quit shortcuts.push("q: Quit".to_string()); diff --git a/shared/Cargo.toml b/shared/Cargo.toml index eee5899..c356935 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.45" +version = "0.1.46" edition = "2021" [dependencies]