@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,85 @@
1
+ import { useCallback, useMemo } from 'react'
2
+ import { useSearchParams } from 'react-router-dom'
3
+ import { columnFiltersParam, getCellFilterValue, kindFiltersFromSearch } from '@skyhook-io/k8s-ui/components/resources/resource-utils'
4
+ import { getCellFilterKind, getColumnsForKind } from '@skyhook-io/k8s-ui/components/resources/ResourcesView'
5
+ import type { HostKind } from '../../integrations/resourceHost'
6
+ import type { KindRead } from './data'
7
+
8
+ export interface ColumnFilter { key: string; label: string; values: string[]; exclude: boolean }
9
+
10
+ /** A Resources-page filter in the URL that these lists don't apply, and the params that clear it. */
11
+ export interface IgnoredFilter { label: string; params: string[]; column?: string }
12
+
13
+ /**
14
+ * The Resources page's own list filters in a query string, as they bear on
15
+ * one of these lists: the `filters` columns the kind's standard table has
16
+ * (applied below, matched against the text that table filters on), and the
17
+ * rest, which these lists name rather than apply.
18
+ */
19
+ export function readListFilters(search: string, kind: HostKind): { columns: ColumnFilter[]; ignored: IgnoredFilter[] } {
20
+ const params = new URLSearchParams(search)
21
+ const { columnFilters, columnFilterExcludes, problemFilters } = kindFiltersFromSearch(search)
22
+ const labels = new Map(getColumnsForKind(kind.name, kind.group).map((c) => [c.key, c.label]))
23
+ const columns: ColumnFilter[] = []
24
+ const ignored: IgnoredFilter[] = []
25
+ for (const [key, values] of Object.entries(columnFilters)) {
26
+ const label = labels.get(key)
27
+ if (label) columns.push({ key, label, values, exclude: !!columnFilterExcludes[key] })
28
+ else ignored.push({ label: `${key}: ${values.join(', ')}`, params: ['filters'], column: key })
29
+ }
30
+ const labelSelector = params.get('labels')
31
+ if (labelSelector) ignored.push({ label: `Labels: ${labelSelector}`, params: ['labels'] })
32
+ const ownerKind = params.get('ownerKind')
33
+ const ownerName = params.get('ownerName')
34
+ if (ownerKind || ownerName) ignored.push({ label: `Owner: ${[ownerKind, ownerName].filter(Boolean).join('/')}`, params: ['ownerKind', 'ownerName'] })
35
+ if (problemFilters.length > 0) ignored.push({ label: `Problems: ${problemFilters.join(', ')}`, params: ['problems'] })
36
+ if (params.get('regex') === 'true') ignored.push({ label: 'Regex search', params: ['regex'] })
37
+ return { columns, ignored }
38
+ }
39
+
40
+ /** Keeps the objects every column filter admits: any of its values, or none of them when it excludes. */
41
+ export function applyColumnFilters(read: KindRead, columns: ColumnFilter[], kind: HostKind): KindRead {
42
+ if (read.state !== 'read' || columns.length === 0) return read
43
+ const cellKind = getCellFilterKind(kind.name, kind.group)
44
+ const items = read.items.filter((o) =>
45
+ columns.every((c) => {
46
+ const match = c.values.includes(getCellFilterValue(o, c.key, cellKind))
47
+ return c.exclude ? !match : match
48
+ }),
49
+ )
50
+ return { ...read, items }
51
+ }
52
+
53
+ /** The query string without one column of the `filters` param. */
54
+ export function withoutColumn(search: string, key: string): URLSearchParams {
55
+ const params = new URLSearchParams(search)
56
+ const { columnFilters, columnFilterExcludes } = kindFiltersFromSearch(search)
57
+ delete columnFilters[key]
58
+ const next = columnFiltersParam(columnFilters, columnFilterExcludes)
59
+ if (next) params.set('filters', next)
60
+ else params.delete('filters')
61
+ return params
62
+ }
63
+
64
+ /**
65
+ * The URL's list filters for this kind: a function narrowing a read by its
66
+ * column filters, and a chip for each, with the filters it doesn't apply
67
+ * named as such so a link's narrowing is never silently dropped.
68
+ */
69
+ export function useListFilters(kind: HostKind): { apply: (read: KindRead) => KindRead; narrows: boolean; chips: { label: string; onClear: () => void }[] } {
70
+ const [params, setParams] = useSearchParams()
71
+ const search = params.toString()
72
+ const { columns, ignored } = useMemo(() => readListFilters(search, kind), [search, kind])
73
+ const apply = useCallback((read: KindRead) => applyColumnFilters(read, columns, kind), [columns, kind])
74
+ const replace = (next: URLSearchParams) => setParams(next, { replace: true })
75
+ const drop = (keys: string[]) => {
76
+ const next = new URLSearchParams(search)
77
+ for (const k of keys) next.delete(k)
78
+ replace(next)
79
+ }
80
+ const chips = [
81
+ ...columns.map((c) => ({ label: `${c.label}${c.exclude ? ' excludes' : ''}: ${c.values.join(', ')}`, onClear: () => replace(withoutColumn(search, c.key)) })),
82
+ ...ignored.map((f) => ({ label: `${f.label} (not applied here)`, onClear: () => (f.column ? replace(withoutColumn(search, f.column)) : drop(f.params)) })),
83
+ ]
84
+ return { apply, narrows: columns.length > 0, chips }
85
+ }
@@ -0,0 +1,52 @@
1
+ import type { Relationships, ResourceRef } from '@skyhook-io/k8s-ui/types/core'
2
+ import { getSandboxClaimWarmPool } from '@skyhook-io/k8s-ui/components/resources/resource-utils-agent-runtimes'
3
+ import { AGENT_SANDBOX_EXTENSIONS_GROUP } from './routes'
4
+
5
+ // What the kind lists join across their rows, within one namespace.
6
+
7
+ type Ref = { kind: string; group: string; namespace: string; name: string }
8
+
9
+ const trimmed = (value: unknown): string | undefined => (typeof value === 'string' && value.trim() ? value.trim() : undefined)
10
+
11
+ /** The object that controls a Sandbox, from its controller owner reference: a warm pool, or a claim. */
12
+ export function sandboxController(o: any): Ref | undefined {
13
+ const refs: any[] = Array.isArray(o?.metadata?.ownerReferences) ? o.metadata.ownerReferences : []
14
+ const owner = refs.find((r) => r?.controller) ?? refs[0]
15
+ if (!owner?.name || !['SandboxWarmPool', 'SandboxClaim'].includes(owner.kind)) return undefined
16
+ return { kind: owner.kind, group: AGENT_SANDBOX_EXTENSIONS_GROUP, namespace: o?.metadata?.namespace ?? '', name: owner.name }
17
+ }
18
+
19
+ /** The claims that name the pool in spec.warmPoolRef. */
20
+ export function poolClaims(pool: any, claims: any[]): any[] {
21
+ const namespace = pool?.metadata?.namespace ?? ''
22
+ const name = pool?.metadata?.name ?? ''
23
+ return claims.filter((c) => (c?.metadata?.namespace ?? '') === namespace && getSandboxClaimWarmPool(c) === name)
24
+ }
25
+
26
+ /** The Sandbox a claim is bound to, from status.sandbox.name. */
27
+ export function claimSandboxName(claim: any): string | undefined {
28
+ return trimmed(claim?.status?.sandbox?.name)
29
+ }
30
+
31
+ export type PodAnswer =
32
+ | { state: 'loading' }
33
+ | { state: 'found'; pods: ResourceRef[] }
34
+ /** Every Pod the viewer may read was checked, and none names this Sandbox as its owner. */
35
+ | { state: 'none' }
36
+ | { state: 'unknown' }
37
+
38
+ /** The Sandbox's Pod from its owner-reference children, never from its name. */
39
+ export function sandboxPod(relationships: Relationships | undefined, loading: boolean): PodAnswer {
40
+ if (!relationships) return loading ? { state: 'loading' } : { state: 'unknown' }
41
+ const pods = (relationships.children ?? []).filter((r) => r.kind === 'Pod' && !r.group)
42
+ if (pods.length > 0) return { state: 'found', pods }
43
+ // Gaps in other kinds (Leases, EndpointSlices, …) say nothing about Pods, so
44
+ // only a Pod gap, an unnamed one, a truncated or unavailable answer is unknown.
45
+ const ownership = relationships.ownership
46
+ if (!ownership || ownership.unavailableReason || ownership.children.truncated) return { state: 'unknown' }
47
+ if (ownership.children.complete) return { state: 'none' }
48
+ const gaps = ownership.children.notChecked ?? []
49
+ // Like `complete`, this is scoped to what the caller may read, so `narrowed` doesn't change it.
50
+ const onlyOtherKinds = gaps.length > 0 && gaps.every((gap) => gap.kind && !(gap.kind === 'Pod' && !gap.group))
51
+ return onlyOtherKinds ? { state: 'none' } : { state: 'unknown' }
52
+ }
@@ -0,0 +1,23 @@
1
+ export const AGENT_SANDBOX_GROUP = 'agents.x-k8s.io'
2
+ export const AGENT_SANDBOX_EXTENSIONS_GROUP = 'extensions.agents.x-k8s.io'
3
+
4
+ export const AGENT_SANDBOX_OVERVIEW = { label: 'Overview', title: 'Agent Sandbox overview', path: '/agent-sandbox' }
5
+
6
+ export const SANDBOX_KIND = { name: 'sandboxes', kind: 'Sandbox', group: AGENT_SANDBOX_GROUP }
7
+ export const SANDBOX_CLAIM_KIND = { name: 'sandboxclaims', kind: 'SandboxClaim', group: AGENT_SANDBOX_EXTENSIONS_GROUP }
8
+ export const SANDBOX_WARM_POOL_KIND = { name: 'sandboxwarmpools', kind: 'SandboxWarmPool', group: AGENT_SANDBOX_EXTENSIONS_GROUP }
9
+ export const SANDBOX_TEMPLATE_KIND = { name: 'sandboxtemplates', kind: 'SandboxTemplate', group: AGENT_SANDBOX_EXTENSIONS_GROUP }
10
+
11
+ export type AgentSandboxKind = typeof SANDBOX_KIND | typeof SANDBOX_CLAIM_KIND | typeof SANDBOX_WARM_POOL_KIND | typeof SANDBOX_TEMPLATE_KIND
12
+
13
+ export function kindListPath(kind: { name: string; group: string }): string {
14
+ return `/resources/${kind.name}?apiGroup=${encodeURIComponent(kind.group)}`
15
+ }
16
+
17
+ export const SANDBOXES_PATH = kindListPath(SANDBOX_KIND)
18
+ export const SANDBOX_CLAIMS_PATH = kindListPath(SANDBOX_CLAIM_KIND)
19
+ export const SANDBOX_WARM_POOLS_PATH = kindListPath(SANDBOX_WARM_POOL_KIND)
20
+
21
+ export function ownsAgentSandboxPath(pathname: string): boolean {
22
+ return pathname === AGENT_SANDBOX_OVERVIEW.path || pathname.startsWith(`${AGENT_SANDBOX_OVERVIEW.path}/`)
23
+ }
@@ -0,0 +1,321 @@
1
+ import type { ReactNode } from 'react'
2
+ import { Boxes } from 'lucide-react'
3
+ import { Badge, PaneLoader, Tooltip, healthToSeverity, type StatusBadge } from '@skyhook-io/k8s-ui'
4
+ import { formatSandboxExpiry, getSandboxExpiry, getSandboxTTLAfterFinished } from '@skyhook-io/k8s-ui/components/resources/resource-utils-agent-runtimes'
5
+ import { resourceCoverageNotice, resourceEmptyMessage, resourceNarrowedNotice } from '@skyhook-io/k8s-ui/utils/resource-coverage'
6
+ import type { SelectedResource } from '../../types'
7
+ import { useConnection } from '../../context/ConnectionContext'
8
+ import { refToSelectedResource } from '../../utils/navigation'
9
+ import { FilterChips, Notice, RefreshFailedNotice, ScreenEmptyState, namespaceChip } from '../workspace/layout'
10
+ import { useWorkspaceNavigate } from '../workspace/useWorkspaceNavigate'
11
+ import type { AgentSandboxListKey, AgentSandboxLists, KindRead } from './data'
12
+ import { readingLabel } from './labels'
13
+ import { AGENT_SANDBOX_OVERVIEW } from './routes'
14
+
15
+ /** A kind list's props: the three kinds as the resource list endpoint read them. */
16
+ export interface AgentSandboxScreenProps {
17
+ data: AgentSandboxLists
18
+ /** The namespace filter the reads applied; empty for all namespaces. */
19
+ namespaces: string[]
20
+ onClearNamespaces: () => void
21
+ onInspect: (resource: SelectedResource) => void
22
+ inspected: SelectedResource | null
23
+ attentionPending?: boolean
24
+ }
25
+
26
+ export const AGENT_SANDBOX_LABEL = 'Agent Sandbox'
27
+
28
+ export const KIND_LABEL: Record<AgentSandboxListKey | 'templates', string> = {
29
+ sandboxes: 'Sandboxes',
30
+ claims: 'SandboxClaims',
31
+ warmPools: 'SandboxWarmPools',
32
+ templates: 'SandboxTemplates',
33
+ }
34
+
35
+ export const KIND_LIST_PERMISSION: Record<AgentSandboxListKey | 'templates', string> = {
36
+ sandboxes: 'list sandboxes.agents.x-k8s.io',
37
+ claims: 'list sandboxclaims.extensions.agents.x-k8s.io',
38
+ warmPools: 'list sandboxwarmpools.extensions.agents.x-k8s.io',
39
+ templates: 'list sandboxtemplates.extensions.agents.x-k8s.io',
40
+ }
41
+
42
+ export function agentSandboxResource(ref: { kind: string; group: string; namespace: string; name: string }): SelectedResource {
43
+ return refToSelectedResource(ref)
44
+ }
45
+
46
+ /** What Agent Sandbox is, in one line, shown when no objects are present yet. */
47
+ export const AGENT_SANDBOX_WHAT_IT_IS = 'Agent Sandbox gives each agent its own sandboxed Pod; claims take sandboxes from warm pools kept ready ahead of demand.'
48
+
49
+ /** The title line, optional subtitle/intro under it, and active filter chips. */
50
+ export function AgentSandboxHeader({
51
+ title,
52
+ subtitle,
53
+ intro,
54
+ namespaces,
55
+ onClearNamespaces,
56
+ actions,
57
+ chips: filters = [],
58
+ }: {
59
+ title: string
60
+ subtitle?: ReactNode
61
+ intro?: ReactNode
62
+ namespaces: string[]
63
+ onClearNamespaces: () => void
64
+ actions?: ReactNode
65
+ chips?: { label: string; onClear: () => void }[]
66
+ }) {
67
+ const navigateTo = useWorkspaceNavigate()
68
+ const chips = [...namespaceChip(namespaces, onClearNamespaces), ...filters]
69
+ const clickableBreadcrumb = title !== AGENT_SANDBOX_OVERVIEW.label
70
+ return (
71
+ <div className="px-5 pt-4 xl:px-7">
72
+ <div className="flex flex-wrap items-center gap-x-2">
73
+ <span className="flex items-center gap-1.5 text-sm text-theme-text-tertiary">
74
+ <Boxes className="h-3.5 w-3.5" />
75
+ {clickableBreadcrumb ? (
76
+ <button
77
+ type="button"
78
+ onClick={() => navigateTo(AGENT_SANDBOX_OVERVIEW.path)}
79
+ className="hover:text-theme-text-primary hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent rounded"
80
+ >
81
+ {AGENT_SANDBOX_LABEL}
82
+ </button>
83
+ ) : (
84
+ AGENT_SANDBOX_LABEL
85
+ )}
86
+ <span>/</span>
87
+ </span>
88
+ <h1 className="text-lg font-semibold text-theme-text-primary">{title}</h1>
89
+ {actions && <div className="ml-auto">{actions}</div>}
90
+ </div>
91
+ {subtitle && <div className="mt-0.5 text-xs text-theme-text-tertiary">{subtitle}</div>}
92
+ {intro && <p className="mt-1 text-sm text-theme-text-secondary">{intro}</p>}
93
+ {chips.length > 0 && (
94
+ <div className="mt-2">
95
+ <FilterChips chips={chips} />
96
+ </div>
97
+ )}
98
+ </div>
99
+ )
100
+ }
101
+
102
+ /** Why a kind was not read in full, in a few words; undefined when it was. */
103
+ export function readGapText(read: KindRead, kindKey?: AgentSandboxListKey): string | undefined {
104
+ switch (read.state) {
105
+ case 'loading':
106
+ return 'still loading'
107
+ case 'failed':
108
+ return read.denied
109
+ ? kindKey
110
+ ? `no access — missing ${KIND_LIST_PERMISSION[kindKey]}`
111
+ : 'no access'
112
+ : `couldn’t be read: ${read.message}`
113
+ case 'read':
114
+ return resourceCoverageNotice(read.coverage, 'objects')?.replace(/^Partial results\. /, '') ?? resourceNarrowedNotice(read.coverage)
115
+ }
116
+ return undefined
117
+ }
118
+
119
+ /** Says which kinds this screen reads were not read in full, and why. What wasn't read shows as unknown. */
120
+ export function AgentSandboxCoverageNotice({ data, kinds }: { data: AgentSandboxLists; kinds: readonly AgentSandboxListKey[] }) {
121
+ const gaps = kinds.flatMap((k) => {
122
+ const text = readGapText(data[k], k)
123
+ return text ? [`${KIND_LABEL[k]} (${text.replace(/\.$/, '')})`] : []
124
+ })
125
+ if (gaps.length === 0) return null
126
+ return <Notice>Radar couldn’t read all of the Agent Sandbox objects on this screen: {gaps.join('; ')}. What it couldn’t read shows as unknown.</Notice>
127
+ }
128
+
129
+ /**
130
+ * Loading, error and not-installed states the kind lists share. The screen
131
+ * renders once any kind it reads has an answer; a kind that failed is named
132
+ * on the screen rather than blocking it.
133
+ */
134
+ export function AgentSandboxGate({
135
+ data,
136
+ keys,
137
+ discoveryPending,
138
+ discovered,
139
+ isFetching,
140
+ refetch,
141
+ refreshQueries,
142
+ children,
143
+ }: {
144
+ data: AgentSandboxLists
145
+ /** The kinds this screen needs at least one answer from. */
146
+ keys: readonly AgentSandboxListKey[]
147
+ discoveryPending: boolean
148
+ discovered: boolean
149
+ isFetching: boolean
150
+ refetch: () => void
151
+ refreshQueries: { isRefetchError: boolean; error: Error | null; dataUpdatedAt: number }[]
152
+ children: ReactNode
153
+ }) {
154
+ const { connection } = useConnection()
155
+ const reads = keys.map((k) => data[k])
156
+ // One kind still loading doesn't hold the screen once another has answered; the notice names it.
157
+ if (discoveryPending || (reads.some((r) => r.state === 'loading') && reads.every((r) => r.state === 'loading' || r.state === 'notServed'))) return <PaneLoader label="Loading Agent Sandbox…" className="flex-1" />
158
+ if (!discovered) {
159
+ return <ScreenEmptyState icon={Boxes} title="Agent Sandbox is not installed" detail={`No agents.x-k8s.io resources are served in ${connection.context || 'this cluster'}.`} />
160
+ }
161
+ if (reads.every((r) => r.state === 'notServed')) {
162
+ return <ScreenEmptyState icon={Boxes} title="Not served by this Agent Sandbox" detail={`Agent Sandbox is installed in ${connection.context || 'this cluster'}, but its version doesn't serve this kind.`} />
163
+ }
164
+ if (reads.every((r) => r.state === 'failed' || r.state === 'notServed')) {
165
+ const failed = reads.find((r): r is Extract<KindRead, { state: 'failed' }> => r.state === 'failed')
166
+ const denied = reads.every((r) => r.state !== 'failed' || r.denied)
167
+ return (
168
+ <ScreenEmptyState
169
+ icon={Boxes}
170
+ title={denied ? 'No access to Agent Sandbox objects' : 'Agent Sandbox data unavailable'}
171
+ detail={denied
172
+ ? `Missing permission to ${keys.filter((k) => data[k].state === 'failed').map((k) => KIND_LIST_PERMISSION[k]).join(', ')} in this scope.`
173
+ : failed?.message ?? 'Radar couldn’t load the Agent Sandbox objects.'}
174
+ action={
175
+ denied ? undefined : (
176
+ <button type="button" onClick={refetch} disabled={isFetching} className="btn-secondary mt-3 px-3 py-1.5 text-sm">
177
+ {isFetching ? 'Retrying…' : 'Retry'}
178
+ </button>
179
+ )
180
+ }
181
+ />
182
+ )
183
+ }
184
+ return (
185
+ <>
186
+ <RefreshFailedNotice queries={refreshQueries} className="px-5 pt-3 xl:px-7" />
187
+ {children}
188
+ </>
189
+ )
190
+ }
191
+
192
+ /**
193
+ * A reading as a badge, colored by how much it needs attention, in plain
194
+ * words; the raw reason the controller or Kubernetes reported is on hover.
195
+ * `level` colors it as the server's Needs attention row about it does.
196
+ */
197
+ export function ReadingBadge({ status, label: override, title, level }: { status: StatusBadge; label?: string; title?: string; level?: StatusBadge['level'] }) {
198
+ const { label, reason } = readingLabel(status)
199
+ const badge = (
200
+ <Badge severity={healthToSeverity(level ?? status.level)} size="sm">
201
+ {override ?? label}
202
+ </Badge>
203
+ )
204
+ const tip = title ?? (reason ? `Reason: ${reason}` : undefined)
205
+ return tip ? <Tooltip content={tip}>{badge}</Tooltip> : badge
206
+ }
207
+
208
+ /** An object's name in a table: mono, one line, cut with an ellipsis and whole on hover. */
209
+ export function ObjectName({ name }: { name: string }) {
210
+ return (
211
+ <Tooltip content={name}>
212
+ <span className="block min-w-0 truncate font-mono text-sm">{name}</span>
213
+ </Tooltip>
214
+ )
215
+ }
216
+
217
+ /** A link inside a table row that opens its own object, not the row's. */
218
+ export function RowLink({ refTo, onInspect, children, inline }: { refTo: { kind: string; group: string; namespace: string; name: string }; onInspect: (r: SelectedResource) => void; children?: ReactNode; inline?: boolean }) {
219
+ return (
220
+ <Tooltip content={`${refTo.kind} ${refTo.name}`} wrapperClassName="min-w-0 max-w-full">
221
+ <button
222
+ type="button"
223
+ onClick={(e) => {
224
+ e.stopPropagation()
225
+ onInspect(agentSandboxResource(refTo))
226
+ }}
227
+ onKeyDown={(e) => e.stopPropagation()}
228
+ className={inline ? 'max-w-full truncate text-left font-mono text-accent-text hover:underline' : 'block max-w-full truncate text-left font-mono text-sm text-accent-text hover:underline'}
229
+ >
230
+ {children ?? refTo.name}
231
+ </button>
232
+ </Tooltip>
233
+ )
234
+ }
235
+
236
+ /**
237
+ * The width the Agent Sandbox tables show every column at, the same as the
238
+ * Substrate tables'. Below it each table folds its secondary columns into the
239
+ * cell they qualify, so nothing scrolls sideways.
240
+ */
241
+ export { SUBSTRATE_WIDE as AGENT_SANDBOX_WIDE } from '../substrate/shared'
242
+
243
+ /** Absence in a table cell or fact, in words: "no expiry", "not bound", "unknown". */
244
+ export function Absent({ children, title }: { children: ReactNode; title?: string }) {
245
+ const text = <span className="text-sm text-theme-text-tertiary">{children}</span>
246
+ return title ? <Tooltip content={title}>{text}</Tooltip> : text
247
+ }
248
+
249
+ /**
250
+ * Text that wraps only at its spaces. Each word is kept whole, since a break at
251
+ * a hyphen inside an image reference or URL ("does-not-" / "exist:1") reads as
252
+ * two words; one wider than the line still wraps within itself.
253
+ */
254
+ export function wrapAtSpaces(text: string): ReactNode[] {
255
+ return text
256
+ .split(/(\s+)/)
257
+ .filter(Boolean)
258
+ .map((part, i) => (/^\s/.test(part) ? part : <span key={i} className="inline-block max-w-full align-top">{part}</span>))
259
+ }
260
+
261
+ export function SourceText({ label, text }: { label?: string; text: string }) {
262
+ return (
263
+ <div className="min-w-0 text-xs">
264
+ {label && <div className="text-theme-text-tertiary">{label}</div>}
265
+ <div className="mt-0.5 whitespace-pre-wrap break-words border-l-2 border-theme-border pl-2 font-mono text-[11.5px] text-theme-text-secondary">{wrapAtSpaces(text)}</div>
266
+ </div>
267
+ )
268
+ }
269
+
270
+ /** "expires in 12m", "expired 2h ago", or undefined when none is set; the exact time on hover. */
271
+ export function expiryText(value: string | undefined, now = Date.now()): string | undefined {
272
+ if (!value) return undefined
273
+ const at = Date.parse(value)
274
+ if (!Number.isFinite(at)) return value
275
+ return `${at >= now ? 'expires' : 'expired'} ${formatSandboxExpiry(value, now)}`
276
+ }
277
+
278
+ function ttlText(seconds: number): string {
279
+ if (seconds < 60) return `${seconds}s`
280
+ if (seconds < 3600) return `${Math.round(seconds / 60)}m`
281
+ if (seconds < 86400) return `${Math.round(seconds / 3600)}h`
282
+ return `${Math.round(seconds / 86400)}d`
283
+ }
284
+
285
+ /**
286
+ * The object's own expiry (getSandboxExpiry). With none set, a claim or a Sandbox
287
+ * nothing claims has no expiry; a claimed Sandbox may still end with its
288
+ * claim, so it says only that it sets none of its own.
289
+ */
290
+ export function ExpiryCell({ resource, claimed }: { resource: any; claimed?: boolean }) {
291
+ const value = getSandboxExpiry(resource)
292
+ const text = expiryText(value)
293
+ const ttl = getSandboxTTLAfterFinished(resource)
294
+ if (!text || !value) {
295
+ if (ttl !== undefined) return <span className="text-sm text-theme-text-secondary">{ttlText(ttl)} after it finishes</span>
296
+ return claimed ? <Absent title="This Sandbox sets no shutdownTime; its claim’s expiry can still end it.">none of its own</Absent> : <Absent>no expiry</Absent>
297
+ }
298
+ return (
299
+ <span className="text-sm text-theme-text-secondary">
300
+ <Tooltip content={new Date(value).toLocaleString()}>{text}</Tooltip>
301
+ {ttl !== undefined && `, or ${ttlText(ttl)} after it finishes if sooner`}
302
+ </span>
303
+ )
304
+ }
305
+
306
+ /** A table's empty text: what was read, so an unread kind never reads as none. */
307
+ export function coverageEmptyText(read: KindRead, kind: string, kindKey?: AgentSandboxListKey): string {
308
+ switch (read.state) {
309
+ case 'loading':
310
+ return `${kind} are still loading.`
311
+ case 'failed':
312
+ return read.denied
313
+ ? kindKey
314
+ ? `Unknown: no access to ${kind} (missing ${KIND_LIST_PERMISSION[kindKey]}).`
315
+ : `Unknown: no access to ${kind} here.`
316
+ : `Unknown: ${kind} couldn’t be read (${read.message}).`
317
+ case 'notServed':
318
+ return `${kind} aren’t served in this cluster: their CRD isn’t installed.`
319
+ }
320
+ return `${resourceEmptyMessage(kind, read.coverage, false)}.`
321
+ }
@@ -0,0 +1,69 @@
1
+ import { useMemo } from 'react'
2
+ import { Bot } from 'lucide-react'
3
+ import type { SidebarCategoryWorkspace } from '@skyhook-io/k8s-ui'
4
+ import type { APIResource } from '../../types'
5
+ import { useRadarFeature } from '../../api/client'
6
+ import { useAgentSandboxWorkspace, type AgentSandboxSidebar } from '../../api/agentSandbox'
7
+ import { useWorkspaceNavigate } from '../workspace/useWorkspaceNavigate'
8
+ import { AGENTS_SIDEBAR_CATEGORY } from '../workspace/sidebar'
9
+ import { agentSandboxDiscovered } from './data'
10
+ import { AGENT_SANDBOX_OVERVIEW, SANDBOXES_PATH, SANDBOX_CLAIMS_PATH, SANDBOX_CLAIM_KIND, SANDBOX_KIND, SANDBOX_WARM_POOLS_PATH, SANDBOX_WARM_POOL_KIND } from './routes'
11
+ import { sidebarCount } from './workspace'
12
+
13
+ /** Agent Sandbox's heading among the Agents row's destinations, when another runtime shares the row. */
14
+ export const AGENT_SANDBOX_SIDEBAR_SECTION = 'Sandbox'
15
+
16
+ const SCREENS = [
17
+ { kind: SANDBOX_KIND, key: 'sandboxes', label: 'Sandboxes', path: SANDBOXES_PATH, noun: ['sandbox', 'sandboxes'] },
18
+ { kind: SANDBOX_CLAIM_KIND, key: 'claims', label: 'Claims', path: SANDBOX_CLAIMS_PATH, noun: ['claim', 'claims'] },
19
+ { kind: SANDBOX_WARM_POOL_KIND, key: 'warmPools', label: 'Warm pools', path: SANDBOX_WARM_POOLS_PATH, noun: ['warm pool', 'warm pools'] },
20
+ ] as const satisfies readonly { kind: unknown; label: string; path: string; key: keyof Omit<AgentSandboxSidebar, 'total'>; noun: readonly [string, string] }[]
21
+
22
+ /**
23
+ * Agent Sandbox in the sidebar's Integrations, as its part of the Agents row:
24
+ * what needs attention, and the Overview and Radar's three tables (each with
25
+ * what needs attention there); SandboxTemplate stays under Other kinds. The counts
26
+ * are the server's (/api/agentsandbox/workspace) and follow the namespace
27
+ * filter. Undefined when Agent Sandbox is not discovered, or the connected
28
+ * Radar is known to predate the overview.
29
+ */
30
+ export function useAgentSandboxSidebarWorkspace({
31
+ apiResources,
32
+ namespaces,
33
+ active,
34
+ }: {
35
+ apiResources: APIResource[] | undefined
36
+ namespaces: string[]
37
+ /** The Overview is on screen. */
38
+ active?: boolean
39
+ }): Record<string, SidebarCategoryWorkspace> | undefined {
40
+ const navigate = useWorkspaceNavigate()
41
+ const { support } = useRadarFeature('agentSandboxWorkspace')
42
+ const available = agentSandboxDiscovered(apiResources) && support !== 'unsupported'
43
+ const { data } = useAgentSandboxWorkspace(namespaces, { enabled: available })
44
+ const sidebar = data?.installed ? data.sidebar : undefined
45
+ const nsKey = (data?.namespaces ?? namespaces).join(', ')
46
+ return useMemo(() => {
47
+ if (!available) return undefined
48
+ const total = sidebar ? sidebarCount(sidebar.total, ['object', 'objects']) : undefined
49
+ const scope = nsKey ? `namespace ${nsKey}` : 'all namespaces'
50
+ return {
51
+ [AGENTS_SIDEBAR_CATEGORY]: {
52
+ tools: 'Agent Sandbox',
53
+ icon: Bot,
54
+ count: total?.count,
55
+ countLowerBound: total?.lowerBound,
56
+ countTitle: total ? `${total.title} Scope: ${scope}.` : undefined,
57
+ countScope: scope,
58
+ destinations: [
59
+ { id: 'agent-sandbox-overview', label: AGENT_SANDBOX_OVERVIEW.label, section: AGENT_SANDBOX_SIDEBAR_SECTION, active: !!active, onSelect: () => navigate(AGENT_SANDBOX_OVERVIEW.path) },
60
+ ...SCREENS.map(({ kind, key, label, path, noun }) => {
61
+ const c = sidebar ? sidebarCount(sidebar[key], [noun[0], noun[1]]) : undefined
62
+ return { id: kind.name, label, section: AGENT_SANDBOX_SIDEBAR_SECTION, kind, count: c?.count, countLowerBound: c?.lowerBound, countTitle: c?.title, onSelect: () => navigate(path) }
63
+ }),
64
+ ],
65
+ scopeNote: nsKey ? `Counts for namespace ${nsKey}` : undefined,
66
+ },
67
+ }
68
+ }, [available, active, navigate, sidebar, nsKey])
69
+ }