@skyhook-io/radar-app 1.17.0 → 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 (347) hide show
  1. package/README.md +1 -1
  2. package/package.json +11 -11
  3. package/src/App.tsx +138 -116
  4. package/src/api/actions.errorCode.test.ts +40 -0
  5. package/src/api/actions.test.ts +48 -0
  6. package/src/api/actions.ts +79 -0
  7. package/src/api/apiResources.navigation.test.tsx +232 -0
  8. package/src/api/apiResources.ts +46 -3
  9. package/src/api/client.gitopsPoll.test.ts +99 -0
  10. package/src/api/client.helmPreview.test.tsx +48 -0
  11. package/src/api/client.helmSource.test.ts +39 -0
  12. package/src/api/client.namespaceSwitch.hook.test.tsx +54 -0
  13. package/src/api/client.namespaceSwitch.test.ts +107 -0
  14. package/src/api/client.resourceAvailability.test.ts +24 -0
  15. package/src/api/client.ts +580 -103
  16. package/src/api/client.workloadRuns.test.ts +53 -0
  17. package/src/api/cnpg-ha.live.test.ts +140 -0
  18. package/src/api/cnpg-ha.test.ts +78 -0
  19. package/src/api/cnpg-ha.ts +19 -0
  20. package/src/api/cnpg-history.ts +123 -0
  21. package/src/api/cnpg-inspect.ts +102 -0
  22. package/src/api/cnpg-protection.ts +112 -0
  23. package/src/api/cnpg-recovery.test.tsx +60 -0
  24. package/src/api/cnpg-recovery.ts +262 -0
  25. package/src/api/cnpg-sessions.ts +175 -0
  26. package/src/api/cnpg-storage.ts +138 -0
  27. package/src/api/cnpg.legacy-reads.test.ts +43 -0
  28. package/src/api/cnpg.pooler-runtime.test.ts +15 -0
  29. package/src/api/cnpg.ts +428 -10
  30. package/src/api/config.test.ts +23 -1
  31. package/src/api/config.ts +7 -3
  32. package/src/api/diagnose.ts +4 -1
  33. package/src/api/drain-plan.test.ts +70 -40
  34. package/src/api/policy.ts +5 -5
  35. package/src/api/radarFeatures.render.test.tsx +47 -3
  36. package/src/api/radarFeatures.ts +5 -1
  37. package/src/api/reviewedActionMutation.test.tsx +164 -0
  38. package/src/api/reviewedActionMutation.ts +66 -0
  39. package/src/api/timelineSource.test.ts +9 -0
  40. package/src/api/timelineSource.ts +8 -0
  41. package/src/api/traffic.scope.render.test.tsx +60 -0
  42. package/src/api/traffic.ts +3 -1
  43. package/src/components/audit/AuditView.tsx +9 -0
  44. package/src/components/capacity/CapacityActivity.tsx +3 -31
  45. package/src/components/capacity/CapacityDemand.tsx +4 -36
  46. package/src/components/capacity/CapacityOverview.tsx +217 -56
  47. package/src/components/capacity/CapacityPoolDetail.tsx +6 -55
  48. package/src/components/capacity/CapacityView.test.tsx +323 -0
  49. package/src/components/capacity/ClusterSchedulingCard.tsx +2 -10
  50. package/src/components/capacity/certaintyGlyph.test.tsx +2 -9
  51. package/src/components/capacity/routes.ts +42 -0
  52. package/src/components/capacity/shared.tsx +11 -129
  53. package/src/components/capacity/workspaceRoute.ts +18 -0
  54. package/src/components/cnpg/CNPGActionHost.compatibility.test.tsx +30 -0
  55. package/src/components/cnpg/CNPGArchivingRepair.tsx +191 -0
  56. package/src/components/cnpg/CNPGBlockingSessions.test.tsx +50 -0
  57. package/src/components/cnpg/CNPGBlockingSessions.tsx +333 -0
  58. package/src/components/cnpg/CNPGClusterActivity.test.tsx +11 -0
  59. package/src/components/cnpg/CNPGClusterActivity.tsx +18 -9
  60. package/src/components/cnpg/CNPGClusterLogs.compatibility.test.tsx +130 -0
  61. package/src/components/cnpg/CNPGClusterLogs.empty.test.tsx +29 -0
  62. package/src/components/cnpg/CNPGClusterLogs.test.ts +9 -0
  63. package/src/components/cnpg/CNPGClusterLogs.tsx +81 -24
  64. package/src/components/cnpg/CNPGClusterTabs.test.tsx +152 -0
  65. package/src/components/cnpg/CNPGClusterTabs.tsx +187 -0
  66. package/src/components/cnpg/CNPGClustersKindView.tsx +46 -0
  67. package/src/components/cnpg/CNPGConfiguration.test.tsx +223 -0
  68. package/src/components/cnpg/CNPGConfiguration.tsx +190 -0
  69. package/src/components/cnpg/CNPGCreateClusterDialog.test.tsx +113 -0
  70. package/src/components/cnpg/CNPGCreateClusterDialog.tsx +74 -0
  71. package/src/components/cnpg/CNPGDeclarations.test.ts +107 -0
  72. package/src/components/cnpg/CNPGDeclarations.tsx +236 -78
  73. package/src/components/cnpg/CNPGDetailPage.test.tsx +62 -0
  74. package/src/components/cnpg/CNPGDetailPage.tsx +159 -98
  75. package/src/components/cnpg/CNPGDrawerTrail.tsx +2 -2
  76. package/src/components/cnpg/CNPGInvestigationAction.test.tsx +30 -0
  77. package/src/components/cnpg/CNPGOperator.test.tsx +34 -0
  78. package/src/components/cnpg/CNPGOperator.tsx +78 -30
  79. package/src/components/cnpg/CNPGOperatorBanner.tsx +39 -0
  80. package/src/components/cnpg/CNPGOperatorConditions.test.tsx +45 -0
  81. package/src/components/cnpg/CNPGOperatorConditions.tsx +16 -0
  82. package/src/components/cnpg/CNPGOperatorConfig.test.tsx +27 -0
  83. package/src/components/cnpg/CNPGOperatorDiagnosis.tsx +247 -0
  84. package/src/components/cnpg/CNPGOverview.test.tsx +171 -0
  85. package/src/components/cnpg/CNPGOverview.tsx +238 -63
  86. package/src/components/cnpg/CNPGParametersInEffect.test.tsx +51 -0
  87. package/src/components/cnpg/CNPGParametersInEffect.tsx +120 -0
  88. package/src/components/cnpg/CNPGPerformance.prerequisite.test.tsx +48 -0
  89. package/src/components/cnpg/CNPGPerformance.test.tsx +73 -0
  90. package/src/components/cnpg/CNPGPerformance.tsx +477 -0
  91. package/src/components/cnpg/CNPGPooling.test.tsx +89 -0
  92. package/src/components/cnpg/CNPGPooling.tsx +97 -40
  93. package/src/components/cnpg/CNPGProtection.test.tsx +145 -0
  94. package/src/components/cnpg/CNPGProtection.tsx +228 -122
  95. package/src/components/cnpg/CNPGReplicationTab.test.tsx +87 -0
  96. package/src/components/cnpg/CNPGReplicationTab.tsx +212 -0
  97. package/src/components/cnpg/CNPGReplicationView.tsx +264 -0
  98. package/src/components/cnpg/CNPGStorage.test.tsx +140 -0
  99. package/src/components/cnpg/CNPGStorage.tsx +619 -0
  100. package/src/components/cnpg/CNPGSummaryHost.overview.test.tsx +44 -0
  101. package/src/components/cnpg/CNPGSummaryHost.test.tsx +23 -0
  102. package/src/components/cnpg/CNPGSummaryHost.tsx +230 -55
  103. package/src/components/cnpg/CNPGTrends.denied.test.tsx +33 -0
  104. package/src/components/cnpg/CNPGTrends.missing.test.tsx +69 -0
  105. package/src/components/cnpg/CNPGTrends.test.ts +38 -0
  106. package/src/components/cnpg/CNPGTrends.tsx +702 -0
  107. package/src/components/cnpg/CNPGView.tsx +34 -21
  108. package/src/components/cnpg/CNPGWorkspace.compatibility.test.tsx +90 -0
  109. package/src/components/cnpg/actions/CNPGClusterActions.dialog.test.tsx +79 -0
  110. package/src/components/cnpg/actions/CNPGClusterActions.test.tsx +142 -0
  111. package/src/components/cnpg/actions/CNPGClusterActions.tsx +853 -0
  112. package/src/components/cnpg/actions/CNPGConnectButton.read.test.tsx +40 -0
  113. package/src/components/cnpg/actions/CNPGConnectButton.test.ts +25 -0
  114. package/src/components/cnpg/actions/CNPGConnectButton.tsx +131 -0
  115. package/src/components/cnpg/actions/CNPGDestroyInstanceDialog.tsx +185 -0
  116. package/src/components/cnpg/actions/CNPGInstanceActions.test.tsx +38 -0
  117. package/src/components/cnpg/actions/CNPGInstanceActions.tsx +74 -0
  118. package/src/components/cnpg/actions/CNPGMaintenanceBanner.tsx +53 -0
  119. package/src/components/cnpg/actions/CNPGPoolerActions.test.tsx +35 -0
  120. package/src/components/cnpg/actions/CNPGPoolerActions.tsx +79 -0
  121. package/src/components/cnpg/actions/CNPGReportDialog.test.tsx +12 -0
  122. package/src/components/cnpg/actions/CNPGReportDialog.tsx +91 -0
  123. package/src/components/cnpg/actions/CNPGScheduleActions.run.test.tsx +58 -0
  124. package/src/components/cnpg/actions/CNPGScheduleActions.test.tsx +54 -0
  125. package/src/components/cnpg/actions/CNPGScheduleActions.tsx +208 -0
  126. package/src/components/cnpg/actions/actionModel.test.ts +111 -0
  127. package/src/components/cnpg/actions/actionModel.ts +127 -0
  128. package/src/components/cnpg/actions/renderCNPGHeaderActions.tsx +60 -0
  129. package/src/components/cnpg/actions/useCNPGWriteGuard.tsx +58 -0
  130. package/src/components/cnpg/actions/useOpenCNPGPsql.ts +22 -0
  131. package/src/components/cnpg/archivingRepair.test.ts +104 -0
  132. package/src/components/cnpg/archivingRepair.ts +145 -0
  133. package/src/components/cnpg/baseBackup.test.ts +36 -0
  134. package/src/components/cnpg/baseBackup.ts +36 -0
  135. package/src/components/cnpg/blocking.test.ts +59 -0
  136. package/src/components/cnpg/blocking.ts +131 -0
  137. package/src/components/cnpg/coverageText.test.ts +27 -0
  138. package/src/components/cnpg/creation/CNPGTargetFields.tsx +110 -0
  139. package/src/components/cnpg/creation/targetModel.test.ts +137 -0
  140. package/src/components/cnpg/creation/targetModel.ts +149 -0
  141. package/src/components/cnpg/fleetStatus.test.ts +46 -0
  142. package/src/components/cnpg/fleetStatus.ts +43 -0
  143. package/src/components/cnpg/formFields.ts +2 -0
  144. package/src/components/cnpg/grantText.test.tsx +11 -0
  145. package/src/components/cnpg/host.test.tsx +24 -0
  146. package/src/components/cnpg/host.tsx +101 -0
  147. package/src/components/cnpg/inspectModel.test.ts +120 -0
  148. package/src/components/cnpg/inspectModel.ts +140 -0
  149. package/src/components/cnpg/logicalSlots.test.ts +30 -0
  150. package/src/components/cnpg/logicalSlots.ts +29 -0
  151. package/src/components/cnpg/lsn.test.ts +40 -0
  152. package/src/components/cnpg/lsn.ts +43 -0
  153. package/src/components/cnpg/operations/CNPGFleetOperation.tsx +30 -0
  154. package/src/components/cnpg/operations/CNPGOperationTracker.test.tsx +247 -0
  155. package/src/components/cnpg/operations/CNPGOperationTracker.tsx +255 -0
  156. package/src/components/cnpg/operations/model.test.ts +510 -0
  157. package/src/components/cnpg/operations/model.ts +499 -0
  158. package/src/components/cnpg/operations/presentation.test.ts +80 -0
  159. package/src/components/cnpg/operations/presentation.ts +84 -0
  160. package/src/components/cnpg/operations/store.ts +98 -0
  161. package/src/components/cnpg/operatorStatus.test.ts +134 -0
  162. package/src/components/cnpg/operatorStatus.ts +194 -0
  163. package/src/components/cnpg/paths.test.ts +54 -0
  164. package/src/components/cnpg/paths.ts +47 -4
  165. package/src/components/cnpg/protection/CNPGAttachArchiveDialog.tsx +185 -0
  166. package/src/components/cnpg/protection/CNPGCreateScheduleDialog.tsx +196 -0
  167. package/src/components/cnpg/protection/CNPGProtectionSetup.test.tsx +121 -0
  168. package/src/components/cnpg/protection/CNPGProtectionSetup.tsx +452 -0
  169. package/src/components/cnpg/protection/CNPGScheduleInput.tsx +115 -0
  170. package/src/components/cnpg/protection/CNPGScheduleRepairButton.tsx +120 -0
  171. package/src/components/cnpg/protection/scheduleModel.test.ts +19 -0
  172. package/src/components/cnpg/protection/scheduleModel.ts +16 -0
  173. package/src/components/cnpg/recovery/CNPGRecoveryPoint.tsx +220 -0
  174. package/src/components/cnpg/recovery/CNPGRestoreButton.test.tsx +29 -0
  175. package/src/components/cnpg/recovery/CNPGRestoreButton.tsx +26 -0
  176. package/src/components/cnpg/recovery/CNPGRestoreChecks.test.tsx +23 -0
  177. package/src/components/cnpg/recovery/CNPGRestoreChecks.tsx +153 -0
  178. package/src/components/cnpg/recovery/CNPGRestoreDialog.back.test.tsx +149 -0
  179. package/src/components/cnpg/recovery/CNPGRestoreDialog.test.tsx +46 -0
  180. package/src/components/cnpg/recovery/CNPGRestoreDialog.tsx +333 -0
  181. package/src/components/cnpg/recovery/CNPGRestoreProgress.tsx +182 -0
  182. package/src/components/cnpg/recovery/CNPGRestoreValidation.tsx +216 -0
  183. package/src/components/cnpg/recovery/restoreModel.test.ts +709 -0
  184. package/src/components/cnpg/recovery/restoreModel.ts +685 -0
  185. package/src/components/cnpg/recovery/restoreOperation.ts +56 -0
  186. package/src/components/cnpg/refresh.test.ts +38 -0
  187. package/src/components/cnpg/refresh.ts +17 -0
  188. package/src/components/cnpg/refreshNotice.test.tsx +29 -0
  189. package/src/components/cnpg/routes.test.ts +34 -3
  190. package/src/components/cnpg/routes.ts +60 -48
  191. package/src/components/cnpg/runtimeAssessment.ts +198 -0
  192. package/src/components/cnpg/runtimeModel.test.ts +175 -0
  193. package/src/components/cnpg/runtimeModel.ts +196 -0
  194. package/src/components/cnpg/runtimeParts.test.tsx +17 -0
  195. package/src/components/cnpg/runtimeParts.tsx +79 -0
  196. package/src/components/cnpg/shared.test.tsx +59 -0
  197. package/src/components/cnpg/shared.tsx +100 -182
  198. package/src/components/cnpg/storageModel.test.ts +107 -0
  199. package/src/components/cnpg/storageModel.ts +101 -0
  200. package/src/components/cnpg/trendSamples.test.ts +148 -0
  201. package/src/components/cnpg/trendSamples.ts +222 -0
  202. package/src/components/cnpg/useCNPGClusterAssessment.ts +30 -0
  203. package/src/components/cnpg/useCNPGKubectlContext.test.tsx +45 -0
  204. package/src/components/cnpg/useCNPGKubectlContext.ts +13 -0
  205. package/src/components/cnpg/useCNPGNavigate.test.tsx +58 -0
  206. package/src/components/cnpg/useCNPGNavigate.ts +21 -0
  207. package/src/components/cnpg/useCNPGPoolerLive.ts +46 -0
  208. package/src/components/cnpg/useCNPGScreenParams.ts +24 -0
  209. package/src/components/cnpg/useCNPGSidebarWorkspace.ts +66 -16
  210. package/src/components/cnpg/workspaceRoute.ts +23 -0
  211. package/src/components/cost/ApplicationCostTab.test.ts +7 -0
  212. package/src/components/cost/ApplicationCostTab.tsx +7 -7
  213. package/src/components/cost/CostView.test.ts +2 -1
  214. package/src/components/cost/CostView.tsx +0 -2
  215. package/src/components/cost/WorkloadCostTab.tsx +2 -4
  216. package/src/components/cost/errors.ts +3 -1
  217. package/src/components/cost/source.test.ts +10 -0
  218. package/src/components/cost/source.ts +5 -1
  219. package/src/components/diagnose/DiagnoseSurface.tsx +3 -3
  220. package/src/components/diagnose/InvestigationChangesEvidence.test.tsx +352 -0
  221. package/src/components/diagnose/InvestigationEvidencePane.test.tsx +101 -0
  222. package/src/components/diagnose/InvestigationView.tsx +2 -1
  223. package/src/components/diagnose/investigationEvidence/adapters/changes.test.ts +123 -0
  224. package/src/components/diagnose/investigationEvidence/adapters/changes.ts +192 -3
  225. package/src/components/diagnose/investigationEvidence/adapters/issues.ts +73 -43
  226. package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +64 -2
  227. package/src/components/diagnose/investigationEvidence/adapters/resource.test.ts +37 -0
  228. package/src/components/diagnose/investigationEvidence/adapters/testdata/get-changes-created.json +323 -0
  229. package/src/components/diagnose/investigationEvidence/bodies/streams.tsx +144 -15
  230. package/src/components/diagnose/investigationEvidence/observations.ts +20 -0
  231. package/src/components/diagnose/investigationEvidence/parse.ts +57 -1
  232. package/src/components/diagnose/investigationEvidence/projection.test.ts +123 -0
  233. package/src/components/diagnose/investigationEvidence/types.ts +11 -0
  234. package/src/components/diagnose/investigationEvidencePresentation.test.ts +18 -0
  235. package/src/components/diagnose/investigationState.test.ts +36 -1
  236. package/src/components/diagnose/investigationState.ts +8 -0
  237. package/src/components/diagnose/launch.ts +2 -2
  238. package/src/components/dock/BottomDock.tsx +8 -3
  239. package/src/components/dock/TerminalTab.test.tsx +17 -0
  240. package/src/components/dock/TerminalTab.tsx +7 -3
  241. package/src/components/dock/WorkloadLogsTab.tsx +3 -0
  242. package/src/components/execution/BatchExecutionView.render.test.tsx +29 -1
  243. package/src/components/execution/BatchExecutionView.tsx +23 -8
  244. package/src/components/execution/cluster-template-runs.render.test.tsx +42 -0
  245. package/src/components/gitops/ArgoResourceDiffLoader.tsx +4 -2
  246. package/src/components/gitops/GitOpsView.tsx +23 -23
  247. package/src/components/helm/HelmCompareRoute.test.tsx +59 -0
  248. package/src/components/helm/HelmCompareRoute.tsx +57 -26
  249. package/src/components/helm/HelmReleaseDrawer.test.ts +55 -3
  250. package/src/components/helm/HelmReleaseDrawer.tsx +186 -64
  251. package/src/components/helm/HelmReleaseNotes.test.tsx +42 -0
  252. package/src/components/helm/HelmReleaseNotes.tsx +26 -0
  253. package/src/components/helm/OwnedResources.tsx +2 -2
  254. package/src/components/helm/TrackChartSourceDialog.render.test.tsx +192 -0
  255. package/src/components/helm/TrackChartSourceDialog.test.ts +51 -0
  256. package/src/components/helm/TrackChartSourceDialog.tsx +179 -176
  257. package/src/components/helm/ValuesDiffPreview.tsx +4 -1
  258. package/src/components/helm/ValuesViewer.test.tsx +301 -0
  259. package/src/components/helm/ValuesViewer.tsx +169 -78
  260. package/src/components/home/ActivitySummary.tsx +2 -1
  261. package/src/components/home/ClusterHealthCard.tsx +4 -4
  262. package/src/components/home/CostCard.test.tsx +100 -0
  263. package/src/components/home/CostCard.tsx +2 -2
  264. package/src/components/home/HelmSummary.tsx +2 -2
  265. package/src/components/home/HomeView.tsx +32 -12
  266. package/src/components/home/MCPSetupDialog.test.tsx +30 -0
  267. package/src/components/home/MCPSetupDialog.tsx +13 -6
  268. package/src/components/home/ProblemsPanel.test.tsx +82 -0
  269. package/src/components/home/TopologyPreview.tsx +2 -2
  270. package/src/components/home/mcpToolCatalog.ts +18 -2
  271. package/src/components/issues/IssuesPane.render.test.tsx +143 -0
  272. package/src/components/issues/IssuesPane.test.ts +65 -1
  273. package/src/components/issues/IssuesPane.tsx +213 -26
  274. package/src/components/issues/UncheckedSourceHelp.test.tsx +42 -0
  275. package/src/components/issues/UncheckedSourceHelp.tsx +24 -0
  276. package/src/components/issues/uncheckedSources.test.ts +43 -0
  277. package/src/components/issues/uncheckedSources.ts +74 -0
  278. package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +4 -2
  279. package/src/components/resource/PVCUsageBar.render.test.tsx +32 -0
  280. package/src/components/resource/PVCUsageBar.test.tsx +24 -0
  281. package/src/components/resource/PVCUsageBar.tsx +15 -6
  282. package/src/components/resource/WorkloadMetricsHelpDialog.test.tsx +3 -1
  283. package/src/components/resource/WorkloadMetricsHelpDialog.tsx +1 -1
  284. package/src/components/resources/CompositeRenderer.tsx +4 -4
  285. package/src/components/resources/ImageFilesystemModal.test.tsx +68 -0
  286. package/src/components/resources/ImageFilesystemModal.tsx +11 -4
  287. package/src/components/resources/PodFilesystemModal.tsx +2 -2
  288. package/src/components/resources/ResourceDetailDrawer.tsx +2 -2
  289. package/src/components/resources/ResourcesView.scope.render.test.tsx +58 -0
  290. package/src/components/resources/ResourcesView.tsx +44 -15
  291. package/src/components/resources/renderers/FluxHelmReleaseRenderer.test.tsx +111 -0
  292. package/src/components/resources/renderers/FluxHelmReleaseRenderer.tsx +67 -0
  293. package/src/components/resources/renderers/KyvernoPolicyCoverage.scope.render.test.tsx +64 -0
  294. package/src/components/resources/renderers/KyvernoPolicyCoverage.tsx +6 -7
  295. package/src/components/settings/LocalIntegrationStatus.test.tsx +52 -0
  296. package/src/components/settings/LocalIntegrationStatus.tsx +3 -4
  297. package/src/components/settings/SettingsDialog.tsx +49 -30
  298. package/src/components/timeline/TimelineList.tsx +22 -24
  299. package/src/components/timeline/TimelineLoadError.test.tsx +62 -0
  300. package/src/components/timeline/TimelineLoadError.tsx +96 -0
  301. package/src/components/timeline/TimelineView.tsx +18 -45
  302. package/src/components/timeline/ViewModeToggle.tsx +20 -0
  303. package/src/components/timeline/useStickyError.test.tsx +47 -0
  304. package/src/components/timeline/useStickyError.ts +15 -0
  305. package/src/components/traffic/TrafficFilterSidebar.test.tsx +77 -0
  306. package/src/components/traffic/TrafficFilterSidebar.tsx +42 -31
  307. package/src/components/traffic/TrafficView.tsx +12 -12
  308. package/src/components/traffic/trafficFilters.test.ts +20 -1
  309. package/src/components/traffic/trafficFilters.ts +13 -0
  310. package/src/components/ui/DiagnosticsOverlay.tsx +34 -2
  311. package/src/components/ui/Markdown.test.tsx +65 -0
  312. package/src/components/ui/Markdown.tsx +144 -127
  313. package/src/components/ui/Omnibar.tsx +13 -2
  314. package/src/components/ui/Toast.tsx +1 -1
  315. package/src/components/ui/omnibar-match.test.ts +30 -0
  316. package/src/components/ui/omnibar-match.ts +18 -0
  317. package/src/components/whats-new/releaseNotes.ts +63 -1
  318. package/src/components/workload/CronJobSchedulingEvidence.test.tsx +35 -0
  319. package/src/components/workload/CronJobSchedulingEvidence.tsx +37 -0
  320. package/src/components/workload/NodeDrainStatus.test.tsx +253 -0
  321. package/src/components/workload/NodeDrainStatus.tsx +55 -0
  322. package/src/components/workload/WorkloadView.test.ts +10 -1
  323. package/src/components/workload/WorkloadView.tsx +63 -243
  324. package/src/components/workspace/layout.test.tsx +29 -0
  325. package/src/components/workspace/layout.tsx +259 -0
  326. package/src/components/workspace/table.ts +7 -0
  327. package/src/context/ConnectionContext.test.ts +27 -1
  328. package/src/context/ConnectionContext.tsx +17 -7
  329. package/src/contexts/CapabilitiesContext.tsx +1 -1
  330. package/src/integrations/resourceHost.test.tsx +55 -0
  331. package/src/integrations/resourceHost.ts +99 -0
  332. package/src/integrations/resourceHosts.test.tsx +142 -0
  333. package/src/integrations/resourceHosts.tsx +121 -0
  334. package/src/integrations/workspaceRoute.ts +20 -0
  335. package/src/integrations/workspaceRoutes.test.ts +40 -0
  336. package/src/integrations/workspaceRoutes.ts +22 -0
  337. package/src/integrations/workspaceScreens.tsx +14 -0
  338. package/src/utils/drawer-trail.ts +35 -0
  339. package/src/utils/kindFilterStore.test.ts +147 -0
  340. package/src/utils/kindFilterStore.ts +91 -0
  341. package/src/utils/navigation.test.ts +13 -1
  342. package/src/utils/navigation.ts +53 -2
  343. package/src/utils/page-links.ts +21 -0
  344. package/src/utils/tabStorage.ts +40 -0
  345. package/src/utils/viewMemory.test.ts +78 -0
  346. package/src/utils/viewMemory.ts +54 -0
  347. package/src/utils/wails-clipboard.ts +4 -2
@@ -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>(
@@ -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, useWorkloadHistory } from './client'
7
+ import { ApiError, isNotFoundError, useApplications, useCapacityPoolDetail, useDrainPlan, useNodeRemovalPlan, usePodEnvironment, useSubjectIssues, useWorkloadHistory } from './client'
8
8
  import { getApiBase } from './config'
9
9
  import { usePolicyResource } from './policy'
10
10
  import { isRadarFeatureUnsupported } from './radarFeatures'
@@ -35,6 +35,7 @@ beforeEach(() => {
35
35
  if (url.includes('/capacity/pools/')) return Promise.resolve(Response.json({ pool: { name: 'default' } }))
36
36
  if (url.endsWith('/environment')) return Promise.resolve(Response.json({ containers: [], coverage: {} }))
37
37
  if (url.includes('/policy/resource/')) return Promise.resolve(Response.json({ evaluated: true, status: 'ready' }))
38
+ if (url.includes('/issues/resource/')) return Promise.resolve(Response.json({ issues: [], coverage: 'ok' }))
38
39
  return new Promise<Response>(() => {})
39
40
  }))
40
41
  element = document.createElement('div')
@@ -73,6 +74,49 @@ function Policy() {
73
74
  return <span>{data?.status ?? (getRadarUpgradeRequirement(error) ? 'upgrade' : 'pending')}</span>
74
75
  }
75
76
 
77
+ function SubjectIssues() {
78
+ const { data, error } = useSubjectIssues({ kind: 'Pod', group: '', namespace: 'shop', name: 'web' }, true)
79
+ return <span>{data ? 'data' : getRadarUpgradeRequirement(error) ? 'upgrade' : error ? 'unconfirmed' : 'pending'}</span>
80
+ }
81
+
82
+ it('waits for coverage capabilities instead of probing an older array-shaped issues route', async () => {
83
+ await render(<SubjectIssues />)
84
+ expect(element.textContent).toBe('pending')
85
+ expect(asked('/issues/resource/')).toBe(false)
86
+
87
+ await act(async () => { client.setQueryData(['capabilities'], { features: { resourceIssues: true } }) })
88
+ await settle()
89
+ await settle()
90
+ expect(element.textContent).toBe('upgrade')
91
+ expect(asked('/issues/resource/')).toBe(false)
92
+
93
+ await act(async () => { client.setQueryData(['capabilities'], { features: { resourceIssueCoverage: true } }) })
94
+ await settle()
95
+ await settle()
96
+ expect(element.textContent).toBe('data')
97
+ expect(asked('/issues/resource/')).toBe(true)
98
+ })
99
+
100
+ it('leaves issue coverage unconfirmed after a failed capability check and recovers when it succeeds', async () => {
101
+ const answer = vi.mocked(fetch).getMockImplementation()!
102
+ vi.mocked(fetch).mockImplementation((input, init) =>
103
+ String(input).endsWith('/capabilities')
104
+ ? Promise.resolve(Response.json({ error: 'capabilities unavailable' }, { status: 503 }))
105
+ : answer(input, init),
106
+ )
107
+ await render(<SubjectIssues />)
108
+ await settle()
109
+ await settle()
110
+ expect(element.textContent).toBe('unconfirmed')
111
+ expect(asked('/issues/resource/')).toBe(false)
112
+
113
+ await act(async () => { client.setQueryData(['capabilities'], { features: { resourceIssueCoverage: true } }) })
114
+ await settle()
115
+ await settle()
116
+ expect(element.textContent).toBe('data')
117
+ expect(asked('/issues/resource/')).toBe(true)
118
+ })
119
+
76
120
  it('fetches for real once the agent turns out to advertise the feature', async () => {
77
121
  await render(<Environment />)
78
122
  expect(element.textContent).toBe('upgrade')
@@ -90,14 +134,14 @@ it('turns an unsupported policy answer into not installed once discovery shows n
90
134
  // No upgrade note yet: discovery may still withdraw it.
91
135
  expect(element.textContent).toBe('loading')
92
136
 
93
- await act(async () => { client.setQueryData(['api-resources'], [{ group: '', name: 'pods' }]) })
137
+ await act(async () => { client.setQueryData(['api-resources'], [{ group: '', version: 'v1', kind: 'Pod', name: 'pods', namespaced: true, isCrd: false, verbs: ['get', 'list', 'watch'] }]) })
94
138
  await settle()
95
139
  expect(element.textContent).toBe('not_installed')
96
140
  expect(asked('/policy/resource/')).toBe(false)
97
141
  })
98
142
 
99
143
  it('keeps the upgrade note when discovery shows an OpenReports policy engine', async () => {
100
- client.setQueryData(['api-resources'], [{ group: 'openreports.io', name: 'reports' }])
144
+ client.setQueryData(['api-resources'], [{ group: 'openreports.io', version: 'v1alpha1', kind: 'Report', name: 'reports', namespaced: true, isCrd: true, verbs: ['get', 'list', 'watch'] }])
101
145
  await render(<Policy />)
102
146
  expect(element.textContent).toBe('upgrade')
103
147
  })
@@ -28,6 +28,7 @@ export interface RadarFeatureSpec {
28
28
 
29
29
  export const RADAR_FEATURES = {
30
30
  resourceIssues: { label: 'Operational issues', minimumVersion: 'v1.8.0', flag: 'resourceIssues' },
31
+ resourceIssueCoverage: { label: 'Resource-specific issue views', flag: 'resourceIssueCoverage', flagShippedWithEndpoint: true },
31
32
  podEnvironment: { label: 'Values from ConfigMaps and Secrets', minimumVersion: 'v1.9.0', flag: 'podEnvironment' },
32
33
  policyResource: { label: 'Policy results', minimumVersion: 'v1.10.0', flag: 'policyResource' },
33
34
  capacity: { label: 'Capacity views', minimumVersion: 'v1.9.0' },
@@ -35,9 +36,12 @@ export const RADAR_FEATURES = {
35
36
  drainPlan: { label: 'Drain plans', minimumVersion: 'v1.14.0' },
36
37
  applications: { label: 'Applications', minimumVersion: 'v1.7.7' },
37
38
  workloadHistory: { label: 'Workload history', flag: 'workloadHistory', flagShippedWithEndpoint: true },
39
+ cnpgWorkspace: { label: 'CloudNativePG views', flag: 'cnpgWorkspace', flagShippedWithEndpoint: true },
40
+ cnpgProtectionSetup: { label: 'CloudNativePG backup setup', flag: 'cnpgProtectionSetup', flagShippedWithEndpoint: true },
41
+ gitopsWriteEvidence: { label: 'GitOps revert warnings', flag: 'gitopsWriteEvidence', flagShippedWithEndpoint: true },
38
42
  serviceEndpointSlices: { label: 'Service EndpointSlice inventories', flag: 'serviceEndpointSlices', flagShippedWithEndpoint: true },
39
43
  trafficRecords: { label: 'Flow records for a graph selection', flag: 'trafficRecords', flagShippedWithEndpoint: true },
40
- gitopsWriteEvidence: { label: 'GitOps revert warnings', flag: 'gitopsWriteEvidence', flagShippedWithEndpoint: true },
44
+ helmSourceIdentity: { label: 'Helm source selection', flag: 'helmSourceIdentity', flagShippedWithEndpoint: true },
41
45
  } as const satisfies Record<string, RadarFeatureSpec>
42
46
 
43
47
  export type RadarFeature = keyof typeof RADAR_FEATURES
@@ -0,0 +1,164 @@
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 { describe, expect, it, vi } from 'vitest'
6
+ import { useReviewedActionMutation } from './reviewedActionMutation'
7
+ import { ApiError } from './client'
8
+ import { actionErrorCode, actionCompleted } from './actions'
9
+ import { RadarFeatureUnsupportedError } from './radarFeatures'
10
+
11
+ ;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true
12
+
13
+ describe('reviewed action lifetime', () => {
14
+ it.each([
15
+ new TypeError('Connection lost'),
16
+ new ApiError('One write completed', 409, { code: 'partial', completed: ['Pod removed'] }),
17
+ new ApiError('upstream connect error or disconnect/reset before headers', 503),
18
+ ])('retains an ambiguous result through remount and prevents another request: %s', async (failure) => {
19
+ const client = new QueryClient({ defaultOptions: { queries: { retry: false }, mutations: { retry: false } } })
20
+ const host = document.body.appendChild(document.createElement('div'))
21
+ const root = createRoot(host)
22
+ const request = vi.fn(async () => { throw failure })
23
+ let current: ReturnType<typeof useReviewedActionMutation<null, { request: { reviewedContext: string } }>>
24
+ function Dialog({ target }: { target: string }) {
25
+ current = useReviewedActionMutation<null, { request: { reviewedContext: string } }>(target, 'ctx', { mutationFn: request })
26
+ return <div>{current.outcomeError?.message}</div>
27
+ }
28
+ const mount = (target?: string) => act(() => root.render(<QueryClientProvider client={client}>{target && <Dialog target={target} />}</QueryClientProvider>))
29
+ const attempt = () => act(async () => {
30
+ await current.mutateAsync({ request: { reviewedContext: 'ctx' } }).catch(() => {})
31
+ await new Promise(resolve => setTimeout(resolve, 0))
32
+ })
33
+ try {
34
+ mount('/api/cnpg/clusters/jobs/orders')
35
+ await attempt()
36
+ mount()
37
+ client.removeQueries()
38
+ client.clear()
39
+ mount('/api/cnpg/clusters/jobs/orders')
40
+ expect(current!.outcomeError?.message).toContain('reload this page')
41
+ expect(actionErrorCode(current!.outcomeError)).toBe(actionErrorCode(failure))
42
+ expect(actionCompleted(current!.outcomeError)).toEqual(actionCompleted(failure))
43
+ await attempt()
44
+ expect(request).toHaveBeenCalledTimes(1)
45
+ mount('/other-cluster/api/cnpg/clusters/jobs/orders')
46
+ expect(current!.outcomeError).toBeNull()
47
+ mount('/api/cnpg/scheduledbackups/jobs/orders')
48
+ expect(current!.outcomeError).toBeNull()
49
+ } finally {
50
+ act(() => root.unmount())
51
+ client.clear()
52
+ host.remove()
53
+ }
54
+ })
55
+ it.each([
56
+ { nextTarget: '/api/target', nextContext: 'other-context' },
57
+ { nextTarget: '/other-cluster/api/target', nextContext: 'ctx' },
58
+ ])('keeps a late result on the original cluster binding: %s', async ({ nextTarget, nextContext }) => {
59
+ const client = new QueryClient()
60
+ const host = document.body.appendChild(document.createElement('div'))
61
+ const root = createRoot(host)
62
+ let fail!: (error: Error) => void
63
+ let current: ReturnType<typeof useReviewedActionMutation<null, { request: { reviewedContext: string } }>>
64
+ function Dialog({ target, context }: { target: string; context: string }) {
65
+ current = useReviewedActionMutation<null, { request: { reviewedContext: string } }>(target, context, {
66
+ mutationFn: () => new Promise<null>((_, reject) => { fail = reject }),
67
+ })
68
+ return null
69
+ }
70
+ const mount = (target: string, context: string) => act(() => root.render(<QueryClientProvider client={client}><Dialog target={target} context={context} /></QueryClientProvider>))
71
+ try {
72
+ mount('/api/target', 'ctx')
73
+ let attempted!: Promise<unknown>
74
+ await act(async () => {
75
+ attempted = current.mutateAsync({ request: { reviewedContext: 'ctx' } }).catch(() => {})
76
+ await Promise.resolve()
77
+ })
78
+ mount(nextTarget, nextContext)
79
+ await act(async () => {
80
+ fail(new TypeError('Connection lost'))
81
+ await attempted
82
+ await new Promise(resolve => setTimeout(resolve, 0))
83
+ })
84
+ expect(current!.outcomeError).toBeNull()
85
+ mount('/api/target', 'ctx')
86
+ expect(current!.outcomeError?.message).toContain('Connection lost')
87
+ } finally {
88
+ act(() => root.unmount())
89
+ client.clear()
90
+ host.remove()
91
+ }
92
+ })
93
+ it.each([
94
+ new ApiError('Facts changed', 409, { code: 'changed' }),
95
+ new ApiError('The operator webhook did not answer', 503, { code: 'operator_webhook_unavailable' }),
96
+ new RadarFeatureUnsupportedError('cnpgWorkspace', {}),
97
+ ])('keeps a known refusal retryable after remount: %s', async (failure) => {
98
+ const client = new QueryClient()
99
+ const host = document.body.appendChild(document.createElement('div'))
100
+ const root = createRoot(host)
101
+ let current: ReturnType<typeof useReviewedActionMutation<null, { request: { reviewedContext: string } }>>
102
+ const request = vi.fn(async () => { throw failure })
103
+ function Dialog() {
104
+ current = useReviewedActionMutation<null, { request: { reviewedContext: string } }>('/api/target', 'ctx', { mutationFn: request })
105
+ return null
106
+ }
107
+ const render = (open: boolean) => act(() => root.render(<QueryClientProvider client={client}>{open && <Dialog />}</QueryClientProvider>))
108
+ try {
109
+ render(true)
110
+ await act(async () => { await current.mutateAsync({ request: { reviewedContext: 'ctx' } }).catch(() => {}) })
111
+ render(false)
112
+ render(true)
113
+ expect(current!.outcomeError).toBeNull()
114
+ await act(async () => { await current.mutateAsync({ request: { reviewedContext: 'ctx' } }).catch(() => {}) })
115
+ expect(request).toHaveBeenCalledTimes(2)
116
+ } finally {
117
+ act(() => root.unmount())
118
+ client.clear()
119
+ host.remove()
120
+ }
121
+ })
122
+
123
+ it('retains an in-flight request through remount and cache clearing without sending twice', async () => {
124
+ const client = new QueryClient()
125
+ const host = document.body.appendChild(document.createElement('div'))
126
+ const root = createRoot(host)
127
+ let complete!: (data: null) => void
128
+ const request = vi.fn(() => new Promise<null>(resolve => { complete = resolve }))
129
+ let current: ReturnType<typeof useReviewedActionMutation<null, { request: { reviewedContext: string } }>>
130
+ function Dialog() {
131
+ current = useReviewedActionMutation<null, { request: { reviewedContext: string } }>('/api/target', 'ctx', { mutationFn: request })
132
+ return null
133
+ }
134
+ const render = (open: boolean) => act(() => root.render(<QueryClientProvider client={client}>{open && <Dialog />}</QueryClientProvider>))
135
+ try {
136
+ render(true)
137
+ let attempted!: Promise<null>
138
+ await act(async () => {
139
+ attempted = current.mutateAsync({ request: { reviewedContext: 'ctx' } })
140
+ await Promise.resolve()
141
+ })
142
+ render(false)
143
+ client.removeQueries()
144
+ client.clear()
145
+ render(true)
146
+ expect(current!.isPending).toBe(true)
147
+ await act(async () => {
148
+ await expect(current.mutateAsync({ request: { reviewedContext: 'ctx' } })).rejects.toThrow('still in progress')
149
+ })
150
+ expect(request).toHaveBeenCalledTimes(1)
151
+ await act(async () => {
152
+ complete(null)
153
+ await attempted
154
+ await new Promise(resolve => setTimeout(resolve, 0))
155
+ })
156
+ expect(current!.isPending).toBe(false)
157
+ expect(current!.outcomeError).toBeNull()
158
+ } finally {
159
+ act(() => root.unmount())
160
+ client.clear()
161
+ host.remove()
162
+ }
163
+ })
164
+ })
@@ -0,0 +1,66 @@
1
+ import { useCallback, useSyncExternalStore } from 'react'
2
+ import { useMutation, useQueryClient, type MutationFunction, type QueryClient, type UseMutationOptions } from '@tanstack/react-query'
3
+ import { actionOutcomeLocked } from './actions'
4
+ import { ApiError } from './client'
5
+
6
+ interface Outcome {
7
+ pending: boolean
8
+ error: Error | null
9
+ }
10
+ const EMPTY: Outcome = { pending: false, error: null }
11
+ const stores = new WeakMap<QueryClient, { entries: Map<string, Outcome>; listeners: Set<() => void> }>()
12
+
13
+ /** Result memory belongs to the host, so dismissing a dialog cannot unlock a second write. */
14
+ export function useReviewedActionMutation<Data, Variables extends { request: { reviewedContext: string } }>(
15
+ target: string,
16
+ reviewedContext: string | undefined,
17
+ options: Omit<UseMutationOptions<Data, Error, Variables>, 'mutationFn' | 'mutationKey'> & { mutationFn: MutationFunction<Data, Variables> },
18
+ ) {
19
+ const client = useQueryClient()
20
+ let store = stores.get(client)
21
+ if (!store) {
22
+ store = { entries: new Map(), listeners: new Set() }
23
+ stores.set(client, store)
24
+ }
25
+ const outcomes = store
26
+ const keyFor = (context: string | undefined) => JSON.stringify([target, context])
27
+ const key = keyFor(reviewedContext)
28
+ const subscribe = useCallback((listener: () => void) => {
29
+ outcomes.listeners.add(listener)
30
+ return () => { outcomes.listeners.delete(listener) }
31
+ }, [outcomes])
32
+ const snapshot = useCallback(() => outcomes.entries.get(key) ?? EMPTY, [outcomes, key])
33
+ // Connection recovery purges query/mutation caches. It must not forget a
34
+ // request still in flight or a result that may already have changed the target.
35
+ const retained = useSyncExternalStore(subscribe, snapshot, () => EMPTY)
36
+ const publish = (key: string, value: Outcome) => {
37
+ if (value.pending || value.error) outcomes.entries.set(key, value)
38
+ else outcomes.entries.delete(key)
39
+ for (const listener of outcomes.listeners) listener()
40
+ }
41
+ const mutation = useMutation<Data, Error, Variables>({
42
+ ...options,
43
+ mutationKey: ['reviewed-action', target, reviewedContext],
44
+ mutationFn: async (variables, context) => {
45
+ const boundKey = keyFor(variables.request.reviewedContext)
46
+ const previous = outcomes.entries.get(boundKey)
47
+ if (previous?.error) throw previous.error
48
+ if (previous?.pending) throw new ApiError('A write to this target is still in progress. Wait for its result.', 409, { code: 'blocked' })
49
+ publish(boundKey, { pending: true, error: null })
50
+ let retainedError: Error | null = null
51
+ try {
52
+ return await options.mutationFn(variables, context)
53
+ } catch (error) {
54
+ if (actionOutcomeLocked(error)) {
55
+ const failure = error as Error
56
+ const message = `${failure.message} Inspect the current state, then reload this page and review the action again.`
57
+ retainedError = failure instanceof ApiError ? new ApiError(message, failure.status, failure.data) : new Error(message)
58
+ }
59
+ throw error
60
+ } finally {
61
+ publish(boundKey, { pending: false, error: retainedError })
62
+ }
63
+ },
64
+ })
65
+ return { ...mutation, isPending: mutation.isPending || retained.pending, outcomeError: retained.error }
66
+ }
@@ -19,6 +19,7 @@ import {
19
19
  applyClientFilters,
20
20
  localOverviewFromEvents,
21
21
  needsWindowFetch,
22
+ frozenWindowRefetchInterval,
22
23
  type RetainedRing,
23
24
  } from './timelineSource'
24
25
  import type { TimelineEvent } from '../types'
@@ -650,3 +651,11 @@ describe('retained ring fetch (the OSS-identical accumulate model)', () => {
650
651
  // cursor is intact on the cached ring — nothing was committed
651
652
  })
652
653
  })
654
+
655
+ describe('frozenWindowRefetchInterval', () => {
656
+ it('polls a failed window until it loads, and leaves a loaded one alone', () => {
657
+ expect(frozenWindowRefetchInterval('error')).toBe(10_000)
658
+ expect(frozenWindowRefetchInterval('success')).toBe(false)
659
+ expect(frozenWindowRefetchInterval('pending')).toBe(false)
660
+ })
661
+ })
@@ -544,6 +544,13 @@ export function needsWindowFetch(
544
544
  // refresh.
545
545
  const FROZEN_WINDOW_STALE_MS = 10 * 60 * 1000
546
546
 
547
+ // A frozen window that failed to load does poll, at the ring's cadence, until
548
+ // it loads: the error page tells the user it recovers on its own once the
549
+ // timeline's database is back, and without a poll only "Try again" would.
550
+ export function frozenWindowRefetchInterval(status: 'pending' | 'error' | 'success'): number | false {
551
+ return status === 'error' ? RETAINED_POLL_MS : false
552
+ }
553
+
547
554
  // Ring keys whose next fetch must be a full reload (manual refresh). A side
548
555
  // flag, not a side cursor: consuming it only switches the PATH of the next
549
556
  // fetch — all sync state that must stay consistent with the data lives inside
@@ -750,6 +757,7 @@ function createRingEventsHook(opts: {
750
757
  },
751
758
  enabled: windowNeeded,
752
759
  staleTime: FROZEN_WINDOW_STALE_MS,
760
+ refetchInterval: (q) => frozenWindowRefetchInterval(q.state.status),
753
761
  })
754
762
 
755
763
  const kindsKey = query.kinds?.join(',')
@@ -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')
@@ -83,6 +83,9 @@ function BestPracticesView({ namespaces, onNavigateToResource }: AuditViewProps)
83
83
  )
84
84
  }
85
85
 
86
+ const annotationIgnored = Object.values(data.annotationIgnoredByNamespace ?? {})
87
+ .reduce((sum, byNS) => sum + Object.values(byNS).reduce((a, n) => a + n, 0), 0)
88
+
86
89
  const onResourceClick = (ref: CheckResourceRef) =>
87
90
  onNavigateToResource({ kind: ref.kind, namespace: ref.namespace, name: ref.name, group: ref.group })
88
91
 
@@ -108,6 +111,11 @@ function BestPracticesView({ namespaces, onNavigateToResource }: AuditViewProps)
108
111
  {ignoredCount > 0 && (
109
112
  <button onClick={() => setShowSettings(true)} className="text-xs text-theme-text-tertiary hover:text-theme-text-secondary transition-colors">{ignoredCount} {ignoredCount === 1 ? 'namespace' : 'namespaces'} hidden</button>
110
113
  )}
114
+ {annotationIgnored > 0 && (
115
+ <Tooltip content={`Resources that opted out of a check with the ${data.ignoreChecksAnnotation} annotation`}>
116
+ <span className="text-xs text-theme-text-tertiary">{annotationIgnored} {annotationIgnored === 1 ? 'finding' : 'findings'} hidden by annotation</span>
117
+ </Tooltip>
118
+ )}
111
119
  <Tooltip content="Checks settings">
112
120
  <button
113
121
  onClick={() => setShowSettings(true)}
@@ -129,6 +137,7 @@ function BestPracticesView({ namespaces, onNavigateToResource }: AuditViewProps)
129
137
  onResourceClick={onResourceClick}
130
138
  onHideCheck={canEdit ? hideCheck : undefined}
131
139
  onHideCategory={canEdit ? hideCategory : undefined}
140
+ ignoreChecksAnnotation={data.ignoreChecksAnnotation}
132
141
  />
133
142
 
134
143
  {showSettings && <AuditSettingsDialog namespaces={namespaces} onClose={() => setShowSettings(false)} />}