@checkstack/ui 1.7.1 → 1.8.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.
Files changed (75) hide show
  1. package/.storybook/main.ts +22 -0
  2. package/.storybook/manager-head.html +2 -0
  3. package/.storybook/mock-access-api.ts +5 -0
  4. package/.storybook/preview.css +5 -0
  5. package/.storybook/preview.tsx +73 -0
  6. package/CHANGELOG.md +234 -0
  7. package/package.json +24 -10
  8. package/postcss.config.js +6 -0
  9. package/src/components/Card.tsx +4 -3
  10. package/src/components/Dialog.tsx +2 -2
  11. package/src/components/EmptyState.tsx +48 -3
  12. package/src/components/InstanceScopeBanner.tsx +46 -0
  13. package/src/components/LinksEditor.tsx +156 -0
  14. package/src/components/UserMenu.tsx +1 -1
  15. package/src/index.ts +2 -0
  16. package/stories/AccessDenied.stories.tsx +17 -0
  17. package/stories/AccessGate.stories.tsx +49 -0
  18. package/stories/Accordion.stories.tsx +56 -0
  19. package/stories/Alert.stories.tsx +88 -0
  20. package/stories/AmbientBackground.stories.tsx +28 -0
  21. package/stories/AnimatedCounter.stories.tsx +41 -0
  22. package/stories/AnimatedNumber.stories.tsx +39 -0
  23. package/stories/BackLink.stories.tsx +32 -0
  24. package/stories/Badge.stories.tsx +37 -0
  25. package/stories/Button.stories.tsx +57 -0
  26. package/stories/Card.stories.tsx +39 -0
  27. package/stories/Checkbox.stories.tsx +45 -0
  28. package/stories/CodeEditor.stories.tsx +67 -0
  29. package/stories/ColorPicker.stories.tsx +24 -0
  30. package/stories/CommandPalette.stories.tsx +36 -0
  31. package/stories/ConfirmationModal.stories.tsx +40 -0
  32. package/stories/DateRangeFilter.stories.tsx +30 -0
  33. package/stories/DateTimePicker.stories.tsx +26 -0
  34. package/stories/Dialog.stories.tsx +62 -0
  35. package/stories/DynamicForm.stories.tsx +83 -0
  36. package/stories/DynamicIcon.stories.tsx +52 -0
  37. package/stories/EditableText.stories.tsx +29 -0
  38. package/stories/Feedback.stories.tsx +45 -0
  39. package/stories/IDELayout.stories.tsx +70 -0
  40. package/stories/InfoBanner.stories.tsx +41 -0
  41. package/stories/Input.stories.tsx +29 -0
  42. package/stories/InstanceScopeBanner.stories.tsx +35 -0
  43. package/stories/Introduction.mdx +50 -0
  44. package/stories/Label.stories.tsx +21 -0
  45. package/stories/LinksEditor.stories.tsx +37 -0
  46. package/stories/Markdown.stories.tsx +35 -0
  47. package/stories/Menu.stories.tsx +35 -0
  48. package/stories/MetricTile.stories.tsx +31 -0
  49. package/stories/NavItem.stories.tsx +29 -0
  50. package/stories/NotFound.stories.tsx +17 -0
  51. package/stories/Page.stories.tsx +29 -0
  52. package/stories/PageLayout.stories.tsx +59 -0
  53. package/stories/PaginatedList.stories.tsx +44 -0
  54. package/stories/Pagination.stories.tsx +31 -0
  55. package/stories/PerformanceProvider.stories.tsx +33 -0
  56. package/stories/PluginConfigForm.stories.tsx +64 -0
  57. package/stories/Popover.stories.tsx +30 -0
  58. package/stories/SectionHeader.stories.tsx +20 -0
  59. package/stories/Select.stories.tsx +36 -0
  60. package/stories/Sheet.stories.tsx +59 -0
  61. package/stories/Slider.stories.tsx +24 -0
  62. package/stories/StatusCard.stories.tsx +30 -0
  63. package/stories/StatusUpdateTimeline.stories.tsx +77 -0
  64. package/stories/StrategyConfigCard.stories.tsx +57 -0
  65. package/stories/SubscribeButton.stories.tsx +27 -0
  66. package/stories/Table.stories.tsx +56 -0
  67. package/stories/Tabs.stories.tsx +40 -0
  68. package/stories/TerminalFeed.stories.tsx +47 -0
  69. package/stories/Textarea.stories.tsx +25 -0
  70. package/stories/ThemeProvider.stories.tsx +38 -0
  71. package/stories/Toast.stories.tsx +32 -0
  72. package/stories/Toggle.stories.tsx +43 -0
  73. package/stories/Tooltip.stories.tsx +20 -0
  74. package/stories/UserMenu.stories.tsx +35 -0
  75. package/tailwind.config.js +74 -0
@@ -0,0 +1,22 @@
1
+ import type { StorybookConfig } from "@storybook/react-vite";
2
+
3
+ const config: StorybookConfig = {
4
+ stories: [
5
+ "../stories/**/*.mdx",
6
+ "../stories/**/*.stories.@(ts|tsx)",
7
+ ],
8
+ addons: [
9
+ "@storybook/addon-docs",
10
+ "@storybook/addon-themes",
11
+ "@storybook/addon-a11y",
12
+ ],
13
+ framework: {
14
+ name: "@storybook/react-vite",
15
+ options: {},
16
+ },
17
+ typescript: {
18
+ reactDocgen: "react-docgen",
19
+ },
20
+ };
21
+
22
+ export default config;
@@ -0,0 +1,2 @@
1
+ <title>Checkstack UI — Component Library</title>
2
+ <meta name="description" content="Component library for Checkstack plugin developers." />
@@ -0,0 +1,5 @@
1
+ import type { AccessApi } from "@checkstack/frontend-api";
2
+
3
+ export const mockAccessApi: AccessApi = {
4
+ useAccess: () => ({ loading: false, allowed: true }),
5
+ };
@@ -0,0 +1,5 @@
1
+ @import "../src/themes.css";
2
+
3
+ @tailwind base;
4
+ @tailwind components;
5
+ @tailwind utilities;
@@ -0,0 +1,73 @@
1
+ import type { Preview } from "@storybook/react";
2
+ import { withThemeByClassName } from "@storybook/addon-themes";
3
+ import React from "react";
4
+ import { MemoryRouter } from "react-router-dom";
5
+ import {
6
+ ApiRegistryBuilder,
7
+ ApiProvider,
8
+ accessApiRef,
9
+ } from "@checkstack/frontend-api";
10
+ import { ThemeProvider } from "../src/components/ThemeProvider";
11
+ import { ToastProvider } from "../src/components/ToastProvider";
12
+ import { PerformanceProvider } from "../src/components/PerformanceProvider";
13
+ import { mockAccessApi } from "./mock-access-api";
14
+ import "./preview.css";
15
+
16
+ const apiRegistry = new ApiRegistryBuilder()
17
+ .register(accessApiRef, mockAccessApi)
18
+ .build();
19
+
20
+ const preview: Preview = {
21
+ parameters: {
22
+ controls: {
23
+ matchers: {
24
+ color: /(background|color)$/i,
25
+ date: /Date$/i,
26
+ },
27
+ },
28
+ backgrounds: {
29
+ default: "app",
30
+ values: [
31
+ { name: "app", value: "hsl(0 0% 100%)" },
32
+ { name: "app-dark", value: "hsl(240 10% 4%)" },
33
+ ],
34
+ },
35
+ layout: "padded",
36
+ options: {
37
+ storySort: {
38
+ order: [
39
+ "Introduction",
40
+ "Foundations",
41
+ "Components",
42
+ ["Inputs", "Display", "Feedback", "Navigation", "Overlays", "Forms", "Layout", "Data"],
43
+ ],
44
+ },
45
+ },
46
+ },
47
+ decorators: [
48
+ withThemeByClassName({
49
+ themes: {
50
+ light: "light",
51
+ dark: "dark",
52
+ },
53
+ defaultTheme: "light",
54
+ }),
55
+ (Story) => (
56
+ <MemoryRouter>
57
+ <ApiProvider registry={apiRegistry}>
58
+ <ThemeProvider defaultTheme="light" storageKey="checkstack-storybook-theme">
59
+ <ToastProvider>
60
+ <PerformanceProvider>
61
+ <div className="bg-background text-foreground p-4">
62
+ <Story />
63
+ </div>
64
+ </PerformanceProvider>
65
+ </ToastProvider>
66
+ </ThemeProvider>
67
+ </ApiProvider>
68
+ </MemoryRouter>
69
+ ),
70
+ ],
71
+ };
72
+
73
+ export default preview;
package/CHANGELOG.md CHANGED
@@ -1,5 +1,239 @@
1
1
  # @checkstack/ui
2
2
 
3
+ ## 1.8.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [9016526]
8
+ - @checkstack/common@0.10.0
9
+ - @checkstack/frontend-api@0.5.1
10
+
11
+ ## 1.8.0
12
+
13
+ ### Minor Changes
14
+
15
+ - 1ef2e79: feat: hotlinks on incidents/maintenances and additional links on systems
16
+
17
+ Users with `manage` access on an incident, maintenance, or system can now
18
+ attach free-form URL "hotlinks" — Jira tickets, runbooks, dashboards, ticket
19
+ tools, etc. — alongside the existing fields.
20
+
21
+ - **Incidents** & **maintenances**: links live on the entity itself and are
22
+ surfaced both in the editor dialog and on the public detail page. Two new
23
+ RPC procedures per plugin (`addLink`, `removeLink`) gated behind the
24
+ existing `manage` access rule. Links are returned as part of
25
+ `getIncident` / `getMaintenance` and cache-invalidated on every link
26
+ mutation.
27
+ - **Systems**: a parallel `system_links` table with `getSystemLinks`,
28
+ `addSystemLink`, `removeSystemLink` procedures. Surfaced inside the
29
+ system editor (next to contacts) and on the read-only system detail
30
+ sidebar. Cache-scoped per-system so list endpoints remain hot.
31
+ - **Shared UI**: a `LinksEditor` component in `@checkstack/ui` does the
32
+ presentation; the three plugins each own their own RPC wiring.
33
+
34
+ Database changes ship as additive migrations (new `incident_links`,
35
+ `maintenance_links`, `system_links` tables, all FK-cascaded on parent
36
+ delete). No existing columns or rows are touched.
37
+
38
+ The system incident and maintenance history pages now sort by relevance:
39
+ active entries (non-`resolved` incidents, `scheduled` or `in_progress`
40
+ maintenances) appear at the top, with creation date descending as the
41
+ tiebreaker.
42
+
43
+ - aa89bc5: Replace the bespoke `registerInfrastructureTab()` registry with a standard
44
+ slot-extension contract (`InfrastructureTabsSlot` from
45
+ `@checkstack/infrastructure-common`). Plugins now contribute infrastructure
46
+ tabs via `createSlotExtension`, depending only on the slot owner.
47
+
48
+ The slot system in `@checkstack/frontend-api` gains a second type parameter
49
+ on `createSlot<TContext, TMetadata>` so extensions can declare typed static
50
+ metadata at registration time (label, icon, access rules, ordering for the
51
+ infrastructure tab bar). A new `useSlotExtensions(slot)` hook returns typed
52
+ extensions and subscribes to plugin lifecycle changes.
53
+
54
+ Each tab body now stacks a **Runtime** sub-section (live state, read-only)
55
+ on top of a **Configuration** sub-section (settings, gated by `canUpdate`).
56
+
57
+ **Queue runtime panel.** Surfaces aggregated counts (pending / processing /
58
+ completed / failed) plus three sub-tabs of recent jobs: **Active**, **Recent
59
+ failed** (with the failure message), and **Recent completed** (with
60
+ duration). Job payloads are deliberately not surfaced — they may carry
61
+ secrets and need a separate manage-access gate to be shown.
62
+
63
+ To support this, `Queue<T>` gains a required `listJobs(opts)` method
64
+ returning `JobSummary[]` (no payloads), and `QueueStats` gains a
65
+ `scope: "instance" | "cluster"` field. The in-memory queue keeps rolling
66
+ ring buffers (200 entries) for completed/failed history and tracks active
67
+ jobs by id; BullMQ uses native `getJobs`. `QueueManager.listJobs` aggregates
68
+ across queues and sorts (most-recent-first for terminal states, FIFO for
69
+ active/waiting/delayed).
70
+
71
+ **Cache runtime panel.** Lists the top N entries by size (or by recency) so
72
+ operators can debug a cache filling up. Values are deliberately omitted —
73
+ PII / secret risk. Backends opt in via an optional `listEntries?` method on
74
+ `CacheProvider`; non-supporting backends return `{ supported: false }` and
75
+ the UI renders a "not supported by this backend" hint. The in-memory cache
76
+ implements it using its existing per-entry byte tracking.
77
+
78
+ `CacheStats` also gains `scope: "instance" | "cluster"`.
79
+
80
+ **Multi-instance scope warning.** A new `<InstanceScopeBanner>` component in
81
+ `@checkstack/ui` renders a yellow banner above any runtime panel whose
82
+ backend reports `scope: "instance"` — i.e. in-memory queue or cache running
83
+ in a horizontally scaled deployment. The banner explains the metrics are
84
+ local to the responding replica and recommends switching to a clustered
85
+ backend (Redis-backed queue / cache) for cluster-wide visibility.
86
+
87
+ **Bug fix — stable cache provider proxy.** `CacheManagerImpl.getProvider()`
88
+ now returns a single stable proxy that delegates to whatever provider is
89
+ currently active. Previously, consumers of `createCachedScope` (and any
90
+ direct `cacheManager.getProvider()` caller) captured the active provider
91
+ reference at plugin-init time. After any `setActiveBackend` call — including
92
+ saving the same memory config in the new Cache tab, which reconstructs the
93
+ in-memory cache — those scopes wrote to an orphaned old provider while the
94
+ runtime panel read stats from the new (empty) one, making the runtime panel
95
+ appear to report 0 keys. With the proxy, all consumers share a single stable
96
+ identity and writes always land in the active provider.
97
+
98
+ **Bytes tracking on the in-memory cache.** `InMemoryCache.getStats().sizeBytes`
99
+ now returns a running approximation (UTF-8 bytes of the key plus
100
+ `v8.serialize(value).byteLength`, with a JSON fallback) that's kept in sync
101
+ across all eviction paths. Treat the number as a sanity gauge; it doesn't
102
+ include `Map` per-entry overhead.
103
+
104
+ **Pagination.** Both `Queue<T>.listJobs` and `CacheProvider.listEntries?`
105
+ are offset-paginated. Inputs gain an `offset: number`; outputs change to
106
+ `{ items, total: number | null, hasMore: boolean }`. `total` is nullable
107
+ so backends that can't compute it cheaply still paginate via `hasMore`.
108
+ The UI uses the existing `<Pagination>` component with a 25-row default
109
+ page size. `QueueManager.listJobs` aggregates by over-fetching
110
+ `[0, offset+limit)` per queue, merge-sorting, then slicing the window —
111
+ optimal for the single-queue case, acceptable for the multi-queue case
112
+ within the UI's reasonable page-depth bounds. BullMQ uses native offset
113
+ ranges via `getJobs(types, start, end)` plus `getJobCounts` for `total`.
114
+
115
+ **Pending tab.** The Queue runtime panel exposes a virtual `"pending"`
116
+ state (waiting ∪ delayed, FIFO). It's now the default sub-tab, since
117
+ "what's queued up?" is the most common question. Per-row state is shown
118
+ when viewing the combined list.
119
+
120
+ **Recurring schedules visible under Pending.** Cron- and interval-based
121
+ recurring jobs (e.g. healthchecks) are surfaced under Pending/Delayed
122
+ between fires, with a `nextRunAt` countdown column and a "(recurring)"
123
+ label. `JobSummary` gains optional `nextRunAt: Date` and `recurring:
124
+ boolean` fields. The in-memory queue synthesises these rows from its
125
+ `recurringJobs` registry; BullMQ already materialises the next fire of
126
+ each scheduler as a delayed job and we now surface its trigger time and
127
+ the `repeatJobKey`-derived `recurring` flag.
128
+
129
+ **Bug fix — drop hook emits with no listeners.** `EventBus.emit` no
130
+ longer enqueues a job when zero listeners (distributed or instance-local)
131
+ are registered for the hook. Previously, hooks like
132
+ `core.plugin.initialized` — emitted on every plugin init but subscribed
133
+ to by nothing in the core repo — accumulated one waiting job per emit
134
+ forever. The in-memory queue's `processNext` short-circuits when there
135
+ are zero consumer groups, so its post-loop cleanup never ran for these
136
+ orphaned jobs. The fix drops the emit at the source and logs a debug
137
+ line. Note: in distributed deployments using a Redis-backed queue, this
138
+ means a subscriber on another replica won't receive an event if no
139
+ replica that emits it has a local listener. Plugins needing cross-process
140
+ delivery must register their listener on every replica that should
141
+ receive the hook.
142
+
143
+ **Breaking notes (treated as minor under beta semantics)**:
144
+
145
+ - `@checkstack/infrastructure-common` removes `registerInfrastructureTab`
146
+ and `getInfrastructureTabs`; former callers must register an extension
147
+ into `InfrastructureTabsSlot`.
148
+ - `@checkstack/queue-api`'s `Queue<T>` interface requires the new
149
+ `listJobs(opts)` method returning `ListJobsResult` (paginated). Both
150
+ bundled queue backends (memory, BullMQ) are updated; out-of-tree
151
+ implementations will need to add it.
152
+ - `QueueStats` and `CacheStats` add a required `scope` field.
153
+ - `CacheProvider.listEntries?` (when implemented) now returns
154
+ `ListEntriesResult` instead of `CacheEntrySummary[]`.
155
+ - `JobState` adds a `"pending"` variant.
156
+
157
+ - 3547670: Add `@checkstack/tips-*` — first-run tip and onboarding infrastructure for
158
+ the frontends.
159
+
160
+ Three new packages:
161
+
162
+ - `@checkstack/tips-common` — RPC contract (`tipsContract`), `TipsApi`
163
+ client definition, and zod schemas. Fully-qualified tip IDs have shape
164
+ `<pluginId>.<localTipId>` and are produced exclusively by
165
+ `qualifyTipId(plugin, localId)` — plugins never write the namespace
166
+ themselves, and a local id with a leading or trailing `.` is rejected,
167
+ so one plugin cannot forge or dismiss a tip in another plugin's
168
+ namespace.
169
+ - `@checkstack/tips-backend` — Postgres-backed dismissal store
170
+ (`user_tip_dismissal` with composite PK on `(user_id, tip_id)`),
171
+ `listDismissed` / `dismiss` / `reset` endpoints scoped to the
172
+ requesting user via the auto-auth middleware, and a
173
+ `auth.userDeleted` hook that cleans up dismissals when a user is
174
+ deleted.
175
+ - `@checkstack/tips-frontend` — `<Tip>` (anchored popover) and
176
+ `<TipBanner>` (inline callout) components plus the `useTipState`
177
+ hook. All three accept `{ plugin, id }` (where `plugin` is the
178
+ caller's `pluginMetadata`) and route through `qualifyTipId` so the
179
+ namespace prefix is enforced at the boundary. Persists per-user on
180
+ the server when logged in, and per-browser in `localStorage`
181
+ (`checkstack.tips.dismissed`) when anonymous, with cross-tab sync via
182
+ the `storage` event.
183
+
184
+ `@checkstack/ui`'s `<EmptyState>` gains optional `steps` and `actions`
185
+ props for richer empty-state coaching (numbered onboarding lists +
186
+ primary CTA), and accepts `ReactNode` for `description`. Existing
187
+ callers continue to work unchanged.
188
+
189
+ `@checkstack/test-utils-backend`'s `createMockDb` now also mocks
190
+ `insert().values().onConflictDoNothing()` so routers using upsert-or-skip
191
+ semantics can be unit-tested.
192
+
193
+ ### Patch Changes
194
+
195
+ - 3547670: Give `<DialogContent>` real vertical breathing room between its
196
+ children. The previous `gap-4` on `<DialogContent>` was a no-op because
197
+ the children were rendered inside a single inner wrapper, so
198
+ `<DialogHeader>`, the body, and `<DialogFooter>` all stacked tight
199
+ against each other. The inner wrapper is now a flex column with
200
+ `gap-6`, so headers/descriptions, body content, and footer buttons sit
201
+ apart at the dialog level without callers having to add
202
+ `<div className="space-y-…">` themselves.
203
+ - 950d6ec: Fix mobile UserMenu items rendering at zero height, group menu items by
204
+ section, and unstack cramped card headers on small viewports.
205
+
206
+ - **UserMenu mobile bug**: On mobile, the user-menu Sheet rendered every
207
+ menu item as a grid row, which combined with `flex-shrink: 1` on each
208
+ item collapsed the buttons whose internal layout uses `display: flex`
209
+ (the items registered with `useNavigate` rather than `<Link>`) to zero
210
+ content height. Switched the mobile container to a flex column with
211
+ `[&>*]:shrink-0` and added `min-h-0` so the sheet scrolls correctly
212
+ when the list overflows.
213
+
214
+ - **UserMenu grouping**: Slot extensions now accept an optional `group`
215
+ field. The user menu buckets `UserMenuItemsSlot` extensions by `group`
216
+ and renders each group under a labeled header (`Workspace`,
217
+ `Reliability`, `Configuration`, `Documentation`, `Account`). Existing
218
+ core plugins are tagged with the appropriate group; third-party plugins
219
+ can pick any of these or supply their own label. Untagged extensions
220
+ render last with no header. `UserMenuItemsBottomSlot` is unaffected.
221
+
222
+ - **Card header responsiveness**: `CardHeaderRow` (the primitive shared by
223
+ Incident, Maintenance, Auth, Catalog, GitOps and other config cards) now
224
+ stacks vertically on narrow viewports and only switches to a single row
225
+ at the `sm` breakpoint, so titles and adjacent filter controls (e.g.
226
+ status `Select`, "Show resolved" checkbox) no longer cram together on
227
+ mobile. Refactored the Incident and Maintenance config pages to use the
228
+ primitive instead of a hand-rolled `flex items-center justify-between`
229
+ row, and made their `Select` triggers full-width on mobile.
230
+
231
+ - Updated dependencies [42abfff]
232
+ - Updated dependencies [aa89bc5]
233
+ - Updated dependencies [950d6ec]
234
+ - @checkstack/common@0.9.0
235
+ - @checkstack/frontend-api@0.5.0
236
+
3
237
  ## 1.7.1
4
238
 
5
239
  ### Patch Changes
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@checkstack/ui",
3
- "version": "1.7.1",
3
+ "version": "1.8.1",
4
4
  "license": "Elastic-2.0",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
7
7
  "dependencies": {
8
- "@checkstack/common": "0.7.0",
9
- "@checkstack/frontend-api": "0.4.1",
8
+ "@checkstack/common": "0.9.0",
9
+ "@checkstack/frontend-api": "0.5.0",
10
10
  "@monaco-editor/react": "^4.7.0",
11
11
  "@radix-ui/react-accordion": "^1.2.12",
12
12
  "@radix-ui/react-dialog": "^1.1.15",
@@ -23,26 +23,40 @@
23
23
  "monaco-editor": "^0.55.1",
24
24
  "react": "^18.2.0",
25
25
  "react-day-picker": "^9.13.0",
26
- "react-dom": "^19.2.5",
26
+ "react-dom": "^18.2.0",
27
27
  "react-markdown": "^10.1.0",
28
28
  "react-router-dom": "^6.20.0",
29
29
  "recharts": "^3.6.0",
30
30
  "tailwind-merge": "^2.2.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@checkstack/scripts": "0.1.2",
34
- "@checkstack/test-utils-frontend": "0.0.4",
35
- "@checkstack/tsconfig": "0.0.6",
33
+ "@checkstack/scripts": "0.3.1",
34
+ "@checkstack/test-utils-frontend": "0.0.5",
35
+ "@checkstack/tsconfig": "0.0.7",
36
+ "@storybook/addon-a11y": "^10.3.6",
37
+ "@storybook/addon-docs": "^10.3.6",
38
+ "@storybook/addon-themes": "^10.3.6",
39
+ "@storybook/react": "^10.3.6",
40
+ "@storybook/react-vite": "^10.3.6",
36
41
  "@testing-library/react": "^16.0.0",
37
42
  "@types/react": "^18.2.0",
38
- "@types/react-dom": "^19.2.3",
39
- "typescript": "^5.0.0"
43
+ "@types/react-dom": "^18.2.0",
44
+ "@vitejs/plugin-react": "^6.0.1",
45
+ "autoprefixer": "^10.4.18",
46
+ "postcss": "^8.4.35",
47
+ "storybook": "^10.3.6",
48
+ "tailwindcss": "^3.4.1",
49
+ "tailwindcss-animate": "^1.0.7",
50
+ "typescript": "^5.0.0",
51
+ "vite": "^8.0.8"
40
52
  },
41
53
  "scripts": {
42
54
  "typecheck": "tsgo -b",
43
55
  "lint": "bun run lint:code",
44
56
  "lint:code": "eslint . --max-warnings 0",
45
- "test": "bun test"
57
+ "test": "bun test",
58
+ "storybook": "storybook dev -p 6006",
59
+ "storybook:build": "storybook build -o storybook-static"
46
60
  },
47
61
  "checkstack": {
48
62
  "type": "tooling"
@@ -0,0 +1,6 @@
1
+ export default {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {},
5
+ },
6
+ };
@@ -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"
@@ -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
+ };