From eeb87cb17768c4a1372047ad67a1e9a1d7dd507b Mon Sep 17 00:00:00 2001 From: Saketh <126517689+SAKETH11111@users.noreply.github.com> Date: Fri, 3 Apr 2026 17:55:40 -0500 Subject: [PATCH] remote: Use SSH nicknames in display names (#53103) Closes #52943 ## Summary - Prefer SSH nicknames over raw hosts in remote connection display names - Add regression tests for nickname and host fallback behavior ## Why The `nickname` field is documented as the user-facing label for SSH connections, but `RemoteConnectionOptions::display_name()` always returned the raw host. That meant recent-projects UI surfaces kept ignoring nicknames even when they were configured. ## Validation - `cargo test -p remote ssh_display_name` - `cargo test -p remote` Release Notes: - Fixed SSH recent-project labels to show configured nicknames instead of raw hosts when available. --- crates/remote/src/remote_client.rs | 31 +++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/crates/remote/src/remote_client.rs b/crates/remote/src/remote_client.rs index e746d82aac857d3174a4bab14c937a7538b2f1b4..c04d3630f92bcc27afb01a619176d3ae79d3fac7 100644 --- a/crates/remote/src/remote_client.rs +++ b/crates/remote/src/remote_client.rs @@ -1285,7 +1285,10 @@ pub enum RemoteConnectionOptions { impl RemoteConnectionOptions { pub fn display_name(&self) -> String { match self { - RemoteConnectionOptions::Ssh(opts) => opts.host.to_string(), + RemoteConnectionOptions::Ssh(opts) => opts + .nickname + .clone() + .unwrap_or_else(|| opts.host.to_string()), RemoteConnectionOptions::Wsl(opts) => opts.distro_name.clone(), RemoteConnectionOptions::Docker(opts) => { if opts.use_podman { @@ -1300,6 +1303,32 @@ impl RemoteConnectionOptions { } } +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_ssh_display_name_prefers_nickname() { + let options = RemoteConnectionOptions::Ssh(SshConnectionOptions { + host: "1.2.3.4".into(), + nickname: Some("My Cool Project".to_string()), + ..Default::default() + }); + + assert_eq!(options.display_name(), "My Cool Project"); + } + + #[test] + fn test_ssh_display_name_falls_back_to_host() { + let options = RemoteConnectionOptions::Ssh(SshConnectionOptions { + host: "1.2.3.4".into(), + ..Default::default() + }); + + assert_eq!(options.display_name(), "1.2.3.4"); + } +} + impl From for RemoteConnectionOptions { fn from(opts: SshConnectionOptions) -> Self { RemoteConnectionOptions::Ssh(opts)