Put name on connection as well for Thread Title

This commit is contained in:
Ben Brandt 2025-07-24 12:06:05 +02:00
parent 44cae51ea3
commit 755cff59a1
No known key found for this signature in database
GPG key ID: D4618C5D3B500571
4 changed files with 18 additions and 14 deletions

View file

@ -572,8 +572,6 @@ impl Error for LoadError {}
impl AcpThread { impl AcpThread {
pub fn new( pub fn new(
connection: Rc<dyn AgentConnection>, connection: Rc<dyn AgentConnection>,
// todo! remove me
title: SharedString,
project: Entity<Project>, project: Entity<Project>,
session_id: acp::SessionId, session_id: acp::SessionId,
cx: &mut Context<Self>, cx: &mut Context<Self>,
@ -585,7 +583,7 @@ impl AcpThread {
shared_buffers: Default::default(), shared_buffers: Default::default(),
entries: Default::default(), entries: Default::default(),
plan: Default::default(), plan: Default::default(),
title, title: connection.name().into(),
project, project,
send_task: None, send_task: None,
connection, connection,
@ -1783,13 +1781,13 @@ mod tests {
} }
}); });
let connection = OldAcpAgentConnection { let connection = OldAcpAgentConnection {
name: "test",
connection, connection,
child_status: io_task, child_status: io_task,
}; };
AcpThread::new( AcpThread::new(
Rc::new(connection), Rc::new(connection),
"Test".into(),
project, project,
acp::SessionId("test".into()), acp::SessionId("test".into()),
cx, cx,

View file

@ -10,6 +10,8 @@ use ui::App;
use crate::AcpThread; use crate::AcpThread;
pub trait AgentConnection { pub trait AgentConnection {
fn name(&self) -> &'static str;
fn new_thread( fn new_thread(
self: Rc<Self>, self: Rc<Self>,
project: Entity<Project>, project: Entity<Project>,
@ -35,11 +37,16 @@ impl fmt::Display for Unauthenticated {
} }
pub struct OldAcpAgentConnection { pub struct OldAcpAgentConnection {
pub name: &'static str,
pub connection: acp_old::AgentConnection, pub connection: acp_old::AgentConnection,
pub child_status: Task<Result<()>>, pub child_status: Task<Result<()>>,
} }
impl AgentConnection for OldAcpAgentConnection { impl AgentConnection for OldAcpAgentConnection {
fn name(&self) -> &'static str {
self.name
}
fn new_thread( fn new_thread(
self: Rc<Self>, self: Rc<Self>,
project: Entity<Project>, project: Entity<Project>,
@ -63,7 +70,7 @@ impl AgentConnection for OldAcpAgentConnection {
cx.update(|cx| { cx.update(|cx| {
let thread = cx.new(|cx| { let thread = cx.new(|cx| {
let session_id = acp::SessionId("acp-old-no-id".into()); let session_id = acp::SessionId("acp-old-no-id".into());
AcpThread::new(self.clone(), "Gemini".into(), project, session_id, cx) AcpThread::new(self.clone(), project, session_id, cx)
}); });
thread thread
}) })

View file

@ -197,6 +197,10 @@ fn send_interrupt(_pid: i32) -> anyhow::Result<()> {
} }
impl AgentConnection for ClaudeAgentConnection { impl AgentConnection for ClaudeAgentConnection {
fn name(&self) -> &'static str {
ClaudeCode.name()
}
fn new_thread( fn new_thread(
self: Rc<Self>, self: Rc<Self>,
project: Entity<Project>, project: Entity<Project>,
@ -204,15 +208,8 @@ impl AgentConnection for ClaudeAgentConnection {
cx: &mut AsyncApp, cx: &mut AsyncApp,
) -> Task<Result<Entity<AcpThread>>> { ) -> Task<Result<Entity<AcpThread>>> {
let session_id = self.session_id.clone(); let session_id = self.session_id.clone();
let thread_result = cx.new(|cx| { let thread_result =
AcpThread::new( cx.new(|cx| AcpThread::new(self.clone(), project, session_id.clone(), cx));
self.clone(),
"Claude".into(),
project,
session_id.clone(),
cx,
)
});
if let Ok(thread) = &thread_result { if let Ok(thread) = &thread_result {
self.threads_map self.threads_map

View file

@ -51,6 +51,7 @@ impl<T: StdioAgentServer + 'static> AgentServer for T {
let root_dir = root_dir.to_path_buf(); let root_dir = root_dir.to_path_buf();
let project = project.clone(); let project = project.clone();
let this = self.clone(); let this = self.clone();
let name = self.name();
cx.spawn(async move |cx| { cx.spawn(async move |cx| {
let command = this.command(&project, cx).await?; let command = this.command(&project, cx).await?;
@ -108,6 +109,7 @@ impl<T: StdioAgentServer + 'static> AgentServer for T {
}); });
let connection: Rc<dyn AgentConnection> = Rc::new(OldAcpAgentConnection { let connection: Rc<dyn AgentConnection> = Rc::new(OldAcpAgentConnection {
name,
connection, connection,
child_status, child_status,
}); });