Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Make Esc dismiss agent notifications (#60001)

Kirill Bulatovc57b348ad14e
diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs
index e8328ffc25d..a26d2c652eb 100644
--- a/crates/agent_ui/src/agent_panel.rs
+++ b/crates/agent_ui/src/agent_panel.rs
@@ -739,7 +739,17 @@ pub fn init(cx: &mut App) {
});
});
},
- );
+ )
+ .register_action(|workspace, _: &menu::Cancel, _window, cx| {
+ if let Some(panel) = workspace.panel::<AgentPanel>(cx) {
+ let dismissed =
+ panel.update(cx, |panel, cx| panel.dismiss_all_notifications(cx));
+ if dismissed {
+ return;
+ }
+ }
+ cx.propagate();
+ });
},
)
.detach();
@@ -2774,6 +2784,22 @@ impl AgentPanel {
}
}
+ pub fn dismiss_all_notifications(&mut self, cx: &mut Context<Self>) -> bool {
+ let mut dismissed = false;
+ for conversation_view in self.conversation_views() {
+ dismissed |= conversation_view.update(cx, |view, cx| view.dismiss_notifications(cx));
+ }
+ let had_terminal_notifications = self
+ .terminals
+ .values()
+ .any(|t| !t.notification_windows.is_empty());
+ if had_terminal_notifications {
+ self.dismiss_all_terminal_notifications(cx);
+ dismissed = true;
+ }
+ dismissed
+ }
+
fn active_terminal_visible(&self, terminal_id: TerminalId, window: &Window, cx: &App) -> bool {
if !window.is_window_active() {
return false;
diff --git a/crates/agent_ui/src/conversation_view.rs b/crates/agent_ui/src/conversation_view.rs
index cb5058e9550..50d45fbaba6 100644
--- a/crates/agent_ui/src/conversation_view.rs
+++ b/crates/agent_ui/src/conversation_view.rs
@@ -2668,7 +2668,8 @@ impl ConversationView {
}
}
- fn dismiss_notifications(&mut self, cx: &mut Context<Self>) {
+ pub(crate) fn dismiss_notifications(&mut self, cx: &mut Context<Self>) -> bool {
+ let had_notifications = !self.notifications.is_empty();
for window in self.notifications.drain(..) {
window
.update(cx, |_, window, _| {
@@ -2678,6 +2679,7 @@ impl ConversationView {
self.notification_subscriptions.remove(&window);
}
+ had_notifications
}
fn agent_ui_font_size_changed(&mut self, _window: &mut Window, cx: &mut Context<Self>) {