@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,1094 @@
1
+ import { renderToStaticMarkup } from 'react-dom/server'
2
+ import { MemoryRouter as Router, type MemoryRouterProps } from 'react-router-dom'
3
+ import { KubectlTargetContext } from './shared'
4
+ import { describe, expect, it, vi } from 'vitest'
5
+ import type { KagentAgentAttribution, SubstrateActorLogs, SubstrateActors, SubstrateActorsQuery } from '../../api/substrateWorkspace'
6
+ import { ApiError } from '../../api/client'
7
+ import * as mediaQuery from '../../hooks/useMediaQuery'
8
+ import { ActorsTable, SubstrateActorsScreen, stateCellReading } from './SubstrateActors'
9
+ import { SubstrateActorOverview } from './SubstrateActorOverview'
10
+ import { actorDetail, actorRow, actors, connection, counts, apiDisabledTier, minutesAgo, poolShortRow, notConnectedWorkspace, status, workspace } from './substrate.fixtures'
11
+
12
+ function MemoryRouter({ children, ...props }: MemoryRouterProps) {
13
+ return <Router {...props}><KubectlTargetContext.Provider value={{ context: 'kind-demo', kubeconfig: '/home/user/.kube/demo' }}>{children}</KubectlTargetContext.Provider></Router>
14
+ }
15
+
16
+ const targetFlags = ' --kubeconfig /home/user/.kube/demo --context kind-demo'
17
+
18
+ const state = vi.hoisted(() => ({
19
+ actors: undefined as SubstrateActors | undefined,
20
+ actorsError: null as unknown,
21
+ lastQuery: undefined as SubstrateActorsQuery | undefined,
22
+ logs: undefined as SubstrateActorLogs | undefined,
23
+ logsError: null as ApiError | null,
24
+ logOptions: undefined as { tailLines?: number; pollMs?: number | false } | undefined,
25
+ kagentSupport: 'supported' as 'supported' | 'unsupported' | 'unknown',
26
+ kagentUpgrade: null as null | { feature: string },
27
+ queryEnabled: true,
28
+ }))
29
+
30
+ vi.mock('../../api/client', async (importOriginal) => ({
31
+ ...(await importOriginal<typeof import('../../api/client')>()),
32
+ usePrometheusStatus: () => ({ data: { connected: false } }),
33
+ useRadarFeature: () => ({ support: state.kagentSupport, upgrade: state.kagentUpgrade, gatedKey: [], guard: <T,>(r: () => Promise<T>) => r() }),
34
+ }))
35
+ vi.mock('../../api/substrateWorkspace', async (importOriginal) => ({
36
+ ...(await importOriginal<typeof import('../../api/substrateWorkspace')>()),
37
+ useSubstrateActors: (q: SubstrateActorsQuery, enabled = true) => {
38
+ state.lastQuery = q
39
+ state.queryEnabled = enabled
40
+ return { data: state.actors, error: state.actorsError, isLoading: false }
41
+ },
42
+ useSubstrateTemplates: () => ({ data: undefined }),
43
+ useSubstrateActorLogs: (_: unknown, options: typeof state.logOptions) => {
44
+ state.logOptions = options
45
+ return { data: state.logs, isLoading: false, error: state.logsError, isRefetchError: !!state.logsError }
46
+ },
47
+ useSubstrateConnection: () => ({ data: connection(), isError: false }),
48
+ useUpdateSubstrateConnection: () => ({ mutate: vi.fn(), isPending: false }),
49
+ }))
50
+
51
+ const text = (html: string) => html.replace(/&#x27;/g, "'").replace(/&quot;/g, '"').replace(/&amp;/g, '&')
52
+ // Names wrap only after a hyphen, so each segment is its own span; read them as the reader does.
53
+ const plain = (html: string) => html.replace(/<\/?span[^>]*>/g, '')
54
+
55
+ function screen(path = '/substrate/actors', ws = workspace()) {
56
+ return text(renderToStaticMarkup(
57
+ <MemoryRouter initialEntries={[path]}>
58
+ <SubstrateActorsScreen workspace={ws} status={status({ apiTier: ws.apiTier })} onOpenActor={() => {}} openActor={null} />
59
+ </MemoryRouter>,
60
+ ))
61
+ }
62
+
63
+ describe('Actors list', () => {
64
+ it.each([false, true])('fits the session name and wraps headings in the wide layout (Agent Sessions: %s)', (revisionOnly) => {
65
+ const name = 'session-01a23b38-7a02-7365-be44-f36204342710'
66
+ const row = actorRow({
67
+ name,
68
+ state: 'running',
69
+ workerImpact: { kind: 'unavailable', reading: 'Worker is unavailable', nextStep: 'Check the worker' },
70
+ kagent: { kind: 'agentSession', agent: { namespace: 'agents', name: 'helper' }, sessionId: name.slice(8), revision: 'abcdef012345' },
71
+ })
72
+ const wide = vi.spyOn(mediaQuery, 'useMediaQuery').mockReturnValue(true)
73
+ let html: string
74
+ try {
75
+ html = renderToStaticMarkup(
76
+ <MemoryRouter><ActorsTable data={actors({ rows: [row] })} revisionOnly={revisionOnly} page={0} onPage={() => {}} onOpenActor={() => {}} openActor={null} /></MemoryRouter>,
77
+ )
78
+ } finally {
79
+ wide.mockRestore()
80
+ }
81
+ expect(html).toMatch(/class="[^"]*truncate[^"]*"[^>]*>session …04342710<\/span>/)
82
+ expect(html).toMatch(/class="[^"]*whitespace-normal[^"]*"[^>]*>Running · worker unavailable<\/span>/)
83
+ expect(html).toMatch(/<th class="[^"]*whitespace-normal[^"]*">Worker or last node<\/th>/)
84
+ const widths = [...html.matchAll(/<col style="width:(\d+)%"/g)].map(([, width]) => Number(width))
85
+ const identityShare = 1 - widths.reduce((total, width) => total + width, 0) / 100
86
+ const actionWidth = Number(html.match(/<col style="width:(\d+)px"/)?.[1])
87
+ // Leave room for 17 monospace characters at 12.5px and 12px padding on each side.
88
+ expect(900 * identityShare - actionWidth - 24).toBeGreaterThanOrEqual(128)
89
+ })
90
+
91
+ it('counts each segment from Substrate’s counts, not the page', () => {
92
+ state.actors = actors()
93
+ const html = screen()
94
+ expect(html).toMatch(/>All<span[^>]*>1,284</)
95
+ expect(html).toMatch(/>Crashed<span[^>]*>14</)
96
+ expect(html).toMatch(/>In progress<span[^>]*>17</)
97
+ expect(html).toMatch(/>Suspended<span[^>]*>1,041</)
98
+ })
99
+
100
+ it('sends the filters from the URL to the server, a page at a time', () => {
101
+ state.actors = actors()
102
+ screen('/substrate/actors?state=crashed&atespace=research&template=research%2Flanggraph-research&page=2')
103
+ expect(state.lastQuery).toMatchObject({ sort: 'attention', state: ['crashed'], atespace: 'research', template: 'research/langgraph-research', limit: 50, offset: 100 })
104
+ screen('/substrate/actors?node=ip-10-0-4-57&nodeHas=localSnapshot')
105
+ expect(state.lastQuery).toMatchObject({ node: 'ip-10-0-4-57', nodeHas: 'localSnapshot' })
106
+ screen('/substrate/actors?state=inProgress')
107
+ expect(state.lastQuery?.state).toEqual(['resuming', 'suspending', 'reverting', 'deleting'])
108
+ })
109
+
110
+ it('sends the kagent sessions union and namespace scope only with its capability', () => {
111
+ state.kagentSupport = 'supported'
112
+ state.actors = actors()
113
+ expect(screen('/substrate/actors?kagent=sessions&atespaces=research&namespaces=other')).toContain('Atespaces: research')
114
+ expect(state.lastQuery).toMatchObject({ kagent: 'sessions', namespaces: 'research' })
115
+ screen('/substrate/actors?kagent=agentSession&atespaces=research&namespaces=other')
116
+ expect(state.lastQuery).toMatchObject({ kagent: 'agentSession', namespaces: 'research' })
117
+ screen('/substrate/actors?kagent=sessions&namespaces=other')
118
+ expect(state.lastQuery?.namespaces).toBeUndefined()
119
+ state.kagentSupport = 'unsupported'
120
+ screen('/substrate/actors?kagent=sessions')
121
+ expect(state.queryEnabled).toBe(false)
122
+ state.kagentSupport = 'supported'
123
+ })
124
+
125
+ it('shows each actor’s state, reason, worker and what its newest snapshot resumes with', () => {
126
+ state.actors = actors()
127
+ const html = plain(screen())
128
+ expect(html).toContain('lit-review-0193')
129
+ expect(html).toContain('OOMKilled (limit 2Gi)')
130
+ expect(html).toContain('gen 14 · memory')
131
+ expect(html).toContain('upload pending')
132
+ // The warning has its own line, so a narrow cell never cuts it off.
133
+ expect(screen()).toMatch(/<span class="block text-xs leading-4[^"]*">upload pending/)
134
+ // No worker now: the node it last ran on, in the same column, explained on hover.
135
+ expect(html).toContain('ip-10-0-4-57')
136
+ expect(html).toContain('Last known node')
137
+ expect(html).toContain('Assigned worker')
138
+ expect(html).toContain('Open actor lit-review-0193')
139
+ expect(html).toContain('batch-pool-5d2b-r8t')
140
+ expect(html).toContain('none yet')
141
+ expect(html).toContain('boots fresh')
142
+ })
143
+
144
+ it('lists a node’s risk two ways, saying what each means', () => {
145
+ state.actors = actors()
146
+ const html = plain(screen('/substrate/actors?node=ip-10-0-4-57&nodeHas=localSnapshot'))
147
+ expect(html).toContain('Snapshots only on this node')
148
+ expect(html).toContain('losing the node loses that state')
149
+ expect(html).toContain('Node: ip-10-0-4-57')
150
+ })
151
+
152
+ it('says where rows came from when the shared read did not hold them', () => {
153
+ state.actors = actors({ sources: ['snapshot', 'atespace'] })
154
+ expect(plain(screen('/substrate/actors?atespace=research'))).toContain('Read directly from this atespace')
155
+ })
156
+
157
+ it('judges a transition held past Substrate’s stuck threshold, and leaves a fresh one plain', () => {
158
+ state.actors = actors({ rows: [
159
+ actorRow({ name: 'long-one', state: 'suspending', reason: 'Suspending for 2h', updateTime: minutesAgo(120) }),
160
+ actorRow({ name: 'fresh-one', state: 'resuming', reason: 'Resuming for 2m', updateTime: minutesAgo(2) }),
161
+ ] })
162
+ const html = plain(screen())
163
+ // The badge judges it, in words; the line beside it says only how long.
164
+ expect(html).toContain('Suspending · stuck')
165
+ expect(html).toContain('for 2h')
166
+ expect(html).toContain('for 2m')
167
+ expect(html).not.toContain('Resuming · stuck')
168
+ expect(html).not.toContain('stuck for')
169
+ })
170
+
171
+ it('says only what the state badge leaves out', () => {
172
+ state.actors = actors({ rows: [actorRow({ state: 'resuming', reason: 'Resuming for 36m' })] })
173
+ const raw = screen()
174
+ const html = plain(raw)
175
+ expect(raw).toContain('>Resuming</span>')
176
+ expect(html).toContain('for 36m')
177
+ expect(html).not.toContain('Resuming for 36m')
178
+ })
179
+
180
+ it('pages with Previous and Next, saying the range and the total', () => {
181
+ const html = text(renderToStaticMarkup(
182
+ <MemoryRouter>
183
+ <ActorsTable data={actors({ offset: 50 })} page={1} onPage={() => {}} onOpenActor={() => {}} openActor={null} />
184
+ </MemoryRouter>,
185
+ ))
186
+ expect(html).toContain('51–53 of 1,284 · needs attention first')
187
+ expect(html).toContain('Previous')
188
+ expect(html).toContain('Next')
189
+ })
190
+
191
+ it('marks the page before as kept while the next page loads', () => {
192
+ const html = text(renderToStaticMarkup(
193
+ <MemoryRouter>
194
+ <ActorsTable data={actors({ offset: 0 })} placeholder page={1} onPage={() => {}} onOpenActor={() => {}} openActor={null} />
195
+ </MemoryRouter>,
196
+ ))
197
+ expect(html).toContain('Loading page 2… showing the page before until it arrives')
198
+ expect(html).toContain('aria-busy="true"')
199
+ expect(html).not.toContain('of 1,284')
200
+ })
201
+
202
+ it('says a partial read’s total is a lower bound, and an empty one proves nothing', () => {
203
+ const partial = actors({ coverage: { state: 'partial', deniedAtespaces: ['restricted'] } })
204
+ const html = text(renderToStaticMarkup(
205
+ <MemoryRouter>
206
+ <ActorsTable data={partial} page={0} onPage={() => {}} onOpenActor={() => {}} openActor={null} />
207
+ <ActorsTable data={actors({ rows: [], total: 0, coverage: { state: 'partial', deniedAtespaces: ['restricted'] } })} page={0} onPage={() => {}} onOpenActor={() => {}} openActor={null} />
208
+ </MemoryRouter>,
209
+ ))
210
+ expect(html).toContain('of at least 1,284')
211
+ expect(html).toContain('No actors match in what Radar could read (Substrate denied atespace restricted).')
212
+ })
213
+
214
+ it('opens rows from the keyboard', () => {
215
+ state.actors = actors()
216
+ const html = screen()
217
+ expect(html).toMatch(/<tr tabindex="0"/)
218
+ })
219
+
220
+ it('says the operator turned the API off, not an error, when actors are refused for that', () => {
221
+ state.actors = actors()
222
+ state.actorsError = new ApiError('turned off', 403, { error: 'turned off', error_code: 'apiDisabled' })
223
+ try {
224
+ const html = plain(screen())
225
+ expect(html).toContain('Turned off for this Radar')
226
+ expect(html).not.toContain('couldn’t read the actors')
227
+ expect(html).not.toContain('lit-review-0193')
228
+ expect(html).not.toContain('Reported phases')
229
+ } finally {
230
+ state.actorsError = null
231
+ }
232
+ })
233
+
234
+ it('reads an actor page refused because the API is off as that, with what to ask for', async () => {
235
+ const { ActorReadFailure } = await import('./SubstrateActorPage')
236
+ const html = text(renderToStaticMarkup(<MemoryRouter><ActorReadFailure actor={{ atespace: 'r', name: 'a' }} error={new ApiError('x', 403, { error: 'x', error_code: 'apiDisabled' })} onBack={() => {}} /></MemoryRouter>))
237
+ expect(html).toContain('Turned off for this Radar')
238
+ expect(html).toContain('substrate.api.enabled')
239
+ })
240
+
241
+ it('labels a crash cause Substrate’s message names in a few words, the message on hover', () => {
242
+ const message = 'killed for exceeding its memory limit: signal: killed'
243
+ state.actors = actors({ rows: [actorRow({ reason: message, cause: 'memoryLimit' }), actorRow({ name: 'other', reason: 'container agent: exit code 1' })] })
244
+ const html = plain(screen('/substrate/actors?state=crashed'))
245
+ // One short label per row, the same on every row it covers; never the multi-line message repeated.
246
+ expect(html.match(/Memory-limit kill/g)).toHaveLength(1)
247
+ expect(html).not.toContain(message)
248
+ // A crash without a named cause still reads its message.
249
+ expect(html).toContain('container agent: exit code 1')
250
+ // The full message is on hover.
251
+ expect(stateCellReading(actorRow({ reason: message, cause: 'memoryLimit' }))).toEqual({ text: 'Memory-limit kill', hover: `Substrate’s message: ${message}.` })
252
+ // From a Radar that names no cause, the message is the cell, as before.
253
+ expect(stateCellReading(actorRow({ reason: message })).text).toBe(message)
254
+ })
255
+
256
+ it('gives a crashed row one red signal, its badge: the crash message reads neutral', async () => {
257
+ const { toneTextClass } = await import('@skyhook-io/k8s-ui')
258
+ state.actors = actors()
259
+ const html = screen('/substrate/actors?state=crashed')
260
+ const msg = html.indexOf('container agent: OOMKilled (limit 2Gi)')
261
+ expect(msg).toBeGreaterThan(-1)
262
+ const cls = html.slice(html.lastIndexOf('class="', msg), msg)
263
+ expect(cls).toContain('text-theme-text-secondary')
264
+ expect(cls).not.toContain(toneTextClass('unhealthy'))
265
+ expect(html).toContain('>Crashed<')
266
+ })
267
+
268
+ it('distinguishes reported phases from the broader needs-attention inventory', () => {
269
+ state.actors = actors({ attentionCount: 24, counts: counts({ crashed: 15, running: 81, suspended: 1185 }) })
270
+ const html = screen()
271
+ expect(html).toContain('Reported phases')
272
+ expect(html).toMatch(/>Needs attention<span[^>]*>24</)
273
+ expect(html).toMatch(/>Crashed<span[^>]*>15</)
274
+ expect(html).toMatch(/role="img" aria-label="1,281 actors: Crashed 15, Running 81, Suspended 1,185"/)
275
+ expect(html).not.toContain('need attention: 14')
276
+ })
277
+
278
+ it('takes worker coverage for the attention count from the actor response', () => {
279
+ const ws = workspace()
280
+ ws.coverage.workers = { state: 'partial' }
281
+ state.actors = actors({ attentionCount: 24 })
282
+ expect(screen('/substrate/actors', ws)).toMatch(/>Needs attention<span[^>]*>24</)
283
+ state.actors = actors({ attentionCount: 24, workerCoverage: { state: 'partial' } })
284
+ expect(screen()).toMatch(/>Needs attention<span[^>]*>≥24</)
285
+ })
286
+
287
+ it('sends the attention filter with the current scope and gives partial results a lower bound', () => {
288
+ state.actors = actors({ attentionCount: 24, coverage: { state: 'partial', deniedAtespaces: ['restricted'] } })
289
+ const html = screen('/substrate/actors?attention=1&atespace=research')
290
+ expect(state.lastQuery).toMatchObject({ attention: 1, atespace: 'research' })
291
+ expect(html).toMatch(/>Needs attention<span[^>]*>≥24</)
292
+ expect(html).toContain('Includes reported crashes, lost sandboxes, unavailable workers and stuck transitions.')
293
+ state.actors = actors({ attentionCount: 0, coverage: { state: 'partial', deniedAtespaces: ['restricted'] } })
294
+ expect(screen('/substrate/actors?attention=1')).not.toMatch(/>Needs attention<span[^>]*>0</)
295
+ })
296
+
297
+ it('leads to Substrate settings instead of the table while not connected', () => {
298
+ state.actors = undefined
299
+ const html = screen('/substrate/actors', notConnectedWorkspace())
300
+ expect(html).toContain('Open Substrate settings')
301
+ expect(html).not.toContain('No actors match')
302
+ })
303
+
304
+ it('follows the current workspace tier when the disabled query still holds actors', () => {
305
+ state.actors = actors()
306
+ const html = plain(screen('/substrate/actors', notConnectedWorkspace(apiDisabledTier)))
307
+ expect(html).toContain('Turned off for this Radar')
308
+ expect(html).not.toContain('lit-review-0193')
309
+ expect(html).not.toContain('Reported phases')
310
+ })
311
+
312
+ it('qualifies an empty worker-impact filter when the worker read is incomplete', () => {
313
+ state.actors = actors({ rows: [], total: 0, workerCoverage: { state: 'partial' } })
314
+ expect(screen('/substrate/actors?impact=restarted')).toContain('No matching actors observed. Some worker disruptions could not be assessed.')
315
+ state.actors = actors({ rows: [], total: 0, workerCoverage: { state: 'full' } })
316
+ expect(screen('/substrate/actors?impact=restarted')).toContain('No actors match.')
317
+ })
318
+ })
319
+
320
+ describe('Actor overview', () => {
321
+ it('leads a crash with Substrate’s message, what it means, and the exact revert command', () => {
322
+ state.logs = { actor: { atespace: 'research', name: 'lit-review-0193' }, state: 'crashed', origin: 'lastNode', node: 'ip-10-0-4-57', reasonCode: 'noMatch', source: 'all', lines: [], searched: [{ namespace: 'agents', pod: 'agent-pool-worker-2', outcome: 'read', scanned: 900, windowFull: false, matched: 0 }], scanned: 900, windowFull: false }
323
+ const html = text(renderToStaticMarkup(<MemoryRouter><SubstrateActorOverview detail={actorDetail()} onOpenSubject={() => {}} /></MemoryRouter>))
324
+ expect(html).toContain('Actor crashed 4m ago')
325
+ expect(html).toContain('container agent: OOMKilled (limit 2Gi)')
326
+ expect(html).toContain('A revert returns it to suspended at generation 14, its newest stored snapshot.')
327
+ expect(html).toContain('Resumes where it left off: the snapshot holds its memory.')
328
+ // How many share its template, as a concentration: never a guess that the template is the cause.
329
+ expect(html).not.toContain('the cause may be')
330
+ // The command box keeps each word unbroken in its own span.
331
+ expect(html.replace(/<\/?span[^>]*>/g, '')).toContain('kubectl ate revert actor lit-review-0193 -a research')
332
+ // The crash is the banner; the backend's crashed-actors row is not repeated.
333
+ expect(html).not.toContain('14 actors are crashed')
334
+ // Visible: the cause, the concentration and the step; what a revert keeps folds under Details.
335
+ const p = plain(html)
336
+ expect(p).toContain('11 reported crashed on this template →')
337
+ expect(p.indexOf('A revert returns it to suspended')).toBeGreaterThan(p.indexOf('Recovery steps'))
338
+ expect(p.indexOf('Recovery steps')).toBeGreaterThan(-1)
339
+ })
340
+
341
+ it('sends a kagent session to kagent for recovery, with no kubectl ate command', () => {
342
+ const d = actorDetail()
343
+ const step = 'This actor looks like a kagent session. Recover it through kagent (its RevertSession API, or Recover on the chat where offered).'
344
+ const detail = { ...d, actor: { ...d.actor, kagent: { sessionId: '01a1faa2-b3e3-7dd3-ae2d-3114122d4291' } }, attention: [{ ...d.attention[0], nextStep: step, command: undefined }] }
345
+ const html = plain(text(renderToStaticMarkup(<MemoryRouter><SubstrateActorOverview detail={detail} onOpenSubject={() => {}} /></MemoryRouter>)))
346
+ expect(html).toContain(step)
347
+ expect(html).not.toContain('kubectl ate revert')
348
+ })
349
+
350
+ it('sends a standalone kagent sandbox to kagent’s SandboxService, never to a chat it doesn’t have', () => {
351
+ const d = actorDetail()
352
+ const step = 'This actor looks like a kagent sandbox. If so, delete the sandbox through kagent (its SandboxService).'
353
+ const detail = { ...d, actor: { ...d.actor, kagent: { sessionId: '01a1faa2-b3e3-7dd3-ae2d-3114122d4291', sandbox: true } }, attention: [{ ...d.attention[0], nextStep: step, command: undefined }] }
354
+ const html = plain(text(renderToStaticMarkup(<MemoryRouter><SubstrateActorOverview detail={detail} onOpenSubject={() => {}} /></MemoryRouter>)))
355
+ expect(html).toContain(step)
356
+ expect(html).not.toContain('RevertSession')
357
+ expect(html).not.toContain('kubectl ate revert')
358
+ })
359
+
360
+ it('shows the server’s wait step for a possible kagent session on a restarted worker', () => {
361
+ const d = actorDetail()
362
+ const step = 'Once Substrate reconciles the worker and marks it crashed, recover it through kagent.'
363
+ const detail = actorDetail({
364
+ actor: { ...d.actor, state: 'running', crash: undefined, kagent: { sessionId: '01a1faa2-b3e3-7dd3-ae2d-3114122d4291' } },
365
+ row: actorRow({ state: 'running', workerImpact: { kind: 'restarted', reading: 'The worker restarted.', nextStep: step } }),
366
+ attention: [],
367
+ })
368
+ const html = plain(text(renderToStaticMarkup(<MemoryRouter><SubstrateActorOverview detail={detail} onOpenSubject={() => {}} /></MemoryRouter>)))
369
+ expect(html).toContain(step)
370
+ expect(html).not.toContain('Copy command')
371
+ })
372
+
373
+ it('says how the revert target resumes only where At a glance doesn’t already say it', () => {
374
+ const d = actorDetail()
375
+ const html = plain(text(renderToStaticMarkup(<MemoryRouter><SubstrateActorOverview detail={d} onOpenSubject={() => {}} /></MemoryRouter>)))
376
+ const sentence = 'Resumes where it left off: the snapshot holds its memory.'
377
+ expect(html.split(sentence).length - 1).toBe(1)
378
+ })
379
+
380
+ it('names a memory-limit kill from the worker’s log as the crash’s cause, with the timing that ties them', () => {
381
+ const before = state.logs
382
+ // The server ties a kill to the crash by timing: it came at most 10m before it, with no restart between.
383
+ const killedAt = new Date(Date.parse(actorDetail().actor.crash!.time!) - 2 * 60_000).toISOString()
384
+ state.logs = { actor: { atespace: 'research', name: 'lit-review-0193' }, state: 'crashed', origin: 'lastNode', node: 'ip-10-0-4-57', reasonCode: 'candidates', source: 'all', searched: [], scanned: 900, windowFull: false, lines: [{ kind: 'worker', time: killedAt, message: 'Killing a sandbox over its memory limit', text: 'x', namespace: 'agents', pod: 'agent-pool-worker-1', memoryLimitBytes: 2147483648, memoryUsageBytes: 2147483648 }], memoryKill: { time: killedAt, namespace: 'agents', pod: 'agent-pool-worker-1', limitBytes: 2147483648, usageBytes: 2147483648, current: true, nextStep: 'Revert the actor, update its template once suspended, then resume.', command: 'kubectl ate revert actor lit-review-0193 -a research', thenCommand: 'kubectl ate update actor lit-review-0193 -a research --template <new-template>' } }
385
+ try {
386
+ const html = plain(text(renderToStaticMarkup(<MemoryRouter><SubstrateActorOverview detail={actorDetail()} onOpenSubject={() => {}} /></MemoryRouter>)))
387
+ // The cause carries its evidence, not a bare claim: how long before the crash the worker killed it.
388
+ expect(html).toContain('Cause, from its worker’s log: the worker killed its sandbox over its memory limit of 2Gi (it used 2Gi), 2m before this crash.')
389
+ expect(html).not.toMatch(/\d{4}-\d{2}-\d{2}T/)
390
+ // What ties it to this crash, in full, under Details.
391
+ expect(html).toContain('Radar ties it to this crash by timing: the record names this actor, came 2m before this crash, and the lines read show no restart between them.')
392
+ expect(html.indexOf('Radar ties it to this crash')).toBeGreaterThan(html.indexOf('Details'))
393
+ // The last lines below mark the kill line with the same evidence, not a second statement of the cause.
394
+ expect(html).toContain('memory-limit kill · 2m before this crash')
395
+ // Where the cause was read is provenance: under Details, not in the visible line.
396
+ expect(html).toContain('Read from the worker’s log')
397
+ expect(html).toContain('in agents/agent-pool-worker-1.')
398
+ expect(html.indexOf('in agents/agent-pool-worker-1.')).toBeGreaterThan(html.indexOf('Details'))
399
+ // The cause found picks the step: the remedy, not "find the cause".
400
+ expect(html).toContain('Next step: Revert the actor, update its template once suspended, then resume.')
401
+ expect(html).not.toContain('Find the cause')
402
+ // The banner names the cause; the last lines below don't repeat it.
403
+ expect(html).not.toContain('that is why it crashed')
404
+ // The cause leads; Substrate's own message folds under Details, and the mechanism is gone.
405
+ expect(html.indexOf('Cause, from its worker’s log')).toBeLessThan(html.indexOf('Next step:'))
406
+ expect(html.indexOf('Details')).toBeGreaterThan(html.indexOf('Next step:'))
407
+ expect(html).not.toContain('released its worker')
408
+ } finally {
409
+ state.logs = before
410
+ }
411
+ })
412
+
413
+ it('never says both that the snapshot holds memory and, unconditioned, that it resumes from volumes (the s05 actor)', () => {
414
+ const before = state.logs
415
+ // The tour's s05 drawer: crashed over its 2Gi limit, gen 6 a stored memory snapshot stamped with its template.
416
+ // The step is CrashedMemoryActorStep's for that snapshot (pkg/substrate TestMemoryStepFollowsTheRecoverySnapshot).
417
+ const step = "Revert, move to a template with more memory and identical volumes, mounts and snapshot location, then resume. The move drops saved memory and files."
418
+ state.logs = { actor: { atespace: 'research', name: 'lit-review-0193' }, state: 'crashed', origin: 'lastNode', node: 'ip-10-0-17-21', reasonCode: 'candidates', source: 'all', searched: [], scanned: 900, windowFull: false, lines: [], memoryKill: { time: minutesAgo(22), namespace: 'agents', pod: 'agent-pool-worker-1', limitBytes: 2147483648, usageBytes: 2147483648, current: true, nextStep: step, command: 'kubectl ate revert actor lit-review-0193 -a research', thenCommand: 'kubectl ate update actor lit-review-0193 -a research --template <new-template>' } }
419
+ const gen6 = { generation: 6, fidelity: 'memory' as const, owner: 'actor' as const, durable: 'completed' as const, sandboxClass: 'gvisor' }
420
+ const d = actorDetail({
421
+ actor: { ...actorDetail().actor, snapshots: [gen6] },
422
+ row: actorRow({ newestSnapshot: gen6, resumeGeneration: 6, resumesWith: 'memory', resumeCondition: 'compatibleRuntime' }),
423
+ recovery: { generation: 6, fidelity: 'memory', resumesWith: 'memory', resumeCondition: 'compatibleRuntime', discarded: [] },
424
+ })
425
+ try {
426
+ const html = plain(text(renderToStaticMarkup(<MemoryRouter><SubstrateActorOverview detail={d} onOpenSubject={() => {}} /></MemoryRouter>))).replace(/<[^>]+>/g, ' ')
427
+ expect(html).toContain('Resumes from snapshot generation 6 (with memory, if the runtime is compatible)')
428
+ expect(html).toContain('Snapshot holds memory')
429
+ expect(html).toContain('The move drops saved memory and files.')
430
+ // Every sentence that restores from volumes names the move as the reason; none says what the snapshot lacks.
431
+ const sentences = html.split(/(?<=[.!?])\s+/)
432
+ for (const x of sentences.filter((x) => /(?:keeping|from|to) volumes/.test(x))) expect(x).toMatch(/[Mm]ove/)
433
+ expect(html).not.toMatch(/without memory|resumes from volumes/)
434
+ } finally {
435
+ state.logs = before
436
+ }
437
+ })
438
+
439
+ it('gives a memory-limit crash both commands of its step, the revert then the template update, after the sentence that says what the move drops', () => {
440
+ const before = state.logs
441
+ const step = "Revert, move to a template with more memory and identical volumes, mounts and snapshot location, then resume. The move drops saved memory and files."
442
+ const move = 'kubectl ate update actor lit-review-0193 -a research --template <new-template>'
443
+ const revert = 'kubectl ate revert actor lit-review-0193 -a research'
444
+ state.logs = { actor: { atespace: 'research', name: 'lit-review-0193' }, state: 'crashed', origin: 'lastNode', node: 'ip-10-0-17-21', reasonCode: 'candidates', source: 'all', searched: [], scanned: 900, windowFull: false, lines: [], memoryKill: { time: minutesAgo(22), namespace: 'agents', pod: 'agent-pool-worker-1', limitBytes: 2147483648, current: true, nextStep: step, command: revert, thenCommand: move } }
445
+ try {
446
+ const raw = text(renderToStaticMarkup(<MemoryRouter><SubstrateActorOverview detail={actorDetail()} onOpenSubject={() => {}} /></MemoryRouter>))
447
+ const html = plain(raw).replace(/<[^>]+>/g, ' ').replace(/&lt;/g, '<').replace(/&gt;/g, '>')
448
+ expect(raw.match(/data-command-line/g)?.length).toBeGreaterThanOrEqual(2)
449
+ const drops = html.indexOf("The move drops saved memory and files")
450
+ expect(drops).toBeGreaterThan(-1)
451
+ expect(drops).toBeLessThan(html.indexOf(revert))
452
+ expect(html.indexOf(revert)).toBeLessThan(html.indexOf(move))
453
+ } finally {
454
+ state.logs = before
455
+ }
456
+ })
457
+
458
+ it('drops cached log evidence and recovery commands when access is denied', () => {
459
+ const before = state.logs
460
+ state.logs = {
461
+ actor: { atespace: 'research', name: 'lit-review-0193' }, state: 'crashed', origin: 'lastNode',
462
+ source: 'all', searched: [], scanned: 1, windowFull: false,
463
+ lines: [{ kind: 'worker', message: 'cached worker log', text: 'x', namespace: 'agents', pod: 'worker' }],
464
+ memoryKill: { time: minutesAgo(4), namespace: 'agents', pod: 'worker', limitBytes: 2 ** 30, current: true,
465
+ nextStep: 'Cached recovery step.', command: 'kubectl ate revert actor lit-review-0193 -a research',
466
+ thenCommand: 'kubectl ate update actor lit-review-0193 -a research --template <new-template>' },
467
+ }
468
+ state.logsError = new ApiError('logs denied', 403, { error_code: 'denied' })
469
+ try {
470
+ const html = plain(text(renderToStaticMarkup(<MemoryRouter><SubstrateActorOverview detail={actorDetail()} /></MemoryRouter>)))
471
+ expect(html).toContain('Worker logs couldn’t be read')
472
+ expect(html).toContain('Substrate’s message')
473
+ expect(html).not.toContain('cached worker log')
474
+ expect(html).not.toContain('Cached recovery step')
475
+ expect(html).not.toContain('kubectl ate update')
476
+ } finally {
477
+ state.logs = before
478
+ state.logsError = null
479
+ }
480
+ })
481
+
482
+ it('opens a last-node preview without polling and qualifies partial searches', () => {
483
+ const before = state.logs
484
+ try {
485
+ state.logs = { actor: { atespace: 'research', name: 'lit-review-0193' }, state: 'crashed', origin: 'lastNode', node: 'worker-node', reasonCode: 'noMatch', partial: true, source: 'all', lines: [], searched: [], scanned: 1, windowFull: false }
486
+ const html = text(renderToStaticMarkup(<MemoryRouter><SubstrateActorOverview detail={actorDetail()} /></MemoryRouter>))
487
+ expect(state.logOptions).toEqual({ tailLines: 8, pollMs: false })
488
+ expect(html).toContain('No matches in the worker logs Radar could search')
489
+ } finally {
490
+ state.logs = before
491
+ }
492
+ })
493
+
494
+ it('does not call an earlier run’s memory-limit kill the cause of this crash', () => {
495
+ const before = state.logs
496
+ try {
497
+ state.logs = { actor: { atespace: 'research', name: 'lit-review-0193' }, state: 'crashed', origin: 'lastNode', node: 'ip-10-0-4-57', reasonCode: 'candidates', source: 'all', searched: [], scanned: 900, windowFull: false, lines: [{ kind: 'worker', time: '2026-11-17T15:48:03Z', message: 'Killing a sandbox over its memory limit', text: 'x', namespace: 'agents', pod: 'agent-pool-worker-1' }], memoryKill: { time: '2026-11-17T15:48:03Z', namespace: 'agents', pod: 'agent-pool-worker-1', limitBytes: 2147483648, current: false } }
498
+ const html = plain(text(renderToStaticMarkup(<MemoryRouter><SubstrateActorOverview detail={actorDetail()} onOpenSubject={() => {}} /></MemoryRouter>)))
499
+ expect(html).not.toContain('Cause, from its worker’s log')
500
+ expect(html).toContain('A memory-limit kill attempt was recorded')
501
+ expect(html).toContain('Substrate reported')
502
+ expect(html).not.toContain('Raise the template’s memory limit')
503
+ } finally {
504
+ state.logs = before
505
+ }
506
+ })
507
+
508
+ it('names what a revert drops, and asks to wait only for an upload that can still finish', () => {
509
+ const pending = actorDetail({ recovery: { generation: 6, fidelity: 'memory', resumesWith: 'memory', resumeCondition: 'compatibleRuntime', discarded: [{ generation: 7, fidelity: 'memory', why: 'uploadPending' }] } })
510
+ const html = text(renderToStaticMarkup(<MemoryRouter><SubstrateActorOverview detail={pending} /></MemoryRouter>))
511
+ expect(html).toContain('A revert drops generation 7 (memory): its upload may still finish; waiting for it before reverting keeps it.')
512
+ expect(html).toContain('To keep generation 7, wait for its upload to finish before reverting.')
513
+ expect(html).toContain('resumes where it left off on a compatible runtime, otherwise restarts from its saved files')
514
+ const abandoned = actorDetail({ recovery: { generation: 6, fidelity: 'memory', resumesWith: 'memory', discarded: [{ generation: 7, why: 'uploadAbandoned' }] } })
515
+ const a = text(renderToStaticMarkup(<MemoryRouter><SubstrateActorOverview detail={abandoned} /></MemoryRouter>))
516
+ expect(a).toContain('Substrate will never record its upload')
517
+ expect(a).not.toContain('wait for its upload')
518
+ const cold = actorDetail({ recovery: { resumesWith: 'cold', discarded: [] } })
519
+ expect(text(renderToStaticMarkup(<MemoryRouter><SubstrateActorOverview detail={cold} /></MemoryRouter>))).toContain('with nothing stored, so it boots fresh')
520
+ })
521
+
522
+ it('says why a crashed actor has no worker and no log, and keeps its last node', () => {
523
+ const html = text(renderToStaticMarkup(<MemoryRouter><SubstrateActorOverview detail={actorDetail()} /></MemoryRouter>))
524
+ expect(html).toContain('Unassigned while crashed')
525
+ expect(html).toContain('ip-10-0-4-57')
526
+ // The last node was searched and held nothing: said plainly, with the crash time, no promise that history returns.
527
+ expect(html).toContain('No matches in the recent log window')
528
+ expect(plain(html)).toMatch(/Actor crashed \d+m ago/)
529
+ expect(html).not.toContain('return when it next runs')
530
+ expect(html).toContain('2 CPU · 2Gi')
531
+ expect(html).toContain('2 rules · api.openai.com, *.arxiv.org')
532
+ })
533
+
534
+ it('shows the crash moment without implying a precisely measured state duration', () => {
535
+ const html = plain(text(renderToStaticMarkup(<MemoryRouter><SubstrateActorOverview detail={actorDetail()} /></MemoryRouter>)))
536
+ expect(html).toMatch(/Actor crashed \d+m ago/)
537
+ expect(html).not.toContain('since at least')
538
+ })
539
+
540
+ it('shows a running actor’s last log lines', () => {
541
+ state.logs = { actor: { atespace: 'research', name: 'a' }, state: 'running', origin: 'worker', source: 'all', scanned: 100, windowFull: false, searched: [], lines: [{ kind: 'container', time: '2026-11-17T15:48:03Z', container: 'agent', message: 'embedding batch 7/9', text: 'x', namespace: 'agents', pod: 'agent-pool-7f9c-xk2' }] }
542
+ const d = actorDetail({ actor: { ...actorDetail().actor, state: 'running', crash: undefined, assignment: { worker: 'w', namespace: 'agent-ns', pool: 'agent-pool', pod: 'agent-pool-7f9c-xk2', node: 'ip-10-0-4-57' } }, attention: [] })
543
+ const html = text(renderToStaticMarkup(<MemoryRouter><SubstrateActorOverview detail={d} /></MemoryRouter>))
544
+ expect(html).toContain('embedding batch 7/9')
545
+ expect(html).not.toContain('Crashed')
546
+ expect(html).toContain('>agent-pool-7f9c-xk2<')
547
+ expect(html).toMatch(/namespace (<span[^>]*>)?agent-ns/)
548
+ expect(html).toContain('state unknown')
549
+ })
550
+
551
+ it('says no egress policy means outbound traffic is denied, and a denied read is unknown', () => {
552
+ // Substrate's egress gateway refuses an actor with no policy, or with one that has no rules.
553
+ const none = text(renderToStaticMarkup(<MemoryRouter><SubstrateActorOverview detail={actorDetail({ egress: { state: 'none', rules: 0 } })} /></MemoryRouter>))
554
+ expect(none).toContain('No egress policy, so Substrate denies all outbound traffic')
555
+ expect(none).not.toContain('No policy:')
556
+ const empty = text(renderToStaticMarkup(<MemoryRouter><SubstrateActorOverview detail={actorDetail({ egress: { state: 'set', rules: 0 } })} /></MemoryRouter>))
557
+ expect(empty).toContain('A policy with no rules, so Substrate denies all outbound traffic')
558
+ expect(empty).not.toContain('0 rules')
559
+ const denied = text(renderToStaticMarkup(<MemoryRouter><SubstrateActorOverview detail={actorDetail({ egress: { state: 'denied', rules: 0, message: 'permission denied' } })} /></MemoryRouter>))
560
+ expect(denied).toContain('Substrate denied permission to read this actor’s egress policy: permission denied')
561
+ })
562
+ })
563
+
564
+ describe('Logs for an actor on no worker', () => {
565
+ const crashed = actorDetail().actor
566
+ const base = { actor: { atespace: 'research', name: 'lit-review-0193' }, state: 'crashed' as const, source: 'all' as const, scanned: 0, windowFull: false }
567
+ const render = async (logs: Parameters<typeof import('./SubstrateActorOverview')['ActorLogsBody']>[0]['logs']['data']) => {
568
+ const { ActorLogsBody } = await import('./SubstrateActorOverview')
569
+ return plain(text(renderToStaticMarkup(<MemoryRouter><ActorLogsBody actor={crashed} logs={{ data: logs, isLoading: false, error: null }} /></MemoryRouter>)))
570
+ }
571
+
572
+ it('preserves searched Pods, unread logs and external search after a zero-match result', async () => {
573
+ const html = await render({
574
+ ...base, origin: 'lastNode', node: 'worker-node', reasonCode: 'noMatch', windowFull: true, morePods: 2, lines: [],
575
+ searched: [
576
+ { namespace: 'agents', pod: 'read-worker', outcome: 'read', scanned: 20_000, windowFull: true, matched: 0 },
577
+ { namespace: 'other', pod: 'denied-worker', outcome: 'denied', message: 'requires get pods/log in other', scanned: 0, windowFull: false, matched: 0 },
578
+ ],
579
+ })
580
+ expect(html).toContain('No matching log lines')
581
+ expect(html).toContain('Older lines may exist')
582
+ expect(html).toContain('agents/read-worker: read, 0 matching lines')
583
+ expect(html).toContain('other/denied-worker: requires get pods/log in other')
584
+ expect(html).toContain('2 more worker Pods left unsearched')
585
+ expect(html).toContain('ate.actor.name="lit-review-0193"')
586
+ })
587
+
588
+ it('distinguishes permission to discover worker Pods from reading their logs', async () => {
589
+ const empty = { ...base, origin: 'lastNode' as const, node: 'worker-node', searched: [], lines: [] }
590
+ const pods = await render({ ...empty, reasonCode: 'podsDenied' })
591
+ expect(pods).toContain('requires list on pods')
592
+ expect(pods).not.toContain('requires get on pods/log')
593
+ expect(await render({ ...empty, reasonCode: 'logsDenied' })).toContain('requires get on pods/log')
594
+ })
595
+
596
+ it('explains when the newest lines were cut off in a zero-match search', async () => {
597
+ const html = await render({
598
+ ...base, origin: 'worker', windowFull: true, lines: [],
599
+ searched: [{ namespace: 'agents', pod: 'worker', outcome: 'read', scanned: 100, windowFull: true, truncated: true, matched: 0 }],
600
+ })
601
+ expect(html).toContain('No matching log lines')
602
+ expect(html).toContain('The byte limit cut off the newest lines in the worker Pod log.')
603
+ expect(html).not.toContain('Radar scanned the newest lines')
604
+ })
605
+
606
+ it('never calls an earlier run’s memory-limit kill the reason for the crash in the logs', async () => {
607
+ const html = await render({ ...base, origin: 'lastNode', node: 'node', reasonCode: 'candidates', searched: [], lines: [{ kind: 'worker', namespace: 'agents', pod: 'worker', text: 'old kill', message: 'old kill', time: '2026-11-17T12:00:00Z' }], memoryKill: { time: '2026-11-17T12:00:00Z', namespace: 'agents', pod: 'worker', limitBytes: 1024, current: false } })
608
+ expect(html).not.toContain('that is why it crashed')
609
+ expect(html).toContain('A memory-limit kill attempt was recorded')
610
+ expect(html).toContain('Substrate’s crash cause is reported separately.')
611
+ })
612
+
613
+ it('labels lines found on the node it last ran on as candidates, naming the Pod and the crash time', async () => {
614
+ const html = await render({ ...base, origin: 'lastNode', node: 'ip-10-0-4-57', reasonCode: 'candidates', searched: [], lines: [{ kind: 'container', time: '2026-11-17T15:48:03Z', container: 'agent', message: 'OOM', text: 'x', namespace: 'agents', pod: 'agent-pool-worker-2' }] })
615
+ // One provenance line names the source and why these are only candidates.
616
+ expect(html).toContain('Candidates from agents/agent-pool-worker-2 on ip-10-0-4-57, the node it last ran on, before it crashed ')
617
+ expect(html).toContain('Substrate doesn’t record which Pod it ran in.')
618
+ expect(html.match(/the node it last ran on/g)).toHaveLength(1)
619
+ })
620
+
621
+ it('marks the kill line of this crash in place, with its timing as the evidence and a way to jump to it', async () => {
622
+ const at = (ms: number) => new Date(Date.parse(crashed.crash!.time!) + ms).toISOString()
623
+ const kill = { kind: 'worker' as const, time: at(-1000), message: 'Killing a sandbox over its memory limit', text: 'x', namespace: 'agents', pod: 'agent-pool-worker-1', memoryLimitBytes: 2147483648 }
624
+ const lines = [{ kind: 'container' as const, time: at(-60_000), container: 'agent', message: 'working', text: 'x', namespace: 'agents', pod: 'agent-pool-worker-1' }, kill, { kind: 'worker' as const, time: at(0), message: 'Sandbox died', text: 'x', namespace: 'agents', pod: 'agent-pool-worker-1' }]
625
+ const html = await render({ ...base, origin: 'lastNode', node: 'n', reasonCode: 'candidates', searched: [], lines, memoryKill: { time: kill.time, pod: kill.pod, namespace: kill.namespace, limitBytes: kill.memoryLimitBytes, current: true } })
626
+ expect(html).toMatch(/data-marked="current"[^>]*>(?:(?!<\/div>).)*Killing a sandbox over its memory limit(?:(?!<\/div>).)*memory-limit kill · 1s before this crash/)
627
+ expect(html.match(/data-marked=/g)).toHaveLength(1)
628
+ expect(html).toContain('Jump to line')
629
+ // The tab refers to the kill in one short line; the cause in full is the Overview banner's.
630
+ expect(html).toContain('Marked below: the worker’s memory-limit kill, 1s before this crash.')
631
+ expect(html).not.toContain('that is why it crashed')
632
+ expect(html).not.toContain('memory limit of 2Gi')
633
+ // The line stays where it is in the log, once.
634
+ expect(html.split('Killing a sandbox over its memory limit').length - 1).toBe(1)
635
+ })
636
+
637
+ it('labels an earlier run’s kill line as one, without the error rail', async () => {
638
+ const kill = { kind: 'worker' as const, time: '2026-11-17T12:00:00Z', message: 'Killing a sandbox over its memory limit', text: 'x', namespace: 'agents', pod: 'w', memoryLimitBytes: 1024 }
639
+ const html = await render({ ...base, origin: 'lastNode', node: 'n', reasonCode: 'candidates', searched: [], lines: [kill], memoryKill: { time: kill.time, pod: 'w', namespace: kill.namespace, limitBytes: 1024, current: false } })
640
+ expect(html).toContain('data-marked="earlier"')
641
+ expect(html).toContain('memory-limit kill attempt')
642
+ expect(html).not.toContain('memory-limit kill · this crash')
643
+ expect(html).not.toMatch(/absolute -left-2/)
644
+ })
645
+
646
+ it('says when a filter hides the kill record, instead of changing the filter', async () => {
647
+ const { HiddenKillNotice, hidesWorkerRecords } = await import('./SubstrateActorPage')
648
+ expect(hidesWorkerRecords('containers', '')).toBe(true)
649
+ expect(hidesWorkerRecords('lifecycle', '')).toBe(true)
650
+ expect(hidesWorkerRecords('all', 'agent')).toBe(true)
651
+ expect(hidesWorkerRecords('all', '')).toBe(false)
652
+ expect(hidesWorkerRecords('worker', '')).toBe(false)
653
+ const html = text(renderToStaticMarkup(<HiddenKillNotice kill={{ current: true, time: '2026-11-17T15:46:03Z' }} crashTime="2026-11-17T15:48:03Z" onShowAll={() => {}} />))
654
+ // What ties the hidden kill to this crash: its timing, not a bare claim of cause.
655
+ expect(html).toContain('This view hides the worker’s record of a memory-limit kill, 2m before this crash.')
656
+ expect(html).not.toContain('the cause of this crash')
657
+ expect(text(renderToStaticMarkup(<HiddenKillNotice kill={{ current: true }} onShowAll={() => {}} />))).toContain('a memory-limit kill, tied to this crash.')
658
+ expect(html).toContain('Show all sources')
659
+ expect(text(renderToStaticMarkup(<HiddenKillNotice kill={{ current: false }} onShowAll={() => {}} />))).toContain('attempt whose tie to the crash is unconfirmed')
660
+ })
661
+
662
+ it('says a worker Pod that is gone in product words, never the raw API error', async () => {
663
+ const html = await render({ ...base, state: 'running', origin: 'worker', worker: { worker: 'w', namespace: 'agents', pool: 'agent-pool', pod: 'agent-pool-worker-1' }, reasonCode: 'workerPodGone', reason: 'pods "agent-pool-worker-1" not found', searched: [], lines: [] })
664
+ expect(html).toContain('The worker Pod agent-pool-worker-1 is gone; Substrate still lists the worker')
665
+ expect(html).not.toContain('not found')
666
+ })
667
+
668
+ it('hands over the external query when the former worker logs are unavailable', async () => {
669
+ const html = await render({ ...base, origin: 'none', reasonCode: 'nodeGone', node: 'ip-10-0-4-57', searched: [], lines: [] })
670
+ expect(html).toContain('is gone from the cluster')
671
+ expect(html).toContain('ate.actor.name="lit-review-0193" ate.atespace="research"')
672
+ expect(html).not.toContain('kubectl ate logs actor lit-review-0193 -a research')
673
+ })
674
+ })
675
+
676
+ describe('A running actor on a bad worker', () => {
677
+ it('gives the worker banner the worker row’s next step and command', () => {
678
+ const d = actorDetail({ actor: { ...actorDetail().actor, state: 'running', crash: undefined }, attention: [], row: actorRow({ workerImpact: { kind: 'unavailable', reading: 'Its Pod is not Ready.', nextStep: 'Find why the worker Pod is not Ready.', command: 'kubectl describe pod agent-pool-worker-0 -n radar-substrate-demo' } }) })
679
+ const raw = renderToStaticMarkup(<MemoryRouter><SubstrateActorOverview detail={d} /></MemoryRouter>)
680
+ const html = plain(text(raw))
681
+ expect(html).toContain('Next step: Find why the worker Pod is not Ready.')
682
+ expect(html).toContain('kubectl describe pod agent-pool-worker-0 -n radar-substrate-demo')
683
+ // A command never wraps, inside a token or between them: it sits whole on its own line and scrolls.
684
+ const code = /<code class="([^"]*)">([^<]*)<\/code>/.exec(raw)!
685
+ expect(code[2]).toBe('kubectl describe pod agent-pool-worker-0 -n radar-substrate-demo')
686
+ expect(code[1].split(' ')).toContain('whitespace-pre')
687
+ expect(code[1].split(' ')).toContain('overflow-x-auto')
688
+ // On its own line, after the step's sentence rather than inside it.
689
+ expect(raw).toMatch(/Recovery steps.*?inert=.*?Target actor.*?data-command-line/)
690
+ expect(raw).not.toContain('break-all')
691
+ })
692
+
693
+ it('qualifies its state chip and says what the worker means for it first', () => {
694
+ const d = actorDetail({ actor: { ...actorDetail().actor, state: 'running', crash: undefined, assignment: { worker: 'w', namespace: 'agents', pool: 'agent-pool', pod: 'agent-pool-worker-0', node: 'n' } }, attention: [], row: actorRow({ workerImpact: { kind: 'unavailable', reading: 'Substrate still records it running, but its worker Pod is not Ready.', nextStep: 'x', command: 'y' } }) })
695
+ const before = state.logs
696
+ try {
697
+ const line = (secondsAgo: number) => ({ kind: 'container' as const, time: new Date(Date.now() - secondsAgo * 1000).toISOString(), container: 'agent', message: 'Tool call', text: 'x', namespace: 'agents', pod: 'agent-pool-worker-0' })
698
+ const logs = { actor: { atespace: 'research', name: 'a' }, state: 'running' as const, origin: 'worker' as const, source: 'all' as const, scanned: 10, windowFull: false, searched: [] }
699
+ const render = () => plain(text(renderToStaticMarkup(<MemoryRouter><SubstrateActorOverview detail={d} /></MemoryRouter>)))
700
+
701
+ state.logs = { ...logs, lines: [line(12)] }
702
+ const html = render()
703
+ expect(html).toContain('Worker unavailable')
704
+ // The recorded state and the time of its last line: a past line, never a claim that it runs now.
705
+ expect(html).toContain('Recorded as running; its last log line was 12s ago.')
706
+ expect(html).not.toContain('still running')
707
+ expect(html).not.toContain('may not be serving')
708
+
709
+ state.logs = { ...logs, lines: [line(20 * 60)] }
710
+ expect(render()).toContain('Recorded as running; its last log line was 20m ago, so it may not be serving.')
711
+
712
+ state.logs = { ...logs, lines: [] }
713
+ expect(render()).toContain('Recorded as running; Radar found no output from it in the worker’s log, so it may not be serving.')
714
+ } finally {
715
+ state.logs = before
716
+ }
717
+ })
718
+ })
719
+
720
+ describe('A worker banner’s visible part', () => {
721
+ it('shows the cause and the next step, and folds the mechanics under Details', () => {
722
+ const reading = 'Its worker Pod is not Ready. It places no new actors there and still records this actor as running. If the Pod is deleted, Substrate marks it crashed.'
723
+ const d = actorDetail({ actor: { ...actorDetail().actor, state: 'running', crash: undefined }, attention: [], row: actorRow({ workerImpact: { kind: 'unavailable', reading, nextStep: 'Find why the worker Pod is not Ready.', command: 'kubectl describe pod w' } }) })
724
+ const html = plain(text(renderToStaticMarkup(<MemoryRouter><SubstrateActorOverview detail={d} /></MemoryRouter>)))
725
+ const details = html.indexOf('Details')
726
+ expect(html.indexOf('Its worker Pod is not Ready. Recorded as running')).toBeGreaterThan(-1)
727
+ expect(html.indexOf('Next step: Find why the worker Pod is not Ready.')).toBeLessThan(details)
728
+ expect(html.indexOf('If the Pod is deleted, Substrate marks it crashed.')).toBeGreaterThan(details)
729
+ })
730
+ })
731
+
732
+ describe('Needs attention rows', () => {
733
+ // The words a reader sees, tags apart: links and chips sit inside sentences.
734
+ const words = (html: string) => text(html).replace(/<[^>]+>/g, '')
735
+
736
+ it('folds each crash group’s known remedy and leaves the concentration visible', async () => {
737
+ const { SubstrateAttentionList } = await import('./SubstrateAttentionList')
738
+ const row = { ...poolShortRow, rule: 'crashedActors' as const, count: 14, nextStep: 'Fix the cause Substrate’s crash message names, then revert each actor.', command: 'kubectl ate revert actor <name> -a <atespace>', groups: [
739
+ { subject: { kind: 'ActorTemplate' as const, atespace: 'research', name: 'langgraph-research' }, count: 11, cause: 'memoryLimit' as const, nextStep: 'Create a template with a higher memory limit. Revert the actors, update their templates once suspended, then resume.', command: 'kubectl ate revert actor <name> -a <atespace>', thenCommand: 'kubectl ate update actor <name> -a <atespace> --template <new-template>' },
740
+ { subject: { kind: 'ActorTemplate' as const, atespace: 'code-review', name: 'claude-code-gvisor' }, count: 2 },
741
+ { subject: { kind: 'ActorTemplate' as const, atespace: 'sandbox-dev', name: 'mcp-browser' }, count: 1, cause: 'memoryLimit' as const, nextStep: 'Create a template with a higher memory limit. Revert the actors, update their templates once suspended, then resume.', command: 'kubectl ate revert actor <name> -a <atespace>', thenCommand: 'kubectl ate update actor <name> -a <atespace> --template <new-template>' },
742
+ ] }
743
+ const raw = renderToStaticMarkup(<MemoryRouter><SubstrateAttentionList rows={[row]} onOpen={() => {}} /></MemoryRouter>)
744
+ const html = words(raw)
745
+ const details = html.indexOf('Details')
746
+ // The concentration stays visible. The known cause and its command sit inside Details.
747
+ expect(html).toContain('Next step for 12 killed over their memory limit, 11 on research / langgraph-research and 1 on sandbox-dev / mcp-browser: Create a template with a higher memory limit')
748
+ expect(html.indexOf('Next step for 12 killed')).toBeGreaterThan(details)
749
+ expect(html.split('Create a template with a higher memory limit').length - 1).toBe(1)
750
+ // The rest collapse to one line with a route to them; "include": a mixed template's crashes may include memory kills.
751
+ expect(html).toContain('The other 2 include crashes for other reasons: view crashes on this template →')
752
+ expect(html).not.toContain('not all over a memory limit')
753
+ expect(html.indexOf('The other 2 include crashes')).toBeGreaterThan(details)
754
+ // Their general step, and which templates the cause's step covers, wait under Details, never with a command for all 14.
755
+ expect(html).toContain('For the other 2, on code-review / claude-code-gvisor (2): Fix the cause Substrate’s crash message names, then revert each actor.')
756
+ expect(html.indexOf('For the other 2, on')).toBeGreaterThan(details)
757
+ // The step's own line names its templates, so Details doesn't list them again.
758
+ expect(html).not.toContain('Killed over their memory limit:')
759
+ expect(html.indexOf('kubectl ate revert actor')).toBeLessThan(html.indexOf('kubectl ate update actor'))
760
+ expect(raw.match(/aria-label="Copy command"/g)).toHaveLength(2)
761
+ // Concentration, not cause.
762
+ expect(html).toContain('11 of the 14 use template research / langgraph-research')
763
+ expect(html.indexOf('11 of the 14')).toBeLessThan(details)
764
+ expect(html).not.toMatch(/from one template|caused/)
765
+ })
766
+
767
+ it('names a remedy’s templates on its line up to two, and counts more, listing them under Details', async () => {
768
+ const { SubstrateAttentionList } = await import('./SubstrateAttentionList')
769
+ const memory = { cause: 'memoryLimit' as const, nextStep: 'Revert them.', command: 'kubectl ate revert actor <name> -a <atespace>' }
770
+ const row = { ...poolShortRow, rule: 'crashedActors' as const, count: 9, nextStep: 'Fix the cause.', groups: [
771
+ { subject: { kind: 'ActorTemplate' as const, atespace: 'a', name: 'one' }, count: 5, ...memory },
772
+ { subject: { kind: 'ActorTemplate' as const, atespace: 'b', name: 'two' }, count: 2, ...memory },
773
+ { subject: { kind: 'ActorTemplate' as const, atespace: 'c', name: 'three' }, count: 1, ...memory },
774
+ { subject: { kind: 'ActorTemplate' as const, atespace: 'd', name: 'mixed' }, count: 1 },
775
+ ] }
776
+ const html = words(renderToStaticMarkup(<MemoryRouter><SubstrateAttentionList rows={[row]} onOpen={() => {}} /></MemoryRouter>))
777
+ const details = html.indexOf('Details')
778
+ expect(html).toContain('Next step for 8 killed over their memory limit, on 3 templates: Revert them.')
779
+ expect(html.indexOf('Killed over their memory limit: a / one (5), b / two (2) and c / three (1)')).toBeGreaterThan(details)
780
+ expect(html).toContain('The other one crashed for another reason')
781
+ })
782
+
783
+ it('says how long a row’s condition has held as a lower bound, never "since … ago"', async () => {
784
+ const { SubstrateAttentionList } = await import('./SubstrateAttentionList')
785
+ const html = words(renderToStaticMarkup(<MemoryRouter><SubstrateAttentionList rows={[{ ...poolShortRow, since: minutesAgo(60) }]} onOpen={() => {}} /></MemoryRouter>))
786
+ expect(html).toContain('for at least 1h')
787
+ expect(html).not.toMatch(/since \S+ ago/)
788
+ })
789
+
790
+ it('puts a row’s command on its own line under the step, never inside the sentence', async () => {
791
+ const { SubstrateAttentionList } = await import('./SubstrateAttentionList')
792
+ const raw = renderToStaticMarkup(<MemoryRouter><SubstrateAttentionList rows={[{ ...poolShortRow, nextStep: 'Revert each.', command: 'kubectl ate revert actor <name> -a <atespace>' }]} onOpen={() => {}} /></MemoryRouter>)
793
+ expect(raw).toMatch(/Revert each\.<div [^>]*data-command-line[^>]*><span[^>]*><code class="[^"]*">kubectl ate revert actor &lt;name&gt; -a &lt;atespace&gt; --kubeconfig [^<]+<\/code>/)
794
+ // The fill-in hint follows the chip, inside the same line.
795
+ expect(raw).toMatch(/<\/code>.*?<\/span><span[^>]*>fill in &lt;name&gt;, &lt;atespace&gt;<\/span><\/div>/)
796
+ })
797
+
798
+ it('folds a crash row’s "Latest" provenance under Details, and sends several other templates there too', async () => {
799
+ const { SubstrateAttentionList } = await import('./SubstrateAttentionList')
800
+ const opened: unknown[] = []
801
+ const row = { ...poolShortRow, rule: 'crashedActors' as const, count: 15, reading: 'Latest: research / lit-review-0193. Substrate’s message: killed for exceeding its memory limit', nextStep: 'Fix the cause.', groups: [
802
+ { subject: { kind: 'ActorTemplate' as const, atespace: 'research', name: 'lg' }, count: 12, cause: 'memoryLimit' as const, nextStep: 'Revert them.', command: 'kubectl ate revert actor <name> -a <atespace>' },
803
+ { subject: { kind: 'ActorTemplate' as const, atespace: 'code', name: 'cc' }, count: 2 },
804
+ { subject: { kind: 'ActorTemplate' as const, atespace: 'support', name: 'adk' }, count: 1 },
805
+ ] }
806
+ const html = words(renderToStaticMarkup(<MemoryRouter><SubstrateAttentionList rows={[row]} onOpen={(x) => opened.push(x)} /></MemoryRouter>))
807
+ const details = html.indexOf('Details')
808
+ expect(html.indexOf('Latest: research / lit-review-0193.')).toBeGreaterThan(details)
809
+ // No one filter covers two templates: the line opens Details, where each links to its actors.
810
+ expect(html).toContain('Next step for 12 killed over their memory limit, on research / lg: Revert them.')
811
+ expect(html).toContain('The other 3 include crashes for other reasons: see Details')
812
+ expect(html).not.toContain('show them →')
813
+ expect(html.indexOf('For the other 3, on code / cc (2) and support / adk (1)')).toBeGreaterThan(details)
814
+ // A template with one crash in the rest is that crash: not a memory-limit kill, said without "all".
815
+ const single = { ...row, count: 13, groups: [row.groups[0], row.groups[2]] }
816
+ expect(words(renderToStaticMarkup(<MemoryRouter><SubstrateAttentionList rows={[single]} onOpen={(x) => opened.push(x)} /></MemoryRouter>))).toContain('The other one crashed for another reason: view crashes on this template →')
817
+ })
818
+
819
+ it('links each crash group to its crashed actors', async () => {
820
+ const { SubstrateAttentionList } = await import('./SubstrateAttentionList')
821
+ const opened: unknown[] = []
822
+ const row = { ...poolShortRow, rule: 'crashedActors' as const, count: 3, subject: { kind: 'Actors' as const, filter: { state: 'crashed' } }, groups: [
823
+ { subject: { kind: 'ActorTemplate' as const, atespace: 'research', name: 'lg' }, count: 2, cause: 'memoryLimit' as const, nextStep: 'Revert them.', command: 'kubectl ate revert actor <name> -a <atespace>' },
824
+ { subject: { kind: 'ActorTemplate' as const, atespace: 'code', name: 'cc' }, count: 1 },
825
+ ] }
826
+ const html = renderToStaticMarkup(<MemoryRouter><SubstrateAttentionList rows={[row]} onOpen={(s) => opened.push(s)} /></MemoryRouter>)
827
+ expect(html).toMatch(/<button[^>]*>research \/ lg<\/button>/)
828
+ expect(html).toMatch(/<button[^>]*>code \/ cc<\/button>/)
829
+ })
830
+
831
+ it('gives crashes that share one remedy that remedy once, with its command', async () => {
832
+ const { SubstrateAttentionList } = await import('./SubstrateAttentionList')
833
+ const step = 'Revert the actors, move them to a template with more memory and identical volumes, mounts and snapshot location, then resume.'
834
+ const cmd = 'kubectl ate revert actor <name> -a <atespace>'
835
+ const row = { ...poolShortRow, rule: 'crashedActors' as const, count: 3, nextStep: step, command: cmd, groups: [
836
+ { subject: { kind: 'ActorTemplate' as const, atespace: 'a', name: 'one' }, count: 2, cause: 'memoryLimit' as const, nextStep: step, command: cmd },
837
+ { subject: { kind: 'ActorTemplate' as const, atespace: 'a', name: 'two' }, count: 1, cause: 'memoryLimit' as const, nextStep: step, command: cmd },
838
+ ] }
839
+ const html = plain(text(renderToStaticMarkup(<MemoryRouter><SubstrateAttentionList rows={[row]} /></MemoryRouter>)))
840
+ expect(html.split(step).length - 1).toBe(1)
841
+ expect(html).toContain(`Next step: ${step}`)
842
+ expect(html).not.toContain('For the other')
843
+ })
844
+
845
+ it('shows a memory-limit remedy’s two commands on their own lines, the revert then the template update', async () => {
846
+ const { SubstrateAttentionList } = await import('./SubstrateAttentionList')
847
+ const step = 'Revert the actors, move them to a template with more memory and identical volumes, mounts and snapshot location, then resume. Snapshots may keep only volumes.'
848
+ const move = 'kubectl ate update actor <name> -a <atespace> --template <new-template>'
849
+ const revert = 'kubectl ate revert actor <name> -a <atespace>'
850
+ const memory = { cause: 'memoryLimit' as const, nextStep: step, command: revert, thenCommand: move }
851
+ const commands = (raw: string) => [...raw.matchAll(/<code class="[^"]*">([^<]*)<\/code>/g)].map((m) => m[1].replace(/&lt;/g, '<').replace(/&gt;/g, '>'))
852
+ // Every crash a memory-limit kill: the row's own step.
853
+ const all = { ...poolShortRow, rule: 'crashedActors' as const, count: 3, nextStep: step, command: revert, thenCommand: move, groups: [{ subject: { kind: 'ActorTemplate' as const, atespace: 'a', name: 'one' }, count: 3, ...memory }] }
854
+ let raw = renderToStaticMarkup(<MemoryRouter><SubstrateAttentionList rows={[all]} /></MemoryRouter>)
855
+ expect(commands(raw)).toEqual([revert + targetFlags, move + targetFlags])
856
+ expect(raw.match(/data-command-line/g)).toHaveLength(2)
857
+ // What the move drops is in the step itself, ahead of both commands.
858
+ expect(words(raw).indexOf('may keep only volumes')).toBeLessThan(words(raw).indexOf('kubectl ate revert'))
859
+ // Split by remedy: the memory groups' step carries both; the rest's general step carries neither.
860
+ const split = { ...poolShortRow, rule: 'crashedActors' as const, count: 4, nextStep: 'Fix the cause.', command: revert, groups: [
861
+ { subject: { kind: 'ActorTemplate' as const, atespace: 'a', name: 'one' }, count: 3, ...memory },
862
+ { subject: { kind: 'ActorTemplate' as const, atespace: 'b', name: 'mixed' }, count: 1 },
863
+ ] }
864
+ raw = renderToStaticMarkup(<MemoryRouter><SubstrateAttentionList rows={[split]} onOpen={() => {}} /></MemoryRouter>)
865
+ expect(commands(raw)).toEqual([revert + targetFlags, move + targetFlags])
866
+ })
867
+
868
+ it('reads a link’s worker-impact filter and lets it be cleared', () => {
869
+ state.actors = actors()
870
+ const html = screen('/substrate/actors?worker=agent-pool-worker-2&impact=restarted')
871
+ expect(state.lastQuery?.impact).toBe('restarted')
872
+ expect(html).toContain('Sandbox lost')
873
+ screen('/substrate/actors?impact=bogus')
874
+ expect(state.lastQuery?.impact).toBeUndefined()
875
+ })
876
+
877
+ it('shows every critical row before the fold, so lost sandboxes are never folded under warnings', async () => {
878
+ const { SubstrateAttentionList } = await import('./SubstrateAttentionList')
879
+ const row = (i: number, severity: 'critical' | 'warning') => ({ ...poolShortRow, id: `r${i}`, severity, title: `row ${i}` })
880
+ const rows = [row(1, 'critical'), row(2, 'critical'), row(3, 'critical'), row(4, 'critical'), row(5, 'warning'), row(6, 'warning')]
881
+ const html = text(renderToStaticMarkup(<MemoryRouter><SubstrateAttentionList rows={rows} /></MemoryRouter>))
882
+ expect(html).toContain('Show 2 more')
883
+ })
884
+
885
+ it('shows a row’s cause in one sentence and its mechanics under Details, a worker row’s too', async () => {
886
+ const { SubstrateAttentionList } = await import('./SubstrateAttentionList')
887
+ const row = {
888
+ id: 'workerRestarting:w', rule: 'workerRestarting' as const, severity: 'critical' as const,
889
+ title: '3 actors lost their sandboxes when agent-pool-worker-2 restarted',
890
+ reading: 'They may still show running until Substrate reconciles the worker and marks them crashed. 3 actors ran under an earlier process of the worker, replaced at epoch 4; Substrate has observed epoch 3.',
891
+ nextStep: 'Revert each to its newest stored generation now.', command: 'kubectl ate revert actor <name> -a <atespace>',
892
+ subject: { kind: 'Actors' as const, filter: { worker: 'agent-pool-worker-2', impact: 'restarted' } }, count: 3,
893
+ }
894
+ const html = words(renderToStaticMarkup(<MemoryRouter><SubstrateAttentionList rows={[row]} /></MemoryRouter>))
895
+ const details = html.indexOf('Details')
896
+ // The qualifier stays in the visible line.
897
+ expect(html.indexOf('They may still show running until Substrate reconciles the worker and marks them crashed.')).toBeLessThan(details)
898
+ expect(html.indexOf('Next step: Revert each')).toBeGreaterThan(details)
899
+ expect(html.indexOf('replaced at epoch 4')).toBeGreaterThan(details)
900
+ })
901
+
902
+ it('colours each row by its severity, alert orange between critical and warning', async () => {
903
+ const { SubstrateAttentionList } = await import('./SubstrateAttentionList')
904
+ const { toneTextClass } = await import('@skyhook-io/k8s-ui')
905
+ const rows = (['critical', 'alert', 'warning'] as const).map((severity, i) => ({ ...poolShortRow, id: `r${i}`, severity, title: `row ${severity}` }))
906
+ const html = renderToStaticMarkup(<MemoryRouter><SubstrateAttentionList rows={rows} /></MemoryRouter>)
907
+ for (const [severity, tone] of [['critical', 'unhealthy'], ['alert', 'alert'], ['warning', 'degraded']] as const) {
908
+ expect(html).toMatch(new RegExp(`data-severity="${severity}".*?class="[^"]*${toneTextClass(tone)}"[^>]*>.*?row ${severity}</div>`))
909
+ }
910
+ })
911
+
912
+ it('shows the next step once, with its command as a chip, and the reading’s first sentence whole', async () => {
913
+ const { SubstrateAttentionList } = await import('./SubstrateAttentionList')
914
+ const row = { ...poolShortRow, reading: 'Substrate places no new actors on 2 of its workers. Kubernetes reports the pool scaling.', nextStep: 'Read the worker’s log.', command: 'kubectl logs -n agents agent-pool-worker-0' }
915
+ const html = plain(text(renderToStaticMarkup(<MemoryRouter><SubstrateAttentionList rows={[row]} /></MemoryRouter>)))
916
+ expect(html).toContain('Substrate places no new actors on 2 of its workers.')
917
+ expect(html.match(/Next step:/g)).toHaveLength(1)
918
+ expect(html).toContain('kubectl logs -n agents agent-pool-worker-0')
919
+ expect(html).toContain('aria-label="Copy command"')
920
+ expect(html).not.toContain('fill in')
921
+ })
922
+
923
+ it('says which parts of a fleet row’s command to fill in', async () => {
924
+ const { SubstrateAttentionList } = await import('./SubstrateAttentionList')
925
+ const row = { ...poolShortRow, command: 'kubectl ate update actor <name> -a <atespace> --template <new-template>' }
926
+ const html = plain(text(renderToStaticMarkup(<MemoryRouter><SubstrateAttentionList rows={[row]} /></MemoryRouter>)))
927
+ expect(html).toContain('fill in &lt;name&gt;, &lt;atespace&gt;, &lt;new-template&gt;')
928
+ })
929
+
930
+ it('shows a worker problem’s actors under it, linked, not as rows of their own', async () => {
931
+ const { SubstrateAttentionList } = await import('./SubstrateAttentionList')
932
+ const row = {
933
+ id: 'workerUnavailable:w', rule: 'workerUnavailable' as const, severity: 'critical' as const,
934
+ title: 'Worker agent-pool-worker-0 has been unavailable for at least 1h', reading: 'Substrate places no new actors on it, and 6 actors are still assigned.', nextStep: 'x',
935
+ subject: { kind: 'Worker' as const, namespace: 'ns', name: 'agent-pool-worker-0' }, count: 6,
936
+ sample: [{ atespace: 'a', name: 'one' }, { atespace: 'a', name: 'two' }],
937
+ }
938
+ const raw = text(renderToStaticMarkup(<MemoryRouter><SubstrateAttentionList rows={[row]} onOpen={() => {}} /></MemoryRouter>))
939
+ const html = plain(raw)
940
+ // The consequence leads. The assignment links sit inside Details.
941
+ expect(html).toContain('Substrate places no new actors on it, and 6 actors are still assigned.')
942
+ expect(html).toContain('View all actors assigned to this worker →')
943
+ expect(html).toContain('Actors on it:')
944
+ expect(html).toContain('>one<')
945
+ expect(html).toContain('view all assignments →')
946
+ })
947
+ })
948
+
949
+ const helper = { namespace: 'kagent', name: 'k8s-helper' }
950
+ const helperSession = (overrides: Partial<KagentAgentAttribution> = {}) =>
951
+ actorRow({ atespace: 'kagent', name: 'session-01a1faa2-b3e3-7dd3-ae2d-3114122d4291', template: { atespace: 'kagent', name: 'k8s-helper-aa5e9426eb2e' }, state: 'suspended', reason: undefined,
952
+ kagent: { sessionId: '01a1faa2-b3e3-7dd3-ae2d-3114122d4291', kind: 'agentSession', agent: helper, revision: 'aa5e9426eb2ead1c0f65f5c97cf535a9f41038ecd7f8f2b9a7ecc6d925987f40', newSessions: true, desired: true, ...overrides } })
953
+
954
+ describe('kagent sessions in the Actors list', () => {
955
+ it('shows the Agent column only where kagent is served, naming exact Agents and why the others are none', () => {
956
+ state.kagentSupport = 'supported'
957
+ state.actors = actors()
958
+ expect(plain(screen())).not.toContain('kagent Agent')
959
+ state.actors = actors({ kagentAgents: { state: 'full' }, rows: [
960
+ helperSession(),
961
+ actorRow({ atespace: 'kagent', name: 'session-9b2d6c1e-4f3a-4e8b-9c7d-1a2b3c4d5e6f', kagent: { sessionId: '9b2d6c1e-4f3a-4e8b-9c7d-1a2b3c4d5e6f', kind: 'sandbox' } }),
962
+ actorRow({ atespace: 'kagent', name: 'session-2c4e6a8b-0d1f-4a3b-8c5d-7e9f0a1b2c3d', kagent: { sessionId: '2c4e6a8b-0d1f-4a3b-8c5d-7e9f0a1b2c3d', kind: 'unattributed', reason: 'earlierRevision', candidates: [helper] } }),
963
+ actorRow({ name: 'lit-0201' }),
964
+ ] })
965
+ const raw = screen()
966
+ const html = plain(raw)
967
+ expect(html).toContain('kagent Agent')
968
+ // The Agent's namespace is the atespace under the actor's name, so the cell names the Agent alone.
969
+ expect(raw).toMatch(/>helper<\/span>/)
970
+ expect(html).not.toContain('kagent/k8s-helper')
971
+ expect(html).toContain('kagent sandbox')
972
+ expect(html).toContain('earlier revision')
973
+ // A session's actor reads as its short id, not session-<uuid> over four lines.
974
+ expect(html).toContain('session …122d4291')
975
+ expect(raw).not.toMatch(/>[^<]*session-01a1faa2-b3e3/)
976
+ expect(raw).toContain('aria-label="Open actor session-01a1faa2-b3e3-7dd3-ae2d-3114122d4291"')
977
+ // A hint names the Agent only in the hover, never in the cell.
978
+ state.actors = actors({ kagentAgents: { state: 'full' }, rows: [
979
+ actorRow({ atespace: 'kagent', name: 'session-2c4e6a8b-0d1f-4a3b-8c5d-7e9f0a1b2c3d', template: { atespace: 'kagent', name: 'k8s-helper-0123456789ab' }, kagent: { sessionId: '2c4e6a8b-0d1f-4a3b-8c5d-7e9f0a1b2c3d', kind: 'unattributed', reason: 'earlierRevision', candidates: [helper] } }),
980
+ ] })
981
+ expect(screen()).not.toMatch(/>helper<\/span>/)
982
+
983
+ // Proven earlier revisions name the Agent, with a note.
984
+ state.actors = actors({ kagentAgents: { state: 'full' }, rows: [helperSession({ earlierRevision: true, newSessions: false, desired: false, revision: '0123456789ab' })] })
985
+ const earlier = screen()
986
+ expect(earlier).toMatch(/>helper<\/span>/)
987
+ expect(plain(earlier)).toContain('earlier revision')
988
+ })
989
+
990
+ it('sends the agent and kagent filters only to a Radar that serves them', () => {
991
+ state.actors = actors({ kagentAgents: { state: 'full' }, rows: [helperSession()] })
992
+ state.kagentSupport = 'supported'
993
+ expect(plain(screen())).toContain('Any kagent link')
994
+ screen('/substrate/actors?agent=kagent%2Fk8s-helper&kagent=unattributed')
995
+ expect(state.lastQuery).toMatchObject({ agent: 'kagent/k8s-helper', kagent: 'unattributed' })
996
+ expect(state.queryEnabled).toBe(true)
997
+
998
+ // An older Radar would ignore them and list every actor under the filter's name: nothing is asked.
999
+ state.kagentSupport = 'unsupported'
1000
+ const html = plain(screen('/substrate/actors?agent=kagent%2Fk8s-helper'))
1001
+ expect(state.lastQuery?.agent).toBeUndefined()
1002
+ expect(state.queryEnabled).toBe(false)
1003
+ expect(html).toContain('needs a newer Radar')
1004
+ state.kagentSupport = 'supported'
1005
+ })
1006
+
1007
+ it('names the Agent in the filter chip', () => {
1008
+ state.actors = actors({ kagentAgents: { state: 'full' }, rows: [helperSession()] })
1009
+ expect(plain(screen('/substrate/actors?agent=kagent%2Fk8s-helper'))).toContain('kagent Agent: kagent/k8s-helper')
1010
+ })
1011
+ })
1012
+
1013
+ describe('kagent session on the actor page', () => {
1014
+ const session = '01a1faa2-b3e3-7dd3-ae2d-3114122d4291'
1015
+ const page = (kagent?: NonNullable<ReturnType<typeof actorRow>['kagent']>) => {
1016
+ const d = actorDetail()
1017
+ const detail = { ...d, actor: { ...d.actor, atespace: 'kagent', name: `session-${session}`, kagent: { sessionId: session } }, row: { ...d.row, kagent }, attention: [] }
1018
+ return plain(text(renderToStaticMarkup(<MemoryRouter><SubstrateActorOverview detail={detail} onOpenSubject={() => {}} /></MemoryRouter>)))
1019
+ }
1020
+
1021
+ it('names the session and its Agent, says the chat isn’t visible, and names the Agent in the recovery step', () => {
1022
+ const html = page({ sessionId: session, kind: 'agentSession', agent: helper, revision: 'aa5e9426eb2e', newSessions: true, desired: true })
1023
+ expect(html).toContain('session …122d4291')
1024
+ expect(html).toContain('kagent/k8s-helper')
1025
+ expect(html).toContain('Conversation outcome: not visible to Radar')
1026
+ expect(html).toContain('This actor is a session of kagent Agent kagent/k8s-helper. Recover it through kagent (its RevertSession API')
1027
+ })
1028
+
1029
+ it('says a session on a proven earlier revision is the Agent’s, on an older revision', () => {
1030
+ const html = page({ sessionId: session, kind: 'agentSession', agent: helper, earlierRevision: true, revision: 'aa5e9426eb2e' })
1031
+ expect(html).toContain('kagent/k8s-helper')
1032
+ expect(html).toContain('on an earlier revision (aa5e9426eb2e) than the one new sessions start on')
1033
+ })
1034
+
1035
+ it('says in words why a session is tied to no Agent', () => {
1036
+ expect(page({ sessionId: session, kind: 'unattributed', reason: 'agentNotReadable' })).toContain('Radar didn’t read kagent Agents in namespace kagent (not read).')
1037
+ expect(page({ sessionId: session, kind: 'unattributed', reason: 'earlierRevision', candidates: [helper] })).toContain('named for kagent/k8s-helper, but for neither of its current revisions')
1038
+ // Without attribution (an older Radar), the session still shows, with kagent's step.
1039
+ const older = page(undefined)
1040
+ expect(older).toContain('session …122d4291')
1041
+ expect(older).toContain('This actor looks like a kagent session.')
1042
+ })
1043
+ })
1044
+
1045
+ describe('kagent filters where the Agents weren’t read', () => {
1046
+ it('says the count is a lower bound and why, rather than that nothing matches', () => {
1047
+ state.kagentSupport = 'supported'
1048
+ for (const [agents, why] of [[{ state: 'denied' as const }, 'you can’t list them'], [{ state: 'syncing' as const }, 'still syncing']] as const) {
1049
+ state.actors = actors({ coverage: { state: 'full', count: 4 }, total: 0, counts: undefined, rows: [], kagentAgents: agents, kagentUnread: ['kagent'] })
1050
+ const html = plain(screen('/substrate/actors?agent=kagent%2Fk8s-helper'))
1051
+ expect(html).toContain(`Radar couldn’t read kagent Agents in kagent (${why}), so a session there could be any Agent’s`)
1052
+ expect(html).toContain('No actors match where Radar could read kagent’s Agents; it couldn’t read them in kagent.')
1053
+ expect(html).not.toContain('No actors match.')
1054
+ }
1055
+ })
1056
+
1057
+ it('reads a non-empty total as at least', () => {
1058
+ state.actors = actors({ coverage: { state: 'full', count: 4 }, total: 1, rows: [helperSession()], kagentAgents: { state: 'partial', allowedNamespaces: ['research'] }, kagentUnread: ['kagent'] })
1059
+ expect(plain(screen('/substrate/actors?kagent=agentSession'))).toContain('of at least 1')
1060
+ })
1061
+
1062
+ it('keeps a way to clear a link’s kagent filter on a Radar that can’t apply it', () => {
1063
+ state.kagentSupport = 'unsupported'
1064
+ const html = plain(screen('/substrate/actors?kagent=unattributed'))
1065
+ expect(html).toContain('kagent: Not tied to an Agent')
1066
+ expect(html).toContain('Clear kagent filters')
1067
+ state.kagentSupport = 'supported'
1068
+ })
1069
+
1070
+ it('wraps a long Agent name after its hyphens, never mid-word', () => {
1071
+ state.actors = actors({ kagentAgents: { state: 'full' }, rows: [helperSession({ agent: { namespace: 'kagent', name: 'spike-edit-agent' } })] })
1072
+ const raw = screen()
1073
+ expect(raw).toMatch(/>spike-<\/span>/)
1074
+ expect(raw).toMatch(/>edit-<\/span>/)
1075
+ })
1076
+ })
1077
+
1078
+ describe('kagent filters while support is unknown', () => {
1079
+ it('says it is checking while capabilities load, and offers to clear once the check fails', () => {
1080
+ state.kagentSupport = 'unknown'
1081
+ state.kagentUpgrade = null
1082
+ let html = plain(screen('/substrate/actors?agent=kagent%2Fk8s-helper'))
1083
+ expect(state.queryEnabled).toBe(false)
1084
+ expect(html).toContain('Checking whether this Radar supports kagent filters…')
1085
+ expect(html).not.toContain('Clear kagent filters')
1086
+
1087
+ state.kagentUpgrade = { feature: 'kagent Agent sessions in Agent Substrate' }
1088
+ html = plain(screen('/substrate/actors?agent=kagent%2Fk8s-helper'))
1089
+ expect(html).toContain('Radar couldn’t check whether this Radar supports kagent filters')
1090
+ expect(html).toContain('Clear kagent filters')
1091
+ state.kagentSupport = 'supported'
1092
+ state.kagentUpgrade = null
1093
+ })
1094
+ })