From 4e3aa0b1b687e553d4e5dfe34dfd9e11c3cdee0f Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 1 Dec 2025 09:12:31 +0100 Subject: [PATCH] zed: Fix session ID mismatching for workspace and telemetry (#43659) I don't think this caused any problems for us but you never know ... Release Notes: - N/A *or* Added/Fixed/Improved ... --- crates/session/src/session.rs | 9 +++------ crates/zed/src/main.rs | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/crates/session/src/session.rs b/crates/session/src/session.rs index e8151f97fd4290058ed9928ba17a700fddbf3d35..fd45982bf40dc975857670ad29e28610f92617a6 100644 --- a/crates/session/src/session.rs +++ b/crates/session/src/session.rs @@ -3,7 +3,6 @@ use std::time::Duration; use db::kvp::KEY_VALUE_STORE; use gpui::{App, AppContext as _, Context, Subscription, Task, WindowId}; use util::ResultExt; -use uuid::Uuid; pub struct Session { session_id: String, @@ -15,11 +14,9 @@ const SESSION_ID_KEY: &str = "session_id"; const SESSION_WINDOW_STACK_KEY: &str = "session_window_stack"; impl Session { - pub async fn new() -> Self { + pub async fn new(session_id: String) -> Self { let old_session_id = KEY_VALUE_STORE.read_kvp(SESSION_ID_KEY).ok().flatten(); - let session_id = Uuid::new_v4().to_string(); - KEY_VALUE_STORE .write_kvp(SESSION_ID_KEY.to_string(), session_id.clone()) .await @@ -43,10 +40,10 @@ impl Session { } } - // #[cfg(any(test, feature = "test-support"))] + #[cfg(any(test, feature = "test-support"))] pub fn test() -> Self { Self { - session_id: Uuid::new_v4().to_string(), + session_id: uuid::Uuid::new_v4().to_string(), old_session_id: None, old_window_ids: None, } diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index e4c41c9ec5ebb523033995c9ed9d780d65b79f31..f92c819dd22c69d95533d16249345e6128e9ded0 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -287,14 +287,16 @@ pub fn main() { let app = Application::new().with_assets(Assets); - let system_id = app.background_executor().block(system_id()).ok(); - let installation_id = app.background_executor().block(installation_id()).ok(); + let system_id = app.background_executor().spawn(system_id()); + let installation_id = app.background_executor().spawn(installation_id()); let session_id = Uuid::new_v4().to_string(); - let session = app.background_executor().block(Session::new()); + let session = app + .background_executor() + .spawn(Session::new(session_id.clone())); app.background_executor() .spawn(crashes::init(InitCrashHandler { - session_id: session_id.clone(), + session_id, zed_version: app_version.to_string(), binary: "zed".to_string(), release_channel: release_channel::RELEASE_CHANNEL_NAME.clone(), @@ -505,11 +507,16 @@ pub fn main() { debugger_ui::init(cx); debugger_tools::init(cx); client::init(&client, cx); + + let system_id = cx.background_executor().block(system_id).ok(); + let installation_id = cx.background_executor().block(installation_id).ok(); + let session = cx.background_executor().block(session); + let telemetry = client.telemetry(); telemetry.start( system_id.as_ref().map(|id| id.to_string()), installation_id.as_ref().map(|id| id.to_string()), - session_id.clone(), + session.id().to_owned(), cx, );