## Why Token usage data is already accumulated per-session (agent_sessions.input_tokens/output_tokens/cost), per-tool (tool_cost_stats view), and per-task (tasks.token_breakdown JSONB), but there is no dedicated UI to view or analyze it. The only token surface today is the ContextMeter ring and the inline ChatThroughput readout — both per-chat, transient, and ephemeral. Users have no way to audit token consumption across sessions, compare provider costs, or understand where their context budget goes. ## What Changes 1. **Nav button**: Add a "Token Analytics" button to the sidebar nav, above the existing Settings button, linking to a new `/analytics` route. 2. **Token Analytics page**: A new route/page at `/analytics` showing aggregate token usage across sessions, per-tool cost breakdown, and per-session token history. 3. **API endpoints**: New or extended read endpoints to serve aggregate token data for the analytics page. ## Capabilities ### New Capabilities - `token-analytics-dashboard`: Aggregate token usage dashboard page with per-session, per-tool, and per-provider breakdowns. Reuses existing `agent_sessions`, `tool_cost_stats`, and `token_breakdown` data sources. - `nav-button-token-analytics`: Sidebar nav button (above Settings) linking to the analytics route. ### Modified Capabilities *(No existing capabilities have requirement changes — this is net-new.)* ## Impact - **apps/web/src**: New page (`/opt/boocode/apps/web/src/pages/Analytics.tsx`), new route in App.tsx, new nav button in ProjectSidebar.tsx, new API client methods. - **apps/server or apps/coder**: Maybe a new aggregate endpoint if existing routes don't cover the required queries; otherwise reuse existing `/api/tools/cost_stats` and `/api/coder/sessions/:id/agent-sessions` endpoints. - **No schema changes** — all data is already persisted.