@skyhook-io/radar-app 1.17.1 → 1.18.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.
Files changed (95) hide show
  1. package/package.json +9 -9
  2. package/src/App.tsx +14 -30
  3. package/src/api/client.gitopsPoll.test.ts +99 -0
  4. package/src/api/client.helmPreview.test.tsx +48 -0
  5. package/src/api/client.resourceAvailability.test.ts +24 -0
  6. package/src/api/client.ts +337 -87
  7. package/src/api/client.workloadRuns.test.ts +53 -0
  8. package/src/api/config.test.ts +23 -1
  9. package/src/api/config.ts +7 -3
  10. package/src/api/diagnose.ts +4 -1
  11. package/src/api/drain-plan.test.ts +70 -40
  12. package/src/api/policy.ts +5 -5
  13. package/src/api/radarFeatures.ts +1 -0
  14. package/src/api/traffic.scope.render.test.tsx +60 -0
  15. package/src/api/traffic.ts +3 -1
  16. package/src/components/cnpg/CNPGSummaryHost.tsx +4 -3
  17. package/src/components/diagnose/DiagnoseSurface.tsx +3 -3
  18. package/src/components/diagnose/InvestigationChangesEvidence.test.tsx +352 -0
  19. package/src/components/diagnose/InvestigationEvidencePane.test.tsx +101 -0
  20. package/src/components/diagnose/InvestigationView.tsx +2 -1
  21. package/src/components/diagnose/investigationEvidence/adapters/changes.test.ts +123 -0
  22. package/src/components/diagnose/investigationEvidence/adapters/changes.ts +192 -3
  23. package/src/components/diagnose/investigationEvidence/adapters/issues.ts +73 -51
  24. package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +64 -2
  25. package/src/components/diagnose/investigationEvidence/adapters/resource.test.ts +37 -0
  26. package/src/components/diagnose/investigationEvidence/adapters/testdata/get-changes-created.json +323 -0
  27. package/src/components/diagnose/investigationEvidence/bodies/streams.tsx +144 -15
  28. package/src/components/diagnose/investigationEvidence/observations.ts +20 -0
  29. package/src/components/diagnose/investigationEvidence/parse.ts +57 -1
  30. package/src/components/diagnose/investigationEvidence/projection.test.ts +107 -0
  31. package/src/components/diagnose/investigationEvidence/types.ts +11 -0
  32. package/src/components/diagnose/investigationEvidencePresentation.test.ts +18 -0
  33. package/src/components/diagnose/investigationState.test.ts +36 -1
  34. package/src/components/diagnose/investigationState.ts +8 -0
  35. package/src/components/diagnose/launch.ts +2 -2
  36. package/src/components/dock/BottomDock.tsx +6 -3
  37. package/src/components/dock/WorkloadLogsTab.tsx +3 -0
  38. package/src/components/execution/BatchExecutionView.render.test.tsx +29 -1
  39. package/src/components/execution/BatchExecutionView.tsx +23 -8
  40. package/src/components/execution/cluster-template-runs.render.test.tsx +42 -0
  41. package/src/components/gitops/GitOpsView.tsx +7 -0
  42. package/src/components/helm/HelmReleaseDrawer.tsx +139 -55
  43. package/src/components/helm/HelmReleaseNotes.test.tsx +42 -0
  44. package/src/components/helm/HelmReleaseNotes.tsx +26 -0
  45. package/src/components/helm/OwnedResources.tsx +2 -2
  46. package/src/components/helm/TrackChartSourceDialog.render.test.tsx +76 -4
  47. package/src/components/helm/TrackChartSourceDialog.test.ts +3 -2
  48. package/src/components/helm/TrackChartSourceDialog.tsx +41 -15
  49. package/src/components/helm/ValuesDiffPreview.tsx +4 -1
  50. package/src/components/home/ClusterHealthCard.tsx +4 -4
  51. package/src/components/home/CostCard.test.tsx +100 -0
  52. package/src/components/home/CostCard.tsx +2 -2
  53. package/src/components/home/HelmSummary.tsx +2 -2
  54. package/src/components/home/HomeView.tsx +15 -6
  55. package/src/components/home/MCPSetupDialog.test.tsx +30 -0
  56. package/src/components/home/MCPSetupDialog.tsx +13 -6
  57. package/src/components/home/ProblemsPanel.test.tsx +1 -0
  58. package/src/components/home/mcpToolCatalog.ts +18 -2
  59. package/src/components/issues/IssuesPane.render.test.tsx +21 -0
  60. package/src/components/issues/IssuesPane.tsx +31 -7
  61. package/src/components/issues/UncheckedSourceHelp.test.tsx +42 -0
  62. package/src/components/issues/UncheckedSourceHelp.tsx +24 -0
  63. package/src/components/issues/uncheckedSources.test.ts +43 -0
  64. package/src/components/issues/uncheckedSources.ts +58 -5
  65. package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +4 -2
  66. package/src/components/resources/ImageFilesystemModal.test.tsx +68 -0
  67. package/src/components/resources/ImageFilesystemModal.tsx +11 -4
  68. package/src/components/resources/PodFilesystemModal.tsx +2 -2
  69. package/src/components/resources/ResourcesView.scope.render.test.tsx +58 -0
  70. package/src/components/resources/ResourcesView.tsx +18 -3
  71. package/src/components/resources/renderers/FluxHelmReleaseRenderer.test.tsx +111 -0
  72. package/src/components/resources/renderers/FluxHelmReleaseRenderer.tsx +67 -0
  73. package/src/components/resources/renderers/KyvernoPolicyCoverage.scope.render.test.tsx +64 -0
  74. package/src/components/resources/renderers/KyvernoPolicyCoverage.tsx +6 -7
  75. package/src/components/settings/SettingsDialog.tsx +21 -15
  76. package/src/components/traffic/TrafficFilterSidebar.test.tsx +77 -0
  77. package/src/components/traffic/TrafficFilterSidebar.tsx +42 -31
  78. package/src/components/traffic/TrafficView.tsx +12 -12
  79. package/src/components/traffic/trafficFilters.test.ts +20 -1
  80. package/src/components/traffic/trafficFilters.ts +13 -0
  81. package/src/components/ui/Omnibar.tsx +13 -2
  82. package/src/components/ui/Toast.tsx +1 -1
  83. package/src/components/ui/omnibar-match.test.ts +30 -0
  84. package/src/components/ui/omnibar-match.ts +18 -0
  85. package/src/components/workload/CronJobSchedulingEvidence.test.tsx +35 -0
  86. package/src/components/workload/CronJobSchedulingEvidence.tsx +37 -0
  87. package/src/components/workload/NodeDrainStatus.test.tsx +253 -0
  88. package/src/components/workload/NodeDrainStatus.tsx +55 -0
  89. package/src/components/workload/WorkloadView.tsx +37 -5
  90. package/src/context/ConnectionContext.test.ts +27 -1
  91. package/src/context/ConnectionContext.tsx +17 -7
  92. package/src/integrations/resourceHosts.test.tsx +1 -0
  93. package/src/integrations/resourceHosts.tsx +2 -0
  94. package/src/utils/navigation.ts +14 -0
  95. 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>(
@@ -41,6 +41,7 @@ export const RADAR_FEATURES = {
41
41
  gitopsWriteEvidence: { label: 'GitOps revert warnings', flag: 'gitopsWriteEvidence', flagShippedWithEndpoint: true },
42
42
  serviceEndpointSlices: { label: 'Service EndpointSlice inventories', flag: 'serviceEndpointSlices', flagShippedWithEndpoint: true },
43
43
  trafficRecords: { label: 'Flow records for a graph selection', flag: 'trafficRecords', flagShippedWithEndpoint: true },
44
+ helmSourceIdentity: { label: 'Helm source selection', flag: 'helmSourceIdentity', flagShippedWithEndpoint: true },
44
45
  } as const satisfies Record<string, RadarFeatureSpec>
45
46
 
46
47
  export type RadarFeature = keyof typeof RADAR_FEATURES
@@ -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
@@ -52,7 +52,7 @@ import { AgentSetupNotice } from "./AgentSetupNotice";
52
52
  import { ConsentCard } from "./parts";
53
53
  import { buildLaunchCommand, launchAgentLabel, openInTerminal } from "./launch";
54
54
  import { type RunSummary, type ExecutionProfile } from "../../api/diagnose";
55
- import { routePath } from "../../api/config";
55
+ import { mcpEndpointUrl } from "../../api/config";
56
56
  import { useCapabilitiesContext } from "../../contexts/CapabilitiesContext";
57
57
  import { useContexts } from "../../api/client";
58
58
  import { formatInvestigationTarget } from "./target";
@@ -93,11 +93,11 @@ function InvestigationMenu({ run }: { run: RunSummary }) {
93
93
  const [open, setOpen] = useState(false);
94
94
  const [copied, setCopied] = useState(false);
95
95
  const menuRef = useRef<HTMLDivElement>(null);
96
- const { localTerminal } = useCapabilitiesContext();
96
+ const { localTerminal, mcpReadOnly } = useCapabilitiesContext();
97
97
  const label = launchAgentLabel(run);
98
98
  const command = buildLaunchCommand(
99
99
  run,
100
- `${window.location.origin}${routePath("/mcp")}`,
100
+ mcpEndpointUrl(mcpReadOnly),
101
101
  );
102
102
 
103
103
  // The diagnose root is a CSS container, so a position:fixed click-away layer