@skyhook-io/radar-app 1.22.1 → 1.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -8
- package/src/App.tsx +131 -38
- package/src/RadarApp.basename.test.tsx +177 -0
- package/src/RadarApp.settings.test.tsx +33 -0
- package/src/RadarApp.tsx +5 -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 +128 -25
- 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 +1172 -0
- package/src/api/workloadSource.ts +408 -0
- package/src/components/APIUnreachableBanner.test.tsx +19 -0
- package/src/components/APIUnreachableBanner.tsx +20 -0
- 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/ConnectionErrorView.test.tsx +63 -2
- package/src/components/ConnectionErrorView.tsx +88 -68
- 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/ActivityTurn.tsx +6 -4
- package/src/components/diagnose/AgentSetupNotice.tsx +5 -0
- package/src/components/diagnose/AssessmentCard.tsx +1 -2
- package/src/components/diagnose/ContinueInAgentButton.test.tsx +7 -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/diagnose/Home.test.tsx +6 -0
- package/src/components/diagnose/Home.tsx +10 -3
- package/src/components/diagnose/InvestigationEvidencePane.story.test.tsx +1 -1
- package/src/components/diagnose/InvestigationEvidencePane.tsx +19 -2
- package/src/components/diagnose/InvestigationFindingsFooter.test.tsx +413 -0
- package/src/components/diagnose/InvestigationView.tsx +120 -23
- package/src/components/diagnose/investigationEvidence/identity.test.ts +1 -1
- package/src/components/diagnose/investigationEvidence/projection.test.ts +1 -1
- package/src/components/diagnose/investigationState.ts +9 -0
- package/src/components/diagnose/parts.test.tsx +11 -3
- package/src/components/diagnose/toolCallLabel.ts +3 -0
- package/src/components/gitops/RemoteDestinationCloudHint.tsx +6 -14
- package/src/components/home/ActivitySummary.tsx +3 -8
- package/src/components/home/ClusterHealthCard.tsx +91 -17
- package/src/components/home/ClusterHealthCard.utilization.test.tsx +187 -0
- package/src/components/home/HomeAgentBlock.tsx +2 -0
- package/src/components/home/HomeView.tsx +9 -29
- 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/TopologyPreview.test.tsx +31 -30
- package/src/components/home/TopologyPreview.tsx +19 -28
- package/src/components/home/mcpToolCatalog.test.ts +10 -0
- package/src/components/home/mcpToolCatalog.ts +7 -7
- 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/JobAdmissionRenderers.tsx +5 -4
- package/src/components/resources/renderers/PodRenderer.tsx +8 -2
- package/src/components/resources/renderers/RolloutRenderer.tsx +4 -1
- package/src/components/resources/renderers/WorkloadRenderer.tsx +4 -1
- 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 +119 -14
- package/src/components/workload/WorkloadView.workloadSource.test.tsx +121 -0
- 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/context/ConnectionContext.tsx +24 -5
- package/src/context/ConnectionProvider.connectionId.test.tsx +14 -0
- package/src/context/ConnectionProvider.handover.test.tsx +94 -0
- package/src/context/DiagnoseCustomization.tsx +20 -2
- package/src/contexts/RegistryAccessMode.test.tsx +51 -0
- package/src/contexts/RegistryAccessMode.tsx +25 -0
- package/src/hooks/useEventSource.test.tsx +275 -4
- package/src/hooks/useEventSource.ts +278 -51
- package/src/index.ts +1 -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
- package/src/utils/navigation.test.ts +1 -6
- package/src/utils/navigation.ts +9 -44
- package/src/utils/network-policy-navigation.test.ts +21 -36
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import type { SidebarCategoryWorkspace } from '@skyhook-io/k8s-ui'
|
|
3
|
+
import { mergeSidebarWorkspaces } from './sidebar'
|
|
4
|
+
|
|
5
|
+
const part = (tools: string, section: string, over: Partial<SidebarCategoryWorkspace> = {}): SidebarCategoryWorkspace => ({
|
|
6
|
+
tools,
|
|
7
|
+
destinations: [{ id: `${section}-overview`, label: 'Overview', section, onSelect: () => {} }],
|
|
8
|
+
...over,
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
describe('mergeSidebarWorkspaces', () => {
|
|
12
|
+
it('is undefined when no integration applies, and passes a lone workspace through as it is', () => {
|
|
13
|
+
expect(mergeSidebarWorkspaces([undefined, undefined])).toBeUndefined()
|
|
14
|
+
const velero = { Velero: part('Velero', 'Velero', { label: 'Backups' }) }
|
|
15
|
+
const agents = { Agents: part('Agent Sandbox', 'Sandbox', { count: 2 }) }
|
|
16
|
+
const merged = mergeSidebarWorkspaces([velero, undefined, agents])!
|
|
17
|
+
expect(merged.Velero).toBe(velero.Velero)
|
|
18
|
+
expect(merged.Agents).toBe(agents.Agents)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('combines tools sharing a category into one row: both tools beneath, destinations one tool after another', () => {
|
|
22
|
+
const merged = mergeSidebarWorkspaces([
|
|
23
|
+
{ Agents: part('Agent Substrate', 'Substrate', { count: 3, countTitle: '3 attention items.' }) },
|
|
24
|
+
{ Agents: part('Agent Sandbox', 'Sandbox', { count: 2, countTitle: '2 attention items.', countScope: 'namespace payments', scopeNote: 'Counts for namespace payments' }) },
|
|
25
|
+
])!.Agents
|
|
26
|
+
expect(merged.tools).toBe('Agent Substrate · Agent Sandbox')
|
|
27
|
+
expect(merged.destinations.map((d) => d.id)).toEqual(['Substrate-overview', 'Sandbox-overview'])
|
|
28
|
+
expect(merged).toMatchObject({ count: 5, countLowerBound: false })
|
|
29
|
+
expect(merged.countTitle).toBe('Attention items — Substrate: 3 · cluster-wide · Sandbox: 2 · namespace payments')
|
|
30
|
+
// Only Sandbox's counts follow the namespace filter, so the note says whose they are.
|
|
31
|
+
expect(merged.scopeNote).toBe('Agent Sandbox: Counts for namespace payments · Agent Substrate: cluster-wide')
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('adds up to a lower bound when either part is one or is unknown, and to unknown when nothing was found', () => {
|
|
35
|
+
const merge = (a: Partial<SidebarCategoryWorkspace>, b: Partial<SidebarCategoryWorkspace>) =>
|
|
36
|
+
mergeSidebarWorkspaces([{ Agents: part('A', 'a', a) }, { Agents: part('B', 'b', b) }])!.Agents
|
|
37
|
+
expect(merge({ count: 3, countLowerBound: true }, { count: 2 })).toMatchObject({ count: 5, countLowerBound: true })
|
|
38
|
+
expect(merge({ count: null, countLowerBound: true }, { count: 2 })).toMatchObject({ count: 2, countLowerBound: true })
|
|
39
|
+
expect(merge({ count: null, countLowerBound: true }, { count: 0 })).toMatchObject({ count: null, countLowerBound: true })
|
|
40
|
+
expect(merge({ count: 0 }, { count: 0 })).toMatchObject({ count: 0, countLowerBound: false })
|
|
41
|
+
expect(merge({}, { count: 2 })).toMatchObject({
|
|
42
|
+
count: 2,
|
|
43
|
+
countLowerBound: true,
|
|
44
|
+
countTitle: 'Attention items — A: unknown · B: 2',
|
|
45
|
+
})
|
|
46
|
+
expect(merge({}, {}).count).toBeUndefined()
|
|
47
|
+
})
|
|
48
|
+
})
|
|
@@ -3,7 +3,77 @@ import type { SidebarCategoryWorkspace } from '@skyhook-io/k8s-ui'
|
|
|
3
3
|
|
|
4
4
|
type Workspaces = Record<string, SidebarCategoryWorkspace>
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
/**
|
|
7
|
+
* The Resources sidebar category the agent runtimes' kinds are listed under
|
|
8
|
+
* (api-resources.ts). Agent Substrate, Agent Sandbox and kagent each
|
|
9
|
+
* contribute a workspace to it, merged into one Integrations row.
|
|
10
|
+
*/
|
|
11
|
+
export const AGENTS_SIDEBAR_CATEGORY = 'Agents'
|
|
12
|
+
|
|
13
|
+
/** Integrations' sidebar workspaces as one map; undefined when none applies. */
|
|
14
|
+
export function useMergedSidebarWorkspaces(
|
|
15
|
+
a: Workspaces | undefined,
|
|
16
|
+
b?: Workspaces | undefined,
|
|
17
|
+
c?: Workspaces | undefined,
|
|
18
|
+
d?: Workspaces | undefined,
|
|
19
|
+
e?: Workspaces | undefined,
|
|
20
|
+
): Workspaces | undefined {
|
|
21
|
+
return useMemo(() => mergeSidebarWorkspaces([a, b, c, d, e]), [a, b, c, d, e])
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Workspaces keyed by category, where several tools may contribute to one
|
|
26
|
+
* category: their destinations are listed one tool after another, and the
|
|
27
|
+
* row's count adds theirs up.
|
|
28
|
+
*/
|
|
29
|
+
export function mergeSidebarWorkspaces(list: (Workspaces | undefined)[]): Workspaces | undefined {
|
|
30
|
+
if (!list.some(Boolean)) return undefined
|
|
31
|
+
const byCategory = new Map<string, SidebarCategoryWorkspace[]>()
|
|
32
|
+
for (const workspaces of list) {
|
|
33
|
+
for (const [name, w] of Object.entries(workspaces ?? {})) byCategory.set(name, [...(byCategory.get(name) ?? []), w])
|
|
34
|
+
}
|
|
35
|
+
return Object.fromEntries([...byCategory].map(([name, parts]) => [name, parts.length === 1 ? parts[0] : combine(parts)]))
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function shortRuntimeName(tools?: string): string | undefined {
|
|
39
|
+
return tools ? tools.replace(/^Agent /, '') : undefined
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function scopeOf(w: SidebarCategoryWorkspace): string | undefined {
|
|
43
|
+
if (w.countScope) return w.countScope
|
|
44
|
+
if (w.tools === 'Agent Substrate') return 'cluster-wide'
|
|
45
|
+
return undefined
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function runtimeCountBreakdown(w: SidebarCategoryWorkspace): string {
|
|
49
|
+
const label = shortRuntimeName(w.tools)
|
|
50
|
+
const val = w.count == null ? 'unknown' : `${w.countLowerBound ? '≥' : ''}${w.count}`
|
|
51
|
+
const scope = scopeOf(w)
|
|
52
|
+
return [label ? `${label}: ${val}` : val, scope].filter(Boolean).join(' · ')
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function combine(parts: SidebarCategoryWorkspace[]): SidebarCategoryWorkspace {
|
|
56
|
+
const named = (w: SidebarCategoryWorkspace, text: string) => (w.tools ? `${w.tools}: ${text}` : text)
|
|
57
|
+
const counted = parts.filter((w) => w.count !== undefined)
|
|
58
|
+
const sum = counted.reduce((n, w) => n + (w.count ?? 0), 0)
|
|
59
|
+
const lowerBound = parts.some((w) => w.count == null || w.countLowerBound)
|
|
60
|
+
const breakdown = parts.map(runtimeCountBreakdown).join(' · ')
|
|
61
|
+
const notes = parts.flatMap((w) => (w.scopeNote ? [named(w, w.scopeNote)] : []))
|
|
62
|
+
if (notes.length > 0) {
|
|
63
|
+
for (const w of parts) {
|
|
64
|
+
if (!w.scopeNote && scopeOf(w) === 'cluster-wide' && w.tools) {
|
|
65
|
+
notes.push(`${w.tools}: cluster-wide`)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
label: parts.find((w) => w.label)?.label,
|
|
71
|
+
icon: parts.find((w) => w.icon)?.icon,
|
|
72
|
+
tools: parts.flatMap((w) => (w.tools ? [w.tools] : [])).join(' · ') || undefined,
|
|
73
|
+
destinations: parts.flatMap((w) => w.destinations),
|
|
74
|
+
count: counted.length === 0 ? undefined : sum === 0 && lowerBound ? null : sum,
|
|
75
|
+
countLowerBound: counted.length === 0 ? undefined : lowerBound,
|
|
76
|
+
countTitle: counted.length ? `Attention items — ${breakdown}` : undefined,
|
|
77
|
+
scopeNote: notes.length ? notes.join(' · ') : undefined,
|
|
78
|
+
}
|
|
9
79
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export const TABLE_WRAP = 'overflow-x-auto';
|
|
2
2
|
export const TABLE_HEAD =
|
|
3
3
|
'border-b border-theme-border bg-theme-base/60 text-[11px] uppercase tracking-wide text-theme-text-tertiary';
|
|
4
|
-
export const
|
|
4
|
+
export const TH_BASE = 'px-3 py-2.5 text-left font-medium';
|
|
5
|
+
export const TH = `${TH_BASE} whitespace-nowrap`;
|
|
5
6
|
export const TD = 'px-3 py-2.5 align-top text-sm text-theme-text-primary';
|
|
6
7
|
export const TBODY = 'table-divide-subtle';
|
|
7
8
|
export const ROW_HOVER = 'transition-colors hover:bg-theme-hover/50';
|
|
@@ -23,6 +23,10 @@ export interface ConnectionState {
|
|
|
23
23
|
// The connection Radar is serving (see connectionBinding.ts). Empty while a
|
|
24
24
|
// switch is between connections; never sent by an in-cluster or older Radar.
|
|
25
25
|
connectionId?: string
|
|
26
|
+
// Set while the serving connection's API server doesn't answer Radar's
|
|
27
|
+
// reachability checks (RFC 3339). The state stays 'connected' and the cache
|
|
28
|
+
// keeps serving its last state. Absent: reachable, or an older Radar.
|
|
29
|
+
apiUnreachableSince?: string
|
|
26
30
|
// Per-kind readiness while the initial informer sync runs ('connecting'
|
|
27
31
|
// with informers started). Drives the progressive app shell — absent once
|
|
28
32
|
// connected or before informers exist.
|
|
@@ -46,7 +50,7 @@ interface ConnectionContextValue {
|
|
|
46
50
|
contextSwitch?: ContextSwitchOperation
|
|
47
51
|
retry: () => void
|
|
48
52
|
isRetrying: boolean
|
|
49
|
-
updateFromSSE: (status: ConnectionState) => void
|
|
53
|
+
updateFromSSE: (status: ConnectionState, opts?: { handover: boolean }) => void
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
class ConnectionRetryError extends Error {
|
|
@@ -301,7 +305,10 @@ export function ConnectionProvider({ children }: { children: ReactNode }) {
|
|
|
301
305
|
data.state === 'connected' && data.contextSwitch?.phase === 'succeeded' && data.contextSwitch.target === data.context) {
|
|
302
306
|
followSwitch(data.contextSwitch.id)
|
|
303
307
|
}
|
|
304
|
-
|
|
308
|
+
// The API server answering again is a reconnect for the data too: what the
|
|
309
|
+
// views fetched during the outage may have failed or gone stale.
|
|
310
|
+
const becameConnected = data.state === 'connected' &&
|
|
311
|
+
(current.state !== 'connected' || (Boolean(current.apiUnreachableSince) && !data.apiUnreachableSince))
|
|
305
312
|
setConnection({
|
|
306
313
|
state: data.state,
|
|
307
314
|
context: data.context,
|
|
@@ -310,6 +317,8 @@ export function ConnectionProvider({ children }: { children: ReactNode }) {
|
|
|
310
317
|
errorType: data.errorType,
|
|
311
318
|
progressMessage: data.progressMessage,
|
|
312
319
|
disconnectedAt: data.disconnectedAt,
|
|
320
|
+
connectionId: data.connectionId,
|
|
321
|
+
apiUnreachableSince: data.apiUnreachableSince,
|
|
313
322
|
syncStatus: data.syncStatus,
|
|
314
323
|
})
|
|
315
324
|
if (becameConnected) {
|
|
@@ -354,7 +363,7 @@ export function ConnectionProvider({ children }: { children: ReactNode }) {
|
|
|
354
363
|
const retryError = error as ConnectionRetryError
|
|
355
364
|
if (retryError.status === 409) {
|
|
356
365
|
if (attempt) setConnection(prev => prev === attempt.pendingConnection ? attempt.previousConnection : prev)
|
|
357
|
-
if (retryError.code !== 'reconnect_superseded') showApiNotice('Cluster retry unavailable', error.message, 'info')
|
|
366
|
+
if (retryError.code !== 'reconnect_superseded' && retryError.code !== 'switch_stopped') showApiNotice('Cluster retry unavailable', error.message, 'info')
|
|
358
367
|
return
|
|
359
368
|
}
|
|
360
369
|
setConnection(prev => {
|
|
@@ -514,13 +523,15 @@ export function ConnectionProvider({ children }: { children: ReactNode }) {
|
|
|
514
523
|
}, [retryMutation])
|
|
515
524
|
|
|
516
525
|
// Handler for SSE connection_state events
|
|
517
|
-
const updateFromSSE = useCallback((status: ConnectionState) => {
|
|
526
|
+
const updateFromSSE = useCallback((status: ConnectionState, opts?: { handover: boolean }) => {
|
|
518
527
|
// Feed the retry-race guards: a live SSE stream means retry failures must
|
|
519
528
|
// not clobber a recovery it already delivered. The generation bump lets
|
|
520
529
|
// in-flight polls detect they raced this frame.
|
|
521
530
|
sseActiveRef.current = true
|
|
522
531
|
sseGenerationRef.current += 1
|
|
523
532
|
observeConnectionStatus(status)
|
|
533
|
+
const previous = connectionRef.current
|
|
534
|
+
const previousState = previous.state
|
|
524
535
|
setConnection(prev => {
|
|
525
536
|
// Don't transition back to 'connecting' from 'connected'. This happens when the
|
|
526
537
|
// pod restarts and the SSE reconnects while the new pod's K8s cache is still
|
|
@@ -539,7 +550,15 @@ export function ConnectionProvider({ children }: { children: ReactNode }) {
|
|
|
539
550
|
return status
|
|
540
551
|
})
|
|
541
552
|
|
|
542
|
-
|
|
553
|
+
// A frame that only says the API server stopped answering is not a
|
|
554
|
+
// reconnect: refetching now would just fail against the dead endpoint.
|
|
555
|
+
const onlyLostReachability = status.state === 'connected' && Boolean(status.apiUnreachableSince) && previousState === 'connected'
|
|
556
|
+
// Neither is a stream replaced for new parameters while connected to the
|
|
557
|
+
// same, reachable connection: the old stream delivered until the new one
|
|
558
|
+
// started, so nothing was missed.
|
|
559
|
+
const handedOver = Boolean(opts?.handover) && status.state === 'connected' && previousState === 'connected'
|
|
560
|
+
&& status.context === previous.context && status.connectionId === previous.connectionId && !previous.apiUnreachableSince
|
|
561
|
+
if (status.state === 'connected' && !onlyLostReachability && !handedOver) {
|
|
543
562
|
refreshCachesOnConnect()
|
|
544
563
|
}
|
|
545
564
|
}, [refreshCachesOnConnect])
|
|
@@ -90,3 +90,17 @@ it('keeps the connection SSE delivered when an older poll resolves after it', as
|
|
|
90
90
|
expect(latest()?.connection.context).toBe('B')
|
|
91
91
|
expect(connectionHeaderValue()).toBe('n-2')
|
|
92
92
|
})
|
|
93
|
+
|
|
94
|
+
// A stream handover counts as one only on the same connection, so a poll that
|
|
95
|
+
// dropped the ID would turn every later handover into a full refetch.
|
|
96
|
+
it('keeps the connection ID a status poll reports', async () => {
|
|
97
|
+
await act(async () => {
|
|
98
|
+
await vi.advanceTimersByTimeAsync(10)
|
|
99
|
+
})
|
|
100
|
+
await act(async () => {
|
|
101
|
+
polls[0](statusA)
|
|
102
|
+
await vi.advanceTimersByTimeAsync(10)
|
|
103
|
+
})
|
|
104
|
+
expect(latest()?.connection.state).toBe('connected')
|
|
105
|
+
expect(latest()?.connection.connectionId).toBe('n-1')
|
|
106
|
+
})
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
4
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
5
|
+
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
|
|
6
|
+
import { ConnectionProvider, useConnection } from './ConnectionContext'
|
|
7
|
+
import { resetConnectionBindingForTest } from '../api/connectionBinding'
|
|
8
|
+
import type { ConnectionState } from './ConnectionContext'
|
|
9
|
+
|
|
10
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
11
|
+
|
|
12
|
+
let root: Root
|
|
13
|
+
let container: HTMLDivElement
|
|
14
|
+
let client: QueryClient
|
|
15
|
+
const seen = vi.fn<(value: ReturnType<typeof useConnection>) => void>()
|
|
16
|
+
const latest = () => seen.mock.lastCall![0]
|
|
17
|
+
|
|
18
|
+
function Probe() {
|
|
19
|
+
seen(useConnection())
|
|
20
|
+
return null
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const connected = { state: 'connected', context: 'A', connectionId: 'n-1' } as ConnectionState
|
|
24
|
+
|
|
25
|
+
beforeEach(async () => {
|
|
26
|
+
vi.useFakeTimers()
|
|
27
|
+
seen.mockClear()
|
|
28
|
+
resetConnectionBindingForTest()
|
|
29
|
+
vi.stubGlobal('fetch', vi.fn(() => new Promise<Response>(() => {})))
|
|
30
|
+
container = document.createElement('div')
|
|
31
|
+
document.body.appendChild(container)
|
|
32
|
+
root = createRoot(container)
|
|
33
|
+
client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
|
|
34
|
+
await act(async () => {
|
|
35
|
+
root.render(
|
|
36
|
+
<QueryClientProvider client={client}>
|
|
37
|
+
<ConnectionProvider>
|
|
38
|
+
<Probe />
|
|
39
|
+
</ConnectionProvider>
|
|
40
|
+
</QueryClientProvider>,
|
|
41
|
+
)
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
afterEach(() => {
|
|
46
|
+
act(() => root.unmount())
|
|
47
|
+
container.remove()
|
|
48
|
+
vi.restoreAllMocks()
|
|
49
|
+
vi.unstubAllGlobals()
|
|
50
|
+
vi.useRealTimers()
|
|
51
|
+
resetConnectionBindingForTest()
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
async function deliver(status: ConnectionState, handover: boolean) {
|
|
55
|
+
await act(async () => {
|
|
56
|
+
latest().updateFromSSE(status, { handover })
|
|
57
|
+
// Past the cache refresh's 1.5 s throttle, so each delivery is judged alone.
|
|
58
|
+
await vi.advanceTimersByTimeAsync(2_000)
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
it('a stream handed over while connected is not a reconnect, so queries are not all refetched', async () => {
|
|
63
|
+
await deliver(connected, false)
|
|
64
|
+
const invalidate = vi.spyOn(client, 'invalidateQueries')
|
|
65
|
+
|
|
66
|
+
await deliver(connected, true)
|
|
67
|
+
expect(invalidate).not.toHaveBeenCalled()
|
|
68
|
+
expect(latest().connection.state).toBe('connected')
|
|
69
|
+
|
|
70
|
+
// Control: the same frame on a reconnected stream does refetch.
|
|
71
|
+
await deliver(connected, false)
|
|
72
|
+
expect(invalidate).toHaveBeenCalled()
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it('a handover that finds the connection recovering still refreshes', async () => {
|
|
76
|
+
await deliver(connected, false)
|
|
77
|
+
// A retry, not the stream, moves a connected tab back to connecting.
|
|
78
|
+
await act(async () => {
|
|
79
|
+
latest().retry()
|
|
80
|
+
await vi.advanceTimersByTimeAsync(10)
|
|
81
|
+
})
|
|
82
|
+
expect(latest().connection.state).toBe('connecting')
|
|
83
|
+
const invalidate = vi.spyOn(client, 'invalidateQueries')
|
|
84
|
+
|
|
85
|
+
await deliver(connected, true)
|
|
86
|
+
expect(invalidate).toHaveBeenCalled()
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
it('a handover that lands on a different connection still refreshes', async () => {
|
|
90
|
+
await deliver(connected, false)
|
|
91
|
+
const invalidate = vi.spyOn(client, 'invalidateQueries')
|
|
92
|
+
await deliver({ ...connected, connectionId: 'n-2' } as ConnectionState, true)
|
|
93
|
+
expect(invalidate).toHaveBeenCalled()
|
|
94
|
+
})
|
|
@@ -21,6 +21,21 @@ export type RenderInvestigationRunActions = (props: {
|
|
|
21
21
|
onRunUpdated: (run: RunSummary) => void;
|
|
22
22
|
}) => ReactNode;
|
|
23
23
|
|
|
24
|
+
/** Content after a run's assessment, evidence, and next steps. To open a
|
|
25
|
+
* linked item, call revealInFindings once when that exact element is mounted.
|
|
26
|
+
* Give the element a tabIndex of -1 so keyboard focus follows the link. */
|
|
27
|
+
export type RenderInvestigationFindingsFooter = (props: {
|
|
28
|
+
run: RunSummary;
|
|
29
|
+
revealInFindings: (element: HTMLElement) => void;
|
|
30
|
+
/** Reveals a unique recorded read in Findings or its original Activity entry.
|
|
31
|
+
* Missing or ambiguous evidence has no link. */
|
|
32
|
+
evidenceLink: (evidenceRef: string) => (() => void) | undefined;
|
|
33
|
+
/** Returns to the current assessment, when the transcript contains one. */
|
|
34
|
+
viewAssessment?: () => void;
|
|
35
|
+
/** Opens Activity and focuses its editable follow-up input, when available. */
|
|
36
|
+
askQuestion?: () => void;
|
|
37
|
+
}) => ReactNode;
|
|
38
|
+
|
|
24
39
|
/** Host action beside a refused start or follow-up, e.g. Radar Cloud's
|
|
25
40
|
* "Upgrade" when an organization has used its investigations. Called only for
|
|
26
41
|
* refusals that carry a code, reason or action; return null to show none. */
|
|
@@ -73,6 +88,7 @@ export type DiagnoseConsentCopy = {
|
|
|
73
88
|
export interface DiagnoseCustomization {
|
|
74
89
|
renderAction: RenderDiagnoseAction | undefined;
|
|
75
90
|
renderRunActions?: RenderInvestigationRunActions;
|
|
91
|
+
renderFindingsFooter?: RenderInvestigationFindingsFooter;
|
|
76
92
|
renderRefusalAction?: RenderInvestigationRefusalAction;
|
|
77
93
|
consentCopy: DiagnoseConsentCopy | undefined;
|
|
78
94
|
// undefined = default (CustomEvent → Radar's own Settings dialog);
|
|
@@ -93,6 +109,7 @@ export function DiagnoseCustomizationProvider({
|
|
|
93
109
|
value,
|
|
94
110
|
consentCopy,
|
|
95
111
|
renderRunActions,
|
|
112
|
+
renderFindingsFooter,
|
|
96
113
|
renderRefusalAction,
|
|
97
114
|
onOpenSettings,
|
|
98
115
|
children,
|
|
@@ -100,6 +117,7 @@ export function DiagnoseCustomizationProvider({
|
|
|
100
117
|
value: RenderDiagnoseAction | undefined;
|
|
101
118
|
consentCopy?: DiagnoseConsentCopy;
|
|
102
119
|
renderRunActions?: RenderInvestigationRunActions;
|
|
120
|
+
renderFindingsFooter?: RenderInvestigationFindingsFooter;
|
|
103
121
|
renderRefusalAction?: RenderInvestigationRefusalAction;
|
|
104
122
|
/** Where "AI settings" affordances lead. Omit for Radar's own Settings
|
|
105
123
|
* dialog; pass `null` to hide them. */
|
|
@@ -107,8 +125,8 @@ export function DiagnoseCustomizationProvider({
|
|
|
107
125
|
children: ReactNode;
|
|
108
126
|
}) {
|
|
109
127
|
const ctx = useMemo(
|
|
110
|
-
() => ({ renderAction: value, consentCopy, onOpenSettings, renderRunActions, renderRefusalAction }),
|
|
111
|
-
[value, consentCopy, onOpenSettings, renderRunActions, renderRefusalAction],
|
|
128
|
+
() => ({ renderAction: value, consentCopy, onOpenSettings, renderRunActions, renderFindingsFooter, renderRefusalAction }),
|
|
129
|
+
[value, consentCopy, onOpenSettings, renderRunActions, renderFindingsFooter, renderRefusalAction],
|
|
112
130
|
);
|
|
113
131
|
return (
|
|
114
132
|
<DiagnoseCustomizationContext.Provider value={ctx}>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act, useContext } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import { afterEach, expect, it, vi } from 'vitest'
|
|
5
|
+
import { RegistryAccessModeContext } from '@skyhook-io/k8s-ui'
|
|
6
|
+
import { RegistryAccessModeProvider } from './RegistryAccessMode'
|
|
7
|
+
|
|
8
|
+
let capabilities: unknown
|
|
9
|
+
let clusterInfo: unknown
|
|
10
|
+
vi.mock('../api/client', () => ({
|
|
11
|
+
useCapabilities: () => ({ data: capabilities }),
|
|
12
|
+
useClusterInfo: () => ({ data: clusterInfo }),
|
|
13
|
+
}))
|
|
14
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
15
|
+
|
|
16
|
+
function Probe() {
|
|
17
|
+
return <span>{useContext(RegistryAccessModeContext) ?? 'none'}</span>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let root: ReturnType<typeof createRoot> | null = null
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
act(() => root?.unmount())
|
|
23
|
+
root = null
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
function read(): string {
|
|
27
|
+
const host = document.createElement('div')
|
|
28
|
+
root = createRoot(host)
|
|
29
|
+
act(() => root!.render(<RegistryAccessModeProvider><Probe /></RegistryAccessModeProvider>))
|
|
30
|
+
return host.textContent ?? ''
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
it('says nothing until capabilities and cluster info have loaded', () => {
|
|
34
|
+
capabilities = undefined
|
|
35
|
+
clusterInfo = { platform: 'eks' }
|
|
36
|
+
expect(read()).toBe('none')
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it('names the EKS/GKE fix for signed-in in-cluster and cloud Radar, and the local one on a loopback local Radar', () => {
|
|
40
|
+
capabilities = { deployment: { mode: 'in-cluster' }, authEnabled: true, localTerminal: false }
|
|
41
|
+
clusterInfo = { platform: 'eks' }
|
|
42
|
+
expect(read()).toBe('eks')
|
|
43
|
+
act(() => root?.unmount())
|
|
44
|
+
capabilities = { deployment: { mode: 'cloud' }, authEnabled: true, localTerminal: false }
|
|
45
|
+
clusterInfo = { platform: 'gke' }
|
|
46
|
+
expect(read()).toBe('gke')
|
|
47
|
+
act(() => root?.unmount())
|
|
48
|
+
capabilities = { deployment: { mode: 'local' }, localTerminal: true }
|
|
49
|
+
clusterInfo = { platform: 'gke' }
|
|
50
|
+
expect(read()).toBe('local')
|
|
51
|
+
})
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useMemo, type ReactNode } from 'react'
|
|
2
|
+
import { RegistryAccessModeContext, registryAccessMode } from '@skyhook-io/k8s-ui'
|
|
3
|
+
import { useCapabilities, useClusterInfo } from '../api/client'
|
|
4
|
+
|
|
5
|
+
/** Tells the code views which private-registry fix applies to this Radar,
|
|
6
|
+
* from the capabilities and cluster info the app already reads. Nothing is
|
|
7
|
+
* said until both have loaded (the capabilities' loading defaults would
|
|
8
|
+
* otherwise look like a local Radar). */
|
|
9
|
+
export function RegistryAccessModeProvider({ children }: { children: ReactNode }) {
|
|
10
|
+
const { data: capabilities } = useCapabilities()
|
|
11
|
+
const { data: clusterInfo } = useClusterInfo()
|
|
12
|
+
const mode = useMemo(
|
|
13
|
+
() =>
|
|
14
|
+
capabilities && clusterInfo
|
|
15
|
+
? registryAccessMode({
|
|
16
|
+
deploymentMode: capabilities.deployment?.mode,
|
|
17
|
+
authEnabled: capabilities.authEnabled,
|
|
18
|
+
localTerminal: capabilities.localTerminal,
|
|
19
|
+
platform: clusterInfo.platform,
|
|
20
|
+
})
|
|
21
|
+
: null,
|
|
22
|
+
[capabilities, clusterInfo],
|
|
23
|
+
)
|
|
24
|
+
return <RegistryAccessModeContext.Provider value={mode}>{children}</RegistryAccessModeContext.Provider>
|
|
25
|
+
}
|