@skyhook-io/radar-app 1.17.1 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/package.json +9 -9
  2. package/src/App.tsx +14 -30
  3. package/src/api/client.gitopsPoll.test.ts +99 -0
  4. package/src/api/client.helmPreview.test.tsx +48 -0
  5. package/src/api/client.resourceAvailability.test.ts +24 -0
  6. package/src/api/client.ts +337 -87
  7. package/src/api/client.workloadRuns.test.ts +53 -0
  8. package/src/api/config.test.ts +23 -1
  9. package/src/api/config.ts +7 -3
  10. package/src/api/diagnose.ts +4 -1
  11. package/src/api/drain-plan.test.ts +70 -40
  12. package/src/api/policy.ts +5 -5
  13. package/src/api/radarFeatures.ts +1 -0
  14. package/src/api/traffic.scope.render.test.tsx +60 -0
  15. package/src/api/traffic.ts +3 -1
  16. package/src/components/cnpg/CNPGSummaryHost.tsx +4 -3
  17. package/src/components/diagnose/DiagnoseSurface.tsx +3 -3
  18. package/src/components/diagnose/InvestigationChangesEvidence.test.tsx +352 -0
  19. package/src/components/diagnose/InvestigationEvidencePane.test.tsx +101 -0
  20. package/src/components/diagnose/InvestigationView.tsx +2 -1
  21. package/src/components/diagnose/investigationEvidence/adapters/changes.test.ts +123 -0
  22. package/src/components/diagnose/investigationEvidence/adapters/changes.ts +192 -3
  23. package/src/components/diagnose/investigationEvidence/adapters/issues.ts +73 -51
  24. package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +64 -2
  25. package/src/components/diagnose/investigationEvidence/adapters/resource.test.ts +37 -0
  26. package/src/components/diagnose/investigationEvidence/adapters/testdata/get-changes-created.json +323 -0
  27. package/src/components/diagnose/investigationEvidence/bodies/streams.tsx +144 -15
  28. package/src/components/diagnose/investigationEvidence/observations.ts +20 -0
  29. package/src/components/diagnose/investigationEvidence/parse.ts +57 -1
  30. package/src/components/diagnose/investigationEvidence/projection.test.ts +107 -0
  31. package/src/components/diagnose/investigationEvidence/types.ts +11 -0
  32. package/src/components/diagnose/investigationEvidencePresentation.test.ts +18 -0
  33. package/src/components/diagnose/investigationState.test.ts +36 -1
  34. package/src/components/diagnose/investigationState.ts +8 -0
  35. package/src/components/diagnose/launch.ts +2 -2
  36. package/src/components/dock/BottomDock.tsx +6 -3
  37. package/src/components/dock/WorkloadLogsTab.tsx +3 -0
  38. package/src/components/execution/BatchExecutionView.render.test.tsx +29 -1
  39. package/src/components/execution/BatchExecutionView.tsx +23 -8
  40. package/src/components/execution/cluster-template-runs.render.test.tsx +42 -0
  41. package/src/components/gitops/GitOpsView.tsx +7 -0
  42. package/src/components/helm/HelmReleaseDrawer.tsx +139 -55
  43. package/src/components/helm/HelmReleaseNotes.test.tsx +42 -0
  44. package/src/components/helm/HelmReleaseNotes.tsx +26 -0
  45. package/src/components/helm/OwnedResources.tsx +2 -2
  46. package/src/components/helm/TrackChartSourceDialog.render.test.tsx +76 -4
  47. package/src/components/helm/TrackChartSourceDialog.test.ts +3 -2
  48. package/src/components/helm/TrackChartSourceDialog.tsx +41 -15
  49. package/src/components/helm/ValuesDiffPreview.tsx +4 -1
  50. package/src/components/home/ClusterHealthCard.tsx +4 -4
  51. package/src/components/home/CostCard.test.tsx +100 -0
  52. package/src/components/home/CostCard.tsx +2 -2
  53. package/src/components/home/HelmSummary.tsx +2 -2
  54. package/src/components/home/HomeView.tsx +15 -6
  55. package/src/components/home/MCPSetupDialog.test.tsx +30 -0
  56. package/src/components/home/MCPSetupDialog.tsx +13 -6
  57. package/src/components/home/ProblemsPanel.test.tsx +1 -0
  58. package/src/components/home/mcpToolCatalog.ts +18 -2
  59. package/src/components/issues/IssuesPane.render.test.tsx +21 -0
  60. package/src/components/issues/IssuesPane.tsx +31 -7
  61. package/src/components/issues/UncheckedSourceHelp.test.tsx +42 -0
  62. package/src/components/issues/UncheckedSourceHelp.tsx +24 -0
  63. package/src/components/issues/uncheckedSources.test.ts +43 -0
  64. package/src/components/issues/uncheckedSources.ts +58 -5
  65. package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +4 -2
  66. package/src/components/resources/ImageFilesystemModal.test.tsx +68 -0
  67. package/src/components/resources/ImageFilesystemModal.tsx +11 -4
  68. package/src/components/resources/PodFilesystemModal.tsx +2 -2
  69. package/src/components/resources/ResourcesView.scope.render.test.tsx +58 -0
  70. package/src/components/resources/ResourcesView.tsx +18 -3
  71. package/src/components/resources/renderers/FluxHelmReleaseRenderer.test.tsx +111 -0
  72. package/src/components/resources/renderers/FluxHelmReleaseRenderer.tsx +67 -0
  73. package/src/components/resources/renderers/KyvernoPolicyCoverage.scope.render.test.tsx +64 -0
  74. package/src/components/resources/renderers/KyvernoPolicyCoverage.tsx +6 -7
  75. package/src/components/settings/SettingsDialog.tsx +21 -15
  76. package/src/components/traffic/TrafficFilterSidebar.test.tsx +77 -0
  77. package/src/components/traffic/TrafficFilterSidebar.tsx +42 -31
  78. package/src/components/traffic/TrafficView.tsx +12 -12
  79. package/src/components/traffic/trafficFilters.test.ts +20 -1
  80. package/src/components/traffic/trafficFilters.ts +13 -0
  81. package/src/components/ui/Omnibar.tsx +13 -2
  82. package/src/components/ui/Toast.tsx +1 -1
  83. package/src/components/ui/omnibar-match.test.ts +30 -0
  84. package/src/components/ui/omnibar-match.ts +18 -0
  85. package/src/components/workload/CronJobSchedulingEvidence.test.tsx +35 -0
  86. package/src/components/workload/CronJobSchedulingEvidence.tsx +37 -0
  87. package/src/components/workload/NodeDrainStatus.test.tsx +253 -0
  88. package/src/components/workload/NodeDrainStatus.tsx +55 -0
  89. package/src/components/workload/WorkloadView.tsx +37 -5
  90. package/src/context/ConnectionContext.test.ts +27 -1
  91. package/src/context/ConnectionContext.tsx +17 -7
  92. package/src/integrations/resourceHosts.test.tsx +1 -0
  93. package/src/integrations/resourceHosts.tsx +2 -0
  94. package/src/utils/navigation.ts +14 -0
  95. package/src/utils/wails-clipboard.ts +4 -2
package/src/api/client.ts CHANGED
@@ -1,4 +1,5 @@
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
4
  import { useEffect, useRef, useCallback, useMemo } from 'react'
4
5
  import type { KueueAdmissionResponse } from '@skyhook-io/k8s-ui/types/scheduling'
@@ -22,7 +23,7 @@ import type {
22
23
  YamlSchemaLoadResult,
23
24
  } from '@skyhook-io/k8s-ui'
24
25
  import { useQuery, useMutation, useQueryClient, skipToken, type QueryClient } from '@tanstack/react-query'
25
- import { showApiError, showApiSuccess } from '../components/ui/Toast'
26
+ import { showApiError, showApiSuccess, showApiNotice } from '../components/ui/Toast'
26
27
  import { useIsAuthEnabled, useNamespacedCapabilities } from '../contexts/CapabilitiesContext'
27
28
  import type {
28
29
  Topology,
@@ -43,6 +44,7 @@ import type {
43
44
  UpgradeInfo,
44
45
  BatchUpgradeInfo,
45
46
  ChartSourceCandidate,
47
+ SourceUpgradeSelection,
46
48
  ChartSourceStatus,
47
49
  ValuesDiff,
48
50
  ValuesPreviewResponse,
@@ -755,22 +757,43 @@ export interface IssuesResponse {
755
757
  recent_changes_reason?: string
756
758
  recent_changes_guidance?: string
757
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
+ }
758
767
  // Present only when RBAC visibility is incomplete (absent = full access).
759
768
  // state 'degraded' means core workload reads are denied, so an empty list may
760
769
  // mean "can't see" rather than "nothing broken" — the UI must say so.
761
770
  visibility?: { state?: string; impact?: string };
762
771
  // Issue sources Radar couldn't check, so their issues may be missing: an
763
- // empty list is not an all-clear. Today only "helm"; a newer Radar may send
764
- // others. Absent when every source was checked, and from older Radars.
765
- unchecked_sources?: { source: string; reason: string }[];
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[];
766
776
  }
767
777
 
768
- export function useIssues(namespaces: string[] = [], enabled = true) {
769
- const params =
770
- 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();
771
794
  return useQuery<IssuesResponse>({
772
- queryKey: ["issues", namespaces],
773
- queryFn: () => fetchJSON(`/issues${params}`),
795
+ queryKey: kind ? ["issues", namespaces, kind] : ["issues", namespaces],
796
+ queryFn: () => fetchJSON(`/issues${query ? `?${query}` : ''}`),
774
797
  staleTime: 30000,
775
798
  refetchInterval: ISSUES_REFRESH_INTERVAL_MS,
776
799
  enabled,
@@ -828,7 +851,18 @@ export function useResourceIssues(
828
851
  // The Issues page narrowed to one subject: the same per-resource lookup with
829
852
  // ?coverage=1, which also says whether Radar reads the subject's kind and what
830
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
+
831
864
  export interface SubjectIssuesResponse {
865
+ scheduling_report?: CronJobSchedulingEvidence;
832
866
  issues: Issue[];
833
867
  coverage: "ok" | "syncing" | "notWatched" | "unknownKind";
834
868
  withheld?: { issues: number };
@@ -836,7 +870,7 @@ export interface SubjectIssuesResponse {
836
870
  }
837
871
 
838
872
  export function useSubjectIssues(
839
- subject: { kind: string; group: string; namespace: string; name: string } | null,
873
+ subject: { kind: string; group: string; namespace: string; name: string; uid?: string } | null,
840
874
  enabled: boolean,
841
875
  ) {
842
876
  const capabilities = useCapabilities();
@@ -845,7 +879,7 @@ export function useSubjectIssues(
845
879
  const params = new URLSearchParams({ coverage: "1" });
846
880
  if (subject?.group) params.set("group", subject.group);
847
881
  return useQuery<SubjectIssuesResponse>({
848
- queryKey: ["issues", "subject", subject?.kind ?? "", subject?.group ?? "", subject?.namespace ?? "", subject?.name ?? "", support, ...gatedKey],
882
+ queryKey: ["issues", "subject", subject?.kind ?? "", subject?.group ?? "", subject?.namespace ?? "", subject?.name ?? "", subject?.uid ?? "", support, ...gatedKey],
849
883
  queryFn: () => {
850
884
  if (!capabilities.data && capabilities.error) throw capabilities.error;
851
885
  return guard(() => fetchJSON<SubjectIssuesResponse>(`/issues/resource/${encodeURIComponent(subject!.kind)}/${pathNs}/${encodeURIComponent(subject!.name)}?${params}`));
@@ -1101,12 +1135,14 @@ function costRefetchInterval(
1101
1135
  };
1102
1136
  }
1103
1137
 
1104
- export function useOpenCostSummary(enabled = true) {
1138
+ export function useOpenCostSummary(enabled = true, namespaces: string[] = []) {
1105
1139
  const clusterInfo = useClusterInfo();
1140
+ const params =
1141
+ namespaces.length > 0 ? `?namespaces=${namespaces.join(",")}` : "";
1106
1142
  return useQuery<OpenCostSummary>({
1107
- queryKey: ["opencost-summary"],
1143
+ queryKey: ["opencost-summary", namespaces],
1108
1144
  enabled,
1109
- queryFn: () => fetchJSON("/opencost/summary"),
1145
+ queryFn: () => fetchJSON(`/opencost/summary${params}`),
1110
1146
  refetchInterval: costRefetchInterval(
1111
1147
  COST_REFRESH_INTERVAL_MS,
1112
1148
  clusterInfo.data?.context,
@@ -1967,6 +2003,10 @@ export interface SearchResult {
1967
2003
  total: number;
1968
2004
  searched: number;
1969
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;
1970
2010
  }
1971
2011
 
1972
2012
  const SEARCH_MIN_QUERY = 2;
@@ -2517,9 +2557,37 @@ export function useApplicationHistory(
2517
2557
  }
2518
2558
 
2519
2559
  // How often a page asks again while Radar is still connecting to argocd-server,
2520
- // and while it retries a connect that failed.
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.
2521
2567
  const ARGO_CONNECTING_POLL_MS = 2000;
2522
- const ARGO_RETRYING_POLL_MS = 10_000;
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
+ }
2523
2591
 
2524
2592
  export function useGitOpsTree(
2525
2593
  kind: string,
@@ -2545,12 +2613,7 @@ export function useGitOpsTree(
2545
2613
  staleTime: 5000,
2546
2614
  // Radar answers at once while it connects to argocd-server; ask again
2547
2615
  // until Argo's per-resource health is in.
2548
- refetchInterval: (query) =>
2549
- query.state.data?.healthApiPending
2550
- ? ARGO_CONNECTING_POLL_MS
2551
- : query.state.data?.healthApiRetrying
2552
- ? ARGO_RETRYING_POLL_MS
2553
- : false,
2616
+ refetchInterval: gitopsTreeRefetchInterval,
2554
2617
  });
2555
2618
  }
2556
2619
 
@@ -2560,6 +2623,27 @@ export function useGitOpsTree(
2560
2623
  // auto-quiesces on completion.
2561
2624
  const INSIGHTS_RUNNING_POLL_MS = 2000;
2562
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
+
2563
2647
  export function useGitOpsInsights(
2564
2648
  kind: string,
2565
2649
  namespace: string,
@@ -2581,19 +2665,7 @@ export function useGitOpsInsights(
2581
2665
  ),
2582
2666
  enabled: Boolean(kind && name),
2583
2667
  staleTime: 5000,
2584
- refetchInterval: (query) => {
2585
- const phase = query.state.data?.summary?.operationPhase;
2586
- if (phase === "Running" || phase === "Terminating") {
2587
- return INSIGHTS_RUNNING_POLL_MS;
2588
- }
2589
- const summary = query.state.data?.summary;
2590
- if (summary?.resourceHealthApiPending || query.state.data?.capabilities?.argoConnecting) {
2591
- return ARGO_CONNECTING_POLL_MS;
2592
- }
2593
- return summary?.resourceHealthApiRetrying || query.state.data?.capabilities?.argoRetrying
2594
- ? ARGO_RETRYING_POLL_MS
2595
- : false;
2596
- },
2668
+ refetchInterval: gitopsInsightsRefetchInterval,
2597
2669
  });
2598
2670
  }
2599
2671
 
@@ -2774,6 +2846,32 @@ export function useResource<T>(
2774
2846
  };
2775
2847
  }
2776
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
+
2777
2875
  // Hook that returns full response with relationships explicitly
2778
2876
  export function useResourceWithRelationships<T>(
2779
2877
  kind: string,
@@ -5543,10 +5641,46 @@ export function useNodeRemovalPlan(name: string | undefined, enabled: boolean) {
5543
5641
  })
5544
5642
  }
5545
5643
 
5546
- 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) {
5547
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 = "") {
5679
+ const queryClient = useQueryClient();
5680
+ const apiBase = getApiBase();
5548
5681
 
5549
5682
  return useMutation({
5683
+ retry: false,
5550
5684
  mutationFn: async ({
5551
5685
  name,
5552
5686
  options,
@@ -5554,7 +5688,7 @@ export function useDrainNode() {
5554
5688
  name: string;
5555
5689
  options?: DrainNodeOptions;
5556
5690
  }) => {
5557
- const response = await apiFetch(`${getApiBase()}/nodes/${name}/drain`, {
5691
+ const response = await apiFetch(apiUrl(`/nodes/${encodeURIComponent(name)}/drain`, apiBase), {
5558
5692
  method: "POST",
5559
5693
  headers: options ? { "Content-Type": "application/json" } : {},
5560
5694
  body: options ? JSON.stringify(options) : undefined,
@@ -5565,6 +5699,37 @@ export function useDrainNode() {
5565
5699
  }
5566
5700
  return response.json();
5567
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
+ },
5568
5733
  meta: {
5569
5734
  errorMessage: "Failed to drain node",
5570
5735
  // No static successMessage — handled in onSuccess to distinguish partial failures
@@ -5574,20 +5739,41 @@ export function useDrainNode() {
5574
5739
  evictedPods?: string[];
5575
5740
  skippedPods?: DrainPlanPod[];
5576
5741
  errors?: string[];
5742
+ pendingPods?: string[];
5743
+ waitedForDeletion?: boolean;
5744
+ outcome?: DrainCompletionOutcome;
5745
+ unconfirmedPods?: string[];
5746
+ verificationError?: string;
5577
5747
  },
5578
5748
  variables,
5749
+ context,
5579
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;
5580
5766
  queryClient.invalidateQueries({ queryKey: ["resources", "nodes"] });
5581
5767
  queryClient.invalidateQueries({
5582
5768
  queryKey: ["resource", "nodes", "", variables.name],
5583
5769
  });
5584
5770
  queryClient.invalidateQueries({ queryKey: ["topology"] });
5585
-
5586
- const { title, detail, failed } = describeDrainResult(data);
5587
- if (failed) {
5771
+ if (type === "error") {
5588
5772
  showApiError(title, detail);
5589
- } else {
5773
+ } else if (type === "success") {
5590
5774
  showApiSuccess(title, detail);
5775
+ } else {
5776
+ showApiNotice(title, detail, type);
5591
5777
  }
5592
5778
  },
5593
5779
  });
@@ -5601,47 +5787,86 @@ function listWithOverflow(items: string[]): string {
5601
5787
  return rest > 0 ? `${shown.join("; ")}; +${rest} more` : shown.join("; ");
5602
5788
  }
5603
5789
 
5604
- /**
5605
- * Turns the drain response into a legible summary: evicted, skipped (with reasons),
5606
- * failed. Lists are capped so the toast stays readable on nodes with many pods.
5607
- */
5608
- export function describeDrainResult(data: {
5790
+ export type DrainCompletionOutcome = "complete" | "incomplete" | "unconfirmed" | "started";
5791
+
5792
+ interface DrainResultData {
5609
5793
  evictedPods?: string[];
5610
5794
  skippedPods?: DrainPlanPod[];
5611
5795
  errors?: string[];
5612
- }): { title: string; detail: string; failed: boolean } {
5613
- const evicted = data?.evictedPods?.length ?? 0;
5614
- const skipped = data?.skippedPods ?? [];
5615
- 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
+ );
5616
5825
  const parts: string[] = [];
5617
- if (skipped.length > 0) {
5618
- parts.push(
5619
- `Skipped ${skipped.length}: ${listWithOverflow(
5620
- skipped.map((p) => `${p.namespace}/${p.name} (${p.reason})`),
5621
- )}`,
5622
- );
5623
- }
5624
5826
  if (errors.length > 0) {
5625
- parts.push(`Failed ${errors.length}: ${listWithOverflow(errors)}`);
5827
+ parts.push(`Failed evictions ${errors.length}: ${listWithOverflow(errors)}`);
5626
5828
  }
5627
- parts.push(
5628
- evicted > 0
5629
- ? "Evictions were accepted; those pods may still be terminating. The node remains cordoned."
5630
- : "The node remains cordoned.",
5631
- );
5632
- const detail = parts.join("\n");
5633
- if (errors.length > 0) {
5634
- return {
5635
- title: `Drain finished with ${errors.length} failed eviction(s): ${evicted} evicted, ${skipped.length} skipped`,
5636
- detail,
5637
- failed: true,
5638
- };
5829
+ if (pending.length > 0) {
5830
+ parts.push(`Still on the node ${pending.length}: ${listWithOverflow(pending)}`);
5639
5831
  }
5640
- return {
5641
- title: `Node drained: ${evicted} evicted, ${skipped.length} skipped`,
5642
- detail,
5643
- 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`,
5644
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 };
5645
5870
  }
5646
5871
 
5647
5872
  // ============================================================================
@@ -5988,6 +6213,8 @@ export function useHelmUninstall() {
5988
6213
  });
5989
6214
  }
5990
6215
 
6216
+ export class HelmSourceSelectionError extends Error {}
6217
+
5991
6218
  // Stream SSE progress events from a Helm operation endpoint.
5992
6219
  // Resolves on 'complete', rejects on 'error'. Returns the complete event data for install (which includes release).
5993
6220
  function streamHelmProgress(
@@ -6037,7 +6264,7 @@ function streamHelmProgress(
6037
6264
  resolve(data);
6038
6265
  return;
6039
6266
  } else if (data.type === "error") {
6040
- 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));
6041
6268
  return;
6042
6269
  }
6043
6270
  } catch (err) {
@@ -6067,18 +6294,19 @@ export function upgradeWithProgress(
6067
6294
  repositoryName: string | undefined,
6068
6295
  onProgress: (event: InstallProgressEvent) => void,
6069
6296
  values?: Record<string, unknown>,
6297
+ sourceUpgrade?: SourceUpgradeSelection,
6070
6298
  ): Promise<void> {
6071
6299
  const params = new URLSearchParams({ version });
6072
6300
  if (repositoryName) params.set("repository", repositoryName);
6073
- const options: RequestInit = values
6301
+ const options: RequestInit = values || sourceUpgrade
6074
6302
  ? {
6075
6303
  method: "POST",
6076
6304
  headers: { "Content-Type": "application/json" },
6077
- body: JSON.stringify({ values }),
6305
+ body: JSON.stringify({ values, sourceUpgrade }),
6078
6306
  }
6079
6307
  : { method: "POST" };
6080
6308
  return streamHelmProgress(
6081
- `${getApiBase()}/helm/releases/${namespace}/${name}/upgrade-stream?${params.toString()}`,
6309
+ `${getApiBase()}/helm/releases/${namespace}/${name}/${sourceUpgrade ? "source/upgrade-stream" : "upgrade-stream"}?${params.toString()}`,
6082
6310
  options,
6083
6311
  onProgress,
6084
6312
  "Upgrade failed",
@@ -6112,20 +6340,21 @@ export function useHelmPreviewValues() {
6112
6340
  values: Record<string, unknown>;
6113
6341
  version?: string;
6114
6342
  repository?: string;
6343
+ sourceUpgrade?: SourceUpgradeSelection;
6115
6344
  }
6116
6345
  >({
6117
- mutationFn: async ({ namespace, name, values, version, repository }) => {
6346
+ mutationFn: async ({ namespace, name, values, version, repository, sourceUpgrade }) => {
6118
6347
  const response = await apiFetch(
6119
- `${getApiBase()}/helm/releases/${namespace}/${name}/values/preview`,
6348
+ `${getApiBase()}/helm/releases/${namespace}/${name}/${sourceUpgrade ? "source/preview" : "values/preview"}`,
6120
6349
  {
6121
6350
  method: "POST",
6122
6351
  headers: { "Content-Type": "application/json" },
6123
- body: JSON.stringify({ values, version, repository }),
6352
+ body: JSON.stringify({ values, version, repository, sourceUpgrade }),
6124
6353
  },
6125
6354
  );
6126
6355
  if (!response.ok) {
6127
6356
  const error = await readErrorBody(response);
6128
- 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}`);
6129
6358
  }
6130
6359
  return response.json();
6131
6360
  },
@@ -6256,6 +6485,20 @@ export function useHelmSourceStatus(namespace: string, releaseName: string, enab
6256
6485
  });
6257
6486
  }
6258
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
+
6259
6502
  async function mutateHelmSource(namespace: string, releaseName: string, source: ChartSourceCandidate): Promise<void> {
6260
6503
  const response = await apiFetch(apiUrl(`/helm/releases/${encodeURIComponent(namespace)}/${encodeURIComponent(releaseName)}/source`), {
6261
6504
  method: "PUT",
@@ -6275,6 +6518,7 @@ export function useSetHelmSource(namespace: string, releaseName: string) {
6275
6518
  meta: { errorMessage: "Failed to associate chart source", successMessage: "Chart source associated" },
6276
6519
  onSuccess: () => {
6277
6520
  queryClient.invalidateQueries({ queryKey: ["helm-source-status", namespace, releaseName] });
6521
+ queryClient.invalidateQueries({ queryKey: ["helm-source-versions", namespace, releaseName] });
6278
6522
  queryClient.invalidateQueries({ queryKey: ["helm-upgrade-info"] });
6279
6523
  queryClient.invalidateQueries({ queryKey: ["helm-release-versions"] });
6280
6524
  queryClient.invalidateQueries({ queryKey: ["helm-batch-upgrade-info"] });
@@ -6436,6 +6680,7 @@ export function useInstallChart() {
6436
6680
 
6437
6681
  // Install progress event types
6438
6682
  export interface InstallProgressEvent {
6683
+ errorCode?: string;
6439
6684
  type: "progress" | "complete" | "error";
6440
6685
  phase?: string;
6441
6686
  message?: string;
@@ -7099,7 +7344,7 @@ export function useSetActiveNamespace() {
7099
7344
  });
7100
7345
  if (scope.cacheScoped) {
7101
7346
  queryClient.removeQueries({
7102
- predicate: (query) => query.queryKey[0] !== "namespace-scope",
7347
+ predicate: (query) => query.queryKey[0] !== "namespace-scope" && query.queryKey[0] !== "node-drain-activity",
7103
7348
  });
7104
7349
  }
7105
7350
  queryClient.setQueryData<NamespaceScope>(["namespace-scope"], scope);
@@ -7297,21 +7542,25 @@ export function useWorkloadRuns(
7297
7542
  namespace: string,
7298
7543
  name: string,
7299
7544
  enabled = true,
7300
- 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 },
7301
7546
  ) {
7302
7547
  const clusterScoped = options?.clusterScoped ?? false;
7303
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(",") : "";
7304
7552
  const params = new URLSearchParams();
7305
7553
  if (clusterScoped) params.set("clusterScoped", "true");
7554
+ if (viewNamespaces) params.set("namespaces", viewNamespaces);
7306
7555
  for (const key of ["role", "search", "state", "selected"] as const) { if (options?.[key]) params.set(key, options[key]); }
7307
7556
  const queryString = params.toString();
7308
7557
 
7309
7558
  return useQuery<WorkloadRunsResponse>({
7310
- 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 ?? ''],
7311
7560
  placeholderData: (previous, query) => {
7312
7561
  if (previous?.collection !== 'members') return undefined
7313
- const identity = ["workload-runs", kind, namespace, name, clusterScoped, options?.role ?? '', options?.search ?? '', options?.state ?? '']
7314
- 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
7315
7564
  },
7316
7565
  queryFn: () =>
7317
7566
  fetchJSON(
@@ -7623,6 +7872,7 @@ export interface DiagnosticsSnapshot {
7623
7872
  historyLimit: number;
7624
7873
  debugEvents: boolean;
7625
7874
  mcpEnabled: boolean;
7875
+ mcpReadOnly: boolean;
7626
7876
  hasPrometheusURL: boolean;
7627
7877
  hasPrometheusHeaders: boolean;
7628
7878
  };