diff --git a/crates/tty7-core/src/host/remote.rs b/crates/tty7-core/src/host/remote.rs index e3803b3f..c90896f4 100644 --- a/crates/tty7-core/src/host/remote.rs +++ b/crates/tty7-core/src/host/remote.rs @@ -253,10 +253,6 @@ impl Host for RemoteHost { }) } - /// The peer owns these panes' PTYs, so it is the one that can walk their - /// process trees. A peer that does not announce the feature is not asked: - /// it would answer `Err` and the caller cannot tell that apart from a pane - /// serving nothing. fn link_rtt(&self) -> Option { // A ping of our own rather than whatever the keepalive last left // behind: that one only fires on an idle link, and a link being polled @@ -273,6 +269,10 @@ impl Host for RemoteHost { self.client.last_rtt() } + /// The peer owns these panes' PTYs, so it is the one that can walk their + /// process trees. A peer that does not announce the feature is not asked: + /// it would answer `Err` and the caller cannot tell that apart from a pane + /// serving nothing. fn pane_procs(&self, pane_id: u64) -> Option { if !self .peer() diff --git a/src/ui/right_panel.rs b/src/ui/right_panel.rs index 3521a53f..364621f4 100644 --- a/src/ui/right_panel.rs +++ b/src/ui/right_panel.rs @@ -278,8 +278,11 @@ fn format_rtt(rtt: std::time::Duration) -> String { // "0 ms" would read as a failed measurement rather than a fast one. return "<1 ms".to_string(); } - if ms < 1000. { - return format!("{} ms", ms.round() as u64); + // Rounded before the comparison, so 999.6 ms is not shown as "1000 ms" — + // a millisecond reading that has run past the unit's own range. + let rounded = ms.round() as u64; + if rounded < 1000 { + return format!("{rounded} ms"); } format!("{:.1} s", rtt.as_secs_f64()) } @@ -2006,6 +2009,9 @@ mod tests { assert_eq!(format_rtt(Duration::from_millis(1)), "1 ms"); assert_eq!(format_rtt(Duration::from_micros(23_400)), "23 ms"); assert_eq!(format_rtt(Duration::from_millis(999)), "999 ms"); + // Rounding up out of the millisecond's own range hands the number to + // the unit above rather than printing a four-digit millisecond. + assert_eq!(format_rtt(Duration::from_micros(999_600)), "1.0 s"); // Past a second the millisecond has stopped carrying information, and // the second is the unit anyone would say the number in. assert_eq!(format_rtt(Duration::from_millis(1_450)), "1.4 s");