@skyhook-io/radar-app 1.22.2 → 1.23.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 (228) hide show
  1. package/package.json +8 -8
  2. package/src/App.tsx +49 -13
  3. package/src/RadarApp.basename.test.tsx +177 -0
  4. package/src/RadarApp.settings.test.tsx +33 -0
  5. package/src/api/agentSandbox.ts +259 -0
  6. package/src/api/client.autoPromConnect.test.tsx +43 -0
  7. package/src/api/client.metricsRelayCheck.test.tsx +134 -0
  8. package/src/api/client.ts +151 -27
  9. package/src/api/client.updateResource.secretExpiry.test.tsx +47 -0
  10. package/src/api/cloudInstallDiscover.test.tsx +76 -0
  11. package/src/api/diagnose.ts +4 -0
  12. package/src/api/kagent.test.ts +82 -0
  13. package/src/api/kagent.ts +230 -0
  14. package/src/api/poll.ts +78 -0
  15. package/src/api/prometheusCharts.ts +5 -0
  16. package/src/api/radarFeatures.test.ts +9 -0
  17. package/src/api/radarFeatures.ts +16 -0
  18. package/src/api/substrateWorkspace.test.ts +72 -0
  19. package/src/api/substrateWorkspace.ts +1394 -0
  20. package/src/api/vulnerabilities.ts +207 -9
  21. package/src/api/workloadSource.test.tsx +315 -0
  22. package/src/api/workloadSource.ts +128 -12
  23. package/src/components/CloudConnectFlow.tsx +46 -7
  24. package/src/components/CloudFunnelButton.test.tsx +193 -7
  25. package/src/components/CloudFunnelButton.tsx +128 -32
  26. package/src/components/SelfManagedStart.tsx +12 -2
  27. package/src/components/agentsandbox/AgentSandboxKindLists.tsx +41 -0
  28. package/src/components/agentsandbox/AgentSandboxLists.test.tsx +410 -0
  29. package/src/components/agentsandbox/AgentSandboxOverview.test.tsx +333 -0
  30. package/src/components/agentsandbox/AgentSandboxOverview.tsx +555 -0
  31. package/src/components/agentsandbox/AgentSandboxSidebar.test.tsx +97 -0
  32. package/src/components/agentsandbox/AgentSandboxSummary.test.tsx +439 -0
  33. package/src/components/agentsandbox/AgentSandboxSummary.tsx +956 -0
  34. package/src/components/agentsandbox/AgentSandboxTables.tsx +966 -0
  35. package/src/components/agentsandbox/AgentSandboxView.tsx +34 -0
  36. package/src/components/agentsandbox/agentsandbox.fixtures.ts +135 -0
  37. package/src/components/agentsandbox/data.ts +135 -0
  38. package/src/components/agentsandbox/host.test.ts +27 -0
  39. package/src/components/agentsandbox/host.tsx +85 -0
  40. package/src/components/agentsandbox/labels.test.ts +42 -0
  41. package/src/components/agentsandbox/labels.ts +146 -0
  42. package/src/components/agentsandbox/listFilters.ts +85 -0
  43. package/src/components/agentsandbox/lists.ts +52 -0
  44. package/src/components/agentsandbox/routes.ts +23 -0
  45. package/src/components/agentsandbox/shared.tsx +321 -0
  46. package/src/components/agentsandbox/useAgentSandboxSidebarWorkspace.ts +69 -0
  47. package/src/components/agentsandbox/workspace.fixtures.ts +125 -0
  48. package/src/components/agentsandbox/workspace.tsx +258 -0
  49. package/src/components/agentsandbox/workspaceRoute.ts +18 -0
  50. package/src/components/applications/ApplicationsView.openResource.test.tsx +248 -3
  51. package/src/components/applications/ApplicationsView.tsx +156 -3
  52. package/src/components/audit/VulnerabilitiesColumns.test.tsx +487 -0
  53. package/src/components/audit/VulnerabilitiesRisk.test.tsx +318 -0
  54. package/src/components/audit/VulnerabilitiesView.test.tsx +458 -13
  55. package/src/components/audit/VulnerabilitiesView.tsx +639 -199
  56. package/src/components/cloudHints/AgentSetupCloudRow.tsx +28 -0
  57. package/src/components/cloudHints/CloudHintLink.tsx +29 -0
  58. package/src/components/cloudHints/SharedInstallAiLine.tsx +36 -0
  59. package/src/components/cloudHints/cloudHints.test.ts +126 -0
  60. package/src/components/cloudHints/cloudHints.ts +131 -0
  61. package/src/components/cloudHints/cloudHintsGate.test.tsx +70 -0
  62. package/src/components/cloudHints/cloudLinks.test.ts +52 -0
  63. package/src/components/cloudHints/cloudLinks.ts +31 -0
  64. package/src/components/cloudHints/hintStorage.ts +28 -0
  65. package/src/components/cnpg/CNPGView.tsx +4 -7
  66. package/src/components/diagnose/AgentSetupNotice.tsx +5 -0
  67. package/src/components/diagnose/DiagnoseContext.tsx +7 -0
  68. package/src/components/diagnose/DiagnoseSurface.escape.test.tsx +215 -0
  69. package/src/components/diagnose/DiagnoseSurface.tsx +57 -1
  70. package/src/components/gitops/RemoteDestinationCloudHint.tsx +6 -14
  71. package/src/components/helm/HelmDrawerRouting.test.tsx +34 -1
  72. package/src/components/helm/HelmReleaseDrawer.tsx +6 -4
  73. package/src/components/helm/HelmView.tsx +4 -3
  74. package/src/components/helm/ObservedHelmNotice.tsx +39 -17
  75. package/src/components/helm/ObservedHelmRelease.test.tsx +62 -3
  76. package/src/components/helm/ObservedHelmReleaseDrawer.test.tsx +18 -0
  77. package/src/components/helm/ObservedHelmReleaseDrawer.tsx +4 -2
  78. package/src/components/home/HomeAgentBlock.tsx +2 -0
  79. package/src/components/home/HomeView.tsx +3 -3
  80. package/src/components/home/MCPSetupDialog.test.tsx +9 -0
  81. package/src/components/home/MCPSetupDialog.tsx +6 -2
  82. package/src/components/home/McpCloudLine.test.tsx +162 -0
  83. package/src/components/home/McpCloudLine.tsx +95 -0
  84. package/src/components/home/ProblemsPanel.investigate.test.tsx +2 -2
  85. package/src/components/home/mcpToolCatalog.test.ts +10 -0
  86. package/src/components/home/mcpToolCatalog.ts +4 -4
  87. package/src/components/issues/ClusterSchedulingBlockerRow.tsx +35 -0
  88. package/src/components/issues/IssuesPane.render.test.tsx +36 -1
  89. package/src/components/issues/IssuesPane.tsx +181 -23
  90. package/src/components/issues/SinceLastVisitRow.render.test.tsx +302 -0
  91. package/src/components/issues/SinceLastVisitRow.tsx +71 -0
  92. package/src/components/issues/sinceLastVisit.test.ts +266 -0
  93. package/src/components/issues/sinceLastVisit.ts +439 -0
  94. package/src/components/issues/uncheckedSources.test.ts +8 -0
  95. package/src/components/issues/uncheckedSources.ts +3 -0
  96. package/src/components/kagent/KagentAgentRenderer.test.ts +32 -0
  97. package/src/components/kagent/KagentAgentRenderer.tsx +87 -0
  98. package/src/components/kagent/KagentAgentSessions.test.tsx +166 -0
  99. package/src/components/kagent/KagentAgentSessions.tsx +124 -0
  100. package/src/components/kagent/KagentDetailPage.tsx +106 -0
  101. package/src/components/kagent/KagentLists.tsx +412 -0
  102. package/src/components/kagent/KagentOverview.tsx +234 -0
  103. package/src/components/kagent/KagentPages.tsx +690 -0
  104. package/src/components/kagent/KagentRuntimeTabs.test.tsx +219 -0
  105. package/src/components/kagent/KagentRuntimeTabs.tsx +283 -0
  106. package/src/components/kagent/KagentSidebar.test.tsx +112 -0
  107. package/src/components/kagent/KagentView.tsx +109 -0
  108. package/src/components/kagent/KagentWorkspace.test.tsx +876 -0
  109. package/src/components/kagent/host.tsx +144 -0
  110. package/src/components/kagent/routes.ts +31 -0
  111. package/src/components/kagent/shared.tsx +336 -0
  112. package/src/components/kagent/useKagentRuntime.test.tsx +77 -0
  113. package/src/components/kagent/useKagentSidebarWorkspace.ts +67 -0
  114. package/src/components/kagent/workspace.fixtures.ts +108 -0
  115. package/src/components/kagent/workspaceRoute.ts +18 -0
  116. package/src/components/nudges/activeNudges.test.ts +39 -0
  117. package/src/components/nudges/activeNudges.ts +76 -0
  118. package/src/components/poll/OssPoll.tsx +871 -0
  119. package/src/components/poll/mount.test.ts +12 -0
  120. package/src/components/poll/pollCloud.test.ts +23 -0
  121. package/src/components/poll/pollCloud.ts +6 -0
  122. package/src/components/poll/pollDefinition.ts +93 -0
  123. package/src/components/poll/pollFlow.test.ts +140 -0
  124. package/src/components/poll/pollFlow.ts +137 -0
  125. package/src/components/poll/pollSender.test.ts +137 -0
  126. package/src/components/poll/pollSender.ts +76 -0
  127. package/src/components/poll/pollStorage.test.ts +53 -0
  128. package/src/components/poll/pollStorage.ts +77 -0
  129. package/src/components/poll/round.json +350 -0
  130. package/src/components/product-hunt/ProductHuntNotice.tsx +2 -0
  131. package/src/components/resource/MetricsNotConnected.test.tsx +28 -0
  132. package/src/components/resource/MetricsNotConnected.tsx +10 -7
  133. package/src/components/resource/PrometheusCharts.tsx +10 -1
  134. package/src/components/resource/PrometheusChartsGrid.render.test.tsx +9 -0
  135. package/src/components/resource/PrometheusChartsGrid.tsx +3 -3
  136. package/src/components/resource/SubstrateHealthCharts.test.tsx +13 -1
  137. package/src/components/resource/SubstrateHealthCharts.tsx +9 -15
  138. package/src/components/resources/ImageFilesystemModal.test.tsx +21 -1
  139. package/src/components/resources/ImageFilesystemModal.tsx +42 -3
  140. package/src/components/resources/ResourceDetailDrawer.tsx +1 -0
  141. package/src/components/resources/ResourcesView.tsx +24 -11
  142. package/src/components/resources/renderers/PodRenderer.tsx +8 -2
  143. package/src/components/settings/LocalIntegrationStatus.test.tsx +1 -0
  144. package/src/components/settings/LocalIntegrationStatus.tsx +3 -2
  145. package/src/components/settings/SettingsDialog.tsx +84 -16
  146. package/src/components/settings/SubstrateSettings.lifecycle.test.tsx +210 -0
  147. package/src/components/settings/SubstrateSettings.test.tsx +131 -0
  148. package/src/components/settings/SubstrateSettings.tsx +544 -0
  149. package/src/components/settings/settings-state.test.ts +21 -3
  150. package/src/components/settings/settings-state.ts +13 -3
  151. package/src/components/share/ShareLinkButton.test.tsx +360 -0
  152. package/src/components/share/ShareLinkButton.tsx +391 -0
  153. package/src/components/share/openShareInCloud.test.ts +29 -0
  154. package/src/components/share/openShareInCloud.ts +10 -0
  155. package/src/components/share/shareLink.test.ts +129 -0
  156. package/src/components/share/shareLink.ts +175 -0
  157. package/src/components/substrate/SubstrateActorDrawer.tsx +87 -0
  158. package/src/components/substrate/SubstrateActorOverview.tsx +489 -0
  159. package/src/components/substrate/SubstrateActorPage.tsx +384 -0
  160. package/src/components/substrate/SubstrateActors.test.tsx +1094 -0
  161. package/src/components/substrate/SubstrateActors.tsx +612 -0
  162. package/src/components/substrate/SubstrateAttentionList.tsx +441 -0
  163. package/src/components/substrate/SubstrateConnect.tsx +88 -0
  164. package/src/components/substrate/SubstrateOverview.test.tsx +396 -0
  165. package/src/components/substrate/SubstrateOverview.tsx +575 -0
  166. package/src/components/substrate/SubstratePages.test.tsx +478 -0
  167. package/src/components/substrate/SubstratePool.test.tsx +462 -0
  168. package/src/components/substrate/SubstratePoolPage.tsx +95 -0
  169. package/src/components/substrate/SubstratePoolSummary.tsx +485 -0
  170. package/src/components/substrate/SubstrateSidebar.test.tsx +101 -0
  171. package/src/components/substrate/SubstrateStateBar.tsx +63 -0
  172. package/src/components/substrate/SubstrateTemplates.tsx +376 -0
  173. package/src/components/substrate/SubstrateView.tsx +173 -0
  174. package/src/components/substrate/SubstrateWorkerPodContext.tsx +73 -0
  175. package/src/components/substrate/SubstrateWorkers.tsx +389 -0
  176. package/src/components/substrate/attention.ts +81 -0
  177. package/src/components/substrate/contextPin.tsx +69 -0
  178. package/src/components/substrate/host.tsx +83 -0
  179. package/src/components/substrate/kubectlTarget.test.tsx +77 -0
  180. package/src/components/substrate/readings.test.ts +484 -0
  181. package/src/components/substrate/readings.ts +997 -0
  182. package/src/components/substrate/routes.ts +103 -0
  183. package/src/components/substrate/shared.tsx +426 -0
  184. package/src/components/substrate/substrate.fixtures.ts +325 -0
  185. package/src/components/substrate/useSubstrateSidebarWorkspace.ts +87 -0
  186. package/src/components/substrate/workspaceRoute.ts +23 -0
  187. package/src/components/traffic/TrafficConnectionsTable.test.tsx +9 -0
  188. package/src/components/traffic/TrafficConnectionsTable.tsx +4 -2
  189. package/src/components/traffic/TrafficFilterSidebar.tsx +19 -14
  190. package/src/components/traffic/TrafficFlowList.test.tsx +63 -0
  191. package/src/components/traffic/TrafficFlowList.tsx +9 -5
  192. package/src/components/traffic/TrafficGraph.test.tsx +26 -0
  193. package/src/components/traffic/TrafficGraph.tsx +17 -14
  194. package/src/components/traffic/TrafficGraphTooLarge.tsx +2 -0
  195. package/src/components/traffic/TrafficGraphUnavailable.tsx +3 -1
  196. package/src/components/traffic/TrafficView.tsx +26 -56
  197. package/src/components/traffic/trafficFilters.test.ts +61 -1
  198. package/src/components/traffic/trafficFilters.ts +68 -8
  199. package/src/components/ui/UpdateNotification.tsx +2 -0
  200. package/src/components/usage-data/UsageDataPrompt.tsx +2 -0
  201. package/src/components/velero/VeleroOverview.tsx +2 -2
  202. package/src/components/velero/VeleroView.tsx +3 -6
  203. package/src/components/vulnerabilities/columns.tsx +132 -0
  204. package/src/components/vulnerabilities/filters.tsx +317 -0
  205. package/src/components/vulnerabilities/owner.test.ts +54 -0
  206. package/src/components/vulnerabilities/owner.tsx +163 -0
  207. package/src/components/vulnerabilities/parts.test.ts +126 -12
  208. package/src/components/vulnerabilities/parts.tsx +612 -52
  209. package/src/components/vulnerabilities/traffic.test.tsx +65 -0
  210. package/src/components/vulnerabilities/traffic.tsx +40 -0
  211. package/src/components/whats-new/WhatsNew.tsx +2 -0
  212. package/src/components/whats-new/releaseNotes.ts +75 -1
  213. package/src/components/workload/WorkloadView.substrateVersion.test.tsx +88 -0
  214. package/src/components/workload/WorkloadView.tsx +52 -13
  215. package/src/components/workspace/layout.tsx +13 -7
  216. package/src/components/workspace/sidebar.test.ts +48 -0
  217. package/src/components/workspace/sidebar.ts +73 -3
  218. package/src/components/workspace/table.ts +2 -1
  219. package/src/contexts/RegistryAccessMode.test.tsx +51 -0
  220. package/src/contexts/RegistryAccessMode.tsx +25 -0
  221. package/src/integrations/resourceHost.ts +12 -6
  222. package/src/integrations/resourceHosts.test.tsx +27 -1
  223. package/src/integrations/resourceHosts.tsx +15 -7
  224. package/src/integrations/sidebarWorkspaces.test.tsx +63 -0
  225. package/src/integrations/sidebarWorkspaces.ts +41 -0
  226. package/src/integrations/workspaceRoute.ts +1 -1
  227. package/src/integrations/workspaceRoutes.ts +7 -1
  228. package/src/integrations/workspaceScreens.tsx +6 -0
@@ -0,0 +1,441 @@
1
+ import { useState, type ReactNode } from 'react'
2
+ import { clsx } from 'clsx'
3
+ import { Collapse, CollapseChevron, RowDetails, StatusDot, Tooltip, toneTextClass } from '@skyhook-io/k8s-ui'
4
+ import type { SubstrateAttention, SubstrateSubject } from '../../api/substrateWorkspace'
5
+ import { SUBJECT_KIND_LABEL, attentionTone, splitReading, subjectLabel } from './readings'
6
+ import { CommandChip, Tokens, When } from './shared'
7
+
8
+ /** Opens what a row or link is about: a filtered actor list, an actor, a template, or a Kubernetes object. */
9
+ export type OpenSubject = (subject: SubstrateSubject) => void
10
+
11
+ // Rows shown before folding: every critical row, and at least this many. The
12
+ // list keeps the server's ranking (severity first), so the fold never hides
13
+ // something more urgent than what shows.
14
+ const ATTENTION_BUDGET = 3
15
+
16
+ const WORKER_RULES = new Set<SubstrateAttention['rule']>(['workerUnavailable', 'workerDraining', 'workerRestarting'])
17
+
18
+ /** A worker row's actors, as the server linked them: shown under the worker, not as rows of their own. */
19
+ function AffectedActors({ row, onOpen }: { row: SubstrateAttention; onOpen?: OpenSubject }) {
20
+ const sample = row.sample ?? []
21
+ if (!WORKER_RULES.has(row.rule) || sample.length === 0) return null
22
+ const shown = sample.slice(0, 4)
23
+ const more = row.count - shown.length
24
+ return (
25
+ <div className="mt-0.5 break-words text-xs text-theme-text-secondary">
26
+ Actors on it:{' '}
27
+ {shown.map((a, i) => (
28
+ <span key={`${a.atespace}/${a.name}`}>
29
+ {i > 0 && ', '}
30
+ {onOpen ? (
31
+ <button type="button" onClick={() => onOpen({ kind: 'Actor', atespace: a.atespace, name: a.name })} className="font-mono text-accent-text hover:underline">{a.name}</button>
32
+ ) : (
33
+ <span className="font-mono">{a.name}</span>
34
+ )}
35
+ </span>
36
+ ))}
37
+ {more > 0 && (
38
+ onOpen && row.subject.kind === 'Worker' && row.subject.name ? (
39
+ <> and <button type="button" onClick={() => onOpen({ kind: 'Actors', filter: { worker: row.subject.name! } })} className="text-accent-text hover:underline">view all assignments →</button></>
40
+ ) : (
41
+ <> and {more} more</>
42
+ )
43
+ )}
44
+ </div>
45
+ )
46
+ }
47
+
48
+ const NAMESPACED = new Set<SubstrateSubject['kind']>(['WorkerPool', 'Pod', 'Worker', 'Agent'])
49
+
50
+ /**
51
+ * A link to what a row names. `short` drops the namespace from a pool, worker
52
+ * or Pod (it shows on hover): in a list, every one of them repeating it is noise.
53
+ */
54
+ export function SubjectLink({ subject, onOpen, count, withKind = true, label: shown, short }: { subject: SubstrateSubject; onOpen?: OpenSubject; count?: number; withKind?: boolean; label?: string; short?: boolean }) {
55
+ const abbreviated = short && NAMESPACED.has(subject.kind) && subject.name
56
+ const label = shown ?? (abbreviated ? subject.name! : subjectLabel(subject, count))
57
+ const kind = withKind && subject.kind !== 'Actors' ? `${SUBJECT_KIND_LABEL[subject.kind]} ` : ''
58
+ const body = !onOpen ? (
59
+ <span className="font-mono">{label}</span>
60
+ ) : (
61
+ <button type="button" onClick={() => onOpen(subject)} className={clsx('text-left text-accent-text hover:underline', subject.kind !== 'Actors' && 'font-mono break-normal')}>
62
+ {subject.kind === 'Actors' ? label : <Tokens text={label} />}
63
+ {subject.kind === 'Actors' && ' →'}
64
+ </button>
65
+ )
66
+ return (
67
+ <span>
68
+ {kind}
69
+ {abbreviated ? <Tooltip content={subjectLabel(subject)}><span>{body}</span></Tooltip> : body}
70
+ </span>
71
+ )
72
+ }
73
+
74
+ const NODE_STATE: Record<string, string | undefined> = {
75
+ ready: 'Ready',
76
+ notReady: 'not Ready',
77
+ gone: 'gone from the cluster',
78
+ }
79
+
80
+ function TallyList({ title, items }: { title: string; items: { key: string; label: ReactNode; count: number }[] }) {
81
+ return (
82
+ <div className="min-w-0">
83
+ <div className="text-theme-text-tertiary">{title}</div>
84
+ <ul className="mt-0.5 space-y-0.5">
85
+ {items.map((it) => (
86
+ <li key={it.key} className="grid grid-cols-[minmax(0,1fr)_auto] items-baseline gap-3">
87
+ <span className="min-w-0 break-words">{it.label}</span>
88
+ <span className="whitespace-nowrap text-theme-text-tertiary">{it.count === 1 ? '1 actor' : `${it.count} actors`}</span>
89
+ </li>
90
+ ))}
91
+ </ul>
92
+ </div>
93
+ )
94
+ }
95
+
96
+ /** The Actors list narrowed to one group of a row: its template, or the worker the actors wait on. */
97
+ function groupFilter(row: SubstrateAttention, g: NonNullable<SubstrateAttention['groups']>[number]): Record<string, string> | undefined {
98
+ if (g.subject?.kind === 'ActorTemplate') return { ...row.subject.filter, template: `${g.subject.atespace}/${g.subject.name}` }
99
+ if (g.subject?.kind === 'Worker' && g.subject.name) return { ...row.subject.filter, worker: g.subject.name }
100
+ return undefined
101
+ }
102
+
103
+ /** A row's breakdowns as short lists: actors per template or per worker, Substrate's most common messages, the nodes holding them. */
104
+ function Tallies({ row, onOpen }: { row: SubstrateAttention; onOpen?: OpenSubject }) {
105
+ const groups = (row.groups ?? []).map((g, i) => {
106
+ const filter = groupFilter(row, g)
107
+ return {
108
+ key: g.subject ? `${g.subject.kind}/${g.subject.atespace ?? g.subject.namespace ?? ''}/${g.subject.name}` : g.text ?? String(i),
109
+ count: g.count,
110
+ label:
111
+ filter && onOpen ? (
112
+ <button type="button" onClick={() => onOpen({ kind: 'Actors', filter })} className="text-left font-mono text-accent-text hover:underline">
113
+ {g.subject?.kind === 'Worker' ? g.subject.name : subjectLabel(g.subject!)} · View matching actors
114
+ </button>
115
+ ) : (
116
+ <span className="font-mono">{g.subject ? subjectLabel(g.subject) : g.text}</span>
117
+ ),
118
+ }
119
+ })
120
+ const groupTitle = row.groups?.[0]?.subject?.kind === 'Worker' ? 'By worker' : 'By template'
121
+ const messages = (row.messages ?? []).map((m, i) => ({ key: m.text ?? String(i), count: m.count, label: m.text }))
122
+ const nodes = (row.nodes ?? []).map((n) => ({
123
+ key: n.node || '(unnamed)',
124
+ count: n.count,
125
+ label: (
126
+ <span>
127
+ {n.node ? (
128
+ onOpen ? (
129
+ <Tooltip content="The actors whose newest snapshot is stored only on this node">
130
+ <button type="button" onClick={() => onOpen({ kind: 'Actors', filter: { node: n.node, nodeHas: 'localSnapshot' } })} className="font-mono text-accent-text hover:underline">{n.node}</button>
131
+ </Tooltip>
132
+ ) : (
133
+ <span className="font-mono">{n.node}</span>
134
+ )
135
+ ) : (
136
+ 'a node Substrate does not name'
137
+ )}
138
+ {NODE_STATE[n.state] && <span className={clsx('ml-1.5', n.state === 'ready' ? 'text-theme-text-tertiary' : toneTextClass('unhealthy'))}>{NODE_STATE[n.state]}</span>}
139
+ {n.oldest && <span className="ml-1.5 text-theme-text-tertiary"><When iso={n.oldest} prefix="waiting for at least" held /></span>}
140
+ </span>
141
+ ),
142
+ }))
143
+ // A crash row split by remedy names its templates beside each step already.
144
+ const byGroup = groups.length > 1 && !splitsByRemedy(row)
145
+ if (!byGroup && messages.length <= 1 && nodes.length === 0) return null
146
+ return (
147
+ <div className="grid gap-x-8 gap-y-2 text-xs text-theme-text-secondary lg:grid-cols-2">
148
+ {byGroup && <TallyList title={groupTitle} items={groups} />}
149
+ {messages.length > 1 && <TallyList title="Substrate’s messages" items={messages} />}
150
+ {nodes.length > 0 && <TallyList title="Nodes holding them" items={nodes} />}
151
+ </div>
152
+ )
153
+ }
154
+
155
+ type Tally = NonNullable<SubstrateAttention['groups']>[number]
156
+
157
+ /** A row's groups that carry a remedy of their own, one entry per distinct remedy. */
158
+ function groupRemedies(row: SubstrateAttention): { nextStep: string; command?: string; thenCommand?: string; cause?: Tally['cause']; groups: Tally[] }[] {
159
+ const byStep = new Map<string, { nextStep: string; command?: string; thenCommand?: string; cause?: Tally['cause']; groups: Tally[] }>()
160
+ for (const g of row.groups ?? []) {
161
+ if (!g.nextStep) continue
162
+ const key = `${g.nextStep}\u0000${g.command ?? ''}\u0000${g.thenCommand ?? ''}`
163
+ const entry = byStep.get(key) ?? { nextStep: g.nextStep, command: g.command, thenCommand: g.thenCommand, cause: g.cause, groups: [] }
164
+ entry.groups.push(g)
165
+ byStep.set(key, entry)
166
+ }
167
+ return [...byStep.values()]
168
+ }
169
+
170
+ /** A crash group's actors, as a filtered list: the template's name links to its crashed actors. */
171
+ function GroupName({ row, group, onOpen }: { row: SubstrateAttention; group: Tally; onOpen?: OpenSubject }) {
172
+ const filter = groupFilter(row, group)
173
+ const label = group.subject ? subjectLabel(group.subject) : group.text
174
+ return filter && onOpen ? (
175
+ <button type="button" onClick={() => onOpen({ kind: 'Actors', filter })} className="font-mono text-accent-text hover:underline">{label}</button>
176
+ ) : (
177
+ <span className="font-mono">{label}</span>
178
+ )
179
+ }
180
+
181
+ function GroupNames({ row, groups, onOpen }: { row: SubstrateAttention; groups: Tally[]; onOpen?: OpenSubject }) {
182
+ return (
183
+ <>
184
+ {groups.map((g, i) => (
185
+ <span key={i}>
186
+ {i > 0 && (i === groups.length - 1 ? ' and ' : ', ')}
187
+ <GroupName row={row} group={g} onOpen={onOpen} /> ({g.count})
188
+ </span>
189
+ ))}
190
+ </>
191
+ )
192
+ }
193
+
194
+ /**
195
+ * Where most of a crash row's actors are: "11 of the 15 use template X". It
196
+ * states a concentration, not a cause; the remedies below say what is known
197
+ * of causes.
198
+ */
199
+ function Concentration({ row, onOpen }: { row: SubstrateAttention; onOpen?: OpenSubject }) {
200
+ const groups = row.groups ?? []
201
+ const top = groups[0]
202
+ if (row.rule !== 'crashedActors' || groups.length < 2 || !top?.subject || top.subject.kind !== 'ActorTemplate' || top.count * 2 <= row.count) return null
203
+ return (
204
+ <div className="break-words text-xs font-medium text-theme-text-primary">
205
+ {top.count} of the {row.count} use template <GroupName row={row} group={top} onOpen={onOpen} />
206
+ </div>
207
+ )
208
+ }
209
+
210
+ /** A crash row's groups by remedy: those whose cause names one, and the rest, which share the row's general step. */
211
+ function crashRemedies(row: SubstrateAttention) {
212
+ const remedies = groupRemedies(row)
213
+ const rest = (row.groups ?? []).filter((g) => !g.nextStep)
214
+ return { remedies, rest, restCount: rest.reduce((n, g) => n + g.count, 0) }
215
+ }
216
+
217
+ /** Whether a row splits its crashes by remedy: one remedy of a known cause shows, the others wait under Details. */
218
+ function splitsByRemedy(row: SubstrateAttention): boolean {
219
+ const { remedies, rest } = crashRemedies(row)
220
+ return remedies.length > 1 || (remedies.length === 1 && rest.length > 0)
221
+ }
222
+
223
+ /** A next step and its commands, each on its own line, in the order they run. */
224
+ function StepLine({ lead, step, command, thenCommand }: { lead: ReactNode; step: string; command?: string; thenCommand?: string }) {
225
+ return (
226
+ <div className="mt-1 break-words text-xs text-theme-text-primary">
227
+ <span className="font-medium">{lead}</span>
228
+ {step}
229
+ {command && <CommandChip command={command} />}
230
+ {command && thenCommand && <CommandChip command={thenCommand} />}
231
+ </div>
232
+ )
233
+ }
234
+
235
+ const CAUSE_WORDS: Record<NonNullable<Tally['cause']>, string> = { memoryLimit: 'killed over their memory limit' }
236
+
237
+ // A remedy names its templates on the visible line up to this many; more wait under Details.
238
+ const NAMED_REMEDY_GROUPS = 2
239
+
240
+ /** Which actors a remedy is for, by template: "on research / lg", "11 on research / lg and 1 on sandbox-dev / mcp", or "on 3 templates". */
241
+ function RemedyGroups({ row, groups, onOpen }: { row: SubstrateAttention; groups: Tally[]; onOpen?: OpenSubject }) {
242
+ if (groups.length > NAMED_REMEDY_GROUPS) return <>on {groups.length} templates</>
243
+ if (groups.length === 1) return <>on <GroupName row={row} group={groups[0]} onOpen={onOpen} /></>
244
+ return (
245
+ <>
246
+ {groups.map((g, i) => (
247
+ <span key={i}>
248
+ {i > 0 && ' and '}
249
+ {g.count} on <GroupName row={row} group={g} onOpen={onOpen} />
250
+ </span>
251
+ ))}
252
+ </>
253
+ )
254
+ }
255
+
256
+ /**
257
+ * A row's one visible next step. A crash row whose groups name a cause shows
258
+ * that cause's remedy, with its command, and one line for the rest, whose
259
+ * general step waits under Details: no one command is offered as though every
260
+ * crash shared a remedy.
261
+ */
262
+ function NextStep({ row, onOpen, onShowDetails }: { row: SubstrateAttention; onOpen?: OpenSubject; onShowDetails: () => void }) {
263
+ if (!splitsByRemedy(row)) return <StepLine lead="Next step: " step={row.nextStep} command={row.command} thenCommand={row.thenCommand} />
264
+ const { remedies, rest } = crashRemedies(row)
265
+ const first = remedies[0]
266
+ const firstCount = first.groups.reduce((n, g) => n + g.count, 0)
267
+ const others = row.count - firstCount
268
+ const one = rest.length === 1 && remedies.length === 1 ? groupFilter(row, rest[0]) : undefined
269
+ // A template lands in the rest when any of its crashes is not of the named
270
+ // cause, so its others may be of it: they "include" other causes. A template
271
+ // with one crash in the rest is that crash, so where every one has one, each
272
+ // crashed for another reason.
273
+ const otherCause = remedies.length === 1 && first.cause === 'memoryLimit'
274
+ const otherWords = others === 1 ? 'The other one' : `The other ${others}`
275
+ const otherLead = !otherCause
276
+ ? `${otherWords} crashed`
277
+ : rest.every((g) => g.count === 1)
278
+ ? `${otherWords} crashed for another reason`
279
+ : `${otherWords} include crashes for other reasons`
280
+ // The step names which actors it is for, by template, so the concentration above and this count reconcile on sight.
281
+ const lead = (
282
+ <>
283
+ Next step for {firstCount}{first.cause ? ` ${CAUSE_WORDS[first.cause]}` : ''}, <RemedyGroups row={row} groups={first.groups} onOpen={onOpen} />:{' '}
284
+ </>
285
+ )
286
+ return (
287
+ <>
288
+ <StepLine lead={lead} step={first.nextStep} command={first.command} thenCommand={first.thenCommand} />
289
+ {others > 0 && (
290
+ <div className="mt-0.5 break-words text-xs text-theme-text-secondary">
291
+ {otherLead}:{' '}
292
+ {one && onOpen ? (
293
+ <button type="button" onClick={() => onOpen({ kind: 'Actors', filter: one })} className="text-accent-text hover:underline">view crashes on this template →</button>
294
+ ) : (
295
+ <button type="button" onClick={onShowDetails} className="text-accent-text hover:underline">see Details</button>
296
+ )}
297
+ </div>
298
+ )}
299
+ </>
300
+ )
301
+ }
302
+
303
+ /** What a split crash row leaves for Details: each other remedy, and the general step for the rest, naming their templates. */
304
+ function OtherSteps({ row, onOpen }: { row: SubstrateAttention; onOpen?: OpenSubject }) {
305
+ if (!splitsByRemedy(row)) return null
306
+ const { remedies, rest, restCount } = crashRemedies(row)
307
+ return (
308
+ <>
309
+ {remedies[0].groups.length > NAMED_REMEDY_GROUPS && (
310
+ <div className="break-words text-xs text-theme-text-secondary">
311
+ {remedies[0].cause ? `${CAUSE_WORDS[remedies[0].cause][0].toUpperCase()}${CAUSE_WORDS[remedies[0].cause].slice(1)}` : 'With that step'}: <GroupNames row={row} groups={remedies[0].groups} onOpen={onOpen} />
312
+ </div>
313
+ )}
314
+ {remedies.slice(1).map((r) => (
315
+ <StepLine
316
+ key={r.nextStep}
317
+ lead={<>Next step for <GroupNames row={row} groups={r.groups} onOpen={onOpen} />{r.cause ? `, ${CAUSE_WORDS[r.cause]}` : ''}: </>}
318
+ step={r.nextStep}
319
+ command={r.command}
320
+ thenCommand={r.thenCommand}
321
+ />
322
+ ))}
323
+ {rest.length > 0 && (
324
+ <StepLine lead={<>For the other {restCount === 1 ? 'one' : restCount}, on <GroupNames row={row} groups={rest} onOpen={onOpen} />: </>} step={row.nextStep} />
325
+ )}
326
+ </>
327
+ )
328
+ }
329
+
330
+ /** A worker row's link to the actors on that worker, beside its subject: the row is about them. */
331
+ function WorkerActorsLink({ row, onOpen }: { row: SubstrateAttention; onOpen?: OpenSubject }) {
332
+ if (!WORKER_RULES.has(row.rule) || row.subject.kind !== 'Worker' || !row.subject.name || row.count <= 0) return null
333
+ const label = 'View all actors assigned to this worker'
334
+ return onOpen ? (
335
+ <button type="button" onClick={() => onOpen({ kind: 'Actors', filter: { worker: row.subject.name! } })} className="whitespace-nowrap text-accent-text hover:underline">{label} →</button>
336
+ ) : (
337
+ <span>{label}</span>
338
+ )
339
+ }
340
+
341
+ /**
342
+ * One row, in the anatomy Velero's and Agent Sandbox's Needs attention rows
343
+ * share, kept to what an operator decides on: the title in its severity's
344
+ * tone; one line with what it is about, its age and the way to the affected
345
+ * objects; the cause in a sentence; one next step with its commands.
346
+ * Everything else folds under Details: the rest of the reading (mechanics,
347
+ * epochs, "Latest: …", Substrate's raw messages), secondary remedies, related
348
+ * objects and the breakdowns. A crash row's visible cause is where its
349
+ * crashes concentrate; its "Latest: …" reading is provenance.
350
+ */
351
+ export function AttentionRow({ row, onOpen }: { row: SubstrateAttention; onOpen?: OpenSubject }) {
352
+ const [open, setOpen] = useState(false)
353
+ const related = (row.related ?? [])
354
+ // A Worker subject already links to its Pod.
355
+ .filter((r) => !(row.subject.kind === 'Worker' && r.kind === 'Pod' && r.name === row.subject.name))
356
+ const crash = row.rule === 'crashedActors'
357
+ const [first, others] = splitReading(row.reading)
358
+ const lead = crash ? <Concentration row={row} onOpen={onOpen} /> : first
359
+ const rest = crash ? row.reading || undefined : others
360
+ const hasDetails = related.length > 0 || splitsByRemedy(row) || (row.groups?.length ?? 0) > 1 || (row.messages?.length ?? 0) > 1 || (row.nodes?.length ?? 0) > 0 || (row.sample?.length ?? 0) > 0 || !!rest || !!row.nextStep || !!row.command
361
+ return (
362
+ <li className="min-w-0 py-1.5 text-sm first:pt-0.5" data-rule={row.rule} data-severity={row.severity}>
363
+ <div className="flex flex-wrap items-baseline justify-between gap-x-4 gap-y-0.5">
364
+ <div className={clsx('flex items-center gap-2 font-medium break-words', toneTextClass(attentionTone(row)))}>
365
+ <StatusDot tone={attentionTone(row)} />
366
+ {row.title}
367
+ </div>
368
+ <div className="text-xs">
369
+ <SubjectLink
370
+ subject={row.subject}
371
+ onOpen={onOpen}
372
+ label={crash ? 'View all crashed actors' : row.rule === 'uploadOverdue' ? 'View all suspended actors'
373
+ : row.rule === 'stuckTransition' ? `View all ${row.subject.filter?.state ?? 'transitioning'} actors`
374
+ : row.rule === 'workerRestarting' && row.subject.kind === 'Actors' ? `View ${row.count} affected ${row.count === 1 ? 'actor' : 'actors'}` : undefined}
375
+ short
376
+ />
377
+ </div>
378
+ </div>
379
+ {lead && <div className="mt-0.5 break-words text-xs text-theme-text-secondary">{lead}</div>}
380
+ {hasDetails && (
381
+ <RowDetails open={open} onToggle={() => setOpen((v) => !v)}>
382
+ {rest && <div className="break-words text-xs text-theme-text-secondary">{rest}</div>}
383
+ {row.since && <div className="text-xs text-theme-text-tertiary"><When iso={row.since} prefix="for at least" held hint="Newest change among them: the condition has held at least since" /></div>}
384
+ <WorkerActorsLink row={row} onOpen={onOpen} />
385
+ <NextStep row={row} onOpen={onOpen} onShowDetails={() => setOpen(true)} />
386
+ <OtherSteps row={row} onOpen={onOpen} />
387
+ {related.length > 0 && (
388
+ <div className="flex flex-wrap gap-x-3 gap-y-1 text-xs text-theme-text-tertiary">
389
+ {related.map((r) => <SubjectLink key={`${r.kind}/${r.namespace}/${r.name}`} subject={r} onOpen={onOpen} short />)}
390
+ </div>
391
+ )}
392
+ <AffectedActors row={row} onOpen={onOpen} />
393
+ <Tallies row={row} onOpen={onOpen} />
394
+ </RowDetails>
395
+ )}
396
+ </li>
397
+ )
398
+ }
399
+
400
+ /**
401
+ * Needs attention as one list in the server's order (severity first, then
402
+ * the rules that cost most), each row labelled with what it is about. The
403
+ * first rows show; the rest fold.
404
+ */
405
+ export function SubstrateAttentionList({ rows, onOpen }: { rows: SubstrateAttention[]; onOpen?: OpenSubject }) {
406
+ const [showAll, setShowAll] = useState(false)
407
+ const visible = Math.max(ATTENTION_BUDGET, rows.filter((r) => r.severity === 'critical').length)
408
+ const shown = rows.slice(0, visible)
409
+ const folded = rows.slice(visible)
410
+ const foldId = 'substrate-attention-more'
411
+ const hiddenSeverities = (['critical', 'alert', 'warning', 'info'] as const).flatMap((severity) => {
412
+ const count = folded.filter((row) => row.severity === severity).length
413
+ return count > 0 ? [`${count} ${severity}`] : []
414
+ }).join(', ')
415
+ return (
416
+ <div>
417
+ <ul className="divide-y divide-theme-border-subtle">
418
+ {shown.map((r) => <AttentionRow key={r.id} row={r} onOpen={onOpen} />)}
419
+ </ul>
420
+ {folded.length > 0 && (
421
+ <>
422
+ <Collapse open={showAll} id={foldId}>
423
+ <ul className="divide-y divide-theme-border-subtle border-t-subtle">
424
+ {folded.map((r) => <AttentionRow key={r.id} row={r} onOpen={onOpen} />)}
425
+ </ul>
426
+ </Collapse>
427
+ <button
428
+ type="button"
429
+ aria-expanded={showAll}
430
+ aria-controls={foldId}
431
+ onClick={() => setShowAll((v) => !v)}
432
+ className="mt-2 inline-flex items-center gap-1 text-xs font-medium text-accent-text hover:underline"
433
+ >
434
+ <CollapseChevron open={showAll} />
435
+ {showAll ? 'Show fewer' : `Show ${folded.length} more (${hiddenSeverities})`}
436
+ </button>
437
+ </>
438
+ )}
439
+ </div>
440
+ )
441
+ }
@@ -0,0 +1,88 @@
1
+ import { AlertBanner } from '@skyhook-io/k8s-ui'
2
+ import type { SubstrateAPITier, SubstrateStatus } from '../../api/substrateWorkspace'
3
+ import { tierReading } from './readings'
4
+ import { CommandChip } from './shared'
5
+
6
+ /**
7
+ * Why actor values are missing, in a banner: not connected, or connected and
8
+ * failing, each with what to do next. Nothing for a connected tier.
9
+ */
10
+ export function SubstrateTierBanner({ tier }: { tier: SubstrateAPITier }) {
11
+ if (!showsTierBanner(tier)) return null
12
+ const r = tierReading(tier)
13
+ return (
14
+ <div role="status">
15
+ <AlertBanner variant={r.tone === 'unhealthy' ? 'error' : 'unknown'} title={`Substrate API: ${r.title.toLowerCase()}`} message={r.detail} className="">
16
+ {r.nextStep && (
17
+ <div className="mt-1 break-words text-xs text-theme-text-primary">
18
+ <span className="font-medium">Next step: </span>
19
+ {r.nextStep}
20
+ {r.command && <CommandChip command={r.command} />}
21
+ </div>
22
+ )}
23
+ </AlertBanner>
24
+ </div>
25
+ )
26
+ }
27
+
28
+ /** A failure the banner states; the rest (not set, turned off, no sign-in) the connect notice states. */
29
+ function showsTierBanner(tier: SubstrateAPITier): boolean {
30
+ if (tier.state === 'connected' || tier.state === 'notConfigured' || tier.state === 'connecting') return false
31
+ return tier.code !== 'sharedRadar' && tier.code !== 'apiDisabled' && tier.code !== 'targetChanged'
32
+ }
33
+
34
+ /** Opens Settings at Agent Substrate; in Radar Hub, a Settings view with only that section. */
35
+ export function openSubstrateSettings() {
36
+ window.dispatchEvent(new CustomEvent('radar:open-settings', { detail: { section: 'substrate' } }))
37
+ }
38
+
39
+ const SETTINGS_LINK = 'text-xs font-medium text-accent-text hover:underline'
40
+
41
+ /** The source line's way to the connection: "Change connection" where it can be edited here, else "Connection settings". */
42
+ export function SubstrateConnectionLink({ status }: { status?: SubstrateStatus }) {
43
+ return (
44
+ <button type="button" onClick={openSubstrateSettings} className={SETTINGS_LINK}>
45
+ {status?.canConfigure ? 'Change connection' : 'Connection settings'}
46
+ </button>
47
+ )
48
+ }
49
+
50
+ /**
51
+ * Where actors, templates and workers would be when Radar doesn't read
52
+ * Substrate's API: why, and the way to Settings → Agent Substrate. A local
53
+ * Radar sets the connection there; elsewhere it shows how this Radar reads
54
+ * Substrate and the person's own access.
55
+ */
56
+ export function SubstrateConnectNotice({ status, tier }: { status?: SubstrateStatus; tier: SubstrateAPITier }) {
57
+ const local = !!status?.canConfigure
58
+ const unset = tier.state === 'notConfigured' || tier.code === 'targetChanged'
59
+ const r = tierReading(tier)
60
+ // A failure is already in the banner above; here only the way to the settings.
61
+ const reading = !showsTierBanner(tier)
62
+ return (
63
+ <section aria-labelledby="substrate-connect" className="rounded-xl border border-theme-border bg-theme-surface px-4 py-4 shadow-theme-sm">
64
+ <h2 id="substrate-connect" className="text-sm font-semibold text-theme-text-primary">
65
+ {local && unset ? 'Connect to Substrate’s API' : reading ? r.title : 'Actors, templates and workers aren’t read'}
66
+ </h2>
67
+ <p className="mt-1 text-sm text-theme-text-secondary">
68
+ Substrate keeps actors, templates and workers in its own API, not Kubernetes. Pools, worker Pods and Prometheus readings show below either way.
69
+ </p>
70
+ {reading && !(local && unset) && r.detail && <p className="mt-2 text-sm text-theme-text-secondary">{r.detail}</p>}
71
+ {reading && r.nextStep && !(local && tier.state === 'notConfigured') && (
72
+ <p className="mt-2 text-sm text-theme-text-primary">
73
+ <span className="font-medium">Next step: </span>
74
+ {r.nextStep}
75
+ {r.command && <CommandChip command={r.command} />}
76
+ </p>
77
+ )}
78
+ <button type="button" onClick={openSubstrateSettings} className={local ? 'btn-brand mt-3 px-3 py-1.5 text-sm font-medium' : `mt-3 ${SETTINGS_LINK}`}>
79
+ {local ? 'Open Substrate settings' : 'Connection settings'}
80
+ </button>
81
+ </section>
82
+ )
83
+ }
84
+
85
+ /** Whether a screen shows the connect notice in place of Substrate's values: whenever the API tier isn't connected. */
86
+ export function showsConnectNotice(tier: SubstrateAPITier): boolean {
87
+ return tier.state !== 'connected' && tier.state !== 'connecting'
88
+ }