@checkstack/dashboard-frontend 0.4.6 → 0.5.1

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,100 @@
1
1
  # @checkstack/dashboard-frontend
2
2
 
3
+ ## 0.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 208ad71: Centralize realtime cache invalidation: signals now carry their owning `pluginId` end-to-end, and a single `SignalAutoInvalidator` mounted near the React Query client invalidates `[[pluginId]]` for every incoming signal automatically.
8
+
9
+ **Breaking change to `createSignal`** (`@checkstack/signal-common`): the factory now takes a single object argument with `pluginMetadata`, `event`, and `payloadSchema`. The signal id is constructed as `${pluginMetadata.pluginId}.${event}` and the resulting `Signal` carries a `pluginId` field. The `SignalMessage` wire envelope and `ServerToClientMessage` `signal` variant gained a `pluginId` field so the frontend can route invalidations without parsing the id.
10
+
11
+ ```ts
12
+ // Before
13
+ export const ANOMALY_STATE_CHANGED = createSignal(
14
+ "anomaly.state_changed",
15
+ z.object({ ... }),
16
+ );
17
+
18
+ // After
19
+ export const ANOMALY_STATE_CHANGED = createSignal({
20
+ pluginMetadata,
21
+ event: "state_changed",
22
+ payloadSchema: z.object({ ... }),
23
+ });
24
+ ```
25
+
26
+ **New plugin field**: `FrontendPlugin.foreignSignals?: Signal<unknown>[]` lets a plugin opt its `[[pluginId]]` cache into invalidation when another plugin's signal fires (e.g. `dependency-frontend` declares `[SYSTEM_STATUS_CHANGED]` because dependency payloads embed system status). Same-plugin signals must NOT be listed — they are always auto-invalidated.
27
+
28
+ **Removed boilerplate**: per-component `useSignal(X, () => refetch())` and `useSignal(X, () => queryClient.invalidateQueries(...))` calls have been removed across `incident-frontend`, `maintenance-frontend`, `healthcheck-frontend`, `slo-frontend`, `dependency-frontend`, `satellite-frontend`, `announcement-frontend`, `notification-frontend`, and `dashboard-frontend`. The `NotificationBell` unread count is now derived directly from the `getUnreadCount` query (auto-invalidated) instead of a local state mirror.
29
+
30
+ **User-visible bug fix**: the system detail page anomaly widget (`SystemAnomalyWidget`) now updates in real-time when anomalies change, with no per-widget signal subscription required. The dashboard status page also stays fresh on `ANOMALY_STATE_CHANGED`, `ANOMALY_BASELINE_UPDATED`, and `ANOMALY_TREND_DETECTED`.
31
+
32
+ UI-state consumers that legitimately need a `useSignal` (the dashboard activity terminal, the queue lag alert, and the rolling-preset date refresh in `useHealthCheckData`) keep their handlers; the auto-invalidator runs alongside them.
33
+
34
+ - Updated dependencies [208ad71]
35
+ - @checkstack/signal-frontend@0.1.0
36
+ - @checkstack/frontend-api@0.4.0
37
+ - @checkstack/anomaly-common@0.3.0
38
+ - @checkstack/healthcheck-common@0.13.0
39
+ - @checkstack/incident-common@0.5.0
40
+ - @checkstack/maintenance-common@0.5.0
41
+ - @checkstack/notification-common@0.3.0
42
+ - @checkstack/queue-frontend@0.3.1
43
+ - @checkstack/auth-frontend@0.5.31
44
+ - @checkstack/catalog-common@1.5.3
45
+ - @checkstack/catalog-frontend@0.8.7
46
+ - @checkstack/command-frontend@0.2.32
47
+ - @checkstack/ui@1.6.1
48
+
49
+ ## 0.5.0
50
+
51
+ ### Minor Changes
52
+
53
+ - 8d1ef12: ## Anomaly Detection & UI Improvements
54
+
55
+ ### Anomaly Detection Enhancements (Phase 2)
56
+
57
+ - **`@checkstack/anomaly-backend`**: Implemented background baseline analyzer jobs and anomaly trend deviation detection mechanics.
58
+ - **`@checkstack/anomaly-common`**: Added new baseline statistical logic and inference rules.
59
+ - **`@checkstack/anomaly-frontend`**: Added new Anomaly Widget and refactored system detail rendering to be more human-readable.
60
+ - **`@checkstack/dashboard-frontend`**: Refined the global anomaly widget and fixed hardcoded access gating to render appropriately.
61
+ - **`@checkstack/healthcheck-backend`**: Connected executor telemetry to the anomaly pipeline.
62
+ - **`@checkstack/healthcheck-frontend`**: Reconciled baseline display consistency in Drawer and charts.
63
+
64
+ ### Notification Identifiers
65
+
66
+ - **`@checkstack/incident-backend`**: Resolved system IDs to human-readable System Names within Incident notifications to eliminate ID-only alert content.
67
+ - **`@checkstack/maintenance-backend`**: Adopted the same resolution strategy for Maintenance notifications to keep parity.
68
+
69
+ ### UI Experience
70
+
71
+ - **`@checkstack/incident-frontend`**: Fixed the "Back to X" BackLink to properly use `react-router` hook `useNavigate` instead of doing a full application reload.
72
+ - **`@checkstack/healthcheck-frontend`**: Implemented `useNavigate` for seamless SPA back-linking.
73
+ - **`@checkstack/integration-frontend`**: Updated connections and delivery logs links to navigate without hard reloads.
74
+
75
+ ### Patch Changes
76
+
77
+ - Updated dependencies [8d1ef12]
78
+ - Updated dependencies [8d1ef12]
79
+ - Updated dependencies [8d1ef12]
80
+ - Updated dependencies [8d1ef12]
81
+ - Updated dependencies [8d1ef12]
82
+ - @checkstack/healthcheck-common@0.12.0
83
+ - @checkstack/anomaly-common@0.2.0
84
+ - @checkstack/common@0.7.0
85
+ - @checkstack/queue-frontend@0.3.0
86
+ - @checkstack/ui@1.6.0
87
+ - @checkstack/auth-frontend@0.5.30
88
+ - @checkstack/catalog-common@1.5.2
89
+ - @checkstack/catalog-frontend@0.8.6
90
+ - @checkstack/command-common@0.2.9
91
+ - @checkstack/command-frontend@0.2.31
92
+ - @checkstack/frontend-api@0.3.11
93
+ - @checkstack/incident-common@0.4.9
94
+ - @checkstack/maintenance-common@0.4.11
95
+ - @checkstack/notification-common@0.2.9
96
+ - @checkstack/signal-frontend@0.0.16
97
+
3
98
  ## 0.4.6
4
99
 
5
100
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/dashboard-frontend",
3
- "version": "0.4.6",
3
+ "version": "0.5.1",
4
4
  "type": "module",
5
5
  "main": "src/index.tsx",
6
6
  "checkstack": {
@@ -13,20 +13,22 @@
13
13
  "lint:code": "eslint . --max-warnings 0"
14
14
  },
15
15
  "dependencies": {
16
- "@checkstack/auth-frontend": "0.5.28",
17
- "@checkstack/catalog-common": "1.4.1",
18
- "@checkstack/catalog-frontend": "0.8.3",
19
- "@checkstack/command-common": "0.2.8",
20
- "@checkstack/command-frontend": "0.2.29",
21
- "@checkstack/common": "0.6.5",
22
- "@checkstack/frontend-api": "0.3.9",
23
- "@checkstack/healthcheck-common": "0.11.0",
24
- "@checkstack/incident-common": "0.4.7",
25
- "@checkstack/maintenance-common": "0.4.9",
26
- "@checkstack/notification-common": "0.2.8",
27
- "@checkstack/queue-frontend": "0.2.30",
28
- "@checkstack/signal-frontend": "0.0.15",
29
- "@checkstack/ui": "1.5.0",
16
+ "@checkstack/anomaly-common": "0.2.0",
17
+ "@checkstack/auth-frontend": "0.5.30",
18
+ "@checkstack/catalog-common": "1.5.2",
19
+ "@checkstack/catalog-frontend": "0.8.6",
20
+ "@checkstack/command-common": "0.2.9",
21
+ "@checkstack/command-frontend": "0.2.31",
22
+ "@checkstack/common": "0.7.0",
23
+ "@checkstack/frontend-api": "0.3.11",
24
+ "@checkstack/healthcheck-common": "0.12.0",
25
+ "@checkstack/incident-common": "0.4.9",
26
+ "@checkstack/maintenance-common": "0.4.11",
27
+ "@checkstack/notification-common": "0.2.9",
28
+ "@checkstack/queue-frontend": "0.3.0",
29
+ "@checkstack/signal-frontend": "0.0.16",
30
+ "@checkstack/ui": "1.6.0",
31
+ "date-fns": "^4.1.0",
30
32
  "lucide-react": "^0.344.0",
31
33
  "react": "^18.2.0",
32
34
  "react-router-dom": "^6.22.0"
package/src/Dashboard.tsx CHANGED
@@ -19,6 +19,7 @@ import {
19
19
  } from "@checkstack/notification-common";
20
20
  import { IncidentApi } from "@checkstack/incident-common";
21
21
  import { MaintenanceApi } from "@checkstack/maintenance-common";
22
+ import { AnomalyApi } from "@checkstack/anomaly-common";
22
23
  import { HEALTH_CHECK_RUN_COMPLETED } from "@checkstack/healthcheck-common";
23
24
  import { useSignal } from "@checkstack/signal-frontend";
24
25
  import {
@@ -46,12 +47,14 @@ import {
46
47
  AlertTriangle,
47
48
  Wrench,
48
49
  Terminal,
50
+ ActivitySquare,
49
51
  } from "lucide-react";
50
52
  import { authApiRef } from "@checkstack/auth-frontend/api";
51
53
  import { QueueLagAlert } from "@checkstack/queue-frontend";
52
54
  import { SystemBadgeDataProvider } from "./components/SystemBadgeDataProvider";
53
55
  import { IncidentOverviewSheet } from "./components/IncidentOverviewSheet";
54
56
  import { MaintenanceOverviewSheet } from "./components/MaintenanceOverviewSheet";
57
+ import { AnomalyOverviewSheet } from "./components/AnomalyOverviewSheet";
55
58
 
56
59
  const CATALOG_PLUGIN_ID = "catalog";
57
60
  const MAX_TERMINAL_ENTRIES = 8;
@@ -87,6 +90,7 @@ export const Dashboard: React.FC = () => {
87
90
  const notificationClient = usePluginClient(NotificationApi);
88
91
  const incidentClient = usePluginClient(IncidentApi);
89
92
  const maintenanceClient = usePluginClient(MaintenanceApi);
93
+ const anomalyClient = usePluginClient(AnomalyApi);
90
94
 
91
95
  const navigate = useNavigate();
92
96
  const toast = useToast();
@@ -103,6 +107,7 @@ export const Dashboard: React.FC = () => {
103
107
 
104
108
  const [isIncidentSheetOpen, setIncidentSheetOpen] = useState(false);
105
109
  const [isMaintenanceSheetOpen, setMaintenanceSheetOpen] = useState(false);
110
+ const [isAnomalySheetOpen, setAnomalySheetOpen] = useState(false);
106
111
 
107
112
  // -------------------------------------------------------------------------
108
113
  // DATA QUERIES
@@ -146,6 +151,13 @@ export const Dashboard: React.FC = () => {
146
151
 
147
152
  const maintenancesLoading = inProgressLoading || scheduledLoading;
148
153
 
154
+ // Fetch active anomalies
155
+ const { data: anomalies = [], isLoading: anomaliesLoading } =
156
+ anomalyClient.getAnomalies.useQuery(
157
+ { limit: 100, state: "anomaly" },
158
+ { staleTime: 30_000 },
159
+ );
160
+
149
161
  // Fetch subscriptions (only when logged in)
150
162
  const { data: subscriptions = [], refetch: refetchSubscriptions } =
151
163
  notificationClient.getSubscriptions.useQuery(
@@ -154,7 +166,11 @@ export const Dashboard: React.FC = () => {
154
166
  );
155
167
 
156
168
  // Combined loading state
157
- const loading = entitiesLoading || incidentsLoading || maintenancesLoading;
169
+ const loading =
170
+ entitiesLoading ||
171
+ incidentsLoading ||
172
+ maintenancesLoading ||
173
+ anomaliesLoading;
158
174
 
159
175
  // -------------------------------------------------------------------------
160
176
  // MUTATIONS
@@ -188,6 +204,7 @@ export const Dashboard: React.FC = () => {
188
204
  const systemsCount = systems.length;
189
205
  const activeIncidentsCount = incidents.length;
190
206
  const activeMaintenancesCount = maintenances.length;
207
+ const activeAnomaliesCount = anomalies.length;
191
208
 
192
209
  // Map groups to include their systems
193
210
  const groupsWithSystems = useMemo<GroupWithSystems[]>(() => {
@@ -373,7 +390,7 @@ export const Dashboard: React.FC = () => {
373
390
  title="Overview"
374
391
  icon={<Activity className="w-5 h-5" />}
375
392
  />
376
- <div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
393
+ <div className="grid gap-6 md:grid-cols-2 lg:grid-cols-4">
377
394
  <StatusCard
378
395
  title="Total Systems"
379
396
  value={loading ? "..." : <AnimatedCounter value={systemsCount} />}
@@ -436,6 +453,30 @@ export const Dashboard: React.FC = () => {
436
453
  : ""
437
454
  }
438
455
  />
456
+
457
+ <StatusCard
458
+ variant={activeAnomaliesCount > 0 ? "gradient" : "default"}
459
+ title="Active Anomalies"
460
+ value={
461
+ loading ? (
462
+ "..."
463
+ ) : (
464
+ <AnimatedCounter value={activeAnomaliesCount} />
465
+ )
466
+ }
467
+ description="Unusual behavior detected"
468
+ icon={<ActivitySquare className="w-4 h-4" />}
469
+ onClick={
470
+ activeAnomaliesCount > 0
471
+ ? () => setAnomalySheetOpen(true)
472
+ : undefined
473
+ }
474
+ className={
475
+ activeAnomaliesCount > 0
476
+ ? "cursor-pointer hover:opacity-90 hover:scale-[1.02] bg-gradient-to-br from-warning/20 to-warning/5 border-warning/30"
477
+ : ""
478
+ }
479
+ />
439
480
  </div>
440
481
  </section>
441
482
 
@@ -478,6 +519,12 @@ export const Dashboard: React.FC = () => {
478
519
  maintenances={maintenances}
479
520
  systems={systems}
480
521
  />
522
+ <AnomalyOverviewSheet
523
+ open={isAnomalySheetOpen}
524
+ onOpenChange={setAnomalySheetOpen}
525
+ anomalies={anomalies}
526
+ systems={systems}
527
+ />
481
528
  </>
482
529
  );
483
530
  };
@@ -0,0 +1,98 @@
1
+ import React from "react";
2
+ import {
3
+ Sheet,
4
+ SheetContent,
5
+ SheetHeader,
6
+ SheetTitle,
7
+ SheetBody,
8
+ Badge,
9
+ } from "@checkstack/ui";
10
+ import { Link } from "react-router-dom";
11
+ import {
12
+ catalogRoutes,
13
+ type System,
14
+ } from "@checkstack/catalog-common";
15
+ import { resolveRoute } from "@checkstack/common";
16
+ import { type AnomalyDto } from "@checkstack/anomaly-common";
17
+ import { formatDistanceToNow } from "date-fns";
18
+
19
+ interface Props {
20
+ open: boolean;
21
+ onOpenChange: (open: boolean) => void;
22
+ anomalies: AnomalyDto[];
23
+ systems: System[];
24
+ }
25
+
26
+ export const AnomalyOverviewSheet: React.FC<Props> = ({
27
+ open,
28
+ onOpenChange,
29
+ anomalies,
30
+ systems,
31
+ }) => {
32
+ // Map of systemId -> systemName
33
+ const systemMap = new Map(systems.map((s) => [s.id, s.name]));
34
+
35
+ return (
36
+ <Sheet open={open} onOpenChange={onOpenChange}>
37
+ <SheetContent>
38
+ <SheetHeader className="flex flex-row items-start justify-between gap-4 pt-6">
39
+ <div className="flex flex-col gap-1 text-left">
40
+ <SheetTitle>Active Anomalies</SheetTitle>
41
+ <p className="text-sm text-muted-foreground">
42
+ Overview of unusual system behavior
43
+ </p>
44
+ </div>
45
+ </SheetHeader>
46
+
47
+ <SheetBody className="flex flex-col gap-3 pb-8">
48
+ {anomalies.length === 0 ? (
49
+ <p className="text-sm text-muted-foreground text-center py-8">
50
+ No active anomalies
51
+ </p>
52
+ ) : (
53
+ anomalies.map((anomaly) => {
54
+ const systemName = systemMap.get(anomaly.systemId) || anomaly.systemId;
55
+ const deviationText = anomaly.deviation
56
+ ? `${anomaly.deviation.toFixed(1)}σ`
57
+ : "unusual";
58
+
59
+ return (
60
+ <Link
61
+ key={anomaly.id}
62
+ to={resolveRoute(catalogRoutes.routes.systemDetail, { systemId: anomaly.systemId })}
63
+ onClick={() => onOpenChange(false)}
64
+ className="flex flex-col gap-2 rounded-lg border border-border bg-card p-4 hover:border-primary/50 hover:shadow-sm transition-all text-left"
65
+ >
66
+ <div className="flex items-start justify-between gap-4">
67
+ <h4 className="font-medium text-foreground">
68
+ {systemName}
69
+ </h4>
70
+ <Badge variant="warning" className="flex-shrink-0 font-mono">
71
+ {deviationText}
72
+ </Badge>
73
+ </div>
74
+ <div className="flex flex-col gap-1 mt-2">
75
+ <span className="text-[10px] font-semibold text-muted-foreground uppercase tracking-wider">
76
+ Metric
77
+ </span>
78
+ <span className="text-sm font-mono text-foreground break-all">
79
+ {anomaly.fieldPath}
80
+ </span>
81
+ </div>
82
+ <div className="flex items-center justify-between mt-2 pt-2 border-t border-border/50 text-xs text-muted-foreground">
83
+ <span className="font-mono">
84
+ Observed: {anomaly.observedValue} <span className="opacity-70">(~{anomaly.baselineValue})</span>
85
+ </span>
86
+ <span>
87
+ {formatDistanceToNow(new Date(anomaly.startedAt), { addSuffix: true })}
88
+ </span>
89
+ </div>
90
+ </Link>
91
+ );
92
+ })
93
+ )}
94
+ </SheetBody>
95
+ </SheetContent>
96
+ </Sheet>
97
+ );
98
+ };
@@ -1,19 +1,15 @@
1
1
  import React, { createContext, useContext, useCallback, useMemo } from "react";
2
- import { usePluginClient, useQueryClient } from "@checkstack/frontend-api";
3
- import { useSignal } from "@checkstack/signal-frontend";
2
+ import { usePluginClient } from "@checkstack/frontend-api";
4
3
  import {
5
4
  HealthCheckApi,
6
- SYSTEM_STATUS_CHANGED,
7
5
  type SystemHealthStatusResponse,
8
6
  } from "@checkstack/healthcheck-common";
9
7
  import {
10
8
  IncidentApi,
11
- INCIDENT_UPDATED,
12
9
  type IncidentWithSystems,
13
10
  } from "@checkstack/incident-common";
14
11
  import {
15
12
  MaintenanceApi,
16
- MAINTENANCE_UPDATED,
17
13
  type MaintenanceWithSystems,
18
14
  } from "@checkstack/maintenance-common";
19
15
 
@@ -46,11 +42,14 @@ interface SystemBadgeDataProviderProps {
46
42
  /**
47
43
  * Provider that bulk-fetches badge data (health, incidents, maintenances)
48
44
  * for multiple systems using TanStack Query and provides it via context.
45
+ *
46
+ * Realtime invalidation of `[["healthcheck"]]`, `[["incident"]]`, and
47
+ * `[["maintenance"]]` is handled centrally by SignalAutoInvalidator — no
48
+ * per-component signal handlers needed here.
49
49
  */
50
50
  export const SystemBadgeDataProvider: React.FC<
51
51
  SystemBadgeDataProviderProps
52
52
  > = ({ systemIds, children }) => {
53
- const queryClient = useQueryClient();
54
53
  const healthCheckClient = usePluginClient(HealthCheckApi);
55
54
  const incidentClient = usePluginClient(IncidentApi);
56
55
  const maintenanceClient = usePluginClient(MaintenanceApi);
@@ -82,56 +81,6 @@ export const SystemBadgeDataProvider: React.FC<
82
81
 
83
82
  const loading = healthLoading || incidentLoading || maintenanceLoading;
84
83
 
85
- // -------------------------------------------------------------------------
86
- // SIGNAL HANDLERS - Invalidate queries on updates
87
- // -------------------------------------------------------------------------
88
-
89
- const refetchHealth = useCallback(
90
- (systemId: string) => {
91
- if (systemIds.includes(systemId)) {
92
- // Invalidate the bulk query to refetch
93
- queryClient.invalidateQueries({ queryKey: [["healthcheck"]] });
94
- }
95
- },
96
- [systemIds, queryClient]
97
- );
98
-
99
- useSignal(SYSTEM_STATUS_CHANGED, ({ systemId }) => {
100
- refetchHealth(systemId);
101
- });
102
-
103
- const refetchIncidents = useCallback(
104
- (affectedSystemIds: string[]) => {
105
- const hasAffected = affectedSystemIds.some((id) =>
106
- systemIds.includes(id)
107
- );
108
- if (hasAffected) {
109
- queryClient.invalidateQueries({ queryKey: [["incident"]] });
110
- }
111
- },
112
- [systemIds, queryClient]
113
- );
114
-
115
- useSignal(INCIDENT_UPDATED, ({ systemIds: affectedIds }) => {
116
- refetchIncidents(affectedIds);
117
- });
118
-
119
- const refetchMaintenances = useCallback(
120
- (affectedSystemIds: string[]) => {
121
- const hasAffected = affectedSystemIds.some((id) =>
122
- systemIds.includes(id)
123
- );
124
- if (hasAffected) {
125
- queryClient.invalidateQueries({ queryKey: [["maintenance"]] });
126
- }
127
- },
128
- [systemIds, queryClient]
129
- );
130
-
131
- useSignal(MAINTENANCE_UPDATED, ({ systemIds: affectedIds }) => {
132
- refetchMaintenances(affectedIds);
133
- });
134
-
135
84
  // -------------------------------------------------------------------------
136
85
  // CONTEXT VALUE
137
86
  // -------------------------------------------------------------------------