Give the token ledger its own card on the dashboard

The AI card answers whether the model is healthy now; what it has spent over a month was a
different question crowding it out one line at a time.
This commit is contained in:
Gmer4Lfe
2026-08-09 11:00:00 -04:00
parent 33e696071e
commit 1afeaf0e15
4 changed files with 226 additions and 48 deletions
+5 -4
View File
@@ -511,15 +511,16 @@ function vv_ai_stats_cached(bool $live = false): array {
// cache write, and — worse — the dashboard and the AI tab could disagree about whether the model
// is resident, because they would have asked at different moments.
//
// Tokens are not part of vv_ai_stats(): that function's shape is the AI tab's banner contract,
// and the ledger read is 15ms, so it is fetched here rather than widening the payload everything
// else carries.
// Tokens are deliberately absent. This block once carried today's total for a single line on the
// AI card; that line is now a card of its own, which fetches the whole ledger from
// api/ai.php?action=tokens because it shows the week and all-time beside today. Leaving the field
// here would have run vv_ai_token_stats() on every cache write — once a minute, forever — and
// discarded all but one number of it that nothing reads.
function vv_ai_monitor_block(array $stats): array {
return [
'model' => $stats['model'] ?? '',
'runtime' => $stats['runtime'] ?? [],
'index' => $stats['index'] ?? [],
'tokens' => vv_ai_token_stats()['today'] ?? null,
];
}