Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
agent: Gate agent registry refresh behind Disable AI setting (#50868)
Ben Brandt90ae70874e57
diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rsindex 19ffc0ff596..0a216ad4bd3 100644--- a/crates/agent_ui/src/agent_panel.rs+++ b/crates/agent_ui/src/agent_panel.rs@@ -3425,13 +3425,12 @@ impl AgentPanel {.filter(|id| {!agent_server_store.external_agents.contains_key(*id)})- .map(|name| {+ .filter_map(|name| {let display_name = registry_store_ref.as_ref().and_then(|store| store.agent(name.0.as_ref()))- .map(|a| a.name().clone())- .unwrap_or_else(|| name.0.clone());- (name.clone(), display_name)+ .map(|a| a.name().clone())?;+ Some((name.clone(), display_name))}).sorted_unstable_by_key(|(_, display_name)| display_name.to_lowercase()).collect::<Vec<_>>();diff --git a/crates/project/src/agent_registry_store.rs b/crates/project/src/agent_registry_store.rsindex a6fc56b7dad..155badc4ac7 100644--- a/crates/project/src/agent_registry_store.rs+++ b/crates/project/src/agent_registry_store.rs@@ -11,7 +11,7 @@ use http_client::{AsyncBody, HttpClient};use serde::Deserialize;use settings::Settings as _;-use crate::agent_server_store::AllAgentServersSettings;+use crate::DisableAiSettings;const REGISTRY_URL: &str = "https://cdn.agentclientprotocol.com/registry/v1/latest/registry.json";const REFRESH_THROTTLE_DURATION: Duration = Duration::from_secs(60 * 60);@@ -129,13 +129,11 @@ impl AgentRegistryStore {let store = cx.new(|cx| Self::new(fs, http_client, cx));cx.set_global(GlobalAgentRegistryStore(store.clone()));- if AllAgentServersSettings::get_global(cx).has_registry_agents() {- store.update(cx, |store, cx| {- if store.agents.is_empty() {- store.refresh(cx);- }- });- }+ store.update(cx, |store, cx| {+ if store.agents.is_empty() {+ store.refresh(cx);+ }+ });store}@@ -173,6 +171,10 @@ impl AgentRegistryStore {return;}+ if DisableAiSettings::get_global(cx).disable_ai {+ return;+ }+self.is_fetching = true;self.fetch_error = None;self.last_refresh = Some(Instant::now());@@ -249,6 +251,10 @@ impl AgentRegistryStore {http_client: Arc<dyn HttpClient>,cx: &mut Context<Self>,) {+ if DisableAiSettings::get_global(cx).disable_ai {+ return;+ }+cx.spawn(async move |this, cx| -> Result<()> {let cache_path = registry_cache_path();if !fs.is_file(&cache_path).await {