@checkstack/dashboard-frontend 0.5.0 → 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,51 @@
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
+
3
49
  ## 0.5.0
4
50
 
5
51
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/dashboard-frontend",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "type": "module",
5
5
  "main": "src/index.tsx",
6
6
  "checkstack": {
@@ -13,21 +13,21 @@
13
13
  "lint:code": "eslint . --max-warnings 0"
14
14
  },
15
15
  "dependencies": {
16
- "@checkstack/anomaly-common": "0.1.0",
17
- "@checkstack/auth-frontend": "0.5.29",
18
- "@checkstack/catalog-common": "1.5.1",
19
- "@checkstack/catalog-frontend": "0.8.5",
20
- "@checkstack/command-common": "0.2.8",
21
- "@checkstack/command-frontend": "0.2.30",
22
- "@checkstack/common": "0.6.5",
23
- "@checkstack/frontend-api": "0.3.10",
24
- "@checkstack/healthcheck-common": "0.11.0",
25
- "@checkstack/incident-common": "0.4.8",
26
- "@checkstack/maintenance-common": "0.4.10",
27
- "@checkstack/notification-common": "0.2.8",
28
- "@checkstack/queue-frontend": "0.2.31",
29
- "@checkstack/signal-frontend": "0.0.15",
30
- "@checkstack/ui": "1.5.1",
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
31
  "date-fns": "^4.1.0",
32
32
  "lucide-react": "^0.344.0",
33
33
  "react": "^18.2.0",
@@ -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
  // -------------------------------------------------------------------------