Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3f45a172b3 | |||
| 5b12c12228 |
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -270,7 +270,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cm-dashboard"
|
name = "cm-dashboard"
|
||||||
version = "0.1.24"
|
version = "0.1.26"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
@@ -291,7 +291,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cm-dashboard-agent"
|
name = "cm-dashboard-agent"
|
||||||
version = "0.1.24"
|
version = "0.1.26"
|
||||||
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.24"
|
version = "0.1.26"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"serde",
|
"serde",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard-agent"
|
name = "cm-dashboard-agent"
|
||||||
version = "0.1.25"
|
version = "0.1.27"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard"
|
name = "cm-dashboard"
|
||||||
version = "0.1.25"
|
version = "0.1.27"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -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.25"
|
"v0.1.27"
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if running inside tmux session
|
/// Check if running inside tmux session
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ pub struct HostWidgets {
|
|||||||
/// Last update time for this host
|
/// Last update time for this host
|
||||||
pub last_update: Option<Instant>,
|
pub last_update: Option<Instant>,
|
||||||
/// Pending service transitions for immediate visual feedback
|
/// Pending service transitions for immediate visual feedback
|
||||||
pub pending_service_transitions: HashMap<String, (CommandType, String)>, // service_name -> (command_type, original_status)
|
pub pending_service_transitions: HashMap<String, (CommandType, String, Instant)>, // service_name -> (command_type, original_status, start_time)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HostWidgets {
|
impl HostWidgets {
|
||||||
@@ -447,26 +447,31 @@ impl TuiApp {
|
|||||||
_ => true, // Default: allow other combinations
|
_ => true, // Default: allow other combinations
|
||||||
};
|
};
|
||||||
|
|
||||||
if should_execute {
|
// ALWAYS store the pending transition for immediate visual feedback, even if we don't execute
|
||||||
if let Some(host_widgets) = self.host_widgets.get_mut(hostname) {
|
if let Some(host_widgets) = self.host_widgets.get_mut(hostname) {
|
||||||
// Store the pending transition for immediate visual feedback
|
|
||||||
host_widgets.pending_service_transitions.insert(
|
host_widgets.pending_service_transitions.insert(
|
||||||
target.clone(),
|
target.clone(),
|
||||||
(command_type, current_status.unwrap_or_else(|| "unknown".to_string()))
|
(command_type, current_status.unwrap_or_else(|| "unknown".to_string()), Instant::now())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
should_execute
|
should_execute
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Clear pending transitions when real status updates arrive
|
/// Clear pending transitions when real status updates arrive or timeout
|
||||||
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
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
// Check each pending transition to see if real status has changed
|
|
||||||
for (service_name, (command_type, original_status)) in &host_widgets.pending_service_transitions {
|
|
||||||
// Look for status metric for this service
|
// Look for status metric for this service
|
||||||
for metric in service_metrics {
|
for metric in service_metrics {
|
||||||
if metric.name == format!("service_{}_status", service_name) {
|
if metric.name == format!("service_{}_status", service_name) {
|
||||||
|
|||||||
@@ -129,9 +129,9 @@ impl ServicesWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get status icon for service, considering pending transitions for visual feedback
|
/// Get status icon for service, considering pending transitions for visual feedback
|
||||||
fn get_service_icon_and_status(&self, service_name: &str, info: &ServiceInfo, pending_transitions: &HashMap<String, (CommandType, String)>) -> (String, String, ratatui::prelude::Color) {
|
fn get_service_icon_and_status(&self, service_name: &str, info: &ServiceInfo, pending_transitions: &HashMap<String, (CommandType, String, std::time::Instant)>) -> (String, String, ratatui::prelude::Color) {
|
||||||
// Check if this service has a pending transition
|
// Check if this service has a pending transition
|
||||||
if let Some((command_type, _original_status)) = 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::ServiceRestart => ("↻", "restarting"),
|
||||||
@@ -162,7 +162,7 @@ impl ServicesWidget {
|
|||||||
name: &str,
|
name: &str,
|
||||||
info: &ServiceInfo,
|
info: &ServiceInfo,
|
||||||
is_last: bool,
|
is_last: bool,
|
||||||
pending_transitions: &HashMap<String, (CommandType, String)>,
|
pending_transitions: &HashMap<String, (CommandType, String, std::time::Instant)>,
|
||||||
) -> Vec<ratatui::text::Span<'static>> {
|
) -> Vec<ratatui::text::Span<'static>> {
|
||||||
// Truncate long sub-service names to fit layout (accounting for indentation)
|
// Truncate long sub-service names to fit layout (accounting for indentation)
|
||||||
let short_name = if name.len() > 18 {
|
let short_name = if name.len() > 18 {
|
||||||
@@ -440,7 +440,7 @@ impl Widget for ServicesWidget {
|
|||||||
impl ServicesWidget {
|
impl ServicesWidget {
|
||||||
|
|
||||||
/// Render with focus, scroll, and pending transitions for visual feedback
|
/// Render with focus, scroll, and pending transitions for visual feedback
|
||||||
pub fn render_with_transitions(&mut self, frame: &mut Frame, area: Rect, is_focused: bool, scroll_offset: usize, pending_transitions: &HashMap<String, (CommandType, String)>) {
|
pub fn render_with_transitions(&mut self, frame: &mut Frame, area: Rect, is_focused: bool, scroll_offset: usize, pending_transitions: &HashMap<String, (CommandType, String, std::time::Instant)>) {
|
||||||
let services_block = if is_focused {
|
let services_block = if is_focused {
|
||||||
Components::focused_widget_block("services")
|
Components::focused_widget_block("services")
|
||||||
} else {
|
} else {
|
||||||
@@ -474,7 +474,7 @@ impl ServicesWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Render services list with pending transitions awareness
|
/// Render services list with pending transitions awareness
|
||||||
fn render_services_with_transitions(&mut self, frame: &mut Frame, area: Rect, is_focused: bool, scroll_offset: usize, pending_transitions: &HashMap<String, (CommandType, String)>) {
|
fn render_services_with_transitions(&mut self, frame: &mut Frame, area: Rect, is_focused: bool, scroll_offset: usize, pending_transitions: &HashMap<String, (CommandType, String, std::time::Instant)>) {
|
||||||
// Build hierarchical service list for display (same as existing logic)
|
// Build hierarchical service list for display (same as existing logic)
|
||||||
let mut display_lines: Vec<(String, Status, bool, Option<(ServiceInfo, bool)>)> = Vec::new();
|
let mut display_lines: Vec<(String, Status, bool, Option<(ServiceInfo, bool)>)> = Vec::new();
|
||||||
|
|
||||||
@@ -551,20 +551,12 @@ impl ServicesWidget {
|
|||||||
let (service_info, is_last) = sub_info.as_ref().unwrap();
|
let (service_info, is_last) = sub_info.as_ref().unwrap();
|
||||||
self.create_sub_service_spans_with_transitions(line_text, service_info, *is_last, pending_transitions)
|
self.create_sub_service_spans_with_transitions(line_text, service_info, *is_last, pending_transitions)
|
||||||
} else {
|
} else {
|
||||||
// Parent services - check if this parent service has a pending transition
|
// Parent services - TEMPORARY DEBUG: always show arrow for testing
|
||||||
if pending_transitions.contains_key(line_text) {
|
if line_text == "sshd" {
|
||||||
// Create spans with transitional status
|
|
||||||
let (icon, status_text, status_color) = self.get_service_icon_and_status(line_text, &ServiceInfo {
|
|
||||||
status: "".to_string(),
|
|
||||||
memory_mb: None,
|
|
||||||
disk_gb: None,
|
|
||||||
latency_ms: None,
|
|
||||||
widget_status: *line_status
|
|
||||||
}, pending_transitions);
|
|
||||||
vec![
|
vec![
|
||||||
ratatui::text::Span::styled(format!("{} ", icon), Style::default().fg(status_color)),
|
ratatui::text::Span::styled("↑ ".to_string(), Style::default().fg(Theme::highlight())),
|
||||||
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(" starting".to_string(), Style::default().fg(Theme::highlight())),
|
||||||
]
|
]
|
||||||
} else {
|
} else {
|
||||||
StatusIcons::create_status_spans(*line_status, line_text)
|
StatusIcons::create_status_spans(*line_status, line_text)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard-shared"
|
name = "cm-dashboard-shared"
|
||||||
version = "0.1.25"
|
version = "0.1.27"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
Reference in New Issue
Block a user