Better error handling for SSH (#19533)

Before this change we sometimes showed errors inline, sometimes in
alerts.
Sometimes we closed the window, someimtes we didn't.

Now they always show as prompts and we never close windows.

Co-Authored-By: Mikayla <mikayla@zed.dev>

Release Notes:

- SSH Remoting: Improve error handling
This commit is contained in:
Conrad Irwin 2024-10-21 23:17:42 -06:00 committed by GitHub
parent 6e485453d0
commit 4f52077d97
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 107 additions and 136 deletions

View file

@ -481,9 +481,7 @@ impl RemoteServerProjects {
let connection_options = ssh_connection.into();
workspace.update(cx, |_, cx| {
cx.defer(move |workspace, cx| {
workspace.toggle_modal(cx, |cx| {
SshConnectionModal::new(&connection_options, false, cx)
});
workspace.toggle_modal(cx, |cx| SshConnectionModal::new(&connection_options, cx));
let prompt = workspace
.active_modal::<SshConnectionModal>(cx)
.unwrap()
@ -498,8 +496,19 @@ impl RemoteServerProjects {
cx,
)
.prompt_err("Failed to connect", cx, |_, _| None);
cx.spawn(move |workspace, mut cx| async move {
let Some(session) = connect.await else {
let session = connect.await;
workspace
.update(&mut cx, |workspace, cx| {
if let Some(prompt) = workspace.active_modal::<SshConnectionModal>(cx) {
prompt.update(cx, |prompt, cx| prompt.finished(cx))
}
})
.ok();
let Some(session) = session else {
workspace
.update(&mut cx, |workspace, cx| {
let weak = cx.view().downgrade();