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.

Fix external agent authentication with spaces in paths (#38175)

Hakan Ensarie9b4f59e0f2b
diff --git a/Cargo.lock b/Cargo.lock
index 14ec0e21db3..2b01b45f637 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -416,7 +416,6 @@ dependencies = [
"serde_json",
"serde_json_lenient",
"settings",
- "shlex",
"smol",
"streaming_diff",
"task",
diff --git a/crates/agent_ui/Cargo.toml b/crates/agent_ui/Cargo.toml
index 028db95c10a..47d9f6d6a27 100644
--- a/crates/agent_ui/Cargo.toml
+++ b/crates/agent_ui/Cargo.toml
@@ -80,7 +80,6 @@ serde.workspace = true
serde_json.workspace = true
serde_json_lenient.workspace = true
settings.workspace = true
-shlex.workspace = true
smol.workspace = true
streaming_diff.workspace = true
task.workspace = true
diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs
index d3986155d74..ceed3f8f98f 100644
--- a/crates/agent_ui/src/acp/thread_view.rs
+++ b/crates/agent_ui/src/acp/thread_view.rs
@@ -9,7 +9,7 @@ use agent_client_protocol::{self as acp, PromptCapabilities};
use agent_servers::{AgentServer, AgentServerDelegate};
use agent_settings::{AgentProfileId, AgentSettings, CompletionMode, NotifyWhenAgentWaiting};
use agent2::{DbThreadMetadata, HistoryEntry, HistoryEntryId, HistoryStore, NativeAgentServer};
-use anyhow::{Context as _, Result, anyhow, bail};
+use anyhow::{Result, anyhow, bail};
use arrayvec::ArrayVec;
use audio::{Audio, Sound};
use buffer_diff::BufferDiff;
@@ -1584,19 +1584,6 @@ impl AcpThreadView {
window.spawn(cx, async move |cx| {
let mut task = login.clone();
- task.command = task
- .command
- .map(|command| anyhow::Ok(shlex::try_quote(&command)?.to_string()))
- .transpose()?;
- task.args = task
- .args
- .iter()
- .map(|arg| {
- Ok(shlex::try_quote(arg)
- .context("Failed to quote argument")?
- .to_string())
- })
- .collect::<Result<Vec<_>>>()?;
task.full_label = task.label.clone();
task.id = task::TaskId(format!("external-agent-{}-login", task.label));
task.command_label = task.label.clone();
@@ -5680,6 +5667,23 @@ pub(crate) mod tests {
});
}
+ #[gpui::test]
+ async fn test_spawn_external_agent_login_handles_spaces(cx: &mut TestAppContext) {
+ init_test(cx);
+
+ // Verify paths with spaces aren't pre-quoted
+ let path_with_spaces = "/Users/test/Library/Application Support/Zed/cli.js";
+ let login_task = task::SpawnInTerminal {
+ command: Some("node".to_string()),
+ args: vec![path_with_spaces.to_string(), "/login".to_string()],
+ ..Default::default()
+ };
+
+ // Args should be passed as-is, not pre-quoted
+ assert!(!login_task.args[0].starts_with('"'));
+ assert!(!login_task.args[0].starts_with('\''));
+ }
+
#[gpui::test]
async fn test_notification_for_tool_authorization(cx: &mut TestAppContext) {
init_test(cx);