@skyhook-io/radar-app 1.22.1 → 1.23.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 (234) hide show
  1. package/package.json +8 -8
  2. package/src/App.tsx +131 -38
  3. package/src/RadarApp.basename.test.tsx +177 -0
  4. package/src/RadarApp.settings.test.tsx +33 -0
  5. package/src/RadarApp.tsx +5 -0
  6. package/src/api/agentSandbox.ts +259 -0
  7. package/src/api/client.autoPromConnect.test.tsx +43 -0
  8. package/src/api/client.metricsRelayCheck.test.tsx +134 -0
  9. package/src/api/client.ts +128 -25
  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/prometheusCharts.ts +5 -0
  15. package/src/api/radarFeatures.test.ts +9 -0
  16. package/src/api/radarFeatures.ts +13 -0
  17. package/src/api/substrateWorkspace.test.ts +72 -0
  18. package/src/api/substrateWorkspace.ts +1394 -0
  19. package/src/api/vulnerabilities.ts +207 -9
  20. package/src/api/workloadSource.test.tsx +1172 -0
  21. package/src/api/workloadSource.ts +408 -0
  22. package/src/components/APIUnreachableBanner.test.tsx +19 -0
  23. package/src/components/APIUnreachableBanner.tsx +20 -0
  24. package/src/components/CloudConnectFlow.tsx +46 -7
  25. package/src/components/CloudFunnelButton.test.tsx +193 -7
  26. package/src/components/CloudFunnelButton.tsx +127 -32
  27. package/src/components/ConnectionErrorView.test.tsx +63 -2
  28. package/src/components/ConnectionErrorView.tsx +88 -68
  29. package/src/components/SelfManagedStart.tsx +12 -2
  30. package/src/components/agentsandbox/AgentSandboxKindLists.tsx +41 -0
  31. package/src/components/agentsandbox/AgentSandboxLists.test.tsx +410 -0
  32. package/src/components/agentsandbox/AgentSandboxOverview.test.tsx +333 -0
  33. package/src/components/agentsandbox/AgentSandboxOverview.tsx +555 -0
  34. package/src/components/agentsandbox/AgentSandboxSidebar.test.tsx +97 -0
  35. package/src/components/agentsandbox/AgentSandboxSummary.test.tsx +439 -0
  36. package/src/components/agentsandbox/AgentSandboxSummary.tsx +956 -0
  37. package/src/components/agentsandbox/AgentSandboxTables.tsx +966 -0
  38. package/src/components/agentsandbox/AgentSandboxView.tsx +34 -0
  39. package/src/components/agentsandbox/agentsandbox.fixtures.ts +135 -0
  40. package/src/components/agentsandbox/data.ts +135 -0
  41. package/src/components/agentsandbox/host.test.ts +27 -0
  42. package/src/components/agentsandbox/host.tsx +85 -0
  43. package/src/components/agentsandbox/labels.test.ts +42 -0
  44. package/src/components/agentsandbox/labels.ts +146 -0
  45. package/src/components/agentsandbox/listFilters.ts +85 -0
  46. package/src/components/agentsandbox/lists.ts +52 -0
  47. package/src/components/agentsandbox/routes.ts +23 -0
  48. package/src/components/agentsandbox/shared.tsx +321 -0
  49. package/src/components/agentsandbox/useAgentSandboxSidebarWorkspace.ts +69 -0
  50. package/src/components/agentsandbox/workspace.fixtures.ts +125 -0
  51. package/src/components/agentsandbox/workspace.tsx +258 -0
  52. package/src/components/agentsandbox/workspaceRoute.ts +18 -0
  53. package/src/components/applications/ApplicationsView.openResource.test.tsx +248 -3
  54. package/src/components/applications/ApplicationsView.tsx +156 -3
  55. package/src/components/audit/VulnerabilitiesColumns.test.tsx +487 -0
  56. package/src/components/audit/VulnerabilitiesRisk.test.tsx +318 -0
  57. package/src/components/audit/VulnerabilitiesView.test.tsx +458 -13
  58. package/src/components/audit/VulnerabilitiesView.tsx +639 -199
  59. package/src/components/cloudHints/AgentSetupCloudRow.tsx +28 -0
  60. package/src/components/cloudHints/CloudHintLink.tsx +29 -0
  61. package/src/components/cloudHints/SharedInstallAiLine.tsx +36 -0
  62. package/src/components/cloudHints/cloudHints.test.ts +126 -0
  63. package/src/components/cloudHints/cloudHints.ts +131 -0
  64. package/src/components/cloudHints/cloudHintsGate.test.tsx +70 -0
  65. package/src/components/cloudHints/cloudLinks.test.ts +52 -0
  66. package/src/components/cloudHints/cloudLinks.ts +31 -0
  67. package/src/components/cloudHints/hintStorage.ts +28 -0
  68. package/src/components/cnpg/CNPGView.tsx +4 -7
  69. package/src/components/diagnose/ActivityTurn.tsx +6 -4
  70. package/src/components/diagnose/AgentSetupNotice.tsx +5 -0
  71. package/src/components/diagnose/AssessmentCard.tsx +1 -2
  72. package/src/components/diagnose/ContinueInAgentButton.test.tsx +7 -0
  73. package/src/components/diagnose/DiagnoseContext.tsx +7 -0
  74. package/src/components/diagnose/DiagnoseSurface.escape.test.tsx +215 -0
  75. package/src/components/diagnose/DiagnoseSurface.tsx +57 -1
  76. package/src/components/diagnose/Home.test.tsx +6 -0
  77. package/src/components/diagnose/Home.tsx +10 -3
  78. package/src/components/diagnose/InvestigationEvidencePane.story.test.tsx +1 -1
  79. package/src/components/diagnose/InvestigationEvidencePane.tsx +19 -2
  80. package/src/components/diagnose/InvestigationFindingsFooter.test.tsx +413 -0
  81. package/src/components/diagnose/InvestigationView.tsx +120 -23
  82. package/src/components/diagnose/investigationEvidence/identity.test.ts +1 -1
  83. package/src/components/diagnose/investigationEvidence/projection.test.ts +1 -1
  84. package/src/components/diagnose/investigationState.ts +9 -0
  85. package/src/components/diagnose/parts.test.tsx +11 -3
  86. package/src/components/diagnose/toolCallLabel.ts +3 -0
  87. package/src/components/gitops/RemoteDestinationCloudHint.tsx +6 -14
  88. package/src/components/home/ActivitySummary.tsx +3 -8
  89. package/src/components/home/ClusterHealthCard.tsx +91 -17
  90. package/src/components/home/ClusterHealthCard.utilization.test.tsx +187 -0
  91. package/src/components/home/HomeAgentBlock.tsx +2 -0
  92. package/src/components/home/HomeView.tsx +9 -29
  93. package/src/components/home/MCPSetupDialog.test.tsx +9 -0
  94. package/src/components/home/MCPSetupDialog.tsx +6 -2
  95. package/src/components/home/McpCloudLine.test.tsx +162 -0
  96. package/src/components/home/McpCloudLine.tsx +95 -0
  97. package/src/components/home/ProblemsPanel.investigate.test.tsx +2 -2
  98. package/src/components/home/TopologyPreview.test.tsx +31 -30
  99. package/src/components/home/TopologyPreview.tsx +19 -28
  100. package/src/components/home/mcpToolCatalog.test.ts +10 -0
  101. package/src/components/home/mcpToolCatalog.ts +7 -7
  102. package/src/components/issues/ClusterSchedulingBlockerRow.tsx +35 -0
  103. package/src/components/issues/IssuesPane.render.test.tsx +36 -1
  104. package/src/components/issues/IssuesPane.tsx +181 -23
  105. package/src/components/issues/SinceLastVisitRow.render.test.tsx +302 -0
  106. package/src/components/issues/SinceLastVisitRow.tsx +71 -0
  107. package/src/components/issues/sinceLastVisit.test.ts +266 -0
  108. package/src/components/issues/sinceLastVisit.ts +439 -0
  109. package/src/components/kagent/KagentAgentRenderer.test.ts +32 -0
  110. package/src/components/kagent/KagentAgentRenderer.tsx +87 -0
  111. package/src/components/kagent/KagentAgentSessions.test.tsx +166 -0
  112. package/src/components/kagent/KagentAgentSessions.tsx +124 -0
  113. package/src/components/kagent/KagentDetailPage.tsx +106 -0
  114. package/src/components/kagent/KagentLists.tsx +412 -0
  115. package/src/components/kagent/KagentOverview.tsx +234 -0
  116. package/src/components/kagent/KagentPages.tsx +690 -0
  117. package/src/components/kagent/KagentRuntimeTabs.test.tsx +219 -0
  118. package/src/components/kagent/KagentRuntimeTabs.tsx +283 -0
  119. package/src/components/kagent/KagentSidebar.test.tsx +112 -0
  120. package/src/components/kagent/KagentView.tsx +109 -0
  121. package/src/components/kagent/KagentWorkspace.test.tsx +876 -0
  122. package/src/components/kagent/host.tsx +144 -0
  123. package/src/components/kagent/routes.ts +31 -0
  124. package/src/components/kagent/shared.tsx +336 -0
  125. package/src/components/kagent/useKagentRuntime.test.tsx +77 -0
  126. package/src/components/kagent/useKagentSidebarWorkspace.ts +67 -0
  127. package/src/components/kagent/workspace.fixtures.ts +108 -0
  128. package/src/components/kagent/workspaceRoute.ts +18 -0
  129. package/src/components/resource/MetricsNotConnected.test.tsx +28 -0
  130. package/src/components/resource/MetricsNotConnected.tsx +10 -7
  131. package/src/components/resource/PrometheusCharts.tsx +10 -1
  132. package/src/components/resource/PrometheusChartsGrid.render.test.tsx +9 -0
  133. package/src/components/resource/PrometheusChartsGrid.tsx +3 -3
  134. package/src/components/resource/SubstrateHealthCharts.test.tsx +13 -1
  135. package/src/components/resource/SubstrateHealthCharts.tsx +9 -15
  136. package/src/components/resources/ResourceDetailDrawer.tsx +1 -0
  137. package/src/components/resources/ResourcesView.tsx +2 -6
  138. package/src/components/resources/renderers/JobAdmissionRenderers.tsx +5 -4
  139. package/src/components/resources/renderers/PodRenderer.tsx +8 -2
  140. package/src/components/resources/renderers/RolloutRenderer.tsx +4 -1
  141. package/src/components/resources/renderers/WorkloadRenderer.tsx +4 -1
  142. package/src/components/settings/LocalIntegrationStatus.test.tsx +1 -0
  143. package/src/components/settings/LocalIntegrationStatus.tsx +3 -2
  144. package/src/components/settings/SettingsDialog.tsx +84 -16
  145. package/src/components/settings/SubstrateSettings.lifecycle.test.tsx +210 -0
  146. package/src/components/settings/SubstrateSettings.test.tsx +131 -0
  147. package/src/components/settings/SubstrateSettings.tsx +544 -0
  148. package/src/components/settings/settings-state.test.ts +21 -3
  149. package/src/components/settings/settings-state.ts +13 -3
  150. package/src/components/share/ShareLinkButton.test.tsx +360 -0
  151. package/src/components/share/ShareLinkButton.tsx +391 -0
  152. package/src/components/share/openShareInCloud.test.ts +29 -0
  153. package/src/components/share/openShareInCloud.ts +10 -0
  154. package/src/components/share/shareLink.test.ts +129 -0
  155. package/src/components/share/shareLink.ts +175 -0
  156. package/src/components/substrate/SubstrateActorDrawer.tsx +87 -0
  157. package/src/components/substrate/SubstrateActorOverview.tsx +489 -0
  158. package/src/components/substrate/SubstrateActorPage.tsx +384 -0
  159. package/src/components/substrate/SubstrateActors.test.tsx +1094 -0
  160. package/src/components/substrate/SubstrateActors.tsx +612 -0
  161. package/src/components/substrate/SubstrateAttentionList.tsx +441 -0
  162. package/src/components/substrate/SubstrateConnect.tsx +88 -0
  163. package/src/components/substrate/SubstrateOverview.test.tsx +396 -0
  164. package/src/components/substrate/SubstrateOverview.tsx +575 -0
  165. package/src/components/substrate/SubstratePages.test.tsx +478 -0
  166. package/src/components/substrate/SubstratePool.test.tsx +462 -0
  167. package/src/components/substrate/SubstratePoolPage.tsx +95 -0
  168. package/src/components/substrate/SubstratePoolSummary.tsx +485 -0
  169. package/src/components/substrate/SubstrateSidebar.test.tsx +101 -0
  170. package/src/components/substrate/SubstrateStateBar.tsx +63 -0
  171. package/src/components/substrate/SubstrateTemplates.tsx +376 -0
  172. package/src/components/substrate/SubstrateView.tsx +173 -0
  173. package/src/components/substrate/SubstrateWorkerPodContext.tsx +73 -0
  174. package/src/components/substrate/SubstrateWorkers.tsx +389 -0
  175. package/src/components/substrate/attention.ts +81 -0
  176. package/src/components/substrate/contextPin.tsx +69 -0
  177. package/src/components/substrate/host.tsx +83 -0
  178. package/src/components/substrate/kubectlTarget.test.tsx +77 -0
  179. package/src/components/substrate/readings.test.ts +484 -0
  180. package/src/components/substrate/readings.ts +997 -0
  181. package/src/components/substrate/routes.ts +103 -0
  182. package/src/components/substrate/shared.tsx +426 -0
  183. package/src/components/substrate/substrate.fixtures.ts +325 -0
  184. package/src/components/substrate/useSubstrateSidebarWorkspace.ts +87 -0
  185. package/src/components/substrate/workspaceRoute.ts +23 -0
  186. package/src/components/traffic/TrafficConnectionsTable.test.tsx +9 -0
  187. package/src/components/traffic/TrafficConnectionsTable.tsx +4 -2
  188. package/src/components/traffic/TrafficFilterSidebar.tsx +19 -14
  189. package/src/components/traffic/TrafficFlowList.test.tsx +63 -0
  190. package/src/components/traffic/TrafficFlowList.tsx +9 -5
  191. package/src/components/traffic/TrafficGraph.test.tsx +26 -0
  192. package/src/components/traffic/TrafficGraph.tsx +17 -14
  193. package/src/components/traffic/TrafficGraphTooLarge.tsx +2 -0
  194. package/src/components/traffic/TrafficGraphUnavailable.tsx +3 -1
  195. package/src/components/traffic/TrafficView.tsx +26 -56
  196. package/src/components/traffic/trafficFilters.test.ts +61 -1
  197. package/src/components/traffic/trafficFilters.ts +68 -8
  198. package/src/components/velero/VeleroOverview.tsx +2 -2
  199. package/src/components/velero/VeleroView.tsx +3 -6
  200. package/src/components/vulnerabilities/columns.tsx +132 -0
  201. package/src/components/vulnerabilities/filters.tsx +317 -0
  202. package/src/components/vulnerabilities/owner.test.ts +54 -0
  203. package/src/components/vulnerabilities/owner.tsx +163 -0
  204. package/src/components/vulnerabilities/parts.test.ts +126 -12
  205. package/src/components/vulnerabilities/parts.tsx +612 -52
  206. package/src/components/vulnerabilities/traffic.test.tsx +65 -0
  207. package/src/components/vulnerabilities/traffic.tsx +40 -0
  208. package/src/components/workload/WorkloadView.substrateVersion.test.tsx +88 -0
  209. package/src/components/workload/WorkloadView.tsx +119 -14
  210. package/src/components/workload/WorkloadView.workloadSource.test.tsx +121 -0
  211. package/src/components/workspace/layout.tsx +13 -7
  212. package/src/components/workspace/sidebar.test.ts +48 -0
  213. package/src/components/workspace/sidebar.ts +73 -3
  214. package/src/components/workspace/table.ts +2 -1
  215. package/src/context/ConnectionContext.tsx +24 -5
  216. package/src/context/ConnectionProvider.connectionId.test.tsx +14 -0
  217. package/src/context/ConnectionProvider.handover.test.tsx +94 -0
  218. package/src/context/DiagnoseCustomization.tsx +20 -2
  219. package/src/contexts/RegistryAccessMode.test.tsx +51 -0
  220. package/src/contexts/RegistryAccessMode.tsx +25 -0
  221. package/src/hooks/useEventSource.test.tsx +275 -4
  222. package/src/hooks/useEventSource.ts +278 -51
  223. package/src/index.ts +1 -0
  224. package/src/integrations/resourceHost.ts +12 -6
  225. package/src/integrations/resourceHosts.test.tsx +27 -1
  226. package/src/integrations/resourceHosts.tsx +15 -7
  227. package/src/integrations/sidebarWorkspaces.test.tsx +63 -0
  228. package/src/integrations/sidebarWorkspaces.ts +41 -0
  229. package/src/integrations/workspaceRoute.ts +1 -1
  230. package/src/integrations/workspaceRoutes.ts +7 -1
  231. package/src/integrations/workspaceScreens.tsx +6 -0
  232. package/src/utils/navigation.test.ts +1 -6
  233. package/src/utils/navigation.ts +9 -44
  234. package/src/utils/network-policy-navigation.test.ts +21 -36
@@ -0,0 +1,333 @@
1
+ import type { ComponentProps, ReactNode } from 'react'
2
+ import { renderToStaticMarkup } from 'react-dom/server'
3
+ import { MemoryRouter } from 'react-router-dom'
4
+ import { describe, expect, it, onTestFinished, vi } from 'vitest'
5
+
6
+ const pods = vi.hoisted(() => ({ verified: true }))
7
+ vi.mock('../../api/client', async (importOriginal) => ({
8
+ ...(await importOriginal<typeof import('../../api/client')>()),
9
+ useResourceWithRelationships: (_kind: string, namespace: string, name: string) => ({
10
+ data: name && pods.verified ? { relationships: { children: [{ kind: 'Pod', namespace, name: `${name}-owned-pod` }] } } : undefined,
11
+ isLoading: false,
12
+ }),
13
+ }))
14
+ vi.mock('../../contexts/CapabilitiesContext', () => ({ useNamespacedCapabilities: () => ({ canViewLogs: true, logsUnknown: false }) }))
15
+ vi.mock('../../context/ConnectionContext', () => ({ useConnection: () => ({ connection: { context: 'kind-demo' } }) }))
16
+
17
+ import { RadarFeatureUnsupportedError } from '../../api/radarFeatures'
18
+ import type { AgentSandboxAttention, AgentSandboxWorkspaceResponse } from '../../api/agentSandbox'
19
+ import { AgentSandboxOverview, NOTHING_IN_WHAT_WAS_READ, NOTHING_NEEDS_ATTENTION, overviewFacts } from './AgentSandboxOverview'
20
+ import { AgentSandboxWorkspaceGate, attentionAge, attentionDetail, attentionTitle, ceilingDuration, sidebarCount } from './workspace'
21
+ import { emptyWorkspace, liveAttention, liveWorkspace, minutesAgo } from './workspace.fixtures'
22
+
23
+ // Repeats until stable, so a tag split across another tag can't survive one pass.
24
+ function stripTags(html: string): string {
25
+ let prev: string
26
+ do {
27
+ prev = html
28
+ html = html.replace(/<[^>]*>/g, '')
29
+ } while (html !== prev)
30
+ return html
31
+ }
32
+
33
+ // renderToStaticMarkup escapes apostrophes; compare against the text a reader sees.
34
+ // Source messages wrap at spaces only, a span per word (wrapAtSpaces); read them as running text.
35
+ const text = (html: string) =>
36
+ html
37
+ .replace(/&#x27;/g, "'")
38
+ .replace(/&quot;/g, '"')
39
+ .replace(/&amp;/g, '&')
40
+ .replace(/<!-- -->/g, '')
41
+ .replace(/<span class="inline-block max-w-full align-top">([^<]*)<\/span>/g, '$1')
42
+ const page = (node: ReactNode) => text(renderToStaticMarkup(<MemoryRouter>{node}</MemoryRouter>))
43
+ const overview = (data: AgentSandboxWorkspaceResponse) => page(<AgentSandboxOverview data={data} onClearNamespaces={() => {}} onInspect={() => {}} inspected={null} />)
44
+ const fact = (data: AgentSandboxWorkspaceResponse, label: string) => {
45
+ const f = overviewFacts(data).find((x) => x.label === label)
46
+ return typeof f?.value === 'string' ? f.value : undefined
47
+ }
48
+ const row = (html: string, title: string) => {
49
+ const start = html.indexOf(title)
50
+ const end = html.indexOf('</li>', start)
51
+ return html.slice(start, end)
52
+ }
53
+
54
+ type GateQuery = ComponentProps<typeof AgentSandboxWorkspaceGate>['query']
55
+ const idle: GateQuery = { data: undefined, error: null, isLoading: false, isFetching: false, refetch: vi.fn(), isRefetchError: false, dataUpdatedAt: 0 }
56
+ const gate = (query: Partial<GateQuery>, opts = { discoveryPending: false, discovered: true }) =>
57
+ page(
58
+ <AgentSandboxWorkspaceGate query={{ ...idle, ...query }} discoveryPending={opts.discoveryPending} discovered={opts.discovered}>
59
+ {() => <div>screen</div>}
60
+ </AgentSandboxWorkspaceGate>,
61
+ )
62
+
63
+ describe('Agent Sandbox overview gate', () => {
64
+ it('waits, then shows the screen; says when Agent Sandbox is not installed', () => {
65
+ expect(gate({ isLoading: true })).toContain('Loading Agent Sandbox')
66
+ expect(gate({}, { discoveryPending: false, discovered: false })).toContain('Agent Sandbox is not installed')
67
+ expect(gate({ data: liveWorkspace({ installed: false }) })).toContain('Agent Sandbox is not installed')
68
+ expect(gate({ data: liveWorkspace() })).toContain('screen')
69
+ })
70
+
71
+ it('tells an older Radar that it needs a newer one, not an error, and keeps the lists usable', () => {
72
+ const html = gate({ error: new RadarFeatureUnsupportedError('agentSandboxWorkspace', { currentVersion: 'v1.16.0' }) })
73
+ expect(html).toContain('needs a newer Radar')
74
+ expect(html).toContain('lists work on this Radar')
75
+ expect(html).not.toContain('Agent Sandbox data unavailable')
76
+ })
77
+
78
+ it('offers a retry for a failed read', () => {
79
+ const html = gate({ error: new Error('boom') })
80
+ expect(html).toContain('Agent Sandbox data unavailable')
81
+ expect(html).toContain('Retry')
82
+ })
83
+ })
84
+
85
+ describe('Agent Sandbox overview, from the server summary', () => {
86
+ it('shows the intro only when the workspace is empty, and leads populated workspaces with Needs attention above At a glance', () => {
87
+ const empty = overview(emptyWorkspace())
88
+ expect(empty).toContain('Agent Sandbox gives each agent its own sandboxed Pod')
89
+ const populated = overview(liveWorkspace())
90
+ expect(populated).not.toContain('Agent Sandbox gives each agent its own sandboxed Pod')
91
+ expect(populated.indexOf('Needs attention')).toBeLessThan(populated.indexOf('At a glance'))
92
+ // Full warm-pool table lives on the Warm pools list, not duplicated on Overview.
93
+ expect(populated).not.toContain('<table')
94
+ })
95
+
96
+ it('summarizes Controller, Sandboxes, Claims, and Warm reserve in framed At a glance rows', () => {
97
+ const data = liveWorkspace()
98
+ expect(fact(data, 'Controller')).toBe('Running (1/1 ready)')
99
+ expect(fact(data, 'Sandboxes')).toBe('2 failed · 2 can’t schedule · 1 suspension blocked')
100
+ expect(fact(data, 'Claims')).toBe('1 waiting · 0 bound')
101
+ expect(fact(data, 'Warm reserve')).toBe('0 of 2 ready in 1 pool')
102
+ const html = overview(data)
103
+ expect(html).toContain('Deployment →')
104
+ expect(html).toContain('cluster-level check, outside namespace filter')
105
+ expect(html).toContain('Sandboxes →')
106
+ expect(html).toContain('Claims →')
107
+ expect(html).toContain('Warm pools →')
108
+ expect(html).toContain('3 sandboxes and claims expired in the last 7 days')
109
+ })
110
+
111
+ it('marks counts over a partial read with ≥, and a denied or left-out kind as unknown naming the missing permission, never 0', () => {
112
+ const live = liveWorkspace()
113
+ const partial = liveWorkspace({ counts: { ...live.counts, sandboxes: { ...live.counts.sandboxes!, lowerBound: true } } })
114
+ expect(fact(partial, 'Sandboxes')).toBe('≥2 failed · ≥2 can’t schedule · ≥1 suspension blocked')
115
+ const leftOut = liveWorkspace({ counts: { ...live.counts, claims: undefined }, coverage: { ...live.coverage, claims: { state: 'denied' } } })
116
+ expect(fact(leftOut, 'Claims')).toBe('Unknown — no access (missing list sandboxclaims.extensions.agents.x-k8s.io)')
117
+ const notInstalled = liveWorkspace({ counts: { ...live.counts, warmPools: undefined }, coverage: { ...live.coverage, warmPools: { state: 'notInstalled' } } })
118
+ expect(fact(notInstalled, 'Warm reserve')).toBe('Not installed')
119
+ const html = overview(leftOut)
120
+ expect(html).toContain('SandboxClaims (no access — missing list sandboxclaims.extensions.agents.x-k8s.io)')
121
+ })
122
+
123
+ it('keeps the reserve unknown when the controller has not reported', () => {
124
+ const data = liveWorkspace()
125
+ const workspace = { ...data, attention: [], counts: { ...data.counts, warmPools: { ...data.counts.warmPools!, readyLowerBound: true } } }
126
+ expect(overviewFacts(workspace).find((f) => f.label === 'Warm reserve')).toMatchObject({
127
+ value: 'unknown ready · target 2 in 1 pool',
128
+ tone: 'unknown',
129
+ })
130
+ })
131
+
132
+ it('reads the controller where it looked, names missing permission when denied, and never calls an unread one stopped', () => {
133
+ const c = liveWorkspace().controller
134
+ expect(fact(liveWorkspace({ controller: { ...c, state: 'notFound' } }), 'Controller')).toBe('Unknown — not found as agent-sandbox-system/agent-sandbox-controller')
135
+ expect(fact(liveWorkspace({ controller: { ...c, state: 'unread', code: 'user_forbidden' } }), 'Controller')).toBe('Unknown — no access (missing get deployments in namespace agent-sandbox-system)')
136
+ const unread = (code: string) => fact(liveWorkspace({ controller: { state: 'unread', namespace: c.namespace, name: c.name, code } }), 'Controller')
137
+ expect(unread('kind_sync_pending')).toBe('Unknown — still loading')
138
+ expect(unread('kind_sync_timed_out')).toBe('Unknown — loading is overdue')
139
+ expect(unread('radar_kind_not_collected')).toBe('Unknown — not collected by Radar')
140
+ expect(unread('outside_namespace_pin')).toBe('Unknown — outside Radar’s namespace scope')
141
+ expect(fact(liveWorkspace({ controller: { ...c, state: 'scaledToZero', ready: 0, desired: 0 } }), 'Controller')).toBe('Scaled to zero')
142
+ expect(fact(liveWorkspace({ controller: { ...c, state: 'notReady', ready: 0, since: minutesAgo(20) } }), 'Controller')).toBe('Not ready for 20m')
143
+ })
144
+
145
+ it('promotes a stopped controller problem callout above Needs attention without duplicating it in the list', () => {
146
+ const c = liveWorkspace().controller
147
+ const ctrlRow: AgentSandboxAttention = {
148
+ id: 'controller', category: 'controller', rule: 'controllerNotRunning', reason: 'AgentSandboxControllerNotReady', severity: 'critical',
149
+ title: 'Agent Sandbox controller not running',
150
+ reading: 'No ready replica, so no Sandbox starts.',
151
+ nextStep: 'Find out why the controller’s Pods aren’t ready, from their events and logs',
152
+ subject: { kind: 'Deployment', group: 'apps', namespace: c.namespace, name: c.name },
153
+ issue: false,
154
+ }
155
+ const html = overview(liveWorkspace({ controller: { ...c, state: 'notReady', ready: 0 }, attention: [ctrlRow, ...liveAttention()], attentionTotal: 6 }))
156
+ expect(html.indexOf('Agent Sandbox controller not running')).toBeLessThan(html.indexOf('Needs attention'))
157
+ expect(html.match(/Agent Sandbox controller not running/g)).toHaveLength(1)
158
+ })
159
+
160
+ it('lists every row the server sent in the server’s order, each with its next step and the source text folded', () => {
161
+ const html = overview(liveWorkspace())
162
+ const attention = html.slice(html.indexOf('Needs attention'), html.indexOf('At a glance'))
163
+ expect([...attention.matchAll(/data-rule="(\w+)"/g)].map((m) => m[1])).toEqual(liveAttention().map((a) => a.rule))
164
+ const reversed = liveAttention().reverse()
165
+ const html2 = overview(liveWorkspace({ attention: reversed }))
166
+ expect([...html2.matchAll(/data-rule="(\w+)"/g)].map((m) => m[1])).toEqual(reversed.map((a) => a.rule))
167
+ expect(attention.match(/data-rule=/g)).toHaveLength(5)
168
+ expect(attention).toContain('Controller’s message')
169
+ expect(attention).toContain('Scheduler’s message')
170
+ expect(attention).toContain('data-rule="reserveBelowTarget"')
171
+ })
172
+
173
+ it('puts the scheduler’s verdict plainly beside the server’s reading', () => {
174
+ const pool = liveAttention().find((a) => a.rule === 'reserveBelowTarget')!
175
+ expect(attentionDetail(pool)).toBe('Its 2 sandboxes can’t be scheduled. No sandbox is ready in reserve, so a new claim takes one still starting or starts its own from the template (a slower, cold start). Scheduler: all nodes have reached their Pod limit.')
176
+ })
177
+
178
+ it('links Pod logs directly on failed Pods and "See in Issues" only on rows Radar’s Issues list too', () => {
179
+ const html = overview(liveWorkspace())
180
+ const failedRow = row(html, 'Pod failed')
181
+ expect(failedRow).toContain('failed-owned-pod')
182
+ expect(failedRow).toContain('Pod logs →')
183
+ expect(failedRow).toContain('See in Issues')
184
+ expect(row(html, 'Warm reserve below target')).not.toContain('See in Issues')
185
+ })
186
+
187
+ it('withholds the ordinary Pod and logs links when the owner reference could not be verified', () => {
188
+ pods.verified = false
189
+ onTestFinished(() => { pods.verified = true })
190
+ const html = overview(liveWorkspace())
191
+ expect(row(html, 'Pod failed')).not.toContain('Pod logs')
192
+ expect(row(html, 'Suspension blocked')).toContain('Conflicting Pod')
193
+ })
194
+
195
+ it('says a relation is not found only where the server read its kind in full, else not read', () => {
196
+ const absent = row(overview(liveWorkspace()), 'Warm pool not found')
197
+ expect(absent).toMatch(/no-such-pool<\/span> <span[^>]*>not found/)
198
+ const claim = liveAttention().find((a) => a.rule === 'cannotBind')!
199
+ const unread: AgentSandboxAttention = { ...claim, relations: [{ ...claim.relations![0], presence: 'unread' }] }
200
+ const html = row(overview(liveWorkspace({ attention: [unread], attentionTotal: 1 })), 'Warm pool not found')
201
+ expect(html).toMatch(/no-such-pool<\/span> <span[^>]*>not read/)
202
+ expect(row(overview(liveWorkspace()), 'Warm reserve below target')).toContain('>tmpl</button>')
203
+ })
204
+
205
+ it('branches on the rule and renders plain-English "up to" ceilings instead of ≤', () => {
206
+ vi.useFakeTimers({ toFake: ['Date'], now: Date.parse('2026-11-18T12:00:00Z') })
207
+ onTestFinished(() => void vi.useRealTimers())
208
+ const base = liveAttention().find((a) => a.id.endsWith('/bad-image'))!
209
+ const slow: AgentSandboxAttention = { ...base, rule: 'slow', severity: 'warning', title: 'Still starting', reading: 'Pod exists with phase: Pending', rawDetail: undefined, since: minutesAgo(12), issue: false }
210
+ expect(attentionTitle(slow)).toBe('Still starting')
211
+ expect(attentionAge(slow)?.text).toBe('up to 12m')
212
+ expect(attentionDetail(slow)).toBe('Pod exists with phase: Pending Radar’s Issues raise it after 30 minutes.')
213
+ const stalled: AgentSandboxAttention = { ...slow, rule: 'stalled', severity: 'alert', since: minutesAgo(45), issue: true }
214
+ expect(attentionAge(stalled)?.text).toBe('up to 45m')
215
+ expect(attentionDetail(stalled)).toBe('Pod exists with phase: Pending')
216
+ const aged = attentionAge({ ...base, since: minutesAgo(90) })
217
+ expect(aged?.text).toBe('up to 1h 30m')
218
+ expect(aged?.tip).toContain('up to 1h 30m ago')
219
+ expect(attentionAge(base)).toBeUndefined()
220
+ expect(attentionAge({ ...base, rule: 'controllerNotRunning', since: minutesAgo(20) })?.text).toBe('20m')
221
+ })
222
+
223
+ it('rounds an age ceiling up, so the bound never understates', () => {
224
+ const s = 1000
225
+ const m = 60 * s
226
+ const h = 60 * m
227
+ expect(ceilingDuration(12 * m)).toBe('12m')
228
+ expect(ceilingDuration(12 * m + 1)).toBe('13m')
229
+ expect(ceilingDuration(59 * m + 30 * s)).toBe('1h')
230
+ expect(ceilingDuration(61 * m + 10 * s)).toBe('1h 2m')
231
+ expect(ceilingDuration(2 * h)).toBe('2h')
232
+ expect(ceilingDuration(25 * h + 1)).toBe('1d 2h')
233
+ expect(ceilingDuration(24 * h)).toBe('1d')
234
+ expect(ceilingDuration(500)).toBe('1s')
235
+ })
236
+
237
+ it('keeps the pool cause on the first view and leaves the remedy and raw evidence under Details', () => {
238
+ const html = overview(liveWorkspace())
239
+ const pool = row(html, 'Warm reserve below target')
240
+ const atPos = (t: string) => {
241
+ const i = pool.indexOf(t)
242
+ expect(i, t).toBeGreaterThanOrEqual(0)
243
+ return i
244
+ }
245
+ expect(atPos('SandboxWarmPool')).toBeLessThan(atPos('no unbound claim in progress uses it'))
246
+ expect(atPos('no unbound claim in progress uses it')).toBeLessThan(atPos('Show all members that aren’t ready'))
247
+ expect(atPos('Its 2 sandboxes can’t be scheduled.')).toBeLessThan(atPos('>Details<'))
248
+ expect(atPos('>Details<')).toBeLessThan(atPos('Next step: '))
249
+ expect(atPos('>Details<')).toBeLessThan(atPos('Not ready:'))
250
+ expect(atPos('>Details<')).toBeLessThan(atPos('0/4 nodes are available'))
251
+ expect(pool).not.toContain('See in Issues')
252
+ const image = row(html, 'Image can’t be pulled')
253
+ expect(image.indexOf('>Details<')).toBeLessThan(image.indexOf('is waiting: ErrImagePull'))
254
+ expect(image).toContain('Check the image name and the registry credentials')
255
+ })
256
+
257
+ it('says how long a state has lasted as "up to X ago", never "≤X"', () => {
258
+ vi.useFakeTimers({ toFake: ['Date'], now: Date.parse('2026-11-18T12:00:00Z') })
259
+ onTestFinished(() => void vi.useRealTimers())
260
+ const base = liveAttention().find((a) => a.id.endsWith('/bad-image'))!
261
+ const html = overview(liveWorkspace({ attention: [{ ...base, since: minutesAgo(90) }], attentionTotal: 1 }))
262
+ expect(html).toContain('up to 1h 30m ago')
263
+ expect(html).not.toContain('≤1h 30m')
264
+ })
265
+
266
+ it('says how many claims an empty reserve leaves without a warm sandbox, and only what the server counted', () => {
267
+ const pool = liveAttention().find((a) => a.rule === 'reserveBelowTarget')!
268
+ const one = (w: AgentSandboxAttention['waitingClaims']) => row(overview(liveWorkspace({ attention: [{ ...pool, waitingClaims: w }], attentionTotal: 1 })), 'Warm reserve below target')
269
+ expect(one({ count: 2, lowerBound: false })).toContain('2 unbound claims in progress use this pool')
270
+ expect(one({ count: 1, lowerBound: true })).toContain('at least 1 unbound claim in progress uses this pool')
271
+ const unread = one(undefined)
272
+ expect(unread).not.toContain('this pool')
273
+ expect(unread).not.toContain('no claim waits')
274
+ const claim: AgentSandboxAttention = {
275
+ id: 'claim:radar-agents-live/a', category: 'claim', rule: 'stalled', severity: 'alert', title: 'Still binding', nextStep: 'Check the SandboxClaim’s Pod and its events for what it waits on',
276
+ subject: { kind: 'SandboxClaim', group: 'extensions.agents.x-k8s.io', namespace: 'radar-agents-live', name: 'a' },
277
+ relations: [{ role: 'warmPool', ref: pool.subject, presence: 'present' }], emptyPool: pool.subject, issue: true,
278
+ }
279
+ const html = row(overview(liveWorkspace({ attention: [claim], attentionTotal: 1 })), 'Still binding')
280
+ expect(html).toMatch(/its warm pool <button[^>]*>warm<\/button> has no sandbox ready/)
281
+ expect(html.match(/>warm<\/button>/g)).toHaveLength(1)
282
+ })
283
+
284
+ it('keeps what limits Radar’s reading beside the title, never under Details', () => {
285
+ const claim = liveAttention().find((a) => a.rule === 'cannotBind')!
286
+ const caveat = 'Radar finds SandboxWarmPool no-such-pool in radar-agents-live, so the controller’s report may predate it.'
287
+ const html = row(overview(liveWorkspace({ attention: [{ ...claim, caveat }], attentionTotal: 1 })), 'Warm pool not found')
288
+ expect(html.indexOf(caveat)).toBeGreaterThan(0)
289
+ expect(html.indexOf(caveat)).toBeLessThan(html.indexOf('Create SandboxWarmPool'))
290
+ expect(html.indexOf(caveat)).toBeLessThan(html.indexOf('>Details<'))
291
+ })
292
+
293
+ it('links the conflicting Pod directly on Suspension blocked and folds the kubectl command under Details', () => {
294
+ const html = row(overview(liveWorkspace()), 'Suspension blocked')
295
+ const cmd = "kubectl get pod foreign -n radar-agents-live -o jsonpath='{.metadata.ownerReferences}'"
296
+ const plain = stripTags(html)
297
+ expect(html).toContain('Conflicting Pod')
298
+ expect(plain).toContain('Next step: Check who owns Pod foreign before removing it, or recreate the Sandbox under another name')
299
+ expect(plain).not.toContain(`(${cmd})`)
300
+ // CommandChip lives inside Details, after the Details toggle.
301
+ expect(html.indexOf('>Details<')).toBeLessThan(html.indexOf('data-command-line'))
302
+ expect(html.slice(html.indexOf('data-command-line'))).toContain(cmd)
303
+ })
304
+
305
+ it('says nothing needs attention only when the server read everything', () => {
306
+ expect(overview(emptyWorkspace())).toContain(NOTHING_NEEDS_ATTENTION)
307
+ expect(overview(emptyWorkspace({ attentionComplete: false }))).toContain(NOTHING_IN_WHAT_WAS_READ)
308
+ })
309
+
310
+ it('says when it shows only the first rows the server sent', () => {
311
+ expect(overview(liveWorkspace({ attentionTotal: 240 }))).toContain('Showing 5 of 240 findings.')
312
+ })
313
+
314
+ it('links recent expirations into the Sandboxes inventory and shows nothing when none expired', () => {
315
+ expect(overview(liveWorkspace())).toContain('Recently expired sandboxes →')
316
+ expect(overview(liveWorkspace())).toContain('Recently expired claims →')
317
+ expect(overview(emptyWorkspace())).not.toContain('Recently expired')
318
+ })
319
+
320
+ it('shows the namespace filter the server applied as a chip and subtitle', () => {
321
+ expect(overview(liveWorkspace())).toContain('Namespace: radar-agents-live')
322
+ expect(overview(liveWorkspace({ namespaces: [] }))).toContain('All namespaces')
323
+ })
324
+ })
325
+
326
+ describe('Agent Sandbox sidebar badges', () => {
327
+ it('take the server’s counts: ≥ for a lower bound, the unknown dash for a lower-bound zero', () => {
328
+ expect(sidebarCount({ count: 3, lowerBound: false }, ['sandbox', 'sandboxes'])).toEqual({ count: 3, lowerBound: false, title: '3 sandboxes need attention.' })
329
+ expect(sidebarCount({ count: 2, lowerBound: true }, ['claim', 'claims']).title).toBe('At least 2 claims need attention. Some couldn’t be read, so there may be more.')
330
+ expect(sidebarCount({ count: null, lowerBound: true }, ['warm pool', 'warm pools'])).toMatchObject({ count: null, lowerBound: true })
331
+ expect(sidebarCount({ count: 1, lowerBound: false }, ['object', 'objects']).title).toBe('1 object needs attention.')
332
+ })
333
+ })