mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
Surfaces per-agent NIP-AM turn-metric usage (tokens, cost, model breakdown, 7d/30d bucket series) in the desktop app, reading from the Phase 2 get_agent_usage_series archive command: - agent-usage/lib/agentUsage.ts: pure client-side helpers -- bucket boundary construction, bigint-safe token formatting, and the ranked overview-row projection shared by both UI surfaces. - agent-usage/hooks.ts: react-query wrapper around get_agent_usage_series with the app's standard retry:1 default. - agent-usage/ui/AgentUsageSection.tsx: ranked per-agent usage rows on the Agents overview, with a 7d/30d window switch, retry-on-error, and a collection-off banner (with or without retained-data coverage copy) linking to Local Archive settings. - agent-usage/ui/AgentUsageFocusedView.tsx: per-agent drill-down (bucketed series + model breakdown) reached via an overview row or the profile panel's Info-tab usage ingress row; wired into AgentsView, UserProfilePanel, and ProfilePanelContext. - Partial badge on rows whose total is a known lower bound (has_unknown_usage), surfaced via the accounting engine's per-field completeness contract. Extends the Rust archive test suite (agent_usage_tests.rs) to close gaps in the pure accounting engine: the f64 cost ladder had no direct outcome.cost assertions, assign_bucket_index's start-inclusive/ end-exclusive edges were only exercised indirectly, validate_request's chrono finite-range rejection was unexercised, and the A2 ranking tiebreak (pubkey ascending on an exact totalTokens tie) had no test distinguishing it from insertion order. tests/e2e/agent-usage.spec.ts (wired into playwright.config.ts's smoke project) exercises both UI surfaces against a mocked get_agent_usage_series: ranked rows, window switching, click-through to the focused view from both the overview row and the profile panel's ingress row, retry recovery from a query error, the collection-off banner and its settings deep link, and the Partial badge. Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com> Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>