feat(dashboards): Sim-built workspace dashboard behind a rollout flag

Merged
TH
1mo ago
+36223-362

Summary

  • Adds table-backed dashboards behind the default-off dashboards flag, which can target specific organizations. A dashboard is YAML that selects authorized table queries and lays out metrics, ECharts charts, tables, text, and tabs. Aggregation runs on the server with bounded results and timeouts.
  • One dashboard per workspace, built by Sim.
    • The sidebar's Dashboard item sits under New chat and opens it directly: there's no list, header, folders, create, rename, or move.
    • Until Sim saves the first one, the page shows an empty state.
    • Dashboards live in their own dashboard table with their own id; a unique index on workspace_id keeps one per workspace. Dropping it later allows several.
  • Agent: Mothership reads and saves the dashboard with dashboards get / dashboards set.
    • The first save creates it.
    • Replacing existing content requires expectedRevision, so a concurrent edit is never overwritten.
  • Entitlements: Sim sends an entitlements list with every Mothership turn (lib/mothership/entitlements.ts), restoring the registry v1.0.0 removed.
    • dashboards is the first entitlement. Mothership hides gated commands, skills, and prompt text when one is absent.
    • Sim still enforces the flag on every operation.
  • Rendering: shared time-range and timezone controls, drag-to-zoom, synchronized hover, responsive layout, and animated metrics. Conditional percent aggregates reuse the table filter grammar.
  • Storage: reads and saves go through a small repository; saves are audited as dashboard.created / dashboard.updated. Dashboards are not files, so Files, search, and pickers are untouched.
  • New icon: a Dashboard EMCN icon drawn on the shared sidebar icon grid.

Companion: https://github.com/simstudioai/mothership/pull/531

Type of Change

  • New feature

Testing

  • Repository conflict and revision behavior verified against real PostgreSQL (lib/dashboards/repository.integration.ts)
  • Dashboard, Mothership, uploads, file search, forks, Chat, and sidebar suites pass (5,758 tests), plus packages/db (104)
  • Type-check, lint, all audits, block registry, docs manifest, and check:migrations pass
  • End-to-end Mothership build against a local stack not yet re-run on the table-backed version

Rollout

  • One migration: 0392_dashboard creates the dashboard table (new table, no backfill, no script migrations).
  • Forks do not copy the dashboard yet: its YAML references table ids that change in a fork, so copying needs id remapping.
  • Deploy the companion worker before enabling the flag. It needs its 0014_run_entitlements migration.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)