@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,956 @@
1
+ import { Fragment, useMemo, type ReactNode } from 'react'
2
+ import { clsx } from 'clsx'
3
+ import { useSearchParams } from 'react-router-dom'
4
+ import {
5
+ DimensionValue,
6
+ FactGrid,
7
+ FactRow,
8
+ OpenIssueContext,
9
+ RefLink,
10
+ SectionHeading,
11
+ StatusDot,
12
+ Tooltip,
13
+ WorkspaceCard,
14
+ WorkspaceProblemCallout,
15
+ formatAge,
16
+ toneTextClass,
17
+ type HealthLevel,
18
+ type NavigateToResource,
19
+ type ResourceRef,
20
+ type StatusBadge,
21
+ type WorkspaceProblem,
22
+ } from '@skyhook-io/k8s-ui'
23
+ import { genericConditionTone } from '@skyhook-io/k8s-ui/components/resources/renderers/GenericRenderer'
24
+ import { FATAL_WAITING_REASONS } from '@skyhook-io/k8s-ui/components/resources/resource-utils'
25
+ import {
26
+ getAgentRuntimeStatus,
27
+ getSandboxWarmPoolReadyOfDesired,
28
+ getSandboxClaimStatus,
29
+ getSandboxClaimWarmPool,
30
+ getSandboxOperatingMode,
31
+ getSandboxStatus,
32
+ getSandboxWarmPoolStatus,
33
+ getSandboxWarmPoolTemplate,
34
+ sandboxPodImagePullNextStep,
35
+ sandboxPodName,
36
+ podOwnersCommand,
37
+ } from '@skyhook-io/k8s-ui/components/resources/resource-utils-agent-runtimes'
38
+ import type { AgentSandboxAttention, AgentSandboxWorkspaceResponse } from '../../api/agentSandbox'
39
+ import { useAgentSandboxWorkspace } from '../../api/agentSandbox'
40
+ import { useRadarFeature, useResource, useResourceEvents, useResourceWithRelationships } from '../../api/client'
41
+ import { useNavCustomization } from '../../context/NavCustomization'
42
+ import { useNamespacedCapabilities } from '../../contexts/CapabilitiesContext'
43
+ import { buildWorkloadPath, refToSelectedResource } from '../../utils/navigation'
44
+ import { issuesPathForSubject } from '../../utils/page-links'
45
+ import { CommandChip } from '../substrate/shared'
46
+ import { SectionTable } from '../workspace/layout'
47
+ import { WorkspaceConditions } from '../workspace/WorkspaceConditions'
48
+ import { useWorkspaceNavigate } from '../workspace/useWorkspaceNavigate'
49
+ import { poolClaimsPath, poolNotReadyPath, stateMessage } from './AgentSandboxTables'
50
+ import { readInNamespace, readItems, useAgentSandboxLists } from './data'
51
+ import { objectKey, readingLabel, schedulerReason, serverReadings, warmPoolBadge } from './labels'
52
+ import { claimSandboxName, poolClaims, sandboxController, sandboxPod, type PodAnswer } from './lists'
53
+ import { AGENT_SANDBOX_EXTENSIONS_GROUP, AGENT_SANDBOX_GROUP, SANDBOXES_PATH, SANDBOX_WARM_POOLS_PATH } from './routes'
54
+ import { Absent, ExpiryCell, KIND_LIST_PERMISSION, ReadingBadge, SourceText } from './shared'
55
+ import { attentionProblem } from './workspace'
56
+
57
+ // A Sandbox, SandboxClaim or SandboxWarmPool's composed Overview, wherever its
58
+ // drawer or full view opens: one problem callout, explicit drawer actions,
59
+ // At a glance, About, and folded Controller conditions. Framed cards on full
60
+ // pages, flat sections in drawers (never cards inside cards).
61
+
62
+ export type AgentSandboxSummaryKind = 'Sandbox' | 'SandboxClaim' | 'SandboxWarmPool'
63
+
64
+ type Subject = { kind: string; namespace: string; name: string }
65
+
66
+ const sameRef = (r: { kind: string; namespace?: string; name: string }, s: Subject) =>
67
+ r.kind === s.kind && (r.namespace ?? '') === s.namespace && r.name === s.name
68
+
69
+ const RANK: Record<HealthLevel, number> = { unhealthy: 0, alert: 1, degraded: 2, unknown: 3, healthy: 4, neutral: 5 }
70
+ const LOG_FAILURE_REASONS = new Set(['PodFailed', 'CrashLoopBackOff'])
71
+
72
+ function findCondition(resource: any, type: string): any | undefined {
73
+ const conditions = resource?.status?.conditions
74
+ return Array.isArray(conditions) ? conditions.find((c: any) => c?.type === type) : undefined
75
+ }
76
+
77
+ /** First non-zero terminated container exit summary from a read Pod, if any. */
78
+ export function podExitSummary(pod: any): string | undefined {
79
+ if (!pod) return undefined
80
+ const statuses: any[] = [
81
+ ...(Array.isArray(pod?.status?.initContainerStatuses) ? pod.status.initContainerStatuses : []),
82
+ ...(Array.isArray(pod?.status?.containerStatuses) ? pod.status.containerStatuses : []),
83
+ ]
84
+ for (const cs of statuses) {
85
+ const t = cs?.state?.terminated ?? cs?.lastState?.terminated
86
+ if (t && typeof t.exitCode === 'number' && t.exitCode !== 0) {
87
+ const container = typeof cs?.name === 'string' && cs.name ? `Container "${cs.name}"` : 'Container'
88
+ return `${container} exited with code ${t.exitCode}${t.reason ? ` (${t.reason})` : ''}.`
89
+ }
90
+ }
91
+ return undefined
92
+ }
93
+
94
+ /**
95
+ * The server's rows that read this object. Its own rows when it has any;
96
+ * otherwise the rows that fold it in: a warm pool's reserve row names its
97
+ * sandboxes that aren't ready, the controller's row the Sandboxes waiting on
98
+ * it, and a Sandbox's row stands for the claim it belongs to. `unknown` when
99
+ * the server kept only some of its rows and none is about this object.
100
+ */
101
+ export function objectReadings(data: AgentSandboxWorkspaceResponse, subject: Subject): { own: AgentSandboxAttention[]; folded: AgentSandboxAttention[]; unknown: boolean } {
102
+ const own = data.attention.filter((a) => sameRef(a.subject, subject))
103
+ if (own.length > 0) return { own, folded: [], unknown: false }
104
+ const folded = data.attention.filter(
105
+ (a) =>
106
+ a.related?.refs.some((r) => sameRef(r, subject)) ||
107
+ (subject.kind === 'SandboxClaim' && a.relations?.some((r) => r.role === 'owner' && sameRef(r.ref, subject))),
108
+ )
109
+ return { own, folded, unknown: folded.length === 0 && data.attentionTotal > data.attention.length }
110
+ }
111
+
112
+ /**
113
+ * A row as the drawer/page callout shows it:
114
+ * - Drops the server's name-guessed Pod ref (the Pod row links the real owned Pod),
115
+ * except for suspensionBlocked where the conflicting Pod is foreign by definition.
116
+ * - Strips inline parenthetical kubectl commands from nextStep so the command renders
117
+ * as a clean CommandChip in the Conflicting Pod row rather than prose.
118
+ * - Adds the container exit code to PodFailed / CrashLoopBackOff callouts when the Pod was read.
119
+ */
120
+ export function drawerProblem(a: AgentSandboxAttention, pod?: any): WorkspaceProblem {
121
+ const p = attentionProblem(a)
122
+ if (a.rule === 'suspensionBlocked') {
123
+ const quoted = a.command ? ` (${a.command})` : ''
124
+ const nextStep = quoted && p.nextStep?.includes(quoted) ? p.nextStep.replace(quoted, '') : p.nextStep
125
+ return { ...p, nextStep }
126
+ }
127
+ const refs = p.related?.refs.filter((r) => r.kind !== 'Pod') ?? []
128
+ const nextStep = (a.subject.kind === 'Sandbox' && a.rule === 'failed' && sandboxPodImagePullNextStep(a.reason, pod)) || p.nextStep
129
+ const exit = a.subject.kind === 'Sandbox' && a.rule === 'failed' && a.reason && LOG_FAILURE_REASONS.has(a.reason) ? podExitSummary(pod) : undefined
130
+ const detail = [exit, p.detail].filter(Boolean).join(' ') || undefined
131
+ return { ...p, detail, nextStep, related: p.related && refs.length > 0 ? { ...p.related, refs } : undefined }
132
+ }
133
+
134
+ function statusOf(kind: AgentSandboxSummaryKind, resource: any): StatusBadge {
135
+ if (kind === 'Sandbox') return getSandboxStatus(resource)
136
+ if (kind === 'SandboxClaim') return getSandboxClaimStatus(resource)
137
+ return getSandboxWarmPoolStatus(resource)
138
+ }
139
+
140
+ /**
141
+ * Conditions that report a problem the reading doesn't already explain. The
142
+ * reading is Ready's; it explains PodScheduled when the scheduler is its
143
+ * source and Suspended when it is a refused suspension.
144
+ */
145
+ export function otherConditions(resource: any, status: StatusBadge, rows: AgentSandboxAttention[]): any[] {
146
+ const conditions: any[] = Array.isArray(resource?.status?.conditions) ? resource.status.conditions : []
147
+ const covered = new Set(['Ready'])
148
+ const scheduled = conditions.find((c) => c?.type === 'PodScheduled')
149
+ if (rows.some((a) => a.rawDetailSource === 'scheduler') || (scheduled?.status === 'False' && scheduled.reason === status.text)) covered.add('PodScheduled')
150
+ if (status.text === 'Suspension blocked' || rows.some((a) => a.rule === 'suspensionBlocked')) covered.add('Suspended')
151
+ return conditions.filter((c) => c?.type && !covered.has(c.type) && ['fail', 'warning', 'unclear'].includes(genericConditionTone(resource, c)))
152
+ }
153
+
154
+ function FlatSection({ title, children, className }: { title?: ReactNode; children: ReactNode; className?: string }) {
155
+ return (
156
+ <section className={clsx('border-t border-theme-border-subtle pt-3 first:border-t-0 first:pt-0', className)}>
157
+ {title && <SectionHeading>{title}</SectionHeading>}
158
+ {children}
159
+ </section>
160
+ )
161
+ }
162
+
163
+ function PodFact({
164
+ answer,
165
+ phase,
166
+ suspendedConfirmed,
167
+ canViewLogs,
168
+ onNavigate,
169
+ onOpenLogs,
170
+ }: {
171
+ answer: PodAnswer
172
+ phase?: string
173
+ suspendedConfirmed: boolean
174
+ canViewLogs: boolean
175
+ onNavigate: (ref: ResourceRef) => void
176
+ onOpenLogs?: (pod: ResourceRef) => void
177
+ }) {
178
+ if (suspendedConfirmed && answer.state === 'unknown') {
179
+ return (
180
+ <div>
181
+ <div className="text-theme-text-secondary">Terminated (reported by controller)</div>
182
+ <div className="mt-0.5 text-[11.5px] text-theme-text-tertiary">
183
+ Pod visibility unknown — Radar couldn’t read every Pod that could belong to it
184
+ </div>
185
+ </div>
186
+ )
187
+ }
188
+ switch (answer.state) {
189
+ case 'loading':
190
+ return <span className="text-theme-text-tertiary">Reading…</span>
191
+ case 'none':
192
+ return <span className="text-theme-text-secondary">none: no Pod Radar can read names this Sandbox as its owner</span>
193
+ case 'unknown':
194
+ return <span className="text-theme-text-tertiary">unknown: Radar couldn’t read every Pod that could belong to it</span>
195
+ }
196
+ const single = answer.pods.length === 1 ? answer.pods[0] : undefined
197
+ return (
198
+ <span className="inline-flex flex-wrap items-center gap-x-2 gap-y-0.5">
199
+ <span>
200
+ {answer.pods.map((p, i) => (
201
+ <Fragment key={p.name}>
202
+ {i > 0 && ', '}
203
+ <RefLink refTo={p} onNavigate={onNavigate} mono />
204
+ </Fragment>
205
+ ))}
206
+ {phase && <span className="text-theme-text-secondary"> · {phase}</span>}
207
+ </span>
208
+ {single && canViewLogs && onOpenLogs && (
209
+ <button type="button" onClick={() => onOpenLogs(single)} className="text-xs text-accent-text hover:underline">
210
+ Logs →
211
+ </button>
212
+ )}
213
+ </span>
214
+ )
215
+ }
216
+
217
+ export interface TemplateContainer {
218
+ name: string
219
+ image?: string
220
+ init: boolean
221
+ }
222
+
223
+ /** The containers of a Sandbox's Pod template (spec.podTemplate.spec), init containers first. */
224
+ export function templateContainers(resource: any): TemplateContainer[] {
225
+ const spec = resource?.spec?.podTemplate?.spec
226
+ const list = (items: unknown, init: boolean): TemplateContainer[] =>
227
+ Array.isArray(items) ? items.filter((c: any) => typeof c?.name === 'string').map((c: any) => ({ name: c.name, image: typeof c.image === 'string' && c.image ? c.image : undefined, init })) : []
228
+ return [...list(spec?.initContainers, true), ...list(spec?.containers, false)]
229
+ }
230
+
231
+ export type ContainerState =
232
+ | { state: 'waiting'; reason?: string; message?: string }
233
+ | { state: 'terminated'; reason?: string; message?: string; exitCode?: number }
234
+ | { state: 'running' }
235
+
236
+ /** A container's current state as the Pod Radar read reports it; undefined when the Pod reports none for it. */
237
+ export function containerState(pod: any, name: string, init: boolean): ContainerState | undefined {
238
+ const statuses: any[] = (init ? pod?.status?.initContainerStatuses : pod?.status?.containerStatuses) ?? []
239
+ const st = Array.isArray(statuses) ? statuses.find((c) => c?.name === name)?.state : undefined
240
+ if (st?.waiting) return { state: 'waiting', reason: st.waiting.reason, message: st.waiting.message }
241
+ if (st?.terminated) return { state: 'terminated', reason: st.terminated.reason, message: st.terminated.message, exitCode: st.terminated.exitCode }
242
+ if (st?.running) return { state: 'running' }
243
+ return undefined
244
+ }
245
+
246
+ function StateLine({ s }: { s: ContainerState }) {
247
+ if (s.state === 'running') return <div className="text-xs text-theme-text-secondary">Running</div>
248
+ const bad = s.state === 'waiting' ? !!s.reason && FATAL_WAITING_REASONS.has(s.reason) : s.exitCode !== undefined && s.exitCode !== 0
249
+ const head =
250
+ s.state === 'waiting'
251
+ ? `Waiting${s.reason ? `: ${s.reason}` : ''}`
252
+ : `Exited${s.exitCode !== undefined ? ` with code ${s.exitCode}` : ''}${s.reason ? ` (${s.reason})` : ''}`
253
+ return (
254
+ <div className="mt-0.5 space-y-0.5">
255
+ <div className={clsx('text-xs', bad ? toneTextClass('unhealthy') : 'text-theme-text-secondary')}>{head}</div>
256
+ {s.message && <SourceText text={s.message} />}
257
+ </div>
258
+ )
259
+ }
260
+
261
+ function ContainersFact({ containers }: { containers: TemplateContainer[] }) {
262
+ const one = containers.length === 1
263
+ return (
264
+ <ul className="space-y-1.5">
265
+ {containers.map((c) => {
266
+ return (
267
+ <li key={`${c.init ? 'init/' : ''}${c.name}`} className="min-w-0">
268
+ {!one && (
269
+ <div className="text-xs text-theme-text-tertiary">
270
+ {c.name}
271
+ {c.init && ' (init)'}
272
+ </div>
273
+ )}
274
+ {c.image ? <div className="break-all font-mono text-[12.5px]">{c.image}</div> : <Absent>no image set</Absent>}
275
+ </li>
276
+ )
277
+ })}
278
+ </ul>
279
+ )
280
+ }
281
+
282
+ function OwnerFact({ owner, resource, onNavigate }: { owner: ReturnType<typeof sandboxController>; resource: any; onNavigate: (ref: ResourceRef) => void }) {
283
+ if (owner) return <RefLink refTo={owner} onNavigate={onNavigate} mono />
284
+ const refs: any[] = Array.isArray(resource?.metadata?.ownerReferences) ? resource.metadata.ownerReferences : []
285
+ const other = refs.find((r) => r?.controller) ?? refs[0]
286
+ if (other?.kind && other?.name) {
287
+ return (
288
+ <span>
289
+ {other.kind} <span className="font-mono">{other.name}</span>
290
+ </span>
291
+ )
292
+ }
293
+ return <Absent>none: no warm pool or claim owns it</Absent>
294
+ }
295
+
296
+ function CreatedValue({ timestamp }: { timestamp?: string }) {
297
+ if (!timestamp) return <Absent>unknown</Absent>
298
+ return (
299
+ <Tooltip content={new Date(timestamp).toLocaleString()}>
300
+ <time dateTime={timestamp} className="text-theme-text-secondary">
301
+ {formatAge(timestamp)} ago
302
+ </time>
303
+ </Tooltip>
304
+ )
305
+ }
306
+
307
+ interface SummaryAction {
308
+ label: string
309
+ onClick: () => void
310
+ primary?: boolean
311
+ }
312
+
313
+ export function AgentSandboxSummary({
314
+ kind,
315
+ apiKind,
316
+ group,
317
+ namespace,
318
+ name,
319
+ resource,
320
+ onNavigate,
321
+ leadContent,
322
+ framed = false,
323
+ }: {
324
+ kind: AgentSandboxSummaryKind
325
+ apiKind: string
326
+ group?: string
327
+ namespace: string
328
+ name: string
329
+ resource: any
330
+ onNavigate?: NavigateToResource
331
+ leadContent?: ReactNode
332
+ /** Framed cards on full pages; flat sections in drawers (never cards inside cards). */
333
+ framed?: boolean
334
+ }) {
335
+ const { support } = useRadarFeature('agentSandboxWorkspace')
336
+ const query = useAgentSandboxWorkspace([namespace], { enabled: support !== 'unsupported' })
337
+ const detail = useResourceWithRelationships<any>(apiKind, namespace, name, group)
338
+ const podAnswer = sandboxPod(detail.data?.relationships, detail.isLoading)
339
+ const onePod = kind === 'Sandbox' && podAnswer.state === 'found' && podAnswer.pods.length === 1 ? podAnswer.pods[0] : undefined
340
+ const pod = useResource<any>('pods', namespace, onePod?.name ?? '', undefined, { enabled: !!onePod })
341
+ const podRead = onePod && pod.data?.metadata?.name === onePod.name ? pod.data : undefined
342
+ // Warm pools fetch namespace Sandboxes & Claims to list members (failures first) and referencing claims.
343
+ const lists = useAgentSandboxLists({ namespaces: [namespace], apiResources: undefined, enabled: kind === 'SandboxWarmPool' })
344
+ const events = useResourceEvents(apiKind, namespace, name, group)
345
+ const logs = useNamespacedCapabilities(onePod?.namespace)
346
+ const canViewLogs = logs.canViewLogs && !logs.logsUnknown
347
+ const navigateTo = useWorkspaceNavigate()
348
+ const [params] = useSearchParams()
349
+ const issuesTakenOver = !!useNavCustomization().fleetTakeoverHref?.('issues')
350
+ const navigate = (ref: ResourceRef) => onNavigate?.(refToSelectedResource(ref))
351
+ const openPodLogs = (p: ResourceRef) => navigateTo(buildWorkloadPath({ kind: 'pods', namespace: p.namespace || namespace, name: p.name, tab: 'logs' }))
352
+
353
+ const containers = kind === 'Sandbox' ? templateContainers(resource) : []
354
+ const subject = { kind, namespace, name }
355
+ const status = statusOf(kind, resource)
356
+ const server = useMemo(() => serverReadings(query.data), [query.data])
357
+ const readings = useMemo(() => (query.data ? objectReadings(query.data, { kind, namespace, name }) : undefined), [query.data, kind, namespace, name])
358
+ const own = useMemo(() => readings?.own ?? [], [readings])
359
+ const folded = readings?.folded ?? []
360
+ const pending = support !== 'unsupported' && query.isLoading
361
+ const showIssues = own.length === 0 && !pending
362
+
363
+ const waitingContainers = containers.flatMap((container) => {
364
+ const state = containerState(podRead, container.name, container.init)
365
+ return state?.state === 'waiting' && state.message ? [{ container, state }] : []
366
+ })
367
+ const effectiveLevel: HealthLevel = server.tones.get(objectKey(kind, namespace, name)) ?? status.level
368
+ const suspensionBlocked = own.some((a) => a.rule === 'suspensionBlocked') || (own.length === 0 && status.text === 'Suspension blocked')
369
+ const suspendedCond = kind === 'Sandbox' ? findCondition(resource, 'Suspended') : undefined
370
+ const suspendedConfirmed = kind === 'Sandbox' && status.text === 'Suspended' && suspendedCond?.status === 'True'
371
+ const conflictingPodName = suspensionBlocked ? sandboxPodName(resource) : ''
372
+ const conflictingCommand =
373
+ own.find((a) => a.rule === 'suspensionBlocked')?.command ??
374
+ (conflictingPodName ? podOwnersCommand(namespace, conflictingPodName) : '')
375
+
376
+ const callout = (a: AgentSandboxAttention) => {
377
+ const isSelf = sameRef(a.subject, subject)
378
+ const showLogsBtn = framed && isSelf && kind === 'Sandbox' && a.rule === 'failed' && !!a.reason && LOG_FAILURE_REASONS.has(a.reason) && !!onePod && canViewLogs
379
+ return (
380
+ <WorkspaceProblemCallout
381
+ key={a.id}
382
+ problem={drawerProblem(a, isSelf ? podRead : undefined)}
383
+ rootKind={kind}
384
+ subjectIsSelf={isSelf}
385
+ hideOrigin
386
+ onNavigate={navigate}
387
+ action={
388
+ showLogsBtn && onePod ? (
389
+ <button type="button" onClick={() => openPodLogs(onePod)} className="whitespace-nowrap text-accent-text hover:underline">
390
+ Pod logs →
391
+ </button>
392
+ ) : undefined
393
+ }
394
+ />
395
+ )
396
+ }
397
+
398
+ const others = otherConditions(resource, status, [...own, ...folded])
399
+ const conditions: any[] = Array.isArray(resource?.status?.conditions) ? resource.status.conditions : []
400
+ const ns = (n: string) => ({ namespace, name: n })
401
+
402
+ // Warm pool members (failures first) and referencing claims.
403
+ const poolMembers = useMemo(() => {
404
+ if (kind !== 'SandboxWarmPool') return [] as { name: string; tone: HealthLevel; label: string }[]
405
+ const fromList = readItems(lists.data.sandboxes)
406
+ .filter((s) => {
407
+ const owner = sandboxController(s)
408
+ return owner?.kind === 'SandboxWarmPool' && owner.name === name && (s?.metadata?.namespace ?? '') === namespace
409
+ })
410
+ .map((s) => {
411
+ const st = getSandboxStatus(s)
412
+ const sName = s?.metadata?.name ?? ''
413
+ const tone = server.tones.get(objectKey('Sandbox', namespace, sName)) ?? st.level
414
+ return { name: sName, tone, label: readingLabel(st).label }
415
+ })
416
+ if (fromList.length > 0) {
417
+ return fromList.sort((a, b) => RANK[a.tone] - RANK[b.tone] || a.name.localeCompare(b.name))
418
+ }
419
+ // Fallback to owner-ref children while list is loading or if list was denied.
420
+ const children = (detail.data?.relationships?.children ?? []).filter((r) => r.kind === 'Sandbox')
421
+ const notReadyNames = new Set(own.flatMap((a) => a.related?.refs.filter((r) => r.kind === 'Sandbox').map((r) => r.name) ?? []))
422
+ return children
423
+ .map((c) => {
424
+ const isNotReady = notReadyNames.has(c.name)
425
+ return { name: c.name, tone: (isNotReady ? 'alert' : 'unknown') as HealthLevel, label: isNotReady ? 'Not ready' : 'Status unread' }
426
+ })
427
+ .sort((a, b) => RANK[a.tone] - RANK[b.tone] || a.name.localeCompare(b.name))
428
+ }, [kind, lists.data.sandboxes, detail.data?.relationships?.children, name, namespace, server, own])
429
+
430
+ const poolRefClaims = useMemo(() => {
431
+ if (kind !== 'SandboxWarmPool' || !readInNamespace(lists.data.claims, namespace)) return undefined
432
+ const served = poolClaims(resource, readItems(lists.data.claims))
433
+ const bound = served.filter((c) => claimSandboxName(c) && getSandboxClaimStatus(c).text !== 'Expired').length
434
+ const expired = served.filter((c) => getSandboxClaimStatus(c).text === 'Expired').length
435
+ return { items: served, bound, expired }
436
+ }, [kind, lists.data.claims, namespace, resource])
437
+
438
+ const latestWarningEvent = useMemo(() => {
439
+ if (kind !== 'SandboxWarmPool') return undefined
440
+ return events.k8sEvents.find((e) => e.reason === 'WarmPoolNotProgressing' || e.eventType === 'Warning')
441
+ }, [kind, events.k8sEvents])
442
+
443
+ // Explicit action bar in drawer mode (matches CNPG's cluster drawer actions).
444
+ const drawerActions: SummaryAction[] = useMemo(() => {
445
+ if (framed) return []
446
+ const openLabel = kind === 'Sandbox' ? 'Open sandbox' : kind === 'SandboxClaim' ? 'Open claim' : 'Open warm pool'
447
+ const actions: SummaryAction[] = [
448
+ {
449
+ label: openLabel,
450
+ primary: true,
451
+ onClick: () => navigateTo(buildWorkloadPath({ kind: apiKind, group, namespace, name })),
452
+ },
453
+ ]
454
+ if (kind === 'Sandbox') {
455
+ if (suspensionBlocked && conflictingPodName) {
456
+ actions.push({
457
+ label: 'Open conflicting Pod',
458
+ onClick: () => navigate({ kind: 'Pod', group: '', namespace, name: conflictingPodName }),
459
+ })
460
+ } else if (onePod) {
461
+ if (canViewLogs) {
462
+ actions.push({ label: 'Pod logs', onClick: () => openPodLogs(onePod) })
463
+ }
464
+ actions.push({ label: 'Open Pod', onClick: () => navigate(onePod) })
465
+ }
466
+ } else if (kind === 'SandboxClaim') {
467
+ const boundSb = claimSandboxName(resource)
468
+ if (boundSb) {
469
+ actions.push({ label: 'Open Sandbox', onClick: () => navigate({ kind: 'Sandbox', group: AGENT_SANDBOX_GROUP, namespace, name: boundSb }) })
470
+ }
471
+ actions.push({
472
+ label: 'Browse warm pools',
473
+ onClick: () => navigateTo(`${SANDBOX_WARM_POOLS_PATH}&namespaces=${encodeURIComponent(namespace)}`),
474
+ })
475
+ } else if (kind === 'SandboxWarmPool') {
476
+ actions.push({
477
+ label: 'View sandboxes',
478
+ onClick: () => navigateTo(`${SANDBOXES_PATH}&pool=${encodeURIComponent(`${namespace}/${name}`)}`),
479
+ })
480
+ actions.push({
481
+ label: 'View claims',
482
+ onClick: () => navigateTo(poolClaimsPath(namespace, name)),
483
+ })
484
+ }
485
+ return actions
486
+ // eslint-disable-next-line react-hooks/exhaustive-deps
487
+ }, [framed, kind, apiKind, group, namespace, name, suspensionBlocked, conflictingPodName, onePod, canViewLogs, resource])
488
+
489
+ const Frame = framed ? WorkspaceCard : FlatSection
490
+
491
+ const claimPoolInfo = useMemo(() => {
492
+ if (kind !== 'SandboxClaim') return undefined
493
+ const pool = getSandboxClaimWarmPool(resource)
494
+ if (pool === '-') return { pool: undefined as string | undefined }
495
+ const fromAttention = own.flatMap((a) => a.relations ?? []).find((r) => r.role === 'warmPool')
496
+ const poolRow = query.data?.warmPools.find((w) => w.namespace === namespace && w.name === pool)
497
+ let presence: 'present' | 'absent' | 'unread' | 'unknown' = 'unknown'
498
+ if (poolRow) presence = 'present'
499
+ else if (fromAttention?.ref.name === pool) presence = fromAttention.presence
500
+ else if (query.data) {
501
+ const cov = query.data.coverage.warmPools
502
+ const covered = cov.state === 'notInstalled' || cov.state === 'full' || cov.allowedNamespaces?.includes(namespace)
503
+ presence = covered && query.data.warmPools.length === query.data.warmPoolsTotal ? 'absent' : 'unread'
504
+ }
505
+ return { pool, presence, poolRow }
506
+ }, [kind, resource, own, query.data, namespace])
507
+
508
+ const warmPoolSummaryRow = kind === 'SandboxWarmPool' ? query.data?.warmPools.find((w) => w.namespace === namespace && w.name === name) : undefined
509
+ const cleanupMessage = kind === 'SandboxClaim' && status.text === 'Expired' ? findCondition(resource, 'Ready')?.message : undefined
510
+ const cleanupInitiated = typeof cleanupMessage === 'string' && /\bcleanup initiated\b/i.test(cleanupMessage)
511
+ const poolBadge = kind === 'SandboxWarmPool' ? warmPoolBadge(resource, server) : undefined
512
+
513
+ return (
514
+ <OpenIssueContext.Provider value={issuesTakenOver ? undefined : (p) => navigateTo(issuesPathForSubject(p.subject, params.get('namespaces')))}>
515
+ <div className="space-y-4 p-4">
516
+ {own.length + folded.length > 0 && <div className="space-y-3">{[...own, ...folded].map(callout)}</div>}
517
+ {showIssues && leadContent}
518
+
519
+ {drawerActions.length > 0 && (
520
+ <div className="flex flex-wrap gap-2">
521
+ {drawerActions.map((a) => (
522
+ <button
523
+ key={a.label}
524
+ type="button"
525
+ onClick={a.onClick}
526
+ className={clsx(
527
+ a.primary ? 'btn-brand' : 'btn-secondary',
528
+ 'inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap px-3 py-1.5 text-xs font-medium',
529
+ )}
530
+ >
531
+ {a.label}
532
+ </button>
533
+ ))}
534
+ </div>
535
+ )}
536
+
537
+ <Frame title="At a glance">
538
+ <FactGrid>
539
+ {kind === 'Sandbox' && (
540
+ <>
541
+ <FactRow label="State">
542
+ {suspendedConfirmed ? (
543
+ <DimensionValue tone="neutral" source="Suspended=True (PodTerminated) · Sandbox status">
544
+ Controller confirms suspension
545
+ </DimensionValue>
546
+ ) : suspensionBlocked ? (
547
+ <DimensionValue tone={effectiveLevel} source="Requested: Suspended · Observed: refused (PodNotOwned)">
548
+ Suspension blocked
549
+ </DimensionValue>
550
+ ) : (
551
+ <DimensionValue
552
+ tone={effectiveLevel}
553
+ source="Ready condition · Sandbox status"
554
+ >
555
+ {readingLabel(status).label}
556
+ </DimensionValue>
557
+ )}
558
+ </FactRow>
559
+
560
+ {suspensionBlocked ? (
561
+ <FactRow label="Conflicting Pod">
562
+ <div className="space-y-1.5">
563
+ <div>
564
+ <RefLink refTo={{ kind: 'Pod', group: '', ...ns(conflictingPodName) }} onNavigate={navigate} mono />
565
+ <div className="mt-0.5 text-[11.5px] text-theme-text-tertiary">
566
+ Not owned by this Sandbox — controller refuses to delete it
567
+ </div>
568
+ </div>
569
+ {conflictingCommand && <CommandChip command={conflictingCommand} />}
570
+ </div>
571
+ </FactRow>
572
+ ) : (
573
+ <FactRow label="Pod">
574
+ <PodFact
575
+ answer={podAnswer}
576
+ phase={typeof podRead?.status?.phase === 'string' ? podRead.status.phase : undefined}
577
+ suspendedConfirmed={suspendedConfirmed}
578
+ canViewLogs={canViewLogs}
579
+ onNavigate={navigate}
580
+ onOpenLogs={openPodLogs}
581
+ />
582
+ {waitingContainers.map(({ container, state }) => (
583
+ <StateLine key={`${container.init ? 'init/' : ''}${container.name}`} s={state} />
584
+ ))}
585
+ </FactRow>
586
+ )}
587
+
588
+ {(() => {
589
+ const owner = sandboxController(resource)
590
+ return (
591
+ <>
592
+ <FactRow label={owner?.kind === 'SandboxClaim' ? 'Claim' : owner?.kind === 'SandboxWarmPool' ? 'Warm pool' : 'Owner'}>
593
+ <OwnerFact owner={owner} resource={resource} onNavigate={navigate} />
594
+ </FactRow>
595
+ <FactRow label="Expiry">
596
+ <ExpiryCell resource={resource} claimed={owner?.kind === 'SandboxClaim'} />
597
+ </FactRow>
598
+ </>
599
+ )
600
+ })()}
601
+ </>
602
+ )}
603
+
604
+ {kind === 'SandboxClaim' && (
605
+ <>
606
+ <FactRow label="State">
607
+ {status.text === 'Expired' ? (
608
+ <DimensionValue
609
+ tone="neutral"
610
+ source="Ready condition · SandboxClaim status"
611
+ >
612
+ Expired
613
+ </DimensionValue>
614
+ ) : (
615
+ <DimensionValue
616
+ tone={effectiveLevel}
617
+ source={stateMessage(resource, status) || 'Ready condition · SandboxClaim status'}
618
+ >
619
+ {readingLabel(status).label}
620
+ </DimensionValue>
621
+ )}
622
+ </FactRow>
623
+
624
+ <FactRow label="Requested pool">
625
+ {!claimPoolInfo?.pool ? (
626
+ <Absent>no warm pool</Absent>
627
+ ) : (
628
+ <div>
629
+ <div className="flex flex-wrap items-center gap-x-2 gap-y-0.5">
630
+ {claimPoolInfo.presence !== 'present' ? (
631
+ <>
632
+ <span className="font-mono">{claimPoolInfo.pool}</span>
633
+ <span className={clsx('text-xs', claimPoolInfo.presence === 'absent' ? toneTextClass('unhealthy') : 'text-theme-text-tertiary')}>
634
+ {claimPoolInfo.presence === 'absent' ? 'not found' : 'not read'}
635
+ </span>
636
+ </>
637
+ ) : (
638
+ <>
639
+ <RefLink refTo={{ kind: 'SandboxWarmPool', group: AGENT_SANDBOX_EXTENSIONS_GROUP, ...ns(claimPoolInfo.pool) }} onNavigate={navigate} mono />
640
+ {claimPoolInfo.poolRow && (
641
+ <span className="text-xs text-theme-text-secondary">
642
+ · {claimPoolInfo.poolRow.ready ?? '?'}/{claimPoolInfo.poolRow.desired ?? '?'} ready
643
+ </span>
644
+ )}
645
+ </>
646
+ )}
647
+ </div>
648
+ <div className="mt-0.5">
649
+ <button
650
+ type="button"
651
+ onClick={() => navigateTo(`${SANDBOX_WARM_POOLS_PATH}&namespaces=${encodeURIComponent(namespace)}`)}
652
+ className="text-xs text-accent-text hover:underline"
653
+ >
654
+ Browse warm pools in this namespace →
655
+ </button>
656
+ </div>
657
+ </div>
658
+ )}
659
+ </FactRow>
660
+
661
+ <FactRow label="Bound sandbox">
662
+ {(() => {
663
+ const sandbox = claimSandboxName(resource)
664
+ if (sandbox) return <RefLink refTo={{ kind: 'Sandbox', group: AGENT_SANDBOX_GROUP, ...ns(sandbox) }} onNavigate={navigate} mono />
665
+ if (status.text === 'Expired') return <Absent>not bound (expired)</Absent>
666
+ return <Absent title="The claim’s status names no Sandbox now.">not bound</Absent>
667
+ })()}
668
+ </FactRow>
669
+
670
+ <FactRow label="Expiry & cleanup">
671
+ <div>
672
+ <ExpiryCell resource={resource} />
673
+ {status.text === 'Expired' && (
674
+ <div className="mt-0.5 text-[11.5px] text-theme-text-tertiary">
675
+ {cleanupInitiated ? 'Controller initiated cleanup. ' : ''}Cleanup outcome unknown.
676
+ </div>
677
+ )}
678
+ </div>
679
+ </FactRow>
680
+ </>
681
+ )}
682
+
683
+ {kind === 'SandboxWarmPool' && (
684
+ <>
685
+ <FactRow label="Warm reserve">
686
+ {(() => {
687
+ const label = poolBadge?.label ?? readingLabel(status).label
688
+ const ownRow = own[0]
689
+ const sched = schedulerReason(ownRow)
690
+ const sourceParts = [
691
+ sched ? `Can’t schedule · ${sched.plain}` : ownRow?.reading,
692
+ 'status.readyReplicas / spec.replicas',
693
+ ].filter(Boolean)
694
+ return (
695
+ <DimensionValue tone={effectiveLevel} source={sourceParts.join(' · ')}>
696
+ {label} · {getSandboxWarmPoolReadyOfDesired(resource)} ready
697
+ </DimensionValue>
698
+ )
699
+ })()}
700
+ </FactRow>
701
+
702
+ <FactRow label="Template">
703
+ {(() => {
704
+ const t = getSandboxWarmPoolTemplate(resource)
705
+ if (t === '-') return <Absent>no template</Absent>
706
+ const presence = (warmPoolSummaryRow?.template === t ? warmPoolSummaryRow.templatePresence : undefined) ?? own.flatMap((a) => a.relations ?? []).find((r) => r.role === 'template' && r.ref.name === t)?.presence
707
+ if (presence !== 'present') {
708
+ return (
709
+ <span className="inline-flex items-center gap-1.5">
710
+ <span className="font-mono">{t}</span>
711
+ <span className={clsx('text-xs', presence === 'absent' ? toneTextClass('unhealthy') : 'text-theme-text-tertiary')}>
712
+ {presence === 'absent' ? 'not found' : 'not read'}
713
+ </span>
714
+ </span>
715
+ )
716
+ }
717
+ return <RefLink refTo={{ kind: 'SandboxTemplate', group: AGENT_SANDBOX_EXTENSIONS_GROUP, ...ns(t) }} onNavigate={navigate} mono />
718
+ })()}
719
+ </FactRow>
720
+
721
+ <FactRow label="Members">
722
+ <div>
723
+ {lists.data.sandboxes.state === 'loading' && poolMembers.length === 0 ? (
724
+ <span className="text-theme-text-tertiary">Reading…</span>
725
+ ) : lists.data.sandboxes.state === 'failed' && poolMembers.length === 0 ? (
726
+ <span className="text-theme-text-tertiary">
727
+ {lists.data.sandboxes.denied
728
+ ? `Unknown — no access (missing ${KIND_LIST_PERMISSION.sandboxes})`
729
+ : `Unknown — Sandboxes couldn’t be read (${lists.data.sandboxes.message})`}
730
+ </span>
731
+ ) : poolMembers.length === 0 ? (
732
+ <span className="text-theme-text-secondary">
733
+ {readInNamespace(lists.data.sandboxes, namespace) ? 'No member sandboxes' : 'Unknown — Sandboxes in this namespace were not read in full'}
734
+ </span>
735
+ ) : (
736
+ <>
737
+ <SectionTable
738
+ framed={false}
739
+ minWidth={0}
740
+ rows={poolMembers.slice(0, 12)}
741
+ rowKey={(m) => m.name}
742
+ empty="No members"
743
+ columns={[
744
+ {
745
+ header: 'Sandbox',
746
+ cell: (m) => <RefLink refTo={{ kind: 'Sandbox', group: AGENT_SANDBOX_GROUP, ...ns(m.name) }} onNavigate={navigate} mono />,
747
+ },
748
+ {
749
+ header: 'State',
750
+ width: '40%',
751
+ cell: (m) => <DimensionValue tone={m.tone}>{m.label}</DimensionValue>,
752
+ },
753
+ ]}
754
+ />
755
+ <div className="mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-xs">
756
+ {poolMembers.some((m) => m.tone !== 'healthy') && (
757
+ <button type="button" onClick={() => navigateTo(poolNotReadyPath(namespace, name))} className="text-accent-text hover:underline">
758
+ Show not ready →
759
+ </button>
760
+ )}
761
+ <button
762
+ type="button"
763
+ onClick={() => navigateTo(`${SANDBOXES_PATH}&pool=${encodeURIComponent(`${namespace}/${name}`)}`)}
764
+ className="text-accent-text hover:underline"
765
+ >
766
+ {poolMembers.length > 12 ? 'View all members →' : 'View in Sandboxes →'}
767
+ </button>
768
+ </div>
769
+ {!readInNamespace(lists.data.sandboxes, namespace) && (
770
+ <div className="mt-1 text-[11.5px] text-theme-text-tertiary">
771
+ Partial view — Sandboxes in this namespace were not read in full
772
+ </div>
773
+ )}
774
+ </>
775
+ )}
776
+ </div>
777
+ </FactRow>
778
+
779
+ <FactRow label="Claims referencing">
780
+ <div>
781
+ {lists.data.claims.state === 'loading' ? (
782
+ <span className="text-theme-text-tertiary">Reading…</span>
783
+ ) : lists.data.claims.state === 'failed' ? (
784
+ <span className="text-theme-text-tertiary">
785
+ {lists.data.claims.denied
786
+ ? `Unknown — no access (missing ${KIND_LIST_PERMISSION.claims})`
787
+ : `Unknown — SandboxClaims couldn’t be read (${lists.data.claims.message})`}
788
+ </span>
789
+ ) : !poolRefClaims ? (
790
+ <span className="text-theme-text-tertiary">Unknown — claims in this namespace were not read in full</span>
791
+ ) : poolRefClaims.items.length === 0 ? (
792
+ <Absent>none</Absent>
793
+ ) : (
794
+ <>
795
+ <div className="flex flex-wrap items-center gap-x-2 gap-y-0.5">
796
+ <span>
797
+ {poolRefClaims.items.length} referencing · {poolRefClaims.bound} currently bound
798
+ {poolRefClaims.expired > 0 ? ` · ${poolRefClaims.expired} expired` : ''}
799
+ </span>
800
+ <button type="button" onClick={() => navigateTo(poolClaimsPath(namespace, name))} className="text-xs text-accent-text hover:underline">
801
+ View claims →
802
+ </button>
803
+ </div>
804
+ <div className="mt-1.5 flex flex-wrap gap-1.5">
805
+ {poolRefClaims.items.slice(0, 6).map((c) => {
806
+ const cName = c?.metadata?.name ?? ''
807
+ const cStatus = getSandboxClaimStatus(c)
808
+ const cTone = server.tones.get(objectKey('SandboxClaim', namespace, cName)) ?? cStatus.level
809
+ return (
810
+ <button
811
+ key={cName}
812
+ type="button"
813
+ onClick={() => navigate({ kind: 'SandboxClaim', group: AGENT_SANDBOX_EXTENSIONS_GROUP, namespace, name: cName })}
814
+ className="inline-flex items-center gap-1.5 rounded-md border border-theme-border bg-theme-base px-2 py-0.5 text-xs hover:border-accent"
815
+ >
816
+ <StatusDot tone={cTone} />
817
+ <span className="font-mono text-theme-text-primary">{cName}</span>
818
+ <span className="text-theme-text-tertiary">{readingLabel(cStatus).label}</span>
819
+ </button>
820
+ )
821
+ })}
822
+ </div>
823
+ </>
824
+ )}
825
+ </div>
826
+ </FactRow>
827
+
828
+ {latestWarningEvent && (
829
+ <FactRow label="Controller event">
830
+ <div>
831
+ <div className="flex flex-wrap items-center gap-x-2">
832
+ <span className={clsx('font-medium', toneTextClass('degraded'))}>{latestWarningEvent.reason || 'Warning'}</span>
833
+ {latestWarningEvent.timestamp && (
834
+ <span className="text-xs text-theme-text-tertiary">{formatAge(latestWarningEvent.timestamp)} ago</span>
835
+ )}
836
+ </div>
837
+ {latestWarningEvent.message && (
838
+ <div className="mt-0.5 text-xs text-theme-text-secondary break-words">{latestWarningEvent.message}</div>
839
+ )}
840
+ </div>
841
+ </FactRow>
842
+ )}
843
+ </>
844
+ )}
845
+ </FactGrid>
846
+ </Frame>
847
+
848
+ <Frame title="About">
849
+ <FactGrid>
850
+ {kind === 'Sandbox' && (
851
+ <>
852
+ {containers.length > 0 && (
853
+ <FactRow label={containers.length === 1 ? 'Image' : 'Images'}>
854
+ <ContainersFact containers={containers} />
855
+ </FactRow>
856
+ )}
857
+ <FactRow label="Operating mode">{getSandboxOperatingMode(resource)}</FactRow>
858
+ <FactRow label="Shutdown policy">{resource?.spec?.shutdownPolicy || <Absent>not set</Absent>}</FactRow>
859
+ <FactRow label="Failed pod policy">{resource?.spec?.failedPodPolicy || <Absent>not set</Absent>}</FactRow>
860
+ <FactRow label="Node">
861
+ {resource?.status?.nodeName ? (
862
+ <RefLink refTo={{ kind: 'Node', group: '', namespace: '', name: resource.status.nodeName }} onNavigate={navigate} mono />
863
+ ) : (
864
+ <Absent>not reported</Absent>
865
+ )}
866
+ </FactRow>
867
+ <FactRow label="Created">
868
+ <CreatedValue timestamp={resource?.metadata?.creationTimestamp} />
869
+ </FactRow>
870
+ </>
871
+ )}
872
+
873
+ {kind === 'SandboxClaim' && (
874
+ <>
875
+ <FactRow label="Shutdown policy">{resource?.spec?.lifecycle?.shutdownPolicy || <Absent>not set</Absent>}</FactRow>
876
+ <FactRow label="Created">
877
+ <CreatedValue timestamp={resource?.metadata?.creationTimestamp} />
878
+ </FactRow>
879
+ </>
880
+ )}
881
+
882
+ {kind === 'SandboxWarmPool' && (
883
+ <>
884
+ <FactRow label="Desired replicas">
885
+ {resource?.spec?.replicas !== undefined ? <span className="font-mono">{resource.spec.replicas}</span> : <Absent>not set</Absent>}
886
+ </FactRow>
887
+ <FactRow label="Observed generation">
888
+ {resource?.status?.observedGeneration !== undefined ? (
889
+ <span className="font-mono">
890
+ {resource.status.observedGeneration}
891
+ {resource?.metadata?.generation !== undefined && resource.status.observedGeneration < resource.metadata.generation && (
892
+ <span className="ml-1.5 font-sans text-xs text-theme-text-tertiary">(spec is {resource.metadata.generation})</span>
893
+ )}
894
+ </span>
895
+ ) : (
896
+ <Absent>not reported</Absent>
897
+ )}
898
+ </FactRow>
899
+ <FactRow label="Created">
900
+ <CreatedValue timestamp={resource?.metadata?.creationTimestamp} />
901
+ </FactRow>
902
+ </>
903
+ )}
904
+ </FactGrid>
905
+ </Frame>
906
+
907
+ {others.length > 0 && (
908
+ <Frame title="Also reported">
909
+ <ul className="space-y-1 text-sm">
910
+ {others.map((c) => (
911
+ <li key={c.type} className="break-words">
912
+ <span className={toneTextClass(genericConditionTone(resource, c) === 'warning' ? 'degraded' : 'unhealthy')}>
913
+ {c.type}={c.status}
914
+ </span>
915
+ {c.reason && <span className="text-theme-text-tertiary"> ({c.reason})</span>}
916
+ {c.message && <div className="text-xs text-theme-text-secondary">{c.message}</div>}
917
+ </li>
918
+ ))}
919
+ </ul>
920
+ </Frame>
921
+ )}
922
+
923
+ {(conditions.length > 0 || kind !== 'SandboxWarmPool') &&
924
+ <WorkspaceConditions
925
+ title="Controller conditions"
926
+ conditions={conditions}
927
+ emptyMessage="The controller has not reported status.conditions."
928
+ framed={framed}
929
+ className={framed ? undefined : 'border-t border-theme-border-subtle pt-3'}
930
+ />}
931
+ </div>
932
+ </OpenIssueContext.Provider>
933
+ )
934
+ }
935
+
936
+ /**
937
+ * Header status badge for Sandbox, SandboxClaim, and SandboxWarmPool. Reads
938
+ * the same workspace summary as the lists so the drawer/page header pill
939
+ * always agrees with the table badge (e.g. "Reserve below target", never "Warming").
940
+ */
941
+ export function AgentSandboxStatusBadge({ data }: { data: any }) {
942
+ const namespace = data?.metadata?.namespace ?? ''
943
+ const name = data?.metadata?.name ?? ''
944
+ const kind = data?.kind ?? ''
945
+ const { support } = useRadarFeature('agentSandboxWorkspace')
946
+ const query = useAgentSandboxWorkspace(namespace ? [namespace] : [], { enabled: !!namespace && support !== 'unsupported' })
947
+ const server = useMemo(() => serverReadings(query.data), [query.data])
948
+ if (kind === 'SandboxWarmPool') {
949
+ const b = warmPoolBadge(data, server)
950
+ return <ReadingBadge status={b.status} label={b.label} level={b.level} title={b.title} />
951
+ }
952
+ const status = getAgentRuntimeStatus(data)
953
+ if (!status) return null
954
+ const level = server.tones.get(objectKey(kind, namespace, name))
955
+ return <ReadingBadge status={status} level={level} />
956
+ }