Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
git_ui: Don't display the merge conflict notification if an agent is running (#51498)
Danilo Leal70a742eadcf8
diff --git a/crates/agent_ui/src/connection_view/thread_view.rs b/crates/agent_ui/src/connection_view/thread_view.rsindex c5e44a582ce..29ba06f470d 100644--- a/crates/agent_ui/src/connection_view/thread_view.rs+++ b/crates/agent_ui/src/connection_view/thread_view.rs@@ -739,10 +739,13 @@ impl ThreadView {}}}));+ if self.parent_id.is_none() {+ self.suppress_merge_conflict_notification(cx);+ }generation}- pub fn stop_turn(&mut self, generation: usize) {+ pub fn stop_turn(&mut self, generation: usize, cx: &mut Context<Self>) {if self.turn_fields.turn_generation != generation {return;}@@ -753,6 +756,25 @@ impl ThreadView {.map(|started| started.elapsed());self.turn_fields.last_turn_tokens = self.turn_fields.turn_tokens.take();self.turn_fields._turn_timer_task = None;+ if self.parent_id.is_none() {+ self.unsuppress_merge_conflict_notification(cx);+ }+ }++ fn suppress_merge_conflict_notification(&self, cx: &mut Context<Self>) {+ self.workspace+ .update(cx, |workspace, cx| {+ workspace.suppress_notification(&workspace::merge_conflict_notification_id(), cx);+ })+ .ok();+ }++ fn unsuppress_merge_conflict_notification(&self, cx: &mut Context<Self>) {+ self.workspace+ .update(cx, |workspace, _cx| {+ workspace.unsuppress(workspace::merge_conflict_notification_id());+ })+ .ok();}pub fn update_turn_tokens(&mut self, cx: &App) {@@ -962,7 +984,7 @@ impl ThreadView {let mut cx = cx.clone();move || {this.update(&mut cx, |this, cx| {- this.stop_turn(generation);+ this.stop_turn(generation, cx);cx.notify();}).ok();diff --git a/crates/git_ui/src/conflict_view.rs b/crates/git_ui/src/conflict_view.rsindex d3bb5213a5c..96faa8879b3 100644--- a/crates/git_ui/src/conflict_view.rs+++ b/crates/git_ui/src/conflict_view.rs@@ -18,10 +18,7 @@ use settings::Settings;use std::{cell::RefCell, ops::Range, rc::Rc, sync::Arc};use ui::{ActiveTheme, Divider, Element as _, Styled, Window, prelude::*};use util::{ResultExt as _, debug_panic, maybe};-use workspace::{- Workspace,- notifications::{NotificationId, simple_message_notification::MessageNotification},-};+use workspace::{Workspace, notifications::simple_message_notification::MessageNotification};use zed_actions::agent::{ConflictContent, ResolveConflictedFilesWithAgent, ResolveConflictsWithAgent,};@@ -500,12 +497,6 @@ fn render_conflict_buttons(.into_any()}-struct MergeConflictNotification;--fn merge_conflict_notification_id() -> NotificationId {- NotificationId::unique::<MergeConflictNotification>()-}-fn collect_conflicted_file_paths(workspace: &Workspace, cx: &App) -> Vec<String> {let project = workspace.project().read(cx);let git_store = project.git_store().read(cx);@@ -547,8 +538,12 @@ pub(crate) fn register_conflict_notification(return;}+ if workspace.is_notification_suppressed(workspace::merge_conflict_notification_id()) {+ return;+ }+let paths = collect_conflicted_file_paths(workspace, cx);- let notification_id = merge_conflict_notification_id();+ let notification_id = workspace::merge_conflict_notification_id();let current_paths_set: HashSet<String> = paths.iter().cloned().collect();if paths.is_empty() {diff --git a/crates/workspace/src/notifications.rs b/crates/workspace/src/notifications.rsindex 29bb9d7b063..85b1fe4e707 100644--- a/crates/workspace/src/notifications.rs+++ b/crates/workspace/src/notifications.rs@@ -234,6 +234,14 @@ impl Workspace {self.suppressed_notifications.insert(id.clone());}+ pub fn is_notification_suppressed(&self, notification_id: NotificationId) -> bool {+ self.suppressed_notifications.contains(¬ification_id)+ }++ pub fn unsuppress(&mut self, notification_id: NotificationId) {+ self.suppressed_notifications.remove(¬ification_id);+ }+pub fn show_initial_notifications(&mut self, cx: &mut Context<Self>) {// Allow absence of the global so that tests don't need to initialize it.let app_notifications = GLOBAL_APP_NOTIFICATIONSdiff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rsindex 7696af97996..dc3d076bd6a 100644--- a/crates/workspace/src/workspace.rs+++ b/crates/workspace/src/workspace.rs@@ -7268,6 +7268,12 @@ impl GlobalAnyActiveCall {cx.global()}}++pub fn merge_conflict_notification_id() -> NotificationId {+ struct MergeConflictNotification;+ NotificationId::unique::<MergeConflictNotification>()+}+/// Workspace-local view of a remote participant's location.#[derive(Clone, Copy, Debug, PartialEq, Eq)]pub enum ParticipantLocation {