@skyhook-io/radar-app 1.18.2 → 1.20.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 (228) hide show
  1. package/README.md +1 -1
  2. package/package.json +7 -7
  3. package/src/App.tsx +31 -6
  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 +285 -55
  13. package/src/api/config.ts +21 -0
  14. package/src/api/diagnose.test.ts +33 -2
  15. package/src/api/diagnose.ts +97 -3
  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 +41 -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/diagnose/AIMarkdown.tsx +4 -1
  48. package/src/components/diagnose/ActivityTurn.tsx +34 -14
  49. package/src/components/diagnose/AgentControls.tsx +53 -6
  50. package/src/components/diagnose/AgentSetupNotice.test.tsx +17 -0
  51. package/src/components/diagnose/AgentSetupNotice.tsx +22 -4
  52. package/src/components/diagnose/AgentSigninNotice.test.tsx +98 -0
  53. package/src/components/diagnose/AgentSigninNotice.tsx +61 -0
  54. package/src/components/diagnose/AnalysisStory.test.tsx +22 -0
  55. package/src/components/diagnose/AnalysisStory.tsx +17 -4
  56. package/src/components/diagnose/AssessmentCard.tsx +39 -8
  57. package/src/components/diagnose/ContinueInAgentButton.mounted.test.tsx +182 -0
  58. package/src/components/diagnose/ContinueInAgentButton.test.tsx +128 -0
  59. package/src/components/diagnose/ContinueInAgentButton.tsx +303 -0
  60. package/src/components/diagnose/DiagnoseContext.capacity.test.tsx +113 -0
  61. package/src/components/diagnose/DiagnoseContext.question.test.tsx +245 -0
  62. package/src/components/diagnose/DiagnoseContext.tsx +272 -10
  63. package/src/components/diagnose/DiagnoseSurface.test.tsx +54 -0
  64. package/src/components/diagnose/DiagnoseSurface.tsx +151 -134
  65. package/src/components/diagnose/EvidenceCard.tsx +67 -14
  66. package/src/components/diagnose/ExampleInvestigationLink.tsx +20 -0
  67. package/src/components/diagnose/Home.test.tsx +208 -5
  68. package/src/components/diagnose/Home.tsx +187 -36
  69. package/src/components/diagnose/InvestigationCapacityNotice.test.tsx +246 -0
  70. package/src/components/diagnose/InvestigationCapacityNotice.tsx +241 -0
  71. package/src/components/diagnose/InvestigationEvidencePane.story.test.tsx +97 -6
  72. package/src/components/diagnose/InvestigationEvidencePane.test.tsx +57 -0
  73. package/src/components/diagnose/InvestigationEvidencePane.tsx +59 -11
  74. package/src/components/diagnose/InvestigationEvidenceSections.tsx +50 -23
  75. package/src/components/diagnose/InvestigationView.tsx +249 -54
  76. package/src/components/diagnose/LocalDiagnoseAction.history.test.tsx +450 -0
  77. package/src/components/diagnose/LocalDiagnoseAction.tsx +365 -39
  78. package/src/components/diagnose/NextStepJump.test.tsx +92 -0
  79. package/src/components/diagnose/NextStepJump.tsx +75 -0
  80. package/src/components/diagnose/QuestionComposer.test.tsx +553 -0
  81. package/src/components/diagnose/QuestionComposer.tsx +495 -0
  82. package/src/components/diagnose/QuestionFocus.test.tsx +38 -0
  83. package/src/components/diagnose/QuestionFocus.tsx +123 -0
  84. package/src/components/diagnose/ResourcePicker.tsx +206 -0
  85. package/src/components/diagnose/StoryExcerpt.tsx +12 -3
  86. package/src/components/diagnose/assessmentCopy.ts +5 -0
  87. package/src/components/diagnose/exampleInvestigation.events.json +191 -0
  88. package/src/components/diagnose/exampleInvestigation.loadFailure.test.tsx +94 -0
  89. package/src/components/diagnose/exampleInvestigation.test.tsx +248 -0
  90. package/src/components/diagnose/exampleInvestigation.ts +121 -0
  91. package/src/components/diagnose/investigationCase.runs.test.tsx +328 -0
  92. package/src/components/diagnose/investigationCase.test.tsx +9 -1
  93. package/src/components/diagnose/investigationCase.ts +33 -1
  94. package/src/components/diagnose/investigationEvidence/adapters/applicationFindings.test.ts +739 -0
  95. package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +46 -0
  96. package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +58 -2
  97. package/src/components/diagnose/investigationEvidence/adapters/issues.ts +9 -0
  98. package/src/components/diagnose/investigationEvidence/adapters/posture.ts +29 -1
  99. package/src/components/diagnose/investigationEvidence/adapters/prometheus.test.ts +40 -0
  100. package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +27 -1
  101. package/src/components/diagnose/investigationEvidence/bodies/metrics.test.tsx +111 -0
  102. package/src/components/diagnose/investigationEvidence/bodies/metrics.tsx +67 -16
  103. package/src/components/diagnose/investigationEvidence/builder.ts +30 -0
  104. package/src/components/diagnose/investigationEvidence/excerpt.test.ts +18 -5
  105. package/src/components/diagnose/investigationEvidence/excerpt.ts +22 -11
  106. package/src/components/diagnose/investigationEvidence/index.ts +1 -1
  107. package/src/components/diagnose/investigationEvidence/navigation.tsx +2 -0
  108. package/src/components/diagnose/investigationEvidence/observations.ts +121 -2
  109. package/src/components/diagnose/investigationEvidence/projection.test.ts +85 -3
  110. package/src/components/diagnose/investigationEvidence/types.ts +7 -0
  111. package/src/components/diagnose/investigationEvidencePartition.ts +6 -1
  112. package/src/components/diagnose/investigationFocus.test.ts +271 -0
  113. package/src/components/diagnose/investigationFocus.ts +132 -0
  114. package/src/components/diagnose/investigationState.ts +28 -0
  115. package/src/components/diagnose/lastInvestigation.test.ts +95 -0
  116. package/src/components/diagnose/lastInvestigation.ts +58 -0
  117. package/src/components/diagnose/launch.test.ts +125 -1
  118. package/src/components/diagnose/launch.ts +57 -10
  119. package/src/components/diagnose/parts.test.tsx +20 -0
  120. package/src/components/diagnose/questionSuggestions.test.ts +111 -0
  121. package/src/components/diagnose/questionSuggestions.ts +150 -0
  122. package/src/components/diagnose/storyParts.test.tsx +13 -0
  123. package/src/components/diagnose/target.test.ts +143 -2
  124. package/src/components/diagnose/target.ts +109 -7
  125. package/src/components/diagnose/testdata/story-runs.json +474 -0
  126. package/src/components/diagnose/toolCallLabel.test.ts +10 -4
  127. package/src/components/diagnose/verdictText.test.tsx +87 -0
  128. package/src/components/diagnose/verdictText.ts +68 -0
  129. package/src/components/execution/BatchExecutionView.tsx +24 -11
  130. package/src/components/execution/JobSetAdmission.test.tsx +42 -0
  131. package/src/components/execution/JobSetAdmission.tsx +18 -3
  132. package/src/components/execution/JobSetMemberComparison.tsx +2 -1
  133. package/src/components/execution/runState.test.ts +14 -0
  134. package/src/components/execution/runState.ts +8 -0
  135. package/src/components/gitops/GitOpsView.rollbackGate.test.tsx +202 -0
  136. package/src/components/gitops/GitOpsView.syncRequest.test.tsx +369 -0
  137. package/src/components/gitops/GitOpsView.tsx +86 -17
  138. package/src/components/gitops/RemoteDestinationCloudHint.tsx +2 -3
  139. package/src/components/gitops/destination-toast.test.ts +1 -1
  140. package/src/components/gitops/destination-toast.ts +2 -2
  141. package/src/components/home/ClusterHealthCard.tsx +13 -39
  142. package/src/components/home/HomeAgentBlock.test.tsx +141 -0
  143. package/src/components/home/HomeAgentBlock.tsx +103 -0
  144. package/src/components/home/HomeDiagramCard.tsx +47 -0
  145. package/src/components/home/HomeView.tsx +86 -47
  146. package/src/components/home/MCPSetupDialog.test.tsx +95 -5
  147. package/src/components/home/MCPSetupDialog.tsx +30 -5
  148. package/src/components/home/ProblemsPanel.investigate.test.tsx +171 -0
  149. package/src/components/home/ProblemsPanel.test.tsx +3 -1
  150. package/src/components/home/RadarVersionLine.test.tsx +0 -14
  151. package/src/components/home/RadarVersionLine.tsx +3 -28
  152. package/src/components/home/TopologyPreview.test.tsx +73 -0
  153. package/src/components/home/TopologyPreview.tsx +120 -233
  154. package/src/components/home/TrafficSummary.test.tsx +63 -0
  155. package/src/components/home/TrafficSummary.tsx +135 -138
  156. package/src/components/home/mcpToolCatalog.ts +23 -10
  157. package/src/components/issues/IssuesPane.test.ts +11 -0
  158. package/src/components/issues/IssuesPane.tsx +15 -5
  159. package/src/components/issues/uncheckedSources.test.ts +20 -1
  160. package/src/components/issues/uncheckedSources.ts +18 -0
  161. package/src/components/kueue/KueuePendingPosition.tsx +35 -0
  162. package/src/components/kueue/useRelatedObjects.test.tsx +219 -0
  163. package/src/components/kueue/useRelatedReads.test.ts +56 -0
  164. package/src/components/kueue/useRelatedReads.ts +205 -0
  165. package/src/components/logs/MultiPodLogsTab.test.tsx +93 -0
  166. package/src/components/logs/MultiPodLogsTab.tsx +120 -0
  167. package/src/components/logs/PodLogsUnavailable.test.tsx +18 -0
  168. package/src/components/logs/PodLogsUnavailable.tsx +21 -0
  169. package/src/components/logs/RayClusterLogsTab.reselect.test.tsx +67 -0
  170. package/src/components/logs/RayClusterLogsTab.test.tsx +167 -0
  171. package/src/components/logs/RayClusterLogsTab.tsx +109 -0
  172. package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +3 -2
  173. package/src/components/logs/rayClusterPods.ts +32 -0
  174. package/src/components/outageSince.test.ts +21 -0
  175. package/src/components/outageSince.ts +10 -0
  176. package/src/components/resource/PrometheusCharts.overlays.test.ts +12 -0
  177. package/src/components/resource/PrometheusCharts.tsx +3 -40
  178. package/src/components/resources/crd/CRDSchemaTab.test.tsx +28 -0
  179. package/src/components/resources/crd/CRDSchemaTab.tsx +13 -0
  180. package/src/components/resources/crd/host.tsx +14 -0
  181. package/src/components/resources/renderers/CustomResourceDefinitionRenderer.test.tsx +27 -0
  182. package/src/components/resources/renderers/CustomResourceDefinitionRenderer.tsx +12 -0
  183. package/src/components/resources/renderers/JobAdmissionRenderers.test.tsx +4 -1
  184. package/src/components/resources/renderers/JobAdmissionRenderers.tsx +4 -3
  185. package/src/components/resources/renderers/KueueHostRenderers.test.tsx +117 -0
  186. package/src/components/resources/renderers/KueueQueueRenderers.test.tsx +97 -0
  187. package/src/components/resources/renderers/KueueQueueRenderers.tsx +139 -0
  188. package/src/components/resources/renderers/KueueWorkloadRenderer.test.tsx +7 -1
  189. package/src/components/resources/renderers/KueueWorkloadRenderer.tsx +47 -7
  190. package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.test.tsx +67 -0
  191. package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.tsx +31 -0
  192. package/src/components/resources/renderers/RayClusterRenderer.test.tsx +81 -3
  193. package/src/components/resources/renderers/RayClusterRenderer.tsx +19 -4
  194. package/src/components/traffic/TrafficView.tsx +3 -3
  195. package/src/components/ui/Omnibar.investigate.test.tsx +105 -0
  196. package/src/components/ui/Omnibar.tsx +47 -3
  197. package/src/components/ui/RadarOmnibar.test.tsx +1 -0
  198. package/src/components/ui/RadarOmnibar.tsx +11 -0
  199. package/src/components/ui/command-items-crd.test.tsx +23 -0
  200. package/src/components/ui/command-items.ts +2 -1
  201. package/src/components/useContextSwitchFlow.test.tsx +61 -0
  202. package/src/components/useContextSwitchFlow.tsx +21 -4
  203. package/src/components/whats-new/WhatsNew.test.ts +10 -3
  204. package/src/components/whats-new/WhatsNew.tsx +5 -1
  205. package/src/components/whats-new/WhatsNewDialog.test.tsx +18 -4
  206. package/src/components/whats-new/releaseNotes.ts +136 -4
  207. package/src/components/workload/RelatedFindingsSection.test.tsx +126 -0
  208. package/src/components/workload/RelatedFindingsSection.tsx +80 -0
  209. package/src/components/workload/WorkloadView.test.ts +10 -1
  210. package/src/components/workload/WorkloadView.tsx +85 -98
  211. package/src/components/workload/issueResourceOpener.test.ts +20 -0
  212. package/src/components/workload/issueResourceOpener.ts +17 -0
  213. package/src/context/ConnectionContext.tsx +133 -60
  214. package/src/context/ConnectionProvider.retry.test.tsx +176 -0
  215. package/src/context/ContextSwitchContext.tsx +14 -1
  216. package/src/context/DiagnoseCustomization.tsx +3 -0
  217. package/src/context/clusterConnected.ts +10 -0
  218. package/src/contexts/CapabilitiesContext.tsx +6 -4
  219. package/src/hooks/useAgentSignin.test.tsx +190 -0
  220. package/src/hooks/useAgentSignin.ts +160 -0
  221. package/src/hooks/useApproveAfterSignin.test.tsx +108 -0
  222. package/src/hooks/useElementSize.ts +30 -0
  223. package/src/integrations/resourceHost.test.tsx +1 -0
  224. package/src/integrations/resourceHost.ts +5 -1
  225. package/src/integrations/resourceHosts.test.tsx +21 -4
  226. package/src/integrations/resourceHosts.tsx +12 -0
  227. package/src/main.tsx +5 -0
  228. package/src/utils/related-findings.ts +46 -0
package/README.md CHANGED
@@ -10,7 +10,7 @@ This package is source-only — it ships TypeScript + TSX files under `src/`. Co
10
10
  npm install @skyhook-io/radar-app
11
11
  ```
12
12
 
13
- Peer deps: `react >=19`, `react-dom >=19`, `react-router-dom >=7`, `@tanstack/react-query >=5`, `@skyhook-io/k8s-ui >=1.17.1`, plus `clsx`, `tailwind-merge`, `lucide-react`, `@xyflow/react`, `elkjs`.
13
+ Peer deps: `react >=19`, `react-dom >=19`, `react-router-dom >=7`, `@tanstack/react-query >=5`, `@skyhook-io/k8s-ui >=1.18.2`, plus `clsx`, `tailwind-merge`, `lucide-react`, `@xyflow/react`, `elkjs`.
14
14
 
15
15
  ## Use
16
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyhook-io/radar-app",
3
- "version": "1.18.2",
3
+ "version": "1.20.0",
4
4
  "description": "Radar's full web UI as a reusable React component. Used by Radar's own binary and by external consumers like Radar Cloud.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -42,7 +42,7 @@
42
42
  "yaml": "^2.9.1"
43
43
  },
44
44
  "peerDependencies": {
45
- "@skyhook-io/k8s-ui": ">=1.18.1",
45
+ "@skyhook-io/k8s-ui": ">=1.19.1",
46
46
  "@tanstack/react-query": ">=5",
47
47
  "@xyflow/react": ">=12.0.0",
48
48
  "clsx": ">=2",
@@ -55,11 +55,11 @@
55
55
  },
56
56
  "devDependencies": {
57
57
  "@eslint/js": "^10.0.1",
58
- "@playwright/test": "^1.62.0",
58
+ "@playwright/test": "^1.64.1",
59
59
  "@skyhook-io/k8s-ui": "*",
60
60
  "@tailwindcss/vite": "^4.3.3",
61
- "@tanstack/react-query": "^5.103.1",
62
- "@types/node": "^26.6.2",
61
+ "@tanstack/react-query": "^5.105.0",
62
+ "@types/node": "^26.6.6",
63
63
  "@types/react": "^19.3.0",
64
64
  "@types/react-dom": "^19.3.0",
65
65
  "@vitejs/plugin-react": "^6.1.2",
@@ -68,7 +68,7 @@
68
68
  "elkjs": "^0.11.1",
69
69
  "eslint": "^10.13.0",
70
70
  "eslint-plugin-react-hooks": "^7.1.1",
71
- "eslint-plugin-react-refresh": "^0.5.3",
71
+ "eslint-plugin-react-refresh": "^0.5.7",
72
72
  "globals": "^17.11.0",
73
73
  "lucide-react": "^1.48.0",
74
74
  "postcss": "^8.5.30",
@@ -79,7 +79,7 @@
79
79
  "tailwind-merge": "^3.7.0",
80
80
  "tailwindcss": "^4.3.3",
81
81
  "typescript": "^6.0.2",
82
- "typescript-eslint": "^8.71.0",
82
+ "typescript-eslint": "^8.72.0",
83
83
  "vite": "^8.3.4"
84
84
  },
85
85
  "sideEffects": [
package/src/App.tsx CHANGED
@@ -46,7 +46,7 @@ import { useNavRailPinned } from './hooks/useNavRailPinned'
46
46
  import { useMediaQuery } from './hooks/useMediaQuery'
47
47
  import { ContextSwitchProvider, useContextSwitch } from './context/ContextSwitchContext'
48
48
  import { ConnectionProvider, useConnection, refreshQueriesAfterReconnect } from './context/ConnectionContext'
49
- import { ConnectionErrorView } from './components/ConnectionErrorView'
49
+ import { DisconnectedView, FailedSwitchView } from './components/SwitchAwareConnectionError'
50
50
  import { SyncProgressPanel } from './components/SyncProgressPanel'
51
51
  import { NoClusterAccessBanner } from './components/NoClusterAccessBanner'
52
52
  import { CapabilitiesProvider, useCapabilitiesContext } from './contexts/CapabilitiesContext'
@@ -89,7 +89,7 @@ import type { ContextSwitcherHandle } from './components/ContextSwitcher'
89
89
  const ALL_NODE_KINDS: NodeKind[] = [
90
90
  'Internet', 'Ingress', 'Gateway', 'HTTPRoute', 'GRPCRoute', 'TCPRoute', 'TLSRoute', 'UDPRoute',
91
91
  'Service', 'Deployment', 'Rollout', 'DaemonSet', 'StatefulSet',
92
- 'ReplicaSet', 'Pod', 'PodGroup', 'ConfigMap', 'Secret', 'ServiceAccount', 'SealedSecret', 'ServiceMonitor', 'PodMonitor', 'HorizontalPodAutoscaler', 'Job', 'CronJob', 'PersistentVolumeClaim', 'Namespace',
92
+ 'ReplicaSet', 'Pod', 'PodGroup', 'ConfigMap', 'Secret', 'ServiceAccount', 'SealedSecret', 'ServiceMonitor', 'PodMonitor', 'HorizontalPodAutoscaler', 'Job', 'CronJob', 'JobSet', 'PersistentVolumeClaim', 'Namespace',
93
93
  'Application', 'Kustomization', 'HelmRelease', 'GitRepository',
94
94
  'KnativeService', 'KnativeConfiguration', 'KnativeRevision', 'KnativeRoute',
95
95
  'Broker', 'Trigger', 'PingSource', 'ApiServerSource', 'ContainerSource', 'SinkBinding', 'Channel',
@@ -1042,7 +1042,7 @@ function AppInner({ manageDocumentTitle = false, documentTitleSuffix, onClusterL
1042
1042
  const { data: namespaceScope } = useNamespaceScope()
1043
1043
 
1044
1044
  // Context switch state
1045
- const { isSwitching, targetContext, progressMessage, updateProgress, endSwitch, takeOpenAfterSwitch } = useContextSwitch()
1045
+ const { isSwitching, failedSwitch, setFailedSwitch, targetContext, progressMessage, updateProgress, endSwitch, takeOpenAfterSwitch } = useContextSwitch()
1046
1046
 
1047
1047
  // Connection state (for graceful startup)
1048
1048
  const { connection, retry: retryConnection, isRetrying, updateFromSSE: updateConnectionFromSSE } = useConnection()
@@ -1055,7 +1055,26 @@ function AppInner({ manageDocumentTitle = false, documentTitleSuffix, onClusterL
1055
1055
  // empty drawer over a not-yet-loaded view. Gating both on the SAME readiness so
1056
1056
  // a drawer only ever sits over a real content surface.
1057
1057
  const contentReady = !isSwitching && !authMePending &&
1058
- !(authMe?.authEnabled && !authMe?.username) && connection.state === 'connected'
1058
+ !(authMe?.authEnabled && !authMe?.username) && connection.state === 'connected' && !failedSwitch
1059
+
1060
+ // The last context that was connected, so a screen about a cluster that
1061
+ // won't connect can offer a way back to it.
1062
+ const [lastConnectedContext, setLastConnectedContext] = useState<string | null>(null)
1063
+ useEffect(() => {
1064
+ if (connection.state === 'connected' && connection.context) setLastConnectedContext(connection.context)
1065
+ }, [connection.state, connection.context])
1066
+ // A refused switch is about the cluster that was still connected. Once that
1067
+ // connection changes in any way (dropped, reconnecting, or switched from
1068
+ // another tab), the screen is stale.
1069
+ const failedSwitchFrom = useRef<string | undefined>(undefined)
1070
+ useEffect(() => {
1071
+ if (!failedSwitch) {
1072
+ failedSwitchFrom.current = undefined
1073
+ return
1074
+ }
1075
+ failedSwitchFrom.current ??= connection.context
1076
+ if (connection.state !== 'connected' || connection.context !== failedSwitchFrom.current) setFailedSwitch(null)
1077
+ }, [failedSwitch, connection.state, connection.context, setFailedSwitch])
1059
1078
 
1060
1079
  // Progressive shell during the initial informer sync: once the server
1061
1080
  // publishes per-kind sync progress, render the app instead of the splash.
@@ -2009,13 +2028,20 @@ function AppInner({ manageDocumentTitle = false, documentTitleSuffix, onClusterL
2009
2028
 
2010
2029
  {/* Connection error view - show when disconnected */}
2011
2030
  {!isSwitching && !(authMe?.authEnabled && !authMe?.username) && connection.state === 'disconnected' && (
2012
- <ConnectionErrorView
2031
+ <DisconnectedView
2013
2032
  connection={connection}
2014
2033
  onRetry={retryConnection}
2015
2034
  isRetrying={isRetrying}
2035
+ lastConnectedContext={lastConnectedContext}
2016
2036
  />
2017
2037
  )}
2018
2038
 
2039
+ {/* A switch refused before leaving the current cluster: the error screen
2040
+ for the cluster that didn't answer, over the still-connected app. */}
2041
+ {!isSwitching && !(authMe?.authEnabled && !authMe?.username) && connection.state === 'connected' && failedSwitch && (
2042
+ <FailedSwitchView currentContext={connection.context} />
2043
+ )}
2044
+
2019
2045
  {/* Connecting view — shown during initial connection or retry.
2020
2046
  Icon is pane-anchored so its screen position matches the
2021
2047
  host hub splash across cross-document transitions. */}
@@ -2109,7 +2135,6 @@ function AppInner({ manageDocumentTitle = false, documentTitleSuffix, onClusterL
2109
2135
  onNavigateToView={setMainView}
2110
2136
  onNavigateToHelmRelease={navCustomization.embedded ? undefined : navigateToHelmRelease}
2111
2137
  onNavigateToManagerPath={navCustomization.embedded || takeover.gitops ? undefined : navigateToPath}
2112
- onShowWhatsNew={!navCustomization.embedded && whatsNewStatus.available ? openWhatsNew : undefined}
2113
2138
  // Upgrade impact lives under /checks, which a Cloud host takes
2114
2139
  // over wholesale — its fleet pages have no upgrade sub-route, so
2115
2140
  // the version line stays plain text there.
@@ -0,0 +1,63 @@
1
+ import { fetchJSON } from './client'
2
+
3
+ export type EvidenceApplication = 'rabbitmq' | 'nats' | 'vault'
4
+ export interface EvidenceTarget { namespace: string; pod: string; uid?: string; container?: string }
5
+ export interface EvidenceCandidate {
6
+ application: EvidenceApplication
7
+ target: EvidenceTarget & { uid: string; container: string }
8
+ expectedEvidence: string[]
9
+ coverage: string
10
+ }
11
+ export interface EvidenceCandidates {
12
+ permissionCheckTimedOut?: boolean
13
+ permissionCheckFailed?: boolean
14
+ enabled: boolean
15
+ context?: string
16
+ subjectUID?: string
17
+ candidates: EvidenceCandidate[]
18
+ truncated?: boolean
19
+ coverageLimited?: boolean
20
+ }
21
+ export interface NATSSequence {
22
+ /** Decimal uint64 identifiers, preserved without JavaScript number rounding. */
23
+ consumerSequence?: string
24
+ streamSequence?: string
25
+ lastActive?: string
26
+ }
27
+ export interface ApplicationEvidenceResult {
28
+ adapter: EvidenceApplication
29
+ target: EvidenceTarget
30
+ observedAt: string
31
+ source: string
32
+ outcome: 'observed' | 'unavailable'
33
+ reason?: string
34
+ httpStatus?: number
35
+ facts?: {
36
+ rabbitmq?: {
37
+ diskAlarm: boolean
38
+ memoryAlarm: boolean
39
+ diskAvailableBytes?: number
40
+ diskWatermarkBytes?: number
41
+ memoryUsedBytes?: number
42
+ memoryWatermarkBytes?: number
43
+ }
44
+ vault?: { initialized: boolean; sealed: boolean; standby: boolean; performanceStandby?: boolean; haConnectionHealthy?: boolean; removedFromCluster?: boolean }
45
+ nats?: {
46
+ jetStreamEnabled: boolean
47
+ totals?: { accounts: number; streams: number; consumers: number; messages: number }
48
+ consumers: { account: string; stream: string; name: string; pending: number; ackPending: number; redelivered: number; delivered?: NATSSequence; ackFloor?: NATSSequence; waitingPullRequests?: number }[]
49
+ coverage: string
50
+ returnedAccounts: number
51
+ returnedStreams: number
52
+ returnedConsumers: number
53
+ truncated: boolean
54
+ }
55
+ }
56
+ limitations: string[]
57
+ }
58
+ export function collectApplicationEvidence(candidate: EvidenceCandidate, context: string, signal: AbortSignal) {
59
+ return fetchJSON<ApplicationEvidenceResult>('/application-evidence/collect', {
60
+ method: 'POST', signal, headers: { 'Content-Type': 'application/json' },
61
+ body: JSON.stringify({ application: candidate.application, namespace: candidate.target.namespace, pod: candidate.target.pod, uid: candidate.target.uid, context, confirmNetworkAccess: true }),
62
+ })
63
+ }
@@ -0,0 +1,22 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import { argoSyncRequestBody } from './client'
3
+
4
+ // A one-click sync (the drawer's Sync button, the create-namespace retry)
5
+ // names no prune and no options; neither may change meaning on an older Radar.
6
+ describe('argoSyncRequestBody for a sync that names no options', () => {
7
+ const vars = { namespace: 'argocd', name: 'guestbook', applicationSyncOptions: ['CreateNamespace=true'] }
8
+
9
+ it('sends prune false and lets a current Radar use the Application options', () => {
10
+ const body = argoSyncRequestBody(vars, true)
11
+ expect(body.prune).toBe(false)
12
+ expect(body.syncOptions).toBeUndefined()
13
+ })
14
+
15
+ it("sends prune false and the Application's options to an older Radar", () => {
16
+ expect(argoSyncRequestBody(vars, false)).toMatchObject({ prune: false, syncOptions: ['CreateNamespace=true'] })
17
+ })
18
+
19
+ it('keeps an explicit prune', () => {
20
+ expect(argoSyncRequestBody({ ...vars, prune: true }, false).prune).toBe(true)
21
+ })
22
+ })
@@ -0,0 +1,48 @@
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 { ClusterConnectedContext } from '../context/clusterConnected'
7
+ import { useAudit } from './client'
8
+
9
+ Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
10
+
11
+ function AuditProbe() {
12
+ useAudit([])
13
+ return null
14
+ }
15
+
16
+ afterEach(() => {
17
+ vi.unstubAllGlobals()
18
+ })
19
+
20
+ async function renderWith(connected: boolean) {
21
+ const fetchMock = vi.fn<(input: RequestInfo | URL) => Promise<Response>>(async () => new Response('{}', { status: 200, headers: { 'Content-Type': 'application/json' } }))
22
+ vi.stubGlobal('fetch', fetchMock)
23
+ const container = document.createElement('div')
24
+ const root = createRoot(container)
25
+ await act(async () => {
26
+ root.render(
27
+ <QueryClientProvider client={new QueryClient({ defaultOptions: { queries: { retry: false } } })}>
28
+ <ClusterConnectedContext.Provider value={connected}>
29
+ <AuditProbe />
30
+ </ClusterConnectedContext.Provider>
31
+ </QueryClientProvider>,
32
+ )
33
+ })
34
+ await act(async () => { await Promise.resolve() })
35
+ const auditCalls = fetchMock.mock.calls.filter(([input]) => String(input).includes('/audit')).length
36
+ act(() => root.unmount())
37
+ return auditCalls
38
+ }
39
+
40
+ describe('useAudit', () => {
41
+ it('does not ask a disconnected cluster for checks', async () => {
42
+ expect(await renderWith(false)).toBe(0)
43
+ })
44
+
45
+ it('fetches checks while connected', async () => {
46
+ expect(await renderWith(true)).toBe(1)
47
+ })
48
+ })
@@ -0,0 +1,32 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import { ApiError, kueuePositionRefetchInterval } from './client'
3
+ import { RadarFeatureUnsupportedError } from './radarFeatures'
4
+
5
+ const answer = (position?: Record<string, unknown>, eligible = true) => ({ data: { uid: 'u', eligible, position: position as never } })
6
+
7
+ describe('kueuePositionRefetchInterval', () => {
8
+ it('polls answers that change by themselves', () => {
9
+ for (const status of ['listed', 'not_listed', 'limit_reached', 'queue_unknown']) {
10
+ expect(kueuePositionRefetchInterval(answer({ status }))).toBe(30000)
11
+ }
12
+ expect(kueuePositionRefetchInterval(answer({ status: 'unavailable', code: 'read_error' }))).toBe(30000)
13
+ expect(kueuePositionRefetchInterval(answer({ status: 'unavailable', code: 'user_permission_check_failed' }))).toBe(30000)
14
+ })
15
+
16
+ it('stops on answers only a change of access or cluster resolves', () => {
17
+ for (const status of ['not_served', 'unsupported', 'no_local_queue']) {
18
+ expect(kueuePositionRefetchInterval(answer({ status }))).toBe(false)
19
+ }
20
+ for (const code of ['user_forbidden', 'radar_forbidden', 'radar_credentials_rejected']) {
21
+ expect(kueuePositionRefetchInterval(answer({ status: 'unavailable', code }))).toBe(false)
22
+ }
23
+ expect(kueuePositionRefetchInterval(answer(undefined, false))).toBe(30000)
24
+ })
25
+
26
+ it('stops on client errors and an older Radar, keeps polling through transient failures', () => {
27
+ expect(kueuePositionRefetchInterval({ error: new ApiError('forbidden', 403) })).toBe(false)
28
+ expect(kueuePositionRefetchInterval({ error: new RadarFeatureUnsupportedError('kueuePendingPosition', {}) })).toBe(false)
29
+ expect(kueuePositionRefetchInterval({ error: new ApiError('unavailable', 503) })).toBe(30000)
30
+ expect(kueuePositionRefetchInterval({ ...answer({ status: 'listed' }), error: new ApiError('unavailable', 503) })).toBe(30000)
31
+ })
32
+ })
@@ -0,0 +1,71 @@
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, expect, it, vi } from 'vitest'
6
+ import { useKueueQueueWorkloads } from './client'
7
+ import { setApiBase } from './config'
8
+
9
+ afterEach(() => {
10
+ setApiBase('/api')
11
+ vi.unstubAllGlobals()
12
+ })
13
+
14
+ const json = (body: unknown) => new Response(JSON.stringify(body), { status: 200, headers: { 'Content-Type': 'application/json' } })
15
+ const page = (names: string[], next?: string) => ({
16
+ queue: { kind: 'ClusterQueue', name: 'cq', uid: 'cq-uid' },
17
+ workloads: {
18
+ items: names.map(name => ({ namespace: 'team-a', name, uid: name, apiVersion: 'kueue.x-k8s.io/v1beta2', createdAt: null, deleting: false, membership: ['reservation'] })),
19
+ matching: 3, counts: { members: 3, submission: 0, reservation: 3, states: {} }, next,
20
+ coverage: { status: 'complete', scope: { type: 'all_namespaces' }, read: { type: 'all_namespaces' }, gaps: [] },
21
+ },
22
+ })
23
+
24
+ it.each(['supported', 'older'] as const)('reads queue Workloads page by page only from a Radar that serves them: %s', async (radar) => {
25
+ vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
26
+ setApiBase('/c/review/api')
27
+ const requests: string[] = []
28
+ vi.stubGlobal('fetch', vi.fn(async (input: string) => {
29
+ const url = new URL(input, 'http://localhost')
30
+ requests.push(url.pathname + url.search)
31
+ if (url.pathname.endsWith('/capabilities')) return json({ features: radar === 'supported' ? { kueueQueueWorkloads: true } : {} })
32
+ if (url.pathname.endsWith('/version')) return json({ currentVersion: 'v1.20.0' })
33
+ if (radar === 'older') return new Response('404 page not found\n', { status: 404, headers: { 'Content-Type': 'text/plain' } })
34
+ return json(url.searchParams.get('cursor') ? page(['c']) : page(['a', 'b'], 'next-1'))
35
+ }))
36
+ const client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
37
+ let result!: ReturnType<typeof useKueueQueueWorkloads>
38
+ function Probe() {
39
+ result = useKueueQueueWorkloads({ kind: 'ClusterQueue', name: 'cq', uid: 'cq-uid' }, { membership: 'reservation' })
40
+ return null
41
+ }
42
+ const host = document.createElement('div')
43
+ const root = createRoot(host)
44
+ const endpoint = (path: string) => path.startsWith('/c/review/api/kueue/')
45
+ try {
46
+ await act(async () => { root.render(<QueryClientProvider client={client}><Probe /></QueryClientProvider>) })
47
+ if (radar === 'older') {
48
+ // Before capabilities answer, one probe may reach the older Radar; once
49
+ // they do, it is never asked again and the upgrade note replaces the list.
50
+ await vi.waitFor(() => expect(result.upgrade).not.toBeNull())
51
+ const asked = requests.filter(endpoint).length
52
+ expect(asked).toBeLessThanOrEqual(1)
53
+ await act(async () => { await result.refetch() })
54
+ expect(requests.filter(endpoint).length).toBe(asked)
55
+ expect(result.data).toBeUndefined()
56
+ return
57
+ }
58
+ await vi.waitFor(() => expect(result.data?.pages).toHaveLength(1))
59
+ expect(result.hasNextPage).toBe(true)
60
+ await act(async () => { await result.fetchNextPage() })
61
+ await vi.waitFor(() => expect(result.data?.pages).toHaveLength(2))
62
+ expect(result.hasNextPage).toBe(false)
63
+ expect(requests.filter(endpoint)).toEqual([
64
+ '/c/review/api/kueue/clusterqueues/cq/workloads?membership=reservation',
65
+ '/c/review/api/kueue/clusterqueues/cq/workloads?membership=reservation&cursor=next-1',
66
+ ])
67
+ } finally {
68
+ act(() => root.unmount())
69
+ client.clear()
70
+ }
71
+ })
@@ -2,6 +2,9 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
2
2
  import { useQuery } from '@tanstack/react-query'
3
3
  import { useResourceAudit, useResourceEvents } from './client'
4
4
 
5
+ // These tests call the hooks outside React; the connected signal is a context read.
6
+ vi.mock('../context/clusterConnected', () => ({ useClusterConnected: () => true }))
7
+
5
8
  vi.mock('@tanstack/react-query', async (original) => ({
6
9
  ...await original<typeof import('@tanstack/react-query')>(),
7
10
  useQuery: vi.fn(() => ({})),
@@ -0,0 +1,239 @@
1
+ // @vitest-environment jsdom
2
+ import { act } from 'react'
3
+ import { createRoot } from 'react-dom/client'
4
+ import { focusManager, QueryClient, QueryClientProvider } from '@tanstack/react-query'
5
+ import { afterEach, beforeEach, expect, it, vi } from 'vitest'
6
+ import { useResourceIssues } from './client'
7
+ import { setApiBase } from './config'
8
+
9
+ interface Props { instance?: number; namespace?: string; observation?: string; enabled?: boolean; name?: string }
10
+ function Probe({ observation, enabled = true, name = 'collector', namespace = 'test' }: Props) {
11
+ const query = useResourceIssues('opentelemetrycollectors', 'opentelemetry.io', namespace, name, enabled, observation)
12
+ return <span>{query.data?.length ?? 'pending'}</span>
13
+ }
14
+
15
+ const clients: QueryClient[] = []
16
+ const roots: ReturnType<typeof createRoot>[] = []
17
+ const hosts: HTMLElement[] = []
18
+
19
+ beforeEach(() => {
20
+ vi.useFakeTimers()
21
+ vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
22
+ focusManager.setFocused(true)
23
+ setApiBase('/api')
24
+ })
25
+
26
+ afterEach(() => {
27
+ roots.splice(0).forEach(root => act(() => root.unmount()))
28
+ clients.splice(0).forEach(client => client.clear())
29
+ hosts.splice(0).forEach(host => host.remove())
30
+ focusManager.setFocused(undefined)
31
+ setApiBase('/api')
32
+ vi.unstubAllGlobals()
33
+ vi.useRealTimers()
34
+ })
35
+
36
+ async function setup(props: Props = {}, supported: boolean | 'unknown' = true) {
37
+ let endpointSupported = supported === true
38
+ let count = 1
39
+ let heldReply: Promise<Response> | undefined
40
+ const requests: string[] = []
41
+ vi.stubGlobal('fetch', vi.fn(async (input: string) => {
42
+ const path = new URL(input, 'http://localhost').pathname
43
+ requests.push(path)
44
+ if (path.includes('/issues/resource/') && !endpointSupported) return new Response('404 page not found\n', { status: 404, headers: { 'Content-Type': 'text/plain; charset=utf-8' } })
45
+ if (path.includes('/issues/resource/') && heldReply) {
46
+ const reply = heldReply
47
+ heldReply = undefined
48
+ return reply
49
+ }
50
+ const body = path.endsWith('/capabilities')
51
+ ? supported === 'unknown' ? { version: 'dev', features: {} } : { version: supported ? 'v1.18.2' : 'v1.7.0', features: { resourceIssues: supported } }
52
+ : Array.from({ length: count }, (_, index) => ({ id: String(index), message: 'Recorded failure' }))
53
+ return new Response(JSON.stringify(body), { status: 200, headers: { 'Content-Type': 'application/json' } })
54
+ }))
55
+ const client = new QueryClient({ defaultOptions: { queries: { retry: false, refetchOnWindowFocus: false } } })
56
+ if (supported === false) client.setQueryData(['version-check', '/api'], { currentVersion: 'v1.7.0' })
57
+ clients.push(client)
58
+ const host = document.createElement('div')
59
+ document.body.append(host)
60
+ hosts.push(host)
61
+ const root = createRoot(host)
62
+ roots.push(root)
63
+ async function render(next: Props) {
64
+ await act(async () => { root.render(<QueryClientProvider client={client}><Probe key={next.instance} {...next} /></QueryClientProvider>) })
65
+ }
66
+ await render(props)
67
+ if (supported === true && props.enabled !== false) await vi.waitFor(() => expect(host.textContent).toBe('1'))
68
+ const issueRequests = () => requests.filter(path => path.includes('/issues/resource/'))
69
+ const advance = async (ms: number) => { await act(async () => { await vi.advanceTimersByTimeAsync(ms) }) }
70
+ const holdNextReply = () => {
71
+ let release!: () => void
72
+ const body = JSON.stringify(Array.from({ length: count }, (_, index) => ({ id: String(index) })))
73
+ heldReply = new Promise(resolve => { release = () => resolve(new Response(body, { status: 200, headers: { 'Content-Type': 'application/json' } })) })
74
+ return release
75
+ }
76
+ return { client, host, root, render, advance, setEndpointSupported: (value: boolean) => { endpointSupported = value }, issueRequests, requests, holdNextReply, setCount: (value: number) => { count = value } }
77
+ }
78
+
79
+ it('clears an old Issue after a watched root changes without reopening', async () => {
80
+ const h = await setup({ observation: 'managed-rv' })
81
+ h.setCount(0)
82
+ await h.render({ observation: 'unmanaged-rv' })
83
+ await h.advance(10001)
84
+ expect(h.host.textContent).toBe('0')
85
+ expect(h.issueRequests()).toHaveLength(2)
86
+ })
87
+
88
+ it('coalesces watch churn and keeps one cache entry for the resource', async () => {
89
+ const h = await setup({ observation: '0' })
90
+ for (let index = 1; index <= 20; index++) {
91
+ await h.render({ observation: String(index) })
92
+ await h.advance(200)
93
+ }
94
+ expect(h.issueRequests()).toHaveLength(1)
95
+ await h.advance(6001)
96
+ expect(h.issueRequests()).toHaveLength(2)
97
+ expect(h.client.getQueryCache().findAll({ queryKey: ['issues', 'resource'] })).toHaveLength(1)
98
+ })
99
+
100
+ it('does not refresh when the observation is unchanged', async () => {
101
+ const observation = 'root-rv'
102
+ const h = await setup({ observation })
103
+ await h.render({ observation })
104
+ await h.advance(10001)
105
+ expect(h.issueRequests()).toHaveLength(1)
106
+ })
107
+
108
+ it('updates Pod-only and timer-driven findings even when the root does not change', async () => {
109
+ const h = await setup({ observation: 'same-rv' })
110
+ h.setCount(0)
111
+ await h.advance(60001)
112
+ expect(h.host.textContent).toBe('0')
113
+ expect(h.issueRequests()).toHaveLength(2)
114
+ })
115
+
116
+ it('does not poll a hidden tab', async () => {
117
+ const h = await setup({ observation: 'same-rv' })
118
+ focusManager.setFocused(false)
119
+ await h.advance(120001)
120
+ expect(h.issueRequests()).toHaveLength(1)
121
+ })
122
+
123
+ it('refreshes a hidden observation when focus returns with the production focus default off', async () => {
124
+ const h = await setup({ observation: 'first' })
125
+ focusManager.setFocused(false)
126
+ h.setCount(0)
127
+ await h.render({ observation: 'changed' })
128
+ await h.advance(10001)
129
+ expect(h.issueRequests()).toHaveLength(1)
130
+ await act(async () => { focusManager.setFocused(true) })
131
+ await h.advance(1)
132
+ expect(h.host.textContent).toBe('0')
133
+ expect(h.issueRequests()).toHaveLength(2)
134
+ })
135
+
136
+ it('does not duplicate the initial request when the root first arrives', async () => {
137
+ const h = await setup()
138
+ await h.render({ observation: 'first' })
139
+ await h.advance(10001)
140
+ expect(h.issueRequests()).toHaveLength(1)
141
+ })
142
+
143
+ it('does not refresh for a drawer transition with an unchanged root', async () => {
144
+ const h = await setup({ observation: 'first' })
145
+ await h.render({ observation: 'first', enabled: false })
146
+ await h.advance(300)
147
+ await h.render({ observation: 'first' })
148
+ await h.advance(10001)
149
+ expect(h.issueRequests()).toHaveLength(1)
150
+ })
151
+
152
+ it('does not let an older in-flight poll swallow a newer watched state', async () => {
153
+ const h = await setup({ observation: 'first' })
154
+ const release = h.holdNextReply()
155
+ await h.advance(60001)
156
+ expect(h.issueRequests()).toHaveLength(2)
157
+ h.setCount(0)
158
+ await h.render({ observation: 'changed' })
159
+ await h.advance(1)
160
+ expect(h.host.textContent).toBe('0')
161
+ await act(async () => { release() })
162
+ await h.advance(1)
163
+ expect(h.host.textContent).toBe('0')
164
+ })
165
+
166
+ it('stops pending refreshes for an inactive drawer and refreshes on reactivation', async () => {
167
+ const h = await setup({ observation: 'first' })
168
+ await h.render({ observation: 'changed' })
169
+ await h.render({ observation: 'changed', enabled: false })
170
+ await h.advance(60001)
171
+ expect(h.issueRequests()).toHaveLength(1)
172
+ h.setCount(0)
173
+ await h.render({ observation: 'changed', enabled: true })
174
+ await h.advance(10001)
175
+ expect(h.host.textContent).toBe('0')
176
+ })
177
+
178
+ it('cancels a pending refresh when the inspected resource changes', async () => {
179
+ const h = await setup({ observation: 'first' })
180
+ await h.render({ observation: 'changed' })
181
+ await h.render({ observation: 'other', name: 'other-collector' })
182
+ await h.advance(10001)
183
+ expect(h.issueRequests().filter(path => path.endsWith('/collector'))).toHaveLength(1)
184
+ expect(h.issueRequests().filter(path => path.endsWith('/other-collector'))).toHaveLength(1)
185
+ })
186
+
187
+ it('does not poll or call an unsupported resource-Issues endpoint', async () => {
188
+ const h = await setup({ observation: 'first' }, false)
189
+ await h.advance(120001)
190
+ await h.render({ observation: 'changed' })
191
+ await h.advance(10001)
192
+ expect(h.issueRequests()).toHaveLength(0)
193
+ })
194
+
195
+ // Cluster-scoped subjects require a cluster-wide Issues scan, so resource
196
+ // version churn must not turn them into automatic repeated scans.
197
+ it('does not automatically rescan cluster-scoped drawers', async () => {
198
+ const h = await setup({ namespace: '', observation: 'first' })
199
+ await h.render({ namespace: '', observation: 'changed' })
200
+ await h.advance(180001)
201
+ expect(h.issueRequests()).toHaveLength(1)
202
+ })
203
+
204
+ it('does not duplicate an in-flight reopen when a newer root arrives', async () => {
205
+ const h = await setup({ observation: 'first' })
206
+ await h.advance(31000)
207
+ const release = h.holdNextReply()
208
+ await h.render({ observation: 'first', instance: 1 })
209
+ const reopening = h.issueRequests().length
210
+ await h.render({ observation: 'changed', instance: 1 })
211
+ await h.advance(1000)
212
+ expect(h.issueRequests()).toHaveLength(reopening)
213
+ release()
214
+ await h.advance(10001)
215
+ expect(h.issueRequests()).toHaveLength(reopening + 1)
216
+ })
217
+
218
+ // An unknown-version host can initially probe an endpoint before capabilities settle.
219
+ it('does not retry an unknown-route error on focus or watch updates', async () => {
220
+ const h = await setup({ observation: 'first' }, 'unknown')
221
+ await h.advance(100)
222
+ expect(h.issueRequests()).toHaveLength(1)
223
+ focusManager.setFocused(false)
224
+ await act(async () => { focusManager.setFocused(true) })
225
+ await h.render({ observation: 'changed' })
226
+ await h.advance(120001)
227
+ expect(h.issueRequests()).toHaveLength(1)
228
+ })
229
+
230
+ it('recovers an open unsupported query when capabilities confirm support', async () => {
231
+ const h = await setup({ observation: 'first' }, 'unknown')
232
+ await h.advance(100)
233
+ expect(h.issueRequests()).toHaveLength(1)
234
+ h.setEndpointSupported(true)
235
+ await act(async () => { h.client.setQueryData(['capabilities'], { features: { resourceIssues: true } }) })
236
+ await h.advance(1)
237
+ expect(h.host.textContent).toBe('1')
238
+ expect(h.issueRequests()).toHaveLength(2)
239
+ })
@@ -16,6 +16,9 @@ import {
16
16
  useUpdateResource,
17
17
  } from './client'
18
18
 
19
+ // These tests call the hooks outside React; the connected signal is a context read.
20
+ vi.mock('../context/clusterConnected', () => ({ useClusterConnected: () => true }))
21
+
19
22
  vi.mock('@tanstack/react-query', async (original) => ({
20
23
  ...await original<typeof import('@tanstack/react-query')>(),
21
24
  useQuery: vi.fn(() => ({})),