Detailed changes
@@ -11,10 +11,9 @@ use crate::AcpThread;
pub trait AgentConnection {
fn new_thread(
- &self,
+ self: Rc<Self>,
project: Entity<Project>,
cwd: &Path,
- connection: Rc<dyn AgentConnection>,
cx: &mut AsyncApp,
) -> Task<Result<Entity<AcpThread>>>;
@@ -42,10 +41,9 @@ pub struct OldAcpAgentConnection {
impl AgentConnection for OldAcpAgentConnection {
fn new_thread(
- &self,
+ self: Rc<Self>,
project: Entity<Project>,
_cwd: &Path,
- connection: Rc<dyn AgentConnection>,
cx: &mut AsyncApp,
) -> Task<Result<Entity<AcpThread>>> {
let task = self.connection.request_any(
@@ -65,7 +63,7 @@ impl AgentConnection for OldAcpAgentConnection {
cx.update(|cx| {
let thread = cx.new(|cx| {
let session_id = acp::SessionId("acp-old-no-id".into());
- AcpThread::new(connection, "Gemini".into(), project, session_id, cx)
+ AcpThread::new(self.clone(), "Gemini".into(), project, session_id, cx)
});
thread
})
@@ -198,15 +198,21 @@ fn send_interrupt(_pid: i32) -> anyhow::Result<()> {
impl AgentConnection for ClaudeAgentConnection {
fn new_thread(
- &self,
+ self: Rc<Self>,
project: Entity<Project>,
_cwd: &Path,
- connection: Rc<dyn AgentConnection>,
cx: &mut AsyncApp,
) -> Task<Result<Entity<AcpThread>>> {
let session_id = self.session_id.clone();
- let thread_result = cx
- .new(|cx| AcpThread::new(connection, "Claude".into(), project, session_id.clone(), cx));
+ let thread_result = cx.new(|cx| {
+ AcpThread::new(
+ self.clone(),
+ "Claude".into(),
+ project,
+ session_id.clone(),
+ cx,
+ )
+ });
if let Ok(thread) = &thread_result {
self.threads_map
@@ -376,12 +376,7 @@ pub async fn new_test_thread(
.unwrap();
let thread = connection
- .new_thread(
- project.clone(),
- current_dir.as_ref(),
- connection.clone(),
- &mut cx.to_async(),
- )
+ .new_thread(project.clone(), current_dir.as_ref(), &mut cx.to_async())
.await
.unwrap();
@@ -213,10 +213,7 @@ impl AcpThreadView {
}
};
- let result = match connection
- .new_thread(project.clone(), &root_dir, connection.clone(), cx)
- .await
- {
+ let result = match connection.new_thread(project.clone(), &root_dir, cx).await {
Err(e) => {
let mut cx = cx.clone();
if e.downcast_ref::<oneshot::Canceled>().is_some() {