From 83934f2e072a709b6d22bc8e7104d2511e8628c3 Mon Sep 17 00:00:00 2001 From: "zed-zippy[bot]" <234243425+zed-zippy[bot]@users.noreply.github.com> Date: Fri, 20 Mar 2026 15:19:22 +0000 Subject: [PATCH] git_ui: Do not show "resolve with agent" as a collab guest (#51676) (cherry-pick to preview) (#52024) Cherry-pick of #51676 to preview ---- Release Notes: - N/A *or* Added/Fixed/Improved ... Co-authored-by: Lukas Wirth --- crates/git_ui/src/conflict_view.rs | 22 ++++++++++++---------- crates/project/src/project.rs | 28 ++++++++++++++-------------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/crates/git_ui/src/conflict_view.rs b/crates/git_ui/src/conflict_view.rs index 96faa8879b38f59133bf3679788a3c24d1201f54..c61214123dff8cbd414c89b586f1176f7255266e 100644 --- a/crates/git_ui/src/conflict_view.rs +++ b/crates/git_ui/src/conflict_view.rs @@ -11,7 +11,7 @@ use gpui::{ }; use language::{Anchor, Buffer, BufferId}; use project::{ - ConflictRegion, ConflictSet, ConflictSetUpdate, ProjectItem as _, + ConflictRegion, ConflictSet, ConflictSetUpdate, Project, ProjectItem as _, git_store::{GitStoreEvent, RepositoryEvent}, }; use settings::Settings; @@ -497,8 +497,7 @@ fn render_conflict_buttons( .into_any() } -fn collect_conflicted_file_paths(workspace: &Workspace, cx: &App) -> Vec { - let project = workspace.project().read(cx); +fn collect_conflicted_file_paths(project: &Project, cx: &App) -> Vec { let git_store = project.git_store().read(cx); let mut paths = Vec::new(); @@ -534,7 +533,11 @@ pub(crate) fn register_conflict_notification( GitStoreEvent::ConflictsUpdated | GitStoreEvent::RepositoryUpdated(_, RepositoryEvent::StatusesChanged, _) ); - if !AgentSettings::get_global(cx).enabled || !conflicts_changed { + if !AgentSettings::get_global(cx).enabled(cx) || !conflicts_changed { + return; + } + let project = workspace.project().read(cx); + if project.is_via_collab() { return; } @@ -542,7 +545,7 @@ pub(crate) fn register_conflict_notification( return; } - let paths = collect_conflicted_file_paths(workspace, cx); + let paths = collect_conflicted_file_paths(project, cx); let notification_id = workspace::merge_conflict_notification_id(); let current_paths_set: HashSet = paths.iter().cloned().collect(); @@ -556,11 +559,10 @@ pub(crate) fn register_conflict_notification( let file_count = paths.len(); workspace.show_notification(notification_id, cx, |cx| { cx.new(|cx| { - let message = if file_count == 1 { - "1 file has unresolved merge conflicts".to_string() - } else { - format!("{file_count} files have unresolved merge conflicts") - }; + let message = format!( + "{file_count} file{} have unresolved merge conflicts", + if file_count == 1 { "" } else { "s" } + ); MessageNotification::new(message, cx) .primary_message("Resolve with Agent") diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 4f2ba9423f69bfc374b072142dbc4508191c3dc2..e6707b8f2db6408f6abf2e7c7fd4dff85e5c82ae 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -304,7 +304,7 @@ enum ProjectClientState { /// Multi-player mode but still a local project. Shared { remote_id: u64 }, /// Multi-player mode but working on a remote project. - Remote { + Collab { sharing_has_stopped: bool, capability: Capability, remote_id: u64, @@ -1813,7 +1813,7 @@ impl Project { client_subscriptions: Default::default(), _subscriptions: vec![cx.on_release(Self::release)], collab_client: client.clone(), - client_state: ProjectClientState::Remote { + client_state: ProjectClientState::Collab { sharing_has_stopped: false, capability: Capability::ReadWrite, remote_id, @@ -1931,7 +1931,7 @@ impl Project { ProjectClientState::Shared { .. } => { let _ = self.unshare_internal(cx); } - ProjectClientState::Remote { remote_id, .. } => { + ProjectClientState::Collab { remote_id, .. } => { let _ = self.collab_client.send(proto::LeaveProject { project_id: *remote_id, }); @@ -2157,7 +2157,7 @@ impl Project { match self.client_state { ProjectClientState::Local => None, ProjectClientState::Shared { remote_id, .. } - | ProjectClientState::Remote { remote_id, .. } => Some(remote_id), + | ProjectClientState::Collab { remote_id, .. } => Some(remote_id), } } @@ -2211,7 +2211,7 @@ impl Project { #[inline] pub fn replica_id(&self) -> ReplicaId { match self.client_state { - ProjectClientState::Remote { replica_id, .. } => replica_id, + ProjectClientState::Collab { replica_id, .. } => replica_id, _ => { if self.remote_client.is_some() { ReplicaId::REMOTE_SERVER @@ -2725,7 +2725,7 @@ impl Project { } else { Capability::ReadOnly }; - if let ProjectClientState::Remote { capability, .. } = &mut self.client_state { + if let ProjectClientState::Collab { capability, .. } = &mut self.client_state { if *capability == new_capability { return; } @@ -2738,7 +2738,7 @@ impl Project { } fn disconnected_from_host_internal(&mut self, cx: &mut App) { - if let ProjectClientState::Remote { + if let ProjectClientState::Collab { sharing_has_stopped, .. } = &mut self.client_state @@ -2765,7 +2765,7 @@ impl Project { #[inline] pub fn is_disconnected(&self, cx: &App) -> bool { match &self.client_state { - ProjectClientState::Remote { + ProjectClientState::Collab { sharing_has_stopped, .. } => *sharing_has_stopped, @@ -2787,7 +2787,7 @@ impl Project { #[inline] pub fn capability(&self) -> Capability { match &self.client_state { - ProjectClientState::Remote { capability, .. } => *capability, + ProjectClientState::Collab { capability, .. } => *capability, ProjectClientState::Shared { .. } | ProjectClientState::Local => Capability::ReadWrite, } } @@ -2803,7 +2803,7 @@ impl Project { ProjectClientState::Local | ProjectClientState::Shared { .. } => { self.remote_client.is_none() } - ProjectClientState::Remote { .. } => false, + ProjectClientState::Collab { .. } => false, } } @@ -2814,7 +2814,7 @@ impl Project { ProjectClientState::Local | ProjectClientState::Shared { .. } => { self.remote_client.is_some() } - ProjectClientState::Remote { .. } => false, + ProjectClientState::Collab { .. } => false, } } @@ -2823,7 +2823,7 @@ impl Project { pub fn is_via_collab(&self) -> bool { match &self.client_state { ProjectClientState::Local | ProjectClientState::Shared { .. } => false, - ProjectClientState::Remote { .. } => true, + ProjectClientState::Collab { .. } => true, } } @@ -4496,7 +4496,7 @@ impl Project { match &self.client_state { ProjectClientState::Shared { .. } => true, ProjectClientState::Local => false, - ProjectClientState::Remote { .. } => true, + ProjectClientState::Collab { .. } => true, } } @@ -5621,7 +5621,7 @@ impl Project { fn synchronize_remote_buffers(&mut self, cx: &mut Context) -> Task> { let project_id = match self.client_state { - ProjectClientState::Remote { + ProjectClientState::Collab { sharing_has_stopped, remote_id, ..