fix(tui/limits): enforce history spacing and labels

This commit is contained in:
James Peter
2025-09-26 16:38:50 +10:00
parent 34d39e7eb2
commit 2f6b506c4f
2 changed files with 23 additions and 1 deletions
+9 -1
View File
@@ -3912,9 +3912,17 @@ impl ChatWidget<'_> {
}
fn format_hour_label(dt: DateTime<Local>) -> String {
let suffix = Self::day_suffix(dt.day());
let (is_pm, hour) = dt.hour12();
let meridiem = if is_pm { "pm" } else { "am" };
format!("{} {:>2}{}", dt.format("%a"), hour, meridiem)
format!(
"{} {:>2}{} {:>2}{}",
dt.format("%b"),
dt.day(),
suffix,
hour,
meridiem
)
}
fn usage_history_lines(summary: Option<&StoredUsageSummary>) -> Vec<RtLine<'static>> {
+14
View File
@@ -322,6 +322,13 @@ fn limits_overlay_renders_snapshot() {
.iter()
.position(|line| line.contains("7 Day History"))
.expect("expected usage header");
assert!(
strings
.get(header_idx.saturating_sub(1))
.map(|line| line.trim().is_empty())
.unwrap_or(false),
"expected blank spacer before 7 Day History"
);
let latest_label = Local::now().format("%b %d").to_string();
let yesterday_label = (Local::now().date_naive() - ChronoDuration::days(1))
.format("%b %d")
@@ -343,6 +350,13 @@ fn limits_overlay_renders_snapshot() {
.iter()
.position(|line| line.contains("6 Month History"))
.expect("expected monthly usage header");
assert!(
strings
.get(month_header_idx.saturating_sub(1))
.map(|line| line.trim().is_empty())
.unwrap_or(false),
"expected blank spacer before 6 Month History"
);
let current_month_label = Local::now().format("%b %Y").to_string();
let month_line = strings
.get(month_header_idx + 1)