Fix transitional icons by always storing pending transitions for visual feedback
All checks were successful
Build and Release / build-and-release (push) Successful in 1m13s
All checks were successful
Build and Release / build-and-release (push) Successful in 1m13s
- Store pending transitions even for redundant commands (start active service) - Add 3-second timeout for redundant command visual feedback - Include timestamp in pending transitions to enable timeout clearing - Show directional arrows immediately regardless of command validation result - Fix core issue where state validation prevented visual feedback storage Now pressing s/S/r always shows immediate directional arrows, even for redundant operations, providing consistent visual feedback to users.
This commit is contained in:
parent
651b801de3
commit
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.25"
|
||||||
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.25"
|
||||||
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.25"
|
||||||
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.26"
|
||||||
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.26"
|
||||||
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.26"
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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()), Instant::now())
|
||||||
(command_type, current_status.unwrap_or_else(|| "unknown".to_string()))
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
// Check each pending transition to see if real status has changed or timed out
|
||||||
for (service_name, (command_type, original_status)) 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 {
|
||||||
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();
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard-shared"
|
name = "cm-dashboard-shared"
|
||||||
version = "0.1.25"
|
version = "0.1.26"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user