@checkstack/healthcheck-frontend 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,141 @@
1
1
  # @checkstack/healthcheck-frontend
2
2
 
3
+ ## 0.23.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 9dcc848: Redesign the catalog into a group-first browse view and tabbed management tables, with inline health rollups.
8
+
9
+ - Browse view: the catalog home is a real read-only, scale-built experience - collapsible group sections (with member counts) plus a synthetic Ungrouped section, a shared toolbar (search, group/health/tag filters, density toggle), URL-backed view state (shareable deep links), polished empty states, and a manager-only "Manage catalog" link. Per-system status badges render through the existing `SystemStateBadgesSlot`; filtering is client-side over the loaded set.
10
+ - Management: redesigned as tabbed data tables (Systems / Groups / Environments) replacing the two-column drag-to-assign layout. Systems get multi-select + a bulk bar, inline health, and group + environment membership as removable chips with type-ahead pickers (portaled so they are never clipped); Groups get inline rename and member chips; Environments get a name / members / field-count table (CRUD gated by `catalog.environment.manage`). GitOps-locked rows stay read-only. Drag-and-drop (and `@dnd-kit` on this page) is removed; the management page also shares the browse toolbar.
11
+ - Inline health rollups: a new platform contract `CatalogBrowseHealthSlot` (`@checkstack/catalog-common`) - an additive optional slot catalog-frontend only consumes (a headless data boundary feeding group rollups + the health filter), with a catalog-owned `CatalogHealthStatus` vocabulary so catalog gains no health-plugin dependency. Group headers show a rollup pill derived from the reported status DATA (a system absent from the map is `"unknown"`, never healthy); all-healthy groups start collapsed. The health filter is wired on both toolbars and enables once a filler reports. healthcheck-frontend fills the slot by reusing dashboard-frontend's `SystemBadgeDataProvider`. When no health source is installed the slot is unfilled and the catalog stays fully functional.
12
+
13
+ This is a beta minor.
14
+
15
+ - 9dcc848: Redesign the dashboard as an extensible "needs attention" overview, and normalize system state badges.
16
+
17
+ The dashboard now surfaces ONLY systems that need attention (degraded, unhealthy, breaching/at-risk SLO, under an incident or active maintenance, anomalous, or with a dependency problem) and hides everything healthy. A compact header summarises fleet health and filters by severity; each problem renders as an elevated card with one row per issue that deep-links to where the issue originates. A calm "all clear" state shows when nothing needs attention, a live "recent activity" feed sits below, and a "View catalog" link replaces the duplicated system list.
18
+
19
+ New platform contract `SystemSignalsSlot` (`@checkstack/catalog-common`): a headless, render-once slot where any plugin bulk-fetches and reports structured `SystemSignal[]` per system via `onSignals(sourceId, map)`. The dashboard aggregates every source agnostic to which plugins contribute; each core reliability plugin (healthcheck, incident, SLO, maintenance, anomaly, dependency) ships a filler, and third-party plugins add new per-system state the same way with no dashboard change. Signals carry an `iconName` rendered via `DynamicIcon` so the contract stays React-free. The dashboard's old summary tiles and overview sheets are removed, so it no longer depends on those plugins' packages. The group "subscribe" control moved onto the catalog browse page's group headers.
20
+
21
+ System state badges are normalized into one icon-only `@checkstack/ui` `StatusBadge` primitive - a small tinted icon chip with the full label on hover/focus (and via `aria-label`). Each signal uses its feature's navbar icon (health = Activity, incident = AlertTriangle, SLO = Target, maintenance = Wrench, dependency = GitBranch; anomaly = ChartSpline). Badges self-sort by severity via CSS `order` (error -> warn -> info), tooltips are scoped to a named group, and in catalog browse rows the cluster moved to the right edge.
22
+
23
+ This is a beta minor.
24
+
25
+ - 9dcc848: Add environments as a first-class catalog primitive, with per-environment health-check fan-out, config templating, per-environment reactive health, and script run-context exposure.
26
+
27
+ - Catalog primitive: an environment is a sibling of groups - a named, instance-global record carrying free-form custom fields (baseUrl, region, tier, ...) that any system can belong to many-to-many. New `environments` + `systems_environments` tables, `EnvironmentSchema` + create/update schemas, `EntityService` environment CRUD and membership joins, RPC endpoints gated by a new `catalogAccess.environment` access rule, a GitOps `Environment` kind + `System.environments` extension, and frontend management (an `EnvironmentEditor`, an Environments management panel, and a per-system environment picker). The Environments card's Add/Edit/Delete affordances are gated on `catalogAccess.environment.manage`.
28
+ - Per-environment fan-out: run identity becomes `(systemId, configurationId, environmentId)`. Runs, aggregates, and state transitions gain a nullable `environmentId`. The health-check assignment gains an `environmentIds` selector with three modes (All / Specific / None; `null` and `[]` are distinct). The queue executor resolves the effective environment set via the catalog `resolveSystemEnvironments` read and executes one isolated run per environment.
29
+ - Config templating: a new `x-templatable` config-field marker renders a string field through the template engine at execute time, against `{ environment, check, system }`. A shared `renderTemplatableConfig` and a `renderTemplatePreview` helper (re-exported from `@checkstack/template-engine`) keep editor previews identical to the run-time render. The HTTP collector's `url`, `headers[].value`, and `body` are templatable, rendered per environment (the strategy client build moves inside the per-env loop); the `url`'s `.url()` validation moves post-render. Secrets resolve before templating; a field marked both secret and `x-templatable` is rejected at plugin load. `DynamicForm` shows a live "Preview" line, and the catalog `EnvironmentPreviewPicker` ("Preview as: <environment>") drives it in the collector editor (only when the schema has a templatable field).
30
+ - Script run-context: `CollectorRunContext` gains an optional `environment` field (`{ id, name, fields }`, metadata only). Shell collectors receive `CHECKSTACK_ENV_ID` / `_NAME` / `CHECKSTACK_ENV_<FIELD>` vars; inline TS collectors read `globalThis.context.environment`; the editor test panel mirrors both. The env-less path is unchanged.
31
+ - Per-environment reactive health (see BREAKING below), env-keyed read/write paths, env-qualified serialization locks, an optional `trigger.payload.environmentId`, per-environment isolation, and an `ENVIRONMENT_RESOLUTION_FAILED` signal when catalog resolution degrades to a single env-less run.
32
+
33
+ BREAKING CHANGES: the reactive `health` entity's id-shape and cardinality change. It now encodes two views: per-environment (id `"<systemId>::<environmentId>"`) and a system rollup (id `"<systemId>"`, the worst status across environments + env-less runs). The rollup PRESERVES the pre-existing system-level contract - dashboards, status badges, and automations referencing health by `systemId` keep working without re-authoring - but the entity's contract surface changed (new id-shape, higher cardinality, new payload field), so it is flagged breaking. `getBulkHealthState` parses env-qualified ids and keys results by the original id.
34
+
35
+ State and scale: membership and custom fields live only in catalog Postgres and are re-read every tick via the cross-plugin RPC; env-keyed health reads from shared `health_check_runs` / aggregates / transitions (compute-on-read). Every pod resolves the same effective set and the same per-environment health. No pod-local environment state.
36
+
37
+ Also: `unwrapSchema` in `zod-config.ts` loops instead of single-pass-stripping so multi-layer wrappers (`.optional().default()`) still resolve `x-templatable` meta. The env-less `{{ environment.* }}` run notice logs at `debug` (a legitimate recurring configuration), while the post-render HTTP `.url()` check still fails a genuinely-broken empty render with a clear "Rendered URL is invalid" error.
38
+
39
+ This is a beta minor.
40
+
41
+ - 9dcc848: Cut initial-load JS: lazy plugin contributions, a hardened lazy-by-default contribution contract, on-demand Monaco, and a lighter icon/chart load.
42
+
43
+ - Lazy plugin route pages: each plugin's route `element` references a `React.lazy`-wrapped page rendered inside a shared `<Suspense>` boundary. Plugins still register synchronously, so nav, slots, commands, API factories, and `foreignSignals` are available on first paint. This moves ~37 route-page chunks (~600 KB) out of the entry; the entry chunk drops from ~2.4 MB to ~190 KB. Auth flow pages stay eager. The `@checkstack/scripts` scaffold template generates lazy route pages too.
44
+ - Hardened contribution contract (BREAKING, frontend plugin contract): plugins declare contributions lazily and let the framework own code-splitting, Suspense, and per-plugin error isolation. Routes use `load: () => import("./Page").then((m) => ({ default: m.Page }))` instead of `element: <Page />` (`element` is still accepted for the rare page that must paint without a chunk fetch; provide exactly one). Slot extensions accept either an eager `component` or a lazy `load`; new `getLazyContribution` + `ExtensionComponent` exports from `@checkstack/frontend-api` render either kind. This also fixes runtime-installed plugins: `ExtensionSlot` subscribes to the plugin registry, and the API registry rebuilds when the plugin set changes (`getPlugins()` returns an immutable snapshot via `useSyncExternalStore`). A per-plugin error boundary contains a bad contribution.
45
+ - On-demand Monaco: the `@checkstack/ui` barrel no longer pulls the `@codingame/*` / `monaco-languageclient` stack into the initial load. `CodeEditor` lazy-loads its Monaco-backed editor behind `React.lazy` + Suspense, `validateTypeScriptSources` imports the editor API via in-body `await import(...)`, and the "vscode services ready" signal moved to a Monaco-free module. The ~10 MB editor body loads only when a `CodeEditor` mounts. A `react-vendor` `manualChunks` split was added for stable vendor caching.
46
+ - lucide-react 1.x + lighter icons/charts (BREAKING for icon consumers): lucide-react unified from three drifting ranges to `^1.17.0`. lucide v1 removed brand icons, so the GitHub/GitLab marks are vendored in `@checkstack/ui` (`GithubIcon`, `GitlabIcon`, `brandIcons`); a new `IconName` type (`LucideIconName | BrandIconName`) in `@checkstack/common` is canonical, accepted by `AuthStrategy.icon` and the card components, so data-driven brand names keep working. `DynamicIcon` no longer eagerly imports lucide's ~1600-icon map (~1 MB) - it lives in a `React.lazy` `iconRegistry` chunk fetched on first data-driven render, while statically named-imported icons tree-shake normally. The recharts-backed health-check charts (~300 KB) and the `HealthCheckSystemOverview` drawer leave the initial load.
47
+
48
+ BREAKING CHANGES:
49
+
50
+ - Frontend plugin contract: routes/slot contributions are lazy-by-default (`load` instead of `element`/eager elements) as described above.
51
+ - Any external consumer importing a brand icon from `lucide-react` (e.g. `import { Github } from "lucide-react"`) must switch to the vendored `@checkstack/ui` brand icons or a custom SVG.
52
+
53
+ This is a beta minor.
54
+
55
+ - 9dcc848: Add the auto-generated, version-pinned `@checkstack/sdk` package + codegen, and serve its types live to the in-app editor.
56
+
57
+ - A new committed workspace package `@checkstack/sdk`, generated from the platform's source of truth by `scripts/generate-sdk.ts` (`generate:sdk` / `generate:sdk:check`): a fully-typed oRPC client (`createCheckstackClient`) over the REST surface with one `InferClient` per plugin contract, real script-authoring helpers (`@checkstack/sdk/healthcheck`, `@checkstack/sdk/integration`) whose runtime body is the same identity function the in-app runner injects, per-subpath `.d.ts` under the package `exports` map, and an editor-only ambient bundle. A `generate:sdk:check` CI guard fails when the committed SDK files drift from a fresh generation. The `@checkstack/sdk` version is stamped from `@checkstack/release` and MUST NOT appear in a changeset (a guard enforces this); the `@checkstack/release` bump here advances the release version so the generated SDK can be published later. The generated client also normalizes its base URL without a backtracking-prone regex, closing a CodeQL `js/polynomial-redos` finding.
58
+ - Live editor type injection: a new version-keyed route `GET /api/script-packages/sdk-types/:releaseVersion` (raw handler in `@checkstack/script-packages-backend`) serves the generated SDK editor bundle with `Cache-Control: private, max-age=1y, immutable`; the pure path-build/parse module lives in `@checkstack/script-packages-common`, shared by backend and frontend. A mismatched version returns `409` so the editor refetches and never serves stale types after an upgrade. The frontend `useSdkTypeInjection` hook fetches the bundle once per session and mounts it into Monaco via `addExtraLib`. Schema-narrowed `context.config` / `context.event.payload` editor types stay local; the package-resolving module declarations come from the one published `@checkstack/sdk` source.
59
+
60
+ BREAKING CHANGES: the script-authoring import surface moves from the bare `@checkstack/healthcheck` / `@checkstack/integration` virtual modules to the `@checkstack/sdk/healthcheck` / `@checkstack/sdk/integration` subpaths of the published `@checkstack/sdk` package. The old bare-name imports no longer resolve (an old import now errors in the editor, surfacing the migration). Existing scripts must update the module specifier:
61
+
62
+ - import { defineHealthCheck } from "@checkstack/healthcheck";
63
+ + import { defineHealthCheck } from "@checkstack/sdk/healthcheck";
64
+
65
+ - import { defineIntegration } from "@checkstack/integration";
66
+ + import { defineIntegration } from "@checkstack/sdk/integration";
67
+
68
+ The helper names and their runtime behaviour are unchanged - only the module specifier moves. The global (no-import) helper form continues to work unchanged.
69
+
70
+ This is a beta minor.
71
+
72
+ - 9dcc848: Align workspace dependency versions and migrate React Router to v7.
73
+
74
+ BREAKING CHANGES (React Router v7): All frontend packages now depend on `react-router-dom@^7.16.0`. Previously the workspace declared four divergent ranges (`^6.20.0`, `^6.22.0`, `^7.1.1`, `^7.14.2`), which resolved both `react-router@6` and `react-router@7` into a single bundle. Everything is now unified on v7. The public imports the app uses (`BrowserRouter`, `Routes`, `Route`, `Link`, `NavLink`, `MemoryRouter`, `useNavigate`, `useParams`, `useSearchParams`, `useLocation`) are unchanged between v6 and v7, so no source rewrites were required - but any out-of-tree plugin still on react-router v6 should upgrade to v7 (see the React Router v6 -> v7 upgrade guide) to share the host's single router instance via the import map.
75
+
76
+ Other unified ranges (no API change): `react` -> `^18.3.1`, the `@orpc/*` family (`contract`, `server`, `client`, `tanstack-query`, `openapi`, `zod`) -> `^1.14.4`, and `better-auth` -> `^1.6.13`.
77
+
78
+ Removed the pre-rename `@orpc/react-query` leftover from `@checkstack/frontend-api`; its `createRouterUtils` / `RouterUtils` / `ProcedureUtils` now come from `@orpc/tanstack-query` (the package already in use).
79
+
80
+ Stale in-range runtime deps pulled up to current published versions: `hono` `^4.12.23`, `@tanstack/react-query` (+devtools) `^5.100.14`, `date-fns` `^4.4.0`, `jose` `^6.2.3`, `tar` `^7.5.16`, `semver` `^7.8.1`, `@xyflow/react` `^12.11.0`.
81
+
82
+ ### Patch Changes
83
+
84
+ - 9dcc848: Move primary navigation into a left sidebar, and serve the user guide in-app.
85
+
86
+ Feature navigation (a ~20-item user-menu dropdown) now lives in a persistent left sidebar (a slide-over drawer on mobile), grouped by section with the active route highlighted; the user menu keeps only account actions. A route opts into the sidebar with new `nav` metadata (`{ group, icon, label?, order?, accessRule? }`) on its registration, co-located with path + access + title. The sidebar filters entries with the same access check as page guards. `@checkstack/common` gains `isAccessRuleSatisfied` and a centralized set of in-app doc slugs (`APP_DOC_SLUGS` + `docsPath`, with a test asserting each resolves to a real docs page); `@checkstack/auth-frontend` exports `useAccessRules`.
87
+
88
+ The backend now serves the Astro Starlight docs build same-origin at `/checkstack/*` (the same artifact deployed to GitHub Pages), so the user guide is available inside the app including for self-hosted / air-gapped installs (served verbatim, no rebuild, no link rewriting; from `CHECKSTACK_DOCS_DIST`, before the SPA catch-all, degrading gracefully when absent; the Docker image builds and ships `docs/dist`; Vite proxies `/checkstack` in dev). The "Docs" link is a shell-owned external sidebar entry under the Documentation group (book icon), opening `/checkstack/user-guide/` in a new tab; the group renders even when no plugin route contributes to it.
89
+
90
+ BREAKING (plugin authors): `UserMenuItemsSlot` is no longer the way to add navigation - registering a top user-menu item no longer surfaces it anywhere. Add `nav` to the page's route instead. `UserMenuItemsBottomSlot` (account items) is unchanged. All bundled plugins have been migrated.
91
+
92
+ This is a beta minor.
93
+
94
+ - 9dcc848: Guard component animations behind isLowPower, and add a shared inline Spinner.
95
+
96
+ - `@checkstack/ui` shared components (`Tabs`, `ConfirmationModal`, `Accordion`, `CodeEditor` popout-button backdrop blur) now drop their `animate-*` / `backdrop-blur` classes when the device reports the low-power tier, matching `LoadingSpinner` / `Skeleton`. No public API change; normal-power rendering is unchanged.
97
+ - A new shared inline `Spinner` (`@checkstack/ui`) renders a lucide `Loader2` whose `animate-spin` is gated internally behind `usePerformance().isLowPower`, so call sites inherit the low-power guard. Props: `size` (`sm`/`md`/`lg`), `className`, rest spread to the icon; decorative by default (`aria-hidden`), `role="status"` when given `aria-label`. The hand-rolled `Loader2` button/table spinners in `HealthCheckDrawer`, `HealthCheckRunsTable`, `IncidentEditor`, `IncidentUpdateForm`, `ProviderConnectionsPage`, `MaintenanceEditor`, `MaintenanceUpdateForm`, `UserChannelCard`, and `DynamicOptionsField` are migrated onto it.
98
+ - Remaining unguarded `animate-*` / `animate-in` / blur classes across the auth, gitops, healthcheck, incident, integration, maintenance, and notification frontends are gated behind `usePerformance().isLowPower`, so effects degrade gracefully on low-power devices per the performance rule.
99
+
100
+ Normal-power behavior is unchanged; low-power rendering drops the animations.
101
+
102
+ This is a beta minor.
103
+
104
+ - Updated dependencies [9dcc848]
105
+ - Updated dependencies [9dcc848]
106
+ - Updated dependencies [9dcc848]
107
+ - Updated dependencies [9dcc848]
108
+ - Updated dependencies [9dcc848]
109
+ - Updated dependencies [9dcc848]
110
+ - Updated dependencies [9dcc848]
111
+ - Updated dependencies [9dcc848]
112
+ - Updated dependencies [9dcc848]
113
+ - Updated dependencies [9dcc848]
114
+ - Updated dependencies [9dcc848]
115
+ - Updated dependencies [9dcc848]
116
+ - Updated dependencies [9dcc848]
117
+ - Updated dependencies [9dcc848]
118
+ - Updated dependencies [9dcc848]
119
+ - Updated dependencies [9dcc848]
120
+ - Updated dependencies [9dcc848]
121
+ - Updated dependencies [9dcc848]
122
+ - Updated dependencies [9dcc848]
123
+ - @checkstack/ui@1.13.0
124
+ - @checkstack/auth-frontend@0.7.0
125
+ - @checkstack/healthcheck-common@1.5.0
126
+ - @checkstack/anomaly-common@1.3.0
127
+ - @checkstack/catalog-frontend@0.11.0
128
+ - @checkstack/catalog-common@2.3.0
129
+ - @checkstack/common@0.13.0
130
+ - @checkstack/dashboard-frontend@0.8.0
131
+ - @checkstack/frontend-api@0.7.0
132
+ - @checkstack/gitops-frontend@0.5.0
133
+ - @checkstack/script-packages-frontend@0.3.0
134
+ - @checkstack/secrets-frontend@0.2.0
135
+ - @checkstack/tips-frontend@0.3.0
136
+ - @checkstack/satellite-common@0.8.0
137
+ - @checkstack/signal-frontend@0.2.0
138
+
3
139
  ## 0.22.0
4
140
 
5
141
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/healthcheck-frontend",
3
- "version": "0.22.0",
3
+ "version": "0.23.0",
4
4
  "license": "Elastic-2.0",
5
5
  "type": "module",
6
6
  "main": "src/index.tsx",
@@ -14,25 +14,26 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@checkstack/anomaly-common": "1.2.3",
17
- "@checkstack/auth-frontend": "0.6.6",
17
+ "@checkstack/auth-frontend": "0.6.7",
18
18
  "@checkstack/catalog-common": "2.2.3",
19
+ "@checkstack/catalog-frontend": "0.10.7",
19
20
  "@checkstack/common": "0.12.0",
20
- "@checkstack/dashboard-frontend": "0.7.7",
21
+ "@checkstack/dashboard-frontend": "0.7.8",
21
22
  "@checkstack/frontend-api": "0.6.0",
22
- "@checkstack/gitops-frontend": "0.4.6",
23
- "@checkstack/healthcheck-common": "1.3.0",
24
- "@checkstack/satellite-common": "0.6.0",
25
- "@checkstack/script-packages-frontend": "0.1.0",
26
- "@checkstack/secrets-frontend": "0.0.1",
23
+ "@checkstack/gitops-frontend": "0.4.7",
24
+ "@checkstack/healthcheck-common": "1.4.0",
25
+ "@checkstack/satellite-common": "0.7.0",
26
+ "@checkstack/script-packages-frontend": "0.2.0",
27
+ "@checkstack/secrets-frontend": "0.1.0",
27
28
  "@checkstack/signal-frontend": "0.1.5",
28
- "@checkstack/tips-frontend": "0.2.6",
29
- "@checkstack/ui": "1.11.0",
29
+ "@checkstack/tips-frontend": "0.2.7",
30
+ "@checkstack/ui": "1.12.0",
30
31
  "ajv": "^8.18.0",
31
32
  "ajv-formats": "^3.0.1",
32
- "date-fns": "^4.1.0",
33
- "lucide-react": "^0.344.0",
34
- "react": "^18.2.0",
35
- "react-router-dom": "^6.20.0",
33
+ "date-fns": "^4.4.0",
34
+ "lucide-react": "^1.17.0",
35
+ "react": "^18.3.1",
36
+ "react-router-dom": "^7.16.0",
36
37
  "recharts": "^3.6.0",
37
38
  "uuid": "^14.0.0",
38
39
  "zod": "^4.2.1"
@@ -5,12 +5,21 @@
5
5
  * for all strategies that have schema metadata.
6
6
  */
7
7
 
8
+ import { lazy, Suspense } from "react";
8
9
  import { createSlotExtension } from "@checkstack/frontend-api";
10
+ import { Skeleton } from "@checkstack/ui";
9
11
  import {
10
12
  HealthCheckDiagramSlot,
11
13
  type HealthCheckDiagramSlotContext,
12
14
  } from "../slots";
13
- import { AutoChartGrid } from "./AutoChartGrid";
15
+
16
+ // Lazy-loaded: AutoChartGrid pulls in recharts (~300 KB). This extension is
17
+ // registered eagerly at plugin load, so a static import would ship recharts in
18
+ // the initial bundle even though charts only render inside the (on-demand)
19
+ // HealthCheckDiagramSlot. Deferring it keeps recharts out of the initial load.
20
+ const AutoChartGrid = lazy(() =>
21
+ import("./AutoChartGrid").then((m) => ({ default: m.AutoChartGrid })),
22
+ );
14
23
 
15
24
  /**
16
25
  * Extension that renders auto-generated charts for any strategy.
@@ -22,6 +31,10 @@ import { AutoChartGrid } from "./AutoChartGrid";
22
31
  export const autoChartExtension = createSlotExtension(HealthCheckDiagramSlot, {
23
32
  id: "healthcheck.auto-charts",
24
33
  component: (context: HealthCheckDiagramSlotContext) => {
25
- return <AutoChartGrid context={context} />;
34
+ return (
35
+ <Suspense fallback={<Skeleton className="h-48 w-full" />}>
36
+ <AutoChartGrid context={context} />
37
+ </Suspense>
38
+ );
26
39
  },
27
40
  });
@@ -0,0 +1,60 @@
1
+ import React, { useEffect, useMemo } from "react";
2
+ import type { SlotContext } from "@checkstack/frontend-api";
3
+ import type { CatalogBrowseHealthSlot } from "@checkstack/catalog-common";
4
+ import type { CatalogHealthStatuses } from "@checkstack/catalog-common";
5
+ import {
6
+ SystemBadgeDataProvider,
7
+ useSystemBadgeData,
8
+ } from "@checkstack/dashboard-frontend";
9
+
10
+ type Props = SlotContext<typeof CatalogBrowseHealthSlot>;
11
+
12
+ /**
13
+ * Reads the bulk-fetched health from dashboard-frontend's SystemBadgeDataProvider
14
+ * context and reports the per-system statuses back to the catalog browse view via
15
+ * `onStatuses`. Renders nothing — it is a headless reporter inside the provider.
16
+ *
17
+ * Healthcheck's status enum (`healthy` | `degraded` | `unhealthy`) matches the
18
+ * catalog-owned `CatalogHealthStatus` vocabulary exactly, so the mapping is a
19
+ * direct copy of the resolved statuses; systems with no health are simply omitted
20
+ * (the catalog rollup treats absence as `"unknown"`).
21
+ */
22
+ const HealthStatusReporter: React.FC<Props> = ({ systemIds, onStatuses }) => {
23
+ const { getSystemBadgeData } = useSystemBadgeData();
24
+
25
+ // Stable, serialised status map: `useMemo` keeps the object identity fixed
26
+ // unless `systemIds` or the bulk-data accessor change, so the effect below
27
+ // re-reports only when the resolved statuses actually change.
28
+ const statuses = useMemo<CatalogHealthStatuses>(() => {
29
+ const result: CatalogHealthStatuses = {};
30
+ for (const id of systemIds) {
31
+ const status = getSystemBadgeData(id)?.health?.status;
32
+ if (status) result[id] = status;
33
+ }
34
+ return result;
35
+ }, [systemIds, getSystemBadgeData]);
36
+
37
+ useEffect(() => {
38
+ onStatuses(statuses);
39
+ }, [statuses, onStatuses]);
40
+
41
+ return null;
42
+ };
43
+
44
+ /**
45
+ * Fills the catalog `CatalogBrowseHealthSlot`. Wraps dashboard-frontend's existing
46
+ * `SystemBadgeDataProvider` (already a healthcheck-frontend dependency) over the
47
+ * browse list's system ids to bulk-fetch health, then reports the resolved
48
+ * statuses to catalog. All cross-plugin coupling lives here on the filler side;
49
+ * catalog stays decoupled.
50
+ */
51
+ export const CatalogBrowseHealthFiller: React.FC<Props> = ({
52
+ systemIds,
53
+ onStatuses,
54
+ }) => {
55
+ return (
56
+ <SystemBadgeDataProvider systemIds={systemIds}>
57
+ <HealthStatusReporter systemIds={systemIds} onStatuses={onStatuses} />
58
+ </SystemBadgeDataProvider>
59
+ );
60
+ };
@@ -35,6 +35,14 @@ interface CollectorListProps {
35
35
  loading?: boolean;
36
36
  /** Called when collector form validity changes */
37
37
  onValidChange?: (isValid: boolean) => void;
38
+ /**
39
+ * Sample context used to preview `x-templatable` config fields (e.g. the
40
+ * HTTP URL's `{{ environment.baseUrl }}`). Typically the custom fields of a
41
+ * sample environment the system belongs to, shaped as
42
+ * `{ environment, check, system }`. Omit it and templatable fields render
43
+ * without a preview line.
44
+ */
45
+ templatePreviewContext?: Record<string, unknown>;
38
46
  }
39
47
 
40
48
  /**
@@ -48,6 +56,7 @@ export const CollectorList: React.FC<CollectorListProps> = ({
48
56
  onChange,
49
57
  loading,
50
58
  onValidChange,
59
+ templatePreviewContext,
51
60
  }) => {
52
61
  // Track validity state per collector index
53
62
  const [validityMap, setValidityMap] = useState<Record<number, boolean>>({});
@@ -277,6 +286,7 @@ export const CollectorList: React.FC<CollectorListProps> = ({
277
286
  <DynamicForm
278
287
  schema={collector.configSchema}
279
288
  value={entry.config}
289
+ templatePreviewContext={templatePreviewContext}
280
290
  onChange={(config) =>
281
291
  handleConfigChange(index, config)
282
292
  }
@@ -1,6 +1,7 @@
1
1
  import React, { useState, useCallback, useRef } from "react";
2
- import { Loader2, ExternalLink, Server } from "lucide-react";
2
+ import { ExternalLink, Server, Layers } from "lucide-react";
3
3
  import { Satellite as SatelliteIcon } from "lucide-react";
4
+ import { CatalogApi } from "@checkstack/catalog-common";
4
5
  import {
5
6
  ExtensionSlot,
6
7
  usePluginClient,
@@ -48,6 +49,7 @@ import {
48
49
  AccordionItem,
49
50
  AccordionTrigger,
50
51
  AccordionContent,
52
+ Spinner,
51
53
  } from "@checkstack/ui";
52
54
  import { formatDistanceToNow } from "date-fns";
53
55
  import { useNavigate, Link } from "react-router-dom";
@@ -114,6 +116,18 @@ export const HealthCheckDrawer: React.FC<HealthCheckDrawerProps> = ({
114
116
  }) => {
115
117
  const healthCheckClient = usePluginClient(HealthCheckApi);
116
118
  const satelliteClient = usePluginClient(SatelliteApi);
119
+ const catalogClient = usePluginClient(CatalogApi);
120
+
121
+ // Environments the system belongs to - resolves run.environmentId to a
122
+ // human-readable name in the run-history table (per-environment fan-out).
123
+ const { data: systemEnvironments = [] } =
124
+ catalogClient.getSystemEnvironments.useQuery(
125
+ { systemId },
126
+ { enabled: !!systemId },
127
+ );
128
+ const envNameById = new Map(
129
+ systemEnvironments.map((e) => [e.id, e.name]),
130
+ );
117
131
  const navigate = useNavigate();
118
132
  const accessApi = useApi(accessApiRef);
119
133
  const { allowed: canViewDetails } = accessApi.useAccess(
@@ -339,7 +353,10 @@ export const HealthCheckDrawer: React.FC<HealthCheckDrawerProps> = ({
339
353
  </button>
340
354
  )}
341
355
  {chartFetching && (
342
- <Loader2 className="h-4 w-4 animate-spin text-muted-foreground ml-2" />
356
+ <Spinner
357
+ size="sm"
358
+ className="text-muted-foreground ml-2"
359
+ />
343
360
  )}
344
361
  </div>
345
362
 
@@ -453,7 +470,7 @@ export const HealthCheckDrawer: React.FC<HealthCheckDrawerProps> = ({
453
470
  <span className="text-sm text-muted-foreground flex items-center gap-2">
454
471
  Recent Runs
455
472
  {historyLoading && (
456
- <Loader2 className="h-3 w-3 animate-spin" />
473
+ <Spinner size="sm" className="h-3 w-3" />
457
474
  )}
458
475
  </span>
459
476
  <div className="flex-1 h-px bg-border" />
@@ -475,12 +492,13 @@ export const HealthCheckDrawer: React.FC<HealthCheckDrawerProps> = ({
475
492
  <TableRow>
476
493
  <TableHead className="w-24">Status</TableHead>
477
494
  <TableHead>Time</TableHead>
495
+ <TableHead>Environment</TableHead>
478
496
  <TableHead>Source</TableHead>
479
497
  </TableRow>
480
498
  </TableHeader>
481
499
  <TableBody>
482
500
  {runs.length === 0 && !historyLoading && (
483
- <EmptyRunsTableRow colSpan={3}>
501
+ <EmptyRunsTableRow colSpan={4}>
484
502
  No runs match the{" "}
485
503
  <span className="font-medium">{runsStatusFilter}</span>{" "}
486
504
  filter.
@@ -518,6 +536,19 @@ export const HealthCheckDrawer: React.FC<HealthCheckDrawerProps> = ({
518
536
  addSuffix: true,
519
537
  })}
520
538
  </TableCell>
539
+ <TableCell>
540
+ {run.environmentId ? (
541
+ <span className="inline-flex items-center gap-1 text-xs px-1.5 py-0.5 rounded-full bg-primary/10 text-primary">
542
+ <Layers className="h-3 w-3" />
543
+ {envNameById.get(run.environmentId) ??
544
+ run.environmentId}
545
+ </span>
546
+ ) : (
547
+ <span className="text-xs text-muted-foreground">
548
+ None
549
+ </span>
550
+ )}
551
+ </TableCell>
521
552
  <TableCell>
522
553
  {run.sourceId ? (
523
554
  <span className="inline-flex items-center gap-1 text-xs px-1.5 py-0.5 rounded-full bg-orange-500/10 text-orange-600">
@@ -8,9 +8,10 @@ import {
8
8
  TableCell,
9
9
  HealthBadge,
10
10
  Pagination,
11
+ Spinner,
11
12
  } from "@checkstack/ui";
12
13
  import { formatDistanceToNow, format } from "date-fns";
13
- import { ExternalLink, Loader2, Satellite, Server } from "lucide-react";
14
+ import { ExternalLink, Satellite, Server, Layers } from "lucide-react";
14
15
  import { useNavigate } from "react-router-dom";
15
16
  import { healthcheckRoutes } from "@checkstack/healthcheck-common";
16
17
  import { resolveRoute } from "@checkstack/common";
@@ -23,16 +24,32 @@ export interface HealthCheckRunDetailed {
23
24
  status: "healthy" | "unhealthy" | "degraded";
24
25
  result: Record<string, unknown>;
25
26
  timestamp: Date;
27
+ /**
28
+ * Environment this run executed for (per-environment fan-out). undefined =
29
+ * env-less run (opt-out / no membership).
30
+ */
31
+ environmentId?: string;
26
32
  /** Source ID for result attribution (undefined = local core, UUID = satellite) */
27
33
  sourceId?: string;
28
34
  /** Human-readable source label (e.g. "Local" or "EU West (eu-west-1)") */
29
35
  sourceLabel?: string;
30
36
  }
31
37
 
38
+ export interface EnvironmentLabel {
39
+ id: string;
40
+ name: string;
41
+ }
42
+
32
43
  export interface HealthCheckRunsTableProps {
33
44
  runs: HealthCheckRunDetailed[];
34
45
  loading: boolean;
35
46
  emptyMessage?: string;
47
+ /**
48
+ * Optional id -> name map for the Environment column. When a run's
49
+ * `environmentId` is present, its display name is looked up here (falling
50
+ * back to the id). Env-less runs render a muted dash.
51
+ */
52
+ environmentLabels?: EnvironmentLabel[];
36
53
  /** Show System ID and Configuration ID columns with link to detail page */
37
54
  showFilterColumns?: boolean;
38
55
  /** Number of columns for the expanded result row */
@@ -52,11 +69,15 @@ export const HealthCheckRunsTable: React.FC<HealthCheckRunsTableProps> = ({
52
69
  runs,
53
70
  loading,
54
71
  emptyMessage = "No health check runs found.",
72
+ environmentLabels,
55
73
  showFilterColumns = false,
56
74
  pagination,
57
75
  }) => {
58
76
  const navigate = useNavigate();
59
77
  const prevRunsRef = useRef(runs);
78
+ const envNameById = new Map(
79
+ (environmentLabels ?? []).map((e) => [e.id, e.name]),
80
+ );
60
81
 
61
82
  // Keep previous runs during loading to prevent layout shift
62
83
  const displayRuns =
@@ -75,9 +96,9 @@ export const HealthCheckRunsTable: React.FC<HealthCheckRunsTableProps> = ({
75
96
  );
76
97
  };
77
98
 
78
- // 3 base columns (Status, Timestamp, Source) + 3 extras when
99
+ // 4 base columns (Status, Timestamp, Environment, Source) + 3 extras when
79
100
  // showFilterColumns is on (System ID, Configuration ID, link icon).
80
- const columnCount = showFilterColumns ? 6 : 3;
101
+ const columnCount = showFilterColumns ? 7 : 4;
81
102
  const showEmptyRow = !loading && displayRuns.length === 0;
82
103
 
83
104
  return (
@@ -89,7 +110,9 @@ export const HealthCheckRunsTable: React.FC<HealthCheckRunsTableProps> = ({
89
110
  <TableHead className="w-24">
90
111
  <span className="flex items-center gap-2">
91
112
  Status
92
- {loading && <Loader2 className="h-3 w-3 animate-spin" />}
113
+ {loading && (
114
+ <Spinner size="sm" className="h-3 w-3" />
115
+ )}
93
116
  </span>
94
117
  </TableHead>
95
118
  {showFilterColumns && (
@@ -99,6 +122,7 @@ export const HealthCheckRunsTable: React.FC<HealthCheckRunsTableProps> = ({
99
122
  </>
100
123
  )}
101
124
  <TableHead>Timestamp</TableHead>
125
+ <TableHead>Environment</TableHead>
102
126
  <TableHead>Source</TableHead>
103
127
  {showFilterColumns && <TableHead className="w-16"></TableHead>}
104
128
  </TableRow>
@@ -135,6 +159,16 @@ export const HealthCheckRunsTable: React.FC<HealthCheckRunsTableProps> = ({
135
159
  })}
136
160
  </span>
137
161
  </TableCell>
162
+ <TableCell>
163
+ {run.environmentId ? (
164
+ <span className="inline-flex items-center gap-1 text-xs px-1.5 py-0.5 rounded-full bg-primary/10 text-primary">
165
+ <Layers className="h-3 w-3" />
166
+ {envNameById.get(run.environmentId) ?? run.environmentId}
167
+ </span>
168
+ ) : (
169
+ <span className="text-xs text-muted-foreground">None</span>
170
+ )}
171
+ </TableCell>
138
172
  <TableCell>
139
173
  {run.sourceId ? (
140
174
  <span className="inline-flex items-center gap-1 text-xs px-1.5 py-0.5 rounded-full bg-orange-500/10 text-orange-600">
@@ -1,4 +1,4 @@
1
- import React, { useState } from "react";
1
+ import React, { useState, lazy, Suspense } from "react";
2
2
  import { useSearchParams } from "react-router-dom";
3
3
  import {
4
4
  usePluginClient,
@@ -17,7 +17,13 @@ import {
17
17
  } from "@checkstack/ui";
18
18
  import { Heart } from "lucide-react";
19
19
  import { HealthCheckSparkline } from "./HealthCheckSparkline";
20
- import { HealthCheckDrawer } from "./HealthCheckDrawer";
20
+ // Lazy-loaded: the drawer pulls in the recharts-based latency/timeline charts
21
+ // (~300 KB). This component is an eagerly-registered slot extension, so a static
22
+ // import would ship recharts in the initial bundle. The drawer only renders when
23
+ // a check is selected, so deferring it keeps charts out of the initial load.
24
+ const HealthCheckDrawer = lazy(() =>
25
+ import("./HealthCheckDrawer").then((m) => ({ default: m.HealthCheckDrawer })),
26
+ );
21
27
 
22
28
  import type {
23
29
  StateThresholds,
@@ -206,16 +212,18 @@ export function HealthCheckSystemOverview(props: SlotProps) {
206
212
  </CardContent>
207
213
  </Card>
208
214
 
209
- {/* Slide-over Drawer */}
215
+ {/* Slide-over Drawer (lazy: loads the chart bundle on first open) */}
210
216
  {selectedCheck && (
211
- <HealthCheckDrawer
212
- item={selectedCheck}
213
- systemId={systemId}
214
- open={!!selectedCheck}
215
- onOpenChange={(open) => {
216
- if (!open) setSelectedCheck(undefined);
217
- }}
218
- />
217
+ <Suspense fallback={null}>
218
+ <HealthCheckDrawer
219
+ item={selectedCheck}
220
+ systemId={systemId}
221
+ open={!!selectedCheck}
222
+ onOpenChange={(open) => {
223
+ if (!open) setSelectedCheck(undefined);
224
+ }}
225
+ />
226
+ </Suspense>
219
227
  )}
220
228
  </>
221
229
  );