Add Top chats to usage analytics (#45765)

## What changed

- Show local chats active in the past 30 days, ranked by estimated lifetime credits, for supported Business and Enterprise plans. Exclude archived chats and subagents.
- Add expandable model, reasoning effort, and speed breakdowns, optional zero-credit groups, and dollar estimates when supplied by the backend.
- Load estimates in bounded batches of up to 100 distinct threads, retaining available results when some estimates are unavailable. Hide chat titles without a returned estimate and distinguish missing usage from zero.

## Testing

Add coverage for batch validation, partial failures, request limits, pagination and ranking, plan eligibility, title visibility, and responsive table navigation and details.

GitOrigin-RevId: 783b960a780f4e0fd39f57e2fa78fb31b3090c44
This commit is contained in:
Felipe Coury authored and copyberry committed 2026-09-15 19:07:03 +00:00
1 parent ca53e19c75
commit 0e7ab7c1b5
47 files changed
+2491 -356

No files matched your search

+9 -2
View File
@@ -92,7 +92,7 @@ impl AnalyticsView {
pub(super) fn render(&mut self, area: Rect, buf: &mut Buffer) {
self.poll_reports();
let width = usize::from(area.width.saturating_sub(/*rhs*/ 4)).max(/*other*/ 1);
let show_range = !self.visible_sections().is_empty();
let show_range = self.section != Section::Chats && !self.visible_sections().is_empty();
let hint = |action| {
self.keymap
.primary_hint(action)
@@ -112,13 +112,20 @@ impl AnalyticsView {
} else {
let navigation = if !self.zoomed {
format!("{}/z maximize", hint(ListAction::Accept))
} else {
} else if self.section != Section::Chats {
format!(
"{}/{} day · {} details",
hint(ListAction::MoveLeft),
hint(ListAction::MoveRight),
hint(ListAction::Accept)
)
} else {
format!(
"{}/{} row · {} details",
hint(ListAction::MoveUp),
hint(ListAction::MoveDown),
hint(ListAction::Accept)
)
};
format!(
"tab/1–{} section · {}{navigation}\n{}{}R refresh · {}/{} scroll · {} back · q close",