From 959745b51bc771df4ab9b359f464c995d51967ee Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Mon, 20 Oct 2025 13:12:39 +0200 Subject: [PATCH] Fix host navigation to work with alphabetical host ordering - Fix host_index calculation for localhost to use actual position in sorted list - Remove incorrect assumption that localhost is always at index 0 - Host navigation (Tab key) now works correctly with all hosts in alphabetical order Fixes issue where only 3 of 5 hosts were accessible via Tab navigation. --- dashboard/src/ui/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dashboard/src/ui/mod.rs b/dashboard/src/ui/mod.rs index bec5a85..1e36bf1 100644 --- a/dashboard/src/ui/mod.rs +++ b/dashboard/src/ui/mod.rs @@ -146,8 +146,9 @@ impl TuiApp { if !self.available_hosts.is_empty() { if self.available_hosts.contains(&localhost) && !self.user_navigated_away { // Localhost is available and user hasn't navigated away - switch to it - self.current_host = Some(localhost); - self.host_index = 0; // localhost is always first in sorted_hosts + self.current_host = Some(localhost.clone()); + // Find the actual index of localhost in the sorted list + self.host_index = self.available_hosts.iter().position(|h| h == &localhost).unwrap_or(0); } else if self.current_host.is_none() { // No current host - select first available (which is localhost if available) self.current_host = Some(self.available_hosts[0].clone());