diff --git a/dashboard/src/ui/mod.rs b/dashboard/src/ui/mod.rs index 16ce86e..bec5a85 100644 --- a/dashboard/src/ui/mod.rs +++ b/dashboard/src/ui/mod.rs @@ -133,34 +133,13 @@ impl TuiApp { /// Update available hosts with localhost prioritization pub fn update_hosts(&mut self, hosts: Vec) { - // Get the current hostname (localhost) - let localhost = gethostname::gethostname().to_string_lossy().to_string(); - - // Sort hosts with localhost first, then others in predefined order - let predefined_order = vec!["cmbox", "labbox", "simonbox", "steambox", "srv01", "srv02"]; - - let mut sorted_hosts = Vec::new(); - - // Add localhost first if it's available - if hosts.contains(&localhost) { - sorted_hosts.push(localhost.clone()); - } - - // Add remaining hosts in predefined order - for predefined_host in &predefined_order { - if hosts.contains(&predefined_host.to_string()) && *predefined_host != localhost { - sorted_hosts.push(predefined_host.to_string()); - } - } - - // Add any remaining hosts not in predefined order - for host in &hosts { - if !sorted_hosts.contains(host) { - sorted_hosts.push(host.clone()); - } - } - + // Sort hosts alphabetically + let mut sorted_hosts = hosts.clone(); + sorted_hosts.sort(); self.available_hosts = sorted_hosts; + + // Get the current hostname (localhost) for auto-selection + let localhost = gethostname::gethostname().to_string_lossy().to_string(); // Prioritize localhost if it becomes available, but respect user navigation let localhost = gethostname::gethostname().to_string_lossy().to_string();