@kb-labs/studio-app 0.6.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.
Files changed (168) hide show
  1. package/.env.example +10 -0
  2. package/README.md +74 -0
  3. package/UI-KIT-COMPONENTS.md +783 -0
  4. package/UI-KIT-PLAN.md +326 -0
  5. package/eslint-rules/no-direct-antd-import.js +151 -0
  6. package/eslint.config.ts +27 -0
  7. package/index.html +17 -0
  8. package/package.json +72 -0
  9. package/postcss.config.js +7 -0
  10. package/public/favicon.ico +0 -0
  11. package/public/favicon.svg +7 -0
  12. package/rspack.config.mjs +118 -0
  13. package/src/App.tsx +46 -0
  14. package/src/components/devtools/devtools-log-feed.module.css +165 -0
  15. package/src/components/devtools/devtools-log-feed.tsx +300 -0
  16. package/src/components/devtools/devtools-panel.module.css +121 -0
  17. package/src/components/devtools/devtools-panel.tsx +115 -0
  18. package/src/components/empty-state.tsx +28 -0
  19. package/src/components/error-boundary.tsx +210 -0
  20. package/src/components/health-banner.module.css +103 -0
  21. package/src/components/health-banner.tsx +134 -0
  22. package/src/components/health-indicator.tsx +12 -0
  23. package/src/components/page-header.tsx +49 -0
  24. package/src/components/page-transition.tsx +24 -0
  25. package/src/components/role-switcher.tsx +148 -0
  26. package/src/components/run-badge.tsx +13 -0
  27. package/src/components/ui/icons.tsx +509 -0
  28. package/src/components/ui/index.ts +25 -0
  29. package/src/components/ui/kb-config-provider.tsx +130 -0
  30. package/src/components/ui/kb-header.module.css +51 -0
  31. package/src/components/ui/kb-header.tsx +112 -0
  32. package/src/components/ui/kb-notification-bell.module.css +103 -0
  33. package/src/components/ui/kb-notification-bell.tsx +199 -0
  34. package/src/components/ui/kb-page-layout.tsx +66 -0
  35. package/src/components/ui/kb-quick-search.module.css +86 -0
  36. package/src/components/ui/kb-quick-search.tsx +196 -0
  37. package/src/components/ui/kb-sidebar.module.css +47 -0
  38. package/src/components/ui/kb-sidebar.tsx +196 -0
  39. package/src/components/ui/kb-stat-card.module.css +21 -0
  40. package/src/components/ui/kb-stat-card.tsx +22 -0
  41. package/src/components/ui/kb-stat-grid.tsx +22 -0
  42. package/src/components/ui/kb-status-bar.module.css +49 -0
  43. package/src/components/ui/kb-status-bar.tsx +145 -0
  44. package/src/components/ui/kb-system-health-indicator.tsx +229 -0
  45. package/src/components/ui/kb-theme-toggle.tsx +42 -0
  46. package/src/components/ui/theme-adapter.ts +812 -0
  47. package/src/components/ui/theme-transition-overlay.tsx +70 -0
  48. package/src/components/ui/utils.ts +6 -0
  49. package/src/components/widget-error-boundary.tsx +172 -0
  50. package/src/config/env.ts +5 -0
  51. package/src/config/feature-flags.ts +482 -0
  52. package/src/config/studio.config.schema.ts +88 -0
  53. package/src/config/studio.config.ts +84 -0
  54. package/src/env.d.ts +23 -0
  55. package/src/hooks/use-command-palette.ts +6 -0
  56. package/src/hooks/use-devtools-store.ts +25 -0
  57. package/src/hooks/use-feature-flags.ts +101 -0
  58. package/src/index.css +10 -0
  59. package/src/layouts/dashboard-grid.tsx +122 -0
  60. package/src/layouts/index.ts +12 -0
  61. package/src/layouts/two-pane.tsx +134 -0
  62. package/src/main.tsx +15 -0
  63. package/src/modules/analytics/components/analytics-daily-stats-chart.tsx +257 -0
  64. package/src/modules/analytics/components/analytics-date-range-picker.tsx +121 -0
  65. package/src/modules/analytics/pages/analytics-cache-page.tsx +285 -0
  66. package/src/modules/analytics/pages/analytics-embeddings-page.tsx +274 -0
  67. package/src/modules/analytics/pages/analytics-events-page.tsx +425 -0
  68. package/src/modules/analytics/pages/analytics-llm-page.tsx +434 -0
  69. package/src/modules/analytics/pages/analytics-overview-page.tsx +336 -0
  70. package/src/modules/analytics/pages/analytics-page.tsx +20 -0
  71. package/src/modules/analytics/pages/analytics-storage-page.tsx +344 -0
  72. package/src/modules/analytics/pages/analytics-vectorstore-page.tsx +279 -0
  73. package/src/modules/analytics/routes/index.tsx +133 -0
  74. package/src/modules/analytics/utils/formatters.test.ts +148 -0
  75. package/src/modules/analytics/utils/formatters.ts +100 -0
  76. package/src/modules/auth/pages/login-page.module.css +113 -0
  77. package/src/modules/auth/pages/login-page.tsx +80 -0
  78. package/src/modules/auth/routes/index.tsx +24 -0
  79. package/src/modules/dashboard/components/ActivityTimelineWidget.tsx +199 -0
  80. package/src/modules/dashboard/components/AiInsightsWidget.tsx +358 -0
  81. package/src/modules/dashboard/components/AnimatedMetricCard.css +88 -0
  82. package/src/modules/dashboard/components/AnimatedMetricCard.tsx +125 -0
  83. package/src/modules/dashboard/components/HeroMetricCard.css +114 -0
  84. package/src/modules/dashboard/components/HeroMetricCard.tsx +152 -0
  85. package/src/modules/dashboard/components/HeroMetricsWidget.tsx +146 -0
  86. package/src/modules/dashboard/components/SystemResourcesWidget.tsx +197 -0
  87. package/src/modules/dashboard/components/dashboard-empty.tsx +22 -0
  88. package/src/modules/dashboard/components/dashboard-kpis-widget.tsx +59 -0
  89. package/src/modules/dashboard/components/dashboard-kpis.tsx +13 -0
  90. package/src/modules/dashboard/components/dashboard-latency-percentiles-widget.tsx +85 -0
  91. package/src/modules/dashboard/components/dashboard-metrics-widget.tsx +78 -0
  92. package/src/modules/dashboard/components/dashboard-plugins-widget.tsx +67 -0
  93. package/src/modules/dashboard/components/dashboard-requests-widget.tsx +62 -0
  94. package/src/modules/dashboard/layouts/dashboard-layout.tsx +16 -0
  95. package/src/modules/dashboard/pages/ai-insights-page.tsx +563 -0
  96. package/src/modules/dashboard/pages/dashboard-animations.css +317 -0
  97. package/src/modules/dashboard/pages/dashboard-page.tsx +13 -0
  98. package/src/modules/dashboard/routes/index.tsx +70 -0
  99. package/src/modules/observability/pages/devkit-page.tsx +263 -0
  100. package/src/modules/observability/pages/incident-detail-page.tsx +571 -0
  101. package/src/modules/observability/pages/incidents-page.tsx +370 -0
  102. package/src/modules/observability/pages/log-detail-page.tsx +508 -0
  103. package/src/modules/observability/pages/logs-page.tsx +1129 -0
  104. package/src/modules/observability/pages/prometheus-metrics-page.tsx +486 -0
  105. package/src/modules/observability/pages/state-broker-page.tsx +229 -0
  106. package/src/modules/observability/pages/system-events-page.tsx +255 -0
  107. package/src/modules/observability/routes/index.tsx +133 -0
  108. package/src/modules/plugins/components/marketplace-card.tsx +153 -0
  109. package/src/modules/plugins/components/plugin-ai-assistant-modal.tsx +374 -0
  110. package/src/modules/plugins/components/plugin-card.tsx +136 -0
  111. package/src/modules/plugins/components/plugin-detail/capabilities-summary.tsx +101 -0
  112. package/src/modules/plugins/components/plugin-detail/cli-commands-table.tsx +101 -0
  113. package/src/modules/plugins/components/plugin-detail/index.ts +7 -0
  114. package/src/modules/plugins/components/plugin-detail/jobs-table.tsx +64 -0
  115. package/src/modules/plugins/components/plugin-detail/permissions/env-permissions.tsx +30 -0
  116. package/src/modules/plugins/components/plugin-detail/permissions/filesystem-permissions.tsx +68 -0
  117. package/src/modules/plugins/components/plugin-detail/permissions/index.ts +6 -0
  118. package/src/modules/plugins/components/plugin-detail/permissions/network-permissions.tsx +43 -0
  119. package/src/modules/plugins/components/plugin-detail/permissions/platform-services.tsx +242 -0
  120. package/src/modules/plugins/components/plugin-detail/permissions/resource-quotas.tsx +96 -0
  121. package/src/modules/plugins/components/plugin-detail/permissions/shell-permissions.tsx +55 -0
  122. package/src/modules/plugins/components/plugin-detail/permissions-view.tsx +47 -0
  123. package/src/modules/plugins/components/plugin-detail/plugin-header.tsx +169 -0
  124. package/src/modules/plugins/components/plugin-detail/rest-routes-table.tsx +159 -0
  125. package/src/modules/plugins/components/plugin-detail/workflows-table.tsx +40 -0
  126. package/src/modules/plugins/components/plugin-grid.tsx +20 -0
  127. package/src/modules/plugins/components/plugin-table.tsx +178 -0
  128. package/src/modules/plugins/pages/marketplace-page.tsx +200 -0
  129. package/src/modules/plugins/pages/plugin-detail-page.tsx +1145 -0
  130. package/src/modules/plugins/routes/index.tsx +48 -0
  131. package/src/modules/plugins/utils/index.ts +1 -0
  132. package/src/modules/plugins/utils/schema-helpers.ts +21 -0
  133. package/src/modules/settings/components/api-routes-viewer.tsx +415 -0
  134. package/src/modules/settings/components/appearance-settings.tsx +200 -0
  135. package/src/modules/settings/components/configuration-settings.tsx +321 -0
  136. package/src/modules/settings/components/data-privacy-settings.tsx +111 -0
  137. package/src/modules/settings/components/experimental-settings.tsx +243 -0
  138. package/src/modules/settings/components/navigation-settings.tsx +198 -0
  139. package/src/modules/settings/components/notifications-settings.tsx +40 -0
  140. package/src/modules/settings/pages/settings-page.tsx +298 -0
  141. package/src/modules/settings/routes/index.tsx +47 -0
  142. package/src/pages/README-assistant.md +91 -0
  143. package/src/pages/login-page.tsx +177 -0
  144. package/src/pages/not-found-page.tsx +85 -0
  145. package/src/providers/auth-provider.tsx +40 -0
  146. package/src/providers/command-palette-provider.tsx +193 -0
  147. package/src/providers/data-sources-provider.tsx +27 -0
  148. package/src/providers/devtools-provider.tsx +72 -0
  149. package/src/providers/navigation-items-provider.tsx +38 -0
  150. package/src/providers/registry-v2-provider.tsx +93 -0
  151. package/src/providers/settings-provider.tsx +158 -0
  152. package/src/router.tsx +302 -0
  153. package/src/routes/helpers.tsx +25 -0
  154. package/src/routes/plugin-page-v2.tsx +52 -0
  155. package/src/routes/types.ts +18 -0
  156. package/src/styles/antd-overrides.css +211 -0
  157. package/src/styles/base.css +190 -0
  158. package/src/styles/settings.css +75 -0
  159. package/src/styles/variables.css +94 -0
  160. package/src/utils/analytics.ts +183 -0
  161. package/src/utils/apply-navigation-categories.ts +83 -0
  162. package/src/utils/commands.ts +252 -0
  163. package/src/utils/export.ts +174 -0
  164. package/src/utils/format-date.ts +166 -0
  165. package/src/utils/logger.ts +110 -0
  166. package/tailwind.config.ts +13 -0
  167. package/tsconfig.json +13 -0
  168. package/vitest-setup.ts +1 -0
@@ -0,0 +1,229 @@
1
+ import {
2
+ UIRow,
3
+ UICol,
4
+ UITable,
5
+ UICard,
6
+ UIStatistic,
7
+ UIProgress,
8
+ UIAlert,
9
+ UIIcon,
10
+ } from '@kb-labs/studio-ui-kit';
11
+ import { useStateBrokerStats } from '@kb-labs/studio-data-client';
12
+ import { useDataSources } from '../../../providers/data-sources-provider';
13
+ import type { NamespaceStats } from '@kb-labs/studio-data-client';
14
+ import { UIPage, UIPageHeader } from '@kb-labs/studio-ui-kit';
15
+
16
+ /**
17
+ * Format uptime in milliseconds to human-readable string
18
+ */
19
+ function formatUptime(ms: number): string {
20
+ const hours = Math.floor(ms / 3600000);
21
+ const minutes = Math.floor((ms % 3600000) / 60000);
22
+
23
+ if (hours > 0) {
24
+ return `${hours}h ${minutes}m`;
25
+ }
26
+ return `${minutes}m`;
27
+ }
28
+
29
+ /**
30
+ * Format bytes to human-readable size
31
+ */
32
+ function formatBytes(bytes: number): string {
33
+ if (bytes === 0) {return '0 B';}
34
+ const k = 1024;
35
+ const sizes = ['B', 'KB', 'MB', 'GB'];
36
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
37
+ return `${Math.round(bytes / Math.pow(k, i) * 100) / 100} ${sizes[i]}`;
38
+ }
39
+
40
+ /**
41
+ * State Broker Observability Page
42
+ *
43
+ * Shows real-time statistics from the State Broker daemon:
44
+ * - Cache hit/miss rates
45
+ * - Namespace breakdown
46
+ * - Uptime and entry counts
47
+ */
48
+ export function StateBrokerPage() {
49
+ const sources = useDataSources();
50
+ const { data, isLoading, error, isError } = useStateBrokerStats(sources.observability);
51
+
52
+ if (isError) {
53
+ return (
54
+ <UIPage>
55
+ <UIPageHeader
56
+ title="State Broker"
57
+ description="In-memory cache statistics"
58
+ />
59
+ <UIAlert
60
+ message="Failed to load State Broker stats"
61
+ description={error instanceof Error ? error.message : 'Unknown error. Make sure State Daemon is running on localhost:7777'}
62
+ variant="error"
63
+ showIcon
64
+ style={{ marginBottom: 24 }}
65
+ />
66
+ </UIPage>
67
+ );
68
+ }
69
+
70
+ if (isLoading || !data) {
71
+ return (
72
+ <UIPage>
73
+ <UIPageHeader
74
+ title="State Broker"
75
+ description="In-memory cache statistics"
76
+ />
77
+ <div style={{ padding: '24px 0', textAlign: 'center' }}>
78
+ Loading...
79
+ </div>
80
+ </UIPage>
81
+ );
82
+ }
83
+
84
+ const hitRatePercent = Math.round(data.hitRate * 100);
85
+ const missRatePercent = Math.round(data.missRate * 100);
86
+
87
+ return (
88
+ <UIPage width="full">
89
+ <UIPageHeader
90
+ title="State Broker"
91
+ description="In-memory cache statistics - Auto-refresh every 5s"
92
+ />
93
+
94
+ {/* Overview Stats */}
95
+ <UIRow gutter={[16, 16]} style={{ marginBottom: 24 }}>
96
+ <UICol xs={24} sm={12} lg={6}>
97
+ <UICard>
98
+ <UIStatistic
99
+ title="Uptime"
100
+ value={formatUptime(data.uptime)}
101
+ prefix={<UIIcon name="ClockCircleOutlined" />}
102
+ />
103
+ </UICard>
104
+ </UICol>
105
+ <UICol xs={24} sm={12} lg={6}>
106
+ <UICard>
107
+ <UIStatistic
108
+ title="Cache Entries"
109
+ value={data.totalEntries}
110
+ prefix={<UIIcon name="DatabaseOutlined" />}
111
+ />
112
+ </UICard>
113
+ </UICol>
114
+ <UICol xs={24} sm={12} lg={6}>
115
+ <UICard>
116
+ <UIStatistic
117
+ title="Cache Size"
118
+ value={formatBytes(data.totalSize)}
119
+ prefix={<UIIcon name="DatabaseOutlined" />}
120
+ />
121
+ </UICard>
122
+ </UICol>
123
+ <UICol xs={24} sm={12} lg={6}>
124
+ <UICard>
125
+ <UIStatistic
126
+ title="Evictions"
127
+ value={data.evictions}
128
+ prefix={<UIIcon name="DeleteOutlined" />}
129
+ />
130
+ </UICard>
131
+ </UICol>
132
+ </UIRow>
133
+
134
+ {/* Hit/Miss Rate */}
135
+ <UIRow gutter={[16, 16]} style={{ marginBottom: 24 }}>
136
+ <UICol xs={24} lg={12}>
137
+ <UICard title="Cache Hit Rate" extra={<UIIcon name="CheckCircleOutlined" style={{ color: '#52c41a' }} />}>
138
+ <UIProgress
139
+ percent={hitRatePercent}
140
+ status={hitRatePercent >= 70 ? 'success' : hitRatePercent >= 50 ? 'normal' : 'exception'}
141
+ strokeColor={hitRatePercent >= 70 ? '#52c41a' : hitRatePercent >= 50 ? '#1890ff' : '#ff4d4f'}
142
+ />
143
+ <div style={{ marginTop: 8, fontSize: 12, color: '#8c8c8c' }}>
144
+ {hitRatePercent >= 70 ? 'Excellent cache performance' :
145
+ hitRatePercent >= 50 ? 'Good cache performance' :
146
+ 'Poor cache performance - consider increasing TTL'}
147
+ </div>
148
+ </UICard>
149
+ </UICol>
150
+ <UICol xs={24} lg={12}>
151
+ <UICard title="Cache Miss Rate" extra={<UIIcon name="CloseCircleOutlined" style={{ color: '#ff4d4f' }} />}>
152
+ <UIProgress
153
+ percent={missRatePercent}
154
+ status={missRatePercent <= 30 ? 'success' : missRatePercent <= 50 ? 'normal' : 'exception'}
155
+ strokeColor={missRatePercent <= 30 ? '#52c41a' : missRatePercent <= 50 ? '#faad14' : '#ff4d4f'}
156
+ />
157
+ <div style={{ marginTop: 8, fontSize: 12, color: '#8c8c8c' }}>
158
+ {missRatePercent <= 30 ? 'Low miss rate - good cache efficiency' :
159
+ missRatePercent <= 50 ? 'Moderate miss rate' :
160
+ 'High miss rate - cache not effective'}
161
+ </div>
162
+ </UICard>
163
+ </UICol>
164
+ </UIRow>
165
+
166
+ {/* Namespaces Table */}
167
+ <UICard title="Namespaces Breakdown" style={{ marginBottom: 24 }}>
168
+ <UITable<{ key: string; name: string } & NamespaceStats>
169
+ dataSource={Object.entries(data.namespaces).map(([name, stats]) => ({
170
+ key: name,
171
+ name,
172
+ ...stats,
173
+ }))}
174
+ columns={[
175
+ {
176
+ title: 'Namespace',
177
+ dataIndex: 'name',
178
+ key: 'name',
179
+ render: (name: string) => <strong>{name}</strong>,
180
+ },
181
+ {
182
+ title: 'Entries',
183
+ dataIndex: 'entries',
184
+ key: 'entries',
185
+ align: 'right' as const,
186
+ },
187
+ {
188
+ title: 'Hits',
189
+ dataIndex: 'hits',
190
+ key: 'hits',
191
+ align: 'right' as const,
192
+ render: (hits: number) => (
193
+ <span style={{ color: '#52c41a' }}>{hits}</span>
194
+ ),
195
+ },
196
+ {
197
+ title: 'Misses',
198
+ dataIndex: 'misses',
199
+ key: 'misses',
200
+ align: 'right' as const,
201
+ render: (misses: number) => (
202
+ <span style={{ color: '#ff4d4f' }}>{misses}</span>
203
+ ),
204
+ },
205
+ {
206
+ title: 'Hit Rate',
207
+ key: 'hitRate',
208
+ align: 'right' as const,
209
+ render: (_: unknown, record: { hits: number; misses: number }) => {
210
+ const total = record.hits + record.misses;
211
+ const rate = total > 0 ? (record.hits / total) * 100 : 0;
212
+ return `${Math.round(rate)}%`;
213
+ },
214
+ },
215
+ {
216
+ title: 'Size',
217
+ dataIndex: 'size',
218
+ key: 'size',
219
+ align: 'right' as const,
220
+ render: (size: number) => formatBytes(size),
221
+ },
222
+ ]}
223
+ pagination={false}
224
+ size="small"
225
+ />
226
+ </UICard>
227
+ </UIPage>
228
+ );
229
+ }
@@ -0,0 +1,255 @@
1
+ import {
2
+ UICard,
3
+ UIAlert,
4
+ UIBadge,
5
+ UITag,
6
+ UITimeline,
7
+ UIRow,
8
+ UICol,
9
+ UIStatistic,
10
+ UIIcon,
11
+ } from '@kb-labs/studio-ui-kit';
12
+ import { useSystemEvents } from '@kb-labs/studio-data-client';
13
+ import { useDataSources } from '../../../providers/data-sources-provider';
14
+ import type { RegistryEvent, HealthEvent } from '@kb-labs/studio-data-client';
15
+ import { UIPage, UIPageHeader } from '@kb-labs/studio-ui-kit';
16
+
17
+ /**
18
+ * Format timestamp to time string
19
+ */
20
+ function formatTime(timestamp: string): string {
21
+ return new Date(timestamp).toLocaleTimeString();
22
+ }
23
+
24
+ /**
25
+ * System Events Live Feed Page
26
+ *
27
+ * Shows real-time system events from /events/registry SSE stream:
28
+ * - Registry updates (plugin registration, checksums)
29
+ * - Health status changes
30
+ * - Redis state transitions
31
+ * - Plugin mount events
32
+ */
33
+ export function SystemEventsPage() {
34
+ const sources = useDataSources();
35
+ const { events, isConnected, error } = useSystemEvents(sources.observability);
36
+
37
+ const latestHealth = events.find((e) => e.type === 'health') as HealthEvent | undefined;
38
+ const latestRegistry = events.find((e) => e.type === 'registry') as RegistryEvent | undefined;
39
+
40
+ return (
41
+ <UIPage width="full">
42
+ <UIPageHeader
43
+ title="System Events"
44
+ description="Real-time system event stream - Auto-updates via Server-Sent Events"
45
+ />
46
+
47
+ {/* Connection Status */}
48
+ {!isConnected && !error && (
49
+ <UIAlert
50
+ message="Connecting to event stream..."
51
+ variant="info"
52
+ showIcon
53
+ icon={<UIIcon name="SyncOutlined" spin />}
54
+ style={{ marginBottom: 24 }}
55
+ />
56
+ )}
57
+
58
+ {error && (
59
+ <UIAlert
60
+ message="Connection failed"
61
+ description={error.message + ' - Make sure REST API is running on localhost:5050'}
62
+ variant="error"
63
+ showIcon
64
+ style={{ marginBottom: 24 }}
65
+ />
66
+ )}
67
+
68
+ {isConnected && (
69
+ <UIAlert
70
+ message="Connected to event stream"
71
+ variant="success"
72
+ showIcon
73
+ icon={<UIIcon name="CheckCircleOutlined" />}
74
+ style={{ marginBottom: 24 }}
75
+ />
76
+ )}
77
+
78
+ {/* Current System Status */}
79
+ <UIRow gutter={[16, 16]} style={{ marginBottom: 24 }}>
80
+ <UICol xs={24} lg={12}>
81
+ <UICard
82
+ title="Latest Health Status"
83
+ extra={
84
+ latestHealth ? (
85
+ <UIBadge
86
+ variant={latestHealth.ready ? 'success' : 'error'}
87
+ >
88
+ {latestHealth.ready ? 'Ready' : 'Not Ready'}
89
+ </UIBadge>
90
+ ) : null
91
+ }
92
+ >
93
+ {latestHealth ? (
94
+ <UIRow gutter={16}>
95
+ <UICol span={8}>
96
+ <UIStatistic
97
+ title="Status"
98
+ value={latestHealth.status}
99
+ valueStyle={{ color: latestHealth.status === 'healthy' ? '#52c41a' : '#ff4d4f' }}
100
+ />
101
+ </UICol>
102
+ <UICol span={8}>
103
+ <UIStatistic
104
+ title="Plugins Mounted"
105
+ value={latestHealth.pluginsMounted ?? 0}
106
+ suffix={latestHealth.pluginsMounted !== undefined && latestHealth.pluginsFailed !== undefined
107
+ ? `/ ${latestHealth.pluginsMounted + latestHealth.pluginsFailed}`
108
+ : ''}
109
+ />
110
+ </UICol>
111
+ <UICol span={8}>
112
+ <UIStatistic
113
+ title="Redis"
114
+ value={latestHealth.redisEnabled
115
+ ? (latestHealth.redisHealthy ? 'Healthy' : 'Unhealthy')
116
+ : 'Disabled'}
117
+ valueStyle={{
118
+ color: !latestHealth.redisEnabled
119
+ ? '#8c8c8c'
120
+ : (latestHealth.redisHealthy ? '#52c41a' : '#ff4d4f')
121
+ }}
122
+ />
123
+ </UICol>
124
+ </UIRow>
125
+ ) : (
126
+ <UIAlert message="No health data received yet" variant="info" showIcon />
127
+ )}
128
+ </UICard>
129
+ </UICol>
130
+
131
+ <UICol xs={24} lg={12}>
132
+ <UICard
133
+ title="Latest Registry"
134
+ extra={
135
+ latestRegistry ? (
136
+ <UITag color={latestRegistry.stale ? 'orange' : 'green'}>
137
+ {latestRegistry.stale ? 'Stale' : 'Fresh'}
138
+ </UITag>
139
+ ) : null
140
+ }
141
+ >
142
+ {latestRegistry ? (
143
+ <UIRow gutter={16}>
144
+ <UICol span={12}>
145
+ <UIStatistic
146
+ title="Revision"
147
+ value={String(latestRegistry.rev).substring(0, 8)}
148
+ valueStyle={{ fontSize: 18 }}
149
+ />
150
+ </UICol>
151
+ <UICol span={12}>
152
+ <UIStatistic
153
+ title="Generated"
154
+ value={formatTime(latestRegistry.generatedAt)}
155
+ valueStyle={{ fontSize: 18 }}
156
+ />
157
+ </UICol>
158
+ </UIRow>
159
+ ) : (
160
+ <UIAlert message="No registry data received yet" variant="info" showIcon />
161
+ )}
162
+ </UICard>
163
+ </UICol>
164
+ </UIRow>
165
+
166
+ {/* Event Timeline */}
167
+ <UICard
168
+ title="Live Event Feed"
169
+ extra={
170
+ <UIBadge
171
+ count={events.length}
172
+ overflowCount={99}
173
+ style={{ backgroundColor: '#1890ff' }}
174
+ />
175
+ }
176
+ >
177
+ {events.length > 0 ? (
178
+ <UITimeline
179
+ items={events.map((event, index) => {
180
+ if (event.type === 'health') {
181
+ const healthEvent = event as HealthEvent;
182
+ return {
183
+ key: index,
184
+ color: healthEvent.ready ? 'green' : 'red',
185
+ dot: healthEvent.ready ? <UIIcon name="CheckCircleOutlined" /> : <UIIcon name="CloseCircleOutlined" />,
186
+ children: (
187
+ <div>
188
+ <div style={{ marginBottom: 4 }}>
189
+ <UITag color="blue">HEALTH</UITag>
190
+ <UITag color={healthEvent.status === 'healthy' ? 'green' : 'red'}>
191
+ {healthEvent.status}
192
+ </UITag>
193
+ {healthEvent.ready && <UITag color="green">READY</UITag>}
194
+ {!healthEvent.ready && healthEvent.reason && (
195
+ <UITag color="orange">{healthEvent.reason}</UITag>
196
+ )}
197
+ <span style={{ fontSize: 12, color: '#8c8c8c', marginLeft: 8 }}>
198
+ {formatTime(healthEvent.ts)}
199
+ </span>
200
+ </div>
201
+ <div style={{ fontSize: 13 }}>
202
+ {healthEvent.pluginsMounted !== undefined && healthEvent.pluginsFailed !== undefined ? (
203
+ <>Plugins: {healthEvent.pluginsMounted} mounted, {healthEvent.pluginsFailed} failed</>
204
+ ) : (
205
+ <>Plugins: status unavailable</>
206
+ )}
207
+ {healthEvent.redisEnabled && (
208
+ <> | Redis: {healthEvent.redisHealthy ? 'healthy' : 'unhealthy'}</>
209
+ )}
210
+ </div>
211
+ </div>
212
+ ),
213
+ };
214
+ } else {
215
+ const registryEvent = event as RegistryEvent;
216
+ return {
217
+ key: index,
218
+ color: registryEvent.stale ? 'orange' : 'blue',
219
+ dot: <UIIcon name="ApiOutlined" />,
220
+ children: (
221
+ <div>
222
+ <div style={{ marginBottom: 4 }}>
223
+ <UITag color="purple">REGISTRY</UITag>
224
+ <UITag>{String(registryEvent.rev).substring(0, 8)}</UITag>
225
+ {registryEvent.stale && <UITag color="orange">STALE</UITag>}
226
+ {registryEvent.partial && <UITag color="orange">PARTIAL</UITag>}
227
+ <span style={{ fontSize: 12, color: '#8c8c8c', marginLeft: 8 }}>
228
+ {formatTime(registryEvent.generatedAt)}
229
+ </span>
230
+ </div>
231
+ {registryEvent.checksum && (
232
+ <div style={{ fontSize: 13 }}>
233
+ Checksum: {registryEvent.checksum.substring(0, 16)}...
234
+ {registryEvent.previousChecksum && ' (changed)'}
235
+ </div>
236
+ )}
237
+ </div>
238
+ ),
239
+ };
240
+ }
241
+ })}
242
+ />
243
+ ) : (
244
+ <UIAlert
245
+ message="No events received yet"
246
+ description="Waiting for system events..."
247
+ variant="info"
248
+ showIcon
249
+ icon={<UIIcon name="SyncOutlined" spin />}
250
+ />
251
+ )}
252
+ </UICard>
253
+ </UIPage>
254
+ );
255
+ }
@@ -0,0 +1,133 @@
1
+ /**
2
+ * @module @kb-labs/studio-app/modules/observability/routes
3
+ * Observability module routing configuration
4
+ */
5
+
6
+ import type { RouteObject } from 'react-router-dom';
7
+ import { StateBrokerPage } from '../pages/state-broker-page';
8
+ import { DevKitPage } from '../pages/devkit-page';
9
+ import { PrometheusMetricsPage } from '../pages/prometheus-metrics-page';
10
+ import { SystemEventsPage } from '../pages/system-events-page';
11
+ import { LogsPage } from '../pages/logs-page';
12
+ import { LogDetailPage } from '../pages/log-detail-page';
13
+ import { IncidentsPage } from '../pages/incidents-page';
14
+ import { IncidentDetailPage } from '../pages/incident-detail-page';
15
+ import { ErrorBoundary } from '../../../components/error-boundary';
16
+ import { renderIcon } from '../../../routes/helpers';
17
+ import type { NavigationItem } from '@/components/ui';
18
+
19
+ // Route paths
20
+ const PATHS = {
21
+ STATE_BROKER: '/observability/state-broker',
22
+ DEVKIT: '/observability/devkit',
23
+ PROMETHEUS: '/observability/prometheus-metrics',
24
+ EVENTS: '/observability/system-events',
25
+ LOGS: '/observability/logs',
26
+ LOG_DETAIL: '/observability/logs/:id',
27
+ INCIDENTS: '/observability/incidents',
28
+ INCIDENT_DETAIL: '/observability/incidents/:id',
29
+ } as const;
30
+
31
+ // Route keys
32
+ const KEYS = {
33
+ MODULE: 'observability',
34
+ STATE_BROKER: 'observability-state-broker',
35
+ DEVKIT: 'observability-devkit',
36
+ PROMETHEUS: 'observability-prometheus',
37
+ EVENTS: 'observability-events',
38
+ LOGS: 'observability-logs',
39
+ INCIDENTS: 'observability-incidents',
40
+ } as const;
41
+
42
+ /**
43
+ * Observability routes
44
+ */
45
+ export const observabilityRoutes: RouteObject[] = [
46
+ {
47
+ path: PATHS.STATE_BROKER,
48
+ element: <StateBrokerPage />,
49
+ errorElement: <ErrorBoundary />,
50
+ },
51
+ {
52
+ path: PATHS.DEVKIT,
53
+ element: <DevKitPage />,
54
+ errorElement: <ErrorBoundary />,
55
+ },
56
+ {
57
+ path: PATHS.PROMETHEUS,
58
+ element: <PrometheusMetricsPage />,
59
+ errorElement: <ErrorBoundary />,
60
+ },
61
+ {
62
+ path: PATHS.EVENTS,
63
+ element: <SystemEventsPage />,
64
+ errorElement: <ErrorBoundary />,
65
+ },
66
+ {
67
+ path: PATHS.LOGS,
68
+ element: <LogsPage />,
69
+ errorElement: <ErrorBoundary />,
70
+ },
71
+ {
72
+ path: PATHS.LOG_DETAIL,
73
+ element: <LogDetailPage />,
74
+ errorElement: <ErrorBoundary />,
75
+ },
76
+ {
77
+ path: PATHS.INCIDENTS,
78
+ element: <IncidentsPage />,
79
+ errorElement: <ErrorBoundary />,
80
+ },
81
+ {
82
+ path: PATHS.INCIDENT_DETAIL,
83
+ element: <IncidentDetailPage />,
84
+ errorElement: <ErrorBoundary />,
85
+ },
86
+ ];
87
+
88
+ /**
89
+ * Observability navigation item for sidebar
90
+ */
91
+ export const observabilityNavigation: NavigationItem = {
92
+ key: KEYS.MODULE,
93
+ label: 'Observability',
94
+ icon: renderIcon('EyeOutlined'),
95
+ children: [
96
+ {
97
+ key: KEYS.STATE_BROKER,
98
+ label: 'State Broker',
99
+ path: PATHS.STATE_BROKER,
100
+ icon: renderIcon('ApiOutlined'),
101
+ },
102
+ {
103
+ key: KEYS.DEVKIT,
104
+ label: 'DevKit',
105
+ path: PATHS.DEVKIT,
106
+ icon: renderIcon('ToolOutlined'),
107
+ },
108
+ {
109
+ key: KEYS.PROMETHEUS,
110
+ label: 'Metrics',
111
+ path: PATHS.PROMETHEUS,
112
+ icon: renderIcon('LineChartOutlined'),
113
+ },
114
+ {
115
+ key: KEYS.EVENTS,
116
+ label: 'System Events',
117
+ path: PATHS.EVENTS,
118
+ icon: renderIcon('BellOutlined'),
119
+ },
120
+ {
121
+ key: KEYS.LOGS,
122
+ label: 'Logs',
123
+ path: PATHS.LOGS,
124
+ icon: renderIcon('FileTextOutlined'),
125
+ },
126
+ {
127
+ key: KEYS.INCIDENTS,
128
+ label: 'Incidents',
129
+ path: PATHS.INCIDENTS,
130
+ icon: renderIcon('WarningOutlined'),
131
+ },
132
+ ],
133
+ };