Skip to content

Commit

Permalink
SSH connection pooling (#19692)
Browse files Browse the repository at this point in the history
Co-Authored-By: Max <[email protected]>

Closes #ISSUE

Release Notes:

- SSH Remoting: Reuse connections across hosts

---------

Co-authored-by: Max <[email protected]>
  • Loading branch information
ConradIrwin and maxbrunsfeld authored Oct 24, 2024
1 parent 3a9c071 commit d45b830
Show file tree
Hide file tree
Showing 4 changed files with 484 additions and 339 deletions.
4 changes: 2 additions & 2 deletions crates/collab/src/tests/remote_editing_collaboration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async fn test_sharing_an_ssh_remote_project(
.await;

// Set up project on remote FS
let (port, server_ssh) = SshRemoteClient::fake_server(cx_a, server_cx);
let (opts, server_ssh) = SshRemoteClient::fake_server(cx_a, server_cx);
let remote_fs = FakeFs::new(server_cx.executor());
remote_fs
.insert_tree(
Expand Down Expand Up @@ -67,7 +67,7 @@ async fn test_sharing_an_ssh_remote_project(
)
});

let client_ssh = SshRemoteClient::fake_client(port, cx_a).await;
let client_ssh = SshRemoteClient::fake_client(opts, cx_a).await;
let (project_a, worktree_id) = client_a
.build_ssh_project("/code/project1", client_ssh, cx_a)
.await;
Expand Down
11 changes: 7 additions & 4 deletions crates/recent_projects/src/remote_servers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use gpui::{
use picker::Picker;
use project::Project;
use remote::SshConnectionOptions;
use remote::SshRemoteClient;
use settings::update_settings_file;
use settings::Settings;
use ui::{
Expand Down Expand Up @@ -46,6 +47,7 @@ pub struct RemoteServerProjects {
scroll_handle: ScrollHandle,
workspace: WeakView<Workspace>,
selectable_items: SelectableItemList,
retained_connections: Vec<Model<SshRemoteClient>>,
}

struct CreateRemoteServer {
Expand Down Expand Up @@ -355,6 +357,7 @@ impl RemoteServerProjects {
scroll_handle: ScrollHandle::new(),
workspace,
selectable_items: Default::default(),
retained_connections: Vec::new(),
}
}

Expand Down Expand Up @@ -424,22 +427,22 @@ impl RemoteServerProjects {
let address_editor = editor.clone();
let creating = cx.spawn(move |this, mut cx| async move {
match connection.await {
Some(_) => this
Some(Some(client)) => this
.update(&mut cx, |this, cx| {
let _ = this.workspace.update(cx, |workspace, _| {
workspace
.client()
.telemetry()
.report_app_event("create ssh server".to_string())
});

this.retained_connections.push(client);
this.add_ssh_server(connection_options, cx);
this.mode = Mode::default_mode();
this.selectable_items.reset_selection();
cx.notify()
})
.log_err(),
None => this
_ => this
.update(&mut cx, |this, cx| {
address_editor.update(cx, |this, _| {
this.set_read_only(false);
Expand Down Expand Up @@ -1056,7 +1059,7 @@ impl RemoteServerProjects {
);

cx.spawn(|mut cx| async move {
if confirmation.await.ok() == Some(1) {
if confirmation.await.ok() == Some(0) {
remote_servers
.update(&mut cx, |this, cx| {
this.delete_ssh_server(index, cx);
Expand Down
Loading

0 comments on commit d45b830

Please sign in to comment.