@checkstack/ui 1.7.0 → 1.8.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,335 @@
1
1
  # @checkstack/ui
2
2
 
3
+ ## 1.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 1ef2e79: feat: hotlinks on incidents/maintenances and additional links on systems
8
+
9
+ Users with `manage` access on an incident, maintenance, or system can now
10
+ attach free-form URL "hotlinks" — Jira tickets, runbooks, dashboards, ticket
11
+ tools, etc. — alongside the existing fields.
12
+
13
+ - **Incidents** & **maintenances**: links live on the entity itself and are
14
+ surfaced both in the editor dialog and on the public detail page. Two new
15
+ RPC procedures per plugin (`addLink`, `removeLink`) gated behind the
16
+ existing `manage` access rule. Links are returned as part of
17
+ `getIncident` / `getMaintenance` and cache-invalidated on every link
18
+ mutation.
19
+ - **Systems**: a parallel `system_links` table with `getSystemLinks`,
20
+ `addSystemLink`, `removeSystemLink` procedures. Surfaced inside the
21
+ system editor (next to contacts) and on the read-only system detail
22
+ sidebar. Cache-scoped per-system so list endpoints remain hot.
23
+ - **Shared UI**: a `LinksEditor` component in `@checkstack/ui` does the
24
+ presentation; the three plugins each own their own RPC wiring.
25
+
26
+ Database changes ship as additive migrations (new `incident_links`,
27
+ `maintenance_links`, `system_links` tables, all FK-cascaded on parent
28
+ delete). No existing columns or rows are touched.
29
+
30
+ The system incident and maintenance history pages now sort by relevance:
31
+ active entries (non-`resolved` incidents, `scheduled` or `in_progress`
32
+ maintenances) appear at the top, with creation date descending as the
33
+ tiebreaker.
34
+
35
+ - aa89bc5: Replace the bespoke `registerInfrastructureTab()` registry with a standard
36
+ slot-extension contract (`InfrastructureTabsSlot` from
37
+ `@checkstack/infrastructure-common`). Plugins now contribute infrastructure
38
+ tabs via `createSlotExtension`, depending only on the slot owner.
39
+
40
+ The slot system in `@checkstack/frontend-api` gains a second type parameter
41
+ on `createSlot<TContext, TMetadata>` so extensions can declare typed static
42
+ metadata at registration time (label, icon, access rules, ordering for the
43
+ infrastructure tab bar). A new `useSlotExtensions(slot)` hook returns typed
44
+ extensions and subscribes to plugin lifecycle changes.
45
+
46
+ Each tab body now stacks a **Runtime** sub-section (live state, read-only)
47
+ on top of a **Configuration** sub-section (settings, gated by `canUpdate`).
48
+
49
+ **Queue runtime panel.** Surfaces aggregated counts (pending / processing /
50
+ completed / failed) plus three sub-tabs of recent jobs: **Active**, **Recent
51
+ failed** (with the failure message), and **Recent completed** (with
52
+ duration). Job payloads are deliberately not surfaced — they may carry
53
+ secrets and need a separate manage-access gate to be shown.
54
+
55
+ To support this, `Queue<T>` gains a required `listJobs(opts)` method
56
+ returning `JobSummary[]` (no payloads), and `QueueStats` gains a
57
+ `scope: "instance" | "cluster"` field. The in-memory queue keeps rolling
58
+ ring buffers (200 entries) for completed/failed history and tracks active
59
+ jobs by id; BullMQ uses native `getJobs`. `QueueManager.listJobs` aggregates
60
+ across queues and sorts (most-recent-first for terminal states, FIFO for
61
+ active/waiting/delayed).
62
+
63
+ **Cache runtime panel.** Lists the top N entries by size (or by recency) so
64
+ operators can debug a cache filling up. Values are deliberately omitted —
65
+ PII / secret risk. Backends opt in via an optional `listEntries?` method on
66
+ `CacheProvider`; non-supporting backends return `{ supported: false }` and
67
+ the UI renders a "not supported by this backend" hint. The in-memory cache
68
+ implements it using its existing per-entry byte tracking.
69
+
70
+ `CacheStats` also gains `scope: "instance" | "cluster"`.
71
+
72
+ **Multi-instance scope warning.** A new `<InstanceScopeBanner>` component in
73
+ `@checkstack/ui` renders a yellow banner above any runtime panel whose
74
+ backend reports `scope: "instance"` — i.e. in-memory queue or cache running
75
+ in a horizontally scaled deployment. The banner explains the metrics are
76
+ local to the responding replica and recommends switching to a clustered
77
+ backend (Redis-backed queue / cache) for cluster-wide visibility.
78
+
79
+ **Bug fix — stable cache provider proxy.** `CacheManagerImpl.getProvider()`
80
+ now returns a single stable proxy that delegates to whatever provider is
81
+ currently active. Previously, consumers of `createCachedScope` (and any
82
+ direct `cacheManager.getProvider()` caller) captured the active provider
83
+ reference at plugin-init time. After any `setActiveBackend` call — including
84
+ saving the same memory config in the new Cache tab, which reconstructs the
85
+ in-memory cache — those scopes wrote to an orphaned old provider while the
86
+ runtime panel read stats from the new (empty) one, making the runtime panel
87
+ appear to report 0 keys. With the proxy, all consumers share a single stable
88
+ identity and writes always land in the active provider.
89
+
90
+ **Bytes tracking on the in-memory cache.** `InMemoryCache.getStats().sizeBytes`
91
+ now returns a running approximation (UTF-8 bytes of the key plus
92
+ `v8.serialize(value).byteLength`, with a JSON fallback) that's kept in sync
93
+ across all eviction paths. Treat the number as a sanity gauge; it doesn't
94
+ include `Map` per-entry overhead.
95
+
96
+ **Pagination.** Both `Queue<T>.listJobs` and `CacheProvider.listEntries?`
97
+ are offset-paginated. Inputs gain an `offset: number`; outputs change to
98
+ `{ items, total: number | null, hasMore: boolean }`. `total` is nullable
99
+ so backends that can't compute it cheaply still paginate via `hasMore`.
100
+ The UI uses the existing `<Pagination>` component with a 25-row default
101
+ page size. `QueueManager.listJobs` aggregates by over-fetching
102
+ `[0, offset+limit)` per queue, merge-sorting, then slicing the window —
103
+ optimal for the single-queue case, acceptable for the multi-queue case
104
+ within the UI's reasonable page-depth bounds. BullMQ uses native offset
105
+ ranges via `getJobs(types, start, end)` plus `getJobCounts` for `total`.
106
+
107
+ **Pending tab.** The Queue runtime panel exposes a virtual `"pending"`
108
+ state (waiting ∪ delayed, FIFO). It's now the default sub-tab, since
109
+ "what's queued up?" is the most common question. Per-row state is shown
110
+ when viewing the combined list.
111
+
112
+ **Recurring schedules visible under Pending.** Cron- and interval-based
113
+ recurring jobs (e.g. healthchecks) are surfaced under Pending/Delayed
114
+ between fires, with a `nextRunAt` countdown column and a "(recurring)"
115
+ label. `JobSummary` gains optional `nextRunAt: Date` and `recurring:
116
+ boolean` fields. The in-memory queue synthesises these rows from its
117
+ `recurringJobs` registry; BullMQ already materialises the next fire of
118
+ each scheduler as a delayed job and we now surface its trigger time and
119
+ the `repeatJobKey`-derived `recurring` flag.
120
+
121
+ **Bug fix — drop hook emits with no listeners.** `EventBus.emit` no
122
+ longer enqueues a job when zero listeners (distributed or instance-local)
123
+ are registered for the hook. Previously, hooks like
124
+ `core.plugin.initialized` — emitted on every plugin init but subscribed
125
+ to by nothing in the core repo — accumulated one waiting job per emit
126
+ forever. The in-memory queue's `processNext` short-circuits when there
127
+ are zero consumer groups, so its post-loop cleanup never ran for these
128
+ orphaned jobs. The fix drops the emit at the source and logs a debug
129
+ line. Note: in distributed deployments using a Redis-backed queue, this
130
+ means a subscriber on another replica won't receive an event if no
131
+ replica that emits it has a local listener. Plugins needing cross-process
132
+ delivery must register their listener on every replica that should
133
+ receive the hook.
134
+
135
+ **Breaking notes (treated as minor under beta semantics)**:
136
+
137
+ - `@checkstack/infrastructure-common` removes `registerInfrastructureTab`
138
+ and `getInfrastructureTabs`; former callers must register an extension
139
+ into `InfrastructureTabsSlot`.
140
+ - `@checkstack/queue-api`'s `Queue<T>` interface requires the new
141
+ `listJobs(opts)` method returning `ListJobsResult` (paginated). Both
142
+ bundled queue backends (memory, BullMQ) are updated; out-of-tree
143
+ implementations will need to add it.
144
+ - `QueueStats` and `CacheStats` add a required `scope` field.
145
+ - `CacheProvider.listEntries?` (when implemented) now returns
146
+ `ListEntriesResult` instead of `CacheEntrySummary[]`.
147
+ - `JobState` adds a `"pending"` variant.
148
+
149
+ - 3547670: Add `@checkstack/tips-*` — first-run tip and onboarding infrastructure for
150
+ the frontends.
151
+
152
+ Three new packages:
153
+
154
+ - `@checkstack/tips-common` — RPC contract (`tipsContract`), `TipsApi`
155
+ client definition, and zod schemas. Fully-qualified tip IDs have shape
156
+ `<pluginId>.<localTipId>` and are produced exclusively by
157
+ `qualifyTipId(plugin, localId)` — plugins never write the namespace
158
+ themselves, and a local id with a leading or trailing `.` is rejected,
159
+ so one plugin cannot forge or dismiss a tip in another plugin's
160
+ namespace.
161
+ - `@checkstack/tips-backend` — Postgres-backed dismissal store
162
+ (`user_tip_dismissal` with composite PK on `(user_id, tip_id)`),
163
+ `listDismissed` / `dismiss` / `reset` endpoints scoped to the
164
+ requesting user via the auto-auth middleware, and a
165
+ `auth.userDeleted` hook that cleans up dismissals when a user is
166
+ deleted.
167
+ - `@checkstack/tips-frontend` — `<Tip>` (anchored popover) and
168
+ `<TipBanner>` (inline callout) components plus the `useTipState`
169
+ hook. All three accept `{ plugin, id }` (where `plugin` is the
170
+ caller's `pluginMetadata`) and route through `qualifyTipId` so the
171
+ namespace prefix is enforced at the boundary. Persists per-user on
172
+ the server when logged in, and per-browser in `localStorage`
173
+ (`checkstack.tips.dismissed`) when anonymous, with cross-tab sync via
174
+ the `storage` event.
175
+
176
+ `@checkstack/ui`'s `<EmptyState>` gains optional `steps` and `actions`
177
+ props for richer empty-state coaching (numbered onboarding lists +
178
+ primary CTA), and accepts `ReactNode` for `description`. Existing
179
+ callers continue to work unchanged.
180
+
181
+ `@checkstack/test-utils-backend`'s `createMockDb` now also mocks
182
+ `insert().values().onConflictDoNothing()` so routers using upsert-or-skip
183
+ semantics can be unit-tested.
184
+
185
+ ### Patch Changes
186
+
187
+ - 3547670: Give `<DialogContent>` real vertical breathing room between its
188
+ children. The previous `gap-4` on `<DialogContent>` was a no-op because
189
+ the children were rendered inside a single inner wrapper, so
190
+ `<DialogHeader>`, the body, and `<DialogFooter>` all stacked tight
191
+ against each other. The inner wrapper is now a flex column with
192
+ `gap-6`, so headers/descriptions, body content, and footer buttons sit
193
+ apart at the dialog level without callers having to add
194
+ `<div className="space-y-…">` themselves.
195
+ - 950d6ec: Fix mobile UserMenu items rendering at zero height, group menu items by
196
+ section, and unstack cramped card headers on small viewports.
197
+
198
+ - **UserMenu mobile bug**: On mobile, the user-menu Sheet rendered every
199
+ menu item as a grid row, which combined with `flex-shrink: 1` on each
200
+ item collapsed the buttons whose internal layout uses `display: flex`
201
+ (the items registered with `useNavigate` rather than `<Link>`) to zero
202
+ content height. Switched the mobile container to a flex column with
203
+ `[&>*]:shrink-0` and added `min-h-0` so the sheet scrolls correctly
204
+ when the list overflows.
205
+
206
+ - **UserMenu grouping**: Slot extensions now accept an optional `group`
207
+ field. The user menu buckets `UserMenuItemsSlot` extensions by `group`
208
+ and renders each group under a labeled header (`Workspace`,
209
+ `Reliability`, `Configuration`, `Documentation`, `Account`). Existing
210
+ core plugins are tagged with the appropriate group; third-party plugins
211
+ can pick any of these or supply their own label. Untagged extensions
212
+ render last with no header. `UserMenuItemsBottomSlot` is unaffected.
213
+
214
+ - **Card header responsiveness**: `CardHeaderRow` (the primitive shared by
215
+ Incident, Maintenance, Auth, Catalog, GitOps and other config cards) now
216
+ stacks vertically on narrow viewports and only switches to a single row
217
+ at the `sm` breakpoint, so titles and adjacent filter controls (e.g.
218
+ status `Select`, "Show resolved" checkbox) no longer cram together on
219
+ mobile. Refactored the Incident and Maintenance config pages to use the
220
+ primitive instead of a hand-rolled `flex items-center justify-between`
221
+ row, and made their `Select` triggers full-width on mobile.
222
+
223
+ - Updated dependencies [42abfff]
224
+ - Updated dependencies [aa89bc5]
225
+ - Updated dependencies [950d6ec]
226
+ - @checkstack/common@0.9.0
227
+ - @checkstack/frontend-api@0.5.0
228
+
229
+ ## 1.7.1
230
+
231
+ ### Patch Changes
232
+
233
+ - 50e5f5f: Runtime plugin system: install + uninstall plugins from npm, GitHub releases
234
+ (including private GitHub Enterprise instances), or tarball uploads at
235
+ runtime, with multi-package bundles, dependency-derived compatibility checks,
236
+ multi-instance coordination via a Postgres artifact store, and
237
+ single-coordinator destructive cleanup.
238
+
239
+ Highlights:
240
+
241
+ - New `PluginSource` discriminated union and `PluginInstaller` /
242
+ `PluginInstallerRegistry` interfaces in `@checkstack/backend-api`. The
243
+ GitHub variant accepts an optional `apiBaseUrl` so deployments backed by
244
+ GitHub Enterprise can install from `https://ghe.example.com/api/v3`
245
+ instead of `api.github.com`.
246
+ - New `installPackageMetadataSchema` (Zod) in `@checkstack/common` validates
247
+ every plugin's `package.json` at install time. Required fields: `name`,
248
+ `version`, `description`, `author`, `license`, `checkstack.type`,
249
+ `checkstack.pluginId`. Optional: `checkstack.bundle`,
250
+ `checkstack.usageInstructions`, `checkstack.allowInstallScripts`.
251
+ - New `pluginManagerContract` in `@checkstack/pluginmanager-common` with
252
+ `list`, `previewInstall`, `install`, `previewUninstall`, `uninstall`, and
253
+ `events` procedures.
254
+ - New `@checkstack/pluginmanager-frontend` admin UI: installed-plugins list
255
+ with per-row uninstall (typed-confirmation modal, schema/configs/cascade
256
+ toggles), install page with NPM / Tarball Upload / GitHub Release tabs
257
+ (Catalog tab disabled — coming soon), and an events page surfacing the
258
+ install/uninstall audit log.
259
+ - New `bunx @checkstack/scripts plugin-pack` CLI for plugin authors —
260
+ per-package mode produces an npm-shaped tarball; `--bundle` mode produces
261
+ an outer tarball containing every sibling declared in
262
+ `package.json#checkstack.bundle`. Published to npm so external authors
263
+ can `bunx` it directly without a workspace checkout.
264
+ - Compatibility derived from `package.json#dependencies` ranges
265
+ (`semver.satisfies` against the platform's loaded `@checkstack/*`
266
+ versions) — no separate `compatibility` field.
267
+ - Multi-instance: originator persists artifacts + `plugins` rows + broadcasts
268
+ install/uninstall; receiving instances do in-process register/unregister
269
+ only. Destructive ops (drop schema, delete plugin_configs, delete
270
+ artifacts, delete `plugins` rows) run exactly once on the originator.
271
+ - Fresh-instance bootstrap: `loadPlugins()` hydrates any
272
+ `is_uninstallable=true` plugin missing from `node_modules` from the
273
+ artifact store before normal Phase 1 register.
274
+ - New schema: `plugin_artifacts` (tarball storage), `plugin_install_events`
275
+ (audit/error log). `plugins` extended with `version`, `metadata`,
276
+ `source`, `bundle_id`, `is_primary`. Local plugin sync now writes
277
+ `version` from each plugin's `package.json` so the admin UI shows real
278
+ versions instead of `—`.
279
+ - Tarball-upload endpoint (`POST /api/pluginmanager/upload-tarball`) for
280
+ the install UI; access-gated by `pluginmanager.plugin.manage`.
281
+ - Plugin Manager menu link added to the user menu (main grid, alongside
282
+ Profile / Notification Settings / etc.).
283
+
284
+ Cross-cutting changes:
285
+
286
+ - Backend request/response logging now flows through `rootLogger` (winston)
287
+ instead of `hono/logger`. 5xx responses include the response body inline
288
+ so swallowed early-return errors are visible in the log.
289
+ - The `/api/:pluginId/*` dispatcher now logs which core service is missing
290
+ or which `pluginId` had no metadata when it 500s.
291
+ - New `registerCorePluginMetadata` on `PluginManager` for core routers
292
+ (like the plugin manager itself) that need their metadata visible to the
293
+ RPC dispatcher without going through the full plugin lifecycle.
294
+ - ESLint: `unicorn/no-null` is now disabled globally. Drizzle distinguishes
295
+ between `null` (writes a real SQL NULL) and `undefined` (skip the column
296
+ on insert), so treating them as interchangeable produced latent bugs at
297
+ the persistence boundary. The bulk of the patch-bumped packages above
298
+ reflect lint-fix touches that landed when this rule was relaxed.
299
+ - Workspace-wide license normalization to `Elastic-2.0` (matches
300
+ `LICENSE.md`). Every `package.json` in the workspace now declares the
301
+ same SPDX identifier; the patch bumps capture this.
302
+
303
+ Plugin packages (every `plugins/*`): added a `pack` npm script
304
+ (`bunx @checkstack/scripts plugin-pack`), mirrored each plugin's
305
+ `pluginId` from `plugin-metadata.ts` into `package.json#checkstack.pluginId`
306
+ so install-time validation passes, stubbed any missing required metadata
307
+ fields (`description`, `author`, `license`), and added
308
+ `checkstack.bundle` to multi-package plugin primaries (telegram, rcon, ssh,
309
+ jira, queue-bullmq, queue-memory, cache-memory).
310
+
311
+ Breaking changes:
312
+
313
+ - The legacy single-method `PluginInstaller` interface (`install(packageName)`)
314
+ is removed. Callers must use `coreServices.pluginInstallerRegistry`.
315
+ - The old `pluginAdminContract` and `createPluginAdminRouter` are removed.
316
+ Replaced by `pluginManagerContract` in `@checkstack/pluginmanager-common`
317
+ and `createPluginManagerRouter` in `core/backend`.
318
+ - `@checkstack/test-utils-backend` no longer exports
319
+ `createMockPluginInstaller` / `MockPluginInstaller` (the legacy interface
320
+ it shimmed is gone).
321
+
322
+ Note: bumps are limited to `minor` (for packages with new public API
323
+ surface) and `patch` (for downstream consumers, license normalization,
324
+ and lint fixes). No `major` bumps despite the `PluginInstaller` removal —
325
+ the legacy interface had no third-party consumers in the wild before this
326
+ runtime plugin system landed, and the contract surface is the same shape
327
+ modulo the rename.
328
+
329
+ - Updated dependencies [50e5f5f]
330
+ - @checkstack/common@0.8.0
331
+ - @checkstack/frontend-api@0.4.2
332
+
3
333
  ## 1.7.0
4
334
 
5
335
  ### Minor Changes
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@checkstack/ui",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
+ "license": "Elastic-2.0",
4
5
  "type": "module",
5
6
  "main": "src/index.ts",
6
7
  "dependencies": {
7
- "@checkstack/common": "0.7.0",
8
- "@checkstack/frontend-api": "0.4.0",
8
+ "@checkstack/common": "0.8.0",
9
+ "@checkstack/frontend-api": "0.4.2",
9
10
  "@monaco-editor/react": "^4.7.0",
10
11
  "@radix-ui/react-accordion": "^1.2.12",
11
12
  "@radix-ui/react-dialog": "^1.1.15",
@@ -29,16 +30,16 @@
29
30
  "tailwind-merge": "^2.2.0"
30
31
  },
31
32
  "devDependencies": {
32
- "@checkstack/scripts": "0.1.2",
33
- "@checkstack/test-utils-frontend": "0.0.4",
34
- "@checkstack/tsconfig": "0.0.5",
33
+ "@checkstack/scripts": "0.3.0",
34
+ "@checkstack/test-utils-frontend": "0.0.5",
35
+ "@checkstack/tsconfig": "0.0.7",
35
36
  "@testing-library/react": "^16.0.0",
36
37
  "@types/react": "^18.2.0",
37
38
  "@types/react-dom": "^19.2.3",
38
39
  "typescript": "^5.0.0"
39
40
  },
40
41
  "scripts": {
41
- "typecheck": "tsc --noEmit",
42
+ "typecheck": "tsgo -b",
42
43
  "lint": "bun run lint:code",
43
44
  "lint:code": "eslint . --max-warnings 0",
44
45
  "test": "bun test"
@@ -22,8 +22,9 @@ export const CardHeader = ({
22
22
  );
23
23
 
24
24
  /**
25
- * A row layout for card headers with title and actions.
26
- * Provides mobile-friendly defaults with flex-wrap and gap.
25
+ * Row layout for card headers with title and actions. Stacks vertically on
26
+ * narrow viewports and switches to a single row at the `sm` breakpoint, so
27
+ * filters and buttons don't get cramped against the title on mobile.
27
28
  */
28
29
  export const CardHeaderRow = ({
29
30
  className,
@@ -31,7 +32,7 @@ export const CardHeaderRow = ({
31
32
  }: React.HTMLAttributes<HTMLDivElement>) => (
32
33
  <div
33
34
  className={cn(
34
- "flex flex-wrap items-center justify-between gap-3",
35
+ "flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between",
35
36
  className,
36
37
  )}
37
38
  {...props}
@@ -33,7 +33,7 @@ const DialogOverlay = React.forwardRef<
33
33
  DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
34
34
 
35
35
  const dialogContentVariants = cva(
36
- "w-full gap-4 border border-border bg-background text-foreground p-6 shadow-lg sm:rounded-lg max-h-[85dvh] overflow-y-auto overflow-x-visible",
36
+ "w-full border border-border bg-background text-foreground p-6 shadow-lg sm:rounded-lg max-h-[85dvh] overflow-y-auto overflow-x-visible",
37
37
  {
38
38
  variants: {
39
39
  size: {
@@ -79,7 +79,7 @@ const DialogContent = React.forwardRef<
79
79
  )}
80
80
  {...props}
81
81
  >
82
- <div className="-mx-2 px-2">{children}</div>
82
+ <div className="-mx-2 px-2 flex flex-col gap-6">{children}</div>
83
83
  {!hideCloseButton && (
84
84
  <DialogPrimitive.Close
85
85
  className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2"
@@ -123,7 +123,7 @@ export const MultiTypeEditorField: React.FC<MultiTypeEditorFieldProps> = ({
123
123
  obj[pair.key] = pair.value;
124
124
  }
125
125
  try {
126
- // eslint-disable-next-line unicorn/no-null -- JSON.stringify requires null for formatting
126
+
127
127
  onChange(JSON.stringify(obj, null, 2));
128
128
  return;
129
129
  } catch {
@@ -4,27 +4,72 @@ import { cn } from "../utils";
4
4
 
5
5
  interface EmptyStateProps extends React.HTMLAttributes<HTMLDivElement> {
6
6
  title: string;
7
- description?: string;
7
+ description?: React.ReactNode;
8
8
  icon?: React.ReactNode;
9
+ /**
10
+ * Optional ordered onboarding steps. When supplied, the empty state
11
+ * renders as a "coaching" card explaining how the user gets started.
12
+ * Each step is shown with a numbered chip.
13
+ */
14
+ steps?: React.ReactNode[];
15
+ /**
16
+ * Optional action area (typically a primary CTA button) shown beneath
17
+ * the description / steps. Use this for "Create your first X" buttons.
18
+ */
19
+ actions?: React.ReactNode;
9
20
  }
10
21
 
11
22
  export const EmptyState: React.FC<EmptyStateProps> = ({
12
23
  title,
13
24
  description,
14
25
  icon,
26
+ steps,
27
+ actions,
15
28
  className,
16
29
  ...props
17
30
  }) => {
31
+ const isCoaching = (steps && steps.length > 0) || !!actions;
32
+
18
33
  return (
19
34
  <Card
20
35
  className={cn("border-dashed border-2 bg-muted/30", className)}
21
36
  {...props}
22
37
  >
23
- <CardContent className="flex flex-col items-center justify-center py-12 text-center">
38
+ <CardContent
39
+ className={cn(
40
+ "flex flex-col items-center text-center",
41
+ isCoaching ? "py-10" : "py-12 justify-center",
42
+ )}
43
+ >
24
44
  {icon && <div className="text-muted-foreground/40 mb-4">{icon}</div>}
25
45
  <p className="text-foreground font-medium">{title}</p>
26
46
  {description && (
27
- <p className="text-sm text-muted-foreground mt-1">{description}</p>
47
+ <div className="text-sm text-muted-foreground mt-1 max-w-prose">
48
+ {description}
49
+ </div>
50
+ )}
51
+ {steps && steps.length > 0 && (
52
+ <ol className="mt-6 flex flex-col gap-3 text-left max-w-md w-full">
53
+ {steps.map((step, index) => (
54
+ <li
55
+ key={index}
56
+ className="flex items-start gap-3 text-sm text-foreground"
57
+ >
58
+ <span
59
+ className="inline-flex size-6 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary text-xs font-semibold"
60
+ aria-hidden="true"
61
+ >
62
+ {index + 1}
63
+ </span>
64
+ <span className="text-muted-foreground">{step}</span>
65
+ </li>
66
+ ))}
67
+ </ol>
68
+ )}
69
+ {actions && (
70
+ <div className="mt-6 flex flex-wrap items-center justify-center gap-2">
71
+ {actions}
72
+ </div>
28
73
  )}
29
74
  </CardContent>
30
75
  </Card>
@@ -0,0 +1,46 @@
1
+ import {
2
+ InfoBanner,
3
+ InfoBannerIcon,
4
+ InfoBannerContent,
5
+ InfoBannerTitle,
6
+ InfoBannerDescription,
7
+ } from "./InfoBanner";
8
+ import { AlertTriangle } from "lucide-react";
9
+
10
+ /**
11
+ * Warns operators that the metrics being displayed reflect a single process
12
+ * — relevant when the underlying backend is in-memory and the deployment is
13
+ * (or could become) horizontally scaled.
14
+ *
15
+ * Renders nothing when `scope === "cluster"`.
16
+ */
17
+ export interface InstanceScopeBannerProps {
18
+ scope: "instance" | "cluster";
19
+ /** What the metrics are about ("Queue" / "Cache"). Used in the title only. */
20
+ subject: string;
21
+ /** Recommendation text — e.g. "switch to a Redis-backed queue". */
22
+ recommendation: string;
23
+ }
24
+
25
+ export const InstanceScopeBanner = ({
26
+ scope,
27
+ subject,
28
+ recommendation,
29
+ }: InstanceScopeBannerProps) => {
30
+ if (scope === "cluster") return null;
31
+ return (
32
+ <InfoBanner variant="warning">
33
+ <InfoBannerIcon>
34
+ <AlertTriangle className="h-4 w-4" />
35
+ </InfoBannerIcon>
36
+ <InfoBannerContent>
37
+ <InfoBannerTitle>{subject}: instance-local metrics</InfoBannerTitle>
38
+ <InfoBannerDescription>
39
+ These figures reflect this server instance only. In a horizontally
40
+ scaled deployment, each replica reports its own numbers depending on
41
+ which one your request hit. {recommendation}
42
+ </InfoBannerDescription>
43
+ </InfoBannerContent>
44
+ </InfoBanner>
45
+ );
46
+ };
@@ -0,0 +1,156 @@
1
+ import { useState } from "react";
2
+ import { ExternalLink, Plus, Trash2 } from "lucide-react";
3
+ import { Button } from "./Button";
4
+ import { Input } from "./Input";
5
+ import { Label } from "./Label";
6
+
7
+ export interface HotLink {
8
+ id: string;
9
+ label: string | null;
10
+ url: string;
11
+ }
12
+
13
+ export interface LinksEditorProps<T extends HotLink> {
14
+ /** Currently attached links. */
15
+ links: T[];
16
+ /** Whether the current user is allowed to add/remove links. */
17
+ canManage?: boolean;
18
+ /** Called when the user submits a new link. Should resolve when persisted. */
19
+ onAdd: (props: { label?: string; url: string }) => Promise<void> | void;
20
+ /** Called when the user removes a link. */
21
+ onRemove: (link: T) => Promise<void> | void;
22
+ /** Whether an add or remove mutation is currently in flight. */
23
+ busy?: boolean;
24
+ /** Heading shown above the list. Defaults to "Hotlinks". */
25
+ title?: string;
26
+ /** Help text under the heading. */
27
+ description?: string;
28
+ }
29
+
30
+ /**
31
+ * Inline editor for a list of free-form URL "hotlinks" (e.g. Jira tickets,
32
+ * dashboards, runbooks). Used by the incident, maintenance, and catalog
33
+ * plugins — the parent owns the data + mutation wiring; this component is
34
+ * pure presentation.
35
+ */
36
+ export function LinksEditor<T extends HotLink>({
37
+ links,
38
+ canManage = true,
39
+ onAdd,
40
+ onRemove,
41
+ busy,
42
+ title = "Hotlinks",
43
+ description,
44
+ }: LinksEditorProps<T>) {
45
+ const [label, setLabel] = useState("");
46
+ const [url, setUrl] = useState("");
47
+ const [error, setError] = useState<string | undefined>();
48
+
49
+ const handleAdd = async () => {
50
+ const trimmedUrl = url.trim();
51
+ if (!trimmedUrl) {
52
+ setError("URL is required");
53
+ return;
54
+ }
55
+ try {
56
+ // Triggers a synchronous URL parse error early so users get a clear
57
+ // message instead of waiting for the server validation roundtrip.
58
+ new URL(trimmedUrl);
59
+ } catch {
60
+ setError("Must be a valid URL (include http:// or https://)");
61
+ return;
62
+ }
63
+ setError(undefined);
64
+ await onAdd({ label: label.trim() || undefined, url: trimmedUrl });
65
+ setLabel("");
66
+ setUrl("");
67
+ };
68
+
69
+ return (
70
+ <div className="space-y-3">
71
+ <div>
72
+ <Label>{title}</Label>
73
+ {description && (
74
+ <p className="text-xs text-muted-foreground mt-1">{description}</p>
75
+ )}
76
+ </div>
77
+
78
+ {links.length > 0 ? (
79
+ <div className="border rounded-lg divide-y">
80
+ {links.map((link) => (
81
+ <div
82
+ key={link.id}
83
+ className="flex items-center justify-between p-3 gap-2"
84
+ >
85
+ <div className="flex items-center gap-2 min-w-0 flex-1">
86
+ <ExternalLink className="h-4 w-4 text-muted-foreground shrink-0" />
87
+ <div className="min-w-0">
88
+ <a
89
+ href={link.url}
90
+ target="_blank"
91
+ rel="noopener noreferrer"
92
+ className="text-sm text-primary hover:underline truncate block"
93
+ >
94
+ {link.label ?? link.url}
95
+ </a>
96
+ {link.label && (
97
+ <span className="text-xs text-muted-foreground truncate block">
98
+ {link.url}
99
+ </span>
100
+ )}
101
+ </div>
102
+ </div>
103
+ {canManage && (
104
+ <Button
105
+ variant="ghost"
106
+ size="sm"
107
+ onClick={() => void onRemove(link)}
108
+ disabled={busy}
109
+ aria-label="Remove link"
110
+ >
111
+ <Trash2 className="h-4 w-4" />
112
+ </Button>
113
+ )}
114
+ </div>
115
+ ))}
116
+ </div>
117
+ ) : (
118
+ <p className="text-sm text-muted-foreground">No links attached</p>
119
+ )}
120
+
121
+ {canManage && (
122
+ <div className="border rounded-lg p-4 space-y-3">
123
+ <div className="grid sm:grid-cols-[1fr_2fr] gap-3">
124
+ <div className="space-y-1">
125
+ <Label htmlFor="hotlink-label">Label (optional)</Label>
126
+ <Input
127
+ id="hotlink-label"
128
+ placeholder="e.g. Jira ticket"
129
+ value={label}
130
+ onChange={(e) => setLabel(e.target.value)}
131
+ />
132
+ </div>
133
+ <div className="space-y-1">
134
+ <Label htmlFor="hotlink-url">URL</Label>
135
+ <Input
136
+ id="hotlink-url"
137
+ placeholder="https://example.com/..."
138
+ value={url}
139
+ onChange={(e) => setUrl(e.target.value)}
140
+ />
141
+ </div>
142
+ </div>
143
+ {error && <p className="text-xs text-destructive">{error}</p>}
144
+ <Button
145
+ onClick={() => void handleAdd()}
146
+ disabled={!url.trim() || busy}
147
+ size="sm"
148
+ >
149
+ <Plus className="h-4 w-4 mr-1" />
150
+ Add Link
151
+ </Button>
152
+ </div>
153
+ )}
154
+ </div>
155
+ );
156
+ }
@@ -94,7 +94,7 @@ export const UserMenu: React.FC<UserMenuProps> = ({
94
94
  <SheetHeader className="px-4 py-3 border-b border-border">
95
95
  <SheetTitle className="text-base">Menu</SheetTitle>
96
96
  </SheetHeader>
97
- <div className="flex-1 overflow-y-auto p-2 grid grid-cols-1 gap-2">
97
+ <div className="flex-1 min-h-0 overflow-y-auto p-2 flex flex-col gap-1 [&>*]:shrink-0">
98
98
  {userInfo}
99
99
  <DropdownMenuSeparator />
100
100
  {children}
package/src/index.ts CHANGED
@@ -25,6 +25,7 @@ export * from "./components/Toggle";
25
25
  export * from "./components/Checkbox";
26
26
  export * from "./components/Alert";
27
27
  export * from "./components/InfoBanner";
28
+ export * from "./components/InstanceScopeBanner";
28
29
  export * from "./components/DynamicForm";
29
30
  export * from "./components/PageLayout";
30
31
  export * from "./components/PluginConfigForm";
@@ -43,6 +44,7 @@ export * from "./components/DateTimePicker";
43
44
  export * from "./components/DateRangeFilter";
44
45
  export * from "./components/BackLink";
45
46
  export * from "./components/StatusUpdateTimeline";
47
+ export * from "./components/LinksEditor";
46
48
  export * from "./components/Slider";
47
49
  export * from "./components/DynamicIcon";
48
50
  export * from "./components/StrategyConfigCard";
package/tsconfig.json CHANGED
@@ -2,5 +2,16 @@
2
2
  "extends": "@checkstack/tsconfig/frontend.json",
3
3
  "include": [
4
4
  "src"
5
+ ],
6
+ "references": [
7
+ {
8
+ "path": "../common"
9
+ },
10
+ {
11
+ "path": "../frontend-api"
12
+ },
13
+ {
14
+ "path": "../test-utils-frontend"
15
+ }
5
16
  ]
6
- }
17
+ }