@skyhook-io/radar-app 1.17.1 → 1.18.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 (146) hide show
  1. package/README.md +6 -0
  2. package/package.json +10 -11
  3. package/src/App.tsx +36 -36
  4. package/src/api/client.gitops-destination.test.tsx +55 -0
  5. package/src/api/client.gitopsPoll.test.ts +99 -0
  6. package/src/api/client.helmPreview.test.tsx +48 -0
  7. package/src/api/client.resource-list.test.ts +76 -0
  8. package/src/api/client.resourceAvailability.test.ts +24 -0
  9. package/src/api/client.ts +396 -105
  10. package/src/api/client.workloadRuns.test.ts +53 -0
  11. package/src/api/config.test.ts +23 -1
  12. package/src/api/config.ts +7 -3
  13. package/src/api/diagnose.ts +4 -1
  14. package/src/api/drain-plan.test.ts +70 -40
  15. package/src/api/policy.ts +5 -5
  16. package/src/api/quotas.ts +9 -20
  17. package/src/api/radarFeatures.ts +3 -0
  18. package/src/api/resourceLists.test.ts +84 -0
  19. package/src/api/resourceLists.ts +71 -0
  20. package/src/api/traffic.scope.render.test.tsx +60 -0
  21. package/src/api/traffic.ts +3 -1
  22. package/src/components/cnpg/CNPGSummaryHost.tsx +4 -3
  23. package/src/components/cnpg/CNPGView.tsx +1 -0
  24. package/src/components/compare/CompareResourcePicker.test.tsx +58 -0
  25. package/src/components/compare/CompareViewRoute.tsx +5 -1
  26. package/src/components/compare/useCompareCandidates.ts +1 -1
  27. package/src/components/compare/useCompareLauncher.tsx +4 -2
  28. package/src/components/diagnose/DiagnoseSurface.tsx +3 -3
  29. package/src/components/diagnose/InvestigationChangesEvidence.test.tsx +352 -0
  30. package/src/components/diagnose/InvestigationEvidencePane.test.tsx +101 -0
  31. package/src/components/diagnose/InvestigationView.tsx +2 -1
  32. package/src/components/diagnose/StoryExcerpt.tsx +24 -5
  33. package/src/components/diagnose/investigationEvidence/adapters/changes.test.ts +123 -0
  34. package/src/components/diagnose/investigationEvidence/adapters/changes.ts +192 -3
  35. package/src/components/diagnose/investigationEvidence/adapters/issues.ts +73 -51
  36. package/src/components/diagnose/investigationEvidence/adapters/listCoverage.test.ts +415 -0
  37. package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +64 -2
  38. package/src/components/diagnose/investigationEvidence/adapters/resource.test.ts +37 -0
  39. package/src/components/diagnose/investigationEvidence/adapters/resource.ts +107 -8
  40. package/src/components/diagnose/investigationEvidence/adapters/testdata/get-changes-created.json +323 -0
  41. package/src/components/diagnose/investigationEvidence/bodies/inventory.tsx +66 -16
  42. package/src/components/diagnose/investigationEvidence/bodies/streams.tsx +144 -15
  43. package/src/components/diagnose/investigationEvidence/builder.ts +13 -1
  44. package/src/components/diagnose/investigationEvidence/excerpt.ts +2 -0
  45. package/src/components/diagnose/investigationEvidence/observations.ts +21 -0
  46. package/src/components/diagnose/investigationEvidence/parse.ts +57 -1
  47. package/src/components/diagnose/investigationEvidence/projection.test.ts +131 -1
  48. package/src/components/diagnose/investigationEvidence/types.ts +26 -0
  49. package/src/components/diagnose/investigationEvidencePresentation.test.ts +18 -0
  50. package/src/components/diagnose/investigationState.test.ts +36 -1
  51. package/src/components/diagnose/investigationState.ts +8 -0
  52. package/src/components/diagnose/launch.ts +2 -2
  53. package/src/components/diagnose/toolCallLabel.test.ts +9 -0
  54. package/src/components/diagnose/toolCallLabel.ts +2 -0
  55. package/src/components/dock/BottomDock.tsx +6 -3
  56. package/src/components/dock/WorkloadLogsTab.tsx +3 -0
  57. package/src/components/execution/BatchExecutionView.image-browse.test.tsx +46 -0
  58. package/src/components/execution/BatchExecutionView.render.test.tsx +29 -1
  59. package/src/components/execution/BatchExecutionView.tsx +28 -11
  60. package/src/components/execution/cluster-template-runs.render.test.tsx +42 -0
  61. package/src/components/gitops/GitOpsView.identity.test.tsx +113 -0
  62. package/src/components/gitops/GitOpsView.tsx +69 -40
  63. package/src/components/gitops/useDestinationCluster.ts +2 -1
  64. package/src/components/helm/ArtifactHubSourceSearch.test.tsx +124 -0
  65. package/src/components/helm/ArtifactHubSourceSearch.tsx +240 -0
  66. package/src/components/helm/ChartBrowser.tsx +5 -4
  67. package/src/components/helm/HelmReleaseDrawer.tsx +139 -55
  68. package/src/components/helm/HelmReleaseNotes.test.tsx +42 -0
  69. package/src/components/helm/HelmReleaseNotes.tsx +26 -0
  70. package/src/components/helm/OwnedResources.tsx +2 -2
  71. package/src/components/helm/TrackChartSourceDialog.render.test.tsx +295 -50
  72. package/src/components/helm/TrackChartSourceDialog.test.ts +3 -2
  73. package/src/components/helm/TrackChartSourceDialog.tsx +614 -85
  74. package/src/components/helm/ValuesDiffPreview.tsx +4 -1
  75. package/src/components/home/ClusterHealthCard.tsx +4 -4
  76. package/src/components/home/CostCard.test.tsx +100 -0
  77. package/src/components/home/CostCard.tsx +2 -2
  78. package/src/components/home/HelmSummary.tsx +2 -2
  79. package/src/components/home/HomeView.tsx +15 -6
  80. package/src/components/home/MCPSetupDialog.test.tsx +30 -0
  81. package/src/components/home/MCPSetupDialog.tsx +13 -6
  82. package/src/components/home/ProblemsPanel.test.tsx +1 -0
  83. package/src/components/home/mcpToolCatalog.ts +28 -2
  84. package/src/components/issues/IssuesPane.render.test.tsx +21 -0
  85. package/src/components/issues/IssuesPane.tsx +31 -7
  86. package/src/components/issues/UncheckedSourceHelp.test.tsx +42 -0
  87. package/src/components/issues/UncheckedSourceHelp.tsx +24 -0
  88. package/src/components/issues/uncheckedSources.test.ts +43 -0
  89. package/src/components/issues/uncheckedSources.ts +58 -5
  90. package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +4 -2
  91. package/src/components/resource/PrometheusCharts.overlays.test.ts +45 -0
  92. package/src/components/resource/PrometheusCharts.tsx +2 -2
  93. package/src/components/resources/ImageFilesystemModal.test.tsx +68 -0
  94. package/src/components/resources/ImageFilesystemModal.tsx +11 -4
  95. package/src/components/resources/PodFilesystemModal.tsx +2 -2
  96. package/src/components/resources/ResourcesView.scope.render.test.tsx +58 -0
  97. package/src/components/resources/ResourcesView.tsx +46 -69
  98. package/src/components/resources/renderers/FluxHelmReleaseRenderer.test.tsx +111 -0
  99. package/src/components/resources/renderers/FluxHelmReleaseRenderer.tsx +67 -0
  100. package/src/components/resources/renderers/KyvernoPolicyCoverage.scope.render.test.tsx +64 -0
  101. package/src/components/resources/renderers/KyvernoPolicyCoverage.tsx +6 -7
  102. package/src/components/resources/renderers/PodRenderer.tsx +4 -1
  103. package/src/components/settings/MyPermissionsDialog.tsx +12 -9
  104. package/src/components/settings/SettingsDialog.tsx +21 -15
  105. package/src/components/traffic/TrafficFilterSidebar.test.tsx +77 -0
  106. package/src/components/traffic/TrafficFilterSidebar.tsx +42 -31
  107. package/src/components/traffic/TrafficSourcePill.test.tsx +110 -0
  108. package/src/components/traffic/TrafficSourcePill.tsx +111 -0
  109. package/src/components/traffic/TrafficView.tsx +21 -67
  110. package/src/components/traffic/trafficFilters.test.ts +20 -1
  111. package/src/components/traffic/trafficFilters.ts +13 -0
  112. package/src/components/ui/DiagnosticsOverlay.test.ts +25 -0
  113. package/src/components/ui/DiagnosticsOverlay.tsx +2 -1
  114. package/src/components/ui/Omnibar.note.test.tsx +141 -0
  115. package/src/components/ui/Omnibar.tsx +89 -14
  116. package/src/components/ui/RadarOmnibar.test.tsx +183 -0
  117. package/src/components/ui/RadarOmnibar.tsx +38 -4
  118. package/src/components/ui/Toast.tsx +1 -1
  119. package/src/components/ui/UpdateNotification.manual.test.tsx +177 -0
  120. package/src/components/ui/UpdateNotification.test.tsx +2 -1
  121. package/src/components/ui/UpdateNotification.tsx +29 -5
  122. package/src/components/ui/omnibar-match.test.ts +37 -0
  123. package/src/components/ui/omnibar-match.ts +23 -0
  124. package/src/components/ui/searchCoverage.fixtures.ts +16 -0
  125. package/src/components/ui/searchCoverageNote.test.ts +245 -0
  126. package/src/components/ui/searchCoverageNote.ts +222 -0
  127. package/src/components/whats-new/WhatsNew.test.ts +10 -0
  128. package/src/components/whats-new/WhatsNew.tsx +5 -4
  129. package/src/components/whats-new/WhatsNewDialog.test.tsx +20 -0
  130. package/src/components/whats-new/releaseNotes.ts +57 -5
  131. package/src/components/workload/CronJobSchedulingEvidence.test.tsx +35 -0
  132. package/src/components/workload/CronJobSchedulingEvidence.tsx +37 -0
  133. package/src/components/workload/NodeDrainStatus.test.tsx +253 -0
  134. package/src/components/workload/NodeDrainStatus.tsx +55 -0
  135. package/src/components/workload/WorkloadView.tsx +43 -5
  136. package/src/context/ConnectionContext.test.ts +27 -1
  137. package/src/context/ConnectionContext.tsx +17 -7
  138. package/src/hooks/useResourceCounts.ts +2 -0
  139. package/src/index.css +2 -4
  140. package/src/index.ts +7 -0
  141. package/src/integrations/resourceHosts.test.tsx +1 -0
  142. package/src/integrations/resourceHosts.tsx +2 -0
  143. package/src/utils/artifacthub.test.ts +18 -0
  144. package/src/utils/artifacthub.ts +9 -0
  145. package/src/utils/navigation.ts +14 -0
  146. package/src/utils/wails-clipboard.ts +4 -2
@@ -0,0 +1,53 @@
1
+ import { afterEach, describe, expect, it, vi } from 'vitest'
2
+ import { useQuery } from '@tanstack/react-query'
3
+ import { useWorkloadRuns, type WorkloadRunsResponse } from './client'
4
+
5
+ vi.mock('@tanstack/react-query', async (original) => ({ ...await original<typeof import('@tanstack/react-query')>(), useQuery: vi.fn(() => ({})) }))
6
+
7
+ type RunsOptions = { queryKey: unknown[]; queryFn: () => Promise<unknown>; placeholderData: (previous: WorkloadRunsResponse | undefined, query: { queryKey: unknown[] } | undefined) => unknown }
8
+
9
+ function useRunsQueryOptions(...args: Parameters<typeof useWorkloadRuns>): RunsOptions {
10
+ useWorkloadRuns(...args)
11
+ return vi.mocked(useQuery).mock.calls.at(-1)![0] as unknown as RunsOptions
12
+ }
13
+
14
+ async function requestedPath(options: RunsOptions): Promise<string> {
15
+ const fetchMock = vi.fn(async () => Response.json({ collection: 'runs', runs: [], total: 0, truncated: false }))
16
+ vi.stubGlobal('fetch', fetchMock)
17
+ await options.queryFn()
18
+ return String((fetchMock.mock.calls[0] as unknown[])[0])
19
+ }
20
+
21
+ afterEach(() => vi.unstubAllGlobals())
22
+
23
+ describe('cluster-scoped workload runs follow the view selection', () => {
24
+ it('sends the selection and keys the query on it', async () => {
25
+ const options = useRunsQueryOptions('clusterworkflowtemplates', '', 'build', true, { clusterScoped: true, namespaces: ['team-a', 'team-b'] })
26
+ const params = new URL(await requestedPath(options), 'http://radar.invalid').searchParams
27
+ expect(params.get('clusterScoped')).toBe('true')
28
+ expect(params.get('namespaces')).toBe('team-a,team-b')
29
+
30
+ const other = useRunsQueryOptions('clusterworkflowtemplates', '', 'build', true, { clusterScoped: true, namespaces: ['team-a'] })
31
+ expect(other.queryKey).not.toEqual(options.queryKey)
32
+ })
33
+
34
+ it('sends no filter when the view covers all namespaces', async () => {
35
+ const options = useRunsQueryOptions('clusterworkflowtemplates', '', 'build', true, { clusterScoped: true, namespaces: [] })
36
+ expect(new URL(await requestedPath(options), 'http://radar.invalid').searchParams.has('namespaces')).toBe(false)
37
+ })
38
+
39
+ it('leaves a namespaced workload alone: its path already names the namespace', async () => {
40
+ const options = useRunsQueryOptions('cronjobs', 'team-a', 'nightly', true, { namespaces: ['team-a', 'team-b'] })
41
+ expect(new URL(await requestedPath(options), 'http://radar.invalid').searchParams.has('namespaces')).toBe(false)
42
+ expect(options.queryKey).toEqual(useRunsQueryOptions('cronjobs', 'team-a', 'nightly', true, {}).queryKey)
43
+ })
44
+
45
+ it('keeps a member list as placeholder only within the same selection', () => {
46
+ const members: WorkloadRunsResponse = { collection: 'members', runs: [], total: 0, truncated: false }
47
+ const before = useRunsQueryOptions('clusterworkflowtemplates', '', 'build', true, { clusterScoped: true, namespaces: ['team-a'], selected: 'x' })
48
+ const after = useRunsQueryOptions('clusterworkflowtemplates', '', 'build', true, { clusterScoped: true, namespaces: ['team-a'], selected: 'y' })
49
+ expect(after.placeholderData(members, { queryKey: before.queryKey })).toBe(members)
50
+ const widened = useRunsQueryOptions('clusterworkflowtemplates', '', 'build', true, { clusterScoped: true, namespaces: ['team-a', 'team-b'], selected: 'y' })
51
+ expect(widened.placeholderData(members, { queryKey: before.queryKey })).toBeUndefined()
52
+ })
53
+ })
@@ -1,10 +1,32 @@
1
+ // @vitest-environment jsdom
1
2
  import { describe, expect, it, afterEach } from 'vitest'
2
3
 
3
- import { setBasename, stripBasename, routePath } from './config'
4
+ import { setBasename, stripBasename, routePath, mcpEndpointUrl, apiUrl, getApiBase, setApiBase } from './config'
4
5
 
5
6
  // setBasename mutates module state — restore standalone default after each test.
6
7
  afterEach(() => {
7
8
  setBasename('')
9
+ setApiBase('/api')
10
+ })
11
+
12
+ it('keeps an explicitly captured API base when the host changes', () => {
13
+ setApiBase('/c/original/api')
14
+ const original = getApiBase()
15
+ setApiBase('/c/other/api')
16
+ expect(apiUrl('/nodes/worker/drain', original)).toBe('/c/original/api/nodes/worker/drain')
17
+ expect(apiUrl('/nodes/worker/drain')).toBe('/c/other/api/nodes/worker/drain')
18
+ })
19
+
20
+ describe('MCP client endpoint', () => {
21
+ it('selects the available endpoint for the effective mode', () => {
22
+ expect(mcpEndpointUrl()).toBe(`${window.location.origin}/mcp`)
23
+ expect(mcpEndpointUrl(true)).toBe(`${window.location.origin}/mcp-readonly`)
24
+ })
25
+
26
+ it('preserves the configured base path', () => {
27
+ setBasename('/tools/radar')
28
+ expect(mcpEndpointUrl(true)).toBe(`${window.location.origin}/tools/radar/mcp-readonly`)
29
+ })
8
30
  })
9
31
 
10
32
  describe('stripBasename', () => {
package/src/api/config.ts CHANGED
@@ -64,6 +64,10 @@ export function routePath(path: string): string {
64
64
  return prefix + path;
65
65
  }
66
66
 
67
+ export function mcpEndpointUrl(readOnly = false): string {
68
+ return `${window.location.origin}${routePath(readOnly ? '/mcp-readonly' : '/mcp')}`;
69
+ }
70
+
67
71
  /**
68
72
  * Inverse of `routePath`: strips the configured basename from a window-level
69
73
  * path so it can be handed to React Router's navigate(), which re-applies the
@@ -94,9 +98,9 @@ export function getWsUrl(path: string): string {
94
98
  return `${protocol}//${window.location.host}${base}${path}`;
95
99
  }
96
100
 
97
- /** Convenience: `${apiBase}${path}` for fetch call sites. */
98
- export function apiUrl(path: string): string {
99
- return getApiBase() + path;
101
+ /** An explicit base keeps a queued request on its original API host. */
102
+ export function apiUrl(path: string, base = getApiBase()): string {
103
+ return base + path;
100
104
  }
101
105
 
102
106
  /**
@@ -25,7 +25,7 @@ export interface AgentsResponse {
25
25
  agents: AgentInfo[];
26
26
  enabled: boolean;
27
27
  // eligible: this run mode supports local BYO-agent investigations (no proxy/OIDC
28
- // auth, /mcp mounted) — true even when no agent is installed. Lets the UI tell
28
+ // auth, investigation MCP mounted) - true even when no agent is installed. Lets the UI tell
29
29
  // "install an agent to enable this" (eligible && !enabled) apart from "not
30
30
  // available here" (auth/cloud/--no-mcp). Absent on older servers / embed hosts.
31
31
  eligible?: boolean;
@@ -248,6 +248,9 @@ export interface RunSummary {
248
248
  ownedByMe?: boolean;
249
249
  canManageVisibility?: boolean;
250
250
  canContinue?: boolean;
251
+ /** Why a run with canContinue false can't take a follow-up, in words for
252
+ * the reader, when the host knows. Absent: a generic read-only notice. */
253
+ continueBlockedReason?: string;
251
254
  trigger?: "interactive" | "background";
252
255
  radarUrl?: string;
253
256
  }
@@ -25,52 +25,82 @@ describe("drain plan request", () => {
25
25
  });
26
26
 
27
27
  describe("describeDrainResult", () => {
28
- it("lists evictions, skips with reasons, and individual failures", () => {
29
- const r = describeDrainResult({
30
- evictedPods: ["shop/cache"],
31
- skippedPods: [
32
- { namespace: "shop", name: "agent", outcome: "skip", reason: "managed by a DaemonSet", emptyDir: false, pdbChecked: false },
33
- ],
34
- errors: ["shop/web-1: timed out waiting for PDB to allow eviction"],
35
- });
36
- expect(r.failed).toBe(true);
37
- expect(r.title).toBe("Drain finished with 1 failed eviction(s): 1 evicted, 1 skipped");
38
- expect(r.detail).toContain("shop/agent (managed by a DaemonSet)");
39
- expect(r.detail).toContain("shop/web-1: timed out");
28
+ const pod = (name: string, expectedSkip = false): import("@skyhook-io/k8s-ui").DrainPlanPod => ({
29
+ namespace: "shop", name, outcome: "skip", reason: expectedSkip ? "expected exclusion" : "protected workload",
30
+ emptyDir: false, pdbChecked: false, expectedSkip,
40
31
  });
41
32
 
42
- it("caps long lists so the toast stays readable", () => {
43
- const skippedPods = Array.from({ length: 8 }, (_, i) => ({
44
- namespace: "ns", name: `p${i}`, outcome: "skip" as const, reason: "r", emptyDir: false, pdbChecked: false,
45
- }));
46
- const r = describeDrainResult({ evictedPods: [], skippedPods });
47
- expect(r.detail).toContain("Skipped 8:");
48
- expect(r.detail).toContain("ns/p4 (r); +3 more");
49
- expect(r.detail).not.toContain("ns/p5");
33
+ it("confirms required removals without promising shutdown safety", () => {
34
+ const result = describeDrainResult({ evictedPods: ["shop/web"], waitedForDeletion: true, outcome: "complete", skippedPods: [pod("system", true)] });
35
+ expect(result).toMatchObject({ title: "Drain complete: 1 pod removed", type: "success", outcome: "complete", failed: false });
36
+ expect(result.detail).toContain("All evicted pods have left the node");
37
+ expect(result.detail).toContain("Left in place by design: 1 pod");
38
+ expect(result.detail).not.toMatch(/empty|safe to/i);
50
39
  });
51
40
 
52
- it("reports a clean drain as success and says what success means", () => {
53
- const r = describeDrainResult({ evictedPods: ["a", "b"] });
54
- expect(r.failed).toBe(false);
55
- expect(r.title).toBe("Node drained: 2 evicted, 0 skipped");
56
- expect(r.detail).toContain("those pods may still be terminating");
57
- expect(r.detail).toContain("node remains cordoned");
41
+ it("gives a skipped running workload an incomplete warning, never green success", () => {
42
+ const result = describeDrainResult({ evictedPods: ["shop/web"], waitedForDeletion: true, skippedPods: [pod("bare")] });
43
+ expect(result).toMatchObject({ title: "Drain incomplete: 1 pod left on the node", type: "warning", outcome: "incomplete", failed: true });
44
+ expect(result.detail).toContain("shop/bare (protected workload)");
45
+ expect(result.detail).toContain("Do not take the node down");
58
46
  });
59
47
 
60
- it("never claims evictions were accepted when nothing was evicted", () => {
61
- const allFailed = describeDrainResult({
62
- evictedPods: [],
63
- errors: ["shop/web-1: timed out waiting for PDB to allow eviction"],
64
- });
65
- expect(allFailed.detail).not.toContain("accepted");
66
- expect(allFailed.detail).toContain("node remains cordoned");
48
+ it("does not turn terminal or system exclusions into failure", () => {
49
+ const result = describeDrainResult({ skippedPods: [pod("completed", true), pod("static", true), pod("daemon", true)] });
50
+ expect(result).toMatchObject({ title: "Nothing to evict", type: "success", outcome: "complete", failed: false });
51
+ expect(result.detail).toContain("Left in place by design: 3 pods");
52
+ expect(result.detail).not.toContain("Do not take the node down");
53
+ });
67
54
 
68
- const skipOnly = describeDrainResult({
69
- evictedPods: [],
70
- skippedPods: [
71
- { namespace: "shop", name: "agent", outcome: "skip", reason: "managed by a DaemonSet", emptyDir: false, pdbChecked: false },
72
- ],
73
- });
74
- expect(skipOnly.detail).not.toContain("accepted");
55
+ it("shows observed remaining pods as incomplete", () => {
56
+ const result = describeDrainResult({ evictedPods: ["shop/web"], waitedForDeletion: true, pendingPods: ["shop/web"] });
57
+ expect(result).toMatchObject({ title: "Drain incomplete: 1 pod left on the node", type: "warning", outcome: "incomplete" });
58
+ expect(result.detail).toContain("Still on the node 1: shop/web");
59
+ expect(result.detail).not.toContain("All evicted pods have left");
60
+ });
61
+
62
+ it("preserves the read error without turning unknown into confirmed presence", () => {
63
+ const result = describeDrainResult({ evictedPods: ["shop/web"], waitedForDeletion: true, unconfirmedPods: ["shop/web"], verificationError: "pod listing unavailable", outcome: "unconfirmed" });
64
+ expect(result).toMatchObject({ title: "Could not confirm drain completion", type: "warning", outcome: "unconfirmed", failed: true });
65
+ expect(result.detail).toContain("Deletion unconfirmed 1: shop/web");
66
+ expect(result.detail).toContain("pod listing unavailable");
67
+ expect(result.detail).not.toMatch(/still on the node|All evicted pods have left/);
68
+ });
69
+
70
+ it("reports failed evictions and unknown siblings together", () => {
71
+ const result = describeDrainResult({ errors: ["shop/db: refused"], unconfirmedPods: ["shop/web"], verificationError: "list failed", outcome: "incomplete" });
72
+ expect(result).toMatchObject({ title: "Drain incomplete: 1 failed eviction", type: "error", outcome: "incomplete" });
73
+ expect(result.detail).toContain("Failed evictions 1: shop/db: refused");
74
+ expect(result.detail).toContain("Deletion unconfirmed 1: shop/web");
75
+ expect(result.detail).not.toContain("Still on the node");
76
+ });
77
+
78
+ it("leads an explicit no-wait result with started and informational treatment", () => {
79
+ const result = describeDrainResult({ evictedPods: ["shop/web"], waitedForDeletion: false, outcome: "started" });
80
+ expect(result).toMatchObject({ title: "Evictions started: 1 accepted", type: "info", outcome: "started", failed: false });
81
+ expect(result.detail).toContain("pod deletion has not been confirmed");
82
+ });
83
+
84
+ it("keeps older backend acceptance and unknown skip metadata conservative", () => {
85
+ expect(describeDrainResult({ evictedPods: ["shop/web"] })).toMatchObject({ outcome: "started", type: "info" });
86
+ expect(describeDrainResult({ skippedPods: [{ namespace: "system", name: "old-agent", outcome: "skip", reason: "managed by a DaemonSet", emptyDir: false, pdbChecked: false }] })).toMatchObject({ outcome: "unconfirmed", type: "warning" });
87
+ });
88
+
89
+ it("does not classify legacy skip reasons as known blockers", () => {
90
+ const legacy = { namespace: "system", name: "agent", outcome: "skip" as const, reason: "managed by a DaemonSet", emptyDir: false, pdbChecked: false };
91
+ const result = describeDrainResult({ evictedPods: ["shop/web"], skippedPods: [legacy] });
92
+ expect(result).toMatchObject({ outcome: "started", type: "info" });
93
+ expect(result.detail).toContain("Skipped pods requiring review 1");
94
+ expect(result.detail).not.toContain("requiring attention");
95
+ });
96
+
97
+ it("uses the backend completion classification when present", () => {
98
+ expect(describeDrainResult({ outcome: "complete", skippedPods: [pod("excluded")] })).toMatchObject({ outcome: "complete", type: "success" });
99
+ });
100
+
101
+ it("caps long pod lists", () => {
102
+ const result = describeDrainResult({ skippedPods: Array.from({ length: 8 }, (_, i) => pod(`p${i}`)) });
103
+ expect(result.detail).toContain("shop/p4 (protected workload); +3 more");
104
+ expect(result.detail).not.toContain("shop/p5");
75
105
  });
76
106
  });
package/src/api/policy.ts CHANGED
@@ -87,18 +87,18 @@ export function usePolicyCoverage(
87
87
  enabled = true,
88
88
  limit?: number,
89
89
  /**
90
- * Whatever identifies the caller's current namespace view. The server applies
91
- * that filter from session state, so it changes the response body without
92
- * changing the URL — it has to be in the key or the cache serves the previous
93
- * scope's answer under the new scope's heading.
90
+ * The namespaces the listed subjects are narrowed to (the header's filter);
91
+ * empty lists every namespace. Counts stay cluster-wide either way.
94
92
  */
95
- viewFilter = '',
93
+ viewNamespaces: readonly string[] = [],
96
94
  ) {
95
+ const viewFilter = viewNamespaces.join(',')
97
96
  return useQuery<PolicyCoverageResponse>({
98
97
  queryKey: ['policy', 'coverage', policy, namespace ?? '', limit ?? 0, viewFilter],
99
98
  queryFn: () => {
100
99
  const params = new URLSearchParams()
101
100
  if (namespace) params.set('namespace', namespace)
101
+ if (viewFilter) params.set('namespaces', viewFilter)
102
102
  if (limit) params.set('limit', String(limit))
103
103
  const qs = params.toString()
104
104
  return fetchJSON<PolicyCoverageResponse>(
package/src/api/quotas.ts CHANGED
@@ -1,32 +1,21 @@
1
- import { useQuery } from '@tanstack/react-query'
2
- import { fetchJSON } from './client'
1
+ import { useResources } from './client'
3
2
 
4
3
  // useNamespaceQuotas fetches a namespace's ResourceQuota objects via
5
- // /api/resources/resourcequotas?namespace=<ns> (a bare array). Backs the
4
+ // /api/resources/resourcequotas?namespaces=<ns> (the `{items, coverage}`
5
+ // list envelope; useResources returns the items). Backs the
6
6
  // NamespaceRenderer quota-usage section — quota saturation is otherwise
7
7
  // surfaced nowhere in the UI, yet it's exactly why a namespace stops
8
8
  // admitting new pods.
9
9
  export function useNamespaceQuotas(namespace: string, enabled = true) {
10
- return useQuery<any[]>({
11
- queryKey: ['resourcequotas', namespace],
12
- queryFn: () => fetchJSON<any[]>(`/resources/resourcequotas?namespace=${encodeURIComponent(namespace)}`),
13
- enabled: enabled && !!namespace,
14
- staleTime: 15000,
15
- })
10
+ return useResources<any>('resourcequotas', namespace, undefined, { enabled: enabled && !!namespace })
16
11
  }
17
12
 
18
- // useNamespaceLimitRanges fetches a namespace's LimitRange objects via
19
- // /api/resources/limitranges?namespace=<ns> (a bare array). Backs the
20
- // NamespaceRenderer rules section and the contextual link on Pod/workload
21
- // details — the defaults and constraints applied at admission are otherwise
22
- // only visible by reading the object.
13
+ // useNamespaceLimitRanges fetches a namespace's LimitRange objects the same
14
+ // way. Backs the NamespaceRenderer rules section and the contextual link on
15
+ // Pod/workload details — the defaults and constraints applied at admission
16
+ // are otherwise only visible by reading the object.
23
17
  export function useNamespaceLimitRanges(namespace: string, enabled = true) {
24
- return useQuery<any[]>({
25
- queryKey: ['limitranges', namespace],
26
- queryFn: () => fetchJSON<any[]>(`/resources/limitranges?namespace=${encodeURIComponent(namespace)}`),
27
- enabled: enabled && !!namespace,
28
- staleTime: 15000,
29
- })
18
+ return useResources<any>('limitranges', namespace, undefined, { enabled: enabled && !!namespace })
30
19
  }
31
20
 
32
21
  export function podLimitRangeNames(limitRanges: any[] | undefined): string[] {
@@ -27,6 +27,8 @@ export interface RadarFeatureSpec {
27
27
  }
28
28
 
29
29
  export const RADAR_FEATURES = {
30
+ resourceReadCoverage: { label: 'Resource read coverage', flag: 'resourceReadCoverage', flagShippedWithEndpoint: true },
31
+ searchCoverage: { label: 'Search coverage and object filters', flag: 'searchCoverage', flagShippedWithEndpoint: true },
30
32
  resourceIssues: { label: 'Operational issues', minimumVersion: 'v1.8.0', flag: 'resourceIssues' },
31
33
  resourceIssueCoverage: { label: 'Resource-specific issue views', flag: 'resourceIssueCoverage', flagShippedWithEndpoint: true },
32
34
  podEnvironment: { label: 'Values from ConfigMaps and Secrets', minimumVersion: 'v1.9.0', flag: 'podEnvironment' },
@@ -41,6 +43,7 @@ export const RADAR_FEATURES = {
41
43
  gitopsWriteEvidence: { label: 'GitOps revert warnings', flag: 'gitopsWriteEvidence', flagShippedWithEndpoint: true },
42
44
  serviceEndpointSlices: { label: 'Service EndpointSlice inventories', flag: 'serviceEndpointSlices', flagShippedWithEndpoint: true },
43
45
  trafficRecords: { label: 'Flow records for a graph selection', flag: 'trafficRecords', flagShippedWithEndpoint: true },
46
+ helmSourceIdentity: { label: 'Helm source selection', flag: 'helmSourceIdentity', flagShippedWithEndpoint: true },
44
47
  } as const satisfies Record<string, RadarFeatureSpec>
45
48
 
46
49
  export type RadarFeature = keyof typeof RADAR_FEATURES
@@ -0,0 +1,84 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import type { ResourceReadCoverage } from '@skyhook-io/k8s-ui/types/resource-coverage'
3
+ import { combinedListStatus, createListRefetchInterval, listSyncPending, normalizeResourceList } from './resourceLists'
4
+
5
+ const complete: ResourceReadCoverage = { status: 'complete', gaps: [], scope: { type: 'cluster' }, read: { type: 'cluster' } }
6
+ const partial: ResourceReadCoverage = { ...complete, status: 'partial', gaps: [{ code: 'radar_namespace_not_collected' }] }
7
+ const columns = [{ name: 'State', type: 'string' }]
8
+
9
+ describe('resource-list responses, read by shape', () => {
10
+ it('reads an older Radar array as rows of unknown coverage', () => {
11
+ const rows = [{ metadata: { name: 'api' } }]
12
+ expect(normalizeResourceList(rows)).toEqual({ items: rows, coverage: { status: 'unknown' }, printerTable: null })
13
+ expect(normalizeResourceList([]).coverage).toEqual({ status: 'unknown' })
14
+ })
15
+ it('reads an older Radar table envelope as a printer table of unknown coverage', () => {
16
+ const body = { items: [{ metadata: { uid: 'one' } }], kind: 'widgets', group: 'example.io', columns, cells: { one: ['Ready'] } }
17
+ const result = normalizeResourceList(body)
18
+ expect(result.items).toEqual(body.items)
19
+ expect(result.coverage).toEqual({ status: 'unknown' })
20
+ expect(result.printerTable?.cells).toEqual(body.cells)
21
+ })
22
+ it('reads the coverage envelope without a table, retaining partial metadata with zero rows', () => {
23
+ expect(normalizeResourceList({ items: [], coverage: partial, kind: 'pods', columns: null, cells: null })).toEqual({ items: [], coverage: partial, printerTable: null })
24
+ })
25
+ it('reads the coverage envelope with a table, keeping rows and cells from the same response', () => {
26
+ const body = { items: [{ metadata: { uid: 'one' } }], kind: 'widgets', group: 'example.io', columns, cells: { one: ['Ready'] }, coverage: complete }
27
+ const result = normalizeResourceList(body)
28
+ expect(result.items).toEqual(body.items)
29
+ expect(result.coverage).toEqual(complete)
30
+ expect(result.printerTable?.cells).toEqual(body.cells)
31
+ })
32
+ })
33
+
34
+ describe('listSyncPending', () => {
35
+ it('holds only while a partial answer has namespaces still loading', () => {
36
+ expect(listSyncPending({ ...partial, gaps: [{ code: 'radar_forbidden' }, { code: 'kind_sync_pending' }] })).toBe(true)
37
+ expect(listSyncPending(partial)).toBe(false)
38
+ expect(listSyncPending(complete)).toBe(false)
39
+ expect(listSyncPending({ status: 'unknown' })).toBe(false)
40
+ expect(listSyncPending(undefined)).toBe(false)
41
+ })
42
+ })
43
+
44
+ describe('combinedListStatus', () => {
45
+ it('is partial when any read failed or was partial', () => {
46
+ expect(combinedListStatus([complete], true, false)).toBe('partial')
47
+ expect(combinedListStatus([complete, partial], false, false)).toBe('partial')
48
+ })
49
+ it("is partial when Radar's collection narrowed a read, since the view shows cluster totals", () => {
50
+ const narrowed = { ...complete, narrowedBy: ['namespace_collection'] }
51
+ expect(combinedListStatus([complete, narrowed], false, false)).toBe('partial')
52
+ expect(combinedListStatus([{ ...complete, narrowedBy: ['user_access'] }], false, false)).toBe('complete')
53
+ })
54
+ it('is complete only when every read was', () => {
55
+ expect(combinedListStatus([complete, complete], false, false)).toBe('complete')
56
+ expect(combinedListStatus([complete, { status: 'unknown' }], false, false)).toBe('unknown')
57
+ })
58
+ it('treats discovery finding nothing to read as complete, and no reads otherwise as unknown', () => {
59
+ expect(combinedListStatus([], false, true)).toBe('complete')
60
+ expect(combinedListStatus([], false, false)).toBe('unknown')
61
+ })
62
+ })
63
+
64
+ describe('loading list backoff', () => {
65
+ it('backs off per response, caps, and resets for coverage or query changes', () => {
66
+ const interval = createListRefetchInterval(120000)
67
+ const pending = { ...partial, gaps: [{ code: 'kind_sync_pending' }] }
68
+ const query = { state: { data: { coverage: pending }, dataUpdateCount: 1 } }
69
+ for (const delay of [5000, 10000, 20000, 30000, 30000]) {
70
+ expect(interval(query)).toBe(delay)
71
+ expect(interval(query)).toBe(delay)
72
+ query.state.dataUpdateCount++
73
+ }
74
+ query.state.data.coverage = complete
75
+ expect(interval(query)).toBe(120000)
76
+ query.state.data.coverage = pending
77
+ expect(interval(query)).toBe(5000)
78
+ query.state.dataUpdateCount++
79
+ expect(interval(query)).toBe(10000)
80
+ const other = { state: { ...query.state } }
81
+ expect(interval(other)).toBe(5000)
82
+ expect(interval(query)).toBe(5000)
83
+ })
84
+ })
@@ -0,0 +1,71 @@
1
+ import { sanitizePrinterTable, type PrinterTable } from '@skyhook-io/k8s-ui/components/resources/printer-columns'
2
+ import type { ResourceCoverage, ResourceListResponse } from '@skyhook-io/k8s-ui/types/resource-coverage'
3
+ import { isLowerBound } from '@skyhook-io/k8s-ui/utils/resource-coverage'
4
+
5
+ export interface ResourceListResult<T> {
6
+ items: T[]
7
+ coverage: ResourceCoverage
8
+ printerTable: PrinterTable | null
9
+ }
10
+
11
+ /**
12
+ * Every list body a supported Radar sends: the coverage envelope, or from a
13
+ * Radar that predates coverage a bare array, or for `?table=1` the printer
14
+ * envelope without `coverage`.
15
+ */
16
+ export type ResourceListBody<T> =
17
+ | ResourceListResponse<T>
18
+ | (Omit<ResourceListResponse<T>, 'coverage'> & { coverage?: undefined })
19
+ | T[]
20
+
21
+ /**
22
+ * Reads a list body by its shape rather than by the cluster's advertised
23
+ * features: a host can point one query client at several clusters, so a cached
24
+ * capabilities answer may describe a different Radar than the one that
25
+ * answered. A response without coverage can't establish absence, so it reads
26
+ * as `unknown`.
27
+ */
28
+ export function normalizeResourceList<T>(body: ResourceListBody<T>): ResourceListResult<T> {
29
+ if (Array.isArray(body)) return { items: body, coverage: { status: 'unknown' }, printerTable: null }
30
+ return { items: body.items, coverage: body.coverage ?? { status: 'unknown' }, printerTable: sanitizePrinterTable(body) }
31
+ }
32
+
33
+ /** Back off once per loading response, resetting for a new query or settled coverage. */
34
+ export function createListRefetchInterval(normalInterval?: number | false) {
35
+ type ListQuery = { state: { data?: { coverage: ResourceCoverage }; dataUpdateCount: number } }
36
+ let previousQuery: ListQuery | undefined
37
+ let previousUpdate = -1
38
+ let delay = 0
39
+ return (query: ListQuery): number | false | undefined => {
40
+ if (query !== previousQuery || !listSyncPending(query.state.data?.coverage)) {
41
+ delay = 0
42
+ previousUpdate = -1
43
+ previousQuery = query
44
+ }
45
+ if (!listSyncPending(query.state.data?.coverage)) return normalInterval
46
+ if (query.state.dataUpdateCount !== previousUpdate) {
47
+ delay = delay === 0 ? 5000 : Math.min(delay * 2, 30000)
48
+ previousUpdate = query.state.dataUpdateCount
49
+ }
50
+ return delay
51
+ }
52
+ }
53
+
54
+ export function listSyncPending(coverage: ResourceCoverage | undefined): boolean {
55
+ return coverage?.status === 'partial' && coverage.gaps.some(gap => gap.code === 'kind_sync_pending')
56
+ }
57
+
58
+ /**
59
+ * One status for a view assembled from several list reads. A failed read makes
60
+ * it partial, and so does one Radar's collection narrowed: the view shows
61
+ * totals for the cluster, which a read of only the collected namespaces can't
62
+ * establish. `nothingToRead` says discovery found no kind to read, which is
63
+ * itself a complete answer.
64
+ */
65
+ export function combinedListStatus(coverage: ResourceCoverage[], failed: boolean, nothingToRead: boolean): 'complete' | 'partial' | 'unknown' {
66
+ if (failed || coverage.some(isLowerBound)) return 'partial'
67
+ if (coverage.length === 0 ? nothingToRead : coverage.every(c => c.status === 'complete')) return 'complete'
68
+ return 'unknown'
69
+ }
70
+
71
+ export { isLowerBound as lowerBound } from '@skyhook-io/k8s-ui/utils/resource-coverage'
@@ -0,0 +1,60 @@
1
+ // @vitest-environment jsdom
2
+ import { act } from 'react'
3
+ import { createRoot } from 'react-dom/client'
4
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
5
+ import { afterEach, beforeEach, expect, it, vi } from 'vitest'
6
+ import { useTrafficFlows, useTrafficRecords } from './traffic'
7
+
8
+ vi.mock('../context/RadarUpgradeHost', () => ({ useRadarUpgradeHost: () => ({}) }))
9
+ vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
10
+
11
+ const requested: URL[] = []
12
+ let root: ReturnType<typeof createRoot>
13
+ let client: QueryClient
14
+
15
+ beforeEach(() => {
16
+ requested.length = 0
17
+ vi.stubGlobal('fetch', vi.fn((input: RequestInfo | URL) => {
18
+ requested.push(new URL(String(input), 'http://radar.invalid'))
19
+ return new Promise<Response>(() => {})
20
+ }))
21
+ root = createRoot(document.createElement('div'))
22
+ client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
23
+ })
24
+
25
+ afterEach(async () => {
26
+ await act(async () => root.unmount())
27
+ client.clear()
28
+ vi.unstubAllGlobals()
29
+ vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
30
+ })
31
+
32
+ function Traffic({ namespaces }: { namespaces: string[] }) {
33
+ useTrafficFlows({ namespaces })
34
+ useTrafficRecords({ namespaces, match: { endpoints: [{ namespace: 'team-a', name: 'web' }] } })
35
+ return null
36
+ }
37
+
38
+ async function scopeOf(namespaces: string[]) {
39
+ await act(async () => { root.render(<QueryClientProvider client={client}><Traffic namespaces={namespaces} /></QueryClientProvider>) })
40
+ await act(async () => { await new Promise((resolve) => setTimeout(resolve, 0)) })
41
+ const flows = requested.find((url) => url.pathname.endsWith('/traffic/flows'))
42
+ const records = requested.find((url) => url.pathname.endsWith('/traffic/flows/records'))
43
+ if (!flows || !records) throw new Error(`missing traffic requests: ${requested.map(String).join(', ')}`)
44
+ const scope = (url: URL) => ({ namespace: url.searchParams.get('namespace'), namespaces: url.searchParams.get('namespaces') })
45
+ return { flows: scope(flows), records: scope(records) }
46
+ }
47
+
48
+ it('sends every namespace in view, since the server does not apply the stored pick', async () => {
49
+ const want = { namespace: null, namespaces: 'team-a,team-b' }
50
+ expect(await scopeOf(['team-a', 'team-b'])).toEqual({ flows: want, records: want })
51
+ })
52
+
53
+ it('sends a single namespace as namespace, and none for all namespaces', async () => {
54
+ const one = { namespace: 'team-a', namespaces: null }
55
+ expect(await scopeOf(['team-a'])).toEqual({ flows: one, records: one })
56
+ requested.length = 0
57
+ client.clear()
58
+ const all = { namespace: null, namespaces: null }
59
+ expect(await scopeOf([])).toEqual({ flows: all, records: all })
60
+ })
@@ -99,8 +99,10 @@ export interface TrafficScope {
99
99
 
100
100
  function trafficScopeParams({ namespaces = [], since, excludeNamespaces, excludeHost }: TrafficScope): URLSearchParams {
101
101
  const params = new URLSearchParams()
102
- // With several namespaces in view the server reads them from the saved pick.
102
+ // Every namespace in view is sent: a read naming none covers every
103
+ // namespace the caller can see.
103
104
  if (namespaces.length === 1) params.set('namespace', namespaces[0])
105
+ else if (namespaces.length > 1) params.set('namespaces', namespaces.join(','))
104
106
  if (since) params.set('since', since)
105
107
  if (excludeNamespaces?.length) params.set('excludeNamespaces', excludeNamespaces.join(','))
106
108
  if (excludeHost) params.set('excludeHost', 'true')
@@ -218,7 +218,8 @@ function SubscriptionSummaryHost(props: { resource: any; workspace: CNPGWorkspac
218
218
  }
219
219
 
220
220
  function PublicationSummaryHost(props: { resource: any; workspace: CNPGWorkspaceResponse | null; onNavigate?: NavigateToRef }) {
221
- // Subscribers are the Subscriptions in view; the publisher's own runtime
221
+ // Subscribers are the Subscriptions in every namespace the caller can read,
222
+ // since logical replication crosses namespaces; the publisher's own runtime
222
223
  // answers for every slot.
223
224
  const pubCluster = props.resource?.spec?.cluster?.name
224
225
  const ns = props.resource?.metadata?.namespace ?? ''
@@ -251,7 +252,7 @@ function ObjectSummaryHost({ ctx, Summary }: { ctx: SummaryContext; Summary: Obj
251
252
  // A ClusterImageCatalog is referenced from any namespace, so its users are
252
253
  // read across every namespace the caller can see.
253
254
  const clusterScoped = ctx.resource?.kind === 'ClusterImageCatalog'
254
- const { query } = useCNPGFleet(clusterScoped ? [] : [ctx.namespace])
255
+ const { query } = useCNPGFleet(clusterScoped ? [] : [ctx.namespace], true, false)
255
256
  if (query.isLoading) return <PaneLoader label="Loading summary…" className="h-40" />
256
257
  const workspace = query.data?.installed ? query.data : null
257
258
  const go = ctx.onNavigate ? (ref: ResourceRef) => ctx.onNavigate?.(refToSelectedResource(ref)) : undefined
@@ -259,7 +260,7 @@ function ObjectSummaryHost({ ctx, Summary }: { ctx: SummaryContext; Summary: Obj
259
260
  }
260
261
 
261
262
  function PoolerSummaryHost({ ctx }: { ctx: SummaryContext }) {
262
- const { query } = useCNPGFleet([ctx.namespace])
263
+ const { query } = useCNPGFleet([ctx.namespace], true, false)
263
264
  const { live, queries } = useCNPGPoolerLive(ctx.namespace, ctx.name)
264
265
  if (query.isLoading) return <PaneLoader label="Loading summary…" className="h-40" />
265
266
  const workspace = query.data?.installed ? query.data : null
@@ -112,6 +112,7 @@ export function CNPGView({ namespaces, selectedResource, onOpenResource, onClose
112
112
  onSelectedKindChange={selectKind}
113
113
  apiResources={apiResources}
114
114
  resourceCounts={counts?.counts}
115
+ resourceCoverage={counts?.coverage}
115
116
  resourceForbidden={counts?.forbidden}
116
117
  resourceUnavailable={counts?.unavailable}
117
118
  pinned={pinned}