diff --git a/crates/workspace/src/multi_workspace.rs b/crates/workspace/src/multi_workspace.rs index c3ec2e1c61e1b038f91a57dddac0b7a7b89b337e..6e4b99ebbfe952d1e3faf3266b80ba5cd18aff34 100644 --- a/crates/workspace/src/multi_workspace.rs +++ b/crates/workspace/src/multi_workspace.rs @@ -649,6 +649,16 @@ impl MultiWorkspace { self.active_workspace_index -= 1; } + // Clear session_id and cancel any in-flight serialization on the + // removed workspace. Without this, a pending throttle timer from + // `serialize_workspace` could fire and write the old session_id + // back to the DB, resurrecting the workspace on next launch. + removed_workspace.update(cx, |workspace, _cx| { + workspace.session_id.take(); + workspace._schedule_serialize_workspace.take(); + workspace._serialize_workspace_task.take(); + }); + if let Some(workspace_id) = removed_workspace.read(cx).database_id() { let db = crate::persistence::WorkspaceDb::global(cx); self.pending_removal_tasks.retain(|task| !task.is_ready());