@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
package/src/api/client.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { canonicalResourceGroup } from '@skyhook-io/k8s-ui/utils/api-resources'
2
+ import { pluralize } from '@skyhook-io/k8s-ui/utils/pluralize'
2
3
  import { knownKindForPluralWithGroup, pluralToKind } from '@skyhook-io/k8s-ui/utils/navigation'
3
- import { useEffect, useRef } from 'react'
4
+ import { useEffect, useRef, useCallback, useMemo } from 'react'
4
5
  import type { KueueAdmissionResponse } from '@skyhook-io/k8s-ui/types/scheduling'
5
6
  import type { GitOpsWriteEvidence } from '@skyhook-io/k8s-ui/utils/gitops-write-guard'
6
7
  import type {
@@ -21,8 +22,8 @@ import type {
21
22
  YamlDocumentIdentity,
22
23
  YamlSchemaLoadResult,
23
24
  } from '@skyhook-io/k8s-ui'
24
- import { useQuery, useMutation, useQueryClient, skipToken } from '@tanstack/react-query'
25
- import { showApiError, showApiSuccess } from '../components/ui/Toast'
25
+ import { useQuery, useMutation, useQueryClient, skipToken, type QueryClient } from '@tanstack/react-query'
26
+ import { showApiError, showApiSuccess, showApiNotice } from '../components/ui/Toast'
26
27
  import { useIsAuthEnabled, useNamespacedCapabilities } from '../contexts/CapabilitiesContext'
27
28
  import type {
28
29
  Topology,
@@ -42,6 +43,9 @@ import type {
42
43
  ResourceDiff,
43
44
  UpgradeInfo,
44
45
  BatchUpgradeInfo,
46
+ ChartSourceCandidate,
47
+ SourceUpgradeSelection,
48
+ ChartSourceStatus,
45
49
  ValuesDiff,
46
50
  ValuesPreviewResponse,
47
51
  HelmRepository,
@@ -229,6 +233,16 @@ export function isNotFoundError(error: unknown): boolean {
229
233
  return error instanceof ApiError && error.status === 404;
230
234
  }
231
235
 
236
+ /**
237
+ * The server's explanation when it refused a request because the browser
238
+ * reported it came from another site, or undefined for any other error.
239
+ */
240
+ export function crossOriginRefusalMessage(error: unknown): string | undefined {
241
+ return error instanceof ApiError && error.data?.error_code === "cross_origin_refused"
242
+ ? error.message
243
+ : undefined;
244
+ }
245
+
232
246
  export function isCapacityCursorInvalidError(error: unknown): boolean {
233
247
  return (
234
248
  error instanceof ApiError &&
@@ -287,6 +301,20 @@ export function isKindSyncFailed(error: unknown): boolean {
287
301
  );
288
302
  }
289
303
 
304
+ // timelineDatabaseError returns the driver's error when a timeline read failed
305
+ // because Radar can't connect to its PostgreSQL database, and null for any other
306
+ // failure. The server redacts the password before it sends the error.
307
+ export function timelineDatabaseError(error: unknown): string | null {
308
+ if (
309
+ !(error instanceof ApiError) ||
310
+ error.status !== 503 ||
311
+ error.data?.error_code !== "timeline_database_unreachable"
312
+ )
313
+ return null;
314
+ const detail = error.data.detail;
315
+ return typeof detail === "string" ? detail : "";
316
+ }
317
+
290
318
  // SyncKindState / SyncStatusSnapshot mirror k8score's SyncSnapshot — attached
291
319
  // to the connection-status payload while the initial informer sync is running.
292
320
  export interface SyncKindState {
@@ -515,6 +543,10 @@ export type { AuditFinding, ResourceGroup, CheckMeta, Check };
515
543
 
516
544
  export interface AuditResponse {
517
545
  missingInputs?: string[];
546
+ // Absent on a Radar that predates the per-resource opt-out.
547
+ ignoreChecksAnnotation?: string;
548
+ // checkID → namespace → resources whose findings the annotation hid.
549
+ annotationIgnoredByNamespace?: Record<string, Record<string, number>>;
518
550
  summary: DashboardAudit;
519
551
  findings: AuditFinding[];
520
552
  groups: ResourceGroup[];
@@ -725,20 +757,46 @@ export interface IssuesResponse {
725
757
  recent_changes_reason?: string
726
758
  recent_changes_guidance?: string
727
759
  recent_changes_truncated?: boolean
760
+ // Present when the recent-changes window starts before the history Radar
761
+ // holds; complete_since is sent only to callers who can read every namespace.
762
+ recent_changes_history_coverage?: {
763
+ incomplete: boolean
764
+ complete_since?: string
765
+ reasons: string[]
766
+ }
728
767
  // Present only when RBAC visibility is incomplete (absent = full access).
729
768
  // state 'degraded' means core workload reads are denied, so an empty list may
730
769
  // mean "can't see" rather than "nothing broken" — the UI must say so.
731
770
  visibility?: { state?: string; impact?: string };
771
+ // Issue sources Radar couldn't check, so their issues may be missing: an
772
+ // empty list is not an all-clear. A newer Radar may send sources and
773
+ // reasons this version doesn't know. Absent when every source was checked,
774
+ // and from older Radars.
775
+ unchecked_sources?: UncheckedSource[];
732
776
  }
733
777
 
734
- export function useIssues(namespaces: string[] = []) {
735
- const params =
736
- namespaces.length > 0 ? `?namespaces=${namespaces.join(",")}` : "";
778
+ export interface UncheckedSource {
779
+ source: string;
780
+ reason: string;
781
+ // The kinds within the source that went unchecked; absent means the whole
782
+ // source, or that Radar couldn't tell which kinds.
783
+ kinds?: { group?: string; kind: string }[];
784
+ // The namespaces whose read failed while the others were read; absent
785
+ // means the gap isn't limited to particular namespaces.
786
+ namespaces?: string[];
787
+ }
788
+
789
+ export function useIssues(namespaces: string[] = [], enabled = true, kind?: string) {
790
+ const params = new URLSearchParams();
791
+ if (namespaces.length) params.set('namespaces', namespaces.join(','));
792
+ if (kind) { params.set('kind', kind); params.set('limit', '1000'); }
793
+ const query = params.toString();
737
794
  return useQuery<IssuesResponse>({
738
- queryKey: ["issues", namespaces],
739
- queryFn: () => fetchJSON(`/issues${params}`),
795
+ queryKey: kind ? ["issues", namespaces, kind] : ["issues", namespaces],
796
+ queryFn: () => fetchJSON(`/issues${query ? `?${query}` : ''}`),
740
797
  staleTime: 30000,
741
798
  refetchInterval: ISSUES_REFRESH_INTERVAL_MS,
799
+ enabled,
742
800
  });
743
801
  }
744
802
 
@@ -790,6 +848,49 @@ export function useResourceIssues(
790
848
  });
791
849
  }
792
850
 
851
+ // The Issues page narrowed to one subject: the same per-resource lookup with
852
+ // ?coverage=1, which also says whether Radar reads the subject's kind and what
853
+ // the caller's RBAC withheld. Polls like the page list.
854
+ export interface CronJobSchedulingEvidence {
855
+ uid: string;
856
+ state: 'reported' | 'configuration_changed' | 'history_incomplete';
857
+ reason: string;
858
+ message: string;
859
+ last_reported_at: string;
860
+ configuration_changed_at?: string;
861
+ history_incomplete?: boolean;
862
+ }
863
+
864
+ export interface SubjectIssuesResponse {
865
+ scheduling_report?: CronJobSchedulingEvidence;
866
+ issues: Issue[];
867
+ coverage: "ok" | "syncing" | "notWatched" | "unknownKind";
868
+ withheld?: { issues: number };
869
+ visibility?: { state?: string; impact?: string };
870
+ }
871
+
872
+ export function useSubjectIssues(
873
+ subject: { kind: string; group: string; namespace: string; name: string; uid?: string } | null,
874
+ enabled: boolean,
875
+ ) {
876
+ const capabilities = useCapabilities();
877
+ const { support, gatedKey, guard } = useRadarFeature('resourceIssueCoverage');
878
+ const pathNs = subject?.namespace ? encodeURIComponent(subject.namespace) : "_";
879
+ const params = new URLSearchParams({ coverage: "1" });
880
+ if (subject?.group) params.set("group", subject.group);
881
+ return useQuery<SubjectIssuesResponse>({
882
+ queryKey: ["issues", "subject", subject?.kind ?? "", subject?.group ?? "", subject?.namespace ?? "", subject?.name ?? "", subject?.uid ?? "", support, ...gatedKey],
883
+ queryFn: () => {
884
+ if (!capabilities.data && capabilities.error) throw capabilities.error;
885
+ return guard(() => fetchJSON<SubjectIssuesResponse>(`/issues/resource/${encodeURIComponent(subject!.kind)}/${pathNs}/${encodeURIComponent(subject!.name)}?${params}`));
886
+ },
887
+ staleTime: 30000,
888
+ refetchInterval: ISSUES_REFRESH_INTERVAL_MS,
889
+ // The existing route alone cannot prove support for this opt-in shape.
890
+ enabled: enabled && !!subject && !capabilities.isPending,
891
+ });
892
+ }
893
+
793
894
  import type { Trace as NetworkTrace, InClusterCapability, DrainPlan, DrainPlanPod } from '@skyhook-io/k8s-ui'
794
895
 
795
896
  // useTrace polls the static path-shaped diagnosis for one network entry
@@ -1034,12 +1135,14 @@ function costRefetchInterval(
1034
1135
  };
1035
1136
  }
1036
1137
 
1037
- export function useOpenCostSummary(enabled = true) {
1138
+ export function useOpenCostSummary(enabled = true, namespaces: string[] = []) {
1038
1139
  const clusterInfo = useClusterInfo();
1140
+ const params =
1141
+ namespaces.length > 0 ? `?namespaces=${namespaces.join(",")}` : "";
1039
1142
  return useQuery<OpenCostSummary>({
1040
- queryKey: ["opencost-summary"],
1143
+ queryKey: ["opencost-summary", namespaces],
1041
1144
  enabled,
1042
- queryFn: () => fetchJSON("/opencost/summary"),
1145
+ queryFn: () => fetchJSON(`/opencost/summary${params}`),
1043
1146
  refetchInterval: costRefetchInterval(
1044
1147
  COST_REFRESH_INTERVAL_MS,
1045
1148
  clusterInfo.data?.context,
@@ -1781,13 +1884,14 @@ export function useRadarFeature(feature: RadarFeature) {
1781
1884
  const currentVersion = versionInfo?.currentVersion || radarVersion
1782
1885
  const latestVersion = versionInfo?.latestVersion
1783
1886
  const support = radarFeatureSupport(feature, capabilities, currentVersion)
1887
+ // Stable across renders, so a callback built on guard keeps its identity.
1888
+ const guard = useCallback(
1889
+ <T,>(request: () => Promise<T>): Promise<T> => guardRadarFeature(feature, support, { currentVersion, latestVersion }, request),
1890
+ [feature, support, currentVersion, latestVersion],
1891
+ )
1892
+ const gatedKey = useMemo(() => (support === 'unsupported' ? ['radar-feature-unsupported'] : []), [support])
1784
1893
 
1785
- return {
1786
- support,
1787
- gatedKey: support === 'unsupported' ? ['radar-feature-unsupported'] : [],
1788
- guard: <T,>(request: () => Promise<T>): Promise<T> =>
1789
- guardRadarFeature(feature, support, { currentVersion, latestVersion }, request),
1790
- }
1894
+ return { support, gatedKey, guard }
1791
1895
  }
1792
1896
 
1793
1897
  // ============================================================================
@@ -1899,6 +2003,10 @@ export interface SearchResult {
1899
2003
  total: number;
1900
2004
  searched: number;
1901
2005
  total_matched: number;
2006
+ /** "time_limit" when scan report findings were only partly searched. */
2007
+ incomplete_findings?: string;
2008
+ /** Some namespaces' scan reports were left out, access not confirmed yet. */
2009
+ access_incomplete?: boolean;
1902
2010
  }
1903
2011
 
1904
2012
  const SEARCH_MIN_QUERY = 2;
@@ -2448,6 +2556,39 @@ export function useApplicationHistory(
2448
2556
  });
2449
2557
  }
2450
2558
 
2559
+ // How often a page asks again while Radar is still connecting to argocd-server,
2560
+ // and while it retries after a failure. Radar re-checks a failed connection at
2561
+ // most every 30s, so asking more often while retrying adds requests without
2562
+ // making the server reconnect sooner.
2563
+ // A page whose last fetch failed and was waiting on something keeps asking at
2564
+ // the slow rate, so a Radar or proxy outage doesn't strand it. It stops when
2565
+ // Radar answered that the object is gone or the caller can't read it, since
2566
+ // asking again won't change that answer.
2567
+ const ARGO_CONNECTING_POLL_MS = 2000;
2568
+ const ARGO_RETRYING_POLL_MS = 30_000;
2569
+
2570
+ type PollState<T> = {
2571
+ state: { status: string; data?: T; error?: unknown };
2572
+ };
2573
+
2574
+ function afterFailedFetch(error: unknown, wanted: number | false): number | false {
2575
+ if (wanted === false) return false;
2576
+ if (error instanceof ApiError && [401, 403, 404].includes(error.status)) return false;
2577
+ return ARGO_RETRYING_POLL_MS;
2578
+ }
2579
+
2580
+ export function gitopsTreeRefetchInterval(
2581
+ query: PollState<Pick<GitOpsResourceTree, "healthApiPending" | "healthApiRetrying">>,
2582
+ ): number | false {
2583
+ const data = query.state.data;
2584
+ const wanted = data?.healthApiPending
2585
+ ? ARGO_CONNECTING_POLL_MS
2586
+ : data?.healthApiRetrying
2587
+ ? ARGO_RETRYING_POLL_MS
2588
+ : false;
2589
+ return query.state.status === "error" ? afterFailedFetch(query.state.error, wanted) : wanted;
2590
+ }
2591
+
2451
2592
  export function useGitOpsTree(
2452
2593
  kind: string,
2453
2594
  namespace: string,
@@ -2470,6 +2611,9 @@ export function useGitOpsTree(
2470
2611
  ),
2471
2612
  enabled: Boolean(kind && name) && (options?.enabled ?? true),
2472
2613
  staleTime: 5000,
2614
+ // Radar answers at once while it connects to argocd-server; ask again
2615
+ // until Argo's per-resource health is in.
2616
+ refetchInterval: gitopsTreeRefetchInterval,
2473
2617
  });
2474
2618
  }
2475
2619
 
@@ -2479,6 +2623,27 @@ export function useGitOpsTree(
2479
2623
  // auto-quiesces on completion.
2480
2624
  const INSIGHTS_RUNNING_POLL_MS = 2000;
2481
2625
 
2626
+ export function gitopsInsightsRefetchInterval(
2627
+ query: PollState<{
2628
+ summary?: Partial<
2629
+ Pick<GitOpsInsight["summary"], "operationPhase" | "resourceHealthApiPending" | "resourceHealthApiRetrying">
2630
+ >;
2631
+ capabilities?: Pick<NonNullable<GitOpsInsight["capabilities"]>, "argoConnecting" | "argoRetrying">;
2632
+ }>,
2633
+ ): number | false {
2634
+ const data = query.state.data;
2635
+ const phase = data?.summary?.operationPhase;
2636
+ let wanted: number | false = false;
2637
+ if (phase === "Running" || phase === "Terminating") {
2638
+ wanted = INSIGHTS_RUNNING_POLL_MS;
2639
+ } else if (data?.summary?.resourceHealthApiPending || data?.capabilities?.argoConnecting) {
2640
+ wanted = ARGO_CONNECTING_POLL_MS;
2641
+ } else if (data?.summary?.resourceHealthApiRetrying || data?.capabilities?.argoRetrying) {
2642
+ wanted = ARGO_RETRYING_POLL_MS;
2643
+ }
2644
+ return query.state.status === "error" ? afterFailedFetch(query.state.error, wanted) : wanted;
2645
+ }
2646
+
2482
2647
  export function useGitOpsInsights(
2483
2648
  kind: string,
2484
2649
  namespace: string,
@@ -2500,12 +2665,7 @@ export function useGitOpsInsights(
2500
2665
  ),
2501
2666
  enabled: Boolean(kind && name),
2502
2667
  staleTime: 5000,
2503
- refetchInterval: (query) => {
2504
- const phase = query.state.data?.summary?.operationPhase;
2505
- return phase === "Running" || phase === "Terminating"
2506
- ? INSIGHTS_RUNNING_POLL_MS
2507
- : false;
2508
- },
2668
+ refetchInterval: gitopsInsightsRefetchInterval,
2509
2669
  });
2510
2670
  }
2511
2671
 
@@ -2686,6 +2846,32 @@ export function useResource<T>(
2686
2846
  };
2687
2847
  }
2688
2848
 
2849
+ // Availability checks return headers only, without downloading Secret values.
2850
+ export async function fetchResourceAvailability(
2851
+ kind: string,
2852
+ namespace: string,
2853
+ name: string,
2854
+ ): Promise<"present" | "missing" | "unchecked"> {
2855
+ const response = await apiFetch(`${getApiBase()}/resources/${encodeURIComponent(kind)}/${encodeURIComponent(namespace || "_")}/${encodeURIComponent(name)}`, { method: "HEAD" });
2856
+ const resourceLookup = response.headers.get("X-Radar-Resource-Read") === "true";
2857
+ if (resourceLookup && response.ok) return "present";
2858
+ if (resourceLookup && response.status === 404) return "missing";
2859
+ // Older Radar versions do not serve HEAD lookups. Keep their existing
2860
+ // navigation without claiming that availability was verified.
2861
+ if (response.status === 405 || response.ok) return "unchecked";
2862
+ throw new ApiError(httpStatusMessage(response.status, response.statusText), response.status);
2863
+ }
2864
+
2865
+ export function useResourceAvailability(kind: string, namespace: string, name: string) {
2866
+ return useQuery({
2867
+ queryKey: ["resource", kind, namespace, name, undefined, "availability"],
2868
+ queryFn: () => fetchResourceAvailability(kind, namespace, name),
2869
+ enabled: Boolean(kind && name),
2870
+ refetchInterval: GONE_RECHECK_MS,
2871
+ retry: (failureCount, error) => !isForbiddenError(error) && failureCount < 1,
2872
+ });
2873
+ }
2874
+
2689
2875
  // Hook that returns full response with relationships explicitly
2690
2876
  export function useResourceWithRelationships<T>(
2691
2877
  kind: string,
@@ -3204,23 +3390,31 @@ function retryMetricsQuery(failureCount: number, error: unknown): boolean {
3204
3390
  return !isMetricsUnavailableError(error) && failureCount < 1;
3205
3391
  }
3206
3392
 
3393
+ // The query behind usePodMetrics, for callers reading several Pods at once
3394
+ // (useQueries) that must share its cache and its null-when-unavailable rule.
3395
+ // null means no metrics for this Pod: the metrics API is missing, or the Pod
3396
+ // has not been scraped yet; one Pod's null cannot tell those apart.
3397
+ export function podMetricsQuery(namespace: string, podName: string, enabled = true) {
3398
+ return {
3399
+ queryKey: ["pod-metrics", namespace, podName] as const,
3400
+ queryFn: () =>
3401
+ fetchMetricsOrNull<PodMetrics>(`/metrics/pods/${namespace}/${podName}`),
3402
+ enabled: Boolean(namespace && podName) && enabled,
3403
+ staleTime: 15000,
3404
+ refetchInterval: 30000,
3405
+ refetchOnMount: "always" as const,
3406
+ refetchOnReconnect: "always" as const,
3407
+ retry: retryMetricsQuery,
3408
+ };
3409
+ }
3410
+
3207
3411
  // Fetch metrics for a specific pod
3208
3412
  export function usePodMetrics(
3209
3413
  namespace: string,
3210
3414
  podName: string,
3211
3415
  options?: { enabled?: boolean },
3212
3416
  ) {
3213
- return useQuery<PodMetrics | null>({
3214
- queryKey: ["pod-metrics", namespace, podName],
3215
- queryFn: () =>
3216
- fetchMetricsOrNull<PodMetrics>(`/metrics/pods/${namespace}/${podName}`),
3217
- enabled: Boolean(namespace && podName) && (options?.enabled ?? true),
3218
- staleTime: 15000,
3219
- refetchInterval: 30000,
3220
- refetchOnMount: "always",
3221
- refetchOnReconnect: "always",
3222
- retry: retryMetricsQuery,
3223
- });
3417
+ return useQuery<PodMetrics | null>(podMetricsQuery(namespace, podName, options?.enabled ?? true));
3224
3418
  }
3225
3419
 
3226
3420
  export function usePodEnvironment(namespace: string, podName: string, enabled = true) {
@@ -3287,6 +3481,7 @@ export interface ContainerMetricsHistory {
3287
3481
  }
3288
3482
 
3289
3483
  export interface PodMetricsHistory {
3484
+ metricsAPIReachable?: boolean;
3290
3485
  namespace: string;
3291
3486
  name: string;
3292
3487
  containers: ContainerMetricsHistory[];
@@ -3522,7 +3717,7 @@ export type PrometheusTimeRange =
3522
3717
  // PVC usage at a moment in time, derived from kubelet_volume_stats_*.
3523
3718
  export interface PrometheusPVCUsage {
3524
3719
  // Hub packages the frontend independently from per-cluster agent upgrades.
3525
- status?: "available" | "no_series" | "invalid_data" | "query_failed";
3720
+ status?: "available" | "no_series" | "invalid_data" | "query_failed" | "ambiguous_scope" | "scope_mismatch";
3526
3721
  namespace: string;
3527
3722
  name: string;
3528
3723
  used: number;
@@ -3670,6 +3865,8 @@ export interface ArgoStatus {
3670
3865
  // client is live. The two differ right after a restart (configured, reconnecting).
3671
3866
  configured: boolean;
3672
3867
  connected: boolean;
3868
+ // Not connected yet, and a connection is being made.
3869
+ connecting?: boolean;
3673
3870
  // Connected without a token: the install serves reads to everyone, so
3674
3871
  // there is nothing to add in Settings.
3675
3872
  anonymous?: boolean;
@@ -3682,8 +3879,12 @@ export function useArgoStatus(enabled = true) {
3682
3879
  queryKey: ["argocd-status"],
3683
3880
  queryFn: () => fetchJSON("/integrations/argocd/status"),
3684
3881
  enabled,
3685
- staleTime: 30000,
3686
- refetchInterval: 60000,
3882
+ // Cheap to ask (it never waits on Argo CD): reopening Settings asks
3883
+ // afresh, so "Connecting…" shows only while it's true.
3884
+ staleTime: 0,
3885
+ // While Radar connects, ask again soon so "Connecting…" doesn't linger.
3886
+ refetchInterval: (query) =>
3887
+ query.state.data?.connecting ? ARGO_CONNECTING_POLL_MS : 60000,
3687
3888
  });
3688
3889
  }
3689
3890
 
@@ -4247,7 +4448,7 @@ export function useUpdateResource() {
4247
4448
  });
4248
4449
  }
4249
4450
 
4250
- // Cascade delete preview — shows resources that will be garbage-collected
4451
+ // Cascade delete preview — visible related resources deletion may affect.
4251
4452
  export interface CascadeDeletePreview {
4252
4453
  root: { kind: string; namespace: string; name: string; group?: string };
4253
4454
  rootResolved: boolean;
@@ -4557,6 +4758,7 @@ export interface ApplyResourceResult {
4557
4758
  namespace: string;
4558
4759
  kind: string;
4559
4760
  apiVersion: string;
4761
+ uid?: string;
4560
4762
  created: boolean;
4561
4763
  }
4562
4764
 
@@ -5439,10 +5641,46 @@ export function useNodeRemovalPlan(name: string | undefined, enabled: boolean) {
5439
5641
  })
5440
5642
  }
5441
5643
 
5442
- export function useDrainNode() {
5644
+ export type NodeDrainActivity = {
5645
+ requestId: number;
5646
+ startedAt: number;
5647
+ timeoutSeconds: number;
5648
+ contextName?: string;
5649
+ } & ({ status: "pending" } | {
5650
+ status: "finished";
5651
+ finishedAt: number;
5652
+ summary: ReturnType<typeof describeDrainResult>;
5653
+ });
5654
+
5655
+ export function nodeDrainActivityKey(apiBase: string, name: string, nodeUID: string) {
5656
+ return ["node-drain-activity", apiBase, name, nodeUID] as const;
5657
+ }
5658
+
5659
+ export function useNodeDrainActivity(name: string, nodeUID: string) {
5660
+ const queryClient = useQueryClient();
5661
+ const queryKey = nodeDrainActivityKey(getApiBase(), nodeUID ? name : "", nodeUID);
5662
+ const { data } = useQuery<NodeDrainActivity | null>({
5663
+ queryKey,
5664
+ queryFn: () => null,
5665
+ initialData: null,
5666
+ enabled: false,
5667
+ staleTime: Infinity,
5668
+ gcTime: Infinity,
5669
+ });
5670
+ return {
5671
+ activity: nodeUID ? data : null,
5672
+ dismiss: () => queryClient.setQueryData(queryKey, null),
5673
+ };
5674
+ }
5675
+
5676
+ let nextNodeDrainRequestId = 0;
5677
+
5678
+ export function useDrainNode(nodeUID = "") {
5443
5679
  const queryClient = useQueryClient();
5680
+ const apiBase = getApiBase();
5444
5681
 
5445
5682
  return useMutation({
5683
+ retry: false,
5446
5684
  mutationFn: async ({
5447
5685
  name,
5448
5686
  options,
@@ -5450,7 +5688,7 @@ export function useDrainNode() {
5450
5688
  name: string;
5451
5689
  options?: DrainNodeOptions;
5452
5690
  }) => {
5453
- const response = await apiFetch(`${getApiBase()}/nodes/${name}/drain`, {
5691
+ const response = await apiFetch(apiUrl(`/nodes/${encodeURIComponent(name)}/drain`, apiBase), {
5454
5692
  method: "POST",
5455
5693
  headers: options ? { "Content-Type": "application/json" } : {},
5456
5694
  body: options ? JSON.stringify(options) : undefined,
@@ -5461,6 +5699,37 @@ export function useDrainNode() {
5461
5699
  }
5462
5700
  return response.json();
5463
5701
  },
5702
+ onMutate: ({ name }) => {
5703
+ const contextName = queryClient.getQueryData<ClusterInfo>(["cluster-info"])?.context
5704
+ ?? queryClient.getQueryData<{ context: string }>(["connection-status"])?.context;
5705
+ const activity: NodeDrainActivity = {
5706
+ status: "pending",
5707
+ requestId: ++nextNodeDrainRequestId,
5708
+ startedAt: Date.now(),
5709
+ timeoutSeconds: 120,
5710
+ contextName,
5711
+ };
5712
+ const queryKey = nodeDrainActivityKey(apiBase, name, nodeUID);
5713
+ if (nodeUID) queryClient.setQueryData(queryKey, activity);
5714
+ return { queryKey, activity, tracked: Boolean(nodeUID), contextName };
5715
+ },
5716
+ onError: (error, _variables, context) => {
5717
+ if (!context?.tracked) return;
5718
+ queryClient.setQueryData<NodeDrainActivity | null>(context.queryKey, (previous) =>
5719
+ previous?.requestId === context.activity.requestId ? {
5720
+ ...context.activity,
5721
+ status: "finished",
5722
+ finishedAt: Date.now(),
5723
+ summary: {
5724
+ title: "Could not confirm drain completion",
5725
+ detail: `${error.message}\nCheck the node's pods before retrying or taking it down. A failed request does not confirm whether evictions ran.`,
5726
+ type: "warning",
5727
+ failed: true,
5728
+ outcome: "unconfirmed",
5729
+ },
5730
+ } : previous,
5731
+ );
5732
+ },
5464
5733
  meta: {
5465
5734
  errorMessage: "Failed to drain node",
5466
5735
  // No static successMessage — handled in onSuccess to distinguish partial failures
@@ -5470,20 +5739,41 @@ export function useDrainNode() {
5470
5739
  evictedPods?: string[];
5471
5740
  skippedPods?: DrainPlanPod[];
5472
5741
  errors?: string[];
5742
+ pendingPods?: string[];
5743
+ waitedForDeletion?: boolean;
5744
+ outcome?: DrainCompletionOutcome;
5745
+ unconfirmedPods?: string[];
5746
+ verificationError?: string;
5473
5747
  },
5474
5748
  variables,
5749
+ context,
5475
5750
  ) => {
5751
+ const currentContext = queryClient.getQueryData<ClusterInfo>(["cluster-info"])?.context;
5752
+ if (context?.tracked && queryClient.getQueryData<NodeDrainActivity | null>(context.queryKey)?.requestId !== context.activity.requestId) return;
5753
+ const { title, detail, type } = describeDrainResult(data);
5754
+ if (context?.tracked) {
5755
+ queryClient.setQueryData<NodeDrainActivity | null>(context.queryKey, (previous) =>
5756
+ previous?.requestId === context.activity.requestId ? {
5757
+ ...context.activity,
5758
+ status: "finished",
5759
+ finishedAt: Date.now(),
5760
+ summary: describeDrainResult(data, { recorded: true }),
5761
+ } : previous,
5762
+ );
5763
+ }
5764
+ if (context && (context.queryKey[1] !== getApiBase() ||
5765
+ (context.contextName && currentContext && context.contextName !== currentContext))) return;
5476
5766
  queryClient.invalidateQueries({ queryKey: ["resources", "nodes"] });
5477
5767
  queryClient.invalidateQueries({
5478
5768
  queryKey: ["resource", "nodes", "", variables.name],
5479
5769
  });
5480
5770
  queryClient.invalidateQueries({ queryKey: ["topology"] });
5481
-
5482
- const { title, detail, failed } = describeDrainResult(data);
5483
- if (failed) {
5771
+ if (type === "error") {
5484
5772
  showApiError(title, detail);
5485
- } else {
5773
+ } else if (type === "success") {
5486
5774
  showApiSuccess(title, detail);
5775
+ } else {
5776
+ showApiNotice(title, detail, type);
5487
5777
  }
5488
5778
  },
5489
5779
  });
@@ -5497,47 +5787,86 @@ function listWithOverflow(items: string[]): string {
5497
5787
  return rest > 0 ? `${shown.join("; ")}; +${rest} more` : shown.join("; ");
5498
5788
  }
5499
5789
 
5500
- /**
5501
- * Turns the drain response into a legible summary: evicted, skipped (with reasons),
5502
- * failed. Lists are capped so the toast stays readable on nodes with many pods.
5503
- */
5504
- export function describeDrainResult(data: {
5790
+ export type DrainCompletionOutcome = "complete" | "incomplete" | "unconfirmed" | "started";
5791
+
5792
+ interface DrainResultData {
5505
5793
  evictedPods?: string[];
5506
5794
  skippedPods?: DrainPlanPod[];
5507
5795
  errors?: string[];
5508
- }): { title: string; detail: string; failed: boolean } {
5509
- const evicted = data?.evictedPods?.length ?? 0;
5510
- const skipped = data?.skippedPods ?? [];
5511
- const errors = data?.errors ?? [];
5796
+ pendingPods?: string[];
5797
+ unconfirmedPods?: string[];
5798
+ verificationError?: string;
5799
+ waitedForDeletion?: boolean;
5800
+ outcome?: DrainCompletionOutcome;
5801
+ }
5802
+
5803
+ export function describeDrainResult(data: DrainResultData, { recorded = false }: { recorded?: boolean } = {}): {
5804
+ title: string;
5805
+ detail: string;
5806
+ failed: boolean;
5807
+ type: "success" | "error" | "warning" | "info";
5808
+ outcome: DrainCompletionOutcome;
5809
+ } {
5810
+ const evicted = data.evictedPods?.length ?? 0;
5811
+ const skipped = data.skippedPods ?? [];
5812
+ const errors = data.errors ?? [];
5813
+ const pending = data.pendingPods ?? [];
5814
+ const unconfirmed = data.unconfirmedPods ?? [];
5815
+ const blocking = skipped.filter((pod) => pod.expectedSkip === false);
5816
+ const unknownSkips = skipped.filter((pod) => pod.expectedSkip === undefined);
5817
+ const expected = skipped.filter((pod) => pod.expectedSkip);
5818
+ // Older backends have no completion outcome or expected-skip metadata.
5819
+ const outcome = data.outcome ?? (
5820
+ errors.length > 0 || pending.length > 0 || blocking.length > 0 ? "incomplete" :
5821
+ unconfirmed.length > 0 || data.verificationError ? "unconfirmed" :
5822
+ evicted > 0 && !data.waitedForDeletion ? "started" :
5823
+ unknownSkips.length > 0 ? "unconfirmed" : "complete"
5824
+ );
5512
5825
  const parts: string[] = [];
5513
- if (skipped.length > 0) {
5514
- parts.push(
5515
- `Skipped ${skipped.length}: ${listWithOverflow(
5516
- skipped.map((p) => `${p.namespace}/${p.name} (${p.reason})`),
5517
- )}`,
5518
- );
5519
- }
5520
5826
  if (errors.length > 0) {
5521
- parts.push(`Failed ${errors.length}: ${listWithOverflow(errors)}`);
5827
+ parts.push(`Failed evictions ${errors.length}: ${listWithOverflow(errors)}`);
5522
5828
  }
5523
- parts.push(
5524
- evicted > 0
5525
- ? "Evictions were accepted; those pods may still be terminating. The node remains cordoned."
5526
- : "The node remains cordoned.",
5527
- );
5528
- const detail = parts.join("\n");
5529
- if (errors.length > 0) {
5530
- return {
5531
- title: `Drain finished with ${errors.length} failed eviction(s): ${evicted} evicted, ${skipped.length} skipped`,
5532
- detail,
5533
- failed: true,
5534
- };
5829
+ if (pending.length > 0) {
5830
+ parts.push(`Still on the node ${pending.length}: ${listWithOverflow(pending)}`);
5535
5831
  }
5536
- return {
5537
- title: `Node drained: ${evicted} evicted, ${skipped.length} skipped`,
5538
- detail,
5539
- failed: false,
5832
+ const describePod = (pod: DrainPlanPod) => `${pod.namespace}/${pod.name} (${pod.reason})`;
5833
+ if (blocking.length > 0) {
5834
+ parts.push(`Skipped pods requiring attention ${blocking.length}: ${listWithOverflow(blocking.map(describePod))}`);
5835
+ }
5836
+ if (unknownSkips.length > 0) {
5837
+ parts.push(`Skipped pods requiring review ${unknownSkips.length}: ${listWithOverflow(unknownSkips.map(describePod))}`);
5838
+ }
5839
+ if (unconfirmed.length > 0) {
5840
+ parts.push(`Deletion unconfirmed ${unconfirmed.length}: ${listWithOverflow(unconfirmed)}`);
5841
+ }
5842
+ if (data.verificationError) {
5843
+ parts.push(`Could not verify pod deletion: ${data.verificationError}`);
5844
+ }
5845
+ if (outcome === "started") {
5846
+ parts.push("Eviction requests were accepted; pod deletion has not been confirmed.");
5847
+ } else if (data.waitedForDeletion && evicted > 0 && pending.length === 0 && unconfirmed.length === 0 && !data.verificationError) {
5848
+ parts.push("All evicted pods have left the node.");
5849
+ }
5850
+ if (expected.length > 0) {
5851
+ parts.push(`Left in place by design: ${pluralize(expected.length, "pod")}.`);
5852
+ }
5853
+ parts.push(recorded ? "The node was left cordoned." : "The node remains cordoned.");
5854
+ if (outcome === "incomplete" || outcome === "unconfirmed") {
5855
+ if (blocking.length > 0) parts.push("Review the skipped workloads and drain options before retrying.");
5856
+ if (pending.length > 0) parts.push("Check the remaining pods before retrying.");
5857
+ if (errors.length > 0) parts.push("Resolve the failed evictions before retrying.");
5858
+ if (unconfirmed.length > 0 || data.verificationError || unknownSkips.length > 0) parts.push("Check the node's pods to confirm what remains.");
5859
+ parts.push("Do not take the node down until required workloads are removed.");
5860
+ }
5861
+ const titles: Record<DrainCompletionOutcome, string> = {
5862
+ complete: evicted > 0 ? `Drain complete: ${pluralize(evicted, "pod")} removed` : "Nothing to evict",
5863
+ incomplete: errors.length > 0 ? `Drain incomplete: ${pluralize(errors.length, "failed eviction")}` :
5864
+ `Drain incomplete: ${pluralize(pending.length + blocking.length, "pod")} left on the node`,
5865
+ unconfirmed: "Could not confirm drain completion",
5866
+ started: `Evictions started: ${evicted} accepted`,
5540
5867
  };
5868
+ const type = outcome === "complete" ? "success" : outcome === "started" ? "info" : errors.length > 0 ? "error" : "warning";
5869
+ return { title: titles[outcome], detail: parts.join("\n"), failed: outcome === "incomplete" || outcome === "unconfirmed", type, outcome };
5541
5870
  }
5542
5871
 
5543
5872
  // ============================================================================
@@ -5884,6 +6213,8 @@ export function useHelmUninstall() {
5884
6213
  });
5885
6214
  }
5886
6215
 
6216
+ export class HelmSourceSelectionError extends Error {}
6217
+
5887
6218
  // Stream SSE progress events from a Helm operation endpoint.
5888
6219
  // Resolves on 'complete', rejects on 'error'. Returns the complete event data for install (which includes release).
5889
6220
  function streamHelmProgress(
@@ -5933,7 +6264,7 @@ function streamHelmProgress(
5933
6264
  resolve(data);
5934
6265
  return;
5935
6266
  } else if (data.type === "error") {
5936
- reject(new Error(data.message || failureLabel));
6267
+ reject(data.errorCode === 'chart_source_changed' || data.errorCode === 'chart_source_required' ? new HelmSourceSelectionError(data.message || failureLabel) : new Error(data.message || failureLabel));
5937
6268
  return;
5938
6269
  }
5939
6270
  } catch (err) {
@@ -5963,18 +6294,19 @@ export function upgradeWithProgress(
5963
6294
  repositoryName: string | undefined,
5964
6295
  onProgress: (event: InstallProgressEvent) => void,
5965
6296
  values?: Record<string, unknown>,
6297
+ sourceUpgrade?: SourceUpgradeSelection,
5966
6298
  ): Promise<void> {
5967
6299
  const params = new URLSearchParams({ version });
5968
6300
  if (repositoryName) params.set("repository", repositoryName);
5969
- const options: RequestInit = values
6301
+ const options: RequestInit = values || sourceUpgrade
5970
6302
  ? {
5971
6303
  method: "POST",
5972
6304
  headers: { "Content-Type": "application/json" },
5973
- body: JSON.stringify({ values }),
6305
+ body: JSON.stringify({ values, sourceUpgrade }),
5974
6306
  }
5975
6307
  : { method: "POST" };
5976
6308
  return streamHelmProgress(
5977
- `${getApiBase()}/helm/releases/${namespace}/${name}/upgrade-stream?${params.toString()}`,
6309
+ `${getApiBase()}/helm/releases/${namespace}/${name}/${sourceUpgrade ? "source/upgrade-stream" : "upgrade-stream"}?${params.toString()}`,
5978
6310
  options,
5979
6311
  onProgress,
5980
6312
  "Upgrade failed",
@@ -6008,20 +6340,21 @@ export function useHelmPreviewValues() {
6008
6340
  values: Record<string, unknown>;
6009
6341
  version?: string;
6010
6342
  repository?: string;
6343
+ sourceUpgrade?: SourceUpgradeSelection;
6011
6344
  }
6012
6345
  >({
6013
- mutationFn: async ({ namespace, name, values, version, repository }) => {
6346
+ mutationFn: async ({ namespace, name, values, version, repository, sourceUpgrade }) => {
6014
6347
  const response = await apiFetch(
6015
- `${getApiBase()}/helm/releases/${namespace}/${name}/values/preview`,
6348
+ `${getApiBase()}/helm/releases/${namespace}/${name}/${sourceUpgrade ? "source/preview" : "values/preview"}`,
6016
6349
  {
6017
6350
  method: "POST",
6018
6351
  headers: { "Content-Type": "application/json" },
6019
- body: JSON.stringify({ values, version, repository }),
6352
+ body: JSON.stringify({ values, version, repository, sourceUpgrade }),
6020
6353
  },
6021
6354
  );
6022
6355
  if (!response.ok) {
6023
6356
  const error = await readErrorBody(response);
6024
- throw new Error(error.error || `HTTP ${response.status}`);
6357
+ throw error.errorCode === 'chart_source_changed' || error.errorCode === 'chart_source_required' ? new HelmSourceSelectionError(error.error || 'Source changed; select it again') : new Error(error.error || `HTTP ${response.status}`);
6025
6358
  }
6026
6359
  return response.json();
6027
6360
  },
@@ -6144,11 +6477,94 @@ export function useHelmOCISources() {
6144
6477
  });
6145
6478
  }
6146
6479
 
6480
+ export function useHelmSourceStatus(namespace: string, releaseName: string, enabled = true) {
6481
+ return useQuery<ChartSourceStatus>({
6482
+ queryKey: ["helm-source-status", namespace, releaseName],
6483
+ queryFn: () => fetchJSON(`/helm/releases/${encodeURIComponent(namespace)}/${encodeURIComponent(releaseName)}/source`),
6484
+ enabled: enabled && Boolean(namespace && releaseName),
6485
+ });
6486
+ }
6487
+
6488
+ export function useHelmSourceVersions(namespace: string, releaseName: string, selection: SourceUpgradeSelection | null, enabled: boolean) {
6489
+ const { support, gatedKey, guard } = useRadarFeature('helmSourceIdentity')
6490
+ return useQuery<string[]>({
6491
+ queryKey: ['helm-source-versions', namespace, releaseName, selection, gatedKey],
6492
+ enabled: enabled && selection !== null && support === 'supported',
6493
+ queryFn: () => guard(() => {
6494
+ if (!selection) throw new Error('Select a chart source')
6495
+ const params = new URLSearchParams({type: selection.source.type, reference: selection.source.reference})
6496
+ if (selection.source.url) params.set('url', selection.source.url)
6497
+ return fetchJSON(`/helm/releases/${encodeURIComponent(namespace)}/${encodeURIComponent(releaseName)}/source/versions?${params}`)
6498
+ }),
6499
+ })
6500
+ }
6501
+
6502
+ async function mutateHelmSource(namespace: string, releaseName: string, source: ChartSourceCandidate): Promise<void> {
6503
+ const response = await apiFetch(apiUrl(`/helm/releases/${encodeURIComponent(namespace)}/${encodeURIComponent(releaseName)}/source`), {
6504
+ method: "PUT",
6505
+ headers: { "Content-Type": "application/json" },
6506
+ body: JSON.stringify(source),
6507
+ });
6508
+ if (!response.ok) {
6509
+ const error = await response.json().catch(() => ({ error: "Unknown error" }));
6510
+ throw new Error(error.error || `HTTP ${response.status}`);
6511
+ }
6512
+ }
6513
+
6514
+ export function useSetHelmSource(namespace: string, releaseName: string) {
6515
+ const queryClient = useQueryClient();
6516
+ return useMutation({
6517
+ mutationFn: (source: ChartSourceCandidate) => mutateHelmSource(namespace, releaseName, source),
6518
+ meta: { errorMessage: "Failed to associate chart source", successMessage: "Chart source associated" },
6519
+ onSuccess: () => {
6520
+ queryClient.invalidateQueries({ queryKey: ["helm-source-status", namespace, releaseName] });
6521
+ queryClient.invalidateQueries({ queryKey: ["helm-source-versions", namespace, releaseName] });
6522
+ queryClient.invalidateQueries({ queryKey: ["helm-upgrade-info"] });
6523
+ queryClient.invalidateQueries({ queryKey: ["helm-release-versions"] });
6524
+ queryClient.invalidateQueries({ queryKey: ["helm-batch-upgrade-info"] });
6525
+ },
6526
+ });
6527
+ }
6528
+
6529
+ interface AddHelmRepositoryRequest {
6530
+ name: string
6531
+ url: string
6532
+ namespace?: string
6533
+ releaseName?: string
6534
+ }
6535
+
6536
+ export function useAddHelmRepository() {
6537
+ const queryClient = useQueryClient();
6538
+ return useMutation({
6539
+ mutationFn: async (request: AddHelmRepositoryRequest): Promise<{ status: string; name: string }> => {
6540
+ const response = await apiFetch(apiUrl('/helm/repositories'), {
6541
+ method: "POST",
6542
+ headers: { "Content-Type": "application/json" },
6543
+ body: JSON.stringify(request),
6544
+ });
6545
+ if (!response.ok) {
6546
+ const error = await response.json().catch(() => ({ error: "Unknown error" }));
6547
+ throw new Error(error.error || `HTTP ${response.status}`);
6548
+ }
6549
+ return response.json();
6550
+ },
6551
+ meta: { errorMessage: "Failed to add Helm repository", successMessage: "Helm repository added" },
6552
+ // Also on error: the repository can be saved before associating it fails.
6553
+ onSettled: () => {
6554
+ queryClient.invalidateQueries({ queryKey: ["helm-repositories"] });
6555
+ queryClient.invalidateQueries({ queryKey: ["helm-source-status"] });
6556
+ queryClient.invalidateQueries({ queryKey: ["helm-upgrade-info"] });
6557
+ queryClient.invalidateQueries({ queryKey: ["helm-release-versions"] });
6558
+ queryClient.invalidateQueries({ queryKey: ["helm-batch-upgrade-info"] });
6559
+ },
6560
+ });
6561
+ }
6562
+
6147
6563
  async function mutateOCISource(
6148
6564
  method: "POST" | "DELETE",
6149
6565
  source: string,
6150
6566
  ): Promise<string[]> {
6151
- const response = await apiFetch(`${getApiBase()}/helm/oci-sources`, {
6567
+ const response = await apiFetch(apiUrl('/helm/oci-sources'), {
6152
6568
  method,
6153
6569
  headers: { "Content-Type": "application/json" },
6154
6570
  body: JSON.stringify({ source }),
@@ -6160,14 +6576,18 @@ async function mutateOCISource(
6160
6576
  return response.json();
6161
6577
  }
6162
6578
 
6163
- // Invalidate the upgrade-info queries so a newly-registered source is probed
6164
- // immediately and "source not tracked" re-resolves.
6165
- function invalidateHelmAfterSourceChange(
6579
+ // Invalidate source inventory/status and upgrade info so an open source dialog
6580
+ // and upgrade checks immediately reflect source additions or removals.
6581
+ export function invalidateHelmAfterSourceChange(
6166
6582
  queryClient: ReturnType<typeof useQueryClient>,
6167
6583
  ) {
6168
- queryClient.invalidateQueries({ queryKey: ["helm-oci-sources"] });
6169
- queryClient.invalidateQueries({ queryKey: ["helm-upgrade-info"] });
6170
- queryClient.invalidateQueries({ queryKey: ["helm-batch-upgrade-info"] });
6584
+ return Promise.all([
6585
+ queryClient.invalidateQueries({ queryKey: ["helm-oci-sources"] }),
6586
+ queryClient.invalidateQueries({ queryKey: ["helm-source-status"] }),
6587
+ queryClient.invalidateQueries({ queryKey: ["helm-upgrade-info"] }),
6588
+ queryClient.invalidateQueries({ queryKey: ["helm-release-versions"] }),
6589
+ queryClient.invalidateQueries({ queryKey: ["helm-batch-upgrade-info"] }),
6590
+ ])
6171
6591
  }
6172
6592
 
6173
6593
  export function useAddOCISource() {
@@ -6260,6 +6680,7 @@ export function useInstallChart() {
6260
6680
 
6261
6681
  // Install progress event types
6262
6682
  export interface InstallProgressEvent {
6683
+ errorCode?: string;
6263
6684
  type: "progress" | "complete" | "error";
6264
6685
  phase?: string;
6265
6686
  message?: string;
@@ -6520,13 +6941,16 @@ export const useFluxResume = createGitOpsMutation<FluxResourceVars>({
6520
6941
  export const useFluxSyncWithSource = createGitOpsMutation<FluxResourceVars>({
6521
6942
  getPath: (v) => `/flux/${v.kind}/${v.namespace}/${v.name}/sync-with-source`,
6522
6943
  errorMessage: "Failed to sync with source",
6523
- successMessage: "Sync with source triggered",
6944
+ // The server names what it reconciled, and says when a source was skipped.
6945
+ getSuccessMessage: (data) => data.message,
6524
6946
  getInvalidateKeys: (v) => [
6525
6947
  ...fluxInvalidateKeys(v),
6526
6948
  // Also invalidate source resources as they were reconciled too
6527
6949
  ["resources", "gitrepositories"],
6528
6950
  ["resources", "ocirepositories"],
6529
6951
  ["resources", "helmrepositories"],
6952
+ ["resources", "helmcharts"],
6953
+ ["resources", "buckets"],
6530
6954
  ],
6531
6955
  });
6532
6956
 
@@ -6782,8 +7206,35 @@ export function useNamespaceScope() {
6782
7206
  });
6783
7207
  }
6784
7208
 
6785
- const NAMESPACE_SWITCH_TIMEOUT = 5000;
7209
+ const NAMESPACE_SWITCH_TIMEOUT = 15000;
6786
7210
  const NAMESPACE_RESCOPE_TIMEOUT = 120000;
7211
+ const NAMESPACE_RECONCILE_TIMEOUT = 5000;
7212
+
7213
+ // After a switch times out on the client the server may still have applied
7214
+ // it. Returns the server's scope when it holds exactly the requested pick, so
7215
+ // a slow success is not reported as a failure.
7216
+ export async function reconcileNamespaceSwitch(
7217
+ namespaces: string[],
7218
+ ): Promise<NamespaceScope | null> {
7219
+ const controller = new AbortController();
7220
+ const timeoutId = setTimeout(
7221
+ () => controller.abort(),
7222
+ NAMESPACE_RECONCILE_TIMEOUT,
7223
+ );
7224
+ try {
7225
+ const scope = await fetchJSON<NamespaceScope>(
7226
+ "/cluster/namespace-scope",
7227
+ controller.signal,
7228
+ );
7229
+ const want = [...new Set(namespaces)].sort().join(",");
7230
+ const got = [...new Set(scope.actives)].sort().join(",");
7231
+ return want === got ? scope : null;
7232
+ } catch {
7233
+ return null;
7234
+ } finally {
7235
+ clearTimeout(timeoutId);
7236
+ }
7237
+ }
6787
7238
 
6788
7239
  export function debugNamespaceLog(
6789
7240
  label: string,
@@ -6799,6 +7250,20 @@ export function debugNamespaceLog(
6799
7250
  });
6800
7251
  }
6801
7252
 
7253
+ /**
7254
+ * A cache-scoped switch rebuilds the watched inventory. View-filter switches
7255
+ * use namespace-specific query keys and do not invalidate the whole client.
7256
+ */
7257
+ export async function refreshAfterNamespaceSwitch(
7258
+ queryClient: QueryClient,
7259
+ scope: Pick<NamespaceScope, "cacheScoped" | "actives">,
7260
+ ): Promise<void> {
7261
+ if (!scope.cacheScoped) return;
7262
+ const notScope = (query: { queryKey: readonly unknown[] }) =>
7263
+ query.queryKey[0] !== "namespace-scope";
7264
+ await queryClient.invalidateQueries({ predicate: notScope }, { cancelRefetch: false });
7265
+ }
7266
+
6802
7267
  export function useSetActiveNamespace() {
6803
7268
  const queryClient = useQueryClient();
6804
7269
  return useMutation<NamespaceScope, Error, { namespaces: string[] }>({
@@ -6820,7 +7285,7 @@ export function useSetActiveNamespace() {
6820
7285
  // flag). If the scope query is missing/stale we can't yet tell a cheap
6821
7286
  // view-filter change from a cache-rebuilding rescope, so bias to the long
6822
7287
  // timeout — only a confirmed non-scoped session gets the fast switch timeout.
6823
- // Aborting a real rebuild at 5s surfaces a spurious failure while the server
7288
+ // Aborting a real rebuild at the switch timeout surfaces a spurious failure while the server
6824
7289
  // keeps going.
6825
7290
  const isRescope = currentScope?.cacheScoped !== false;
6826
7291
  const timeoutMs = isRescope
@@ -6854,6 +7319,13 @@ export function useSetActiveNamespace() {
6854
7319
  error: error instanceof Error ? error.message : String(error),
6855
7320
  });
6856
7321
  if (error instanceof Error && error.name === "AbortError") {
7322
+ // A rescope publishes its target before the rebuild finishes and can
7323
+ // still roll back, so only a view-filter pick is proven by the scope.
7324
+ const applied = isRescope ? null : await reconcileNamespaceSwitch(namespaces);
7325
+ if (applied) {
7326
+ debugNamespaceLog("mutation:timeout-but-applied", { namespaces });
7327
+ return applied;
7328
+ }
6857
7329
  throw new Error(
6858
7330
  isRescope
6859
7331
  ? "Namespace rescope timed out. The cluster may still be loading."
@@ -6872,13 +7344,11 @@ export function useSetActiveNamespace() {
6872
7344
  });
6873
7345
  if (scope.cacheScoped) {
6874
7346
  queryClient.removeQueries({
6875
- predicate: (query) => query.queryKey[0] !== "namespace-scope",
7347
+ predicate: (query) => query.queryKey[0] !== "namespace-scope" && query.queryKey[0] !== "node-drain-activity",
6876
7348
  });
6877
7349
  }
6878
7350
  queryClient.setQueryData<NamespaceScope>(["namespace-scope"], scope);
6879
- if (scope.cacheScoped) {
6880
- queryClient.invalidateQueries();
6881
- }
7351
+ void refreshAfterNamespaceSwitch(queryClient, scope);
6882
7352
  debugNamespaceLog("mutation:success-after-scope-cache-write");
6883
7353
  },
6884
7354
  onError: () => {
@@ -7072,21 +7542,25 @@ export function useWorkloadRuns(
7072
7542
  namespace: string,
7073
7543
  name: string,
7074
7544
  enabled = true,
7075
- options?: { refetchActive?: boolean; clusterScoped?: boolean; role?: string; search?: string; state?: string; selected?: string },
7545
+ options?: { refetchActive?: boolean; clusterScoped?: boolean; namespaces?: string[]; role?: string; search?: string; state?: string; selected?: string; ownerUID?: string },
7076
7546
  ) {
7077
7547
  const clusterScoped = options?.clusterScoped ?? false;
7078
7548
  const ns = clusterScoped ? "_" : namespace;
7549
+ // A cluster-scoped template's runs live in many namespaces; the view's
7550
+ // namespace selection narrows them, as it does every other list.
7551
+ const viewNamespaces = clusterScoped ? (options?.namespaces ?? []).join(",") : "";
7079
7552
  const params = new URLSearchParams();
7080
7553
  if (clusterScoped) params.set("clusterScoped", "true");
7554
+ if (viewNamespaces) params.set("namespaces", viewNamespaces);
7081
7555
  for (const key of ["role", "search", "state", "selected"] as const) { if (options?.[key]) params.set(key, options[key]); }
7082
7556
  const queryString = params.toString();
7083
7557
 
7084
7558
  return useQuery<WorkloadRunsResponse>({
7085
- queryKey: ["workload-runs", kind, namespace, name, clusterScoped, options?.role ?? '', options?.search ?? '', options?.state ?? '', options?.selected ?? ''],
7559
+ queryKey: ["workload-runs", kind, namespace, name, clusterScoped, viewNamespaces, options?.role ?? '', options?.search ?? '', options?.state ?? '', options?.selected ?? '', options?.ownerUID ?? ''],
7086
7560
  placeholderData: (previous, query) => {
7087
7561
  if (previous?.collection !== 'members') return undefined
7088
- const identity = ["workload-runs", kind, namespace, name, clusterScoped, options?.role ?? '', options?.search ?? '', options?.state ?? '']
7089
- return identity.every((value, index) => query?.queryKey[index] === value) ? previous : undefined
7562
+ const identity = ["workload-runs", kind, namespace, name, clusterScoped, viewNamespaces, options?.role ?? '', options?.search ?? '', options?.state ?? '']
7563
+ return identity.every((value, index) => query?.queryKey[index] === value) && query?.queryKey[10] === (options?.ownerUID ?? '') ? previous : undefined
7090
7564
  },
7091
7565
  queryFn: () =>
7092
7566
  fetchJSON(
@@ -7322,6 +7796,8 @@ export interface DiagnosticsSnapshot {
7322
7796
  };
7323
7797
  timeline?: {
7324
7798
  storageType: string;
7799
+ degraded?: boolean;
7800
+ degradedReason?: string;
7325
7801
  totalEvents: number;
7326
7802
  oldestEvent?: string;
7327
7803
  newestEvent?: string;
@@ -7396,6 +7872,7 @@ export interface DiagnosticsSnapshot {
7396
7872
  historyLimit: number;
7397
7873
  debugEvents: boolean;
7398
7874
  mcpEnabled: boolean;
7875
+ mcpReadOnly: boolean;
7399
7876
  hasPrometheusURL: boolean;
7400
7877
  hasPrometheusHeaders: boolean;
7401
7878
  };