feat: add Usage dashboard panel to desktop app - #77572
Conversation
New /usage route with a UsageView component that shows token and cost metrics via the existing /api/analytics/usage endpoint: - Summary cards: sessions, tokens, cost, cache reads - Bar sparklines for tokens/day and cost/day - Model breakdown table with percentage bar, token count, and cost - 7d/14d/30d/90d/365d preset selector - Estimated vs actual cost toggle - Sidebar nav entry + keybind (nav.usage) - Lazy-loaded via React.lazy Closes NousResearch#77221
Independent review notes — from a competing Phase-1 draft (now withdrawn)I had a Phase-1 draft (#77251) implementing a While building mine, the #77221 triage surfaced three correctness findings (from the automated review on my draft) that apply to any usage surface reading these tables. Sharing them so they don't get re-discovered the hard way:
Good work on the lazy-loading and the breakdown table — those are exactly the Phase-2 pieces the issue asks for. Happy to review if you want a second pair of eyes after the triage runs. |
Correction to my earlier review notes — verified against your diffAfter reading your actual diff (and the
The one finding that genuinely applies:
Sorry for the noise — the two retracted points were about my competing draft, not your diff. Your approach (reusing the existing analytics endpoint, no parallel RPC) is the right call, and the per-model breakdown + sparkline are exactly the Phase-2 pieces the issue asks for. |
Summary
Adds a new /usage route to the desktop app that shows token and cost metrics. The panel reads from the existing
/api/analytics/usageendpoint — no backend changes needed.Changes
New files:
apps/desktop/src/app/usage/index.tsx— UsageView component with summary cards, bar sparklines, and model breakdown tableapps/desktop/src/app/usage/sparkline.tsx— BarSparkline component with hover tooltipapps/desktop/src/app/usage/store.ts— nanostores atom for days selectorModified files:
apps/desktop/src/app/routes.ts— add USAGE_ROUTE, AppView, AppRouteIdapps/desktop/src/app/chat/sidebar/index.tsx— sidebar nav entryapps/desktop/src/app/contrib/surfaces.tsx— lazy-loaded routeapps/desktop/src/lib/keybinds/actions.ts— nav.usage keybindFeatures:
Verification
/api/analytics/usageendpoint — no new backend APICloses #77221