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.

agent: Use correct timezone for thread history separators (#30059)

Agus Zubiaga264097e25330
diff --git a/crates/agent/src/thread_history.rs b/crates/agent/src/thread_history.rs
index 8a348a5b712..87b67a60a5b 100644
--- a/crates/agent/src/thread_history.rs
+++ b/crates/agent/src/thread_history.rs
@@ -3,7 +3,7 @@ use std::ops::Range;
use std::sync::Arc;
use assistant_context_editor::SavedContextMetadata;
-use chrono::{Datelike as _, NaiveDate, TimeDelta, Utc};
+use chrono::{Datelike as _, Local, NaiveDate, TimeDelta};
use editor::{Editor, EditorEvent};
use fuzzy::{StringMatch, StringMatchCandidate};
use gpui::{
@@ -140,10 +140,14 @@ impl ThreadHistory {
let bg_task = cx.background_spawn(async move {
let mut bucket = None;
- let today = Utc::now().naive_local().date();
+ let today = Local::now().naive_local().date();
for (index, entry) in all_entries.iter().enumerate() {
- let entry_date = entry.updated_at().naive_local().date();
+ let entry_date = entry
+ .updated_at()
+ .with_timezone(&Local)
+ .naive_local()
+ .date();
let entry_bucket = TimeBucket::from_dates(today, entry_date);
if Some(entry_bucket) != bucket {
@@ -252,6 +256,14 @@ impl ThreadHistory {
}
}
+ fn list_item_count(&self) -> usize {
+ match &self.search_state {
+ SearchState::Empty => self.separated_items.len(),
+ SearchState::Searching { .. } => 0,
+ SearchState::Searched { matches, .. } => matches.len(),
+ }
+ }
+
fn search_produced_no_matches(&self) -> bool {
match &self.search_state {
SearchState::Empty => false,
@@ -575,7 +587,7 @@ impl Render for ThreadHistory {
uniform_list(
cx.entity().clone(),
"thread-history",
- self.matched_count(),
+ self.list_item_count(),
Self::list_items,
)
.p_1()