@skyhook-io/radar-app 1.19.0 → 1.20.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 (198) hide show
  1. package/README.md +1 -1
  2. package/package.json +5 -5
  3. package/src/App.tsx +37 -9
  4. package/src/api/application-evidence.ts +63 -0
  5. package/src/api/argoSync.test.ts +22 -0
  6. package/src/api/client.audit-gating.test.tsx +48 -0
  7. package/src/api/client.kueuePosition.test.ts +32 -0
  8. package/src/api/client.kueueQueueWorkloads.test.tsx +71 -0
  9. package/src/api/client.resource-identity.test.ts +3 -0
  10. package/src/api/client.resourceIssues.test.tsx +239 -0
  11. package/src/api/client.resourcePath.test.ts +3 -0
  12. package/src/api/client.ts +353 -64
  13. package/src/api/config.ts +21 -0
  14. package/src/api/diagnose.ts +4 -0
  15. package/src/api/helmInventory.test.tsx +108 -0
  16. package/src/api/radarFeatures.render.test.tsx +33 -1
  17. package/src/api/radarFeatures.test.ts +47 -0
  18. package/src/api/radarFeatures.ts +42 -1
  19. package/src/api/rbac.settled.test.tsx +42 -0
  20. package/src/api/rbac.test.ts +18 -0
  21. package/src/api/rbac.ts +37 -7
  22. package/src/api/traffic.ts +9 -4
  23. package/src/api/usage-data.fixtures.ts +3 -1
  24. package/src/api/usage-data.test.tsx +134 -0
  25. package/src/api/usage-data.ts +35 -7
  26. package/src/api/workloadPodsPolling.test.ts +26 -0
  27. package/src/components/CloudConnectFlow.test.tsx +86 -0
  28. package/src/components/CloudConnectFlow.tsx +65 -27
  29. package/src/components/CloudFunnelButton.test.tsx +140 -5
  30. package/src/components/CloudFunnelButton.tsx +50 -9
  31. package/src/components/ConnectionErrorView.test.tsx +34 -0
  32. package/src/components/ConnectionErrorView.tsx +35 -11
  33. package/src/components/ContextSwitcher.tsx +5 -2
  34. package/src/components/SwitchAwareConnectionError.test.tsx +43 -0
  35. package/src/components/SwitchAwareConnectionError.tsx +85 -0
  36. package/src/components/application-evidence/ApplicationEvidenceAction.flow.test.tsx +234 -0
  37. package/src/components/application-evidence/ApplicationEvidenceAction.test.tsx +144 -0
  38. package/src/components/application-evidence/ApplicationEvidenceAction.tsx +218 -0
  39. package/src/components/capacity/CapacityDemand.tsx +3 -2
  40. package/src/components/capacity/demandSummary.test.ts +38 -0
  41. package/src/components/capacity/shared.tsx +12 -1
  42. package/src/components/cost/ApplicationCostTab.tsx +4 -0
  43. package/src/components/cost/CostTrendChart.tsx +2 -0
  44. package/src/components/cost/WorkloadCostTab.tsx +4 -0
  45. package/src/components/cost/source.test.ts +5 -0
  46. package/src/components/cost/source.ts +11 -0
  47. package/src/components/curl/ServiceCurlAvailability.test.tsx +32 -0
  48. package/src/components/curl/ServiceCurlButton.tsx +2 -2
  49. package/src/components/diagnose/AIMarkdown.tsx +3 -0
  50. package/src/components/diagnose/AgentSetupNotice.test.tsx +17 -0
  51. package/src/components/diagnose/AgentSetupNotice.tsx +21 -3
  52. package/src/components/diagnose/ContinueInAgentButton.mounted.test.tsx +182 -0
  53. package/src/components/diagnose/ContinueInAgentButton.test.tsx +128 -0
  54. package/src/components/diagnose/ContinueInAgentButton.tsx +303 -0
  55. package/src/components/diagnose/DiagnoseContext.question.test.tsx +1 -1
  56. package/src/components/diagnose/DiagnoseContext.tsx +68 -2
  57. package/src/components/diagnose/DiagnoseSurface.tsx +58 -113
  58. package/src/components/diagnose/ExampleInvestigationLink.tsx +20 -0
  59. package/src/components/diagnose/Home.test.tsx +26 -0
  60. package/src/components/diagnose/Home.tsx +20 -1
  61. package/src/components/diagnose/InvestigationEvidenceSections.tsx +45 -22
  62. package/src/components/diagnose/InvestigationView.tsx +94 -26
  63. package/src/components/diagnose/LocalDiagnoseAction.history.test.tsx +450 -0
  64. package/src/components/diagnose/LocalDiagnoseAction.tsx +354 -35
  65. package/src/components/diagnose/NextStepJump.test.tsx +92 -0
  66. package/src/components/diagnose/NextStepJump.tsx +75 -0
  67. package/src/components/diagnose/QuestionComposer.tsx +8 -0
  68. package/src/components/diagnose/exampleInvestigation.events.json +191 -0
  69. package/src/components/diagnose/exampleInvestigation.loadFailure.test.tsx +94 -0
  70. package/src/components/diagnose/exampleInvestigation.test.tsx +248 -0
  71. package/src/components/diagnose/exampleInvestigation.ts +121 -0
  72. package/src/components/diagnose/investigationCase.test.tsx +50 -1
  73. package/src/components/diagnose/investigationEvidence/adapters/applicationFindings.test.ts +739 -0
  74. package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +72 -0
  75. package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +50 -2
  76. package/src/components/diagnose/investigationEvidence/adapters/helm.ts +51 -16
  77. package/src/components/diagnose/investigationEvidence/adapters/issues.ts +9 -0
  78. package/src/components/diagnose/investigationEvidence/adapters/listings.ts +34 -4
  79. package/src/components/diagnose/investigationEvidence/adapters/resource.ts +3 -2
  80. package/src/components/diagnose/investigationEvidence/builder.ts +30 -0
  81. package/src/components/diagnose/investigationEvidence/observations.ts +121 -2
  82. package/src/components/diagnose/investigationEvidence/projection.test.ts +85 -3
  83. package/src/components/diagnose/investigationEvidence/types.ts +5 -0
  84. package/src/components/diagnose/investigationState.ts +28 -0
  85. package/src/components/diagnose/lastInvestigation.test.ts +95 -0
  86. package/src/components/diagnose/lastInvestigation.ts +58 -0
  87. package/src/components/diagnose/launch.test.ts +125 -1
  88. package/src/components/diagnose/launch.ts +57 -10
  89. package/src/components/diagnose/toolCallLabel.test.ts +10 -4
  90. package/src/components/execution/BatchExecutionView.tsx +24 -11
  91. package/src/components/execution/JobSetAdmission.test.tsx +42 -0
  92. package/src/components/execution/JobSetAdmission.tsx +18 -3
  93. package/src/components/execution/JobSetMemberComparison.tsx +2 -1
  94. package/src/components/execution/runState.test.ts +14 -0
  95. package/src/components/execution/runState.ts +8 -0
  96. package/src/components/gitops/GitOpsView.rollbackGate.test.tsx +202 -0
  97. package/src/components/gitops/GitOpsView.syncRequest.test.tsx +369 -0
  98. package/src/components/gitops/GitOpsView.tsx +86 -17
  99. package/src/components/gitops/RemoteDestinationCloudHint.tsx +2 -3
  100. package/src/components/gitops/destination-toast.test.ts +1 -1
  101. package/src/components/gitops/destination-toast.ts +2 -2
  102. package/src/components/helm/HelmDrawerFrame.tsx +101 -0
  103. package/src/components/helm/HelmDrawerRouting.test.tsx +86 -0
  104. package/src/components/helm/HelmReleaseDrawer.tsx +23 -86
  105. package/src/components/helm/HelmView.tsx +213 -71
  106. package/src/components/helm/ObservedHelmNotice.tsx +146 -0
  107. package/src/components/helm/ObservedHelmRelease.test.tsx +261 -0
  108. package/src/components/helm/ObservedHelmReleaseDrawer.test.tsx +80 -0
  109. package/src/components/helm/ObservedHelmReleaseDrawer.tsx +228 -0
  110. package/src/components/helm/OwnedResources.tsx +4 -2
  111. package/src/components/home/ClusterHealthCard.restricted.test.tsx +76 -0
  112. package/src/components/home/ClusterHealthCard.tsx +28 -5
  113. package/src/components/home/HelmSummary.tsx +23 -4
  114. package/src/components/home/HelmSummary.unread.test.ts +16 -0
  115. package/src/components/home/HomeAgentBlock.test.tsx +31 -3
  116. package/src/components/home/HomeAgentBlock.tsx +20 -4
  117. package/src/components/home/HomeDiagramCard.tsx +47 -0
  118. package/src/components/home/HomeView.tsx +81 -41
  119. package/src/components/home/MCPSetupDialog.test.tsx +126 -10
  120. package/src/components/home/MCPSetupDialog.tsx +33 -5
  121. package/src/components/home/ProblemsPanel.investigate.test.tsx +171 -0
  122. package/src/components/home/ProblemsPanel.test.tsx +3 -1
  123. package/src/components/home/TopologyPreview.test.tsx +73 -0
  124. package/src/components/home/TopologyPreview.tsx +120 -233
  125. package/src/components/home/TrafficSummary.test.tsx +63 -0
  126. package/src/components/home/TrafficSummary.tsx +135 -138
  127. package/src/components/home/mcpToolCatalog.ts +67 -14
  128. package/src/components/issues/IssuesPane.test.ts +11 -0
  129. package/src/components/issues/IssuesPane.tsx +15 -5
  130. package/src/components/issues/uncheckedSources.test.ts +22 -1
  131. package/src/components/issues/uncheckedSources.ts +21 -0
  132. package/src/components/kueue/KueuePendingPosition.tsx +35 -0
  133. package/src/components/kueue/useRelatedObjects.test.tsx +219 -0
  134. package/src/components/kueue/useRelatedReads.test.ts +56 -0
  135. package/src/components/kueue/useRelatedReads.ts +205 -0
  136. package/src/components/logs/MultiPodLogsTab.test.tsx +93 -0
  137. package/src/components/logs/MultiPodLogsTab.tsx +120 -0
  138. package/src/components/logs/PodLogsUnavailable.test.tsx +18 -0
  139. package/src/components/logs/PodLogsUnavailable.tsx +21 -0
  140. package/src/components/logs/RayClusterLogsTab.reselect.test.tsx +67 -0
  141. package/src/components/logs/RayClusterLogsTab.test.tsx +167 -0
  142. package/src/components/logs/RayClusterLogsTab.tsx +109 -0
  143. package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +3 -2
  144. package/src/components/logs/rayClusterPods.ts +32 -0
  145. package/src/components/outageSince.test.ts +21 -0
  146. package/src/components/outageSince.ts +10 -0
  147. package/src/components/resource/PrometheusCharts.overlays.test.ts +12 -0
  148. package/src/components/resource/PrometheusCharts.tsx +3 -40
  149. package/src/components/resources/crd/CRDSchemaTab.test.tsx +28 -0
  150. package/src/components/resources/crd/CRDSchemaTab.tsx +13 -0
  151. package/src/components/resources/crd/host.tsx +14 -0
  152. package/src/components/resources/renderers/CustomResourceDefinitionRenderer.test.tsx +27 -0
  153. package/src/components/resources/renderers/CustomResourceDefinitionRenderer.tsx +12 -0
  154. package/src/components/resources/renderers/JobAdmissionRenderers.test.tsx +4 -1
  155. package/src/components/resources/renderers/JobAdmissionRenderers.tsx +4 -3
  156. package/src/components/resources/renderers/KueueHostRenderers.test.tsx +117 -0
  157. package/src/components/resources/renderers/KueueQueueRenderers.test.tsx +97 -0
  158. package/src/components/resources/renderers/KueueQueueRenderers.tsx +139 -0
  159. package/src/components/resources/renderers/KueueWorkloadRenderer.test.tsx +7 -1
  160. package/src/components/resources/renderers/KueueWorkloadRenderer.tsx +47 -7
  161. package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.test.tsx +67 -0
  162. package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.tsx +31 -0
  163. package/src/components/resources/renderers/RayClusterRenderer.test.tsx +81 -3
  164. package/src/components/resources/renderers/RayClusterRenderer.tsx +19 -4
  165. package/src/components/resources/renderers/ServiceRenderer.test.tsx +15 -2
  166. package/src/components/resources/renderers/ServiceRenderer.tsx +1 -1
  167. package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.test.tsx +160 -0
  168. package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.tsx +128 -0
  169. package/src/components/traffic/TrafficView.tsx +3 -3
  170. package/src/components/ui/command-items-crd.test.tsx +23 -0
  171. package/src/components/ui/command-items.ts +2 -1
  172. package/src/components/useContextSwitchFlow.test.tsx +61 -0
  173. package/src/components/useContextSwitchFlow.tsx +21 -4
  174. package/src/components/whats-new/WhatsNew.test.ts +10 -3
  175. package/src/components/whats-new/WhatsNew.tsx +5 -1
  176. package/src/components/whats-new/WhatsNewDialog.test.tsx +17 -3
  177. package/src/components/whats-new/releaseNotes.ts +77 -4
  178. package/src/components/workload/RelatedFindingsSection.test.tsx +126 -0
  179. package/src/components/workload/RelatedFindingsSection.tsx +80 -0
  180. package/src/components/workload/WorkloadView.test.ts +10 -1
  181. package/src/components/workload/WorkloadView.tsx +85 -98
  182. package/src/components/workload/issueResourceOpener.test.ts +20 -0
  183. package/src/components/workload/issueResourceOpener.ts +17 -0
  184. package/src/context/ConnectionContext.tsx +133 -60
  185. package/src/context/ConnectionProvider.retry.test.tsx +176 -0
  186. package/src/context/ContextSwitchContext.tsx +14 -1
  187. package/src/context/DiagnoseCustomization.tsx +3 -0
  188. package/src/context/clusterConnected.ts +10 -0
  189. package/src/contexts/CapabilitiesContext.tsx +8 -4
  190. package/src/hooks/useElementSize.ts +30 -0
  191. package/src/hooks/useResolvedGitOpsOwner.test.ts +22 -0
  192. package/src/hooks/useResolvedGitOpsOwner.ts +6 -3
  193. package/src/integrations/resourceHost.test.tsx +1 -0
  194. package/src/integrations/resourceHost.ts +5 -1
  195. package/src/integrations/resourceHosts.test.tsx +21 -4
  196. package/src/integrations/resourceHosts.tsx +17 -0
  197. package/src/main.tsx +5 -0
  198. package/src/utils/related-findings.ts +46 -0
package/src/api/config.ts CHANGED
@@ -133,3 +133,24 @@ export function setCredentialsMode(mode: RequestCredentials): void {
133
133
  export function getCredentialsMode(): RequestCredentials {
134
134
  return credentialsMode;
135
135
  }
136
+
137
+ let markAutomaticRequests = false;
138
+
139
+ /**
140
+ * Internal: Radar's own entry point turns the automatic-request mark on at
141
+ * startup, and the usage status then keeps it on only while usage data is
142
+ * recorded. Off, requests carry nothing extra, which also keeps an embedding
143
+ * host free of a header its proxy might refuse.
144
+ */
145
+ export function setAutomaticRequestMarking(on: boolean): void {
146
+ markAutomaticRequests = on;
147
+ }
148
+
149
+ /**
150
+ * Headers for a request the UI makes on its own (a background probe, a
151
+ * reconnect attempt) rather than for something the user did, so the opt-in
152
+ * usage report does not count it as an action.
153
+ */
154
+ export function automaticRequestHeaders(): Record<string, string> {
155
+ return markAutomaticRequests ? { 'X-Radar-Request-Origin': 'auto' } : {};
156
+ }
@@ -255,6 +255,10 @@ export interface RunSummary {
255
255
  status: "running" | "stopping" | "done" | "error" | "stopped" | "stale";
256
256
  sessionId?: string;
257
257
  preview?: string;
258
+ /** When the turn behind preview finished. Set only when preview is an
259
+ * assessment Findings shows; absent before any, or when the server
260
+ * doesn't record it. */
261
+ assessedAt?: string;
258
262
  createdAt: string;
259
263
  updatedAt: string;
260
264
  visibility?: "private" | "organization";
@@ -0,0 +1,108 @@
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, describe, expect, it, vi } from 'vitest'
6
+ import { ApiError, helmInventoryRefetchInterval, observedHelmReleaseRefetchInterval, useHelmInventory } from './client'
7
+ import type { HelmInventory, ObservedHelmReleaseDetail } from '../types'
8
+
9
+ ;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true
10
+
11
+ vi.mock('../context/ConnectionContext', () => ({ useClusterConnected: () => true, useConnection: () => ({ connection: { state: 'connected' } }) }))
12
+
13
+ type Seen = { data?: HelmInventory; error: unknown }
14
+
15
+ const json = (status: number, body: unknown) => new Response(JSON.stringify(body), { status, headers: { 'Content-Type': 'application/json' } })
16
+
17
+ let root: Root | undefined
18
+
19
+ afterEach(() => {
20
+ act(() => root?.unmount())
21
+ root = undefined
22
+ vi.unstubAllGlobals()
23
+ })
24
+
25
+ async function readInventory(features: Record<string, boolean>, routes: Record<string, () => Response>) {
26
+ const paths: string[] = []
27
+ vi.stubGlobal('fetch', vi.fn(async (input: RequestInfo | URL) => {
28
+ const path = new URL(String(input), 'http://radar.test').pathname
29
+ paths.push(path)
30
+ if (path.endsWith('/capabilities')) return json(200, { features })
31
+ const route = Object.keys(routes).find((key) => path.endsWith(key))
32
+ return route ? routes[route]() : json(200, {})
33
+ }))
34
+ const seen: Seen = { error: null }
35
+ function Probe() {
36
+ const { data, error } = useHelmInventory([])
37
+ seen.data = data
38
+ seen.error = error
39
+ return null
40
+ }
41
+ const client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
42
+ root = createRoot(document.createElement('div'))
43
+ await act(async () => {
44
+ root!.render(<QueryClientProvider client={client}><Probe /></QueryClientProvider>)
45
+ })
46
+ await vi.waitFor(() => expect(seen.data !== undefined || seen.error !== null).toBe(true))
47
+ return { seen, paths }
48
+ }
49
+
50
+ describe('useHelmInventory', () => {
51
+ it('reads the inventory from a Radar that advertises it', async () => {
52
+ const inventory: HelmInventory = { releases: [], observed: [{ name: 'api', namespace: 'apps', resourceCount: 1 }], storageDenied: { extent: 'all' } }
53
+ const { seen, paths } = await readInventory({ helmInventory: true }, { '/helm/inventory': () => json(200, inventory) })
54
+ expect(seen.data).toEqual(inventory)
55
+ expect(paths.some((path) => path.endsWith('/helm/releases'))).toBe(false)
56
+ })
57
+
58
+ it('reads the release list from an older Radar, which is the whole answer', async () => {
59
+ const release = { name: 'api', namespace: 'apps', chart: 'c', chartVersion: '1', appVersion: '1', status: 'deployed', revision: 1, updated: '2026-01-01T00:00:00Z' }
60
+ const { seen, paths } = await readInventory({}, { '/helm/releases': () => json(200, [release]) })
61
+ expect(seen.data).toEqual({ releases: [release], observed: [] })
62
+ expect(paths.some((path) => path.includes('/helm/inventory'))).toBe(false)
63
+ })
64
+
65
+ it('keeps an older Radar’s denial an error', async () => {
66
+ const { seen } = await readInventory({}, { '/helm/releases': () => json(403, { error: 'insufficient permissions to list Helm releases' }) })
67
+ expect(seen.data).toBeUndefined()
68
+ expect((seen.error as { status?: number }).status).toBe(403)
69
+ })
70
+ })
71
+
72
+ describe('helmInventoryRefetchInterval', () => {
73
+ const withGap = (action: string): HelmInventory => ({ releases: [], observed: [], objectCoverage: { gaps: [{ code: 'x', action }] } as unknown as HelmInventory['objectCoverage'] })
74
+
75
+ it('leaves a settled list alone', () => {
76
+ expect(helmInventoryRefetchInterval(undefined, 0)).toBe(false)
77
+ expect(helmInventoryRefetchInterval({}, 0)).toBe(false)
78
+ expect(helmInventoryRefetchInterval(withGap('grant_access'), 0)).toBe(false)
79
+ })
80
+
81
+ it('follows both gaps that can clear by themselves', () => {
82
+ expect(helmInventoryRefetchInterval(withGap('retry'), 0)).toBe(5000)
83
+ expect(helmInventoryRefetchInterval(withGap('wait'), 0)).toBe(5000)
84
+ })
85
+
86
+ it('slows down, without stopping, once a gap outlasts the quick retries', () => {
87
+ expect(helmInventoryRefetchInterval(withGap('retry'), 24)).toBe(60000)
88
+ expect(helmInventoryRefetchInterval(withGap('wait'), 500)).toBe(60000)
89
+ })
90
+ })
91
+
92
+ describe('observedHelmReleaseRefetchInterval', () => {
93
+ const detail = (action?: string) =>
94
+ ({ name: 'web', namespace: 'apps', resourceCount: 1, objectCoverage: { gaps: action ? [{ code: 'x', action }] : [] } }) as unknown as ObservedHelmReleaseDetail
95
+
96
+ it('rereads a settled drawer only once a minute, since each read walks every object', () => {
97
+ expect(observedHelmReleaseRefetchInterval(detail(), 3, null)).toBe(60000)
98
+ })
99
+
100
+ it('follows the list while objects settle', () => {
101
+ expect(observedHelmReleaseRefetchInterval(detail('retry'), 0, null)).toBe(5000)
102
+ })
103
+
104
+ it('retries a retryable error and stops on a stable one', () => {
105
+ expect(observedHelmReleaseRefetchInterval(undefined, 0, new ApiError('busy', 503))).toBe(15000)
106
+ expect(observedHelmReleaseRefetchInterval(undefined, 0, new ApiError('gone', 404))).toBe(false)
107
+ })
108
+ })
@@ -4,7 +4,7 @@ import { createRoot } from 'react-dom/client'
4
4
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
5
5
  import { afterEach, beforeEach, expect, it, vi } from 'vitest'
6
6
  import { getRadarUpgradeRequirement } from '@skyhook-io/k8s-ui'
7
- import { ApiError, isNotFoundError, useApplications, useCapacityPoolDetail, useDrainPlan, useNodeRemovalPlan, usePodEnvironment, useSubjectIssues, useWorkloadHistory } from './client'
7
+ import { ApiError, isNotFoundError, useApplications, useCapacityPoolDetail, useDrainPlan, useNodeRemovalPlan, usePodEnvironment, useRadarFeature, useSubjectIssues, useWorkloadHistory } from './client'
8
8
  import { getApiBase } from './config'
9
9
  import { usePolicyResource } from './policy'
10
10
  import { isRadarFeatureUnsupported } from './radarFeatures'
@@ -283,3 +283,35 @@ it('asks again once capabilities confirm workload history after a probe hit an o
283
283
  await settle()
284
284
  expect(requested.filter((url) => url.includes('/history'))).toHaveLength(2)
285
285
  })
286
+
287
+ function ArgoRollbackGate() {
288
+ const { upgrade, blockedReason } = useRadarFeature('argoRollback')
289
+ return <span>{blockedReason || (upgrade ? `${upgrade.feature} @ ${upgrade.currentVersion}` : 'enabled')}</span>
290
+ }
291
+
292
+ it('hands a control the upgrade requirement once capabilities omit its flag', async () => {
293
+ client.setQueryData(['capabilities'], { features: { workloadHistory: true } })
294
+ await render(<ArgoRollbackGate />)
295
+ expect(element.textContent).toBe('Argo CD rollbacks @ v1.7.2')
296
+ })
297
+
298
+ it('reports that support could not be checked when /api/capabilities fails', async () => {
299
+ const answer = vi.mocked(fetch).getMockImplementation()!
300
+ vi.mocked(fetch).mockImplementation((input, init) =>
301
+ String(input).endsWith('/capabilities')
302
+ ? Promise.resolve(Response.json({ error: 'capabilities down' }, { status: 500 }))
303
+ : answer(input, init),
304
+ )
305
+ await render(<ArgoRollbackGate />)
306
+ await settle()
307
+ expect(element.textContent).toBe("Couldn't check this cluster's Radar support. Refresh to try again.")
308
+ })
309
+
310
+ it('keeps a control checking until capabilities carry its flag', async () => {
311
+ await render(<ArgoRollbackGate />)
312
+ expect(element.textContent).toBe("Checking this cluster's Radar…")
313
+
314
+ await act(async () => { client.setQueryData(['capabilities'], { features: { argoRollbackSync: true } }) })
315
+ await settle()
316
+ expect(element.textContent).toBe('enabled')
317
+ })
@@ -6,6 +6,8 @@ import {
6
6
  RadarFeatureUnsupportedError,
7
7
  guardRadarFeature,
8
8
  isRadarFeatureUnsupported,
9
+ radarControlBlocked,
10
+ radarControlBlockedReason,
9
11
  radarFeatureSupport,
10
12
  radarSpecSupport,
11
13
  type RadarFeatureSpec,
@@ -65,6 +67,28 @@ describe('workload history, whose flag shipped with its endpoint', () => {
65
67
  })
66
68
  })
67
69
 
70
+ // A behavior change on endpoints every Radar serves: only the flag tells.
71
+ describe('Argo CD rollback and auto-sync, gated on argoRollbackSync', () => {
72
+ it.each(['argoRollback', 'argoAutoSyncEnable'] as const)('%s trusts the flag and reads its absence as too old', (feature) => {
73
+ expect(radarFeatureSupport(feature, { features: { argoRollbackSync: true } }, 'v1.16.3')).toBe('supported')
74
+ expect(radarFeatureSupport(feature, { features: { workloadHistory: true } }, 'v1.16.3')).toBe('unsupported')
75
+ expect(radarFeatureSupport(feature, {}, 'dev')).toBe('unsupported')
76
+ expect(radarFeatureSupport(feature, undefined, 'v1.16.3')).toBe('unknown')
77
+ })
78
+ })
79
+
80
+ describe('radarControlBlocked', () => {
81
+ // A control can't be probed like a request: its outcome on an older Radar
82
+ // is wrong, not a 404. So it fails closed when /api/capabilities failed,
83
+ // and stays usable only while the answer is still loading.
84
+ it('blocks a known-old Radar, and an unknown one whose capabilities failed', () => {
85
+ expect(radarControlBlocked('unsupported', false)).toBe(true)
86
+ expect(radarControlBlocked('unknown', true)).toBe(true)
87
+ expect(radarControlBlocked('unknown', false)).toBe(false)
88
+ expect(radarControlBlocked('supported', true)).toBe(false)
89
+ })
90
+ })
91
+
68
92
  describe('radarSpecSupport for a feature whose flag shipped with its endpoint', () => {
69
93
  const driftAlerts: RadarFeatureSpec = { label: 'Drift alerts', flag: 'resourceIssues', flagShippedWithEndpoint: true }
70
94
 
@@ -140,3 +164,26 @@ describe('shouldRetryRadarQuery', () => {
140
164
  }
141
165
  })
142
166
  })
167
+
168
+ describe('affirmative mutation support', () => {
169
+ it.each(['argoRollback', 'argoAutoSyncEnable'] as const)('%s distinguishes checking, failed and known answers', feature => {
170
+ expect(radarControlBlockedReason(feature, 'unknown', false)).toBe("Checking this cluster's Radar…")
171
+ expect(radarControlBlockedReason(feature, 'unknown', true)).toBe("Couldn't check this cluster's Radar support. Refresh to try again.")
172
+ expect(radarControlBlockedReason(feature, 'supported', false)).toBeUndefined()
173
+ expect(radarControlBlockedReason(feature, 'supported', true)).toBe("Couldn't check this cluster's Radar support. Refresh to try again.")
174
+ expect(radarControlBlockedReason(feature, 'unsupported', false)).toBeUndefined()
175
+ })
176
+ it('preserves permissive loading for other features', () => {
177
+ expect(radarControlBlockedReason('workloadHistory', 'unknown', false)).toBeUndefined()
178
+ expect(radarControlBlocked('unknown', false)).toBe(false)
179
+ })
180
+ })
181
+
182
+ describe('RayCluster runtime Pods, whose flag came after its route', () => {
183
+ it('trusts the flag, and otherwise the first release that served the route', () => {
184
+ expect(radarFeatureSupport('rayClusterPods', { features: { rayClusterPods: true } }, 'v1.14.0')).toBe('supported')
185
+ expect(radarFeatureSupport('rayClusterPods', { features: { resourceIssues: true } }, 'v1.15.0')).toBe('supported')
186
+ expect(radarFeatureSupport('rayClusterPods', { features: { resourceIssues: true } }, 'v1.14.1')).toBe('unsupported')
187
+ expect(radarFeatureSupport('rayClusterPods', { features: {} }, 'dev')).toBe('unknown')
188
+ })
189
+ })
@@ -11,7 +11,9 @@ import { compareVersions } from '../utils/version'
11
11
  // an entry here with that flag and `flagShippedWithEndpoint: true`, and guard
12
12
  // its hook with useRadarFeature. TestFeatureFlagsHaveFrontendGates keeps the
13
13
  // two lists in step. `minimumVersion` can wait for the release to be cut:
14
- // until then the note asks for the latest Radar.
14
+ // until then the note asks for the latest Radar. A behavior change on an
15
+ // existing endpoint is gated the same way, except that the control relying on
16
+ // it is disabled: an older Radar still answers the request, wrongly.
15
17
  export interface RadarFeatureSpec {
16
18
  /** Plural noun phrase; the upgrade note reads "<label> need Radar vX or newer." */
17
19
  label: string
@@ -24,16 +26,20 @@ export interface RadarFeatureSpec {
24
26
  * entries below, whose flags were added after their endpoints.
25
27
  */
26
28
  flagShippedWithEndpoint?: boolean
29
+ requireAffirmativeSupport?: boolean
27
30
  }
28
31
 
29
32
  export const RADAR_FEATURES = {
30
33
  resourceReadCoverage: { label: 'Resource read coverage', flag: 'resourceReadCoverage', flagShippedWithEndpoint: true },
31
34
  searchCoverage: { label: 'Search coverage and object filters', flag: 'searchCoverage', flagShippedWithEndpoint: true },
35
+ applicationEvidence: { label: 'Application evidence collection', flag: 'applicationEvidence', flagShippedWithEndpoint: true },
32
36
  resourceIssues: { label: 'Operational issues', minimumVersion: 'v1.8.0', flag: 'resourceIssues' },
33
37
  resourceIssueCoverage: { label: 'Resource-specific issue views', flag: 'resourceIssueCoverage', flagShippedWithEndpoint: true },
34
38
  podEnvironment: { label: 'Values from ConfigMaps and Secrets', minimumVersion: 'v1.9.0', flag: 'podEnvironment' },
35
39
  policyResource: { label: 'Policy results', minimumVersion: 'v1.10.0', flag: 'policyResource' },
36
40
  capacity: { label: 'Capacity views', minimumVersion: 'v1.9.0' },
41
+ // Radars from v1.15.0 serve the route without advertising the flag.
42
+ rayClusterPods: { label: 'RayCluster runtime Pods', minimumVersion: 'v1.15.0', flag: 'rayClusterPods' },
37
43
  upgradeReadiness: { label: 'Upgrade impact reports', minimumVersion: 'v1.9.0' },
38
44
  drainPlan: { label: 'Drain plans', minimumVersion: 'v1.14.0' },
39
45
  applications: { label: 'Applications', minimumVersion: 'v1.7.7' },
@@ -43,7 +49,25 @@ export const RADAR_FEATURES = {
43
49
  gitopsWriteEvidence: { label: 'GitOps revert warnings', flag: 'gitopsWriteEvidence', flagShippedWithEndpoint: true },
44
50
  serviceEndpointSlices: { label: 'Service EndpointSlice inventories', flag: 'serviceEndpointSlices', flagShippedWithEndpoint: true },
45
51
  trafficRecords: { label: 'Flow records for a graph selection', flag: 'trafficRecords', flagShippedWithEndpoint: true },
52
+ kueuePendingPosition: { label: 'Kueue queue positions', flag: 'kueuePendingPosition', flagShippedWithEndpoint: true },
53
+ kueueQueueWorkloads: { label: 'Workload lists on Kueue queues', flag: 'kueueQueueWorkloads', flagShippedWithEndpoint: true },
54
+ // One flag, two controls. An older Radar's rollback never runs, and its
55
+ // resume reports success while leaving automated.enabled: false in place.
56
+ argoRollback: { label: 'Argo CD rollbacks', flag: 'argoRollbackSync', flagShippedWithEndpoint: true, requireAffirmativeSupport: true },
57
+ argoAutoSyncEnable: { label: 'Auto-sync controls for Applications with automated.enabled: false', flag: 'argoRollbackSync', flagShippedWithEndpoint: true, requireAffirmativeSupport: true },
58
+ // Never blocks a control. An older Radar's sync drops the Application's
59
+ // sync options when the request omits them, and prunes when it omits prune,
60
+ // so useArgoSync sends both explicitly unless this is supported. Also tells
61
+ // the UI that Enable auto-sync on a never-suspended Application starts with
62
+ // prune off.
63
+ argoSyncInheritance: { label: "Syncs that keep the Application's sync options", flag: 'argoSyncInheritance', flagShippedWithEndpoint: true },
64
+ // Never blocks a control: tells the UI that Enable auto-sync on a
65
+ // never-suspended Application starts with selfHeal off; an older Radar
66
+ // turns it on.
67
+ argoEnableSelfHealOff: { label: 'Auto-sync that starts without self-heal', flag: 'argoEnableSelfHealOff', flagShippedWithEndpoint: true },
46
68
  helmSourceIdentity: { label: 'Helm source selection', flag: 'helmSourceIdentity', flagShippedWithEndpoint: true },
69
+ // Never blocks a control: on an older Radar the Helm view reads /helm/releases.
70
+ helmInventory: { label: 'Helm releases without Secret access', flag: 'helmInventory', flagShippedWithEndpoint: true },
47
71
  agentSigninCheck: { label: 'Agent sign-in checks', flag: 'agentSigninCheck', flagShippedWithEndpoint: true },
48
72
  } as const satisfies Record<string, RadarFeatureSpec>
49
73
 
@@ -89,6 +113,23 @@ export function radarFeatureSupport(
89
113
  return radarSpecSupport(RADAR_FEATURES[feature], capabilities, currentVersion)
90
114
  }
91
115
 
116
+ /**
117
+ * Whether a control backed by `feature` renders disabled with the upgrade
118
+ * note. A request can be probed, but a control's outcome can't, so a control
119
+ * also stays disabled when /api/capabilities failed, as CapabilitiesContext
120
+ * fails closed on the same error. While it loads, the control stays enabled.
121
+ */
122
+ export function radarControlBlocked(support: RadarFeatureSupport, capabilitiesFailed: boolean): boolean {
123
+ return support === 'unsupported' || (support === 'unknown' && capabilitiesFailed)
124
+ }
125
+
126
+ export function radarControlBlockedReason(feature: RadarFeature, support: RadarFeatureSupport, capabilitiesFailed: boolean): string | undefined {
127
+ const spec: RadarFeatureSpec = RADAR_FEATURES[feature]
128
+ if (!spec.requireAffirmativeSupport) return undefined
129
+ if (capabilitiesFailed) return "Couldn't check this cluster's Radar support. Refresh to try again."
130
+ return support === 'unknown' ? "Checking this cluster's Radar…" : undefined
131
+ }
132
+
92
133
  export function radarUpgradeRequirement(feature: RadarFeature, versions: RadarVersions): RadarUpgradeRequirement {
93
134
  const spec: RadarFeatureSpec = RADAR_FEATURES[feature]
94
135
  return {
@@ -0,0 +1,42 @@
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, describe, expect, it, vi } from 'vitest'
6
+ import { useRBACSubject } from './rbac'
7
+
8
+ Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
9
+
10
+ function Probe() {
11
+ useRBACSubject('ServiceAccount', 'shop', 'default')
12
+ return null
13
+ }
14
+
15
+ afterEach(() => vi.unstubAllGlobals())
16
+
17
+ // Opens the "drawer" twice on one query client and counts RBAC requests.
18
+ async function requestsOverTwoOpens(status: number, error: string) {
19
+ const fetchMock = vi.fn<(input: RequestInfo | URL) => Promise<Response>>(async () =>
20
+ new Response(JSON.stringify({ error }), { status, headers: { 'Content-Type': 'application/json' } }))
21
+ vi.stubGlobal('fetch', fetchMock)
22
+ const client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
23
+ for (let open = 0; open < 2; open++) {
24
+ const root = createRoot(document.createElement('div'))
25
+ await act(async () => {
26
+ root.render(<QueryClientProvider client={client}><Probe /></QueryClientProvider>)
27
+ })
28
+ await act(async () => { await new Promise(resolve => setTimeout(resolve, 20)) })
29
+ act(() => root.unmount())
30
+ }
31
+ return fetchMock.mock.calls.filter(([input]) => String(input).includes('/rbac/subject')).length
32
+ }
33
+
34
+ describe('useRBACSubject', () => {
35
+ it('asks once when Radar cannot read RBAC', async () => {
36
+ expect(await requestsOverTwoOpens(503, 'RBAC cache not available (informers not synced)')).toBe(1)
37
+ })
38
+
39
+ it('asks again on the next open after any other failure', async () => {
40
+ expect(await requestsOverTwoOpens(404, 'not found')).toBe(2)
41
+ })
42
+ })
@@ -0,0 +1,18 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import { isRBACCacheUnavailable } from './rbac'
3
+
4
+ function fetchError(status: number, message: string) {
5
+ return Object.assign(new Error(message), { status })
6
+ }
7
+
8
+ describe('isRBACCacheUnavailable', () => {
9
+ it('recognizes the settled answer from a Radar that cannot read RBAC', () => {
10
+ expect(isRBACCacheUnavailable(fetchError(503, 'RBAC cache not available (informers not synced or RBAC reads disabled for the Radar SA)'))).toBe(true)
11
+ })
12
+
13
+ it('leaves other outages to the normal retry', () => {
14
+ expect(isRBACCacheUnavailable(fetchError(503, 'Not connected to cluster'))).toBe(false)
15
+ expect(isRBACCacheUnavailable(fetchError(500, 'RBAC cache exploded'))).toBe(false)
16
+ expect(isRBACCacheUnavailable(null)).toBe(false)
17
+ })
18
+ })
package/src/api/rbac.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { useQuery } from '@tanstack/react-query'
1
+ import { useQuery, useQueryClient } from '@tanstack/react-query'
2
2
  import type {
3
3
  RBACSubjectResponse,
4
4
  RBACRoleResponse,
@@ -6,6 +6,27 @@ import type {
6
6
  RBACNamespaceResponse,
7
7
  } from '@skyhook-io/k8s-ui'
8
8
  import { fetchJSON } from './client'
9
+ import { shouldRetryRadarQuery } from './radarFeatures'
10
+
11
+ // The server answers 503 "RBAC cache not available" when the identity Radar
12
+ // connects with can't read RBAC. That holds until the next connection, so a
13
+ // retry, or a refetch on every drawer open, only repeats the same answer.
14
+ // Reconnecting removes errored RBAC queries and a context switch removes all
15
+ // queries, so the next look after either asks again.
16
+ export function isRBACCacheUnavailable(error: unknown): boolean {
17
+ const e = error as { status?: unknown; message?: unknown } | null
18
+ return e?.status === 503 && typeof e.message === 'string' && e.message.includes('RBAC cache')
19
+ }
20
+
21
+ function retryRBACQuery(failureCount: number, error: unknown): boolean {
22
+ return !isRBACCacheUnavailable(error) && shouldRetryRadarQuery(failureCount, error)
23
+ }
24
+
25
+ // Pauses one RBAC query, and only while its stored answer is the settled
26
+ // "can't read RBAC" 503; any other error still refetches when the drawer opens.
27
+ function useRBACAnswerSettled(queryKey: readonly unknown[]): boolean {
28
+ return isRBACCacheUnavailable(useQueryClient().getQueryState(queryKey)?.error)
29
+ }
9
30
 
10
31
  // /api/rbac/subject/{kind}/{namespace}/{name} (ServiceAccount)
11
32
  // /api/rbac/subject/{kind}/{name} (User/Group — no namespace)
@@ -17,10 +38,13 @@ export function useRBACSubject(kind: 'ServiceAccount' | 'User' | 'Group', namesp
17
38
  kind === 'ServiceAccount'
18
39
  ? `/rbac/subject/${kind}/${encodeURIComponent(namespace)}/${encodeURIComponent(name)}`
19
40
  : `/rbac/subject/${kind}/${encodeURIComponent(name)}`
41
+ const queryKey = ['rbac', 'subject', kind, namespace, name]
42
+ const settled = useRBACAnswerSettled(queryKey)
20
43
  return useQuery<RBACSubjectResponse>({
21
- queryKey: ['rbac', 'subject', kind, namespace, name],
44
+ queryKey,
45
+ retry: retryRBACQuery,
22
46
  queryFn: () => fetchJSON<RBACSubjectResponse>(path),
23
- enabled: enabled && !!name && (kind !== 'ServiceAccount' || !!namespace),
47
+ enabled: enabled && !settled && !!name && (kind !== 'ServiceAccount' || !!namespace),
24
48
  staleTime: 15000,
25
49
  })
26
50
  }
@@ -28,20 +52,26 @@ export function useRBACSubject(kind: 'ServiceAccount' | 'User' | 'Group', namesp
28
52
  // /api/rbac/role/{kind}/{namespace}/{name} (use "_" for ClusterRole's empty namespace)
29
53
  export function useRBACRole(kind: 'Role' | 'ClusterRole', namespace: string, name: string, enabled = true) {
30
54
  const nsSegment = kind === 'ClusterRole' ? '_' : encodeURIComponent(namespace)
55
+ const queryKey = ['rbac', 'role', kind, namespace, name]
56
+ const settled = useRBACAnswerSettled(queryKey)
31
57
  return useQuery<RBACRoleResponse>({
32
- queryKey: ['rbac', 'role', kind, namespace, name],
58
+ queryKey,
59
+ retry: retryRBACQuery,
33
60
  queryFn: () => fetchJSON<RBACRoleResponse>(`/rbac/role/${kind}/${nsSegment}/${encodeURIComponent(name)}`),
34
- enabled: enabled && !!name && (kind !== 'Role' || !!namespace),
61
+ enabled: enabled && !settled && !!name && (kind !== 'Role' || !!namespace),
35
62
  staleTime: 15000,
36
63
  })
37
64
  }
38
65
 
39
66
  // /api/rbac/namespace/{namespace}
40
67
  export function useRBACNamespace(namespace: string, enabled = true) {
68
+ const queryKey = ['rbac', 'namespace', namespace]
69
+ const settled = useRBACAnswerSettled(queryKey)
41
70
  return useQuery<RBACNamespaceResponse>({
42
- queryKey: ['rbac', 'namespace', namespace],
71
+ queryKey,
72
+ retry: retryRBACQuery,
43
73
  queryFn: () => fetchJSON<RBACNamespaceResponse>(`/rbac/namespace/${encodeURIComponent(namespace)}`),
44
- enabled: enabled && !!namespace,
74
+ enabled: enabled && !settled && !!namespace,
45
75
  staleTime: 15000,
46
76
  })
47
77
  }
@@ -3,7 +3,7 @@ import { useQuery, useMutation, useQueryClient, type QueryClient } from '@tansta
3
3
  import type { TrafficSourcesResponse, TrafficFlowsResponse, TrafficRecordsResponse } from '../types'
4
4
  import { fetchJSON as fetchApiJSON, useRadarFeature } from './client'
5
5
  import { shouldRetryRadarQuery } from './radarFeatures'
6
- import { apiUrl, getAuthHeaders, getCredentialsMode } from './config'
6
+ import { apiUrl, automaticRequestHeaders, getAuthHeaders, getCredentialsMode } from './config'
7
7
  import { readErrorBody } from './httpErrors'
8
8
 
9
9
  async function fetchJSON<T>(path: string, signal?: AbortSignal): Promise<T> {
@@ -279,12 +279,17 @@ export function useTrafficConnectionStatus() {
279
279
  export function useTrafficConnect() {
280
280
  const queryClient = useQueryClient()
281
281
 
282
- return useMutation<TrafficConnectionInfo, Error>({
283
- mutationFn: async () => {
282
+ // `automatic`: the page connected by itself, not for a click.
283
+ return useMutation<TrafficConnectionInfo, Error, { automatic?: boolean } | void>({
284
+ mutationFn: async (vars) => {
284
285
  const response = await fetch(apiUrl('/traffic/connect'), {
285
286
  method: 'POST',
286
287
  credentials: getCredentialsMode(),
287
- headers: { 'Content-Type': 'application/json', ...getAuthHeaders() },
288
+ headers: {
289
+ 'Content-Type': 'application/json',
290
+ ...getAuthHeaders(),
291
+ ...(vars?.automatic ? automaticRequestHeaders() : {}),
292
+ },
288
293
  })
289
294
  if (!response.ok) {
290
295
  const error = await readErrorBody(response)
@@ -3,15 +3,17 @@ import type { UsageDataStatus, UsageReport } from './usage-data'
3
3
  // Test-only: a report and status shaped like the server's.
4
4
  export function exampleReport(patch: Partial<UsageReport> = {}): UsageReport {
5
5
  return {
6
- schema: 3,
6
+ schema: 4,
7
7
  version: '1.15.0', os: 'darwin', arch: 'arm64', installMethod: 'homebrew', mode: 'local',
8
8
  periodStart: '2026-09-23', periodEnd: '2026-09-24',
9
9
  setup: {
10
10
  authMode: 'none', timelineStorage: 'memory', mcpEnabled: true, prometheus: 'none',
11
11
  costSource: 'auto', browsers: ['chrome'],
12
+ aiConfigured: false, trafficSource: 'none',
12
13
  },
13
14
  engagement: { sessions: 2, activeMinutes: '20-49' },
14
15
  views: {}, actions: {}, mcpTools: {}, uiEvents: {}, errors: {},
16
+ actionKinds: {}, connectionFailures: {},
15
17
  clusters: {
16
18
  contexts: '5-9', used: 1,
17
19
  shapes: [{ kubernetesVersion: '1.33', platform: 'eks', nodes: '10-19', integrations: ['argo-cd'] }],