@skyhook-io/radar-app 1.22.2 → 1.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -8
- package/src/App.tsx +49 -13
- package/src/RadarApp.basename.test.tsx +177 -0
- package/src/RadarApp.settings.test.tsx +33 -0
- package/src/api/agentSandbox.ts +259 -0
- package/src/api/client.autoPromConnect.test.tsx +43 -0
- package/src/api/client.metricsRelayCheck.test.tsx +134 -0
- package/src/api/client.ts +151 -27
- package/src/api/client.updateResource.secretExpiry.test.tsx +47 -0
- package/src/api/cloudInstallDiscover.test.tsx +76 -0
- package/src/api/diagnose.ts +4 -0
- package/src/api/kagent.test.ts +82 -0
- package/src/api/kagent.ts +230 -0
- package/src/api/poll.ts +78 -0
- package/src/api/prometheusCharts.ts +5 -0
- package/src/api/radarFeatures.test.ts +9 -0
- package/src/api/radarFeatures.ts +16 -0
- package/src/api/substrateWorkspace.test.ts +72 -0
- package/src/api/substrateWorkspace.ts +1394 -0
- package/src/api/vulnerabilities.ts +207 -9
- package/src/api/workloadSource.test.tsx +315 -0
- package/src/api/workloadSource.ts +128 -12
- package/src/components/CloudConnectFlow.tsx +46 -7
- package/src/components/CloudFunnelButton.test.tsx +193 -7
- package/src/components/CloudFunnelButton.tsx +128 -32
- package/src/components/SelfManagedStart.tsx +12 -2
- package/src/components/agentsandbox/AgentSandboxKindLists.tsx +41 -0
- package/src/components/agentsandbox/AgentSandboxLists.test.tsx +410 -0
- package/src/components/agentsandbox/AgentSandboxOverview.test.tsx +333 -0
- package/src/components/agentsandbox/AgentSandboxOverview.tsx +555 -0
- package/src/components/agentsandbox/AgentSandboxSidebar.test.tsx +97 -0
- package/src/components/agentsandbox/AgentSandboxSummary.test.tsx +439 -0
- package/src/components/agentsandbox/AgentSandboxSummary.tsx +956 -0
- package/src/components/agentsandbox/AgentSandboxTables.tsx +966 -0
- package/src/components/agentsandbox/AgentSandboxView.tsx +34 -0
- package/src/components/agentsandbox/agentsandbox.fixtures.ts +135 -0
- package/src/components/agentsandbox/data.ts +135 -0
- package/src/components/agentsandbox/host.test.ts +27 -0
- package/src/components/agentsandbox/host.tsx +85 -0
- package/src/components/agentsandbox/labels.test.ts +42 -0
- package/src/components/agentsandbox/labels.ts +146 -0
- package/src/components/agentsandbox/listFilters.ts +85 -0
- package/src/components/agentsandbox/lists.ts +52 -0
- package/src/components/agentsandbox/routes.ts +23 -0
- package/src/components/agentsandbox/shared.tsx +321 -0
- package/src/components/agentsandbox/useAgentSandboxSidebarWorkspace.ts +69 -0
- package/src/components/agentsandbox/workspace.fixtures.ts +125 -0
- package/src/components/agentsandbox/workspace.tsx +258 -0
- package/src/components/agentsandbox/workspaceRoute.ts +18 -0
- package/src/components/applications/ApplicationsView.openResource.test.tsx +248 -3
- package/src/components/applications/ApplicationsView.tsx +156 -3
- package/src/components/audit/VulnerabilitiesColumns.test.tsx +487 -0
- package/src/components/audit/VulnerabilitiesRisk.test.tsx +318 -0
- package/src/components/audit/VulnerabilitiesView.test.tsx +458 -13
- package/src/components/audit/VulnerabilitiesView.tsx +639 -199
- package/src/components/cloudHints/AgentSetupCloudRow.tsx +28 -0
- package/src/components/cloudHints/CloudHintLink.tsx +29 -0
- package/src/components/cloudHints/SharedInstallAiLine.tsx +36 -0
- package/src/components/cloudHints/cloudHints.test.ts +126 -0
- package/src/components/cloudHints/cloudHints.ts +131 -0
- package/src/components/cloudHints/cloudHintsGate.test.tsx +70 -0
- package/src/components/cloudHints/cloudLinks.test.ts +52 -0
- package/src/components/cloudHints/cloudLinks.ts +31 -0
- package/src/components/cloudHints/hintStorage.ts +28 -0
- package/src/components/cnpg/CNPGView.tsx +4 -7
- package/src/components/diagnose/AgentSetupNotice.tsx +5 -0
- package/src/components/diagnose/DiagnoseContext.tsx +7 -0
- package/src/components/diagnose/DiagnoseSurface.escape.test.tsx +215 -0
- package/src/components/diagnose/DiagnoseSurface.tsx +57 -1
- package/src/components/gitops/RemoteDestinationCloudHint.tsx +6 -14
- package/src/components/helm/HelmDrawerRouting.test.tsx +34 -1
- package/src/components/helm/HelmReleaseDrawer.tsx +6 -4
- package/src/components/helm/HelmView.tsx +4 -3
- package/src/components/helm/ObservedHelmNotice.tsx +39 -17
- package/src/components/helm/ObservedHelmRelease.test.tsx +62 -3
- package/src/components/helm/ObservedHelmReleaseDrawer.test.tsx +18 -0
- package/src/components/helm/ObservedHelmReleaseDrawer.tsx +4 -2
- package/src/components/home/HomeAgentBlock.tsx +2 -0
- package/src/components/home/HomeView.tsx +3 -3
- package/src/components/home/MCPSetupDialog.test.tsx +9 -0
- package/src/components/home/MCPSetupDialog.tsx +6 -2
- package/src/components/home/McpCloudLine.test.tsx +162 -0
- package/src/components/home/McpCloudLine.tsx +95 -0
- package/src/components/home/ProblemsPanel.investigate.test.tsx +2 -2
- package/src/components/home/mcpToolCatalog.test.ts +10 -0
- package/src/components/home/mcpToolCatalog.ts +4 -4
- package/src/components/issues/ClusterSchedulingBlockerRow.tsx +35 -0
- package/src/components/issues/IssuesPane.render.test.tsx +36 -1
- package/src/components/issues/IssuesPane.tsx +181 -23
- package/src/components/issues/SinceLastVisitRow.render.test.tsx +302 -0
- package/src/components/issues/SinceLastVisitRow.tsx +71 -0
- package/src/components/issues/sinceLastVisit.test.ts +266 -0
- package/src/components/issues/sinceLastVisit.ts +439 -0
- package/src/components/issues/uncheckedSources.test.ts +8 -0
- package/src/components/issues/uncheckedSources.ts +3 -0
- package/src/components/kagent/KagentAgentRenderer.test.ts +32 -0
- package/src/components/kagent/KagentAgentRenderer.tsx +87 -0
- package/src/components/kagent/KagentAgentSessions.test.tsx +166 -0
- package/src/components/kagent/KagentAgentSessions.tsx +124 -0
- package/src/components/kagent/KagentDetailPage.tsx +106 -0
- package/src/components/kagent/KagentLists.tsx +412 -0
- package/src/components/kagent/KagentOverview.tsx +234 -0
- package/src/components/kagent/KagentPages.tsx +690 -0
- package/src/components/kagent/KagentRuntimeTabs.test.tsx +219 -0
- package/src/components/kagent/KagentRuntimeTabs.tsx +283 -0
- package/src/components/kagent/KagentSidebar.test.tsx +112 -0
- package/src/components/kagent/KagentView.tsx +109 -0
- package/src/components/kagent/KagentWorkspace.test.tsx +876 -0
- package/src/components/kagent/host.tsx +144 -0
- package/src/components/kagent/routes.ts +31 -0
- package/src/components/kagent/shared.tsx +336 -0
- package/src/components/kagent/useKagentRuntime.test.tsx +77 -0
- package/src/components/kagent/useKagentSidebarWorkspace.ts +67 -0
- package/src/components/kagent/workspace.fixtures.ts +108 -0
- package/src/components/kagent/workspaceRoute.ts +18 -0
- package/src/components/nudges/activeNudges.test.ts +39 -0
- package/src/components/nudges/activeNudges.ts +76 -0
- package/src/components/poll/OssPoll.tsx +871 -0
- package/src/components/poll/mount.test.ts +12 -0
- package/src/components/poll/pollCloud.test.ts +23 -0
- package/src/components/poll/pollCloud.ts +6 -0
- package/src/components/poll/pollDefinition.ts +93 -0
- package/src/components/poll/pollFlow.test.ts +140 -0
- package/src/components/poll/pollFlow.ts +137 -0
- package/src/components/poll/pollSender.test.ts +137 -0
- package/src/components/poll/pollSender.ts +76 -0
- package/src/components/poll/pollStorage.test.ts +53 -0
- package/src/components/poll/pollStorage.ts +77 -0
- package/src/components/poll/round.json +350 -0
- package/src/components/product-hunt/ProductHuntNotice.tsx +2 -0
- package/src/components/resource/MetricsNotConnected.test.tsx +28 -0
- package/src/components/resource/MetricsNotConnected.tsx +10 -7
- package/src/components/resource/PrometheusCharts.tsx +10 -1
- package/src/components/resource/PrometheusChartsGrid.render.test.tsx +9 -0
- package/src/components/resource/PrometheusChartsGrid.tsx +3 -3
- package/src/components/resource/SubstrateHealthCharts.test.tsx +13 -1
- package/src/components/resource/SubstrateHealthCharts.tsx +9 -15
- package/src/components/resources/ImageFilesystemModal.test.tsx +21 -1
- package/src/components/resources/ImageFilesystemModal.tsx +42 -3
- package/src/components/resources/ResourceDetailDrawer.tsx +1 -0
- package/src/components/resources/ResourcesView.tsx +24 -11
- package/src/components/resources/renderers/PodRenderer.tsx +8 -2
- package/src/components/settings/LocalIntegrationStatus.test.tsx +1 -0
- package/src/components/settings/LocalIntegrationStatus.tsx +3 -2
- package/src/components/settings/SettingsDialog.tsx +84 -16
- package/src/components/settings/SubstrateSettings.lifecycle.test.tsx +210 -0
- package/src/components/settings/SubstrateSettings.test.tsx +131 -0
- package/src/components/settings/SubstrateSettings.tsx +544 -0
- package/src/components/settings/settings-state.test.ts +21 -3
- package/src/components/settings/settings-state.ts +13 -3
- package/src/components/share/ShareLinkButton.test.tsx +360 -0
- package/src/components/share/ShareLinkButton.tsx +391 -0
- package/src/components/share/openShareInCloud.test.ts +29 -0
- package/src/components/share/openShareInCloud.ts +10 -0
- package/src/components/share/shareLink.test.ts +129 -0
- package/src/components/share/shareLink.ts +175 -0
- package/src/components/substrate/SubstrateActorDrawer.tsx +87 -0
- package/src/components/substrate/SubstrateActorOverview.tsx +489 -0
- package/src/components/substrate/SubstrateActorPage.tsx +384 -0
- package/src/components/substrate/SubstrateActors.test.tsx +1094 -0
- package/src/components/substrate/SubstrateActors.tsx +612 -0
- package/src/components/substrate/SubstrateAttentionList.tsx +441 -0
- package/src/components/substrate/SubstrateConnect.tsx +88 -0
- package/src/components/substrate/SubstrateOverview.test.tsx +396 -0
- package/src/components/substrate/SubstrateOverview.tsx +575 -0
- package/src/components/substrate/SubstratePages.test.tsx +478 -0
- package/src/components/substrate/SubstratePool.test.tsx +462 -0
- package/src/components/substrate/SubstratePoolPage.tsx +95 -0
- package/src/components/substrate/SubstratePoolSummary.tsx +485 -0
- package/src/components/substrate/SubstrateSidebar.test.tsx +101 -0
- package/src/components/substrate/SubstrateStateBar.tsx +63 -0
- package/src/components/substrate/SubstrateTemplates.tsx +376 -0
- package/src/components/substrate/SubstrateView.tsx +173 -0
- package/src/components/substrate/SubstrateWorkerPodContext.tsx +73 -0
- package/src/components/substrate/SubstrateWorkers.tsx +389 -0
- package/src/components/substrate/attention.ts +81 -0
- package/src/components/substrate/contextPin.tsx +69 -0
- package/src/components/substrate/host.tsx +83 -0
- package/src/components/substrate/kubectlTarget.test.tsx +77 -0
- package/src/components/substrate/readings.test.ts +484 -0
- package/src/components/substrate/readings.ts +997 -0
- package/src/components/substrate/routes.ts +103 -0
- package/src/components/substrate/shared.tsx +426 -0
- package/src/components/substrate/substrate.fixtures.ts +325 -0
- package/src/components/substrate/useSubstrateSidebarWorkspace.ts +87 -0
- package/src/components/substrate/workspaceRoute.ts +23 -0
- package/src/components/traffic/TrafficConnectionsTable.test.tsx +9 -0
- package/src/components/traffic/TrafficConnectionsTable.tsx +4 -2
- package/src/components/traffic/TrafficFilterSidebar.tsx +19 -14
- package/src/components/traffic/TrafficFlowList.test.tsx +63 -0
- package/src/components/traffic/TrafficFlowList.tsx +9 -5
- package/src/components/traffic/TrafficGraph.test.tsx +26 -0
- package/src/components/traffic/TrafficGraph.tsx +17 -14
- package/src/components/traffic/TrafficGraphTooLarge.tsx +2 -0
- package/src/components/traffic/TrafficGraphUnavailable.tsx +3 -1
- package/src/components/traffic/TrafficView.tsx +26 -56
- package/src/components/traffic/trafficFilters.test.ts +61 -1
- package/src/components/traffic/trafficFilters.ts +68 -8
- package/src/components/ui/UpdateNotification.tsx +2 -0
- package/src/components/usage-data/UsageDataPrompt.tsx +2 -0
- package/src/components/velero/VeleroOverview.tsx +2 -2
- package/src/components/velero/VeleroView.tsx +3 -6
- package/src/components/vulnerabilities/columns.tsx +132 -0
- package/src/components/vulnerabilities/filters.tsx +317 -0
- package/src/components/vulnerabilities/owner.test.ts +54 -0
- package/src/components/vulnerabilities/owner.tsx +163 -0
- package/src/components/vulnerabilities/parts.test.ts +126 -12
- package/src/components/vulnerabilities/parts.tsx +612 -52
- package/src/components/vulnerabilities/traffic.test.tsx +65 -0
- package/src/components/vulnerabilities/traffic.tsx +40 -0
- package/src/components/whats-new/WhatsNew.tsx +2 -0
- package/src/components/whats-new/releaseNotes.ts +75 -1
- package/src/components/workload/WorkloadView.substrateVersion.test.tsx +88 -0
- package/src/components/workload/WorkloadView.tsx +52 -13
- package/src/components/workspace/layout.tsx +13 -7
- package/src/components/workspace/sidebar.test.ts +48 -0
- package/src/components/workspace/sidebar.ts +73 -3
- package/src/components/workspace/table.ts +2 -1
- package/src/contexts/RegistryAccessMode.test.tsx +51 -0
- package/src/contexts/RegistryAccessMode.tsx +25 -0
- package/src/integrations/resourceHost.ts +12 -6
- package/src/integrations/resourceHosts.test.tsx +27 -1
- package/src/integrations/resourceHosts.tsx +15 -7
- package/src/integrations/sidebarWorkspaces.test.tsx +63 -0
- package/src/integrations/sidebarWorkspaces.ts +41 -0
- package/src/integrations/workspaceRoute.ts +1 -1
- package/src/integrations/workspaceRoutes.ts +7 -1
- package/src/integrations/workspaceScreens.tsx +6 -0
package/src/api/client.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { hasPrometheusCharts, metricsSourceUnavailable } from './prometheusCharts'
|
|
1
|
+
import { hasPrometheusCharts, metricsSourceChecking, metricsSourceUnavailable } from './prometheusCharts'
|
|
2
2
|
import type { RightsizingRow, WorkloadRightsizingEvidence } from '@skyhook-io/k8s-ui/types/rightsizing'
|
|
3
3
|
import { followSwitch, switchFinished, switchInProgress, type ContextSwitchOperation } from './contextSwitch'
|
|
4
4
|
import { createListRefetchInterval, normalizeResourceList, type ResourceListBody, type ResourceListResult } from './resourceLists'
|
|
@@ -38,7 +38,7 @@ import type {
|
|
|
38
38
|
YamlDocumentIdentity,
|
|
39
39
|
YamlSchemaLoadResult,
|
|
40
40
|
} from '@skyhook-io/k8s-ui'
|
|
41
|
-
import { focusManager, onlineManager, useInfiniteQuery, useQuery, useMutation, useQueryClient, skipToken, type QueryClient } from '@tanstack/react-query'
|
|
41
|
+
import { focusManager, onlineManager, useInfiniteQuery, useIsFetching, useQuery, useMutation, useQueryClient, skipToken, type QueryClient } from '@tanstack/react-query'
|
|
42
42
|
import { showApiError, showApiSuccess, showApiNotice } from '../components/ui/Toast'
|
|
43
43
|
import { useIsAuthEnabled, useNamespacedCapabilities } from '../contexts/CapabilitiesContext'
|
|
44
44
|
import { applyTabPick, cleanPick, ownsTabPick, pruneTabPick, withActives, writeTabPick } from '../utils/namespacePick'
|
|
@@ -100,6 +100,7 @@ import {
|
|
|
100
100
|
import { useRadarUpgradeHost } from '../context/RadarUpgradeHost'
|
|
101
101
|
import { isGitOpsActionTarget, gitOpsActionPermissions, gitOpsDisabledReasons, type GitOpsActionCapabilities } from './gitOpsPermissions'
|
|
102
102
|
import { apiVersionToGroup } from '../utils/navigation'
|
|
103
|
+
import type { CloudHintEntry } from '../components/cloudHints/cloudHints'
|
|
103
104
|
import { isBadgeWorthy } from '../utils/auditBadges'
|
|
104
105
|
import type { DeploymentMode } from '../types'
|
|
105
106
|
|
|
@@ -599,6 +600,7 @@ import type {
|
|
|
599
600
|
Check,
|
|
600
601
|
Issue,
|
|
601
602
|
IssueRecentChange,
|
|
603
|
+
SchedulingBlockerSummary,
|
|
602
604
|
} from "@skyhook-io/k8s-ui";
|
|
603
605
|
export type DashboardAudit = AuditCardData;
|
|
604
606
|
export type { AuditFinding, ResourceGroup, CheckMeta, Check };
|
|
@@ -870,6 +872,9 @@ export function useUpgradeReadiness(target?: string) {
|
|
|
870
872
|
// that honestly rather than presenting a capped list as if it were complete.
|
|
871
873
|
export interface IssuesResponse {
|
|
872
874
|
issues: Issue[]
|
|
875
|
+
scheduling_blockers?: SchedulingBlockerSummary[]
|
|
876
|
+
scheduling_node_gap?: string
|
|
877
|
+
next_member_after?: string
|
|
873
878
|
total?: number
|
|
874
879
|
total_matched?: number
|
|
875
880
|
recent_changes?: IssueRecentChange[]
|
|
@@ -908,20 +913,38 @@ export interface UncheckedSource {
|
|
|
908
913
|
namespaces?: string[];
|
|
909
914
|
}
|
|
910
915
|
|
|
911
|
-
export function useIssues(namespaces: string[] = [], enabled = true, kind?: string) {
|
|
916
|
+
export function useIssues(namespaces: string[] = [], enabled = true, kind?: string, view?: 'blockers') {
|
|
912
917
|
const params = new URLSearchParams();
|
|
913
918
|
if (namespaces.length) params.set('namespaces', namespaces.join(','));
|
|
914
919
|
if (kind) { params.set('kind', kind); params.set('limit', '1000'); }
|
|
920
|
+
if (view) params.set('view', view);
|
|
915
921
|
const query = params.toString();
|
|
922
|
+
const key = kind ? ["issues", namespaces, kind] : ["issues", namespaces];
|
|
916
923
|
return useQuery<IssuesResponse>({
|
|
917
|
-
queryKey:
|
|
918
|
-
queryFn: () => fetchJSON(`/issues${query ? `?${query}` : ''}
|
|
924
|
+
queryKey: view ? [...key, view] : key,
|
|
925
|
+
queryFn: ({ signal }) => fetchJSON(`/issues${query ? `?${query}` : ''}`, signal),
|
|
919
926
|
staleTime: 30000,
|
|
920
927
|
refetchInterval: ISSUES_REFRESH_INTERVAL_MS,
|
|
921
928
|
enabled,
|
|
922
929
|
});
|
|
923
930
|
}
|
|
924
931
|
|
|
932
|
+
export function useSchedulingBlockerMembers(blocker: SchedulingBlockerSummary, namespaces: string[], enabled: boolean) {
|
|
933
|
+
return useInfiniteQuery({
|
|
934
|
+
queryKey: ["issues", namespaces, "blockers", blocker.id, blocker.affected_workloads],
|
|
935
|
+
queryFn: ({ pageParam, signal }) => {
|
|
936
|
+
const params = new URLSearchParams({ view: "blockers", blocker: blocker.id, limit: "25" });
|
|
937
|
+
if (namespaces.length) params.set("namespaces", namespaces.join(","));
|
|
938
|
+
if (pageParam) params.set("after", pageParam);
|
|
939
|
+
return fetchJSON<IssuesResponse>(`/issues?${params}`, signal);
|
|
940
|
+
},
|
|
941
|
+
initialPageParam: "",
|
|
942
|
+
getNextPageParam: (page) => page.next_member_after,
|
|
943
|
+
staleTime: ISSUES_REFRESH_INTERVAL_MS,
|
|
944
|
+
enabled,
|
|
945
|
+
});
|
|
946
|
+
}
|
|
947
|
+
|
|
925
948
|
export function useResourceAudit(
|
|
926
949
|
kind: string,
|
|
927
950
|
namespace: string,
|
|
@@ -1294,7 +1317,9 @@ export interface CertExpiry {
|
|
|
1294
1317
|
expired?: boolean;
|
|
1295
1318
|
}
|
|
1296
1319
|
|
|
1297
|
-
|
|
1320
|
+
// With readLive the expiry is read live from the person's Secrets, like the
|
|
1321
|
+
// Secrets list it sits in, so it refreshes with that list rather than on a timer.
|
|
1322
|
+
export function useSecretCertExpiry(namespaces: string[] = [], enabled = true, readLive = false) {
|
|
1298
1323
|
const params =
|
|
1299
1324
|
namespaces.length > 0 ? `?namespaces=${namespaces.join(",")}` : "";
|
|
1300
1325
|
return useQuery<Record<string, CertExpiry>>({
|
|
@@ -1302,7 +1327,7 @@ export function useSecretCertExpiry(namespaces: string[] = [], enabled = true) {
|
|
|
1302
1327
|
queryFn: () => fetchJSON(`/secrets/certificate-expiry${params}`),
|
|
1303
1328
|
enabled,
|
|
1304
1329
|
staleTime: 30000,
|
|
1305
|
-
refetchInterval: 60000,
|
|
1330
|
+
refetchInterval: readLive ? false : 60000,
|
|
1306
1331
|
});
|
|
1307
1332
|
}
|
|
1308
1333
|
|
|
@@ -2170,6 +2195,13 @@ function versionCheckQueryOptions(apiBase: string) {
|
|
|
2170
2195
|
};
|
|
2171
2196
|
}
|
|
2172
2197
|
|
|
2198
|
+
/** The connected Radar's version, from the version check the app already runs; undefined until known. */
|
|
2199
|
+
export function useRadarVersion(): string | undefined {
|
|
2200
|
+
const { data } = useQuery<VersionInfo>(versionCheckQueryOptions(getApiBase()))
|
|
2201
|
+
const { radarVersion } = useRadarUpgradeHost()
|
|
2202
|
+
return data?.currentVersion || radarVersion || undefined
|
|
2203
|
+
}
|
|
2204
|
+
|
|
2173
2205
|
export function useVersionCheck() {
|
|
2174
2206
|
const capabilities = useCapabilities()
|
|
2175
2207
|
const apiBase = getApiBase()
|
|
@@ -2569,19 +2601,21 @@ export interface CloudConnectInfo {
|
|
|
2569
2601
|
|
|
2570
2602
|
// Deliberately a bare cross-origin GET: no credentials, no identifiers. The
|
|
2571
2603
|
// Hub learns what any HTTP request reveals plus `about`, below: the lane the
|
|
2572
|
-
// footer renders
|
|
2573
|
-
// about the cluster or the person rides
|
|
2574
|
-
// lane change (a driver install that just
|
|
2575
|
-
// instead of reusing the
|
|
2604
|
+
// footer renders, this deployment's mode, and which in-app hint opened the
|
|
2605
|
+
// dialog, all closed enums, so nothing about the cluster or the person rides
|
|
2606
|
+
// along. Part of the query key so a lane change (a driver install that just
|
|
2607
|
+
// became tunneled, say) or a different hint refetches instead of reusing the
|
|
2608
|
+
// other's copy.
|
|
2576
2609
|
export function useCloudConnectInfo(
|
|
2577
2610
|
apiUrl: string | undefined,
|
|
2578
2611
|
enabled: boolean,
|
|
2579
|
-
about: { lane: "driver" | "wizard"; mode?: DeploymentMode },
|
|
2612
|
+
about: { lane: "driver" | "wizard"; mode?: DeploymentMode; entry?: CloudHintEntry | null },
|
|
2580
2613
|
) {
|
|
2581
2614
|
const params = new URLSearchParams({ lane: about.lane });
|
|
2582
2615
|
if (about.mode) params.set("mode", about.mode);
|
|
2616
|
+
if (about.entry) params.set("entry", about.entry);
|
|
2583
2617
|
return useQuery<CloudConnectInfo>({
|
|
2584
|
-
queryKey: ["cloud-connect-info", apiUrl, about.lane, about.mode],
|
|
2618
|
+
queryKey: ["cloud-connect-info", apiUrl, about.lane, about.mode, about.entry ?? null],
|
|
2585
2619
|
queryFn: async () => {
|
|
2586
2620
|
const res = await fetch(`${apiUrl}/api/connect/info?${params}`, {
|
|
2587
2621
|
credentials: "omit",
|
|
@@ -2667,14 +2701,22 @@ export interface CloudInstallDiscovered {
|
|
|
2667
2701
|
partialScan: boolean
|
|
2668
2702
|
}
|
|
2669
2703
|
|
|
2670
|
-
// Keyed by context: a switch must not describe the previous cluster.
|
|
2671
|
-
|
|
2704
|
+
// Keyed by context: a switch must not describe the previous cluster. The
|
|
2705
|
+
// lookup lists Deployments across the cluster, so a caller that only words a
|
|
2706
|
+
// hint can reuse an answer up to maxAgeMs old. Those answers are cached under
|
|
2707
|
+
// their own key: the Cloud dialog passes none and must never show an old
|
|
2708
|
+
// answer while it asks again.
|
|
2709
|
+
export function useCloudInstallDiscover(
|
|
2710
|
+
enabled: boolean,
|
|
2711
|
+
contextName: string | undefined,
|
|
2712
|
+
{ maxAgeMs = 0 }: { maxAgeMs?: number } = {},
|
|
2713
|
+
) {
|
|
2672
2714
|
return useQuery<CloudInstallDiscovered>({
|
|
2673
|
-
queryKey: ['cloud-install-discover', contextName],
|
|
2715
|
+
queryKey: maxAgeMs > 0 ? ['cloud-install-discover', contextName, 'reusable'] : ['cloud-install-discover', contextName],
|
|
2674
2716
|
queryFn: () => fetchJSON('/cloud/install/discover'),
|
|
2675
2717
|
enabled,
|
|
2676
|
-
staleTime:
|
|
2677
|
-
gcTime:
|
|
2718
|
+
staleTime: maxAgeMs,
|
|
2719
|
+
gcTime: maxAgeMs,
|
|
2678
2720
|
retry: false,
|
|
2679
2721
|
})
|
|
2680
2722
|
}
|
|
@@ -4399,6 +4441,48 @@ export function usePrometheusStatus(enabled = true) {
|
|
|
4399
4441
|
});
|
|
4400
4442
|
}
|
|
4401
4443
|
|
|
4444
|
+
const PROM_STATUS_CHECK_KEY = ["prometheus-status-check"];
|
|
4445
|
+
|
|
4446
|
+
/**
|
|
4447
|
+
* Settings opening on a metrics relay (OpenObserve) asks Radar to send it one
|
|
4448
|
+
* query and wait, so a backend that went down while nothing queried it reads
|
|
4449
|
+
* as unavailable rather than connected. Radar never queries it on its own.
|
|
4450
|
+
*/
|
|
4451
|
+
export function useMetricsRelayCheck(open: boolean) {
|
|
4452
|
+
const queryClient = useQueryClient();
|
|
4453
|
+
const { data: status } = usePrometheusStatus(open);
|
|
4454
|
+
const relay = status?.source?.kind === "openobserve" && !!(status.source.matchedBy || status.source.unavailable);
|
|
4455
|
+
const checked = useRef(false);
|
|
4456
|
+
useEffect(() => {
|
|
4457
|
+
if (!open) {
|
|
4458
|
+
checked.current = false;
|
|
4459
|
+
void queryClient.cancelQueries({ queryKey: PROM_STATUS_CHECK_KEY });
|
|
4460
|
+
return;
|
|
4461
|
+
}
|
|
4462
|
+
if (checked.current || !relay) return;
|
|
4463
|
+
checked.current = true;
|
|
4464
|
+
queryClient
|
|
4465
|
+
.fetchQuery({
|
|
4466
|
+
queryKey: PROM_STATUS_CHECK_KEY,
|
|
4467
|
+
// The check only updates what Radar knows. The status is read after
|
|
4468
|
+
// it rather than taken from its reply, so a newer status this tab
|
|
4469
|
+
// received meanwhile is never replaced by an older one.
|
|
4470
|
+
queryFn: async ({ signal }) => {
|
|
4471
|
+
await fetchJSON("/prometheus/status?check=true", signal);
|
|
4472
|
+
await queryClient.refetchQueries({ queryKey: ["prometheus-status"], exact: true });
|
|
4473
|
+
return true;
|
|
4474
|
+
},
|
|
4475
|
+
staleTime: 0,
|
|
4476
|
+
})
|
|
4477
|
+
.catch(() => {});
|
|
4478
|
+
}, [open, relay, queryClient]);
|
|
4479
|
+
}
|
|
4480
|
+
|
|
4481
|
+
/** A metrics relay check Settings asked for is waiting on its answer. */
|
|
4482
|
+
export function useMetricsRelayChecking(): boolean {
|
|
4483
|
+
return useIsFetching({ queryKey: PROM_STATUS_CHECK_KEY }) > 0;
|
|
4484
|
+
}
|
|
4485
|
+
|
|
4402
4486
|
export interface ArgoStatus {
|
|
4403
4487
|
// configured = a URL or token is set; connected = a probe has landed and the
|
|
4404
4488
|
// client is live. The two differ right after a restart (configured, reconnecting).
|
|
@@ -4521,6 +4605,7 @@ export function useAutoPromConnect(): void {
|
|
|
4521
4605
|
const { data: status, isLoading: statusLoading } = usePrometheusStatus();
|
|
4522
4606
|
const chartsAvailable = hasPrometheusCharts(status);
|
|
4523
4607
|
const sourceUnavailable = metricsSourceUnavailable(status);
|
|
4608
|
+
const sourceChecking = metricsSourceChecking(status);
|
|
4524
4609
|
const attemptedRef = useRef<string | null>(null);
|
|
4525
4610
|
|
|
4526
4611
|
useEffect(() => {
|
|
@@ -4541,6 +4626,9 @@ export function useAutoPromConnect(): void {
|
|
|
4541
4626
|
// An OpenObserve connection that can't answer is the source in use;
|
|
4542
4627
|
// discovering Prometheus would not stand in for it.
|
|
4543
4628
|
if (sourceUnavailable) return;
|
|
4629
|
+
// Until Radar knows whether OpenObserve serves this cluster, discovering
|
|
4630
|
+
// Prometheus would race the answer.
|
|
4631
|
+
if (sourceChecking) return;
|
|
4544
4632
|
if (attemptedRef.current === context) return;
|
|
4545
4633
|
let cached: string | null = null;
|
|
4546
4634
|
try {
|
|
@@ -4554,13 +4642,15 @@ export function useAutoPromConnect(): void {
|
|
|
4554
4642
|
// Cached path probes immediately; first-time path defers briefly so the
|
|
4555
4643
|
// initial UI render isn't competing with the cluster network call.
|
|
4556
4644
|
const delay = cached === "1" ? 0 : PROM_FIRSTLAUNCH_PROBE_DELAY_MS;
|
|
4645
|
+
// The server only reports discovering once the run has started; mark it
|
|
4646
|
+
// now so the view shows progress from the start instead of the manual CTA
|
|
4647
|
+
// until the request lands.
|
|
4648
|
+
queryClient.setQueryData<PrometheusStatus>(["prometheus-status"], (prev) =>
|
|
4649
|
+
prev ? { ...prev, discovering: true } : prev,
|
|
4650
|
+
);
|
|
4651
|
+
let sent = false;
|
|
4557
4652
|
const timeout = window.setTimeout(() => {
|
|
4558
|
-
|
|
4559
|
-
// here first so the view shows progress instead of the manual CTA for the
|
|
4560
|
-
// whole duration of this request.
|
|
4561
|
-
queryClient.setQueryData<PrometheusStatus>(["prometheus-status"], (prev) =>
|
|
4562
|
-
prev ? { ...prev, discovering: true } : prev,
|
|
4563
|
-
);
|
|
4653
|
+
sent = true;
|
|
4564
4654
|
// Direct apiFetch (not via the usePrometheusConnect mutation) so the
|
|
4565
4655
|
// meta-driven toast handler stays silent — the user didn't click anything.
|
|
4566
4656
|
apiFetch(`${getApiBase()}/prometheus/connect?optional=true`, {
|
|
@@ -4592,8 +4682,18 @@ export function useAutoPromConnect(): void {
|
|
|
4592
4682
|
attemptedRef.current = null;
|
|
4593
4683
|
});
|
|
4594
4684
|
}, delay);
|
|
4595
|
-
return () =>
|
|
4596
|
-
|
|
4685
|
+
return () => {
|
|
4686
|
+
window.clearTimeout(timeout);
|
|
4687
|
+
if (sent) return;
|
|
4688
|
+
// Canceled before it was sent (an OpenObserve check began, say): forget
|
|
4689
|
+
// the attempt so the probe runs once this context is eligible again.
|
|
4690
|
+
attemptedRef.current = null;
|
|
4691
|
+
queryClient.setQueryData<PrometheusStatus>(
|
|
4692
|
+
["prometheus-status"],
|
|
4693
|
+
(prev) => (prev?.discovering ? { ...prev, discovering: false } : prev),
|
|
4694
|
+
);
|
|
4695
|
+
};
|
|
4696
|
+
}, [clusterInfo?.context, chartsAvailable, sourceUnavailable, sourceChecking, statusLoading, queryClient]);
|
|
4597
4697
|
}
|
|
4598
4698
|
|
|
4599
4699
|
// Fetch Prometheus metrics for a resource
|
|
@@ -4938,6 +5038,10 @@ export function useAvailablePorts(
|
|
|
4938
5038
|
export function useUpdateResource() {
|
|
4939
5039
|
const queryClient = useQueryClient();
|
|
4940
5040
|
const { segment: emptyNamespaceSegment } = useEmptyNamespaceSegment();
|
|
5041
|
+
const { data: capabilities } = useCapabilities();
|
|
5042
|
+
const secretsReadLive =
|
|
5043
|
+
radarFeatureSupport("secretLiveRead", capabilities, undefined) === "supported" &&
|
|
5044
|
+
capabilities?.secretCollection === "disabled-by-policy";
|
|
4941
5045
|
|
|
4942
5046
|
return useMutation({
|
|
4943
5047
|
mutationFn: async ({
|
|
@@ -5023,6 +5127,16 @@ export function useUpdateResource() {
|
|
|
5023
5127
|
],
|
|
5024
5128
|
});
|
|
5025
5129
|
}
|
|
5130
|
+
if (secretsReadLive && ["secret", "secrets"].includes(variables.kind.toLowerCase())) {
|
|
5131
|
+
// Radar doesn't collect Secrets here, so no watch lags behind the
|
|
5132
|
+
// write: the page reads the API server as this person. Read the
|
|
5133
|
+
// saved Secret back rather than trusting the seed alone, and the
|
|
5134
|
+
// certificate expiry, which no longer polls.
|
|
5135
|
+
queryClient.invalidateQueries({
|
|
5136
|
+
queryKey: ["resource", variables.kind, variables.namespace, variables.name],
|
|
5137
|
+
});
|
|
5138
|
+
queryClient.invalidateQueries({ queryKey: ["secret-cert-expiry"] });
|
|
5139
|
+
}
|
|
5026
5140
|
queryClient.invalidateQueries({
|
|
5027
5141
|
queryKey: ["resources", variables.kind],
|
|
5028
5142
|
});
|
|
@@ -6832,6 +6946,13 @@ export function isHelmReleaseReadDenied(error: unknown): boolean {
|
|
|
6832
6946
|
return isForbiddenError(error) && (error as ApiError).data?.error_code === "release_read_denied";
|
|
6833
6947
|
}
|
|
6834
6948
|
|
|
6949
|
+
// Radar didn't read Helm's storage because its Secret collection is turned off
|
|
6950
|
+
// (rbac.secretAccess: none). Granting the caller more access won't change this,
|
|
6951
|
+
// and an older Radar never sends it.
|
|
6952
|
+
export function isHelmReleaseNotCollected(error: unknown): boolean {
|
|
6953
|
+
return error instanceof ApiError && error.status === 503 && error.data?.error_code === "radar_kind_not_collected";
|
|
6954
|
+
}
|
|
6955
|
+
|
|
6835
6956
|
// Each observed read walks every object the caller can see, so an open drawer
|
|
6836
6957
|
// follows the list's schedule while objects settle and otherwise refreshes
|
|
6837
6958
|
// once a minute. A retryable error retries sooner.
|
|
@@ -6862,9 +6983,12 @@ export function useHelmRelease(
|
|
|
6862
6983
|
queryFn: () => fetchJSON(`/helm/releases/${namespace}/${name}`),
|
|
6863
6984
|
enabled: Boolean(namespace && name) && (options?.enabled ?? true),
|
|
6864
6985
|
staleTime: 5000,
|
|
6986
|
+
// A release Radar doesn't collect stays uncollected until an admin changes
|
|
6987
|
+
// the chart, so neither a retry nor a poll would change the answer.
|
|
6988
|
+
retry: (failureCount, error) => !isHelmReleaseNotCollected(error) && shouldRetryRadarQuery(failureCount, error),
|
|
6865
6989
|
// Poll for live resource status updates (post-upgrade/rollback); a refusal
|
|
6866
6990
|
// would only repeat.
|
|
6867
|
-
refetchInterval: (query) => (isForbiddenError(query.state.error) ? false : 10000),
|
|
6991
|
+
refetchInterval: (query) => (isForbiddenError(query.state.error) || isHelmReleaseNotCollected(query.state.error) ? false : 10000),
|
|
6868
6992
|
});
|
|
6869
6993
|
}
|
|
6870
6994
|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
//
|
|
3
|
+
// With Secrets read live, nothing watches them, so saving a Secret must
|
|
4
|
+
// re-read what was derived from it: the Secrets list's Expires column.
|
|
5
|
+
import { act } from 'react'
|
|
6
|
+
import { createRoot } from 'react-dom/client'
|
|
7
|
+
import { QueryClientProvider } from '@tanstack/react-query'
|
|
8
|
+
import { afterEach, expect, it, vi } from 'vitest'
|
|
9
|
+
|
|
10
|
+
const { makeDefaultQueryClient } = await import('../RadarApp')
|
|
11
|
+
const { useUpdateResource } = await import('./client')
|
|
12
|
+
|
|
13
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
14
|
+
afterEach(() => {
|
|
15
|
+
vi.unstubAllGlobals()
|
|
16
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
async function saveSecret(secretCollection: 'enabled' | 'disabled-by-policy') {
|
|
20
|
+
const saved = { apiVersion: 'v1', kind: 'Secret', metadata: { name: 'web-tls', namespace: 'shop', resourceVersion: '2' }, type: 'kubernetes.io/tls' }
|
|
21
|
+
vi.stubGlobal('fetch', vi.fn(async () => new Response(JSON.stringify(saved), { status: 200, headers: { 'Content-Type': 'application/json' } })))
|
|
22
|
+
const client = makeDefaultQueryClient()
|
|
23
|
+
client.setQueryData(['capabilities'], { features: { secretLiveRead: true }, secretCollection })
|
|
24
|
+
client.setQueryData(['secret-cert-expiry', []], { 'shop/web-tls': { daysLeft: 3 } })
|
|
25
|
+
let mutate: ReturnType<typeof useUpdateResource>['mutateAsync'] | undefined
|
|
26
|
+
function Probe() {
|
|
27
|
+
mutate = useUpdateResource().mutateAsync
|
|
28
|
+
return null
|
|
29
|
+
}
|
|
30
|
+
const root = createRoot(document.createElement('div'))
|
|
31
|
+
await act(async () => {
|
|
32
|
+
root.render(<QueryClientProvider client={client}><Probe /></QueryClientProvider>)
|
|
33
|
+
})
|
|
34
|
+
await act(async () => {
|
|
35
|
+
await mutate!({ kind: 'secrets', namespace: 'shop', name: 'web-tls', yaml: 'kind: Secret' })
|
|
36
|
+
})
|
|
37
|
+
act(() => root.unmount())
|
|
38
|
+
return client.getQueryState(['secret-cert-expiry', []])?.isInvalidated
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
it('re-reads certificate expiry after saving a Secret read live', async () => {
|
|
42
|
+
expect(await saveSecret('disabled-by-policy')).toBe(true)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('leaves certificate expiry to its poll when Radar collects Secrets', async () => {
|
|
46
|
+
expect(await saveSecret('enabled')).toBe(false)
|
|
47
|
+
})
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act, useRef } from 'react'
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
4
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
5
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
6
|
+
import { useCloudInstallDiscover } from './client'
|
|
7
|
+
|
|
8
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
9
|
+
let root: Root
|
|
10
|
+
let host: HTMLDivElement
|
|
11
|
+
let client: QueryClient
|
|
12
|
+
let calls = 0
|
|
13
|
+
|
|
14
|
+
const firstRenders: string[] = []
|
|
15
|
+
|
|
16
|
+
function Probe({ maxAgeMs }: { maxAgeMs?: number }) {
|
|
17
|
+
const q = useCloudInstallDiscover(true, 'kind-dev', maxAgeMs === undefined ? undefined : { maxAgeMs })
|
|
18
|
+
const shown = q.data ? 'ready' : 'pending'
|
|
19
|
+
// Recorded during the first render itself: read after act() instead, the
|
|
20
|
+
// fetch may already have resolved, depending on how busy the machine is.
|
|
21
|
+
const recorded = useRef(false)
|
|
22
|
+
if (!recorded.current) {
|
|
23
|
+
recorded.current = true
|
|
24
|
+
firstRenders.push(shown)
|
|
25
|
+
}
|
|
26
|
+
return <span>{shown}</span>
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function mountProbe(maxAgeMs?: number) {
|
|
30
|
+
await act(async () => {
|
|
31
|
+
root.render(<QueryClientProvider client={client}><Probe maxAgeMs={maxAgeMs} /></QueryClientProvider>)
|
|
32
|
+
})
|
|
33
|
+
await vi.waitFor(() => expect(host.textContent).toBe('ready'))
|
|
34
|
+
await act(async () => root.unmount())
|
|
35
|
+
root = createRoot(host)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
beforeEach(() => {
|
|
39
|
+
calls = 0
|
|
40
|
+
client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
|
|
41
|
+
host = document.createElement('div')
|
|
42
|
+
document.body.appendChild(host)
|
|
43
|
+
root = createRoot(host)
|
|
44
|
+
vi.stubGlobal('fetch', vi.fn(async () => {
|
|
45
|
+
calls++
|
|
46
|
+
return new Response(JSON.stringify({ connected: [], partialScan: false }), { status: 200 })
|
|
47
|
+
}))
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
afterEach(() => {
|
|
51
|
+
client.clear()
|
|
52
|
+
host.remove()
|
|
53
|
+
vi.unstubAllGlobals()
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
describe('useCloudInstallDiscover', () => {
|
|
57
|
+
it('reuses a recent answer when the caller allows one', async () => {
|
|
58
|
+
await mountProbe(5 * 60_000)
|
|
59
|
+
await mountProbe(5 * 60_000)
|
|
60
|
+
expect(calls).toBe(1)
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
it('asks again on every mount by default, as the Cloud dialog needs', async () => {
|
|
64
|
+
await mountProbe()
|
|
65
|
+
await mountProbe()
|
|
66
|
+
expect(calls).toBe(2)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('never shows a default caller the cached answer while it asks again', async () => {
|
|
70
|
+
firstRenders.length = 0
|
|
71
|
+
await mountProbe(5 * 60_000)
|
|
72
|
+
await mountProbe()
|
|
73
|
+
expect(calls).toBe(2)
|
|
74
|
+
expect(firstRenders[1]).toBe('pending')
|
|
75
|
+
})
|
|
76
|
+
})
|
package/src/api/diagnose.ts
CHANGED
|
@@ -35,6 +35,10 @@ export interface AgentsResponse {
|
|
|
35
35
|
// "install an agent to enable this" (eligible && !enabled) apart from "not
|
|
36
36
|
// available here" (auth/cloud/--no-mcp). Absent on older servers / embed hosts.
|
|
37
37
|
eligible?: boolean;
|
|
38
|
+
// Why investigations can't run here when not eligible: "shared" for a team
|
|
39
|
+
// installation (auth or operator-managed config), "no-mcp" when the MCP
|
|
40
|
+
// mount is off. Empty when eligible; absent on older servers.
|
|
41
|
+
unavailableReason?: "" | "shared" | "no-mcp";
|
|
38
42
|
// cliOverride: RADAR_AI_CLI_BIN is set, pinning the engine to one CLI. With
|
|
39
43
|
// CLIs detected and investigations still off, that variable is what's broken.
|
|
40
44
|
// Absent on older servers and embed hosts.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { beforeEach, expect, it, vi } from 'vitest'
|
|
2
|
+
import { QueryClient, useInfiniteQuery, useQuery } from '@tanstack/react-query'
|
|
3
|
+
import { ApiError, fetchJSON } from './client'
|
|
4
|
+
import { useKagentSessionSummary, useKagentWorkspace } from './kagent'
|
|
5
|
+
const state = vi.hoisted(() => ({ workspace: 'supported', context: 'one', base: '/api' }))
|
|
6
|
+
vi.mock('@tanstack/react-query', async (original) => ({ ...(await original<typeof import('@tanstack/react-query')>()), useQuery: vi.fn(() => ({})), useInfiniteQuery: vi.fn(() => ({})) }))
|
|
7
|
+
vi.mock('./config', () => ({ getApiBase: () => state.base }))
|
|
8
|
+
vi.mock('./client', async (original) => ({
|
|
9
|
+
...(await original<typeof import('./client')>()),
|
|
10
|
+
fetchJSON: vi.fn(),
|
|
11
|
+
useClusterInfo: () => ({ data: { context: state.context } }),
|
|
12
|
+
useRadarFeature: (feature: string) => ({
|
|
13
|
+
support: feature === 'kagentWorkspace' ? state.workspace : 'unsupported',
|
|
14
|
+
gatedKey: [],
|
|
15
|
+
guard: (fn: () => unknown) => fn(),
|
|
16
|
+
}),
|
|
17
|
+
}))
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
vi.clearAllMocks()
|
|
20
|
+
state.workspace = 'supported'
|
|
21
|
+
state.context = 'one'
|
|
22
|
+
state.base = '/api'
|
|
23
|
+
})
|
|
24
|
+
it.each(['unsupported', 'unknown'])('gates configuration and runtime on the workspace capability while it is %s', (support) => {
|
|
25
|
+
state.workspace = support
|
|
26
|
+
useKagentWorkspace([])
|
|
27
|
+
expect(vi.mocked(useQuery).mock.calls.at(-1)![0].enabled).toBe(false)
|
|
28
|
+
useKagentSessionSummary([])
|
|
29
|
+
expect(vi.mocked(useInfiniteQuery).mock.calls.at(-1)![0].enabled).toBe(false)
|
|
30
|
+
})
|
|
31
|
+
it('keeps retrying pending discovery and keeps the ordinary error budget', () => {
|
|
32
|
+
useKagentWorkspace([])
|
|
33
|
+
const options = vi.mocked(useQuery).mock.calls.at(-1)![0]
|
|
34
|
+
const retry = options.retry as (count: number, error: unknown) => boolean
|
|
35
|
+
const delay = options.retryDelay as (count: number, error: unknown) => number
|
|
36
|
+
const pending = new ApiError('discovery is running', 503, { error_code: 'kind_sync_pending' })
|
|
37
|
+
expect(retry(10, pending)).toBe(true)
|
|
38
|
+
expect(delay(10, pending)).toBe(2000)
|
|
39
|
+
expect(retry(1, new ApiError('unavailable', 503))).toBe(false)
|
|
40
|
+
})
|
|
41
|
+
it('separates namespaces, contexts and API hosts and carries cancellation', async () => {
|
|
42
|
+
useKagentWorkspace(['b', 'a'])
|
|
43
|
+
const first = vi.mocked(useQuery).mock.calls.at(-1)![0]
|
|
44
|
+
await (first.queryFn as (context: { signal: AbortSignal }) => Promise<unknown>)({ signal: new AbortController().signal })
|
|
45
|
+
expect(fetchJSON).toHaveBeenCalledWith('/kagent/workspace?namespaces=a%2Cb', expect.any(AbortSignal))
|
|
46
|
+
state.context = 'two'
|
|
47
|
+
useKagentWorkspace(['a', 'b'])
|
|
48
|
+
expect(vi.mocked(useQuery).mock.calls.at(-1)![0].queryKey).not.toEqual(first.queryKey)
|
|
49
|
+
state.base = '/other'
|
|
50
|
+
useKagentWorkspace(['a', 'b'])
|
|
51
|
+
expect(vi.mocked(useQuery).mock.calls.at(-1)![0].queryKey).not.toEqual(first.queryKey)
|
|
52
|
+
expect(first.placeholderData).toBeUndefined()
|
|
53
|
+
})
|
|
54
|
+
it('pages the fleet summary instead of treating its first 1000 Agents as the fleet', () => {
|
|
55
|
+
useKagentSessionSummary([])
|
|
56
|
+
const options = vi.mocked(useInfiniteQuery).mock.calls.at(-1)![0]
|
|
57
|
+
const next = options.getNextPageParam as (lastPage: { offset: number; rows: unknown[]; total: number }) => number | undefined
|
|
58
|
+
expect(next({ offset: 0, rows: Array(1000), total: 1001 })).toBe(1000)
|
|
59
|
+
expect(next({ offset: 1000, rows: [1], total: 1001 })).toBeUndefined()
|
|
60
|
+
expect(next({ offset: 0, rows: [], total: 1001 })).toBeUndefined()
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
it('invalidates session summaries with the saved Substrate connection, only for that API host', async () => {
|
|
64
|
+
const client = new QueryClient()
|
|
65
|
+
useKagentSessionSummary([])
|
|
66
|
+
const first = vi.mocked(useInfiniteQuery).mock.calls.at(-1)![0].queryKey
|
|
67
|
+
state.base = '/other'
|
|
68
|
+
useKagentSessionSummary([])
|
|
69
|
+
const other = vi.mocked(useInfiniteQuery).mock.calls.at(-1)![0].queryKey
|
|
70
|
+
client.setQueryData(first, { rows: [] })
|
|
71
|
+
client.setQueryData(other, { rows: [] })
|
|
72
|
+
await client.invalidateQueries({ queryKey: ['substrate', '/api'] })
|
|
73
|
+
expect(client.getQueryState(first)?.isInvalidated).toBe(true)
|
|
74
|
+
expect(client.getQueryState(other)?.isInvalidated).toBe(false)
|
|
75
|
+
client.clear()
|
|
76
|
+
})
|
|
77
|
+
it('enables both workspace endpoints when Radar advertises kagentWorkspace', () => {
|
|
78
|
+
useKagentWorkspace([])
|
|
79
|
+
useKagentSessionSummary([])
|
|
80
|
+
expect(vi.mocked(useQuery).mock.calls.at(-1)![0].enabled).toBe(true)
|
|
81
|
+
expect(vi.mocked(useInfiniteQuery).mock.calls.at(-1)![0].enabled).toBe(true)
|
|
82
|
+
})
|