From 82e7917e08162a0ee253a2ce2010623e8585dd3c Mon Sep 17 00:00:00 2001 From: Om Chillure Date: Mon, 20 Apr 2026 13:41:55 +0530 Subject: [PATCH] diagnostics: Hide Inline Assist toolbar button when agent is disabled (#52706) ### Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [ ] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the UI/UX checklist - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable #### Closes #52702 ### Video [Screencast from 2026-03-30 13-17-08.webm](https://github.com/user-attachments/assets/8b0f6927-04d2-406b-b7fd-064a730b2f86) Release Notes: - Fixed the Inline Assist button showing in the Project Diagnostics toolbar when the agent is disabled. --- Cargo.lock | 1 + crates/diagnostics/Cargo.toml | 1 + crates/diagnostics/src/toolbar_controls.rs | 26 +++++++++++++--------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c758bce1e17099cb26a5e10264dc206a0eadd442..72f7970822f0c20b0c01b71c624f36d84e680dc4 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 6a19e7e40e0ce91cfb78ca44c5c5e7f74205106f..fe850303e83f2bac4629b2a9c7066bda933716de 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 47debfe31beffde9632fc9cf02b3bd8f49252b8b..1e2436c7ab833315dae3a0240ecd819cdd0be643 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 {