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.

diagnostics: Hide Inline Assist toolbar button when agent is disabled (#52706)

Om Chillure82e7917e0816
diff --git a/Cargo.lock b/Cargo.lock
index c758bce1e17..72f7970822f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4872,6 +4872,7 @@ dependencies = [
name = "diagnostics"
version = "0.1.0"
dependencies = [
+ "agent_settings",
"anyhow",
"collections",
"component",
diff --git a/crates/diagnostics/Cargo.toml b/crates/diagnostics/Cargo.toml
index 6a19e7e40e0..fe850303e83 100644
--- a/crates/diagnostics/Cargo.toml
+++ b/crates/diagnostics/Cargo.toml
@@ -13,6 +13,7 @@ path = "src/diagnostics.rs"
doctest = false
[dependencies]
+agent_settings.workspace = true
anyhow.workspace = true
collections.workspace = true
component.workspace = true
diff --git a/crates/diagnostics/src/toolbar_controls.rs b/crates/diagnostics/src/toolbar_controls.rs
index 47debfe31be..1e2436c7ab8 100644
--- a/crates/diagnostics/src/toolbar_controls.rs
+++ b/crates/diagnostics/src/toolbar_controls.rs
@@ -1,6 +1,8 @@
use crate::{BufferDiagnosticsEditor, ProjectDiagnosticsEditor, ToggleDiagnosticsRefresh};
+use agent_settings::AgentSettings;
use gpui::{Context, EventEmitter, ParentElement, Render, Window};
use language::DiagnosticEntry;
+use settings::Settings;
use text::{Anchor, BufferId};
use ui::{Tooltip, prelude::*};
use workspace::{ToolbarItemEvent, ToolbarItemLocation, ToolbarItemView, item::ItemHandle};
@@ -46,6 +48,8 @@ impl Render for ToolbarControls {
None => {}
}
+ let is_agent_enabled = AgentSettings::get_global(cx).enabled(cx);
+
let (warning_tooltip, warning_color) = if include_warnings {
("Exclude Warnings", Color::Warning)
} else {
@@ -65,16 +69,18 @@ impl Render for ToolbarControls {
window.dispatch_action(Box::new(buffer_search::Deploy::find()), cx);
})
})
- .child({
- IconButton::new("inline_assist", IconName::ZedAssistant)
- .icon_size(IconSize::Small)
- .tooltip(Tooltip::for_action_title(
- "Inline Assist",
- &InlineAssist::default(),
- ))
- .on_click(|_, window, cx| {
- window.dispatch_action(Box::new(InlineAssist::default()), cx);
- })
+ .when(is_agent_enabled, |this| {
+ this.child(
+ IconButton::new("inline_assist", IconName::ZedAssistant)
+ .icon_size(IconSize::Small)
+ .tooltip(Tooltip::for_action_title(
+ "Inline Assist",
+ &InlineAssist::default(),
+ ))
+ .on_click(|_, window, cx| {
+ window.dispatch_action(Box::new(InlineAssist::default()), cx);
+ }),
+ )
})
.map(|div| {
if is_updating {