remote_server: Fix opening a new remote project not refreshing the project panel (#18262)

CharlesChen0823 created

Currently, when open new remote project, project_panel not refresh, we
must `ctrl-p` and select an file to refresh the project_panel. After
that, project_panel will refresh when remote project window active.

Release Notes:

- Fixed remote projects not restoring previous locations and not
refreshing the project panel on open.

Change summary

crates/workspace/src/workspace.rs | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)

Detailed changes

crates/workspace/src/workspace.rs 🔗

@@ -5607,6 +5607,9 @@ pub fn join_dev_server_project(
             })
         });
 
+        let serialized_workspace: Option<SerializedWorkspace> =
+            persistence::DB.workspace_for_dev_server_project(dev_server_project_id);
+
         let workspace = if let Some(existing_workspace) = existing_workspace {
             existing_workspace
         } else {
@@ -5620,10 +5623,7 @@ pub fn join_dev_server_project(
             )
             .await?;
 
-            let serialized_workspace: Option<SerializedWorkspace> =
-                persistence::DB.workspace_for_dev_server_project(dev_server_project_id);
-
-            let workspace_id = if let Some(serialized_workspace) = serialized_workspace {
+            let workspace_id = if let Some(ref serialized_workspace) = serialized_workspace {
                 serialized_workspace.id
             } else {
                 persistence::DB.next_id().await?
@@ -5650,10 +5650,13 @@ pub fn join_dev_server_project(
             }
         };
 
-        workspace.update(&mut cx, |_, cx| {
-            cx.activate(true);
-            cx.activate_window();
-        })?;
+        workspace
+            .update(&mut cx, |_, cx| {
+                cx.activate(true);
+                cx.activate_window();
+                open_items(serialized_workspace, vec![], app_state, cx)
+            })?
+            .await?;
 
         anyhow::Ok(workspace)
     })