diff --git a/hive-ag3nt/src/stats.rs b/hive-ag3nt/src/stats.rs index cad8fce5..eb3f6152 100644 --- a/hive-ag3nt/src/stats.rs +++ b/hive-ag3nt/src/stats.rs @@ -42,6 +42,7 @@ impl Window { "7d" => Self::Week, "30d" => Self::Month, "all" => Self::All, + // Default (incl. `label()`'s own canonical `"24h"`/`"1d"`). _ => Self::Day, } } diff --git a/hive-ag3nt/src/turn_stats.rs b/hive-ag3nt/src/turn_stats.rs index 31682712..0734d581 100644 --- a/hive-ag3nt/src/turn_stats.rs +++ b/hive-ag3nt/src/turn_stats.rs @@ -289,7 +289,10 @@ impl TurnStats { last_input_tokens, last_output_tokens, last_cache_read_input_tokens, last_cache_creation_input_tokens FROM turn_stats - ORDER BY started_at DESC + -- `id` (AUTOINCREMENT) is monotonic with insertion, so this is + -- the most-recently-inserted row even among same-second turns + -- (which `started_at DESC` would order arbitrarily). + ORDER BY id DESC LIMIT 1", [], |row| {