Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

sidebar: Fix sidebar and archive view content display (#51930)

Danilo Leald09b335492c4
diff --git a/crates/agent_ui/src/thread_metadata_store.rs b/crates/agent_ui/src/thread_metadata_store.rs
index fdc466d9bfc..7b20ac26827 100644
--- a/crates/agent_ui/src/thread_metadata_store.rs
+++ b/crates/agent_ui/src/thread_metadata_store.rs
@@ -188,14 +188,6 @@ impl SidebarThreadMetadataStore {
})
}
- pub fn list_sidebar_ids(&self, cx: &App) -> Task<Result<Vec<acp::SessionId>>> {
- let db = self.db.clone();
- cx.background_spawn(async move {
- let s = db.list_sidebar_ids()?;
- Ok(s)
- })
- }
-
pub fn list(&self, cx: &App) -> Task<Result<Vec<ThreadMetadata>>> {
let db = self.db.clone();
cx.background_spawn(async move {
@@ -323,16 +315,6 @@ impl ThreadMetadataDb {
.map(|ids| ids.into_iter().map(|id| acp::SessionId::new(id)).collect())
}
- /// List session IDs of threads that belong to a real project workspace
- /// (i.e. have non-empty folder_paths). These are the threads shown in
- /// the sidebar, as opposed to threads created in empty workspaces.
- pub fn list_sidebar_ids(&self) -> anyhow::Result<Vec<acp::SessionId>> {
- self.select::<Arc<str>>(
- "SELECT session_id FROM sidebar_threads WHERE folder_paths IS NOT NULL AND folder_paths != ''",
- )?()
- .map(|ids| ids.into_iter().map(|id| acp::SessionId::new(id)).collect())
- }
-
/// List all sidebar thread metadata, ordered by updated_at descending.
pub fn list(&self) -> anyhow::Result<Vec<ThreadMetadata>> {
self.select::<ThreadMetadata>(
diff --git a/crates/agent_ui/src/threads_archive_view.rs b/crates/agent_ui/src/threads_archive_view.rs
index 06085bfc4df..a7faaeca906 100644
--- a/crates/agent_ui/src/threads_archive_view.rs
+++ b/crates/agent_ui/src/threads_archive_view.rs
@@ -2,7 +2,7 @@ use std::sync::Arc;
use crate::{
Agent, RemoveSelectedThread, agent_connection_store::AgentConnectionStore,
- thread_history::ThreadHistory, thread_metadata_store::SidebarThreadMetadataStore,
+ thread_history::ThreadHistory,
};
use acp_thread::AgentSessionInfo;
use agent::ThreadStore;
@@ -244,21 +244,11 @@ impl ThreadsArchiveView {
let today = Local::now().naive_local().date();
self._update_items_task.take();
- let unarchived_ids_task = SidebarThreadMetadataStore::global(cx)
- .read(cx)
- .list_sidebar_ids(cx);
self._update_items_task = Some(cx.spawn(async move |this, cx| {
- let unarchived_session_ids = unarchived_ids_task.await.unwrap_or_default();
-
let mut items = Vec::with_capacity(sessions.len() + 5);
let mut current_bucket: Option<TimeBucket> = None;
for session in sessions {
- // Skip sessions that are shown in the sidebar
- if unarchived_session_ids.contains(&session.session_id) {
- continue;
- }
-
let highlight_positions = if !query.is_empty() {
let title = session.title.as_ref().map(|t| t.as_ref()).unwrap_or("");
match fuzzy_match_positions(&query, title) {
diff --git a/crates/sidebar/src/sidebar.rs b/crates/sidebar/src/sidebar.rs
index c628ea32885..7236e1e5e85 100644
--- a/crates/sidebar/src/sidebar.rs
+++ b/crates/sidebar/src/sidebar.rs
@@ -321,7 +321,7 @@ impl Sidebar {
this.update_entries(cx);
});
- Self {
+ let mut this = Self {
_list_threads_task: None,
multi_workspace: multi_workspace.downgrade(),
width: DEFAULT_WIDTH,
@@ -340,7 +340,9 @@ impl Sidebar {
recent_projects_popover_handle: PopoverMenuHandle::default(),
_subscriptions: Vec::new(),
_draft_observation: None,
- }
+ };
+ this.list_threads(cx);
+ this
}
fn subscribe_to_workspace(