Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
acp: Hide history unless in native agent (#36644)
Conrad Irwind8fc779a6758
diff --git a/crates/agent2/src/history_store.rs b/crates/agent2/src/history_store.rsindex 2d70164a668..78d83cc1d05 100644--- a/crates/agent2/src/history_store.rs+++ b/crates/agent2/src/history_store.rs@@ -10,6 +10,7 @@ use itertools::Itertools;use paths::contexts_dir;use serde::{Deserialize, Serialize};use std::{collections::VecDeque, path::Path, sync::Arc, time::Duration};+use ui::ElementId;use util::ResultExt as _;const MAX_RECENTLY_OPENED_ENTRIES: usize = 6;@@ -68,6 +69,15 @@ pub enum HistoryEntryId {TextThread(Arc<Path>),}+impl Into<ElementId> for HistoryEntryId {+ fn into(self) -> ElementId {+ match self {+ HistoryEntryId::AcpThread(session_id) => ElementId::Name(session_id.0.into()),+ HistoryEntryId::TextThread(path) => ElementId::Path(path),+ }+ }+}+#[derive(Serialize, Deserialize, Debug)]enum SerializedRecentOpen {AcpThread(String),diff --git a/crates/agent_ui/src/acp/thread_history.rs b/crates/agent_ui/src/acp/thread_history.rsindex 68a41f31d0d..d76969378ce 100644--- a/crates/agent_ui/src/acp/thread_history.rs+++ b/crates/agent_ui/src/acp/thread_history.rs@@ -673,18 +673,9 @@ impl AcpHistoryEntryElement {impl RenderOnce for AcpHistoryEntryElement {fn render(self, _window: &mut Window, _cx: &mut App) -> impl IntoElement {- let (id, title, timestamp) = match &self.entry {- HistoryEntry::AcpThread(thread) => (- thread.id.to_string(),- thread.title.clone(),- thread.updated_at,- ),- HistoryEntry::TextThread(context) => (- context.path.to_string_lossy().to_string(),- context.title.clone(),- context.mtime.to_utc(),- ),- };+ let id = self.entry.id();+ let title = self.entry.title();+ let timestamp = self.entry.updated_at();let formatted_time = {let now = chrono::Utc::now();@@ -701,7 +692,7 @@ impl RenderOnce for AcpHistoryEntryElement {}};- ListItem::new(SharedString::from(id))+ ListItem::new(id).rounded().toggle_state(self.selected).spacing(ListItemSpacing::Sparse)diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rsindex f8c616c9e03..090e224b4d1 100644--- a/crates/agent_ui/src/acp/thread_view.rs+++ b/crates/agent_ui/src/acp/thread_view.rs@@ -2404,16 +2404,18 @@ impl AcpThreadView {fn render_empty_state(&self, window: &mut Window, cx: &mut Context<Self>) -> AnyElement {let loading = matches!(&self.thread_state, ThreadState::Loading { .. });- let recent_history = self- .history_store- .update(cx, |history_store, cx| history_store.recent_entries(3, cx));- let no_history = self- .history_store- .update(cx, |history_store, cx| history_store.is_empty(cx));+ let render_history = self+ .agent+ .clone()+ .downcast::<agent2::NativeAgentServer>()+ .is_some()+ && self+ .history_store+ .update(cx, |history_store, cx| !history_store.is_empty(cx));v_flex().size_full()- .when(no_history, |this| {+ .when(!render_history, |this| {this.child(v_flex().size_full()@@ -2445,7 +2447,10 @@ impl AcpThreadView {})),)})- .when(!no_history, |this| {+ .when(render_history, |this| {+ let recent_history = self+ .history_store+ .update(cx, |history_store, cx| history_store.recent_entries(3, cx));this.justify_end().child(v_flex().child(