Add gated plan usage history to TUI analytics (#45766)

## What changed

- Add consumer plan usage history behind `analytics_plan_history`, disabled by default, fetching seven days of five-hour and weekly allowance periods.
- Show period usage percentages with expandable breakdowns by feature, model, surface, or turn start, plus snapshot freshness and incomplete coverage indicators.
- Preserve unknown usage separately from zero and handle an unavailable history endpoint without blocking other analytics reports.

## Testing

Add backend and TUI tests for unavailable endpoints, response validation, feature and account gating, account changes during requests, period navigation, snapshot resets, and narrow and wide layouts.

GitOrigin-RevId: 7bea87a3407730b18040d7dda7e7dd0afe67fb2e
This commit is contained in:
Felipe Coury authored and copyberry committed 2026-09-15 19:12:18 +00:00
1 parent 0e7ab7c1b5
commit 0d0979f457
23 files changed
+1062 -18

No files matched your search

+6 -2
View File
@@ -35,7 +35,7 @@ impl AnalyticsView {
let group = self.sections[section].group;
let heading = if matches!(
section,
Section::Usage | Section::Credits | Section::Activity
Section::Usage | Section::Credits | Section::Activity | Section::Plan
) {
columns(
heading,
@@ -79,7 +79,11 @@ impl AnalyticsView {
}),
);
}
if section == Section::Chats {
if section == Section::Plan {
let (plan, detail) = self.plan_lines(width);
selection = lines.len() + detail.start..lines.len() + detail.end;
lines.extend(plan);
} else if section == Section::Chats {
let (chats, detail) = self.chat_lines(width);
selection = lines.len() + detail.start..lines.len() + detail.end;
lines.extend(chats);