Fix panic in remote workspaces (#50647)

Conrad Irwin created

Fixes ZED-4JD

Release Notes:

- Fix a panic when opening the remote server modal

Change summary

crates/recent_projects/src/remote_servers.rs | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)

Detailed changes

crates/recent_projects/src/remote_servers.rs 🔗

@@ -1161,12 +1161,11 @@ impl RemoteServerProjects {
                 workspace.toggle_modal(window, cx, |window, cx| {
                     RemoteConnectionModal::new(&connection_options, Vec::new(), window, cx)
                 });
-                let prompt = workspace
-                    .active_modal::<RemoteConnectionModal>(cx)
-                    .unwrap()
-                    .read(cx)
-                    .prompt
-                    .clone();
+                // can be None if another copy of this modal opened in the meantime
+                let Some(modal) = workspace.active_modal::<RemoteConnectionModal>(cx) else {
+                    return;
+                };
+                let prompt = modal.read(cx).prompt.clone();
 
                 let connect = connect(
                     ConnectionIdentifier::setup(),