Usage view: per-model breakdown, daily trend and CSV export

Aperta
#232 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
react, rust, tauri, typescript

Direzione di ricerca

Start with docs/guide/llm-call-ledger.md and crates/agent-core/src/usage.rs, then trace usage aggregation in crates/daemon-api/src/routes.rs and crates/daemon-api/src/dto.rs; review apps/desktop/ui/src/views/UsageView.tsx for the existing range selector and UI patterns. Propose the response shape in the issue before implementing, as requested. Done means model totals, daily local-time buckets, unknown usage, CSV export, and the specified tests and schema updates meet the acceptance criteria.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area: daemon area: desktop-ui enhancement help wanted

size: M · first-timer: no

Summary

Extend the Usage view with a per-model breakdown, a daily trend and CSV export, so users can see which model costs what, how usage develops over time, and take the numbers elsewhere.

Why it matters

The usage view answers "which bot used how much". People choosing between models (or between a cloud model and a local one) need "which model", and people with a budget need to see whether the trend is going up. It also complements per-bot limits (#210), which need a clear picture of past spend.

Current state

  • GET /v1/usage aggregates over runs and returns a total, by_bot and by_purpose (UsageSummary in crates/daemon-api/src/dto.rs, computed in routes.rs). The UI (apps/desktop/ui/src/views/UsageView.tsx) shows totals and a per-bot table with a range selector (all, day, week, month).
  • Every model call is recorded in the LLM call ledger with purpose, model, tokens and optional cost_usd (UsageCall in crates/agent-core/src/usage.rs, docs/guide/llm-call-ledger.md), so the data for a per-model view exists; it is not aggregated or returned.
  • The ledger doc is explicit that unknown token counts do not mean zero, and cost can be unknown (CLI engines, failed calls, embeddings); the view must not present unknown as zero.
  • There is no time series and no export.

Proposal and suggested approach

  1. Daemon. Add by_model and a daily series (bucketed in the user's local time zone, bounded number of days) to the usage summary, keeping existing fields unchanged (additive, optional for older clients). Calls with unknown tokens or cost are counted separately ("n calls without usage data").
  2. UI. A model table next to the bot table, and a small bar or sparkline per day with an accessible text alternative (a table behind it); an "unknown" marker wherever cost is not known. Use the shared design tokens and the existing chart conventions if any; do not add a heavy charting dependency without discussing it in the issue.
  3. Export. "Download CSV" of the current range (day, bot, model, purpose, calls, tokens in/out, cost or empty); in the app through a save action. Formula-injection safe (cells that start with =, +, - or @ are prefixed).
  4. Tests for the aggregation (unknown usage, several models per run, subagents counted once, time-zone edges), UI helper tests, and golden CSV.

Acceptance criteria

  • Per-model totals add up to the overall total for calls that report usage; calls without usage are shown separately.
  • The daily series respects the selected range and local midnight.
  • The OpenAPI snapshot and the generated schema are updated (CONTRIBUTING.md); check:i18n, lint, typecheck, cargo test -p daemon-api -p agent-core pass.

Out of scope

Budgets and limits (#210), price changes or catalog edits, provider balance lookups, and cross-device aggregation.

How to get started

Read docs/guide/llm-call-ledger.md, crates/agent-core/src/usage.rs, the usage code in crates/daemon-api/src/routes.rs, and views/UsageView.tsx. Comment here with the response shape you propose.

Lingua principale
Rust
Stelle
0
Fork
1
Merge medio
6h 54m
PR unite (30g)
152

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di emreocell/Praxi-Bot

Tutte le issue di emreocell/Praxi-Bot

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.