Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Rename Archive view to Thread History (#54075)
Nathan Sobo3dfbfc8fffe4
diff --git a/assets/icons/clock.svg b/assets/icons/clock.svgnew file mode 100644index 00000000000..fb8c6f851ff--- /dev/null+++ b/assets/icons/clock.svg@@ -0,0 +1,4 @@+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">+<path d="M8 4.87936V8L10.229 9.33742" stroke="#C6CAD0" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>+<path d="M8 14C11.3137 14 14 11.3137 14 8C14 4.6863 11.3137 2 8 2C4.6863 2 2 4.6863 2 8C2 11.3137 4.6863 14 8 14Z" stroke="#C6CAD0" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>+</svg>diff --git a/assets/icons/history.svg b/assets/icons/history.svgdeleted file mode 100644index f9b803f2bd6..00000000000--- a/assets/icons/history.svg+++ /dev/null@@ -1,4 +0,0 @@-<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">-<path d="M12.3329 11.0949V3.66708C12.3329 3.33875 12.2025 3.02387 11.9703 2.7917C11.7381 2.55954 11.4233 2.42911 11.0949 2.42911H3.0481" stroke="#C6CAD0" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>-<path d="M5.52407 13.5709H12.9519C13.2802 13.5709 13.5951 13.4404 13.8273 13.2083C14.0595 12.9761 14.1899 12.6612 14.1899 12.3329V11.7139C14.1899 11.5497 14.1247 11.3923 14.0086 11.2762C13.8925 11.1601 13.7351 11.0949 13.5709 11.0949H7.38103C7.21687 11.0949 7.05943 11.1601 6.94334 11.2762C6.82726 11.3923 6.76205 11.5497 6.76205 11.7139V12.3329C6.76205 12.6612 6.63162 12.9761 6.39945 13.2083C6.16729 13.4404 5.8524 13.5709 5.52407 13.5709ZM5.52407 13.5709C5.19574 13.5709 4.88086 13.4404 4.64869 13.2083C4.41653 12.9761 4.2861 12.6612 4.2861 12.3329V3.66708C4.2861 3.33875 4.15567 3.02387 3.9235 2.7917C3.69134 2.55954 3.37646 2.42911 3.04812 2.42911C2.71979 2.42911 2.40491 2.55954 2.17274 2.7917C1.94058 3.02387 1.81015 3.33875 1.81015 3.66708V4.90506C1.81015 5.06922 1.87536 5.22666 1.99145 5.34275C2.10753 5.45883 2.26497 5.52404 2.42914 5.52404H4.2861" stroke="#C6CAD0" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>-</svg>diff --git a/assets/icons/thread_import.svg b/assets/icons/thread_import.svgdeleted file mode 100644index a56b5a7cccc..00000000000--- a/assets/icons/thread_import.svg+++ /dev/null@@ -1,5 +0,0 @@-<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">-<path d="M8.31947 5.03803L8.31947 9.28259" stroke="#C6CAD0" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>-<path d="M6.19576 7.67419L8.31948 9.79792L10.4432 7.67419" stroke="#C6CAD0" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>-<path d="M5.64894 12.8952C6.89401 13.5339 8.32626 13.7069 9.68759 13.383C11.0489 13.0592 12.2499 12.2598 13.0739 11.1288C13.8979 9.99787 14.291 8.60973 14.1821 7.21464C14.0733 5.81955 13.4698 4.5092 12.4803 3.51972C11.4908 2.53024 10.1805 1.92671 8.78535 1.81787C7.39026 1.70904 6.00218 2.10207 4.87122 2.92612C3.74026 3.75018 2.94082 4.95106 2.61695 6.3124C2.29307 7.67374 2.46606 9.10598 3.10475 10.3511L1.80005 14.1999L5.64894 12.8952Z" stroke="#C6CAD0" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>-</svg>diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.jsonindex 15a4a6f64d5..97a84303b4f 100644--- a/assets/keymaps/default-linux.json+++ b/assets/keymaps/default-linux.json@@ -384,6 +384,12 @@"backspace": "agent::RemoveSelectedThread",},},+ {+ "context": "ThreadsArchiveView",+ "bindings": {+ "shift-backspace": "agent::ArchiveSelectedThread",+ },+ },{"context": "RulesLibrary","bindings": {@@ -720,7 +726,7 @@"right": "menu::SelectChild","enter": "menu::Confirm","ctrl-f": "agents_sidebar::FocusSidebarFilter",- "ctrl-g": "agents_sidebar::ViewAllThreads",+ "ctrl-g": "agents_sidebar::ToggleThreadHistory","shift-backspace": "agent::RemoveSelectedThread","ctrl-tab": "agents_sidebar::ToggleThreadSwitcher","ctrl-shift-tab": ["agents_sidebar::ToggleThreadSwitcher", { "select_last": true }],diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.jsonindex 302225c87e3..38207365ef3 100644--- a/assets/keymaps/default-macos.json+++ b/assets/keymaps/default-macos.json@@ -431,6 +431,12 @@"shift-backspace": "agent::RemoveSelectedThread",},},+ {+ "context": "ThreadsArchiveView",+ "bindings": {+ "backspace": "agent::ArchiveSelectedThread",+ },+ },{"context": "RulesLibrary","use_key_equivalents": true,@@ -776,7 +782,7 @@"right": "menu::SelectChild","enter": "menu::Confirm","cmd-f": "agents_sidebar::FocusSidebarFilter",- "cmd-g": "agents_sidebar::ViewAllThreads",+ "cmd-g": "agents_sidebar::ToggleThreadHistory","shift-backspace": "agent::RemoveSelectedThread","ctrl-tab": "agents_sidebar::ToggleThreadSwitcher","ctrl-shift-tab": ["agents_sidebar::ToggleThreadSwitcher", { "select_last": true }],diff --git a/assets/keymaps/default-windows.json b/assets/keymaps/default-windows.jsonindex 2098f18ff0f..03225bb253f 100644--- a/assets/keymaps/default-windows.json+++ b/assets/keymaps/default-windows.json@@ -386,6 +386,13 @@"backspace": "agent::RemoveSelectedThread",},},+ {+ "context": "ThreadsArchiveView",+ "use_key_equivalents": true,+ "bindings": {+ "shift-backspace": "agent::ArchiveSelectedThread",+ },+ },{"context": "RulesLibrary","use_key_equivalents": true,@@ -720,7 +727,7 @@"right": "menu::SelectChild","enter": "menu::Confirm","ctrl-f": "agents_sidebar::FocusSidebarFilter",- "ctrl-g": "agents_sidebar::ViewAllThreads",+ "ctrl-g": "agents_sidebar::ToggleThreadHistory","shift-backspace": "agent::RemoveSelectedThread","ctrl-tab": "agents_sidebar::ToggleThreadSwitcher","ctrl-shift-tab": ["agents_sidebar::ToggleThreadSwitcher", { "select_last": true }],diff --git a/crates/agent_ui/src/agent_ui.rs b/crates/agent_ui/src/agent_ui.rsindex b5b6a7dea69..9fa038b6e25 100644--- a/crates/agent_ui/src/agent_ui.rs+++ b/crates/agent_ui/src/agent_ui.rs@@ -112,6 +112,8 @@ actions!(OpenHistory,/// Adds a context server to the configuration.AddContextServer,+ /// Archives the currently selected thread.+ ArchiveSelectedThread,/// Removes the currently selected thread.RemoveSelectedThread,/// Starts a chat conversation with follow-up enabled.diff --git a/crates/agent_ui/src/thread_import.rs b/crates/agent_ui/src/thread_import.rsindex cb123448441..944813525b4 100644--- a/crates/agent_ui/src/thread_import.rs+++ b/crates/agent_ui/src/thread_import.rs@@ -391,7 +391,7 @@ impl Render for ThreadImportModal {.headline("Import External Agent Threads").description("Import threads from agents like Claude Agent, Codex, and more, whether started in Zed or another client. \- Choose which agents to include, and their threads will appear in your list."+ Choose which agents to include, and their threads will appear in your thread history.").show_dismiss_button(true),diff --git a/crates/agent_ui/src/threads_archive_view.rs b/crates/agent_ui/src/threads_archive_view.rsindex 351e83bdff7..6547187547c 100644--- a/crates/agent_ui/src/threads_archive_view.rs+++ b/crates/agent_ui/src/threads_archive_view.rs@@ -7,7 +7,7 @@ use crate::agent_connection_store::AgentConnectionStore;use crate::thread_metadata_store::{ThreadId, ThreadMetadata, ThreadMetadataStore, worktree_info_from_thread_paths,};-use crate::{Agent, DEFAULT_THREAD_TITLE, RemoveSelectedThread};+use crate::{Agent, ArchiveSelectedThread, DEFAULT_THREAD_TITLE, RemoveSelectedThread};use agent::ThreadStore;use agent_client_protocol as acp;@@ -45,6 +45,13 @@ use workspace::{use zed_actions::agents_sidebar::FocusSidebarFilter;use zed_actions::editor::{MoveDown, MoveUp};+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]+enum ThreadFilter {+ #[default]+ All,+ ArchivedOnly,+}+#[derive(Clone)]enum ArchiveListItem {BucketSeparator(TimeBucket),@@ -117,6 +124,7 @@ pub enum ThreadsArchiveViewEvent {Close,Activate { thread: ThreadMetadata },CancelRestore { thread_id: ThreadId },+ Import,}impl EventEmitter<ThreadsArchiveViewEvent> for ThreadsArchiveView {}@@ -139,7 +147,7 @@ pub struct ThreadsArchiveView {archived_thread_ids: HashSet<ThreadId>,archived_branch_names: HashMap<ThreadId, HashMap<PathBuf, String>>,_load_branch_names_task: Task<()>,- show_archived_only: bool,+ thread_filter: ThreadFilter,}impl ThreadsArchiveView {@@ -213,7 +221,7 @@ impl ThreadsArchiveView {archived_thread_ids: HashSet::default(),archived_branch_names: HashMap::default(),_load_branch_names_task: Task::ready(()),- show_archived_only: false,+ thread_filter: ThreadFilter::All,};this.update_items(cx);@@ -252,11 +260,14 @@ impl ThreadsArchiveView {}fn update_items(&mut self, cx: &mut Context<Self>) {- let show_archived_only = self.show_archived_only;+ let thread_filter = self.thread_filter;let sessions = ThreadMetadataStore::global(cx).read(cx).entries()- .filter(|t| !show_archived_only || t.archived)+ .filter(|t| match thread_filter {+ ThreadFilter::All => true,+ ThreadFilter::ArchivedOnly => t.archived,+ }).sorted_by_cached_key(|t| t.created_at.unwrap_or(t.updated_at)).rev().cloned()@@ -388,6 +399,24 @@ impl ThreadsArchiveView {ThreadMetadataStore::global(cx).update(cx, |store, cx| store.archive(thread_id, None, cx));}+ fn archive_selected_thread(+ &mut self,+ _: &ArchiveSelectedThread,+ _window: &mut Window,+ cx: &mut Context<Self>,+ ) {+ let Some(ix) = self.selection else { return };+ let Some(ArchiveListItem::Entry { thread, .. }) = self.items.get(ix) else {+ return;+ };++ if thread.archived {+ return;+ }++ self.archive_thread(thread.thread_id, cx);+ }+fn unarchive_thread(&mut self,thread: ThreadMetadata,@@ -605,13 +634,14 @@ impl ThreadsArchiveView {&branch_names_for_thread,);- let archived_color = Color::Custom(cx.theme().colors().text_muted.opacity(0.85));+ let archived_color = Color::Custom(cx.theme().colors().icon_muted.opacity(0.6));let base = ThreadItem::new(id, thread.display_title()).icon(icon).when(is_archived, |this| {- this.icon_color(archived_color)- .title_label_color(archived_color)+ this.archived(true)+ .icon_color(archived_color)+ .title_label_color(Color::Muted)}).when_some(icon_from_external_svg, |this, svg| {this.custom_icon_from_external_svg(svg)@@ -693,7 +723,16 @@ impl ThreadsArchiveView {IconButton::new("archive-thread", IconName::Archive).icon_size(IconSize::Small).icon_color(Color::Muted)- .tooltip(Tooltip::text("Archive Thread"))+ .tooltip({+ move |_window, cx| {+ Tooltip::for_action_in(+ "Archive Thread",+ &ArchiveSelectedThread,+ &focus_handle,+ cx,+ )+ }+ }).on_click({let thread_id = thread.thread_id;cx.listener(move |this, _, _, cx| {@@ -852,14 +891,13 @@ impl ThreadsArchiveView {.filter(|item| matches!(item, ArchiveListItem::Entry { .. })).count();+ let has_archived_threads = {+ let store = ThreadMetadataStore::global(cx).read(cx);+ store.archived_entries().next().is_some()+ };+let count_label = if entry_count == 1 {- if self.show_archived_only {- "1 archived thread".to_string()- } else {- "1 thread".to_string()- }- } else if self.show_archived_only {- format!("{} archived threads", entry_count)+ "1 thread".to_string()} else {format!("{} threads", entry_count)};@@ -878,18 +916,37 @@ impl ThreadsArchiveView {.color(Color::Muted),).child(- IconButton::new("toggle-archived-only", IconName::Archive)- .icon_size(IconSize::Small)- .toggle_state(self.show_archived_only)- .tooltip(Tooltip::text(if self.show_archived_only {- "Show All Threads"- } else {- "Show Archived Only"- }))- .on_click(cx.listener(|this, _, _, cx| {- this.show_archived_only = !this.show_archived_only;- this.update_items(cx);- })),+ h_flex()+ .child(+ IconButton::new("thread-import", IconName::Download)+ .icon_size(IconSize::Small)+ .tooltip(Tooltip::text("Import Threads"))+ .on_click(cx.listener(|_this, _, _, cx| {+ cx.emit(ThreadsArchiveViewEvent::Import);+ })),+ )+ .child(+ IconButton::new("filter-archived-only", IconName::Archive)+ .icon_size(IconSize::Small)+ .disabled(!has_archived_threads)+ .toggle_state(self.thread_filter == ThreadFilter::ArchivedOnly)+ .tooltip(Tooltip::text(+ if self.thread_filter == ThreadFilter::ArchivedOnly {+ "Show All Threads"+ } else {+ "Show Only Archived Threads"+ },+ ))+ .on_click(cx.listener(|this, _, _, cx| {+ this.thread_filter =+ if this.thread_filter == ThreadFilter::ArchivedOnly {+ ThreadFilter::All+ } else {+ ThreadFilter::ArchivedOnly+ };+ this.update_items(cx);+ })),+ ),)}}@@ -972,6 +1029,7 @@ impl Render for ThreadsArchiveView {.on_action(cx.listener(Self::select_last)).on_action(cx.listener(Self::confirm)).on_action(cx.listener(Self::remove_selected_thread))+ .on_action(cx.listener(Self::archive_selected_thread)).size_full().child(self.render_header(window, cx)).when(!has_query, |this| this.child(self.render_toolbar(cx)))diff --git a/crates/icons/src/icons.rs b/crates/icons/src/icons.rsindex 9fc8d4220bf..20d7b609d8d 100644--- a/crates/icons/src/icons.rs+++ b/crates/icons/src/icons.rs@@ -66,6 +66,7 @@ pub enum IconName {ChevronUpDown,Circle,CircleHelp,+ Clock,Close,CloudDownload,Code,@@ -153,7 +154,6 @@ pub enum IconName {GitWorktree,Github,Hash,- History,HistoryRerun,Image,Inception,@@ -243,7 +243,6 @@ pub enum IconName {ThinkingModeOff,Thread,ThreadFromSummary,- ThreadImport,ThreadsSidebarLeftClosed,ThreadsSidebarLeftOpen,ThreadsSidebarRightClosed,diff --git a/crates/sidebar/src/sidebar.rs b/crates/sidebar/src/sidebar.rsindex c8bfa93368a..6fb6358e777 100644--- a/crates/sidebar/src/sidebar.rs+++ b/crates/sidebar/src/sidebar.rs@@ -68,8 +68,8 @@ gpui::actions!([/// Creates a new thread in the currently selected or active project group.NewThreadInGroup,- /// Toggles between the thread list and the archive view.- ViewAllThreads,+ /// Toggles between the thread list and the thread history.+ ToggleThreadHistory,]);@@ -89,7 +89,8 @@ const MAX_WIDTH: Pixels = px(800.0);enum SerializedSidebarView {#[default]ThreadList,- Archive,+ #[serde(alias = "Archive")]+ History,}#[derive(Default, Serialize, Deserialize)]@@ -4241,45 +4242,33 @@ impl Sidebar {fn render_sidebar_bottom_bar(&mut self, cx: &mut Context<Self>) -> impl IntoElement {let is_archive = matches!(self.view, SidebarView::Archive(..));- let show_import_button = is_archive && !self.should_render_acp_import_onboarding(cx);let on_right = self.side(cx) == SidebarSide::Right;- let action_buttons = h_flex()+ h_flex()+ .p_1().gap_1().when(on_right, |this| this.flex_row_reverse())- .when(show_import_button, |this| {- this.child(- IconButton::new("thread-import", IconName::ThreadImport)- .icon_size(IconSize::Small)- .tooltip(Tooltip::text("Import External Agent Threads"))- .on_click(cx.listener(|this, _, window, cx| {- this.show_archive(window, cx);- this.show_thread_import_modal(window, cx);- })),- )- })+ .border_t_1()+ .border_color(cx.theme().colors().border)+ .child(self.render_sidebar_toggle_button(cx)).child(- IconButton::new("history", IconName::History)+ IconButton::new("history", IconName::Clock).icon_size(IconSize::Small).toggle_state(is_archive).tooltip(move |_, cx| {- Tooltip::for_action("View All Threads", &ViewAllThreads, cx)+ let label = if is_archive {+ "Hide Thread History"+ } else {+ "Show Thread History"+ };+ Tooltip::for_action(label, &ToggleThreadHistory, cx)}).on_click(cx.listener(|this, _, window, cx| {- this.toggle_archive(&ViewAllThreads, window, cx);+ this.toggle_archive(&ToggleThreadHistory, window, cx);})),)- .child(self.render_recent_projects_button(cx));-- h_flex()- .p_1()- .gap_1()- .when(on_right, |this| this.flex_row_reverse())- .justify_between()- .border_t_1()- .border_color(cx.theme().colors().border)- .child(self.render_sidebar_toggle_button(cx))- .child(action_buttons)+ .child(div().flex_1())+ .child(self.render_recent_projects_button(cx))}fn active_workspace(&self, cx: &App) -> Option<Entity<Workspace>> {@@ -4405,14 +4394,19 @@ impl Sidebar {)}- fn toggle_archive(&mut self, _: &ViewAllThreads, window: &mut Window, cx: &mut Context<Self>) {+ fn toggle_archive(+ &mut self,+ _: &ToggleThreadHistory,+ window: &mut Window,+ cx: &mut Context<Self>,+ ) {match &self.view {SidebarView::ThreadList => {let side = match self.side(cx) {SidebarSide::Left => "left",SidebarSide::Right => "right",};- telemetry::event!("Sidebar Archive Viewed", side = side);+ telemetry::event!("Thread History Viewed", side = side);self.show_archive(window, cx);}SidebarView::Archive(_) => self.show_thread_list(window, cx),@@ -4463,6 +4457,9 @@ impl Sidebar {ThreadsArchiveViewEvent::CancelRestore { thread_id } => {this.restoring_tasks.remove(thread_id);}+ ThreadsArchiveViewEvent::Import => {+ this.show_thread_import_modal(window, cx);+ }},);@@ -4535,7 +4532,7 @@ fn render_import_onboarding_banner(.style(ButtonStyle::OutlinedCustom(cx.theme().colors().border)).label_size(LabelSize::Small).start_icon(- Icon::new(IconName::ThreadImport)+ Icon::new(IconName::Download).size(IconSize::Small).color(Color::Muted),)@@ -4592,7 +4589,7 @@ impl WorkspaceSidebar for Sidebar {width: Some(f32::from(self.width)),active_view: match self.view {SidebarView::ThreadList => SerializedSidebarView::ThreadList,- SidebarView::Archive(_) => SerializedSidebarView::Archive,+ SidebarView::Archive(_) => SerializedSidebarView::History,},};serde_json::to_string(&serialized).ok()@@ -4608,7 +4605,7 @@ impl WorkspaceSidebar for Sidebar {if let Some(width) = serialized.width {self.width = px(width).clamp(MIN_WIDTH, MAX_WIDTH);}- if serialized.active_view == SerializedSidebarView::Archive {+ if serialized.active_view == SerializedSidebarView::History {cx.defer_in(window, |this, window, cx| {this.show_archive(window, cx);});diff --git a/crates/sidebar/src/sidebar_tests.rs b/crates/sidebar/src/sidebar_tests.rsindex d687ae5066f..66820d513a5 100644--- a/crates/sidebar/src/sidebar_tests.rs+++ b/crates/sidebar/src/sidebar_tests.rs@@ -481,7 +481,7 @@ async fn test_restore_serialized_archive_view_does_not_panic(cx: &mut TestAppConlet serialized = serde_json::to_string(&SerializedSidebar {width: Some(400.0),- active_view: SerializedSidebarView::Archive,+ active_view: SerializedSidebarView::History,}).expect("serialization should succeed");diff --git a/crates/ui/src/components/ai/thread_item.rs b/crates/ui/src/components/ai/thread_item.rsindex ccac7a7723b..a106d3fa399 100644--- a/crates/ui/src/components/ai/thread_item.rs+++ b/crates/ui/src/components/ai/thread_item.rs@@ -55,6 +55,7 @@ pub struct ThreadItem {project_name: Option<SharedString>,worktrees: Vec<ThreadItemWorktreeInfo>,is_remote: bool,+ archived: bool,on_click: Option<Box<dyn Fn(&ClickEvent, &mut Window, &mut App) + 'static>>,on_hover: Box<dyn Fn(&bool, &mut Window, &mut App) + 'static>,action_slot: Option<AnyElement>,@@ -86,6 +87,7 @@ impl ThreadItem {project_name: None,worktrees: Vec::new(),is_remote: false,+ archived: false,on_click: None,on_hover: Box::new(|_, _, _| {}),action_slot: None,@@ -183,6 +185,11 @@ impl ThreadItem {self}+ pub fn archived(mut self, archived: bool) -> Self {+ self.archived = archived;+ self+ }+pub fn hovered(mut self, hovered: bool) -> Self {self.hovered = hovered;self@@ -431,6 +438,14 @@ impl RenderOnce for ThreadItem {h_flex().gap_1p5().child(icon_container()) // Icon Spacing+ .when(self.archived, |this| {+ this.child(+ Icon::new(IconName::Archive).size(IconSize::XSmall).color(+ Color::Custom(cx.theme().colors().icon_muted.opacity(0.5)),+ ),+ )+ // .child(dot_separator())+ }).when(has_project_name || has_project_paths || has_worktree,|this| {