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

Abierto
#232 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
react, rust, tauri, typescript

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Rust
Estrellas
0
Forks
1
Merge medio
6 h 54 min
PR fusionados (30 d)
152

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de emreocell/Praxi-Bot

Todos los issues de emreocell/Praxi-Bot

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.