From e4945b5d0990fb8d7ab4ac8563eb32a4889770b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8B=90=E7=8B=B8?= <308013446a@gmail.com> Date: Mon, 5 Oct 2026 07:30:35 +0000 Subject: [PATCH] remote: Reuse the known OS when reconnecting over SSH (#65024) ## Summary The OS should not be re-probed during remote reconnection. ## Testing Just a simple refactoring. ## Self-review - [x] I've reviewed my diff for quality, security, reliability, and performance. - [ ] UI changes follow the [checklist](https://zed.dev/docs/development/ui-checklist). - [ ] Tests cover the new or changed behavior. Release Notes: - Reuse the known OS when reconnecting over SSH Co-authored-by: Kirill Bulatov --- crates/remote/src/remote_client.rs | 12 +++++++++--- crates/remote/src/transport/ssh.rs | 6 +++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/crates/remote/src/remote_client.rs b/crates/remote/src/remote_client.rs index 91eb5c5a2fe..c645a31d129 100644 --- a/crates/remote/src/remote_client.rs +++ b/crates/remote/src/remote_client.rs @@ -385,7 +385,7 @@ pub async fn connect( ) -> Result> { cx.update(|cx| { cx.update_default_global(|pool: &mut ConnectionPool, cx| { - pool.connect(connection_options.clone(), delegate.clone(), cx) + pool.connect(connection_options.clone(), None, delegate.clone(), cx) }) }) .await @@ -684,7 +684,12 @@ impl RemoteClient { let (remote_connection, io_task) = match async { let remote_connection = cx .update_global(|pool: &mut ConnectionPool, cx| { - pool.connect(connection_options, delegate.clone(), cx) + pool.connect( + connection_options, + Some(remote_connection.remote_platform().os), + delegate.clone(), + cx, + ) }) .await .map_err(|error| error.cloned())?; @@ -1231,6 +1236,7 @@ impl ConnectionPool { fn connect( &mut self, opts: RemoteConnectionOptions, + known_os: Option, delegate: Arc, cx: &mut App, ) -> Shared, Arc>>> { @@ -1270,7 +1276,7 @@ impl ConnectionPool { async move |cx| { let connection = match opts.clone() { RemoteConnectionOptions::Ssh(opts) => { - SshRemoteConnection::new(opts, delegate, cx) + SshRemoteConnection::new(opts, known_os, delegate, cx) .await .map(|connection| Arc::new(connection) as Arc) } diff --git a/crates/remote/src/transport/ssh.rs b/crates/remote/src/transport/ssh.rs index c13e39b9582..5c9ab757162 100644 --- a/crates/remote/src/transport/ssh.rs +++ b/crates/remote/src/transport/ssh.rs @@ -633,6 +633,7 @@ async fn find_existing_control_master( impl SshRemoteConnection { pub(crate) async fn new( connection_options: SshConnectionOptions, + known_os: Option, delegate: Arc, cx: &mut AsyncApp, ) -> Result { @@ -788,7 +789,10 @@ impl SshRemoteConnection { (socket, Some(master_process)) }; - let is_windows = socket.probe_is_windows().await; + let is_windows = match known_os { + Some(os) => os.is_windows(), + None => socket.probe_is_windows().await, + }; log::info!("Remote is windows: {}", is_windows); let ssh_shell = socket.shell(is_windows).await;