Put name on connection as well for Thread Title
This commit is contained in:
parent
44cae51ea3
commit
755cff59a1
4 changed files with 18 additions and 14 deletions
|
@ -572,8 +572,6 @@ impl Error for LoadError {}
|
|||
impl AcpThread {
|
||||
pub fn new(
|
||||
connection: Rc<dyn AgentConnection>,
|
||||
// todo! remove me
|
||||
title: SharedString,
|
||||
project: Entity<Project>,
|
||||
session_id: acp::SessionId,
|
||||
cx: &mut Context<Self>,
|
||||
|
@ -585,7 +583,7 @@ impl AcpThread {
|
|||
shared_buffers: Default::default(),
|
||||
entries: Default::default(),
|
||||
plan: Default::default(),
|
||||
title,
|
||||
title: connection.name().into(),
|
||||
project,
|
||||
send_task: None,
|
||||
connection,
|
||||
|
@ -1783,13 +1781,13 @@ mod tests {
|
|||
}
|
||||
});
|
||||
let connection = OldAcpAgentConnection {
|
||||
name: "test",
|
||||
connection,
|
||||
child_status: io_task,
|
||||
};
|
||||
|
||||
AcpThread::new(
|
||||
Rc::new(connection),
|
||||
"Test".into(),
|
||||
project,
|
||||
acp::SessionId("test".into()),
|
||||
cx,
|
||||
|
|
|
@ -10,6 +10,8 @@ use ui::App;
|
|||
use crate::AcpThread;
|
||||
|
||||
pub trait AgentConnection {
|
||||
fn name(&self) -> &'static str;
|
||||
|
||||
fn new_thread(
|
||||
self: Rc<Self>,
|
||||
project: Entity<Project>,
|
||||
|
@ -35,11 +37,16 @@ impl fmt::Display for Unauthenticated {
|
|||
}
|
||||
|
||||
pub struct OldAcpAgentConnection {
|
||||
pub name: &'static str,
|
||||
pub connection: acp_old::AgentConnection,
|
||||
pub child_status: Task<Result<()>>,
|
||||
}
|
||||
|
||||
impl AgentConnection for OldAcpAgentConnection {
|
||||
fn name(&self) -> &'static str {
|
||||
self.name
|
||||
}
|
||||
|
||||
fn new_thread(
|
||||
self: Rc<Self>,
|
||||
project: Entity<Project>,
|
||||
|
@ -63,7 +70,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(self.clone(), "Gemini".into(), project, session_id, cx)
|
||||
AcpThread::new(self.clone(), project, session_id, cx)
|
||||
});
|
||||
thread
|
||||
})
|
||||
|
|
|
@ -197,6 +197,10 @@ fn send_interrupt(_pid: i32) -> anyhow::Result<()> {
|
|||
}
|
||||
|
||||
impl AgentConnection for ClaudeAgentConnection {
|
||||
fn name(&self) -> &'static str {
|
||||
ClaudeCode.name()
|
||||
}
|
||||
|
||||
fn new_thread(
|
||||
self: Rc<Self>,
|
||||
project: Entity<Project>,
|
||||
|
@ -204,15 +208,8 @@ impl AgentConnection for ClaudeAgentConnection {
|
|||
cx: &mut AsyncApp,
|
||||
) -> Task<Result<Entity<AcpThread>>> {
|
||||
let session_id = self.session_id.clone();
|
||||
let thread_result = cx.new(|cx| {
|
||||
AcpThread::new(
|
||||
self.clone(),
|
||||
"Claude".into(),
|
||||
project,
|
||||
session_id.clone(),
|
||||
cx,
|
||||
)
|
||||
});
|
||||
let thread_result =
|
||||
cx.new(|cx| AcpThread::new(self.clone(), project, session_id.clone(), cx));
|
||||
|
||||
if let Ok(thread) = &thread_result {
|
||||
self.threads_map
|
||||
|
|
|
@ -51,6 +51,7 @@ impl<T: StdioAgentServer + 'static> AgentServer for T {
|
|||
let root_dir = root_dir.to_path_buf();
|
||||
let project = project.clone();
|
||||
let this = self.clone();
|
||||
let name = self.name();
|
||||
|
||||
cx.spawn(async move |cx| {
|
||||
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 {
|
||||
name,
|
||||
connection,
|
||||
child_status,
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue