@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,876 @@
1
+ // @vitest-environment jsdom
2
+ import { act, type ReactNode } from 'react'
3
+ import { createRoot } from 'react-dom/client'
4
+ import { renderToStaticMarkup } from 'react-dom/server'
5
+ import { MemoryRouter } from 'react-router-dom'
6
+ import { beforeEach, describe, expect, it, vi } from 'vitest'
7
+ import type { KagentMCPServer, KagentWorkspace } from '../../api/kagent'
8
+ import { ApiError } from '../../api/client'
9
+ import type { SubstrateAPITier, SubstratePoolRow } from '../../api/substrateWorkspace'
10
+ import { toneFillClass } from '@skyhook-io/k8s-ui'
11
+ import { KagentGate, CoverageNotice, SessionValue, type KagentRuntime } from './shared'
12
+ import { KagentAttention, KagentOverview } from './KagentOverview'
13
+ import { KagentAgentsTable, KagentMCPServers, KagentModels } from './KagentLists'
14
+ import { KagentAgentOverview, KagentDependencyOverview } from './KagentPages'
15
+ import { agent, blockedWorkspace, ref, workspace } from './workspace.fixtures'
16
+
17
+ const state = vi.hoisted(() => ({
18
+ data: undefined as KagentWorkspace | undefined,
19
+ loading: false,
20
+ workspaceError: null as unknown,
21
+ resourceError: null as unknown,
22
+ resourceData: undefined as any,
23
+ resourceEnabled: [] as boolean[],
24
+ wide: true,
25
+ sessionSupport: 'supported',
26
+ substrateSupport: 'supported',
27
+ substrateTier: undefined as SubstrateAPITier | undefined,
28
+ pools: [] as SubstratePoolRow[],
29
+ poolError: null as unknown,
30
+ poolRequests: [] as unknown[],
31
+ }))
32
+ vi.mock('../../api/kagent', async (original) => ({
33
+ ...(await original<typeof import('../../api/kagent')>()),
34
+ useKagentWorkspace: () => ({
35
+ data: state.data,
36
+ isLoading: state.loading,
37
+ error: state.workspaceError,
38
+ dataUpdatedAt: 1,
39
+ }),
40
+ }))
41
+ vi.mock('../../api/substrateWorkspace', async (original) => ({
42
+ ...(await original<typeof import('../../api/substrateWorkspace')>()),
43
+ useSubstrateWorkspace: () => ({ data: state.substrateTier && { apiTier: state.substrateTier, pools: state.pools } }),
44
+ useSubstratePool: (pool: unknown) => {
45
+ if (pool) state.poolRequests.push(pool)
46
+ return { isLoading: false, error: pool ? state.poolError : null }
47
+ },
48
+ }))
49
+ vi.mock('../../api/client', async (original) => ({
50
+ ...(await original<typeof import('../../api/client')>()),
51
+ useResource: (_kind: string, _namespace: string, _name: string, _group: string, options: { enabled: boolean }) => {
52
+ state.resourceEnabled.push(options.enabled)
53
+ return { data: state.resourceData, error: state.resourceError, isLoading: false }
54
+ },
55
+ useRadarFeature: (feature: string) => ({ support: feature === 'kagentWorkspace' ? state.sessionSupport : feature === 'substrateWorkspace' ? state.substrateSupport : 'supported' }),
56
+ }))
57
+ vi.mock('../../context/ConnectionContext', () => ({
58
+ useConnection: () => ({ connection: { context: 'test' } }),
59
+ }))
60
+ vi.mock('../../hooks/useMediaQuery', () => ({
61
+ useMediaQuery: () => state.wide,
62
+ }))
63
+ vi.mock('./KagentAgentRenderer', () => ({
64
+ KagentAgentRenderer: () => <p>Individual dependency reads</p>,
65
+ }))
66
+ vi.mock('./shared', async (original) => ({
67
+ ...(await original<typeof import('./shared')>()),
68
+ useKagentRuntime: () => runtime(),
69
+ }))
70
+ function runtime(): KagentRuntime {
71
+ return {
72
+ rows: [],
73
+ unavailable: 'Substrate is not connected',
74
+ tier: { state: 'notConfigured' },
75
+ completePage: false,
76
+ lowerBound: true,
77
+ query: { error: null, isRefetchError: false, dataUpdatedAt: 1 },
78
+ } as unknown as KagentRuntime
79
+ }
80
+ const html = (node: ReactNode) => renderToStaticMarkup(<MemoryRouter>{node}</MemoryRouter>).replace(/<!-- -->/g, '')
81
+ const open = vi.fn()
82
+
83
+ function enterSearch(input: HTMLInputElement, value: string) {
84
+ act(() => {
85
+ Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set?.call(input, value)
86
+ input.dispatchEvent(new Event('input', { bubbles: true }))
87
+ })
88
+ }
89
+
90
+ function server(name: string, toolsOffered: string[] = []): KagentMCPServer {
91
+ return {
92
+ ref: ref('RemoteMCPServer', name),
93
+ reading: { state: 'ready', tone: 'healthy', text: 'Ready', summary: 'Tools discovered' },
94
+ failing: false,
95
+ toolsOffered,
96
+ toolsOfferedKnown: true,
97
+ usedBy: { consumers: 'none', agents: [], count: 0, lowerBound: false },
98
+ }
99
+ }
100
+
101
+ beforeEach(() => {
102
+ state.data = undefined
103
+ state.loading = false
104
+ state.workspaceError = null
105
+ state.resourceError = null
106
+ state.resourceData = undefined
107
+ state.resourceEnabled = []
108
+ state.wide = true
109
+ state.sessionSupport = 'supported'
110
+ state.substrateSupport = 'supported'
111
+ state.substrateTier = undefined
112
+ state.pools = []
113
+ state.poolError = null
114
+ state.poolRequests = []
115
+ })
116
+
117
+ describe('workspace loading, empty and version states', () => {
118
+ it('waits for capabilities and data without flashing the generic list', () => {
119
+ for (const support of ['unknown', 'supported'])
120
+ expect(
121
+ html(
122
+ <KagentGate support={support} loading installed>
123
+ {'table'}
124
+ </KagentGate>,
125
+ ),
126
+ ).toContain('Reading kagent configuration')
127
+ })
128
+ it.each(['kind_sync_pending', 'cluster_connecting'])('keeps the workspace and detail views loading during %s', (code) => {
129
+ const error = new ApiError('Kubernetes API discovery is still running', 503, { error_code: code })
130
+ const out = html(<KagentGate support="supported" loading={false} error={error}>table</KagentGate>)
131
+ expect(out).toContain('Reading kagent configuration')
132
+ expect(out).not.toContain('Could not read kagent')
133
+ state.workspaceError = error
134
+ expect(html(<KagentAgentOverview resource={{ metadata: agent().ref }} onOpen={open} />)).toContain('Reading Agent configuration')
135
+ const model = { kind: 'ModelConfig', metadata: ref('ModelConfig', 'shared') }
136
+ expect(html(<KagentDependencyOverview resource={model} onOpen={open} />)).toContain('Reading dependency configuration')
137
+ })
138
+ it('keeps old Radar on its existing views', () => {
139
+ const out = html(
140
+ <KagentGate support="unsupported" loading={false}>
141
+ {'new table'}
142
+ </KagentGate>,
143
+ )
144
+ expect(out).toContain('existing Agents list and drawer')
145
+ expect(out).not.toContain('new table')
146
+ })
147
+ it('distinguishes not installed, read failure and a complete empty inventory', () => {
148
+ expect(
149
+ html(
150
+ <KagentGate support="supported" loading={false} installed={false}>
151
+ unused
152
+ </KagentGate>,
153
+ ),
154
+ ).toContain('kagent is not installed')
155
+ expect(
156
+ html(
157
+ <KagentGate support="supported" loading={false} error={new Error('unavailable')}>
158
+ unused
159
+ </KagentGate>,
160
+ ),
161
+ ).toContain('Could not read kagent')
162
+ expect(html(<KagentAgentsTable data={workspace()} runtime={runtime()} onOpen={open} />)).toContain('No Agents in this scope')
163
+ })
164
+ })
165
+ describe('Overview evidence and folding', () => {
166
+ it.each(['unknown', 'unsupported'])('does not link to the Sessions filter when its capability is %s', (support) => {
167
+ state.sessionSupport = support
168
+ const out = html(<KagentOverview data={workspace()} runtime={runtime()} onOpen={open} />)
169
+ expect(out).not.toContain('href="/substrate/')
170
+ expect(out).toContain('Unknown')
171
+ expect(out).toContain('Substrate is not connected')
172
+ })
173
+ it.each([false, true])('links session counts to Substrate with namespace and crash filters (partial=%s)', (partial) => {
174
+ const r = runtime()
175
+ r.completePage = true
176
+ r.lowerBound = partial
177
+ r.rows = [{ agent: { namespace: 'team-a', name: 'helper' }, sessions: { total: 26 }, crashed: 2, complete: !partial }] as KagentRuntime['rows']
178
+ const out = html(<KagentOverview data={workspace()} runtime={r} namespaces={['team-a', 'team-b']} onOpen={open} />)
179
+ expect(out).toContain(`${partial ? '≥' : ''}26</span><span class="text-theme-text-secondary">Attributed sessions →</span></a>`)
180
+ expect(out).toContain(`${partial ? '≥' : ''}2 crashed →</a>`)
181
+ expect(out).toContain('href="/substrate/actors?kagent=agentSession&amp;atespaces=team-a%2Cteam-b&amp;namespaces=team-a%2Cteam-b"')
182
+ expect(out).toContain('href="/substrate/actors?kagent=agentSession&amp;atespaces=team-a%2Cteam-b&amp;state=crashed&amp;namespaces=team-a%2Cteam-b"')
183
+ expect(out).toContain('href="/substrate/actors?kagent=sessions&amp;atespaces=team-a%2Cteam-b&amp;namespaces=team-a%2Cteam-b"')
184
+ })
185
+ it('qualifies failed, processing and per-role consumer counts over a partial read', () => {
186
+ const w = blockedWorkspace()
187
+ w.counts.agents.lowerBound = true
188
+ w.coverage.agents.state = 'partial'
189
+ w.counts.agentsByLatestChange = { failed: 2, preparing: 3 }
190
+ w.models[0].usedBy.lowerBound = true
191
+ w.models[0].usedBy.byRole = { model: 1, summarizer: 1 }
192
+ const overview = html(<KagentOverview data={w} runtime={runtime()} onOpen={open} />)
193
+ expect(overview).toContain('≥2 failed')
194
+ expect(overview).toContain('≥3 processing')
195
+ expect(html(<KagentModels data={w} onOpen={open} />)).toContain('Agent model: ≥1')
196
+ })
197
+ it('accounts for every remaining Agent state in the headline', () => {
198
+ const w = workspace()
199
+ w.counts.agentsByLatestChange = { notProcessed: 1, notReported: 2, notReady: 3, deleting: 4, unknown: 5 }
200
+ const out = html(<KagentOverview data={w} runtime={runtime()} onOpen={open} />)
201
+ for (const text of ['1 not yet processed', '2 not reported', '3 not ready', '4 deleting', '5 unknown']) expect(out).toContain(text)
202
+ })
203
+ it('does not count stale credential conditions as current findings', () => {
204
+ const w = blockedWorkspace()
205
+ w.findings = []
206
+ w.groups = []
207
+ w.models[0].reading.state = 'stale'
208
+ const out = html(<KagentOverview data={w} runtime={runtime()} onOpen={open} />)
209
+ expect(out).toContain('0</span> of 1</span><span class="text-theme-text-secondary">Models with credential problems</span></a>')
210
+ })
211
+ it('shows inventory totals alongside counts and omits partial denominators', () => {
212
+ const w = blockedWorkspace()
213
+ w.counts.agents.n = 4
214
+ w.counts.agentsByLatestChange = { prepared: 3, blocked: 1 }
215
+ w.counts.mcpServers.n = 5
216
+ w.counts.mcpServersFailing.n = 3
217
+ w.counts.models.n = 5
218
+ const card = (label: string) => {
219
+ const d = new DOMParser().parseFromString(html(<KagentOverview data={w} runtime={runtime()} onOpen={open} />), 'text/html')
220
+ return [...d.querySelectorAll('[aria-label="kagent status"] > a')].find((link) => link.textContent?.includes(label))
221
+ }
222
+ expect(card('Agents')?.textContent).toBe('4Agents3 prepared1 blocked')
223
+ expect(card('Failing MCP servers')?.textContent).toBe('3 of 5Failing MCP servers')
224
+ expect(card('Models with credential problems')?.textContent).toBe('1 of 5Models with credential problems')
225
+ w.coverage.mcpServers.state = 'partial'
226
+ w.counts.mcpServers.lowerBound = true
227
+ w.counts.mcpServersFailing.lowerBound = true
228
+ w.coverage.models.state = 'partial'
229
+ w.counts.models.lowerBound = true
230
+ for (const label of ['Failing MCP servers', 'Models with credential problems']) {
231
+ expect(card(label)?.textContent).not.toContain(' of ')
232
+ expect(card(label)?.querySelector('[aria-label="Lower bound"]')).not.toBeNull()
233
+ }
234
+ })
235
+ it('keeps a matched Agent beneath the model and presents impact and next step', () => {
236
+ const out = html(<KagentOverview data={blockedWorkspace()} runtime={runtime()} onOpen={open} />)
237
+ expect(out).toContain('first reported cause')
238
+ expect(out).toContain('blocked-edit')
239
+ expect(out).toContain('Create Secret models/missing')
240
+ expect(out).toContain('2 configuration findings in 1 group')
241
+ expect(out).not.toContain('Detected by Radar')
242
+ expect(out.indexOf('Affects ')).toBeLessThan(out.indexOf('Next step:'))
243
+ expect(out.indexOf('Next step:')).toBeLessThan(out.indexOf('kagent&#x27;s message'))
244
+ expect(out).not.toContain('healthy conversations')
245
+ })
246
+ it('shows the sharing finding only on Agents with a refused reference', () => {
247
+ const w = blockedWorkspace()
248
+ const refused = w.agents[0]
249
+ const permitted = agent('permitted')
250
+ const model = w.models[0].ref
251
+ const r = refused.references[0]
252
+ r.state = 'notPermitted'
253
+ permitted.references = [{ ...r, from: permitted.ref, state: 'present' }]
254
+ w.agents.push(permitted)
255
+ w.findings = [{
256
+ id: 'sharing', subject: model, reason: 'KagentDependencyNotPermitted', severity: 'warning',
257
+ message: 'Sharing policy refuses the reference', action: 'Allow the namespace.',
258
+ }]
259
+ w.groups = [{ id: 'sharing', findings: ['sharing'], severity: 'warning' }]
260
+ expect(html(<KagentAttention data={w} agent={refused.ref} onOpen={open} />)).toContain('Sharing policy refuses the reference')
261
+ expect(html(<KagentAttention data={w} agent={permitted.ref} onOpen={open} />)).toBe('')
262
+ })
263
+ it("shows the first kagent message inline and folds the remaining unique lines", () => {
264
+ const w = blockedWorkspace()
265
+ const other = agent('other')
266
+ const third = agent('third')
267
+ w.agents[0].reading.message = 'Repeated compiler detail'
268
+ w.models[0].reading.message = 'Repeated compiler detail'
269
+ other.reading.message = 'Distinct compiler detail'
270
+ third.reading.message = 'Distinct compiler detail'
271
+ w.agents.push(other, third)
272
+ for (const a of [other, third]) {
273
+ w.findings.push({ ...w.findings[0], id: a.ref.name, subject: a.ref })
274
+ w.groups[0].folded!.push({ finding: a.ref.name, under: 'model' })
275
+ }
276
+ const out = html(<KagentAttention data={w} onOpen={open} />)
277
+ expect(out).toMatch(/<p[^>]*>Repeated compiler detail<\/p>/)
278
+ expect(out).toMatch(/whitespace-pre-line[^>]*>Repeated compiler detail\nDistinct compiler detail<\/div>/)
279
+ expect(out.match(/Distinct compiler detail/g)).toHaveLength(1)
280
+ expect(out.indexOf('Repeated compiler detail')).toBeLessThan(out.indexOf('Affects '))
281
+ })
282
+ it("shows a short, single-line redacted kagent message without a disclosure", () => {
283
+ const w = blockedWorkspace()
284
+ w.groups[0].folded = []
285
+ w.models[0].reading.message = 'lookup tools.invalid: no such host ([REDACTED])'
286
+ const out = html(<KagentAttention data={w} onOpen={open} />)
287
+ expect(out).toMatch(/<p[^>]*>lookup tools\.invalid: no such host \(\[REDACTED\]\)<\/p>/)
288
+ expect(out).not.toContain('aria-expanded')
289
+ })
290
+ it('shows the DNS cause in a long MCP discovery preview and keeps the full chain in the disclosure', () => {
291
+ const w = workspace()
292
+ const mcp = server('spike-unreachable-mcp')
293
+ const message = 'Failed to connect to MCP server: failed to connect MCP client: calling "initialize": sending "initialize": rejected by transport: Post "http://no-such-mcp.radar-kagent-spike.svc.cluster.local:9999/mcp": dial tcp: lookup no-such-mcp.radar-kagent-spike.svc.cluster.local on 172.20.0.10:53: no such host'
294
+ mcp.reading = { ...mcp.reading, state: 'failed', message }
295
+ w.mcpServers = [mcp]
296
+ w.findings = [{ id: 'mcp', subject: mcp.ref, reason: 'KagentToolDiscoveryFailed', severity: 'warning', message, action: 'Check the server URL.' }]
297
+ w.groups = [{ id: 'mcp', severity: 'warning', findings: ['mcp'] }]
298
+ const doc = new DOMParser().parseFromString(html(<KagentAttention data={w} agent={mcp.ref} onOpen={open} />), 'text/html')
299
+ expect(doc.querySelector('p.break-words')?.textContent).toBe('Failed to connect to MCP server: failed to connect MCP client … lookup no-such-mcp.radar-kagent-spike.svc.cluster.local on 172.20.0.10:53: no such host')
300
+ expect(doc.querySelector('.whitespace-pre-line')?.textContent).toBe(message)
301
+ })
302
+ it('qualifies an empty partial answer and names missing list permission', () => {
303
+ const w = workspace()
304
+ w.counts.findings.lowerBound = true
305
+ w.coverage.models = { state: 'denied', deniedNamespaces: ['models'] }
306
+ const out = html(
307
+ <>
308
+ <CoverageNotice coverage={w.coverage} />
309
+ <KagentOverview data={w} runtime={runtime()} onOpen={open} />
310
+ </>,
311
+ )
312
+ expect(out).toContain('Nothing in what Radar can read needs attention')
313
+ expect(out).toContain('list modelconfigs (api.kagent.dev)')
314
+ expect(out).toContain('in namespace models')
315
+ })
316
+ it('shows all-good evidence and unavailable runtime without fabricating session zeroes', () => {
317
+ const w = workspace()
318
+ w.agents = [agent()]
319
+ w.counts.agents.n = 1
320
+ w.counts.agentsByLatestChange = { prepared: 1 }
321
+ const out = html(<KagentOverview data={w} runtime={runtime()} onOpen={open} />)
322
+ expect(out).toContain('Nothing needs attention')
323
+ expect(out).toContain('1</span><span class="text-theme-text-secondary">Agents</span>')
324
+ expect(out).toContain('1 prepared')
325
+ expect(out).toContain('Substrate is not connected')
326
+ expect(out).not.toContain('0 sessions')
327
+ })
328
+ })
329
+ describe.each([true, false])('inventory tables, wide=%s', (wide) => {
330
+ it('separates blocked edits from the previous new-sessions revision', () => {
331
+ state.wide = wide
332
+ const out = html(<KagentAgentsTable data={blockedWorkspace()} runtime={runtime()} onOpen={open} />)
333
+ expect(out).toContain('Blocked')
334
+ expect(out).toContain('abcdef012345')
335
+ expect(out).toContain('API key Secret missing')
336
+ })
337
+ it('never turns failed discovery into zero offered tools', () => {
338
+ state.wide = wide
339
+ const w = workspace()
340
+ w.mcpServers = [
341
+ {
342
+ ref: ref('RemoteMCPServer', 'mcp'),
343
+ reading: {
344
+ state: 'failed',
345
+ tone: 'alert',
346
+ text: 'Discovery failed',
347
+ summary: 'Cannot discover tools',
348
+ },
349
+ failing: true,
350
+ toolsOffered: [],
351
+ toolsOfferedKnown: false,
352
+ usedBy: {
353
+ count: 0,
354
+ lowerBound: true,
355
+ consumers: 'noneSeen',
356
+ agents: [],
357
+ },
358
+ },
359
+ ]
360
+ const out = html(<KagentMCPServers data={w} onOpen={open} />)
361
+ expect(out).toContain('Discovery failed')
362
+ expect(out).toContain('Unknown')
363
+ expect(out).toContain('No Agent consumers seen')
364
+ })
365
+ it('shows Secret coordinates and missing keys, never credential values', () => {
366
+ state.wide = wide
367
+ const out = html(<KagentModels data={blockedWorkspace()} onOpen={open} />)
368
+ expect(out).toContain('models/missing')
369
+ expect(out).toContain('OPENAI_API_KEY')
370
+ expect(out).not.toContain('Agent model: 1')
371
+ expect(out).toContain('kagent 1.0.1 does not report')
372
+ })
373
+ })
374
+ describe('object pages', () => {
375
+ it.each(['unknown', 'unsupported'])('does not link a declared pool to an unavailable Substrate workspace (%s)', (support) => {
376
+ state.substrateSupport = support
377
+ state.data = workspace()
378
+ const a = agent()
379
+ a.references = [{ from: a.ref, target: { ...ref('WorkerPool', 'pool'), group: 'ate.dev' }, role: 'workerPool', field: 'workerPool', state: 'declared' }]
380
+ state.data.agents = [a]
381
+ const out = html(<KagentAgentOverview resource={{ metadata: a.ref }} onOpen={open} />)
382
+ expect(out).not.toContain('href="/substrate/')
383
+ expect(out).toContain('WorkerPool agents/pool')
384
+ })
385
+ it.each(['outside_namespace_pin', 'forbidden', 'notFound'])('does not reuse a withheld Harness image in About (%s)', (failure) => {
386
+ state.data = workspace()
387
+ const a = agent()
388
+ a.references = [{ from: a.ref, target: ref('Harness', 'harness'), role: 'harness', field: 'spec.harnessRef', state: 'unread', unread: failure === 'outside_namespace_pin' ? failure : 'denied' }]
389
+ state.data.agents = [a]
390
+ state.resourceData = { apiVersion: 'api.kagent.dev/v1alpha3', kind: 'Harness', spec: { workload: { image: 'WITHHELD_IMAGE' } } }
391
+ state.resourceError = failure === 'outside_namespace_pin' ? null : new ApiError(failure, failure === 'forbidden' ? 403 : 404)
392
+ const out = html(<KagentAgentOverview resource={{ metadata: a.ref }} onOpen={open} />)
393
+ expect(out).not.toContain('WITHHELD_IMAGE')
394
+ })
395
+ it.each(['notReported', 'discoveryOff', 'stale'])('keeps missing-tool counts unknown when discovery is %s', (discovery) => {
396
+ state.data = workspace()
397
+ const a = agent()
398
+ const target = ref('RemoteMCPServer', 'tools')
399
+ a.references = [{ from: a.ref, target, role: 'mcpServer', field: 'tools', state: 'present' }]
400
+ a.mcpServers.declared = 1
401
+ state.data.agents = [a]
402
+ state.data.mcpServers = [{ ref: target, reading: { state: discovery, text: 'Not reported', summary: 'Not reported', tone: 'unknown' }, toolsOfferedKnown: false, toolsOffered: [], failing: false, usedBy: { count: 1, lowerBound: false, consumers: 'seen', agents: [] } }]
403
+ const out = html(<KagentAgentOverview resource={{ metadata: a.ref }} onOpen={open} />)
404
+ expect(out).toContain('Missing tools unknown')
405
+ expect(out).not.toContain('0 missing tools')
406
+ })
407
+ it('qualifies discovery failure totals when the reference chain is incomplete', () => {
408
+ state.data = workspace()
409
+ const a = agent()
410
+ a.incomplete = true
411
+ a.mcpServers = { declared: 1, failing: 1, absent: 0, unread: 0, notPermitted: 0 }
412
+ state.data.agents = [a]
413
+ const out = html(<KagentAgentOverview resource={{ metadata: a.ref }} onOpen={open} />)
414
+ expect(out).toContain('≥1 failing')
415
+ })
416
+ it('keeps cross-namespace reference coordinates visible in the configuration chain', () => {
417
+ state.data = workspace()
418
+ const a = agent()
419
+ a.references = [{ from: ref('AgentTemplate', 'template', 'template-ns'), target: ref('RemoteMCPServer', 'tools', 'tools-ns'), role: 'mcpServer', field: 'tools', state: 'unread', unread: 'denied' }]
420
+ state.data.agents = [a]
421
+ const out = html(<KagentAgentOverview resource={{ metadata: a.ref }} onOpen={open} />)
422
+ expect(out).toContain('tools-ns/tools')
423
+ expect(out).toContain('via template template · template-ns')
424
+ })
425
+ it('waits for the dependency workspace before showing a get-only fallback', () => {
426
+ state.loading = true
427
+ const out = html(<KagentDependencyOverview resource={{ kind: 'ModelConfig', metadata: ref('ModelConfig', 'model') }} onOpen={open} />)
428
+ expect(out).toContain('Reading dependency configuration')
429
+ expect(out).not.toContain('Used by: unknown')
430
+ expect(out).not.toContain('No API key Secret declared')
431
+ })
432
+ it('keeps dependencies outside the namespace pin unread, including after a cached 404', () => {
433
+ state.data = blockedWorkspace()
434
+ const a = state.data.agents[0]
435
+ a.references[0].state = 'unread'
436
+ a.references[0].unread = 'outside_namespace_pin'
437
+ a.references[0].reading = undefined
438
+ state.data.models = []
439
+ state.resourceError = new ApiError('outside namespace scope', 404)
440
+ state.resourceData = { apiVersion: 'api.kagent.dev/v1alpha3', kind: 'ModelConfig', spec: { provider: 'OUTSIDE_PROVIDER', apiKeySecret: 'OUTSIDE_SECRET' } }
441
+ const out = html(<KagentAgentOverview resource={{ metadata: a.ref }} onOpen={open} />)
442
+ expect(out).toContain('Not read: outside_namespace_pin')
443
+ expect(out).not.toContain('Absent')
444
+ expect(out).not.toContain('OUTSIDE_PROVIDER')
445
+ expect(out).not.toContain('OUTSIDE_SECRET')
446
+ expect(state.resourceEnabled.length).toBeGreaterThan(0)
447
+ expect(state.resourceEnabled.every(enabled => !enabled)).toBe(true)
448
+ })
449
+ it('redacts credentials in direct Harness and MCP reads as well as the get-only MCP page', () => {
450
+ state.data = workspace()
451
+ const a = agent()
452
+ a.references = [{ from: a.ref, target: ref('Harness', 'harness'), role: 'harness', field: 'spec.harnessRef', state: 'present' }]
453
+ state.data.agents = [a]
454
+ state.resourceData = { apiVersion: 'api.kagent.dev/v1alpha3', kind: 'Harness', spec: { workload: { image: 'https://user:IMAGE_PASSWORD@registry.invalid/image?token=IMAGE_TOKEN' } } }
455
+ const harness = html(<KagentAgentOverview resource={{ metadata: a.ref }} onOpen={open} />)
456
+ expect(harness).toContain('[REDACTED]')
457
+ expect(harness).not.toContain('IMAGE_PASSWORD')
458
+ expect(harness).not.toContain('IMAGE_TOKEN')
459
+ const server = { apiVersion: 'api.kagent.dev/v1alpha3', kind: 'RemoteMCPServer', metadata: ref('RemoteMCPServer', 'tools'), status: { conditions: [{ type: 'Accepted', status: 'True' }], discoveredTools: [{ name: 'https://user:TOOL_PASSWORD@tools.invalid?token=TOOL_TOKEN' }] } }
460
+ a.references = [{ from: a.ref, target: server.metadata, role: 'mcpServer', field: 'tools', state: 'unread', unread: 'denied' }]
461
+ state.resourceData = server
462
+ const chain = html(<KagentAgentOverview resource={{ metadata: a.ref }} onOpen={open} />)
463
+ state.data = undefined
464
+ const page = html(<KagentDependencyOverview resource={server} onOpen={open} />)
465
+ for (const out of [chain, page]) {
466
+ expect(out).toContain('[REDACTED]')
467
+ expect(out).not.toContain('TOOL_PASSWORD')
468
+ expect(out).not.toContain('TOOL_TOKEN')
469
+ }
470
+ expect(server.status.discoveredTools[0].name).toContain('TOOL_PASSWORD')
471
+ })
472
+ it('shows the Agent loading state before composing a chain', () => {
473
+ state.loading = true
474
+ const out = html(<KagentAgentOverview resource={{ metadata: { namespace: 'agents', name: 'helper' } }} onOpen={open} />)
475
+ expect(out).toContain('Reading Agent configuration')
476
+ expect(out).not.toContain('No revision prepared')
477
+ })
478
+ it.each(['preparing', 'notProcessed'])('qualifies the configuration while the latest change is %s', (latest) => {
479
+ state.data = blockedWorkspace()
480
+ state.data.agents[0].latestChange.state = latest
481
+ state.data.agents[0].reading.state = latest === 'notProcessed' ? 'stale' : 'preparing'
482
+ const out = html(<KagentAgentOverview resource={{ metadata: { namespace: 'agents', name: 'blocked-edit' } }} onOpen={open} />)
483
+ expect(out).toContain(
484
+ latest === 'notProcessed'
485
+ ? 'Configuration of the latest change (not yet processed)'
486
+ : 'Configuration of the latest change (processing)',
487
+ )
488
+ expect(out).toContain('New sessions still run revision abcdef012345')
489
+ })
490
+ it('folds offered tools while keeping asked-for and missing tools visible', () => {
491
+ state.data = workspace()
492
+ const a = agent()
493
+ const target = ref('RemoteMCPServer', 'tools')
494
+ a.references = [
495
+ {
496
+ from: a.ref,
497
+ target,
498
+ role: 'mcpServer',
499
+ field: 'template.inline.tools',
500
+ state: 'present',
501
+ tools: ['missing-tool'],
502
+ },
503
+ ]
504
+ state.data.agents = [a]
505
+ state.data.mcpServers = [
506
+ {
507
+ ref: target,
508
+ reading: {
509
+ state: 'ready',
510
+ tone: 'healthy',
511
+ text: 'Accepted',
512
+ summary: 'Tools discovered',
513
+ },
514
+ failing: false,
515
+ toolsOfferedKnown: true,
516
+ toolsOffered: ['get-pods', 'get-events'],
517
+ usedBy: { count: 1, lowerBound: false, consumers: 'seen', agents: [] },
518
+ },
519
+ ]
520
+ const out = html(
521
+ <KagentAgentOverview
522
+ resource={{
523
+ metadata: { namespace: a.ref.namespace, name: a.ref.name },
524
+ }}
525
+ onOpen={open}
526
+ />,
527
+ )
528
+ const doc = new DOMParser().parseFromString(out, 'text/html')
529
+ expect(doc.body.textContent).toContain('Tools asked: missing-tool (missing)')
530
+ expect(out).toContain('Not offered: missing-tool')
531
+ expect(out).toContain('Tools offered (2)')
532
+ expect([...doc.querySelectorAll('li .truncate')].map((tool) => tool.textContent)).toEqual(['get-pods', 'get-events'])
533
+ expect(out).not.toContain('Filter offered tools')
534
+ expect(out).toContain('aria-expanded="false"')
535
+ })
536
+ it('explains a blocked latest change without reconstructing the prepared configuration', () => {
537
+ state.data = blockedWorkspace()
538
+ const out = html(<KagentAgentOverview resource={{ metadata: { namespace: 'agents', name: 'blocked-edit' } }} onOpen={open} />)
539
+ expect(out).toContain('Configuration of the latest change (blocked)')
540
+ expect(out).toContain('prepared before this change')
541
+ expect(out).toContain('Conversation outcomes</dt>')
542
+ expect(out).toContain('Not visible to Radar')
543
+ expect(out).not.toContain('prepared 2')
544
+ })
545
+ it('reads a list-denied dependency individually and names its missing get grant', () => {
546
+ state.data = blockedWorkspace()
547
+ const a = state.data.agents[0]
548
+ a.references[0].state = 'unread'
549
+ a.references[0].unread = 'denied'
550
+ state.data.models = []
551
+ state.resourceError = new ApiError('forbidden', 403)
552
+ state.resourceData = { apiVersion: 'api.kagent.dev/v1alpha3', kind: 'ModelConfig', spec: { provider: 'WITHHELD_PROVIDER' } }
553
+ const out = html(<KagentAgentOverview resource={{ metadata: { namespace: 'agents', name: a.ref.name } }} onOpen={open} />)
554
+ expect(out).toContain('get modelconfigs (api.kagent.dev)')
555
+ expect(out).toContain('Unread')
556
+ expect(out).not.toContain('WITHHELD_PROVIDER')
557
+ })
558
+ it('keeps individual reads available when the Agent list is denied', () => {
559
+ state.data = workspace()
560
+ expect(html(<KagentAgentOverview resource={{ metadata: { namespace: 'agents', name: 'helper' } }} onOpen={open} />)).toContain(
561
+ 'Individual dependency reads',
562
+ )
563
+ })
564
+ it.each([
565
+ [{ actorJwt: { audiences: ['demo'] } }, 'Actor identity'],
566
+ [{ tokenPassthrough: true }, 'Token passthrough'],
567
+ [{}, 'No credential declared'],
568
+ [{ apiKeySecret: 'demo-key', apiKeySecretKey: 'KEY', actorJwt: {} }, 'models/demo-key'],
569
+ ])('uses inventory credential wording for a get-only model: %j', (spec, text) => {
570
+ expect(html(<KagentDependencyOverview resource={{ kind: 'ModelConfig', metadata: { namespace: 'models', name: 'get-only' }, spec }} onOpen={open} />)).toContain(text)
571
+ })
572
+ it('shows model reading, credential reference and consumers', () => {
573
+ state.data = blockedWorkspace()
574
+ const out = html(
575
+ <KagentDependencyOverview
576
+ resource={{
577
+ kind: 'ModelConfig',
578
+ metadata: { namespace: 'models', name: 'broken-model' },
579
+ }}
580
+ onOpen={open}
581
+ />,
582
+ )
583
+ expect(out).toContain('Used by')
584
+ expect(out).toContain('Agent model')
585
+ expect(out).toContain('models/missing')
586
+ })
587
+ it('uses the shared credential Issue title and omits a single finding’s Secret heading', () => {
588
+ const w = blockedWorkspace()
589
+ state.data = w
590
+ w.findings[1].kagentReason = 'APIKeySecretKeyNotFound'
591
+ w.models[0].reading.reason = 'APIKeySecretKeyNotFound'
592
+ w.groups[0].secret = w.models[0].credential.secret
593
+ const out = html(<KagentDependencyOverview resource={{ kind: 'ModelConfig', metadata: w.models[0].ref }} onOpen={open} />)
594
+ expect(out).toContain('API key Secret or key missing')
595
+ expect(out).not.toContain('API key Secret:</')
596
+ })
597
+ it('leaves absent runtime rows unknown after all summary pages arrive', () => {
598
+ const r = runtime()
599
+ r.completePage = true
600
+ expect(html(<SessionValue runtime={r} />)).toContain('No summary for this Agent')
601
+ })
602
+ })
603
+
604
+ it('shows a model sharing refusal ahead of its own healthy reading and names a denied list grant', () => {
605
+ const w = blockedWorkspace()
606
+ w.agents[0].model!.reading = { state: 'ready', tone: 'healthy', text: 'Accepted', summary: 'Accepted' }
607
+ expect(html(<KagentAgentsTable data={w} runtime={runtime()} onOpen={open} />)).toContain('References resolved')
608
+ w.agents[0].model!.state = 'notPermitted'
609
+ const refused = html(<KagentAgentsTable data={w} runtime={runtime()} onOpen={open} />)
610
+ expect(refused).toContain('Not permitted by allowedNamespaces')
611
+ expect(refused).not.toContain('References resolved')
612
+ w.agents[0].model!.state = 'unread'
613
+ w.agents[0].model!.unread = 'denied'
614
+ expect(html(<KagentAgentsTable data={w} runtime={runtime()} onOpen={open} />)).toContain('list modelconfigs (api.kagent.dev)')
615
+ })
616
+
617
+ it('keeps a declared dependency’s banner on an Agent beyond the capped impact links', () => {
618
+ state.data = blockedWorkspace()
619
+ state.data.findings[1].affects!.agents = [
620
+ {
621
+ agent: ref('Agent', 'another-agent'),
622
+ effect: 'usesIt',
623
+ roles: ['model'],
624
+ },
625
+ ]
626
+ state.data.findings[1].affects!.count = 1000
627
+ state.data.groups[0].folded = []
628
+ const out = html(<KagentAgentOverview resource={{ metadata: { namespace: 'agents', name: 'blocked-edit' } }} onOpen={open} />)
629
+ expect(out).toContain('Create Secret models/missing')
630
+ })
631
+
632
+ it('keeps Agents beyond capped impact links in the Problems filter', () => {
633
+ const w = blockedWorkspace()
634
+ w.findings = [w.findings[1]]
635
+ w.findings[0].affects!.agents = [{ agent: ref('Agent', 'another-agent'), effect: 'usesIt', roles: ['model'] }]
636
+ w.findings[0].affects!.count = 1000
637
+ const out = renderToStaticMarkup(<MemoryRouter initialEntries={['/kagent/agents?status=problems']}><KagentAgentsTable data={w} runtime={runtime()} onOpen={open} /></MemoryRouter>)
638
+ expect(out).toContain('blocked-edit')
639
+ })
640
+
641
+ it('offers the generic views after a failed capability check instead of loading forever', () => {
642
+ const out = html(
643
+ <KagentGate support="unknown" checking={false} loading={false}>
644
+ unused
645
+ </KagentGate>,
646
+ )
647
+ expect(out).toContain('Could not check kagent workspace support')
648
+ expect(out).toContain('Open Agents')
649
+ })
650
+
651
+ it('uses prose for an unprepared revision and omits placement', () => {
652
+ state.data = workspace()
653
+ const a = agent()
654
+ a.newSessionsRevision = undefined
655
+ a.references = [
656
+ {
657
+ from: a.ref,
658
+ target: { ...ref('WorkerPool', 'pool'), group: 'ate.dev' },
659
+ role: 'workerPool',
660
+ field: 'substrate.workerPoolRef',
661
+ state: 'declared',
662
+ },
663
+ ]
664
+ state.data.agents = [a]
665
+ const out = html(<KagentAgentOverview resource={{ metadata: a.ref }} onOpen={open} />)
666
+ expect(out).toContain('No revision prepared</span>')
667
+ expect(out).not.toContain('font-mono">No revision prepared')
668
+ expect(out).not.toContain('Placement')
669
+ expect(out).toContain('/substrate/workerpools/agents/pool?ctx=test')
670
+ expect(out).toContain('Substrate&#x27;s pools aren&#x27;t readable with this connection')
671
+ })
672
+
673
+ it('keeps one copy of a dependency finding and labels URL removal only when it changed', () => {
674
+ state.data = blockedWorkspace()
675
+ const model = state.data.models[0]
676
+ model.reading.message = 'Unique controller message'
677
+ const out = html(<KagentDependencyOverview resource={{ kind: model.ref.kind, metadata: model.ref }} onOpen={open} />)
678
+ expect(out.match(/<p[^>]*>Unique controller message<\/p>/g)).toHaveLength(1)
679
+ expect(out.match(/whitespace-pre-line[^>]*>Unique controller message\n/g)).toHaveLength(1)
680
+ expect(out.match(/kagent&#x27;s message/g)).toHaveLength(1)
681
+ state.data = workspace()
682
+ for (const [url, label] of [
683
+ ['https://mcp.example/path', 'URL'],
684
+ ['https://user:pass@mcp.example/path?token=x', 'URL (credentials removed)'],
685
+ ]) {
686
+ const page = html(
687
+ <KagentDependencyOverview
688
+ resource={{
689
+ kind: 'RemoteMCPServer',
690
+ metadata: { namespace: 'agents', name: 'mcp' },
691
+ spec: { url },
692
+ }}
693
+ onOpen={open}
694
+ />,
695
+ )
696
+ expect(page).toContain(label)
697
+ expect(page).not.toContain('URL (redacted)')
698
+ if (label === 'URL') expect(page).not.toContain('credentials removed')
699
+ }
700
+ })
701
+
702
+ it('uses the singular for exactly one session', () => {
703
+ const r = runtime()
704
+ const row = {
705
+ sessions: { total: 1 },
706
+ crashed: 0,
707
+ complete: true,
708
+ } as KagentRuntime['rows'][number]
709
+ expect(html(<SessionValue row={row} runtime={r} />)).toContain('1</span> session')
710
+ expect(html(<SessionValue row={row} runtime={r} />)).not.toContain('sessions')
711
+ })
712
+
713
+ it('links overview problems to filtered lists and filters to the matching findings', () => {
714
+ const w = blockedWorkspace()
715
+ const out = html(<KagentOverview data={w} runtime={runtime()} onOpen={open} />)
716
+ expect(out).toContain('/kagent/mcpservers?status=problems')
717
+ expect(out).toContain('/kagent/models?status=problems')
718
+ w.models.push({ ...w.models[0], ref: ref('ModelConfig', 'healthy-model') })
719
+ const filtered = renderToStaticMarkup(
720
+ <MemoryRouter initialEntries={['/kagent/models?status=problems']}>
721
+ <KagentModels data={w} onOpen={open} />
722
+ </MemoryRouter>,
723
+ )
724
+ expect(filtered).toContain('broken-model')
725
+ expect(filtered).not.toContain('healthy-model')
726
+ })
727
+
728
+ it.each([
729
+ ['Search Agents', 'BROKEN-MODEL', 'blocked-edit', 'other-agent', 1],
730
+ ['Search MCP servers', 'GET-EVENTS', 'matching-server', 'other-server', 0],
731
+ ['Search models', 'MISSING', 'broken-model', 'other-model', 1],
732
+ ] as const)('%s matches fields and updates both segment counts', (label, query, match, other, problems) => {
733
+ const w = blockedWorkspace()
734
+ w.agents.push(agent('other-agent'))
735
+ w.mcpServers = [server('matching-server', ['get-events']), server('other-server')]
736
+ w.models.push({ ...w.models[0], ref: ref('ModelConfig', 'other-model'), credential: { mode: 'none' } })
737
+ const view = label === 'Search Agents' ? <KagentAgentsTable data={w} runtime={runtime()} onOpen={open} />
738
+ : label === 'Search MCP servers' ? <KagentMCPServers data={w} onOpen={open} />
739
+ : <KagentModels data={w} onOpen={open} />
740
+ const host = document.createElement('div')
741
+ const root = createRoot(host)
742
+ vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
743
+ try {
744
+ act(() => root.render(<MemoryRouter>{view}</MemoryRouter>))
745
+ const tabs = () => [...host.querySelectorAll('[role="tab"]')].map((t) => t.textContent)
746
+ expect(tabs()).toEqual(['All2', `Problems${problems}`])
747
+ expect(host.textContent).toContain(other)
748
+ enterSearch(host.querySelector<HTMLInputElement>(`[aria-label="${label}"]`)!, ` ${query} `)
749
+ expect(tabs()).toEqual(['All1', `Problems${problems}`])
750
+ expect(host.textContent).toContain(match)
751
+ expect(host.textContent).not.toContain(other)
752
+ } finally {
753
+ act(() => root.unmount())
754
+ vi.unstubAllGlobals()
755
+ }
756
+ })
757
+
758
+ it('filters a long tool list inside its disclosure', () => {
759
+ state.data = workspace()
760
+ const longTool = 'argo_verify_argo_rollouts_controller_install'
761
+ const mcp = server('tools', [...Array.from({ length: 20 }, (_, i) => `get-resource-${i}`), longTool])
762
+ state.data.mcpServers = [mcp]
763
+ const host = document.createElement('div')
764
+ const root = createRoot(host)
765
+ vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
766
+ try {
767
+ act(() => root.render(<MemoryRouter><KagentDependencyOverview resource={{ kind: 'RemoteMCPServer', metadata: mcp.ref }} onOpen={open} /></MemoryRouter>))
768
+ const toggle = [...host.querySelectorAll('button')].find((b) => b.textContent?.includes('Tools offered (21)'))!
769
+ expect(toggle.getAttribute('aria-expanded')).toBe('false')
770
+ act(() => toggle.click())
771
+ const panel = host.querySelector(`[id="${toggle.getAttribute('aria-controls')}"]`)!
772
+ expect(panel.querySelectorAll('li')).toHaveLength(21)
773
+ enterSearch(panel.querySelector<HTMLInputElement>('[aria-label="Filter offered tools"]')!, 'CONTROLLER')
774
+ expect([...panel.querySelectorAll('li .truncate')].map((tool) => tool.textContent)).toEqual([longTool])
775
+ } finally {
776
+ act(() => root.unmount())
777
+ vi.unstubAllGlobals()
778
+ }
779
+ })
780
+
781
+ it('preserves namespace and investigation selection on every overview configuration card', () => {
782
+ const out = renderToStaticMarkup(
783
+ <MemoryRouter initialEntries={['/kagent?namespaces=agents,models&ai-run=investigation-1']}>
784
+ <KagentOverview data={blockedWorkspace()} runtime={runtime()} onOpen={open} />
785
+ </MemoryRouter>,
786
+ )
787
+ const links = [...out.matchAll(/href="([^"]+)"/g)].map((match) => new URL(match[1].replace(/&amp;/g, '&'), 'http://radar.invalid'))
788
+ for (const path of ['/kagent/agents', '/kagent/mcpservers', '/kagent/models']) {
789
+ const link = links.find((url) => url.pathname === path)!
790
+ expect(link).toBeDefined()
791
+ expect(link.searchParams.get('namespaces')).toBe('agents,models')
792
+ expect(link.searchParams.get('ai-run')).toBe('investigation-1')
793
+ if (path !== '/kagent/agents') expect(link.searchParams.get('status')).toBe('problems')
794
+ }
795
+ })
796
+
797
+ it('groups Agent facts into ordered cards and shows provenance only for indirect references', () => {
798
+ state.data = workspace()
799
+ const a = agent()
800
+ a.references = [
801
+ { from: a.ref, target: ref('AgentTemplate', 'base'), role: 'template', field: 'template.ref', state: 'present' },
802
+ { from: ref('AgentTemplate', 'base'), target: ref('ModelConfig', 'llm'), role: 'model', field: 'modelConfig', state: 'present' },
803
+ ]
804
+ state.data.agents = [a]
805
+ const out = html(<KagentAgentOverview resource={{ metadata: a.ref }} onOpen={open} />)
806
+ const headings = ['At a glance', 'Configuration of the latest change', 'About', 'kagent conditions'].map(text => out.indexOf(text))
807
+ expect(headings.every(index => index >= 0)).toBe(true)
808
+ expect(headings).toEqual([...headings].sort((a, b) => a - b))
809
+ expect(out).toContain('via template base')
810
+ expect(out).not.toContain('declared by')
811
+ expect(out).not.toContain('Nothing needs attention')
812
+ })
813
+
814
+ it('distinguishes a known missing model from an unread model in At a glance', () => {
815
+ state.data = blockedWorkspace()
816
+ state.data.agents[0].model!.state = 'absent'
817
+ const out = html(<KagentAgentOverview resource={{ metadata: state.data.agents[0].ref }} onOpen={open} />)
818
+ const model = out.split('>Model</dt>')[1].split('<dt')[0]
819
+ expect(model).toContain('Model missing')
820
+ expect(model).toContain('bg-rose-500')
821
+ state.data.agents[0].model!.state = 'unread'
822
+ const unread = html(<KagentAgentOverview resource={{ metadata: state.data.agents[0].ref }} onOpen={open} />).split('>Model</dt>')[1].split('<dt')[0]
823
+ expect(unread).toContain('Model unread')
824
+ expect(unread).not.toContain('bg-rose-500')
825
+ })
826
+
827
+ it('does not turn failed tool discovery into zero missing tools in At a glance', () => {
828
+ state.data = workspace()
829
+ const a = agent()
830
+ a.mcpServers = { declared: 1, failing: 1, absent: 0, unread: 0, notPermitted: 0 }
831
+ state.data.agents = [a]
832
+ const out = html(<KagentAgentOverview resource={{ metadata: a.ref }} onOpen={open} />)
833
+ const tools = out.split('>Tools</dt>')[1].split('<dt')[0]
834
+ expect(tools).toContain('Missing tools unknown')
835
+ expect(tools).not.toContain('0 missing tools')
836
+ })
837
+
838
+ it('does not repeat an unused dependency in a separate Used by table', () => {
839
+ const w = blockedWorkspace()
840
+ w.models[0].usedBy = { ...w.models[0].usedBy, agents: [], count: 0, consumers: 'none', lowerBound: false }
841
+ state.data = w
842
+ const model = w.models[0]
843
+ const out = html(<KagentDependencyOverview resource={{ kind: model.ref.kind, metadata: model.ref }} onOpen={open} />)
844
+ expect(out).not.toContain('Used by →')
845
+ expect(out).not.toContain('kagent-used-by"><section')
846
+ expect(out).toContain('No Agent uses')
847
+ })
848
+
849
+ describe('WorkerPool references on the Agent page', () => {
850
+ function renderPool() {
851
+ const a = agent()
852
+ const pool = { ...ref('WorkerPool', 'worker-pool'), group: 'ate.dev' }
853
+ a.references = [{ from: ref('Harness', 'harness'), target: pool, role: 'workerPool', field: 'spec.substrate.workerPoolRef', state: 'declared' }]
854
+ state.data = workspace()
855
+ state.data.agents = [a]
856
+ return html(<KagentAgentOverview resource={{ metadata: a.ref }} onOpen={open} />)
857
+ }
858
+
859
+ it('reads Kubernetes readiness without requesting the API-tier point read while disconnected', () => {
860
+ state.substrateTier = { state: 'notConfigured', code: 'notConfigured' }
861
+ state.pools = [{ namespace: 'agents', name: 'worker-pool', kubernetes: {
862
+ namespace: 'agents', name: 'worker-pool', desired: 1, reportedReady: 1, health: 'healthy', healthReason: 'Ready',
863
+ } }]
864
+ const out = renderPool()
865
+ expect(out).toContain('1 ready of 1 · from Kubernetes')
866
+ expect(state.poolRequests).toEqual([])
867
+ })
868
+
869
+ it('shows a point-read 404 as an unhealthy missing WorkerPool', () => {
870
+ state.substrateTier = { state: 'connected' }
871
+ state.poolError = new ApiError('no WorkerPool in Kubernetes or Substrate', 404, { error_code: 'notFound' })
872
+ const out = renderPool()
873
+ expect(out).toContain('WorkerPool missing')
874
+ expect(out).toContain(toneFillClass('unhealthy'))
875
+ })
876
+ })