All your AI agent sessions in one place — browse, search, resume. Rust + GPUI.
Rust
Unify the session time display
Corey Chiu0611bf4f5217
diff --git a/DESIGN.md b/DESIGN.mdindex 6a9a415..20ab403 100644--- a/DESIGN.md+++ b/DESIGN.md@@ -144,7 +144,7 @@ macOS 不设置横跨三栏的自定义 header。主窗口透明标题栏高 44p- 顶部由 22px 上下文标题、会话总数角标和 icon-only 排序按钮组成;整个标题区固定为 88px,与左栏顶部身份区等高。标题和会话总数保持 2px 紧凑间距,并作为一个信息组在 88px 内整体垂直居中,禁止拆成两条 44px 行。排序按钮与信息组顶部对齐,沿用 16px 图标、透明 ghost 常态和 6px 圆角;当前排序字段和方向放在 tooltip 与菜单选中态中。- 会话流固定 336px;顶部使用 22px 上下文标题、Label 11 会话数量和 icon-only 排序按钮。- 会话行使用 Body 14 标题与 Label 11 元信息,共两行;行内 `SPACE_SM` 上下内边距 + `SPACE_XS` 两行间距。-- 第二行固定为品牌图标 15px、项目名 badge、弹性空隙和右对齐相对时间。+- 第二行固定为品牌图标 15px、项目名 badge、弹性空隙和右对齐的智能时间;一分钟内显示 Just now,一小时内显示分钟数,当天显示时间,昨天显示 Yesterday,本年显示月日,更早补年份。Hover 统一显示精确到秒的本地时间。- 分支、token 和归档状态不在列表重复展示,移入详情元信息。- 收藏和置顶允许以 11px 系统蓝图标出现在标题尾部。- 当前行使用低饱和蓝材质,不额外描边。@@ -158,7 +158,7 @@ macOS 不设置横跨三栏的自定义 header。主窗口透明标题栏高 44p2. 会话标题独占第二个 44px 行,与第一行合计 88px;标题行下沿与左栏身份区和会话列表标题区对齐。标题保持 22px,过长时单行截断。3. 模型、来源(Via)badge 与消息数/token 共处标题下方第一行;统计文本弹性占据剩余宽度,窄窗口下单行截断。4. 项目路径独占第二行。-5. 第三行以 12px 日期图标开头,创建与更新信息常态只显示日期,两者以留白和低对比度中点明确分组;Hover 对应日期时再展示精确到秒的完整日期时间。+5. 第三行以 12px 日期图标开头,创建与更新信息复用会话列表的智能时间,两者以留白和低对比度中点明确分组;Hover 对应时间时统一展示精确到秒的完整本地时间。五层信息一项不减;标题下方的三行信息不压进 88px 标题区域。层内保持紧凑,层间至少 8–12px,让来源、标题、运行统计、位置和时间上下文能被分别扫读。diff --git a/crates/wake/src/format.rs b/crates/wake/src/format.rsindex cb6a62d..02c908a 100644--- a/crates/wake/src/format.rs+++ b/crates/wake/src/format.rs@@ -1,26 +1,32 @@-use chrono::{Local, TimeZone};+use chrono::{DateTime, Datelike, Duration, Local, TimeZone};-pub fn relative_time(ts: i64) -> String {+/// 会话时间的渐进式展示:越近越强调新鲜度,越远越强调日期锚点。+pub fn smart_time(ts: i64) -> String {+ smart_time_from(ts, &Local::now())+}++fn smart_time_from(ts: i64, now: &DateTime<Local>) -> String {if ts <= 0 {return String::new();}- let now = chrono::Utc::now().timestamp_millis();- let diff = now - ts;++ let Some(dt) = Local.timestamp_millis_opt(ts).single() else {+ return String::new();+ };+ let diff = now.timestamp_millis() - ts;const MIN: i64 = 60_000;- if diff < MIN {- "now".to_string()- } else if diff < 60 * MIN {- format!("{}m", diff / MIN)- } else if diff < 24 * 60 * MIN {- format!("{}h", diff / (60 * MIN))- } else if diff < 7 * 24 * 60 * MIN {- format!("{}d", diff / (24 * 60 * MIN))+ if (0..MIN).contains(&diff) {+ "Just now".to_string()+ } else if (MIN..60 * MIN).contains(&diff) {+ format!("{} min ago", diff / MIN)+ } else if dt.date_naive() == now.date_naive() {+ dt.format("%-I:%M %p").to_string()+ } else if dt.date_naive() == now.date_naive() - Duration::days(1) {+ "Yesterday".to_string()+ } else if dt.year() == now.year() {+ dt.format("%b %-d").to_string()} else {- Local- .timestamp_millis_opt(ts)- .single()- .map(|d| d.format("%m-%d").to_string())- .unwrap_or_default()+ dt.format("%b %-d, %Y").to_string()}}@@ -36,18 +42,6 @@ pub fn abs_date(ts: i64) -> String {.unwrap_or_default()}-/// 详情页常显日期:精确时间放进 Hover,降低头部的信息密度。-pub fn date_only(ts: i64) -> String {- if ts <= 0 {- return String::new();- }- Local- .timestamp_millis_opt(ts)- .single()- .map(|dt| dt.format("%Y-%m-%d").to_string())- .unwrap_or_default()-}-pub fn fmt_tokens(n: Option<i64>) -> String {match n {None | Some(0) => String::new(),@@ -118,3 +112,45 @@ pub fn one_line(s: &str, max_chars: usize) -> String {joined}}++#[cfg(test)]+mod tests {+ use super::*;++ fn local_time(year: i32, month: u32, day: u32, hour: u32, minute: u32) -> DateTime<Local> {+ Local+ .with_ymd_and_hms(year, month, day, hour, minute, 0)+ .single()+ .expect("test date should be unambiguous in the local timezone")+ }++ #[test]+ fn smart_time_uses_progressive_precision() {+ let now = local_time(2026, 8, 26, 18, 0);++ assert_eq!(+ smart_time_from((now - Duration::seconds(30)).timestamp_millis(), &now),+ "Just now"+ );+ assert_eq!(+ smart_time_from((now - Duration::minutes(23)).timestamp_millis(), &now),+ "23 min ago"+ );+ assert_eq!(+ smart_time_from(local_time(2026, 8, 26, 15, 42).timestamp_millis(), &now),+ "3:42 PM"+ );+ assert_eq!(+ smart_time_from(local_time(2026, 8, 25, 12, 0).timestamp_millis(), &now),+ "Yesterday"+ );+ assert_eq!(+ smart_time_from(local_time(2026, 8, 21, 12, 0).timestamp_millis(), &now),+ "Aug 21"+ );+ assert_eq!(+ smart_time_from(local_time(2025, 8, 21, 12, 0).timestamp_millis(), &now),+ "Aug 21, 2025"+ );+ }+}diff --git a/crates/wake/src/workbench.rs b/crates/wake/src/workbench.rsindex 8c79701..47ae1d8 100644--- a/crates/wake/src/workbench.rs+++ b/crates/wake/src/workbench.rs@@ -45,9 +45,7 @@ use wake_core::scanner::{run_scan, ScanEvents, ScanProgress};use wake_core::services::{exporter, terminal};use wake_core::watcher::{start_watcher, SessionWatcher};-use crate::format::{- abs_date, date_only, expand_tilde, fmt_tokens, one_line, relative_time, tilde_path,-};+use crate::format::{abs_date, expand_tilde, fmt_tokens, one_line, smart_time, tilde_path};use crate::settings::{SettingsPage, SettingsView};use crate::ui::*;use crate::update::{self, UpdateStatus};@@ -138,6 +136,8 @@ impl ListDelegate for SessionsDelegate {) -> Option<Self::Item> {let s = self.sessions.get(ix.row)?;let theme = cx.theme();+ let updated_time: SharedString = smart_time(s.updated_at).into();+ let updated_tooltip: SharedString = abs_date(s.updated_at).into();Some(ListItem::new(ix.row)@@ -193,7 +193,18 @@ impl ListDelegate for SessionsDelegate {theme.muted_foreground,)).child(div().flex_1())- .child(div().flex_shrink_0().child(relative_time(s.updated_at))),+ .child(+ div()+ .id(("session-updated-time", ix.row))+ .flex_shrink_0()+ .child(updated_time)+ .tooltip(move |window, cx| {+ gpui_component::tooltip::Tooltip::new(+ updated_tooltip.clone(),+ )+ .build(window, cx)+ }),+ ),),),)@@ -233,6 +244,9 @@ impl ListDelegate for SearchDelegate {) -> Option<Self::Item> {let h = self.hits.get(ix.row)?;let theme = cx.theme();+ let timestamp = h.timestamp.unwrap_or(0);+ let hit_time: SharedString = smart_time(timestamp).into();+ let hit_time_tooltip: SharedString = abs_date(timestamp).into();let snippet = h.snippet.replace(HL_OPEN, "「")@@ -267,14 +281,17 @@ impl ListDelegate for SearchDelegate {.child(div().flex_1()).child(div()+ .id(("search-hit-time", ix.row)).flex_shrink_0().text_size(FONT_CAPTION).text_color(theme.muted_foreground)- .child(format!(- "{} · {}",- h.session.project_name,- relative_time(h.timestamp.unwrap_or(0))- )),+ .child(format!("{} · {}", h.session.project_name, hit_time))+ .tooltip(move |window, cx| {+ gpui_component::tooltip::Tooltip::new(+ hit_time_tooltip.clone(),+ )+ .build(window, cx)+ }),),).child(@@ -2951,13 +2968,13 @@ impl Workbench {let detail_fact_line: SharedString = detail_facts.join(" · ").into();let created_time: Option<(SharedString, SharedString)> = (meta.created_at > 0).then(|| {(- format!("Created {}", date_only(meta.created_at)).into(),+ format!("Created {}", smart_time(meta.created_at)).into(),format!("Created {}", abs_date(meta.created_at)).into(),)});let updated_time: Option<(SharedString, SharedString)> = (meta.updated_at > 0).then(|| {(- format!("Updated {}", date_only(meta.updated_at)).into(),+ format!("Updated {}", smart_time(meta.updated_at)).into(),format!("Updated {}", abs_date(meta.updated_at)).into(),)});