This commit is contained in:
Conrad Irwin 2025-08-15 14:46:52 -06:00
parent fd8ea2acfc
commit 251baacdab
12 changed files with 75 additions and 33 deletions

View file

@ -21,6 +21,7 @@ agent-client-protocol.workspace = true
agent.workspace = true
anyhow.workspace = true
buffer_diff.workspace = true
chrono.workspace = true
collections.workspace = true
editor.workspace = true
file_icons.workspace = true

View file

@ -6,11 +6,13 @@ mod terminal;
pub use connection::*;
pub use diff::*;
pub use mention::*;
use serde::{Deserialize, Serialize};
pub use terminal::*;
use action_log::ActionLog;
use agent_client_protocol as acp;
use anyhow::{Context as _, Result, anyhow};
use chrono::{DateTime, Utc};
use editor::Bias;
use futures::{FutureExt, channel::oneshot, future::BoxFuture};
use gpui::{AppContext, AsyncApp, Context, Entity, EventEmitter, SharedString, Task, WeakEntity};
@ -632,6 +634,13 @@ impl PlanEntry {
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AcpThreadMetadata {
pub id: acp::SessionId,
pub title: SharedString,
pub updated_at: DateTime<Utc>,
}
pub struct AcpThread {
title: SharedString,
entries: Vec<AgentThreadEntry>,
@ -1608,7 +1617,7 @@ mod tests {
use super::*;
use anyhow::anyhow;
use futures::{channel::mpsc, future::LocalBoxFuture, select};
use gpui::{AsyncApp, TestAppContext, WeakEntity};
use gpui::{App, AsyncApp, TestAppContext, WeakEntity};
use indoc::indoc;
use project::{FakeFs, Fs};
use rand::Rng as _;
@ -2284,7 +2293,7 @@ mod tests {
self: Rc<Self>,
project: Entity<Project>,
_cwd: &Path,
cx: &mut gpui::App,
cx: &mut App,
) -> Task<gpui::Result<Entity<AcpThread>>> {
let session_id = acp::SessionId(
rand::thread_rng()
@ -2300,6 +2309,10 @@ mod tests {
Task::ready(Ok(thread))
}
fn list_threads(&self, _: &mut App) -> Task<Result<Vec<AcpThreadMetadata>>> {
unimplemented!()
}
fn authenticate(&self, method: acp::AuthMethodId, _cx: &mut App) -> Task<gpui::Result<()>> {
if self.auth_methods().iter().any(|m| m.id == method) {
Task::ready(Ok(()))

View file

@ -1,4 +1,4 @@
use crate::AcpThread;
use crate::{AcpThread, AcpThreadMetadata};
use agent_client_protocol::{self as acp};
use anyhow::Result;
use collections::IndexMap;
@ -26,6 +26,8 @@ pub trait AgentConnection {
cx: &mut App,
) -> Task<Result<Entity<AcpThread>>>;
fn list_threads(&self, _cx: &mut App) -> Task<Result<Vec<AcpThreadMetadata>>>;
fn auth_methods(&self) -> &[acp::AuthMethod];
fn authenticate(&self, method: acp::AuthMethodId, cx: &mut App) -> Task<Result<()>>;
@ -264,6 +266,10 @@ mod test_support {
unimplemented!()
}
fn list_threads(&self, _: &mut App) -> Task<Result<Vec<AcpThreadMetadata>>> {
unimplemented!()
}
fn prompt(
&self,
_id: Option<UserMessageId>,