Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
agent_servers: Fix proxy configuration for Gemini (#37790)
Patsakula Nikita246c64431623
diff --git a/crates/agent_servers/Cargo.toml b/crates/agent_servers/Cargo.tomlindex 2a601dcb161..bb3fe6ff907 100644--- a/crates/agent_servers/Cargo.toml+++ b/crates/agent_servers/Cargo.toml@@ -23,7 +23,7 @@ action_log.workspace = trueagent-client-protocol.workspace = trueagent_settings.workspace = trueanyhow.workspace = true-client = { workspace = true, optional = true }+client.workspace = truecollections.workspace = trueenv_logger = { workspace = true, optional = true }fs.workspace = truediff --git a/crates/agent_servers/src/gemini.rs b/crates/agent_servers/src/gemini.rsindex 20a18dfd332..cf553273db8 100644--- a/crates/agent_servers/src/gemini.rs+++ b/crates/agent_servers/src/gemini.rs@@ -4,10 +4,12 @@ use std::{any::Any, path::Path};use crate::{AgentServer, AgentServerDelegate};use acp_thread::AgentConnection;use anyhow::{Context as _, Result};+use client::ProxySettings;use collections::HashMap;-use gpui::{App, SharedString, Task};+use gpui::{App, AppContext, SharedString, Task};use language_models::provider::google::GoogleLanguageModelProvider;use project::agent_server_store::GEMINI_NAME;+use settings::SettingsStore;#[derive(Clone)]pub struct Gemini;@@ -35,13 +37,16 @@ impl AgentServer for Gemini {let root_dir = root_dir.map(|root_dir| root_dir.to_string_lossy().to_string());let is_remote = delegate.project.read(cx).is_via_remote_server();let store = delegate.store.downgrade();+ let proxy_url = cx.read_global(|settings: &SettingsStore, _| {+ settings.get::<ProxySettings>(None).proxy.clone()+ });cx.spawn(async move |cx| {let mut extra_env = HashMap::default();if let Some(api_key) = cx.update(GoogleLanguageModelProvider::api_key)?.await.ok() {extra_env.insert("GEMINI_API_KEY".into(), api_key.key);}- let (command, root_dir, login) = store+ let (mut command, root_dir, login) = store.update(cx, |store, cx| {let agent = store.get_external_agent(&GEMINI_NAME.into())@@ -55,6 +60,15 @@ impl AgentServer for Gemini {))})??.await?;++ // Add proxy flag if proxy settings are configured in Zed and not in the args+ if let Some(proxy_url_value) = &proxy_url+ && !command.args.iter().any(|arg| arg.contains("--proxy"))+ {+ command.args.push("--proxy".into());+ command.args.push(proxy_url_value.clone());+ }+let connection =crate::acp::connect(name, command, root_dir.as_ref(), is_remote, cx).await?;Ok((connection, login))