WIP

Antonio Scandurra created

Change summary

Cargo.lock                         | 56 ++++++++++++++++----------------
Cargo.toml                         | 12 +++---
crates/acp/Cargo.toml              |  9 +---
crates/acp/LICENSE-GPL             |  0 
crates/acp/src/acp.rs              |  0 
crates/acp/src/agent2.rs           | 18 ----------
crates/acp/src/thread_element.rs   |  0 
crates/agent_ui/Cargo.toml         |  7 +--
crates/agent_ui/src/agent_panel.rs | 46 +++++++++++++-------------
9 files changed, 62 insertions(+), 86 deletions(-)

Detailed changes

Cargo.lock 🔗

@@ -2,6 +2,33 @@
 # It is not intended for manual editing.
 version = 4
 
+[[package]]
+name = "acp"
+version = "0.1.0"
+dependencies = [
+ "agentic-coding-protocol",
+ "anyhow",
+ "async-trait",
+ "base64 0.22.1",
+ "chrono",
+ "collections",
+ "editor",
+ "env_logger 0.11.8",
+ "futures 0.3.31",
+ "gpui",
+ "language",
+ "parking_lot",
+ "project",
+ "serde_json",
+ "settings",
+ "smol",
+ "ui",
+ "util",
+ "uuid",
+ "workspace-hack",
+ "zed_actions",
+]
+
 [[package]]
 name = "activity_indicator"
 version = "0.1.0"
@@ -107,33 +134,6 @@ dependencies = [
  "zstd",
 ]
 
-[[package]]
-name = "agent2"
-version = "0.1.0"
-dependencies = [
- "agentic-coding-protocol",
- "anyhow",
- "async-trait",
- "base64 0.22.1",
- "chrono",
- "collections",
- "editor",
- "env_logger 0.11.8",
- "futures 0.3.31",
- "gpui",
- "language",
- "parking_lot",
- "project",
- "serde_json",
- "settings",
- "smol",
- "ui",
- "util",
- "uuid",
- "workspace-hack",
- "zed_actions",
-]
-
 [[package]]
 name = "agent_settings"
 version = "0.1.0"
@@ -157,8 +157,8 @@ dependencies = [
 name = "agent_ui"
 version = "0.1.0"
 dependencies = [
+ "acp",
  "agent",
- "agent2",
  "agent_settings",
  "anyhow",
  "assistant_context",

Cargo.toml 🔗

@@ -2,9 +2,9 @@
 resolver = "2"
 members = [
     "crates/activity_indicator",
+    "crates/acp",
     "crates/agent_ui",
     "crates/agent",
-    "crates/agent2",
     "crates/agent_settings",
     "crates/anthropic",
     "crates/askpass",
@@ -215,9 +215,9 @@ edition = "2024"
 # Workspace member crates
 #
 
-activity_indicator = { path = "crates/activity_indicator" }
+acp = { path = "crates/acp" }
 agent = { path = "crates/agent" }
-agent2 = { path = "crates/agent2" }
+activity_indicator = { path = "crates/activity_indicator" }
 agent_ui = { path = "crates/agent_ui" }
 agent_settings = { path = "crates/agent_settings" }
 ai = { path = "crates/ai" }
@@ -481,7 +481,7 @@ json_dotpath = "1.1"
 jsonschema = "0.30.0"
 jsonwebtoken = "9.3"
 jupyter-protocol = { git = "https://github.com/ConradIrwin/runtimed", rev = "7130c804216b6914355d15d0b91ea91f6babd734" }
-jupyter-websocket-client = {  git = "https://github.com/ConradIrwin/runtimed" ,rev = "7130c804216b6914355d15d0b91ea91f6babd734" }
+jupyter-websocket-client = { git = "https://github.com/ConradIrwin/runtimed", rev = "7130c804216b6914355d15d0b91ea91f6babd734" }
 libc = "0.2"
 libsqlite3-sys = { version = "0.30.1", features = ["bundled"] }
 linkify = "0.10.0"
@@ -492,7 +492,7 @@ metal = "0.29"
 moka = { version = "0.12.10", features = ["sync"] }
 naga = { version = "25.0", features = ["wgsl-in"] }
 nanoid = "0.4"
-nbformat = {  git = "https://github.com/ConradIrwin/runtimed", rev = "7130c804216b6914355d15d0b91ea91f6babd734" }
+nbformat = { git = "https://github.com/ConradIrwin/runtimed", rev = "7130c804216b6914355d15d0b91ea91f6babd734" }
 nix = "0.29"
 num-format = "0.4.4"
 objc = "0.2"
@@ -532,7 +532,7 @@ reqwest = { git = "https://github.com/zed-industries/reqwest.git", rev = "951c77
     "stream",
 ] }
 rsa = "0.9.6"
-runtimelib = {  git = "https://github.com/ConradIrwin/runtimed", rev = "7130c804216b6914355d15d0b91ea91f6babd734", default-features = false, features = [
+runtimelib = { git = "https://github.com/ConradIrwin/runtimed", rev = "7130c804216b6914355d15d0b91ea91f6babd734", default-features = false, features = [
     "async-dispatcher-runtime",
 ] }
 rust-embed = { version = "8.4", features = ["include-exclude"] }

crates/agent2/Cargo.toml → crates/acp/Cargo.toml 🔗

@@ -1,5 +1,5 @@
 [package]
-name = "agent2"
+name = "acp"
 version = "0.1.0"
 edition.workspace = true
 publish.workspace = true
@@ -9,14 +9,11 @@ license = "GPL-3.0-or-later"
 workspace = true
 
 [lib]
-path = "src/agent2.rs"
+path = "src/acp.rs"
 doctest = false
 
 [features]
-test-support = [
-    "gpui/test-support",
-    "project/test-support",
-]
+test-support = ["gpui/test-support", "project/test-support"]
 
 [dependencies]
 agentic-coding-protocol = { path = "../../../agentic-coding-protocol" }

crates/agent2/src/agent2.rs → crates/acp/src/agent2.rs 🔗

@@ -11,24 +11,6 @@ use std::{ops::Range, path::PathBuf, sync::Arc};
 pub use acp::AcpAgent;
 pub use thread_element::ThreadElement;
 
-#[async_trait(?Send)]
-pub trait Agent: 'static {
-    async fn threads(&self, cx: &mut AsyncApp) -> Result<Vec<AgentThreadSummary>>;
-    async fn create_thread(self: Arc<Self>, cx: &mut AsyncApp) -> Result<Entity<Thread>>;
-    async fn open_thread(&self, id: ThreadId, cx: &mut AsyncApp) -> Result<Entity<Thread>>;
-    async fn thread_entries(
-        &self,
-        id: ThreadId,
-        cx: &mut AsyncApp,
-    ) -> Result<Vec<AgentThreadEntryContent>>;
-    async fn send_thread_message(
-        &self,
-        thread_id: ThreadId,
-        message: Message,
-        cx: &mut AsyncApp,
-    ) -> Result<()>;
-}
-
 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
 pub struct ThreadId(SharedString);
 

crates/agent_ui/Cargo.toml 🔗

@@ -13,14 +13,11 @@ path = "src/agent_ui.rs"
 doctest = false
 
 [features]
-test-support = [
-    "gpui/test-support",
-    "language/test-support",
-]
+test-support = ["gpui/test-support", "language/test-support"]
 
 [dependencies]
+acp.workspace = true
 agent.workspace = true
-agent2.workspace = true
 agent_settings.workspace = true
 anyhow.workspace = true
 assistant_context.workspace = true

crates/agent_ui/src/agent_panel.rs 🔗

@@ -133,7 +133,7 @@ pub fn init(cx: &mut App) {
                                 let thread = thread.read(cx).thread().clone();
                                 AgentDiffPane::deploy_in_workspace(thread, workspace, window, cx);
                             }
-                            ActiveView::Agent2Thread { .. } => todo!(),
+                            ActiveView::AcpThread { .. } => todo!(),
                             ActiveView::TextThread { .. }
                             | ActiveView::History
                             | ActiveView::Configuration => {}
@@ -197,7 +197,7 @@ enum ActiveView {
         message_editor: Entity<MessageEditor>,
         _subscriptions: Vec<gpui::Subscription>,
     },
-    Agent2Thread {
+    AcpThread {
         thread_element: Entity<agent2::ThreadElement>,
     },
     TextThread {
@@ -219,7 +219,7 @@ enum WhichFontSize {
 impl ActiveView {
     pub fn which_font_size_used(&self) -> WhichFontSize {
         match self {
-            ActiveView::Thread { .. } | ActiveView::Agent2Thread { .. } | ActiveView::History => {
+            ActiveView::Thread { .. } | ActiveView::AcpThread { .. } | ActiveView::History => {
                 WhichFontSize::AgentFont
             }
             ActiveView::TextThread { .. } => WhichFontSize::BufferFont,
@@ -252,7 +252,7 @@ impl ActiveView {
                             thread.scroll_to_bottom(cx);
                         });
                     }
-                    ActiveView::Agent2Thread { .. } => {
+                    ActiveView::AcpThread { .. } => {
                         // todo!
                     }
                     ActiveView::TextThread { .. }
@@ -670,7 +670,7 @@ impl AgentPanel {
                             .clone()
                             .update(cx, |thread, cx| thread.get_or_init_configured_model(cx));
                     }
-                    ActiveView::Agent2Thread { .. } => {
+                    ActiveView::AcpThread { .. } => {
                         // todo!
                     }
                     ActiveView::TextThread { .. }
@@ -753,7 +753,7 @@ impl AgentPanel {
             ActiveView::Thread { thread, .. } => {
                 thread.update(cx, |thread, cx| thread.cancel_last_completion(window, cx));
             }
-            ActiveView::Agent2Thread { thread_element, .. } => {
+            ActiveView::AcpThread { thread_element, .. } => {
                 thread_element.update(cx, |thread_element, _cx| thread_element.cancel());
             }
             ActiveView::TextThread { .. } | ActiveView::History | ActiveView::Configuration => {}
@@ -763,7 +763,7 @@ impl AgentPanel {
     fn active_message_editor(&self) -> Option<&Entity<MessageEditor>> {
         match &self.active_view {
             ActiveView::Thread { message_editor, .. } => Some(message_editor),
-            ActiveView::Agent2Thread { .. } => {
+            ActiveView::AcpThread { .. } => {
                 // todo!
                 None
             }
@@ -921,7 +921,7 @@ impl AgentPanel {
             let thread_element =
                 cx.new_window_entity(|window, cx| agent2::ThreadElement::new(thread, window, cx))?;
             this.update_in(cx, |this, window, cx| {
-                this.set_active_view(ActiveView::Agent2Thread { thread_element }, window, cx);
+                this.set_active_view(ActiveView::AcpThread { thread_element }, window, cx);
             })
         })
         .detach();
@@ -1092,7 +1092,7 @@ impl AgentPanel {
                         ActiveView::Thread { message_editor, .. } => {
                             message_editor.focus_handle(cx).focus(window);
                         }
-                        ActiveView::Agent2Thread { .. } => {
+                        ActiveView::AcpThread { .. } => {
                             todo!()
                         }
                         ActiveView::TextThread { context_editor, .. } => {
@@ -1214,7 +1214,7 @@ impl AgentPanel {
                     })
                     .log_err();
             }
-            ActiveView::Agent2Thread { .. } => todo!(),
+            ActiveView::AcpThread { .. } => todo!(),
             ActiveView::TextThread { .. } | ActiveView::History | ActiveView::Configuration => {}
         }
     }
@@ -1268,7 +1268,7 @@ impl AgentPanel {
                 )
                 .detach_and_log_err(cx);
             }
-            ActiveView::Agent2Thread { .. } => {
+            ActiveView::AcpThread { .. } => {
                 todo!()
             }
             ActiveView::TextThread { .. } | ActiveView::History | ActiveView::Configuration => {}
@@ -1305,7 +1305,7 @@ impl AgentPanel {
     pub(crate) fn active_thread(&self, cx: &App) -> Option<Entity<Thread>> {
         match &self.active_view {
             ActiveView::Thread { thread, .. } => Some(thread.read(cx).thread().clone()),
-            ActiveView::Agent2Thread { .. } => {
+            ActiveView::AcpThread { .. } => {
                 // todo!
                 None
             }
@@ -1414,7 +1414,7 @@ impl AgentPanel {
                     });
                 }
             }
-            ActiveView::Agent2Thread { .. } => {
+            ActiveView::AcpThread { .. } => {
                 // todo!
             }
             _ => {}
@@ -1432,7 +1432,7 @@ impl AgentPanel {
                     }
                 })
             }
-            ActiveView::Agent2Thread { .. } => {
+            ActiveView::AcpThread { .. } => {
                 // todo! push history entry
             }
             _ => {}
@@ -1521,7 +1521,7 @@ impl Focusable for AgentPanel {
     fn focus_handle(&self, cx: &App) -> FocusHandle {
         match &self.active_view {
             ActiveView::Thread { message_editor, .. } => message_editor.focus_handle(cx),
-            ActiveView::Agent2Thread { thread_element, .. } => thread_element.focus_handle(cx),
+            ActiveView::AcpThread { thread_element, .. } => thread_element.focus_handle(cx),
             ActiveView::History => self.history.focus_handle(cx),
             ActiveView::TextThread { context_editor, .. } => context_editor.focus_handle(cx),
             ActiveView::Configuration => {
@@ -1678,7 +1678,7 @@ impl AgentPanel {
                         .into_any_element(),
                 }
             }
-            ActiveView::Agent2Thread { thread_element } => {
+            ActiveView::AcpThread { thread_element } => {
                 Label::new(thread_element.read(cx).title(cx))
                     .truncate()
                     .into_any_element()
@@ -1817,7 +1817,7 @@ impl AgentPanel {
 
         let active_thread = match &self.active_view {
             ActiveView::Thread { thread, .. } => Some(thread.read(cx).thread().clone()),
-            ActiveView::Agent2Thread { .. } => {
+            ActiveView::AcpThread { .. } => {
                 // todo!
                 None
             }
@@ -1988,7 +1988,7 @@ impl AgentPanel {
                 message_editor,
                 ..
             } => (thread.read(cx), message_editor.read(cx)),
-            ActiveView::Agent2Thread { .. } => {
+            ActiveView::AcpThread { .. } => {
                 // todo!
                 return None;
             }
@@ -2132,7 +2132,7 @@ impl AgentPanel {
                     return false;
                 }
             }
-            ActiveView::Agent2Thread { .. } => {
+            ActiveView::AcpThread { .. } => {
                 // todo!
                 return false;
             }
@@ -2720,7 +2720,7 @@ impl AgentPanel {
     ) -> Option<AnyElement> {
         let active_thread = match &self.active_view {
             ActiveView::Thread { thread, .. } => thread,
-            ActiveView::Agent2Thread { .. } => {
+            ActiveView::AcpThread { .. } => {
                 // todo!
                 return None;
             }
@@ -3093,7 +3093,7 @@ impl AgentPanel {
                     .detach();
                 });
             }
-            ActiveView::Agent2Thread { .. } => {
+            ActiveView::AcpThread { .. } => {
                 unimplemented!()
             }
             ActiveView::TextThread { context_editor, .. } => {
@@ -3178,7 +3178,7 @@ impl Render for AgentPanel {
                         });
                         this.continue_conversation(window, cx);
                     }
-                    ActiveView::Agent2Thread { .. } => {
+                    ActiveView::AcpThread { .. } => {
                         todo!()
                     }
                     ActiveView::TextThread { .. }
@@ -3230,7 +3230,7 @@ impl Render for AgentPanel {
                         )
                     })
                     .child(self.render_drag_target(cx)),
-                ActiveView::Agent2Thread { thread_element, .. } => parent
+                ActiveView::AcpThread { thread_element, .. } => parent
                     .relative()
                     .child(thread_element.clone())
                     // todo!