From fc3e503cfe84813ce48b60869a59e920dfb486ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=80=E1=B4=8D=E1=B4=9B=E1=B4=8F=E1=B4=80=E1=B4=87?= =?UTF-8?q?=CA=80?= Date: Wed, 5 Nov 2025 00:15:35 +0800 Subject: [PATCH] remote: Fix incorrect default repository selection when using remote (#41698) If I understand this correctly: The `active_repo_id` uses `get_or_insert_with`, which makes it dependent on the `RepositoryAdded` event sequence. To ensure correct initialization of the `active_repo_id` on the remote side, the first local `RepositoryAdded` event must synchronously send an `UpdateRepository` to `updates_tx`. Closes #30694 Release Notes: - Fixed incorrect default repository selection when using remote --- crates/project/src/git_store.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/project/src/git_store.rs b/crates/project/src/git_store.rs index 6c6603941b6e523b9a3f8d250207942d320697f7..d5350125b0a7ec4c6879f8b1e0a256470430ae13 100644 --- a/crates/project/src/git_store.rs +++ b/crates/project/src/git_store.rs @@ -1268,6 +1268,12 @@ impl GitStore { git_store, cx, ); + if let Some(updates_tx) = updates_tx.as_ref() { + // trigger an empty `UpdateRepository` to ensure remote active_repo_id is set correctly + updates_tx + .unbounded_send(DownstreamUpdate::UpdateRepository(repo.snapshot())) + .ok(); + } repo.schedule_scan(updates_tx.clone(), cx); repo });