@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,439 @@
1
+ import type { ReactNode } from 'react'
2
+ import { renderToStaticMarkup } from 'react-dom/server'
3
+ import { MemoryRouter } from 'react-router-dom'
4
+ import { beforeEach, describe, expect, it, vi } from 'vitest'
5
+ import type { Relationships, TimelineEvent } from '@skyhook-io/k8s-ui/types/core'
6
+ import { getSandboxStatus } from '@skyhook-io/k8s-ui/components/resources/resource-utils-agent-runtimes'
7
+ import type { AgentSandboxWorkspaceResponse } from '../../api/agentSandbox'
8
+ import type { AgentSandboxLists } from './data'
9
+
10
+ const state = vi.hoisted(() => ({
11
+ support: 'supported' as 'supported' | 'unsupported',
12
+ workspace: undefined as AgentSandboxWorkspaceResponse | undefined,
13
+ workspaceLoading: false,
14
+ relationships: undefined as Relationships | undefined,
15
+ relationshipsLoading: false,
16
+ pod: undefined as any,
17
+ podRequests: [] as { name: string; enabled: boolean }[],
18
+ lists: undefined as AgentSandboxLists | undefined,
19
+ events: [] as TimelineEvent[],
20
+ }))
21
+
22
+ vi.mock('../../contexts/CapabilitiesContext', () => ({ useNamespacedCapabilities: () => ({ canViewLogs: true, logsUnknown: false }) }))
23
+ vi.mock('../../context/ConnectionContext', () => ({ useConnection: () => ({ connection: { context: 'kind-demo' } }) }))
24
+ vi.mock('../../api/client', async (importOriginal) => ({
25
+ ...(await importOriginal<typeof import('../../api/client')>()),
26
+ useRadarFeature: () => ({ support: state.support }),
27
+ useResourceWithRelationships: () => ({ data: state.relationships ? { resource: {}, relationships: state.relationships } : undefined, isLoading: state.relationshipsLoading }),
28
+ useResource: (_kind: string, _ns: string, name: string, _group?: string, opts?: { enabled?: boolean }) => {
29
+ state.podRequests.push({ name, enabled: !!opts?.enabled })
30
+ return { data: opts?.enabled && state.pod?.metadata?.name === name ? state.pod : undefined }
31
+ },
32
+ useResourceEvents: () => ({ k8sEvents: state.events, updates: [], isLoading: false, k8sError: null, updatesError: null }),
33
+ }))
34
+ vi.mock('../../api/agentSandbox', async (importOriginal) => ({
35
+ ...(await importOriginal<typeof import('../../api/agentSandbox')>()),
36
+ useAgentSandboxWorkspace: () => ({ data: state.support === 'unsupported' ? undefined : state.workspace, isLoading: state.workspaceLoading }),
37
+ }))
38
+ vi.mock('./data', async (importOriginal) => ({
39
+ ...(await importOriginal<typeof import('./data')>()),
40
+ useAgentSandboxLists: () => ({
41
+ data: state.lists ?? { sandboxes: { state: 'loading' }, claims: { state: 'loading' }, warmPools: { state: 'loading' } },
42
+ isFetching: false,
43
+ refetch: () => {},
44
+ refreshQueries: [],
45
+ }),
46
+ }))
47
+
48
+ import { AgentSandboxStatusBadge, AgentSandboxSummary, drawerProblem, objectReadings, otherConditions, podExitSummary, type AgentSandboxSummaryKind } from './AgentSandboxSummary'
49
+ import { sandboxPod } from './lists'
50
+ import { NS, claim, liveClaims, liveData, liveSandboxes, warmPool } from './agentsandbox.fixtures'
51
+ import { liveAttention, liveWorkspace } from './workspace.fixtures'
52
+
53
+ // Repeats until stable, so a tag split across another tag can't survive one pass.
54
+ function stripTags(html: string): string {
55
+ let prev: string
56
+ do {
57
+ prev = html
58
+ html = html.replace(/<[^>]*>/g, '')
59
+ } while (html !== prev)
60
+ return html
61
+ }
62
+
63
+ // renderToStaticMarkup escapes apostrophes; compare against the text a reader sees.
64
+ // Source messages wrap at spaces only, a span per word (wrapAtSpaces); read them as running text.
65
+ const text = (html: string) =>
66
+ html
67
+ .replace(/&#x27;/g, "'")
68
+ .replace(/&quot;/g, '"')
69
+ .replace(/&amp;/g, '&')
70
+ .replace(/<!-- -->/g, '')
71
+ .replace(/<span class="inline-block max-w-full align-top">([^<]*)<\/span>/g, '$1')
72
+ const page = (node: ReactNode) => text(renderToStaticMarkup(<MemoryRouter>{node}</MemoryRouter>))
73
+ const words = (html: string) => stripTags(html)
74
+ const byName = (name: string) => liveSandboxes().find((s) => s.metadata.name === name)
75
+ const ISSUES = <div>OPERATIONAL ISSUES (2)</div>
76
+
77
+ function drawer(kind: AgentSandboxSummaryKind, resource: any, framed = false) {
78
+ const apiKind = { Sandbox: 'sandboxes', SandboxClaim: 'sandboxclaims', SandboxWarmPool: 'sandboxwarmpools' }[kind]
79
+ return page(
80
+ <AgentSandboxSummary kind={kind} apiKind={apiKind} namespace={NS} name={resource.metadata.name} resource={resource} framed={framed} onNavigate={() => {}} leadContent={ISSUES} />,
81
+ )
82
+ }
83
+
84
+ const podChild = (name: string): Relationships => ({ children: [{ kind: 'Pod', namespace: NS, name }], ownership: { children: { complete: true } } })
85
+ const DENIED = { state: 'failed', message: 'forbidden', denied: true } as const
86
+
87
+ beforeEach(() => {
88
+ state.support = 'supported'
89
+ state.workspace = liveWorkspace()
90
+ state.workspaceLoading = false
91
+ state.relationships = undefined
92
+ state.relationshipsLoading = false
93
+ state.pod = undefined
94
+ state.podRequests = []
95
+ state.lists = liveData()
96
+ state.events = []
97
+ })
98
+
99
+ describe('Agent Sandbox header status badge', () => {
100
+ it('matches the Warm pools list verdict (Reserve below target) instead of Warming', () => {
101
+ const html = page(<AgentSandboxStatusBadge data={warmPool('warm', { readyReplicas: 0 })} />)
102
+ expect(html).toContain('>Reserve below target<')
103
+ expect(html).not.toContain('>Warming<')
104
+ expect(html).toMatch(/orange/)
105
+ })
106
+
107
+ it('falls back to Warming when no workspace reserve row exists', () => {
108
+ state.support = 'unsupported'
109
+ const html = page(<AgentSandboxStatusBadge data={warmPool('warm', { readyReplicas: 0 })} />)
110
+ expect(html).toContain('>Warming<')
111
+ })
112
+ })
113
+
114
+ describe('Agent Sandbox drawer and expanded reading', () => {
115
+ it('uses flat sections in drawers and framed WorkspaceCards when expanded, with At a glance, About, and folded Controller conditions', () => {
116
+ state.relationships = podChild('bad-image-pod')
117
+ const flatHtml = drawer('Sandbox', byName('bad-image'), false)
118
+ expect(flatHtml).toContain('At a glance')
119
+ expect(flatHtml).toContain('About')
120
+ expect(flatHtml).toContain('Controller conditions')
121
+ expect(flatHtml).toContain('Open sandbox')
122
+ expect(flatHtml).not.toContain('rounded-xl border border-theme-border bg-theme-surface px-4 py-3 shadow-theme-sm')
123
+
124
+ const framedHtml = drawer('Sandbox', byName('bad-image'), true)
125
+ expect(framedHtml).toContain('rounded-xl border border-theme-border bg-theme-surface px-4 py-3 shadow-theme-sm')
126
+ expect(framedHtml).toContain('At a glance')
127
+ expect(framedHtml).toContain('About')
128
+ expect(framedHtml).toContain('Controller conditions')
129
+ expect(framedHtml).not.toContain('Open sandbox')
130
+ })
131
+
132
+ it('leads an image pull failure with the workspace’s reading, keeps stable At a glance rows, and links Pod + Logs', () => {
133
+ state.relationships = podChild('bad-image-pod')
134
+ const html = drawer('Sandbox', byName('bad-image'))
135
+ expect(html).toContain('Image can’t be pulled')
136
+ expect(words(html)).toContain('Next step: Check the image name and the registry credentials (imagePullSecrets)')
137
+ expect(html).toContain('Controller’s message')
138
+ expect(html).toMatch(/Pod<\/dt><dd[^>]*>.*?<button[^>]*>bad-image-pod<\/button>/)
139
+ expect(html).toContain('Logs →')
140
+ expect(html).not.toContain('Its Pod:')
141
+ expect(html).not.toContain('OPERATIONAL ISSUES')
142
+ // Stable rows: State stays visible in At a glance alongside the callout.
143
+ expect(html).toContain('>State<')
144
+ expect(html.indexOf('Image can’t be pulled')).toBeLessThan(html.indexOf('>State<'))
145
+ })
146
+
147
+ it('puts the container exit code directly in the Pod failed callout and exposes Pod logs', () => {
148
+ state.relationships = podChild('failed')
149
+ state.pod = { metadata: { name: 'failed', namespace: NS }, status: { phase: 'Failed', containerStatuses: [{ name: 'agent', state: { terminated: { exitCode: 3, reason: 'Error' } } }] } }
150
+ expect(podExitSummary(state.pod)).toBe('Container "agent" exited with code 3 (Error).')
151
+ const html = drawer('Sandbox', byName('failed'))
152
+ expect(html).toContain('Pod failed')
153
+ expect(html).toContain('Container "agent" exited with code 3 (Error).')
154
+ expect(html).toContain('>Pod logs</button>')
155
+ expect(html).toContain('Logs →')
156
+ expect(html).toMatch(/<button[^>]*>failed<\/button>/)
157
+ })
158
+
159
+ it('says the Pod is unknown when Radar couldn’t read every place it could be, and never guesses it', () => {
160
+ state.relationships = { children: [], ownership: { children: { complete: false, narrowed: true } } }
161
+ const html = drawer('Sandbox', byName('bad-image'))
162
+ expect(html).toContain('unknown: Radar couldn’t read every Pod that could belong to it')
163
+ expect(html).not.toContain('>bad-image</button>')
164
+ state.relationships = { children: [] }
165
+ expect(drawer('Sandbox', byName('bad-image'))).toContain('unknown: Radar couldn’t read every Pod')
166
+ state.relationships = undefined
167
+ state.relationshipsLoading = true
168
+ expect(drawer('Sandbox', byName('bad-image'))).toContain('Reading…')
169
+ })
170
+
171
+ it('shows Controller confirms suspension and separates unknown Pod visibility on a cleanly suspended Sandbox', () => {
172
+ state.relationships = { children: [], ownership: { children: { complete: false } } }
173
+ const html = drawer('Sandbox', byName('suspended'))
174
+ expect(html).toContain('Controller confirms suspension')
175
+ expect(html).toContain('Terminated (reported by controller)')
176
+ expect(html).toContain('Pod visibility unknown — Radar couldn’t read every Pod that could belong to it')
177
+ })
178
+
179
+ it('shows Conflicting Pod with ownership check as a CommandChip on Suspension blocked, without parenthetical kubectl in prose', () => {
180
+ state.relationships = { children: [], ownership: { children: { complete: true } } }
181
+ const html = drawer('Sandbox', byName('foreign'))
182
+ const cmd = "kubectl get pod foreign -n radar-agents-live -o jsonpath='{.metadata.ownerReferences}'"
183
+ expect(html).toContain('Suspension blocked')
184
+ expect(html).toContain('Conflicting Pod')
185
+ expect(html).toMatch(/<button[^>]*>foreign<\/button>/)
186
+ expect(html).toContain('data-command-line')
187
+ expect(html).toContain(cmd)
188
+ // Inline parenthetical command is stripped from the callout prose.
189
+ expect(words(html)).not.toContain(`(${cmd})`)
190
+ expect(html).not.toContain('no Pod Radar can read names this Sandbox')
191
+ // Without the server's reading: still shows Conflicting Pod + CommandChip, never owner-ref "none".
192
+ state.support = 'unsupported'
193
+ const local = drawer('Sandbox', byName('foreign'))
194
+ expect(local).toContain('Suspension blocked')
195
+ expect(local).toContain('Conflicting Pod')
196
+ expect(local).toContain('data-command-line')
197
+ expect(local).not.toContain('no Pod Radar can read names this Sandbox')
198
+ })
199
+
200
+ it('says there is no Pod only when every Pod Radar can read was checked', () => {
201
+ state.relationships = { children: [], ownership: { children: { complete: true } } }
202
+ expect(drawer('Sandbox', byName('expired'))).toContain('none: no Pod Radar can read names this Sandbox as its owner')
203
+ })
204
+
205
+ it('reads a Sandbox the server folds into its warm pool’s row with that row, naming the pool', () => {
206
+ const html = drawer('Sandbox', byName('warm-4xmkm'))
207
+ expect(html).toContain('Warm reserve below target: 0/2 ready')
208
+ expect(html).toContain('Scheduler: all nodes have reached their Pod limit.')
209
+ expect(words(html)).toContain('Next step: Add nodes, raise the nodes’ max-pods limit, or remove Pods you no longer need')
210
+ expect(html.indexOf('Warm reserve below target')).toBeLessThan(html.indexOf('>State<'))
211
+ expect(html).toContain('Can’t schedule')
212
+ expect(html).not.toContain('Also reported')
213
+ })
214
+
215
+ it('keeps the plain reading and Radar’s issues where the server has no row, or this Radar has no summary', () => {
216
+ state.support = 'unsupported'
217
+ state.relationships = podChild('bad-image')
218
+ const html = drawer('Sandbox', byName('bad-image'))
219
+ expect(html).toContain('OPERATIONAL ISSUES')
220
+ expect(html).toContain('Image can’t be pulled')
221
+ expect(html).toContain('ImagePullBackOff')
222
+ expect(words(html)).not.toContain('Next step')
223
+ })
224
+
225
+ it('doesn’t show Radar’s issues and then swap them out while the reading loads', () => {
226
+ state.workspace = undefined
227
+ state.workspaceLoading = true
228
+ expect(drawer('Sandbox', byName('bad-image'))).not.toContain('OPERATIONAL ISSUES')
229
+ })
230
+
231
+ it('shows requested pool with verified state, Browse warm pools link, and cleanup honesty on SandboxClaims', () => {
232
+ const missingHtml = drawer('SandboxClaim', liveClaims()[0])
233
+ expect(missingHtml).toContain('Warm pool not found')
234
+ expect(missingHtml).toContain('Requested pool')
235
+ expect(missingHtml).toContain('no-such-pool')
236
+ expect(missingHtml).toContain('not found')
237
+ expect(missingHtml).toContain('Browse warm pools in this namespace →')
238
+ expect(missingHtml).toContain('Bound sandbox')
239
+ expect(missingHtml).toContain('not bound')
240
+ expect(missingHtml).not.toContain('never bound')
241
+
242
+ // Expired claim shows controller-initiated cleanup without claiming cleanup finished.
243
+ const expiredHtml = drawer('SandboxClaim', liveClaims()[1])
244
+ expect(words(expiredHtml)).toContain('Controller initiated cleanup. Cleanup outcome unknown.')
245
+ expect(expiredHtml).toContain('>warm</button>')
246
+ expect(expiredHtml).toContain('0/2 ready')
247
+ expect(expiredHtml).toContain('Browse warm pools in this namespace →')
248
+ })
249
+
250
+ it('leaves cleanup initiation unknown when expiration is the only evidence', () => {
251
+ const html = drawer('SandboxClaim', claim('expired-no-message', { reason: 'ClaimExpired' }))
252
+ expect(html).toContain('Cleanup outcome unknown.')
253
+ expect(html).not.toContain('Controller initiated cleanup')
254
+ })
255
+
256
+ it('shows both claim expiry rules before finish and the earlier deadline after finish', () => {
257
+ const now = Date.now()
258
+ const shutdownTime = new Date(now + 2.5 * 3_600_000).toISOString()
259
+ const resource = claim('with-expiry', { shutdownTime })
260
+ resource.spec.lifecycle.ttlSecondsAfterFinished = 3600
261
+ expect(words(drawer('SandboxClaim', resource))).toContain('expires in 2h, or 1h after it finishes if sooner')
262
+
263
+ resource.status.conditions.push({ type: 'Finished', status: 'True', lastTransitionTime: new Date(now - 29.5 * 60_000).toISOString() })
264
+ const finished = words(drawer('SandboxClaim', resource))
265
+ expect(finished).toContain('expires in 30m')
266
+ expect(finished).not.toContain('after it finishes')
267
+ expect(finished).not.toContain('expires in 2h')
268
+ })
269
+
270
+ it('gives a warm pool one reserve verdict, members sorted failures-first, referencing claims, and controller warning events', () => {
271
+ state.events = [
272
+ {
273
+ id: 'ev-1',
274
+ type: 'k8s_event',
275
+ source: 'k8s_event',
276
+ timestamp: new Date(Date.now() - 5 * 60_000).toISOString(),
277
+ kind: 'SandboxWarmPool',
278
+ namespace: NS,
279
+ name: 'warm',
280
+ eventType: 'Warning',
281
+ reason: 'WarmPoolNotProgressing',
282
+ message: '2/2 sandboxes are unschedulable past the 5m0s readiness grace period',
283
+ } as TimelineEvent,
284
+ ]
285
+ const html = drawer('SandboxWarmPool', warmPool('warm', { readyReplicas: 0 }))
286
+ expect(html).toContain('Warm reserve below target: 0/2 ready')
287
+ expect(html).toContain('Reserve below target · 0/2 ready')
288
+ expect(html).toContain('Scheduler’s message')
289
+ expect(html).toContain('Members')
290
+ expect(html).toContain('warm-4xmkm')
291
+ expect(html).toContain('warm-nd2zw')
292
+ expect(html).toContain('Show not ready →')
293
+ expect(html).toContain('Claims referencing')
294
+ expect(html).toContain('1 referencing · 0 currently bound · 1 expired')
295
+ expect(html).toContain('claim-ok')
296
+ expect(html).toContain('WarmPoolNotProgressing')
297
+ expect(html).toContain('About')
298
+ expect(html).toContain('Desired replicas')
299
+ })
300
+
301
+ it('names missing permissions on WarmPool members and claims when reads are denied', () => {
302
+ state.lists = liveData({ sandboxes: DENIED, claims: DENIED })
303
+ const html = drawer('SandboxWarmPool', warmPool('warm', { readyReplicas: 0 }))
304
+ expect(html).toContain('missing list sandboxes.agents.x-k8s.io')
305
+ expect(html).toContain('missing list sandboxclaims.extensions.agents.x-k8s.io')
306
+ })
307
+ })
308
+
309
+ describe('Agent Sandbox drawer facts', () => {
310
+ const withTemplate = (name: string, containers: any[], initContainers?: any[]) => {
311
+ const s = byName(name)!
312
+ return { ...s, spec: { ...s.spec, podTemplate: { spec: { containers, ...(initContainers ? { initContainers } : {}) } } } }
313
+ }
314
+ const podOf = (name: string, statuses: any[], phase = 'Pending') => ({ metadata: { name, namespace: NS }, status: { phase, containerStatuses: statuses } })
315
+
316
+ it('shows the image the Pod template asks for, and the waiting reason and message from the Pod Radar read', () => {
317
+ state.relationships = podChild('bad-image-pod')
318
+ state.pod = podOf('bad-image-pod', [{ name: 'agent', state: { waiting: { reason: 'ImagePullBackOff', message: 'Back-off pulling image "ghcr.io/acme/agent:v9"' } } }])
319
+ const html = drawer('Sandbox', withTemplate('bad-image', [{ name: 'agent', image: 'ghcr.io/acme/agent:v9' }]))
320
+ expect(html).toMatch(/>Image<\/dt><dd[^>]*>.*?ghcr\.io\/acme\/agent:v9/)
321
+ expect(html).toContain('Waiting: ImagePullBackOff')
322
+ expect(html).toContain('Back-off pulling image "ghcr.io/acme/agent:v9"')
323
+ expect(words(html)).toContain('bad-image-pod · Pending')
324
+ expect(state.podRequests.filter((r) => r.enabled).map((r) => r.name)).toEqual(['bad-image-pod'])
325
+ })
326
+
327
+ const DNS_PULL =
328
+ 'Back-off pulling image "registry.invalid/does-not-exist:1": ErrImagePull: failed to pull and unpack image "registry.invalid/does-not-exist:1": failed to do request: Head "https://registry.invalid/v2/does-not-exist/manifests/1": dial tcp: lookup registry.invalid on 10.0.0.2:53: no such host'
329
+
330
+ it('leads with the registry’s DNS where the pull error the Pod reports shows a failed lookup, and shows that error once, whole words to a line', () => {
331
+ state.relationships = podChild('bad-image-pod')
332
+ state.pod = podOf('bad-image-pod', [{ name: 'agent', state: { waiting: { reason: 'ImagePullBackOff', message: DNS_PULL } } }])
333
+ const raw = renderToStaticMarkup(<MemoryRouter><AgentSandboxSummary kind="Sandbox" apiKind="sandboxes" namespace={NS} name="bad-image" resource={withTemplate('bad-image', [{ name: 'agent', image: 'registry.invalid/does-not-exist:1' }])} onNavigate={() => {}} /></MemoryRouter>)
334
+ const html = text(raw)
335
+ expect(words(html)).toContain('Next step: Check the registry hostname in the Pod template’s image, and that the nodes’ DNS resolves it')
336
+ expect(words(html)).not.toContain('registry credentials')
337
+ expect(html.split(DNS_PULL)).toHaveLength(2)
338
+ expect(raw).toContain('<span class="inline-block max-w-full align-top">&quot;https://registry.invalid/v2/does-not-exist/manifests/1&quot;:</span>')
339
+ })
340
+
341
+ it('keeps the server’s step where the Pod’s pull error shows no failed lookup', () => {
342
+ state.relationships = podChild('bad-image-pod')
343
+ state.pod = podOf('bad-image-pod', [{ name: 'agent', state: { waiting: { reason: 'ErrImagePull', message: 'failed to authorize: failed to fetch anonymous token: 401 Unauthorized' } } }])
344
+ const html = drawer('Sandbox', withTemplate('bad-image', [{ name: 'agent', image: 'ghcr.io/acme/agent:v9' }]))
345
+ expect(words(html)).toContain('Next step: Check the image name and the registry credentials (imagePullSecrets)')
346
+ expect(words(html)).not.toContain('DNS')
347
+ })
348
+
349
+ it('shows only the template where Radar didn’t read the Pod, and never reads a Pod it would have to guess', () => {
350
+ const tmpl = withTemplate('bad-image', [{ name: 'agent', image: 'ghcr.io/acme/agent:v9' }, { name: 'sidecar', image: 'envoy:1.30' }], [{ name: 'init', image: 'busybox' }])
351
+ state.relationships = { children: [], ownership: { children: { complete: false } } }
352
+ let html = drawer('Sandbox', tmpl)
353
+ expect(html).toContain('>Images<')
354
+ for (const image of ['ghcr.io/acme/agent:v9', 'envoy:1.30', 'busybox']) expect(html).toContain(image)
355
+ expect(words(html)).toContain('init (init)')
356
+ expect(html).not.toContain('Waiting:')
357
+ expect(state.podRequests.some((r) => r.enabled)).toBe(false)
358
+ state.podRequests = []
359
+ state.relationships = { children: [{ kind: 'Pod', namespace: NS, name: 'p1' }, { kind: 'Pod', namespace: NS, name: 'p2' }], ownership: { children: { complete: true } } }
360
+ html = drawer('Sandbox', tmpl)
361
+ expect(state.podRequests.some((r) => r.enabled)).toBe(false)
362
+ expect(html).not.toContain('Waiting:')
363
+ expect(drawer('Sandbox', byName('bad-image'))).not.toMatch(/>Images?<\/dt>/)
364
+ })
365
+
366
+ it('says what an exited container reports', () => {
367
+ state.relationships = podChild('failed')
368
+ state.pod = podOf('failed', [{ name: 'agent', state: { terminated: { exitCode: 137, reason: 'OOMKilled' } } }], 'Failed')
369
+ const html = drawer('Sandbox', withTemplate('failed', [{ name: 'agent', image: 'agent:1' }]))
370
+ expect(html.match(/exited with code 137 \(OOMKilled\)/ig)).toHaveLength(1)
371
+ })
372
+
373
+ it('says a Sandbox nothing owns has no owner and no expiry, in words', () => {
374
+ state.relationships = podChild('bad-image')
375
+ const html = drawer('Sandbox', byName('bad-image'))
376
+ expect(html).toMatch(/>Owner<\/dt><dd[^>]*>.*?none: no warm pool or claim owns it/)
377
+ expect(html).toMatch(/>Expiry<\/dt><dd[^>]*>.*?no expiry/)
378
+ expect(words(html)).not.toContain('–')
379
+ const claimed = { ...byName('bad-image'), metadata: { ...byName('bad-image').metadata, ownerReferences: [{ kind: 'SandboxClaim', name: 'c', controller: true }] } }
380
+ expect(drawer('Sandbox', claimed)).toMatch(/>Expiry<\/dt><dd[^>]*>.*?none of its own/)
381
+ })
382
+
383
+ it('says a claim names no warm pool and a pool names no template, in words', () => {
384
+ const noPool = claim('direct')
385
+ delete noPool.spec.warmPoolRef
386
+ expect(drawer('SandboxClaim', noPool)).toMatch(/>Requested pool<\/dt><dd[^>]*>.*?no warm pool/)
387
+ const bare = warmPool('bare')
388
+ delete bare.spec.sandboxTemplateRef
389
+ expect(drawer('SandboxWarmPool', bare)).toMatch(/>Template<\/dt><dd[^>]*>.*?no template/)
390
+ })
391
+ })
392
+
393
+ describe('Agent Sandbox drawer reading, its parts', () => {
394
+ it('finds an object’s own rows first, then the rows that fold it in', () => {
395
+ const ws = liveWorkspace()
396
+ expect(objectReadings(ws, { kind: 'Sandbox', namespace: NS, name: 'bad-image' }).own.map((a) => a.id)).toEqual([`sandbox:${NS}/bad-image`])
397
+ const member = objectReadings(ws, { kind: 'Sandbox', namespace: NS, name: 'warm-nd2zw' })
398
+ expect(member.own).toEqual([])
399
+ expect(member.folded.map((a) => a.id)).toEqual([`warmPool:${NS}/warm`])
400
+ const onSandbox = liveAttention().map((a) => (a.id === `sandbox:${NS}/failed` ? { ...a, relations: [{ role: 'owner' as const, ref: { kind: 'SandboxClaim', group: 'extensions.agents.x-k8s.io', namespace: NS, name: 'c' }, presence: 'present' as const }] } : a))
401
+ expect(objectReadings(liveWorkspace({ attention: onSandbox }), { kind: 'SandboxClaim', namespace: NS, name: 'c' }).folded.map((a) => a.id)).toEqual([`sandbox:${NS}/failed`])
402
+ expect(objectReadings(liveWorkspace({ attentionTotal: 500 }), { kind: 'Sandbox', namespace: NS, name: 'running' }).unknown).toBe(true)
403
+ expect(objectReadings(ws, { kind: 'Sandbox', namespace: NS, name: 'running' }).unknown).toBe(false)
404
+ })
405
+
406
+ it('drops the Pod the server names without reading it, and keeps every other related ref', () => {
407
+ const rows = liveAttention()
408
+ expect(drawerProblem(rows.find((a) => a.id === `sandbox:${NS}/bad-image`)!).related).toBeUndefined()
409
+ expect(drawerProblem(rows.find((a) => a.id === `sandbox:${NS}/foreign`)!).related).toEqual({ lead: 'The Pod it won’t delete:', refs: [{ kind: 'Pod', group: '', namespace: NS, name: 'foreign' }] })
410
+ const relabeled = { ...rows.find((a) => a.id === `sandbox:${NS}/bad-image`)!, related: { lead: 'The Pod it won’t delete:', refs: [{ kind: 'Pod', group: '', namespace: NS, name: 'x' }] } }
411
+ expect(drawerProblem(relabeled).related).toBeUndefined()
412
+ expect(drawerProblem(rows.find((a) => a.id === `warmPool:${NS}/warm`)!).related?.refs.map((r) => r.name)).toEqual(['warm-nd2zw', 'warm-4xmkm'])
413
+ })
414
+
415
+ it('takes the Pod only from owner-reference children', () => {
416
+ expect(sandboxPod(undefined, true)).toEqual({ state: 'loading' })
417
+ expect(sandboxPod(undefined, false)).toEqual({ state: 'unknown' })
418
+ expect(sandboxPod({ children: [{ kind: 'Pod', namespace: NS, name: 'p' }] }, false)).toEqual({ state: 'found', pods: [{ kind: 'Pod', namespace: NS, name: 'p' }] })
419
+ expect(sandboxPod({ children: [{ kind: 'Pod', namespace: NS, name: 'p', group: 'example.com' }], ownership: { children: { complete: true } } }, false)).toEqual({ state: 'none' })
420
+ // Uncollected kinds that can't be a Sandbox's Pod leave the answer "none".
421
+ const otherGaps = { children: { complete: false, notChecked: [{ group: 'coordination.k8s.io', kind: 'Lease', reason: 'radar_kind_not_collected' }] } }
422
+ expect(sandboxPod({ ownership: otherGaps }, false)).toEqual({ state: 'none' })
423
+ // A signed-in read is always narrowed; that alone doesn't make the Pod unknown.
424
+ expect(sandboxPod({ ownership: { children: { ...otherGaps.children, narrowed: true } } }, false)).toEqual({ state: 'none' })
425
+ expect(sandboxPod({ ownership: { children: { complete: false, notChecked: [{ kind: 'Pod', reason: 'user_forbidden' }] } } }, false)).toEqual({ state: 'unknown' })
426
+ expect(sandboxPod({ ownership: { children: { complete: false, notChecked: [{ reason: 'read_error' }] } } }, false)).toEqual({ state: 'unknown' })
427
+ expect(sandboxPod({ ownership: { children: { complete: true, truncated: true } } }, false)).toEqual({ state: 'unknown' })
428
+ })
429
+
430
+ it('lists only conditions that report a problem the reading doesn’t explain; NotSuspended is not one', () => {
431
+ const s = byName('bad-image')
432
+ expect(otherConditions(s, getSandboxStatus(s), [])).toEqual([])
433
+ const extra = { ...s, status: { conditions: [...s.status.conditions, { type: 'Degraded', status: 'True', reason: 'Quota', message: 'quota exceeded' }] } }
434
+ expect(otherConditions(extra, getSandboxStatus(extra), []).map((c) => c.type)).toEqual(['Degraded'])
435
+ const foreign = byName('foreign')
436
+ expect(otherConditions(foreign, getSandboxStatus(foreign), [])).toEqual([])
437
+ expect(otherConditions(claim('c'), getSandboxStatus(claim('c')), [])).toEqual([])
438
+ })
439
+ })