@checkstack/infrastructure-frontend 0.2.3 → 0.2.5

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,172 @@
1
1
  # @checkstack/infrastructure-frontend
2
2
 
3
+ ## 0.2.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [9016526]
8
+ - @checkstack/common@0.10.0
9
+ - @checkstack/frontend-api@0.5.1
10
+ - @checkstack/infrastructure-common@0.3.1
11
+ - @checkstack/ui@1.8.1
12
+
13
+ ## 0.2.4
14
+
15
+ ### Patch Changes
16
+
17
+ - aa89bc5: Replace the bespoke `registerInfrastructureTab()` registry with a standard
18
+ slot-extension contract (`InfrastructureTabsSlot` from
19
+ `@checkstack/infrastructure-common`). Plugins now contribute infrastructure
20
+ tabs via `createSlotExtension`, depending only on the slot owner.
21
+
22
+ The slot system in `@checkstack/frontend-api` gains a second type parameter
23
+ on `createSlot<TContext, TMetadata>` so extensions can declare typed static
24
+ metadata at registration time (label, icon, access rules, ordering for the
25
+ infrastructure tab bar). A new `useSlotExtensions(slot)` hook returns typed
26
+ extensions and subscribes to plugin lifecycle changes.
27
+
28
+ Each tab body now stacks a **Runtime** sub-section (live state, read-only)
29
+ on top of a **Configuration** sub-section (settings, gated by `canUpdate`).
30
+
31
+ **Queue runtime panel.** Surfaces aggregated counts (pending / processing /
32
+ completed / failed) plus three sub-tabs of recent jobs: **Active**, **Recent
33
+ failed** (with the failure message), and **Recent completed** (with
34
+ duration). Job payloads are deliberately not surfaced — they may carry
35
+ secrets and need a separate manage-access gate to be shown.
36
+
37
+ To support this, `Queue<T>` gains a required `listJobs(opts)` method
38
+ returning `JobSummary[]` (no payloads), and `QueueStats` gains a
39
+ `scope: "instance" | "cluster"` field. The in-memory queue keeps rolling
40
+ ring buffers (200 entries) for completed/failed history and tracks active
41
+ jobs by id; BullMQ uses native `getJobs`. `QueueManager.listJobs` aggregates
42
+ across queues and sorts (most-recent-first for terminal states, FIFO for
43
+ active/waiting/delayed).
44
+
45
+ **Cache runtime panel.** Lists the top N entries by size (or by recency) so
46
+ operators can debug a cache filling up. Values are deliberately omitted —
47
+ PII / secret risk. Backends opt in via an optional `listEntries?` method on
48
+ `CacheProvider`; non-supporting backends return `{ supported: false }` and
49
+ the UI renders a "not supported by this backend" hint. The in-memory cache
50
+ implements it using its existing per-entry byte tracking.
51
+
52
+ `CacheStats` also gains `scope: "instance" | "cluster"`.
53
+
54
+ **Multi-instance scope warning.** A new `<InstanceScopeBanner>` component in
55
+ `@checkstack/ui` renders a yellow banner above any runtime panel whose
56
+ backend reports `scope: "instance"` — i.e. in-memory queue or cache running
57
+ in a horizontally scaled deployment. The banner explains the metrics are
58
+ local to the responding replica and recommends switching to a clustered
59
+ backend (Redis-backed queue / cache) for cluster-wide visibility.
60
+
61
+ **Bug fix — stable cache provider proxy.** `CacheManagerImpl.getProvider()`
62
+ now returns a single stable proxy that delegates to whatever provider is
63
+ currently active. Previously, consumers of `createCachedScope` (and any
64
+ direct `cacheManager.getProvider()` caller) captured the active provider
65
+ reference at plugin-init time. After any `setActiveBackend` call — including
66
+ saving the same memory config in the new Cache tab, which reconstructs the
67
+ in-memory cache — those scopes wrote to an orphaned old provider while the
68
+ runtime panel read stats from the new (empty) one, making the runtime panel
69
+ appear to report 0 keys. With the proxy, all consumers share a single stable
70
+ identity and writes always land in the active provider.
71
+
72
+ **Bytes tracking on the in-memory cache.** `InMemoryCache.getStats().sizeBytes`
73
+ now returns a running approximation (UTF-8 bytes of the key plus
74
+ `v8.serialize(value).byteLength`, with a JSON fallback) that's kept in sync
75
+ across all eviction paths. Treat the number as a sanity gauge; it doesn't
76
+ include `Map` per-entry overhead.
77
+
78
+ **Pagination.** Both `Queue<T>.listJobs` and `CacheProvider.listEntries?`
79
+ are offset-paginated. Inputs gain an `offset: number`; outputs change to
80
+ `{ items, total: number | null, hasMore: boolean }`. `total` is nullable
81
+ so backends that can't compute it cheaply still paginate via `hasMore`.
82
+ The UI uses the existing `<Pagination>` component with a 25-row default
83
+ page size. `QueueManager.listJobs` aggregates by over-fetching
84
+ `[0, offset+limit)` per queue, merge-sorting, then slicing the window —
85
+ optimal for the single-queue case, acceptable for the multi-queue case
86
+ within the UI's reasonable page-depth bounds. BullMQ uses native offset
87
+ ranges via `getJobs(types, start, end)` plus `getJobCounts` for `total`.
88
+
89
+ **Pending tab.** The Queue runtime panel exposes a virtual `"pending"`
90
+ state (waiting ∪ delayed, FIFO). It's now the default sub-tab, since
91
+ "what's queued up?" is the most common question. Per-row state is shown
92
+ when viewing the combined list.
93
+
94
+ **Recurring schedules visible under Pending.** Cron- and interval-based
95
+ recurring jobs (e.g. healthchecks) are surfaced under Pending/Delayed
96
+ between fires, with a `nextRunAt` countdown column and a "(recurring)"
97
+ label. `JobSummary` gains optional `nextRunAt: Date` and `recurring:
98
+ boolean` fields. The in-memory queue synthesises these rows from its
99
+ `recurringJobs` registry; BullMQ already materialises the next fire of
100
+ each scheduler as a delayed job and we now surface its trigger time and
101
+ the `repeatJobKey`-derived `recurring` flag.
102
+
103
+ **Bug fix — drop hook emits with no listeners.** `EventBus.emit` no
104
+ longer enqueues a job when zero listeners (distributed or instance-local)
105
+ are registered for the hook. Previously, hooks like
106
+ `core.plugin.initialized` — emitted on every plugin init but subscribed
107
+ to by nothing in the core repo — accumulated one waiting job per emit
108
+ forever. The in-memory queue's `processNext` short-circuits when there
109
+ are zero consumer groups, so its post-loop cleanup never ran for these
110
+ orphaned jobs. The fix drops the emit at the source and logs a debug
111
+ line. Note: in distributed deployments using a Redis-backed queue, this
112
+ means a subscriber on another replica won't receive an event if no
113
+ replica that emits it has a local listener. Plugins needing cross-process
114
+ delivery must register their listener on every replica that should
115
+ receive the hook.
116
+
117
+ **Breaking notes (treated as minor under beta semantics)**:
118
+
119
+ - `@checkstack/infrastructure-common` removes `registerInfrastructureTab`
120
+ and `getInfrastructureTabs`; former callers must register an extension
121
+ into `InfrastructureTabsSlot`.
122
+ - `@checkstack/queue-api`'s `Queue<T>` interface requires the new
123
+ `listJobs(opts)` method returning `ListJobsResult` (paginated). Both
124
+ bundled queue backends (memory, BullMQ) are updated; out-of-tree
125
+ implementations will need to add it.
126
+ - `QueueStats` and `CacheStats` add a required `scope` field.
127
+ - `CacheProvider.listEntries?` (when implemented) now returns
128
+ `ListEntriesResult` instead of `CacheEntrySummary[]`.
129
+ - `JobState` adds a `"pending"` variant.
130
+
131
+ - 950d6ec: Fix mobile UserMenu items rendering at zero height, group menu items by
132
+ section, and unstack cramped card headers on small viewports.
133
+
134
+ - **UserMenu mobile bug**: On mobile, the user-menu Sheet rendered every
135
+ menu item as a grid row, which combined with `flex-shrink: 1` on each
136
+ item collapsed the buttons whose internal layout uses `display: flex`
137
+ (the items registered with `useNavigate` rather than `<Link>`) to zero
138
+ content height. Switched the mobile container to a flex column with
139
+ `[&>*]:shrink-0` and added `min-h-0` so the sheet scrolls correctly
140
+ when the list overflows.
141
+
142
+ - **UserMenu grouping**: Slot extensions now accept an optional `group`
143
+ field. The user menu buckets `UserMenuItemsSlot` extensions by `group`
144
+ and renders each group under a labeled header (`Workspace`,
145
+ `Reliability`, `Configuration`, `Documentation`, `Account`). Existing
146
+ core plugins are tagged with the appropriate group; third-party plugins
147
+ can pick any of these or supply their own label. Untagged extensions
148
+ render last with no header. `UserMenuItemsBottomSlot` is unaffected.
149
+
150
+ - **Card header responsiveness**: `CardHeaderRow` (the primitive shared by
151
+ Incident, Maintenance, Auth, Catalog, GitOps and other config cards) now
152
+ stacks vertically on narrow viewports and only switches to a single row
153
+ at the `sm` breakpoint, so titles and adjacent filter controls (e.g.
154
+ status `Select`, "Show resolved" checkbox) no longer cram together on
155
+ mobile. Refactored the Incident and Maintenance config pages to use the
156
+ primitive instead of a hand-rolled `flex items-center justify-between`
157
+ row, and made their `Select` triggers full-width on mobile.
158
+
159
+ - Updated dependencies [42abfff]
160
+ - Updated dependencies [3547670]
161
+ - Updated dependencies [1ef2e79]
162
+ - Updated dependencies [aa89bc5]
163
+ - Updated dependencies [950d6ec]
164
+ - Updated dependencies [3547670]
165
+ - @checkstack/common@0.9.0
166
+ - @checkstack/ui@1.8.0
167
+ - @checkstack/frontend-api@0.5.0
168
+ - @checkstack/infrastructure-common@0.3.0
169
+
3
170
  ## 0.2.3
4
171
 
5
172
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/infrastructure-frontend",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "license": "Elastic-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -21,10 +21,10 @@
21
21
  "lint:code": "eslint . --max-warnings 0"
22
22
  },
23
23
  "dependencies": {
24
- "@checkstack/common": "0.7.0",
25
- "@checkstack/frontend-api": "0.4.1",
26
- "@checkstack/infrastructure-common": "0.2.2",
27
- "@checkstack/ui": "1.7.0",
24
+ "@checkstack/common": "0.9.0",
25
+ "@checkstack/frontend-api": "0.5.0",
26
+ "@checkstack/infrastructure-common": "0.3.0",
27
+ "@checkstack/ui": "1.8.0",
28
28
  "lucide-react": "^0.468.0",
29
29
  "react": "^18.3.1",
30
30
  "react-router-dom": "^7.1.1"
@@ -32,7 +32,7 @@
32
32
  "devDependencies": {
33
33
  "@types/react": "^18.3.18",
34
34
  "typescript": "^5.7.2",
35
- "@checkstack/tsconfig": "0.0.6",
36
- "@checkstack/scripts": "0.1.2"
35
+ "@checkstack/tsconfig": "0.0.7",
36
+ "@checkstack/scripts": "0.3.1"
37
37
  }
38
38
  }
@@ -1,26 +1,37 @@
1
1
  import React from "react";
2
2
  import { Link } from "react-router-dom";
3
3
  import { Server } from "lucide-react";
4
- import type { UserMenuItemsContext } from "@checkstack/frontend-api";
4
+ import {
5
+ type UserMenuItemsContext,
6
+ pluginRegistry,
7
+ } from "@checkstack/frontend-api";
5
8
  import { DropdownMenuItem } from "@checkstack/ui";
6
9
  import { resolveRoute } from "@checkstack/common";
7
10
  import {
8
11
  infrastructureRoutes,
9
- getInfrastructureTabs,
12
+ InfrastructureTabsSlot,
13
+ type InfrastructureTabMetadata,
10
14
  } from "@checkstack/infrastructure-common";
11
15
 
12
16
  /**
13
17
  * User menu item pointing to Infrastructure Settings.
14
18
  * Only visible if the user has read access to at least one infrastructure tab.
19
+ *
20
+ * The check is best-effort/synchronous: it uses the user's pre-fetched
21
+ * access-rule list rather than calling `useAccess`, which avoids hooks in a
22
+ * component that may be rendered without a Suspense boundary.
15
23
  */
16
24
  export const InfrastructureUserMenuItems = ({
17
25
  accessRules: userPerms,
18
26
  }: UserMenuItemsContext) => {
19
- // Check if user has access to ANY infrastructure tab's read permission
20
- const tabs = getInfrastructureTabs();
21
- const canReadAny = tabs.some((tab) => {
22
- const qualifiedId = `${tab.pluginId}.${tab.readAccess.id}`;
23
- return userPerms.includes("*") || userPerms.includes(qualifiedId);
27
+ const tabs = pluginRegistry.getExtensions(InfrastructureTabsSlot.id);
28
+
29
+ const canReadAny = tabs.some((ext) => {
30
+ const meta = ext.metadata as InfrastructureTabMetadata | undefined;
31
+ if (!meta) return false;
32
+ return (
33
+ userPerms.includes("*") || userPerms.includes(meta.readAccess.id)
34
+ );
24
35
  });
25
36
 
26
37
  if (!canReadAny) {
package/src/index.tsx CHANGED
@@ -23,6 +23,7 @@ export const infrastructurePlugin = createFrontendPlugin({
23
23
  createSlotExtension(UserMenuItemsSlot, {
24
24
  id: "infrastructure.user-menu.items",
25
25
  component: InfrastructureUserMenuItems,
26
+ metadata: { group: "Configuration" },
26
27
  }),
27
28
  ],
28
29
  });
@@ -3,36 +3,44 @@ import {
3
3
  wrapInSuspense,
4
4
  accessApiRef,
5
5
  useApi,
6
+ useSlotExtensions,
6
7
  } from "@checkstack/frontend-api";
7
- import { getInfrastructureTabs } from "@checkstack/infrastructure-common";
8
- import {
9
- PageLayout,
10
- cn,
11
- } from "@checkstack/ui";
8
+ import { InfrastructureTabsSlot } from "@checkstack/infrastructure-common";
9
+ import { PageLayout, cn } from "@checkstack/ui";
12
10
  import { Server, ShieldOff } from "lucide-react";
13
11
 
14
12
  /**
15
- * Infrastructure Configuration page — IDE Editor pattern.
13
+ * Infrastructure Settings page — IDE Editor pattern.
16
14
  *
17
15
  * Renders a vertical tab bar on the left with content area on the right.
18
- * Each tab is registered by plugins (queue, cache, etc.) with its own access rules.
19
- * The page only shows tabs the user has read access to.
16
+ * Each tab is contributed by a plugin (queue, cache, ) via an extension
17
+ * registered into `InfrastructureTabsSlot`. The shell page is plugin-agnostic
18
+ * and only depends on the slot contract in `@checkstack/infrastructure-common`.
20
19
  */
21
20
  const InfrastructureConfigPageContent = () => {
22
21
  const accessApi = useApi(accessApiRef);
23
- const allTabs = getInfrastructureTabs();
22
+ const tabs = useSlotExtensions(InfrastructureTabsSlot);
23
+
24
+ const sortedTabs = useMemo(
25
+ () =>
26
+ tabs.toSorted(
27
+ (a, b) => (a.metadata.order ?? 100) - (b.metadata.order ?? 100),
28
+ ),
29
+ [tabs],
30
+ );
24
31
 
25
- // Check access for each tab
26
- const tabAccess = allTabs.map((tab) => ({
27
- tab,
28
- readResult: accessApi.useAccess(tab.readAccess),
29
- manageResult: accessApi.useAccess(tab.manageAccess),
32
+ // Per-tab access lookup (read + manage). Hooks must be called in stable
33
+ // order, so we map over `sortedTabs` — the registry is append-only during
34
+ // a session aside from explicit lifecycle changes, which trigger a full
35
+ // re-render via `useSlotExtensions`.
36
+ const tabAccess = sortedTabs.map((ext) => ({
37
+ extension: ext,
38
+ readResult: accessApi.useAccess(ext.metadata.readAccess),
39
+ manageResult: accessApi.useAccess(ext.metadata.manageAccess),
30
40
  }));
31
41
 
32
- // Filter to visible tabs
33
42
  const visibleTabs = useMemo(
34
- () =>
35
- tabAccess.filter(({ readResult }) => readResult.allowed),
43
+ () => tabAccess.filter(({ readResult }) => readResult.allowed),
36
44
  // eslint-disable-next-line react-hooks/exhaustive-deps
37
45
  [tabAccess.map(({ readResult }) => readResult.allowed).join(",")],
38
46
  );
@@ -41,11 +49,10 @@ const InfrastructureConfigPageContent = () => {
41
49
  const hasAnyAccess = visibleTabs.length > 0;
42
50
 
43
51
  const [activeTabId, setActiveTabId] = useState<string>();
44
-
45
- // Default to first visible tab
46
- const effectiveActiveTabId = activeTabId ?? visibleTabs[0]?.tab.id;
52
+ const effectiveActiveTabId =
53
+ activeTabId ?? visibleTabs[0]?.extension.id;
47
54
  const activeTabEntry = visibleTabs.find(
48
- (t) => t.tab.id === effectiveActiveTabId,
55
+ (t) => t.extension.id === effectiveActiveTabId,
49
56
  );
50
57
 
51
58
  if (!isLoading && !hasAnyAccess) {
@@ -77,15 +84,14 @@ const InfrastructureConfigPageContent = () => {
77
84
  allowed={hasAnyAccess}
78
85
  >
79
86
  <div className="flex gap-6 min-h-[600px]">
80
- {/* Tab Bar */}
81
87
  <nav className="flex flex-col gap-1 w-52 shrink-0 border-r border-border pr-4">
82
- {visibleTabs.map(({ tab }) => {
83
- const Icon = tab.icon;
84
- const isActive = tab.id === effectiveActiveTabId;
88
+ {visibleTabs.map(({ extension }) => {
89
+ const Icon = extension.metadata.icon;
90
+ const isActive = extension.id === effectiveActiveTabId;
85
91
  return (
86
92
  <button
87
- key={tab.id}
88
- onClick={() => setActiveTabId(tab.id)}
93
+ key={extension.id}
94
+ onClick={() => setActiveTabId(extension.id)}
89
95
  className={cn(
90
96
  "flex items-center gap-3 rounded-lg px-3 py-2.5 text-sm font-medium transition-colors text-left",
91
97
  isActive
@@ -94,16 +100,15 @@ const InfrastructureConfigPageContent = () => {
94
100
  )}
95
101
  >
96
102
  <Icon className="h-4 w-4 shrink-0" />
97
- {tab.label}
103
+ {extension.metadata.label}
98
104
  </button>
99
105
  );
100
106
  })}
101
107
  </nav>
102
108
 
103
- {/* Tab Content */}
104
109
  <div className="flex-1 min-w-0">
105
110
  {activeTabEntry && (
106
- <activeTabEntry.tab.component
111
+ <activeTabEntry.extension.component
107
112
  canUpdate={activeTabEntry.manageResult.allowed}
108
113
  />
109
114
  )}