Re-add history entries for native agent threads (#36500)
Closes #ISSUE Release Notes: - N/A --------- Co-authored-by: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
parent
6b6eb11643
commit
6ba52a3a42
16 changed files with 2007 additions and 119 deletions
|
@ -9,6 +9,7 @@ use agent::{TextThreadStore, ThreadStore};
|
|||
use agent_client_protocol::{self as acp};
|
||||
use agent_servers::{AgentServer, ClaudeCode};
|
||||
use agent_settings::{AgentProfileId, AgentSettings, CompletionMode, NotifyWhenAgentWaiting};
|
||||
use agent2::DbThreadMetadata;
|
||||
use anyhow::bail;
|
||||
use audio::{Audio, Sound};
|
||||
use buffer_diff::BufferDiff;
|
||||
|
@ -155,6 +156,7 @@ enum ThreadState {
|
|||
impl AcpThreadView {
|
||||
pub fn new(
|
||||
agent: Rc<dyn AgentServer>,
|
||||
resume_thread: Option<DbThreadMetadata>,
|
||||
workspace: WeakEntity<Workspace>,
|
||||
project: Entity<Project>,
|
||||
thread_store: Entity<ThreadStore>,
|
||||
|
@ -203,7 +205,7 @@ impl AcpThreadView {
|
|||
workspace: workspace.clone(),
|
||||
project: project.clone(),
|
||||
entry_view_state,
|
||||
thread_state: Self::initial_state(agent, workspace, project, window, cx),
|
||||
thread_state: Self::initial_state(agent, resume_thread, workspace, project, window, cx),
|
||||
message_editor,
|
||||
model_selector: None,
|
||||
profile_selector: None,
|
||||
|
@ -228,6 +230,7 @@ impl AcpThreadView {
|
|||
|
||||
fn initial_state(
|
||||
agent: Rc<dyn AgentServer>,
|
||||
resume_thread: Option<DbThreadMetadata>,
|
||||
workspace: WeakEntity<Workspace>,
|
||||
project: Entity<Project>,
|
||||
window: &mut Window,
|
||||
|
@ -254,28 +257,27 @@ impl AcpThreadView {
|
|||
}
|
||||
};
|
||||
|
||||
// this.update_in(cx, |_this, _window, cx| {
|
||||
// let status = connection.exit_status(cx);
|
||||
// cx.spawn(async move |this, cx| {
|
||||
// let status = status.await.ok();
|
||||
// this.update(cx, |this, cx| {
|
||||
// this.thread_state = ThreadState::ServerExited { status };
|
||||
// cx.notify();
|
||||
// })
|
||||
// .ok();
|
||||
// })
|
||||
// .detach();
|
||||
// })
|
||||
// .ok();
|
||||
|
||||
let Some(result) = cx
|
||||
.update(|_, cx| {
|
||||
let result = if let Some(native_agent) = connection
|
||||
.clone()
|
||||
.downcast::<agent2::NativeAgentConnection>()
|
||||
&& let Some(resume) = resume_thread
|
||||
{
|
||||
cx.update(|_, cx| {
|
||||
native_agent
|
||||
.0
|
||||
.update(cx, |agent, cx| agent.open_thread(resume.id, cx))
|
||||
})
|
||||
.log_err()
|
||||
} else {
|
||||
cx.update(|_, cx| {
|
||||
connection
|
||||
.clone()
|
||||
.new_thread(project.clone(), &root_dir, cx)
|
||||
})
|
||||
.log_err()
|
||||
else {
|
||||
};
|
||||
|
||||
let Some(result) = result else {
|
||||
return;
|
||||
};
|
||||
|
||||
|
@ -382,6 +384,7 @@ impl AcpThreadView {
|
|||
this.update(cx, |this, cx| {
|
||||
this.thread_state = Self::initial_state(
|
||||
agent.clone(),
|
||||
None,
|
||||
this.workspace.clone(),
|
||||
this.project.clone(),
|
||||
window,
|
||||
|
@ -842,6 +845,7 @@ impl AcpThreadView {
|
|||
} else {
|
||||
this.thread_state = Self::initial_state(
|
||||
agent,
|
||||
None,
|
||||
this.workspace.clone(),
|
||||
project.clone(),
|
||||
window,
|
||||
|
@ -4044,6 +4048,7 @@ pub(crate) mod tests {
|
|||
cx.new(|cx| {
|
||||
AcpThreadView::new(
|
||||
Rc::new(agent),
|
||||
None,
|
||||
workspace.downgrade(),
|
||||
project,
|
||||
thread_store.clone(),
|
||||
|
@ -4248,6 +4253,7 @@ pub(crate) mod tests {
|
|||
cx.new(|cx| {
|
||||
AcpThreadView::new(
|
||||
Rc::new(StubAgentServer::new(connection.as_ref().clone())),
|
||||
None,
|
||||
workspace.downgrade(),
|
||||
project.clone(),
|
||||
thread_store.clone(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue