mirror of
https://github.com/mastra-ai/mastra.git
synced 2026-11-17 08:44:46 +00:00
refactor(playground-ui): share one observability header across Traces, Spans and Threads (#28270)
## Summary `/traces`, `/spans` and `/threads` each built their own header (a "Traces" breadcrumb plus the Traces/Spans/Threads view switch). They also each had their own copy of the date/filter state, query options, error/empty/list body and capability-gate states. Switching tabs remounted the whole header. The header now comes from **one React Router layout route**, so it stays mounted when you switch tabs. Each page renders only its body inside the outlet. All the reusable pieces now live in `@mastra/playground-ui`. They take props and callbacks and never import `react-router`, so the platform app can reuse them as they are: - `ObservabilityPageLayout` + `useObservabilityViews`: header, breadcrumb state and view switch (rules match the old ones: skeleton while capabilities load, switch only when more than one view exists and the current view is one of them) - `ObservabilityCapabilityGate`: loading and "capability not activated" states - `ObservabilityListBody`, `useObservabilityListFilters`, `observabilityListQueryOptions`: shared list body, filter/date/sort state and recovery polling options - `observabilityViewCrumbLabel` and URL selection helpers (`readSpanSelection`, `withSpanSelection`, `spanTraceSearch`, `readThreadSelection`, `withThreadSelection`) - `SpansExplorerBody` / `ThreadsExplorerBody`: full page bodies, with the side panel passed in through a `renderPanel` slot - `TracesExplorer.Body`: `TracesExplorer.Layout` minus `PageLayout`. `Layout` keeps its API, so scoped agent/workflow Traces tabs and existing consumers are unchanged. Studio keeps only the router glue: pathname → current view, `navigate`, search params, `PageBreadcrumbs` and the `RouteSidePanel` container. ## Test plan - [x] Existing spans/threads/traces page MSW suites pass with no assertion changes (they now mount the real layout route) - [x] New test: switching Spans → Threads keeps the same header node mounted - [x] New playground-ui tests: `ObservabilityPageLayout` view rules, `SpansExplorerBody` / `ThreadsExplorerBody` mounted with no router, selection/crumb helpers - [x] `playground-ui` and `playground` typecheck, test and lint - [x] No `react-router` imports in `playground-ui` source outside tests - [ ] Manual Studio check: Traces ↔ Spans ↔ Threads, side panel and thread drawer, `/traces/:id` redirect <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## ELI5 The Traces, Spans, and Threads pages now share one header. Switching between them keeps the header in place, while reusable page parts live in `@mastra/playground-ui` so other apps can use them. ## Changes - Added a React Router layout for `/traces`, `/spans`, and `/threads`. - Moved shared observability components, hooks, query options, selection helpers, and breadcrumb helpers to `@mastra/playground-ui`. - Added reusable page bodies for spans and threads, plus `TracesExplorer.Body`. Kept `TracesExplorer.Layout` for scoped traces views. - Kept router integration, breadcrumbs, and side-panel containers in Studio. ## Validation The author reports that existing MSW suites pass without assertion changes, a new test confirms the header stays mounted when navigating from Spans to Threads, and typecheck, test, and lint checks pass for `playground-ui` and `playground`. Manual Studio checks for switching views, the side panel, the thread drawer, and the `/traces/:id` redirect remain unchecked. Review finding counts were not provided. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
This commit is contained in:
parent
c583bc9549
commit
399cb80de9
36 changed files with 1479 additions and 635 deletions
Loading…
Add table
Add a link
Reference in a new issue