diff --git a/crates/sidebar/src/sidebar.rs b/crates/sidebar/src/sidebar.rs index 602f60d70d8d2f30ebfd3296708d0974fd48a2af..3bb6c9dbef4e1ee986bacd6f9f187b3f2b8f5f74 100644 --- a/crates/sidebar/src/sidebar.rs +++ b/crates/sidebar/src/sidebar.rs @@ -2814,16 +2814,7 @@ impl Sidebar { } } - // Capture metadata before archiving in case we need to cancel. - let thread_metadata = self.contents.entries.iter().find_map(|entry| { - if let ListEntry::Thread(t) = entry { - if &t.metadata.session_id == session_id { - return Some(t.metadata.clone()); - } - } - None - }); - self.maybe_delete_git_worktree_for_archived_thread(session_id, thread_metadata, window, cx); + self.maybe_delete_git_worktree_for_archived_thread(session_id, window, cx); } /// If the thread being archived is associated with a linked git worktree, @@ -2833,7 +2824,6 @@ impl Sidebar { fn maybe_delete_git_worktree_for_archived_thread( &self, session_id: &acp::SessionId, - thread_metadata: Option, window: &mut Window, cx: &mut Context, ) { @@ -2899,6 +2889,7 @@ impl Sidebar { let fs = ::global(cx); let worktree_path_str = worktree_path.to_string_lossy().to_string(); let main_repo_path_str = main_repo_path.to_string_lossy().to_string(); + let session_id = session_id.clone(); cx.spawn_in(window, async move |_this, cx| { if !is_last_thread { @@ -2909,11 +2900,9 @@ impl Sidebar { // Helper: unarchive the thread so it reappears in the sidebar. let unarchive = |cx: &mut AsyncWindowContext| { - if let Some(metadata) = &thread_metadata { - store.update(cx, |store, cx| { - store.unarchive(&metadata.session_id, cx); - }); - } + store.update(cx, |store, cx| { + store.unarchive(&session_id, cx); + }); }; // Helper: undo both WIP commits on the worktree.