@skyhook-io/radar-app 1.22.2 → 1.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -8
- package/src/App.tsx +35 -10
- package/src/RadarApp.basename.test.tsx +177 -0
- package/src/RadarApp.settings.test.tsx +33 -0
- package/src/api/agentSandbox.ts +259 -0
- package/src/api/client.autoPromConnect.test.tsx +43 -0
- package/src/api/client.metricsRelayCheck.test.tsx +134 -0
- package/src/api/client.ts +122 -24
- package/src/api/cloudInstallDiscover.test.tsx +76 -0
- package/src/api/diagnose.ts +4 -0
- package/src/api/kagent.test.ts +82 -0
- package/src/api/kagent.ts +230 -0
- package/src/api/prometheusCharts.ts +5 -0
- package/src/api/radarFeatures.test.ts +9 -0
- package/src/api/radarFeatures.ts +13 -0
- package/src/api/substrateWorkspace.test.ts +72 -0
- package/src/api/substrateWorkspace.ts +1394 -0
- package/src/api/vulnerabilities.ts +207 -9
- package/src/api/workloadSource.test.tsx +315 -0
- package/src/api/workloadSource.ts +128 -12
- package/src/components/CloudConnectFlow.tsx +46 -7
- package/src/components/CloudFunnelButton.test.tsx +193 -7
- package/src/components/CloudFunnelButton.tsx +127 -32
- package/src/components/SelfManagedStart.tsx +12 -2
- package/src/components/agentsandbox/AgentSandboxKindLists.tsx +41 -0
- package/src/components/agentsandbox/AgentSandboxLists.test.tsx +410 -0
- package/src/components/agentsandbox/AgentSandboxOverview.test.tsx +333 -0
- package/src/components/agentsandbox/AgentSandboxOverview.tsx +555 -0
- package/src/components/agentsandbox/AgentSandboxSidebar.test.tsx +97 -0
- package/src/components/agentsandbox/AgentSandboxSummary.test.tsx +439 -0
- package/src/components/agentsandbox/AgentSandboxSummary.tsx +956 -0
- package/src/components/agentsandbox/AgentSandboxTables.tsx +966 -0
- package/src/components/agentsandbox/AgentSandboxView.tsx +34 -0
- package/src/components/agentsandbox/agentsandbox.fixtures.ts +135 -0
- package/src/components/agentsandbox/data.ts +135 -0
- package/src/components/agentsandbox/host.test.ts +27 -0
- package/src/components/agentsandbox/host.tsx +85 -0
- package/src/components/agentsandbox/labels.test.ts +42 -0
- package/src/components/agentsandbox/labels.ts +146 -0
- package/src/components/agentsandbox/listFilters.ts +85 -0
- package/src/components/agentsandbox/lists.ts +52 -0
- package/src/components/agentsandbox/routes.ts +23 -0
- package/src/components/agentsandbox/shared.tsx +321 -0
- package/src/components/agentsandbox/useAgentSandboxSidebarWorkspace.ts +69 -0
- package/src/components/agentsandbox/workspace.fixtures.ts +125 -0
- package/src/components/agentsandbox/workspace.tsx +258 -0
- package/src/components/agentsandbox/workspaceRoute.ts +18 -0
- package/src/components/applications/ApplicationsView.openResource.test.tsx +248 -3
- package/src/components/applications/ApplicationsView.tsx +156 -3
- package/src/components/audit/VulnerabilitiesColumns.test.tsx +487 -0
- package/src/components/audit/VulnerabilitiesRisk.test.tsx +318 -0
- package/src/components/audit/VulnerabilitiesView.test.tsx +458 -13
- package/src/components/audit/VulnerabilitiesView.tsx +639 -199
- package/src/components/cloudHints/AgentSetupCloudRow.tsx +28 -0
- package/src/components/cloudHints/CloudHintLink.tsx +29 -0
- package/src/components/cloudHints/SharedInstallAiLine.tsx +36 -0
- package/src/components/cloudHints/cloudHints.test.ts +126 -0
- package/src/components/cloudHints/cloudHints.ts +131 -0
- package/src/components/cloudHints/cloudHintsGate.test.tsx +70 -0
- package/src/components/cloudHints/cloudLinks.test.ts +52 -0
- package/src/components/cloudHints/cloudLinks.ts +31 -0
- package/src/components/cloudHints/hintStorage.ts +28 -0
- package/src/components/cnpg/CNPGView.tsx +4 -7
- package/src/components/diagnose/AgentSetupNotice.tsx +5 -0
- package/src/components/diagnose/DiagnoseContext.tsx +7 -0
- package/src/components/diagnose/DiagnoseSurface.escape.test.tsx +215 -0
- package/src/components/diagnose/DiagnoseSurface.tsx +57 -1
- package/src/components/gitops/RemoteDestinationCloudHint.tsx +6 -14
- package/src/components/home/HomeAgentBlock.tsx +2 -0
- package/src/components/home/HomeView.tsx +3 -3
- package/src/components/home/MCPSetupDialog.test.tsx +9 -0
- package/src/components/home/MCPSetupDialog.tsx +6 -2
- package/src/components/home/McpCloudLine.test.tsx +162 -0
- package/src/components/home/McpCloudLine.tsx +95 -0
- package/src/components/home/ProblemsPanel.investigate.test.tsx +2 -2
- package/src/components/home/mcpToolCatalog.test.ts +10 -0
- package/src/components/home/mcpToolCatalog.ts +4 -4
- package/src/components/issues/ClusterSchedulingBlockerRow.tsx +35 -0
- package/src/components/issues/IssuesPane.render.test.tsx +36 -1
- package/src/components/issues/IssuesPane.tsx +181 -23
- package/src/components/issues/SinceLastVisitRow.render.test.tsx +302 -0
- package/src/components/issues/SinceLastVisitRow.tsx +71 -0
- package/src/components/issues/sinceLastVisit.test.ts +266 -0
- package/src/components/issues/sinceLastVisit.ts +439 -0
- package/src/components/kagent/KagentAgentRenderer.test.ts +32 -0
- package/src/components/kagent/KagentAgentRenderer.tsx +87 -0
- package/src/components/kagent/KagentAgentSessions.test.tsx +166 -0
- package/src/components/kagent/KagentAgentSessions.tsx +124 -0
- package/src/components/kagent/KagentDetailPage.tsx +106 -0
- package/src/components/kagent/KagentLists.tsx +412 -0
- package/src/components/kagent/KagentOverview.tsx +234 -0
- package/src/components/kagent/KagentPages.tsx +690 -0
- package/src/components/kagent/KagentRuntimeTabs.test.tsx +219 -0
- package/src/components/kagent/KagentRuntimeTabs.tsx +283 -0
- package/src/components/kagent/KagentSidebar.test.tsx +112 -0
- package/src/components/kagent/KagentView.tsx +109 -0
- package/src/components/kagent/KagentWorkspace.test.tsx +876 -0
- package/src/components/kagent/host.tsx +144 -0
- package/src/components/kagent/routes.ts +31 -0
- package/src/components/kagent/shared.tsx +336 -0
- package/src/components/kagent/useKagentRuntime.test.tsx +77 -0
- package/src/components/kagent/useKagentSidebarWorkspace.ts +67 -0
- package/src/components/kagent/workspace.fixtures.ts +108 -0
- package/src/components/kagent/workspaceRoute.ts +18 -0
- package/src/components/resource/MetricsNotConnected.test.tsx +28 -0
- package/src/components/resource/MetricsNotConnected.tsx +10 -7
- package/src/components/resource/PrometheusCharts.tsx +10 -1
- package/src/components/resource/PrometheusChartsGrid.render.test.tsx +9 -0
- package/src/components/resource/PrometheusChartsGrid.tsx +3 -3
- package/src/components/resource/SubstrateHealthCharts.test.tsx +13 -1
- package/src/components/resource/SubstrateHealthCharts.tsx +9 -15
- package/src/components/resources/ResourceDetailDrawer.tsx +1 -0
- package/src/components/resources/ResourcesView.tsx +2 -6
- package/src/components/resources/renderers/PodRenderer.tsx +8 -2
- package/src/components/settings/LocalIntegrationStatus.test.tsx +1 -0
- package/src/components/settings/LocalIntegrationStatus.tsx +3 -2
- package/src/components/settings/SettingsDialog.tsx +84 -16
- package/src/components/settings/SubstrateSettings.lifecycle.test.tsx +210 -0
- package/src/components/settings/SubstrateSettings.test.tsx +131 -0
- package/src/components/settings/SubstrateSettings.tsx +544 -0
- package/src/components/settings/settings-state.test.ts +21 -3
- package/src/components/settings/settings-state.ts +13 -3
- package/src/components/share/ShareLinkButton.test.tsx +360 -0
- package/src/components/share/ShareLinkButton.tsx +391 -0
- package/src/components/share/openShareInCloud.test.ts +29 -0
- package/src/components/share/openShareInCloud.ts +10 -0
- package/src/components/share/shareLink.test.ts +129 -0
- package/src/components/share/shareLink.ts +175 -0
- package/src/components/substrate/SubstrateActorDrawer.tsx +87 -0
- package/src/components/substrate/SubstrateActorOverview.tsx +489 -0
- package/src/components/substrate/SubstrateActorPage.tsx +384 -0
- package/src/components/substrate/SubstrateActors.test.tsx +1094 -0
- package/src/components/substrate/SubstrateActors.tsx +612 -0
- package/src/components/substrate/SubstrateAttentionList.tsx +441 -0
- package/src/components/substrate/SubstrateConnect.tsx +88 -0
- package/src/components/substrate/SubstrateOverview.test.tsx +396 -0
- package/src/components/substrate/SubstrateOverview.tsx +575 -0
- package/src/components/substrate/SubstratePages.test.tsx +478 -0
- package/src/components/substrate/SubstratePool.test.tsx +462 -0
- package/src/components/substrate/SubstratePoolPage.tsx +95 -0
- package/src/components/substrate/SubstratePoolSummary.tsx +485 -0
- package/src/components/substrate/SubstrateSidebar.test.tsx +101 -0
- package/src/components/substrate/SubstrateStateBar.tsx +63 -0
- package/src/components/substrate/SubstrateTemplates.tsx +376 -0
- package/src/components/substrate/SubstrateView.tsx +173 -0
- package/src/components/substrate/SubstrateWorkerPodContext.tsx +73 -0
- package/src/components/substrate/SubstrateWorkers.tsx +389 -0
- package/src/components/substrate/attention.ts +81 -0
- package/src/components/substrate/contextPin.tsx +69 -0
- package/src/components/substrate/host.tsx +83 -0
- package/src/components/substrate/kubectlTarget.test.tsx +77 -0
- package/src/components/substrate/readings.test.ts +484 -0
- package/src/components/substrate/readings.ts +997 -0
- package/src/components/substrate/routes.ts +103 -0
- package/src/components/substrate/shared.tsx +426 -0
- package/src/components/substrate/substrate.fixtures.ts +325 -0
- package/src/components/substrate/useSubstrateSidebarWorkspace.ts +87 -0
- package/src/components/substrate/workspaceRoute.ts +23 -0
- package/src/components/traffic/TrafficConnectionsTable.test.tsx +9 -0
- package/src/components/traffic/TrafficConnectionsTable.tsx +4 -2
- package/src/components/traffic/TrafficFilterSidebar.tsx +19 -14
- package/src/components/traffic/TrafficFlowList.test.tsx +63 -0
- package/src/components/traffic/TrafficFlowList.tsx +9 -5
- package/src/components/traffic/TrafficGraph.test.tsx +26 -0
- package/src/components/traffic/TrafficGraph.tsx +17 -14
- package/src/components/traffic/TrafficGraphTooLarge.tsx +2 -0
- package/src/components/traffic/TrafficGraphUnavailable.tsx +3 -1
- package/src/components/traffic/TrafficView.tsx +26 -56
- package/src/components/traffic/trafficFilters.test.ts +61 -1
- package/src/components/traffic/trafficFilters.ts +68 -8
- package/src/components/velero/VeleroOverview.tsx +2 -2
- package/src/components/velero/VeleroView.tsx +3 -6
- package/src/components/vulnerabilities/columns.tsx +132 -0
- package/src/components/vulnerabilities/filters.tsx +317 -0
- package/src/components/vulnerabilities/owner.test.ts +54 -0
- package/src/components/vulnerabilities/owner.tsx +163 -0
- package/src/components/vulnerabilities/parts.test.ts +126 -12
- package/src/components/vulnerabilities/parts.tsx +612 -52
- package/src/components/vulnerabilities/traffic.test.tsx +65 -0
- package/src/components/vulnerabilities/traffic.tsx +40 -0
- package/src/components/workload/WorkloadView.substrateVersion.test.tsx +88 -0
- package/src/components/workload/WorkloadView.tsx +52 -13
- package/src/components/workspace/layout.tsx +13 -7
- package/src/components/workspace/sidebar.test.ts +48 -0
- package/src/components/workspace/sidebar.ts +73 -3
- package/src/components/workspace/table.ts +2 -1
- package/src/contexts/RegistryAccessMode.test.tsx +51 -0
- package/src/contexts/RegistryAccessMode.tsx +25 -0
- package/src/integrations/resourceHost.ts +12 -6
- package/src/integrations/resourceHosts.test.tsx +27 -1
- package/src/integrations/resourceHosts.tsx +15 -7
- package/src/integrations/sidebarWorkspaces.test.tsx +63 -0
- package/src/integrations/sidebarWorkspaces.ts +41 -0
- package/src/integrations/workspaceRoute.ts +1 -1
- package/src/integrations/workspaceRoutes.ts +7 -1
- package/src/integrations/workspaceScreens.tsx +6 -0
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
import { Fragment, useContext, useState, type ReactNode } from 'react'
|
|
2
|
+
import { useSearchParams } from 'react-router-dom'
|
|
3
|
+
import { clsx } from 'clsx'
|
|
4
|
+
import {
|
|
5
|
+
Collapse,
|
|
6
|
+
CollapseChevron,
|
|
7
|
+
DimensionValue,
|
|
8
|
+
FactGrid,
|
|
9
|
+
FactRow,
|
|
10
|
+
OpenIssueContext,
|
|
11
|
+
RefLink,
|
|
12
|
+
RowDetails,
|
|
13
|
+
StatusDot,
|
|
14
|
+
Tooltip,
|
|
15
|
+
WorkspaceCard,
|
|
16
|
+
WorkspaceProblemCallout,
|
|
17
|
+
toneTextClass,
|
|
18
|
+
type ResourceRef,
|
|
19
|
+
type StatusTone,
|
|
20
|
+
} from '@skyhook-io/k8s-ui'
|
|
21
|
+
import type { AgentSandboxAttention, AgentSandboxRef, AgentSandboxWorkspaceResponse } from '../../api/agentSandbox'
|
|
22
|
+
import { useResourceWithRelationships } from '../../api/client'
|
|
23
|
+
import { sandboxPod } from './lists'
|
|
24
|
+
import { useNamespacedCapabilities } from '../../contexts/CapabilitiesContext'
|
|
25
|
+
import type { SelectedResource } from '../../types'
|
|
26
|
+
import { buildWorkloadPath, refToSelectedResource } from '../../utils/navigation'
|
|
27
|
+
import { issuesPathForSubject } from '../../utils/page-links'
|
|
28
|
+
import { ScreenBody } from '../workspace/layout'
|
|
29
|
+
import { useWorkspaceNavigate } from '../workspace/useWorkspaceNavigate'
|
|
30
|
+
import { CommandChip } from '../substrate/shared'
|
|
31
|
+
import { poolNotReadyPath } from './AgentSandboxTables'
|
|
32
|
+
import { notReadyMembers, schedulerReason } from './labels'
|
|
33
|
+
import { SANDBOXES_PATH, SANDBOX_CLAIMS_PATH, SANDBOX_WARM_POOLS_PATH } from './routes'
|
|
34
|
+
import { AGENT_SANDBOX_WHAT_IT_IS, AgentSandboxHeader, SourceText } from './shared'
|
|
35
|
+
import { PRESENCE_TEXT, WorkspaceCoverageNotice, attentionAge, attentionDetail, attentionProblem, controllerValue, leftOutText, relationLabel, severityTone } from './workspace'
|
|
36
|
+
import { useNavCustomization } from '../../context/NavCustomization'
|
|
37
|
+
|
|
38
|
+
export const NOTHING_NEEDS_ATTENTION = 'Nothing needs attention.'
|
|
39
|
+
/** The same, when part of Agent Sandbox could not be read: an empty list there proves less. */
|
|
40
|
+
export const NOTHING_IN_WHAT_WAS_READ = 'Nothing in what Radar can read needs attention.'
|
|
41
|
+
|
|
42
|
+
// Rows shown before folding the rest. The server orders rows (worst first);
|
|
43
|
+
// the list keeps that order and does not group or re-sort them.
|
|
44
|
+
const ATTENTION_SHOWN = 8
|
|
45
|
+
|
|
46
|
+
export interface AgentSandboxOverviewProps {
|
|
47
|
+
data: AgentSandboxWorkspaceResponse
|
|
48
|
+
onClearNamespaces: () => void
|
|
49
|
+
onInspect: (resource: SelectedResource) => void
|
|
50
|
+
inspected: SelectedResource | null
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface SummaryFact {
|
|
54
|
+
label: string
|
|
55
|
+
value: ReactNode
|
|
56
|
+
source?: ReactNode
|
|
57
|
+
tone: StatusTone
|
|
58
|
+
linkLabel?: string
|
|
59
|
+
listPath?: string
|
|
60
|
+
refTo?: ResourceRef & { group: string }
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const plural = (n: number, one: string, many: string) => `${n} ${n === 1 ? one : many}`
|
|
64
|
+
const at = (lowerBound: boolean, n: number) => `${lowerBound ? '≥' : ''}${n}`
|
|
65
|
+
const toRef = (r: AgentSandboxRef): ResourceRef & { group: string } => ({ kind: r.kind, group: r.group, namespace: r.namespace ?? '', name: r.name })
|
|
66
|
+
|
|
67
|
+
/** The At a glance dimensions: Controller, Sandboxes, Claims, Warm reserve. Unknown never reads as 0. */
|
|
68
|
+
export function overviewFacts(data: AgentSandboxWorkspaceResponse): SummaryFact[] {
|
|
69
|
+
const { counts } = data
|
|
70
|
+
const controller = controllerValue(data.controller)
|
|
71
|
+
const controllerReadable = data.controller.state === 'running' || data.controller.state === 'notReady' || data.controller.state === 'scaledToZero'
|
|
72
|
+
const controllerRef = controllerReadable
|
|
73
|
+
? { kind: 'Deployment', group: 'apps', namespace: data.controller.namespace, name: data.controller.name }
|
|
74
|
+
: undefined
|
|
75
|
+
const facts: SummaryFact[] = [
|
|
76
|
+
{
|
|
77
|
+
label: 'Controller',
|
|
78
|
+
value: controller.value,
|
|
79
|
+
tone: controller.tone,
|
|
80
|
+
refTo: controllerRef,
|
|
81
|
+
linkLabel: controllerRef ? 'Deployment' : undefined,
|
|
82
|
+
source:
|
|
83
|
+
data.controller.state === 'notInstalled'
|
|
84
|
+
? 'No Agent Sandbox CRDs served'
|
|
85
|
+
: `Deployment ${data.controller.namespace}/${data.controller.name} · cluster-level check, outside namespace filter`,
|
|
86
|
+
},
|
|
87
|
+
]
|
|
88
|
+
|
|
89
|
+
const s = counts.sandboxes
|
|
90
|
+
if (!s) {
|
|
91
|
+
facts.push({
|
|
92
|
+
label: 'Sandboxes',
|
|
93
|
+
value: leftOutText(data, 'sandboxes'),
|
|
94
|
+
tone: data.coverage.sandboxes?.state === 'notInstalled' ? 'neutral' : 'unknown',
|
|
95
|
+
linkLabel: 'Sandboxes',
|
|
96
|
+
listPath: SANDBOXES_PATH,
|
|
97
|
+
source: 'agents.x-k8s.io',
|
|
98
|
+
})
|
|
99
|
+
} else if (s.total === 0) {
|
|
100
|
+
facts.push({
|
|
101
|
+
label: 'Sandboxes',
|
|
102
|
+
value: s.lowerBound ? 'None Radar can read' : 'None',
|
|
103
|
+
tone: s.lowerBound ? 'unknown' : 'neutral',
|
|
104
|
+
linkLabel: 'Sandboxes',
|
|
105
|
+
listPath: SANDBOXES_PATH,
|
|
106
|
+
source: 'agents.x-k8s.io',
|
|
107
|
+
})
|
|
108
|
+
} else {
|
|
109
|
+
const lb = s.lowerBound
|
|
110
|
+
const problemParts = [
|
|
111
|
+
s.failed > 0 ? `${at(lb, s.failed)} failed` : null,
|
|
112
|
+
s.unschedulable > 0 ? `${at(lb, s.unschedulable)} can’t schedule` : null,
|
|
113
|
+
s.suspensionBlocked > 0 ? `${at(lb, s.suspensionBlocked)} suspension blocked` : null,
|
|
114
|
+
s.unknown > 0 ? `${at(lb, s.unknown)} unknown` : null,
|
|
115
|
+
].filter((x): x is string => x !== null)
|
|
116
|
+
const otherParts = [
|
|
117
|
+
s.running > 0 ? `${at(lb, s.running)} running` : null,
|
|
118
|
+
s.starting > 0 ? `${at(lb, s.starting)} starting` : null,
|
|
119
|
+
s.suspended > 0 ? `${at(lb, s.suspended)} suspended` : null,
|
|
120
|
+
s.expired > 0 ? `${at(lb, s.expired)} expired` : null,
|
|
121
|
+
s.finished > 0 ? `${at(lb, s.finished)} finished` : null,
|
|
122
|
+
s.terminating > 0 ? `${at(lb, s.terminating)} terminating` : null,
|
|
123
|
+
].filter((x): x is string => x !== null)
|
|
124
|
+
const headline =
|
|
125
|
+
problemParts.length > 0
|
|
126
|
+
? problemParts.join(' · ')
|
|
127
|
+
: s.running > 0
|
|
128
|
+
? [`${at(lb, s.running)} running`, s.starting > 0 ? `${at(lb, s.starting)} starting` : null].filter(Boolean).join(' · ')
|
|
129
|
+
: otherParts.join(' · ')
|
|
130
|
+
const subParts = problemParts.length > 0 ? otherParts : s.running > 0 ? otherParts.filter((p) => !p.endsWith(' running') && !p.endsWith(' starting')) : []
|
|
131
|
+
const tone: StatusTone =
|
|
132
|
+
s.failed > 0 ? 'unhealthy' : s.suspensionBlocked > 0 || s.unschedulable > 0 ? 'alert' : s.starting > 0 || s.unknown > 0 ? 'degraded' : lb ? 'unknown' : s.running > 0 ? 'healthy' : 'neutral'
|
|
133
|
+
facts.push({
|
|
134
|
+
label: 'Sandboxes',
|
|
135
|
+
value: headline,
|
|
136
|
+
tone,
|
|
137
|
+
linkLabel: 'Sandboxes',
|
|
138
|
+
listPath: SANDBOXES_PATH,
|
|
139
|
+
source: [`${at(lb, s.total)} total`, ...subParts, 'agents.x-k8s.io'].join(' · '),
|
|
140
|
+
})
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const c = counts.claims
|
|
144
|
+
if (!c) {
|
|
145
|
+
facts.push({
|
|
146
|
+
label: 'Claims',
|
|
147
|
+
value: leftOutText(data, 'claims'),
|
|
148
|
+
tone: data.coverage.claims?.state === 'notInstalled' ? 'neutral' : 'unknown',
|
|
149
|
+
linkLabel: 'Claims',
|
|
150
|
+
listPath: SANDBOX_CLAIMS_PATH,
|
|
151
|
+
source: 'extensions.agents.x-k8s.io',
|
|
152
|
+
})
|
|
153
|
+
} else if (c.total === 0) {
|
|
154
|
+
facts.push({
|
|
155
|
+
label: 'Claims',
|
|
156
|
+
value: c.lowerBound ? 'None Radar can read' : 'None',
|
|
157
|
+
tone: c.lowerBound ? 'unknown' : 'neutral',
|
|
158
|
+
linkLabel: 'Claims',
|
|
159
|
+
listPath: SANDBOX_CLAIMS_PATH,
|
|
160
|
+
source: 'extensions.agents.x-k8s.io',
|
|
161
|
+
})
|
|
162
|
+
} else {
|
|
163
|
+
const lb = c.lowerBound
|
|
164
|
+
const headline =
|
|
165
|
+
c.waiting > 0
|
|
166
|
+
? `${at(lb, c.waiting)} waiting · ${at(lb, c.bound)} bound`
|
|
167
|
+
: c.bound > 0
|
|
168
|
+
? `${at(lb, c.bound)} bound`
|
|
169
|
+
: `${at(lb, c.expired)} expired`
|
|
170
|
+
const subParts = [`${at(lb, c.total)} total`, c.expired > 0 && (c.waiting > 0 || c.bound > 0) ? `${at(lb, c.expired)} expired` : null, 'extensions.agents.x-k8s.io'].filter(Boolean)
|
|
171
|
+
facts.push({
|
|
172
|
+
label: 'Claims',
|
|
173
|
+
value: headline,
|
|
174
|
+
tone: c.waiting > 0 ? 'degraded' : lb ? 'unknown' : c.bound > 0 ? 'healthy' : 'neutral',
|
|
175
|
+
linkLabel: 'Claims',
|
|
176
|
+
listPath: SANDBOX_CLAIMS_PATH,
|
|
177
|
+
source: subParts.join(' · '),
|
|
178
|
+
})
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const w = counts.warmPools
|
|
182
|
+
if (!w) {
|
|
183
|
+
facts.push({
|
|
184
|
+
label: 'Warm reserve',
|
|
185
|
+
value: leftOutText(data, 'warmPools'),
|
|
186
|
+
tone: data.coverage.warmPools?.state === 'notInstalled' ? 'neutral' : 'unknown',
|
|
187
|
+
linkLabel: 'Warm pools',
|
|
188
|
+
listPath: SANDBOX_WARM_POOLS_PATH,
|
|
189
|
+
source: 'extensions.agents.x-k8s.io',
|
|
190
|
+
})
|
|
191
|
+
} else if (w.total === 0) {
|
|
192
|
+
facts.push({
|
|
193
|
+
label: 'Warm reserve',
|
|
194
|
+
value: w.lowerBound ? 'None Radar can read' : 'None',
|
|
195
|
+
tone: w.lowerBound ? 'unknown' : 'neutral',
|
|
196
|
+
linkLabel: 'Warm pools',
|
|
197
|
+
listPath: SANDBOX_WARM_POOLS_PATH,
|
|
198
|
+
source: 'extensions.agents.x-k8s.io',
|
|
199
|
+
})
|
|
200
|
+
} else {
|
|
201
|
+
const lb = w.lowerBound
|
|
202
|
+
const readyLowerBound = lb || !!w.readyLowerBound
|
|
203
|
+
const desiredLowerBound = lb || !!w.desiredLowerBound
|
|
204
|
+
const ready = readyLowerBound && w.ready === 0 ? 'unknown' : at(readyLowerBound, w.ready)
|
|
205
|
+
const target = desiredLowerBound && w.desired === 0 ? 'unknown' : at(desiredLowerBound, w.desired)
|
|
206
|
+
const pools = lb ? `≥${w.total} pools` : plural(w.total, 'pool', 'pools')
|
|
207
|
+
const poolAttention = data.attention.filter((a) => a.category === 'warmPool')
|
|
208
|
+
const worstPoolTone = poolAttention.length > 0 ? severityTone(poolAttention[0].severity) : undefined
|
|
209
|
+
const topPoolRow = poolAttention[0]
|
|
210
|
+
const topScheduler = schedulerReason(topPoolRow)
|
|
211
|
+
const causeNote = topPoolRow
|
|
212
|
+
? `${topPoolRow.subject.name}: ${topScheduler ? `can’t schedule (${topScheduler.plain.toLowerCase()})` : topPoolRow.title.toLowerCase()}`
|
|
213
|
+
: 'status.readyReplicas / spec.replicas'
|
|
214
|
+
facts.push({
|
|
215
|
+
label: 'Warm reserve',
|
|
216
|
+
value: ready === 'unknown' || target === 'unknown' ? `${ready} ready · target ${target} in ${pools}` : `${ready} of ${target} ready in ${pools}`,
|
|
217
|
+
tone: worstPoolTone ?? (readyLowerBound || desiredLowerBound ? 'unknown' : w.ready >= w.desired ? 'healthy' : 'degraded'),
|
|
218
|
+
linkLabel: 'Warm pools',
|
|
219
|
+
listPath: SANDBOX_WARM_POOLS_PATH,
|
|
220
|
+
source: `${causeNote} · extensions.agents.x-k8s.io`,
|
|
221
|
+
})
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return facts
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function RefsLine({ lead, refs, onNavigate }: { lead: string; refs: AgentSandboxRef[]; onNavigate: (ref: ResourceRef) => void }) {
|
|
228
|
+
return (
|
|
229
|
+
<div className="break-words text-xs text-theme-text-secondary">
|
|
230
|
+
{lead}{' '}
|
|
231
|
+
{refs.map((r, i) => (
|
|
232
|
+
<Fragment key={`${r.kind}/${r.namespace}/${r.name}`}>
|
|
233
|
+
{i > 0 && (i === refs.length - 1 ? ' and ' : ', ')}
|
|
234
|
+
<RefLink refTo={toRef(r)} onNavigate={onNavigate} mono />
|
|
235
|
+
</Fragment>
|
|
236
|
+
))}
|
|
237
|
+
.
|
|
238
|
+
</div>
|
|
239
|
+
)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* The objects a row names, each with what Radar could say about it: a link
|
|
244
|
+
* when it is there, "not found" only where its kind was read in full in that
|
|
245
|
+
* namespace, "not read" otherwise. Objects the row already links are left out.
|
|
246
|
+
*/
|
|
247
|
+
function shownRelations(a: AgentSandboxAttention) {
|
|
248
|
+
const linked = new Set([a.subject, ...(a.related?.refs ?? []), ...(a.emptyPool ? [a.emptyPool] : [])].map((r) => `${r.kind}/${r.namespace ?? ''}/${r.name}`))
|
|
249
|
+
return (a.relations ?? []).filter((r) => !linked.has(`${r.ref.kind}/${r.ref.namespace ?? ''}/${r.ref.name}`))
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function RelationsLine({ a, onNavigate }: { a: AgentSandboxAttention; onNavigate: (ref: ResourceRef) => void }) {
|
|
253
|
+
const shown = shownRelations(a)
|
|
254
|
+
if (shown.length === 0) return null
|
|
255
|
+
return (
|
|
256
|
+
<div className="break-words text-xs text-theme-text-secondary">
|
|
257
|
+
{shown.map((r, i) => (
|
|
258
|
+
<Fragment key={`${r.role}/${r.ref.name}`}>
|
|
259
|
+
{i > 0 && ' · '}
|
|
260
|
+
{relationLabel(r)}{' '}
|
|
261
|
+
{r.presence === 'present' ? (
|
|
262
|
+
<RefLink refTo={toRef(r.ref)} onNavigate={onNavigate} mono />
|
|
263
|
+
) : (
|
|
264
|
+
<>
|
|
265
|
+
<span className="font-mono">{r.ref.name}</span>{' '}
|
|
266
|
+
<span className={clsx(r.presence === 'absent' ? toneTextClass('unhealthy') : 'text-theme-text-tertiary')}>{PRESENCE_TEXT[r.presence]}</span>
|
|
267
|
+
</>
|
|
268
|
+
)}
|
|
269
|
+
</Fragment>
|
|
270
|
+
))}
|
|
271
|
+
</div>
|
|
272
|
+
)
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function Impact({ a, onNavigate }: { a: AgentSandboxAttention; onNavigate: (ref: ResourceRef) => void }) {
|
|
276
|
+
if (a.rule === 'controllerNotRunning' && a.related) return <span>{a.related.lead.replace(/:$/, '')}</span>
|
|
277
|
+
const w = a.waitingClaims
|
|
278
|
+
if (w && w.count !== null) {
|
|
279
|
+
if (w.count === 0) return <span>no unbound claim in progress uses it</span>
|
|
280
|
+
return (
|
|
281
|
+
<span>
|
|
282
|
+
{w.lowerBound ? 'at least ' : ''}
|
|
283
|
+
{plural(w.count, 'unbound claim in progress uses', 'unbound claims in progress use')} this pool
|
|
284
|
+
</span>
|
|
285
|
+
)
|
|
286
|
+
}
|
|
287
|
+
if (a.emptyPool) {
|
|
288
|
+
return (
|
|
289
|
+
<span>
|
|
290
|
+
its warm pool <RefLink refTo={toRef(a.emptyPool)} onNavigate={onNavigate} mono /> has no sandbox ready
|
|
291
|
+
</span>
|
|
292
|
+
)
|
|
293
|
+
}
|
|
294
|
+
return null
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/** Strips an inline parenthetical command so the next step reads cleanly; the chip lives in Details on Overview. */
|
|
298
|
+
export function cleanNextStepText(a: AgentSandboxAttention): string {
|
|
299
|
+
if (!a.command) return a.nextStep
|
|
300
|
+
const quoted = ` (${a.command})`
|
|
301
|
+
return a.nextStep.includes(quoted) ? a.nextStep.replace(quoted, '') : a.nextStep
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
const LOG_FAILURE_REASONS = new Set(['PodFailed', 'CrashLoopBackOff'])
|
|
305
|
+
|
|
306
|
+
function RowLinkOut({ a }: { a: AgentSandboxAttention }) {
|
|
307
|
+
const openIssue = useContext(OpenIssueContext)
|
|
308
|
+
const navigateTo = useWorkspaceNavigate()
|
|
309
|
+
const members = notReadyMembers(a)
|
|
310
|
+
if (members.length > 0) {
|
|
311
|
+
return (
|
|
312
|
+
<button type="button" onClick={() => navigateTo(poolNotReadyPath(a.subject.namespace ?? '', a.subject.name))} className="whitespace-nowrap text-accent-text hover:underline">
|
|
313
|
+
Show all members that aren’t ready →
|
|
314
|
+
</button>
|
|
315
|
+
)
|
|
316
|
+
}
|
|
317
|
+
if (!openIssue || !a.issue) return null
|
|
318
|
+
return (
|
|
319
|
+
<button type="button" onClick={() => openIssue(attentionProblem(a))} className="whitespace-nowrap text-accent-text hover:underline">
|
|
320
|
+
See in Issues →
|
|
321
|
+
</button>
|
|
322
|
+
)
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Compact Needs attention row: severity dot + title + age, one evidence line
|
|
327
|
+
* with subject + direct Pod/Logs link + honest Issues/members link, optional
|
|
328
|
+
* caveat, one-line next step. Full reading, kubectl commands, and raw source
|
|
329
|
+
* messages fold under Details.
|
|
330
|
+
*/
|
|
331
|
+
function AttentionRow({ a, onNavigate }: { a: AgentSandboxAttention; onNavigate: (ref: ResourceRef) => void }) {
|
|
332
|
+
const navigateTo = useWorkspaceNavigate()
|
|
333
|
+
const age = attentionAge(a)
|
|
334
|
+
const detail = attentionDetail(a)
|
|
335
|
+
const nextStep = cleanNextStepText(a)
|
|
336
|
+
const evidence = detail || nextStep
|
|
337
|
+
const podRef = a.related?.refs.find((r) => r.kind === 'Pod' && !r.group)
|
|
338
|
+
const sandboxName = a.subject.kind === 'Sandbox' && a.rule !== 'suspensionBlocked' && podRef ? a.subject.name : ''
|
|
339
|
+
const detailQuery = useResourceWithRelationships('sandboxes', a.subject.namespace ?? '', sandboxName, a.subject.group)
|
|
340
|
+
const owned = sandboxPod(detailQuery.data?.relationships, detailQuery.isLoading)
|
|
341
|
+
const verified = owned.state === 'found' && owned.pods.length === 1 ? owned.pods[0] : undefined
|
|
342
|
+
const inlinePod = a.rule === 'suspensionBlocked' ? (podRef && toRef(podRef)) : verified
|
|
343
|
+
const { canViewLogs, logsUnknown } = useNamespacedCapabilities(verified?.namespace)
|
|
344
|
+
|
|
345
|
+
const showPodLogs = !!verified && canViewLogs && !logsUnknown && a.rule === 'failed' && !!a.reason && LOG_FAILURE_REASONS.has(a.reason)
|
|
346
|
+
const extraRelated = a.related?.refs.some((r) => r.kind !== 'Pod') ? a.related : undefined
|
|
347
|
+
const hasDetails = !!detail || !!a.command || !!extraRelated || shownRelations(a).length > 0 || !!a.rawDetail
|
|
348
|
+
const [open, setOpen] = useState(false)
|
|
349
|
+
const tone = severityTone(a.severity)
|
|
350
|
+
|
|
351
|
+
return (
|
|
352
|
+
<li className="min-w-0 py-2.5 first:pt-0 last:pb-0 text-sm" data-rule={a.rule}>
|
|
353
|
+
<div className="flex flex-wrap items-center gap-x-2 gap-y-0.5">
|
|
354
|
+
<StatusDot tone={tone} />
|
|
355
|
+
<span className={clsx('break-words font-medium', toneTextClass(tone))}>{a.title}</span>
|
|
356
|
+
{age && (
|
|
357
|
+
<Tooltip content={age.tip}>
|
|
358
|
+
<span className="whitespace-nowrap text-xs text-theme-text-tertiary">
|
|
359
|
+
{a.rule === 'controllerNotRunning' ? `for ${age.text}` : `${age.text} ago`}
|
|
360
|
+
</span>
|
|
361
|
+
</Tooltip>
|
|
362
|
+
)}
|
|
363
|
+
</div>
|
|
364
|
+
<div className="mt-0.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-theme-text-tertiary">
|
|
365
|
+
<span className="min-w-0 break-words">
|
|
366
|
+
{a.subject.kind} <RefLink refTo={toRef(a.subject)} onNavigate={onNavigate} mono />
|
|
367
|
+
</span>
|
|
368
|
+
{inlinePod && (
|
|
369
|
+
<span className="min-w-0 break-words">
|
|
370
|
+
{a.rule === 'suspensionBlocked' ? 'Conflicting Pod' : 'Pod'}{' '}
|
|
371
|
+
<RefLink refTo={inlinePod} onNavigate={onNavigate} mono />
|
|
372
|
+
</span>
|
|
373
|
+
)}
|
|
374
|
+
{showPodLogs && inlinePod && (
|
|
375
|
+
<button
|
|
376
|
+
type="button"
|
|
377
|
+
onClick={() => navigateTo(buildWorkloadPath({ kind: 'pods', namespace: inlinePod.namespace ?? '', name: inlinePod.name, tab: 'logs' }))}
|
|
378
|
+
className="whitespace-nowrap text-accent-text hover:underline"
|
|
379
|
+
>
|
|
380
|
+
Pod logs →
|
|
381
|
+
</button>
|
|
382
|
+
)}
|
|
383
|
+
<Impact a={a} onNavigate={onNavigate} />
|
|
384
|
+
<RowLinkOut a={a} />
|
|
385
|
+
</div>
|
|
386
|
+
{a.caveat && <div className="mt-0.5 break-words text-xs text-theme-text-secondary">{a.caveat}</div>}
|
|
387
|
+
<div className="mt-0.5 break-words text-xs text-theme-text-primary">
|
|
388
|
+
{evidence}
|
|
389
|
+
</div>
|
|
390
|
+
{hasDetails && (
|
|
391
|
+
<RowDetails open={open} onToggle={() => setOpen((v) => !v)}>
|
|
392
|
+
{detail && <div className="break-words text-xs text-theme-text-secondary">Next step: {nextStep}</div>}
|
|
393
|
+
{a.command && <CommandChip command={a.command} />}
|
|
394
|
+
{extraRelated && <RefsLine lead={extraRelated.lead} refs={extraRelated.refs} onNavigate={onNavigate} />}
|
|
395
|
+
<RelationsLine a={a} onNavigate={onNavigate} />
|
|
396
|
+
{a.rawDetail && <SourceText label={a.rawDetailLabel ?? 'Source’s message'} text={a.rawDetail} />}
|
|
397
|
+
</RowDetails>
|
|
398
|
+
)}
|
|
399
|
+
</li>
|
|
400
|
+
)
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function foldedSeveritySummary(rows: AgentSandboxAttention[]): string {
|
|
404
|
+
const counts: Partial<Record<AgentSandboxAttention['severity'], number>> = {}
|
|
405
|
+
for (const r of rows) counts[r.severity] = (counts[r.severity] ?? 0) + 1
|
|
406
|
+
const parts = (['critical', 'alert', 'warning'] as const)
|
|
407
|
+
.filter((s) => (counts[s] ?? 0) > 0)
|
|
408
|
+
.map((s) => `${counts[s]} ${s}`)
|
|
409
|
+
return parts.length > 0 ? ` — ${parts.join(', ')}` : ''
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
function AttentionList({ rows, onNavigate }: { rows: AgentSandboxAttention[]; onNavigate: (ref: ResourceRef) => void }) {
|
|
413
|
+
const [showAll, setShowAll] = useState(false)
|
|
414
|
+
const folded = rows.slice(ATTENTION_SHOWN)
|
|
415
|
+
const foldId = 'agent-sandbox-attention-more'
|
|
416
|
+
return (
|
|
417
|
+
<div>
|
|
418
|
+
<ul className="divide-y divide-theme-border-subtle">
|
|
419
|
+
{rows.slice(0, ATTENTION_SHOWN).map((a) => (
|
|
420
|
+
<AttentionRow key={a.id} a={a} onNavigate={onNavigate} />
|
|
421
|
+
))}
|
|
422
|
+
</ul>
|
|
423
|
+
{folded.length > 0 && (
|
|
424
|
+
<>
|
|
425
|
+
<Collapse open={showAll} id={foldId}>
|
|
426
|
+
<ul className="divide-y divide-theme-border-subtle border-t border-theme-border-subtle pt-2.5">
|
|
427
|
+
{folded.map((a) => (
|
|
428
|
+
<AttentionRow key={a.id} a={a} onNavigate={onNavigate} />
|
|
429
|
+
))}
|
|
430
|
+
</ul>
|
|
431
|
+
</Collapse>
|
|
432
|
+
<button
|
|
433
|
+
type="button"
|
|
434
|
+
aria-expanded={showAll}
|
|
435
|
+
aria-controls={foldId}
|
|
436
|
+
onClick={() => setShowAll((v) => !v)}
|
|
437
|
+
className="mt-2.5 inline-flex items-center gap-1 text-xs font-medium text-accent-text hover:underline"
|
|
438
|
+
>
|
|
439
|
+
<CollapseChevron open={showAll} />
|
|
440
|
+
{showAll ? 'Show fewer' : `Show ${folded.length} more${foldedSeveritySummary(folded)}`}
|
|
441
|
+
</button>
|
|
442
|
+
</>
|
|
443
|
+
)}
|
|
444
|
+
</div>
|
|
445
|
+
)
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
type FactLink = { linkLabel: string; onOpen: () => void } | { linkLabel?: never; onOpen?: never }
|
|
449
|
+
|
|
450
|
+
function factLink(f: SummaryFact, navigateTo: (path: string) => void, navigate: (ref: ResourceRef) => void): FactLink {
|
|
451
|
+
if (f.linkLabel && f.listPath) return { linkLabel: f.linkLabel, onOpen: () => navigateTo(f.listPath!) }
|
|
452
|
+
if (f.linkLabel && f.refTo) return { linkLabel: f.linkLabel, onOpen: () => navigate(f.refTo!) }
|
|
453
|
+
return {}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
export function AgentSandboxOverview({ data, onClearNamespaces, onInspect }: AgentSandboxOverviewProps) {
|
|
457
|
+
const navigateTo = useWorkspaceNavigate()
|
|
458
|
+
const issuesTakenOver = !!useNavCustomization().fleetTakeoverHref?.('issues')
|
|
459
|
+
const [params] = useSearchParams()
|
|
460
|
+
const navigate = (ref: ResourceRef) => onInspect(refToSelectedResource(ref))
|
|
461
|
+
|
|
462
|
+
const controllerProblem = data.attention.find((a) => a.rule === 'controllerNotRunning')
|
|
463
|
+
const attentionRows = controllerProblem ? data.attention.filter((a) => a.id !== controllerProblem.id) : data.attention
|
|
464
|
+
const findingsTotal = data.attentionTotal - (controllerProblem ? 1 : 0)
|
|
465
|
+
const facts = overviewFacts(data)
|
|
466
|
+
const totalObjects = (data.counts.sandboxes?.total ?? 0) + (data.counts.claims?.total ?? 0) + (data.counts.warmPools?.total ?? 0)
|
|
467
|
+
const scopeSubtitle =
|
|
468
|
+
data.namespaces.length > 0
|
|
469
|
+
? `Namespace: ${data.namespaces.join(', ')}`
|
|
470
|
+
: 'All namespaces'
|
|
471
|
+
|
|
472
|
+
const expiredTotal = data.expired.recentTotal
|
|
473
|
+
const expiredNote = `Expired in the last 7 days. Sandboxes with shutdownPolicy Retain stay until deleted; Delete removes them on expiry.${data.expired.lowerBound ? ' Some namespaces weren’t read, so there may be more.' : ''}`
|
|
474
|
+
|
|
475
|
+
return (
|
|
476
|
+
<OpenIssueContext.Provider value={issuesTakenOver ? undefined : (p) => navigateTo(issuesPathForSubject(p.subject, params.get('namespaces')))}>
|
|
477
|
+
<div className="flex min-h-0 flex-1 flex-col">
|
|
478
|
+
<AgentSandboxHeader
|
|
479
|
+
title="Overview"
|
|
480
|
+
subtitle={scopeSubtitle}
|
|
481
|
+
intro={totalObjects === 0 ? AGENT_SANDBOX_WHAT_IT_IS : undefined}
|
|
482
|
+
namespaces={data.namespaces}
|
|
483
|
+
onClearNamespaces={onClearNamespaces}
|
|
484
|
+
/>
|
|
485
|
+
<ScreenBody>
|
|
486
|
+
<WorkspaceCoverageNotice data={data} />
|
|
487
|
+
|
|
488
|
+
{controllerProblem && (
|
|
489
|
+
<WorkspaceProblemCallout
|
|
490
|
+
problem={attentionProblem(controllerProblem)}
|
|
491
|
+
rootKind="Deployment"
|
|
492
|
+
hideOrigin
|
|
493
|
+
onNavigate={navigate}
|
|
494
|
+
/>
|
|
495
|
+
)}
|
|
496
|
+
|
|
497
|
+
<WorkspaceCard title="Needs attention">
|
|
498
|
+
{attentionRows.length === 0 ? (
|
|
499
|
+
<div className="flex items-center gap-2 text-sm text-theme-text-secondary">
|
|
500
|
+
{data.attentionComplete && !controllerProblem && <StatusDot tone="healthy" />}
|
|
501
|
+
<span className="text-theme-text-tertiary">{controllerProblem ? 'No other findings in the objects Radar read.' : data.attentionComplete ? NOTHING_NEEDS_ATTENTION : NOTHING_IN_WHAT_WAS_READ}</span>
|
|
502
|
+
</div>
|
|
503
|
+
) : (
|
|
504
|
+
<AttentionList rows={attentionRows} onNavigate={navigate} />
|
|
505
|
+
)}
|
|
506
|
+
{findingsTotal > attentionRows.length && (
|
|
507
|
+
<p className="mt-2.5 text-xs text-theme-text-tertiary">Showing {attentionRows.length} of {findingsTotal} findings.</p>
|
|
508
|
+
)}
|
|
509
|
+
</WorkspaceCard>
|
|
510
|
+
|
|
511
|
+
<WorkspaceCard title="At a glance">
|
|
512
|
+
<FactGrid>
|
|
513
|
+
{facts.map((f) => (
|
|
514
|
+
<FactRow key={f.label} label={f.label}>
|
|
515
|
+
<DimensionValue
|
|
516
|
+
tone={f.tone}
|
|
517
|
+
{...factLink(f, navigateTo, navigate)}
|
|
518
|
+
source={
|
|
519
|
+
f.label === 'Sandboxes' && expiredTotal > 0 ? (
|
|
520
|
+
<span className="inline-flex flex-wrap items-center gap-x-2">
|
|
521
|
+
<span>{f.source}</span>
|
|
522
|
+
<Tooltip content={expiredNote}>
|
|
523
|
+
<span>{at(data.expired.lowerBound, expiredTotal)} sandboxes and claims expired in the last 7 days</span>
|
|
524
|
+
</Tooltip>
|
|
525
|
+
<button
|
|
526
|
+
type="button"
|
|
527
|
+
onClick={() => navigateTo(`${SANDBOXES_PATH}&state=recentlyExpired`)}
|
|
528
|
+
className="text-accent-text hover:underline"
|
|
529
|
+
>
|
|
530
|
+
Recently expired sandboxes →
|
|
531
|
+
</button>
|
|
532
|
+
<button
|
|
533
|
+
type="button"
|
|
534
|
+
onClick={() => navigateTo(`${SANDBOX_CLAIMS_PATH}&segment=expired&state=recentlyExpired`)}
|
|
535
|
+
className="text-accent-text hover:underline"
|
|
536
|
+
>
|
|
537
|
+
Recently expired claims →
|
|
538
|
+
</button>
|
|
539
|
+
</span>
|
|
540
|
+
) : (
|
|
541
|
+
f.source
|
|
542
|
+
)
|
|
543
|
+
}
|
|
544
|
+
>
|
|
545
|
+
{f.value}
|
|
546
|
+
</DimensionValue>
|
|
547
|
+
</FactRow>
|
|
548
|
+
))}
|
|
549
|
+
</FactGrid>
|
|
550
|
+
</WorkspaceCard>
|
|
551
|
+
</ScreenBody>
|
|
552
|
+
</div>
|
|
553
|
+
</OpenIssueContext.Provider>
|
|
554
|
+
)
|
|
555
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
2
|
+
import { MemoryRouter } from 'react-router-dom'
|
|
3
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
4
|
+
import { ResourcesSidebar, type SidebarCategoryWorkspace } from '@skyhook-io/k8s-ui'
|
|
5
|
+
import type { AgentSandboxWorkspaceResponse } from '../../api/agentSandbox'
|
|
6
|
+
import type { SubstrateWorkspace } from '../../api/substrateWorkspace'
|
|
7
|
+
import type { APIResource } from '../../types'
|
|
8
|
+
import { AGENTS_SIDEBAR_CATEGORY, useMergedSidebarWorkspaces } from '../workspace/sidebar'
|
|
9
|
+
import { useSubstrateSidebarWorkspace } from '../substrate/useSubstrateSidebarWorkspace'
|
|
10
|
+
import { workspace as substrateWorkspace } from '../substrate/substrate.fixtures'
|
|
11
|
+
import { useAgentSandboxSidebarWorkspace } from './useAgentSandboxSidebarWorkspace'
|
|
12
|
+
import { liveWorkspace } from './workspace.fixtures'
|
|
13
|
+
|
|
14
|
+
const state = vi.hoisted(() => ({ sandbox: undefined as AgentSandboxWorkspaceResponse | undefined, substrate: undefined as SubstrateWorkspace | undefined }))
|
|
15
|
+
|
|
16
|
+
vi.mock('../../api/client', async (importOriginal) => ({
|
|
17
|
+
...(await importOriginal<typeof import('../../api/client')>()),
|
|
18
|
+
useRadarFeature: () => ({ support: 'supported' }),
|
|
19
|
+
}))
|
|
20
|
+
vi.mock('../../api/agentSandbox', async (importOriginal) => ({
|
|
21
|
+
...(await importOriginal<typeof import('../../api/agentSandbox')>()),
|
|
22
|
+
useAgentSandboxWorkspace: () => ({ data: state.sandbox }),
|
|
23
|
+
}))
|
|
24
|
+
vi.mock('../../api/substrateWorkspace', async (importOriginal) => ({
|
|
25
|
+
...(await importOriginal<typeof import('../../api/substrateWorkspace')>()),
|
|
26
|
+
useSubstrateWorkspace: () => ({ data: state.substrate }),
|
|
27
|
+
}))
|
|
28
|
+
vi.mock('../../context/ConnectionContext', () => ({ useConnection: () => ({ connection: { context: 'kind-demo' } }) }))
|
|
29
|
+
|
|
30
|
+
const crd = (group: string, kind: string, name: string) => ({ group, version: 'v1alpha1', kind, name, namespaced: true, isCrd: true, verbs: ['list'] }) as APIResource
|
|
31
|
+
const SANDBOX_KINDS = [crd('agents.x-k8s.io', 'Sandbox', 'sandboxes'), crd('extensions.agents.x-k8s.io', 'SandboxClaim', 'sandboxclaims'), crd('extensions.agents.x-k8s.io', 'SandboxWarmPool', 'sandboxwarmpools'), crd('extensions.agents.x-k8s.io', 'SandboxTemplate', 'sandboxtemplates')]
|
|
32
|
+
const SUBSTRATE_KINDS = [crd('ate.dev', 'WorkerPool', 'workerpools'), crd('ate.dev', 'SandboxConfig', 'sandboxconfigs')]
|
|
33
|
+
|
|
34
|
+
function render(apiResources: APIResource[], namespaces: string[] = []) {
|
|
35
|
+
let workspaces: Record<string, SidebarCategoryWorkspace> | undefined
|
|
36
|
+
function Host() {
|
|
37
|
+
const substrate = useSubstrateSidebarWorkspace({ apiResources })
|
|
38
|
+
const sandbox = useAgentSandboxSidebarWorkspace({ apiResources, namespaces, active: true })
|
|
39
|
+
workspaces = useMergedSidebarWorkspaces(undefined, undefined, substrate, sandbox)
|
|
40
|
+
return <ResourcesSidebar selectedKind={null} onSelectedKindChange={() => {}} apiResources={apiResources} categoryWorkspaces={workspaces} />
|
|
41
|
+
}
|
|
42
|
+
const html = renderToStaticMarkup(<MemoryRouter><Host /></MemoryRouter>).replace(/<!-- -->/g, '')
|
|
43
|
+
return { html, agents: workspaces?.[AGENTS_SIDEBAR_CATEGORY] }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
describe('Agent Sandbox in the sidebar', () => {
|
|
47
|
+
it('is its part of the Agents row, the tool beneath, opening to its Overview and three tables', () => {
|
|
48
|
+
state.sandbox = liveWorkspace({ namespaces: ['payments'] })
|
|
49
|
+
const { html, agents } = render(SANDBOX_KINDS, ['payments'])
|
|
50
|
+
expect(agents?.tools).toBe('Agent Sandbox')
|
|
51
|
+
expect(agents?.destinations.map((d) => d.label)).toEqual(['Overview', 'Sandboxes', 'Claims', 'Warm pools'])
|
|
52
|
+
expect(agents?.count).toBe(7)
|
|
53
|
+
// One runtime: the row reads as before, with no section headings.
|
|
54
|
+
expect(html).toMatch(/>Agents<\/span><span[^>]*>Agent Sandbox</)
|
|
55
|
+
expect(html).not.toMatch(/uppercase[^"]*">Sandbox</)
|
|
56
|
+
expect(html).toContain('Counts for namespace payments')
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
describe('The Agents row with both runtimes', () => {
|
|
61
|
+
it('names the job, lists both tools beneath, heads each runtime’s destinations, and adds up their counts', () => {
|
|
62
|
+
state.sandbox = liveWorkspace({ namespaces: [] })
|
|
63
|
+
state.substrate = substrateWorkspace()
|
|
64
|
+
const { html, agents } = render([...SUBSTRATE_KINDS, ...SANDBOX_KINDS])
|
|
65
|
+
expect(html).toMatch(/>Agents<\/span><span[^>]*>Agent Substrate · Agent Sandbox</)
|
|
66
|
+
// One row: the two runtimes no longer list as rows of their own.
|
|
67
|
+
expect(html.match(/aria-label="(Expand|Collapse) Agents"/g)).toHaveLength(1)
|
|
68
|
+
expect(html).not.toContain('Expand Agent Substrate')
|
|
69
|
+
expect(agents?.destinations.map((d) => `${d.section}/${d.label}`)).toEqual([
|
|
70
|
+
'Substrate/Overview', 'Substrate/Actors', 'Substrate/Templates', 'Substrate/Workers', 'Substrate/Pools',
|
|
71
|
+
'Sandbox/Overview', 'Sandbox/Sandboxes', 'Sandbox/Claims', 'Sandbox/Warm pools',
|
|
72
|
+
])
|
|
73
|
+
expect(new Set(agents?.destinations.map((d) => d.id)).size).toBe(9)
|
|
74
|
+
expect(html.indexOf('>Substrate</div>')).toBeGreaterThan(-1)
|
|
75
|
+
expect(html.indexOf('>Substrate</div>')).toBeLessThan(html.indexOf('>Sandbox</div>'))
|
|
76
|
+
// Substrate's 3 attention items and Sandbox's 7 objects needing attention, with hover breakdown and scope.
|
|
77
|
+
expect(agents).toMatchObject({
|
|
78
|
+
count: 10,
|
|
79
|
+
countLowerBound: false,
|
|
80
|
+
countTitle: 'Attention items — Substrate: 3 · cluster-wide · Sandbox: 7 · all namespaces',
|
|
81
|
+
})
|
|
82
|
+
// The kinds neither runtime has a table for stay under Other kinds, suffixed with their runtime.
|
|
83
|
+
expect(html).toMatch(/Other kinds \(2\)/)
|
|
84
|
+
expect(html).toContain('SandboxConfig')
|
|
85
|
+
expect(html).toContain(' · Substrate')
|
|
86
|
+
expect(html).toContain('SandboxTemplate')
|
|
87
|
+
expect(html).toContain(' · Sandbox')
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
it('includes namespace scope in the Agents badge hover breakdown when filtered', () => {
|
|
91
|
+
state.sandbox = liveWorkspace({ namespaces: ['payments'] })
|
|
92
|
+
state.substrate = substrateWorkspace()
|
|
93
|
+
const { agents } = render([...SUBSTRATE_KINDS, ...SANDBOX_KINDS], ['payments'])
|
|
94
|
+
expect(agents?.countTitle).toBe('Attention items — Substrate: 3 · cluster-wide · Sandbox: 7 · namespace payments')
|
|
95
|
+
expect(agents?.scopeNote).toBe('Agent Sandbox: Counts for namespace payments · Agent Substrate: cluster-wide')
|
|
96
|
+
})
|
|
97
|
+
})
|