Fix remoting things (#19587)

- Fixes modal closing when using the remote modal folder 
- Fixes a bug with local terminals where they could open in / instead of
~
- Fixes a bug where SSH connections would continue running after their
window is closed
- Hides SSH Terminal process details from Zed UI
- Implement `cmd-o` for remote projects
- Implement LanguageServerPromptRequest for remote LSPs

Release Notes:

- N/A
This commit is contained in:
Mikayla Maki 2024-10-23 00:14:43 -07:00 committed by GitHub
parent fabc14355c
commit d0bc84eb33
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 318 additions and 109 deletions

View file

@ -386,6 +386,7 @@ impl RemoteServerProjects {
if !matches!(self.mode, Mode::Default(_) | Mode::ViewServerOptions(_, _)) {
return;
}
self.selectable_items.next(cx);
cx.notify();
self.scroll_to_selected(cx);
@ -768,7 +769,7 @@ impl RemoteServerProjects {
};
let project = project.clone();
let server = server.clone();
cx.spawn(|_, mut cx| async move {
cx.spawn(|remote_server_projects, mut cx| async move {
let nickname = server.nickname.clone();
let result = open_ssh_project(
server.into(),
@ -789,6 +790,10 @@ impl RemoteServerProjects {
)
.await
.ok();
} else {
remote_server_projects
.update(&mut cx, |_, cx| cx.emit(DismissEvent))
.ok();
}
})
.detach();

View file

@ -1,13 +1,13 @@
use std::{path::PathBuf, sync::Arc, time::Duration};
use anyhow::Result;
use anyhow::{anyhow, Result};
use auto_update::AutoUpdater;
use editor::Editor;
use futures::channel::oneshot;
use gpui::{
percentage, Animation, AnimationExt, AnyWindowHandle, AsyncAppContext, DismissEvent,
EventEmitter, FocusableView, ParentElement as _, PromptLevel, Render, SemanticVersion,
SharedString, Task, TextStyleRefinement, Transformation, View,
SharedString, Task, TextStyleRefinement, Transformation, View, WeakView,
};
use gpui::{AppContext, Model};
@ -128,6 +128,14 @@ pub struct SshPrompt {
editor: View<Editor>,
}
impl Drop for SshPrompt {
fn drop(&mut self) {
if let Some(cancel) = self.cancellation.take() {
cancel.send(()).ok();
}
}
}
pub struct SshConnectionModal {
pub(crate) prompt: View<SshPrompt>,
paths: Vec<PathBuf>,
@ -393,7 +401,7 @@ impl ModalView for SshConnectionModal {
#[derive(Clone)]
pub struct SshClientDelegate {
window: AnyWindowHandle,
ui: View<SshPrompt>,
ui: WeakView<SshPrompt>,
known_password: Option<String>,
}
@ -493,7 +501,7 @@ impl SshClientDelegate {
)
.await
.map_err(|e| {
anyhow::anyhow!(
anyhow!(
"failed to download remote server binary (os: {}, arch: {}): {}",
platform.os,
platform.arch,
@ -520,7 +528,7 @@ impl SshClientDelegate {
.output()
.await?;
if !output.status.success() {
Err(anyhow::anyhow!("failed to run command: {:?}", command))?;
Err(anyhow!("failed to run command: {:?}", command))?;
}
Ok(())
}
@ -629,7 +637,7 @@ pub fn connect_over_ssh(
rx,
Arc::new(SshClientDelegate {
window,
ui,
ui: ui.downgrade(),
known_password,
}),
cx,
@ -686,7 +694,7 @@ pub async fn open_ssh_project(
Some(Arc::new(SshClientDelegate {
window: cx.window_handle(),
ui,
ui: ui.downgrade(),
known_password: connection_options.password.clone(),
}))
}