From 11ac83f3d46b2f979a3a13918ea9912f73d21501 Mon Sep 17 00:00:00 2001 From: Smit Barmase Date: Wed, 23 Jul 2025 06:48:31 +0530 Subject: [PATCH] workspace: Fix closing remote workspace restores last local workspace on startup (#34931) Closes #7759 While opening a new SSH project if we are reusing an existing window, i.e. drop the existing workspace and create a new one, then before dropping it, we should remove `session_id` from that workspace's serialized entry. That way: 1. Upon closing (cmd-w) this remote workspace (which also clears `session_id` for this), and then quitting. No workspace with that `session_id` is found, and it starts fresh. 2. Upon directly quitting (cmd-q) this remote workspace, only this workspace exists in db (among two of them) with that `session_id`, and it restores correctly. Release Notes: - Fixed an issue while closing remote workspace restores last local workspace on startup. --- crates/workspace/src/workspace.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 2c223c476b..4c70c52d5a 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -7378,6 +7378,17 @@ async fn open_ssh_project_inner( return Err(project_path_errors.pop().context("no paths given")?); } + if let Some(detach_session_task) = window + .update(cx, |_workspace, window, cx| { + cx.spawn_in(window, async move |this, cx| { + this.update_in(cx, |this, window, cx| this.remove_from_session(window, cx)) + }) + }) + .ok() + { + detach_session_task.await.ok(); + } + cx.update_window(window.into(), |_, window, cx| { window.replace_root(cx, |window, cx| { telemetry::event!("SSH Project Opened");