Skip to content

feat(dashboard): tool-stats model breakdown + Apr 18 anomaly viz#133

Merged
manager-identity[bot] merged 1 commit into
mainfrom
feat/dashboard-tool-stats-endpoint
May 13, 2026
Merged

feat(dashboard): tool-stats model breakdown + Apr 18 anomaly viz#133
manager-identity[bot] merged 1 commit into
mainfrom
feat/dashboard-tool-stats-endpoint

Conversation

@manager-identity
Copy link
Copy Markdown
Contributor

Summary

  • Extends /api/tool-stats with a by_model time-series (and models list) parallel to the existing by_project/projects. Optional model query param scopes all three series.
  • Backward-compatible: by_date and by_project shapes are unchanged. Existing /agentic chart continues to work.
  • Adds a "By Model" toggle button + chart to the existing WebSearch panel in AgenticDashboard.tsx, alongside "All Projects" and "By Project".
  • 7 tests, including a regression test for the card's motivating use case: Apr 18 2026 WebSearch count == 0 (zero-search anomaly visible in by_date).

Code reviewer flagged two LOW issues in the first pass (weak substring assertion, cross-series scope not tested); both addressed and re-reviewed PASS.

Test plan

  • pytest tests/test_dashboard_tool_stats.py -v → 6 pass + 1 conditional skip
  • pytest tests/test_dashboard_navigation.py tests/test_dashboard_cache.py → no regressions
  • curl http://localhost:8000/api/tool-stats?tool=WebSearch&days=60 returns the new shape; Apr 18 = 0 calls
  • Browser smoke: visit /agentic after dist rebuild → "By Model" toggle shows opus/sonnet/haiku breakdown

Related

  • Closes #6048

…on (#6048)

Existing /api/tool-stats returned by_date + by_project time-series; this
card asked for a model breakdown so the April 18 zero-search anomaly is
visible alongside per-model usage. Extends the endpoint without breaking
the existing /agentic chart's response contract.

Backend (dashboard/app.py):
- Add `by_model` time-series (DATE × COALESCE(model, 'unknown')) and a
  `models` de-duplicated list, parallel to the existing by_project /
  projects pair.
- Optional `model` query param scopes all three series to a single model.
- All filters parameter-bound; brain.db opened read-only (uri mode).

Frontend (dashboard/frontend/src/{types.ts,components/AgenticDashboard.tsx}):
- `ToolStatsResponse` extended with `by_model: ToolStatsByModel[]` and
  `models: string[]`.
- `ToolView` type extended with `'by-model'`; new memoized `modelChartData`
  pivots by_model into a Recharts-friendly shape; new "By Model" button
  and chart rendering mirror the existing "By Project" pattern.

Tests (tests/test_dashboard_tool_stats.py):
- 7 cases. Default shape, model filter scoping, unknown-tool empty
  response, days clamping (0/365), and a regression test for the card's
  motivating use-case: Apr 18 2026 WebSearch count == 0 in the by_date
  series.

Closes #6048.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@manager-identity manager-identity Bot added the feature New feature label May 13, 2026
@manager-identity manager-identity Bot merged commit 13b956a into main May 13, 2026
2 checks passed
@manager-identity manager-identity Bot deleted the feat/dashboard-tool-stats-endpoint branch May 13, 2026 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants