0
Fork 0
mirror of https://github.com/mastra-ai/mastra.git synced 2026-11-17 08:44:46 +00:00

feat(playground-ui): DashboardRenderer and the kpis, timeseries, table and scores widget kinds (#28724)

## Description

Adds `DashboardRenderer` to `@mastra/playground-ui/domains/dashboards`.
It renders a dashboard definition (the schema from #28714) on a
12-column grid, and ships four widget kinds that rebuild today's Metrics
cards from JSON: `kpis`, `timeseries`, `table` and `scores`.

- Kinds are a registry (`defineWidgetKind({ kind, optionsSchema,
component })`). The renderer has no per-kind code, and hosts pass extra
kinds through `kinds`. A widget whose kind isn't registered says "This
widget needs a newer version."
- Each widget is validated, queried and rendered on its own (error
boundary per cell). A widget with bad options, a failing request or a
render error shows its own error and the rest of the dashboard renders.
- The page's range and filter bar come from the existing
`MetricsProvider`: trace/span `where` are ANDed (widget first), and
metrics/scores `filters` are merged (widget wins on a clash, as
Breakdown's usage totals do today). `dashboardDefaults(definition)`
gives Platform the preset and filter chips to use when the URL sets
none.
- Drilldowns go through `onDrilldown(page, scope)`, so Studio and
Platform keep their own routing.
- The `table` kind reuses the Breakdown card's rendering: the table body
is extracted into `BreakdownShareTable`, which the card now uses too (no
behaviour change; the metrics tests pass unchanged).

**Equality with today's cards.** `card-equality.test.tsx` renders each
card next to the widget that describes it, under the same MSW handlers.
It asserts the same request bodies and count, and identical `innerHTML`,
at project and org scope. Cards covered: KPIs; Token usage (both tabs),
Agent runs and Failure rate together (they share requests); Latency
(every tab); Resources and threads; Scores; Breakdown (every tab,
projects-first, dropped rows, thread resources, row-click drilldowns). I
checked the harness by changing one series colour, one label, and the
Threads `dropped` option: each change fails the tests. The widget
definitions in `__tests__/fixtures/metrics-widgets.ts` seed
`METRICS_DASHBOARD` (OBS-750).

**`@mastra/core` peer range.** At runtime, `domains/dashboards` imports
`dashboardWidgetSchema` and `migrateDashboardDefinition` from
`@mastra/core/storage/dashboards`, so it needs a core release that
contains #28714 (c0918c01b3). No released `@mastra/core` contains it
yet, so the peer floor stays at `>=1.7.1-0` for now. It gets raised to
the first release that does. Other playground-ui entries don't change.
`check:core-imports` can't check playground-ui (it fails to download
core 1.7.1).

## Related issue(s)

OBS-748. Builds on #28714 (merged to main as c0918c01b3).

## Type of change

- [ ] Bug fix (non-breaking change that fixes an issue)
- [x] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
- [ ] Code refactoring
- [ ] Performance improvement
- [x] Test update

## Checklist

- [x] I have linked the related issue(s) in the description above
- [ ] I have made corresponding changes to the documentation (if
applicable)
- [x] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have addressed all Coderabbit comments on this PR



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## ELI5

This PR lets the playground display dashboards with charts, tables, and
score cards. If one widget has a problem, the other widgets can still
render. Hosts can also add custom widget types.

## Summary

- Add `DashboardRenderer` and a responsive 12-column grid for dashboard
widgets.
- Add built-in `kpis`, `timeseries`, `table`, and `scores` widget kinds,
with support for host-provided kinds.
- Add query construction, filter handling, response helpers, widget
validation, and per-widget loading and error states.
- Reuse shared Breakdown components in dashboard table cells.
- Add tests for dashboard behavior, request states, and comparisons with
existing Metrics cards.
- Raise the `@mastra/core` peer dependency minimum to `>=1.81.0-0`.

Test results were not provided. Review finding counts are unavailable.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
Co-authored-by: mfrachet <marvin@mastra.ai>
This commit is contained in:
Daniel Lew 2026-10-30 11:02:00 -04:00 • committed by GitHub
commit 0db65eb9a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
56 changed files with 6025 additions and 40 deletions