@skyhook-io/radar-app 1.19.0 → 1.20.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/README.md +1 -1
- package/package.json +5 -5
- package/src/App.tsx +37 -9
- package/src/api/application-evidence.ts +63 -0
- package/src/api/argoSync.test.ts +22 -0
- package/src/api/client.audit-gating.test.tsx +48 -0
- package/src/api/client.kueuePosition.test.ts +32 -0
- package/src/api/client.kueueQueueWorkloads.test.tsx +71 -0
- package/src/api/client.resource-identity.test.ts +3 -0
- package/src/api/client.resourceIssues.test.tsx +239 -0
- package/src/api/client.resourcePath.test.ts +3 -0
- package/src/api/client.ts +353 -64
- package/src/api/config.ts +21 -0
- package/src/api/diagnose.ts +4 -0
- package/src/api/helmInventory.test.tsx +108 -0
- package/src/api/radarFeatures.render.test.tsx +33 -1
- package/src/api/radarFeatures.test.ts +47 -0
- package/src/api/radarFeatures.ts +42 -1
- package/src/api/rbac.settled.test.tsx +42 -0
- package/src/api/rbac.test.ts +18 -0
- package/src/api/rbac.ts +37 -7
- package/src/api/traffic.ts +9 -4
- package/src/api/usage-data.fixtures.ts +3 -1
- package/src/api/usage-data.test.tsx +134 -0
- package/src/api/usage-data.ts +35 -7
- package/src/api/workloadPodsPolling.test.ts +26 -0
- package/src/components/CloudConnectFlow.test.tsx +86 -0
- package/src/components/CloudConnectFlow.tsx +65 -27
- package/src/components/CloudFunnelButton.test.tsx +140 -5
- package/src/components/CloudFunnelButton.tsx +50 -9
- package/src/components/ConnectionErrorView.test.tsx +34 -0
- package/src/components/ConnectionErrorView.tsx +35 -11
- package/src/components/ContextSwitcher.tsx +5 -2
- package/src/components/SwitchAwareConnectionError.test.tsx +43 -0
- package/src/components/SwitchAwareConnectionError.tsx +85 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.flow.test.tsx +234 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.test.tsx +144 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.tsx +218 -0
- package/src/components/capacity/CapacityDemand.tsx +3 -2
- package/src/components/capacity/demandSummary.test.ts +38 -0
- package/src/components/capacity/shared.tsx +12 -1
- package/src/components/cost/ApplicationCostTab.tsx +4 -0
- package/src/components/cost/CostTrendChart.tsx +2 -0
- package/src/components/cost/WorkloadCostTab.tsx +4 -0
- package/src/components/cost/source.test.ts +5 -0
- package/src/components/cost/source.ts +11 -0
- package/src/components/curl/ServiceCurlAvailability.test.tsx +32 -0
- package/src/components/curl/ServiceCurlButton.tsx +2 -2
- package/src/components/diagnose/AIMarkdown.tsx +3 -0
- package/src/components/diagnose/AgentSetupNotice.test.tsx +17 -0
- package/src/components/diagnose/AgentSetupNotice.tsx +21 -3
- package/src/components/diagnose/ContinueInAgentButton.mounted.test.tsx +182 -0
- package/src/components/diagnose/ContinueInAgentButton.test.tsx +128 -0
- package/src/components/diagnose/ContinueInAgentButton.tsx +303 -0
- package/src/components/diagnose/DiagnoseContext.question.test.tsx +1 -1
- package/src/components/diagnose/DiagnoseContext.tsx +68 -2
- package/src/components/diagnose/DiagnoseSurface.tsx +58 -113
- package/src/components/diagnose/ExampleInvestigationLink.tsx +20 -0
- package/src/components/diagnose/Home.test.tsx +26 -0
- package/src/components/diagnose/Home.tsx +20 -1
- package/src/components/diagnose/InvestigationEvidenceSections.tsx +45 -22
- package/src/components/diagnose/InvestigationView.tsx +94 -26
- package/src/components/diagnose/LocalDiagnoseAction.history.test.tsx +450 -0
- package/src/components/diagnose/LocalDiagnoseAction.tsx +354 -35
- package/src/components/diagnose/NextStepJump.test.tsx +92 -0
- package/src/components/diagnose/NextStepJump.tsx +75 -0
- package/src/components/diagnose/QuestionComposer.tsx +8 -0
- package/src/components/diagnose/exampleInvestigation.events.json +191 -0
- package/src/components/diagnose/exampleInvestigation.loadFailure.test.tsx +94 -0
- package/src/components/diagnose/exampleInvestigation.test.tsx +248 -0
- package/src/components/diagnose/exampleInvestigation.ts +121 -0
- package/src/components/diagnose/investigationCase.test.tsx +50 -1
- package/src/components/diagnose/investigationEvidence/adapters/applicationFindings.test.ts +739 -0
- package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +72 -0
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +50 -2
- package/src/components/diagnose/investigationEvidence/adapters/helm.ts +51 -16
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +9 -0
- package/src/components/diagnose/investigationEvidence/adapters/listings.ts +34 -4
- package/src/components/diagnose/investigationEvidence/adapters/resource.ts +3 -2
- package/src/components/diagnose/investigationEvidence/builder.ts +30 -0
- package/src/components/diagnose/investigationEvidence/observations.ts +121 -2
- package/src/components/diagnose/investigationEvidence/projection.test.ts +85 -3
- package/src/components/diagnose/investigationEvidence/types.ts +5 -0
- package/src/components/diagnose/investigationState.ts +28 -0
- package/src/components/diagnose/lastInvestigation.test.ts +95 -0
- package/src/components/diagnose/lastInvestigation.ts +58 -0
- package/src/components/diagnose/launch.test.ts +125 -1
- package/src/components/diagnose/launch.ts +57 -10
- package/src/components/diagnose/toolCallLabel.test.ts +10 -4
- package/src/components/execution/BatchExecutionView.tsx +24 -11
- package/src/components/execution/JobSetAdmission.test.tsx +42 -0
- package/src/components/execution/JobSetAdmission.tsx +18 -3
- package/src/components/execution/JobSetMemberComparison.tsx +2 -1
- package/src/components/execution/runState.test.ts +14 -0
- package/src/components/execution/runState.ts +8 -0
- package/src/components/gitops/GitOpsView.rollbackGate.test.tsx +202 -0
- package/src/components/gitops/GitOpsView.syncRequest.test.tsx +369 -0
- package/src/components/gitops/GitOpsView.tsx +86 -17
- package/src/components/gitops/RemoteDestinationCloudHint.tsx +2 -3
- package/src/components/gitops/destination-toast.test.ts +1 -1
- package/src/components/gitops/destination-toast.ts +2 -2
- package/src/components/helm/HelmDrawerFrame.tsx +101 -0
- package/src/components/helm/HelmDrawerRouting.test.tsx +86 -0
- package/src/components/helm/HelmReleaseDrawer.tsx +23 -86
- package/src/components/helm/HelmView.tsx +213 -71
- package/src/components/helm/ObservedHelmNotice.tsx +146 -0
- package/src/components/helm/ObservedHelmRelease.test.tsx +261 -0
- package/src/components/helm/ObservedHelmReleaseDrawer.test.tsx +80 -0
- package/src/components/helm/ObservedHelmReleaseDrawer.tsx +228 -0
- package/src/components/helm/OwnedResources.tsx +4 -2
- package/src/components/home/ClusterHealthCard.restricted.test.tsx +76 -0
- package/src/components/home/ClusterHealthCard.tsx +28 -5
- package/src/components/home/HelmSummary.tsx +23 -4
- package/src/components/home/HelmSummary.unread.test.ts +16 -0
- package/src/components/home/HomeAgentBlock.test.tsx +31 -3
- package/src/components/home/HomeAgentBlock.tsx +20 -4
- package/src/components/home/HomeDiagramCard.tsx +47 -0
- package/src/components/home/HomeView.tsx +81 -41
- package/src/components/home/MCPSetupDialog.test.tsx +126 -10
- package/src/components/home/MCPSetupDialog.tsx +33 -5
- package/src/components/home/ProblemsPanel.investigate.test.tsx +171 -0
- package/src/components/home/ProblemsPanel.test.tsx +3 -1
- package/src/components/home/TopologyPreview.test.tsx +73 -0
- package/src/components/home/TopologyPreview.tsx +120 -233
- package/src/components/home/TrafficSummary.test.tsx +63 -0
- package/src/components/home/TrafficSummary.tsx +135 -138
- package/src/components/home/mcpToolCatalog.ts +67 -14
- package/src/components/issues/IssuesPane.test.ts +11 -0
- package/src/components/issues/IssuesPane.tsx +15 -5
- package/src/components/issues/uncheckedSources.test.ts +22 -1
- package/src/components/issues/uncheckedSources.ts +21 -0
- package/src/components/kueue/KueuePendingPosition.tsx +35 -0
- package/src/components/kueue/useRelatedObjects.test.tsx +219 -0
- package/src/components/kueue/useRelatedReads.test.ts +56 -0
- package/src/components/kueue/useRelatedReads.ts +205 -0
- package/src/components/logs/MultiPodLogsTab.test.tsx +93 -0
- package/src/components/logs/MultiPodLogsTab.tsx +120 -0
- package/src/components/logs/PodLogsUnavailable.test.tsx +18 -0
- package/src/components/logs/PodLogsUnavailable.tsx +21 -0
- package/src/components/logs/RayClusterLogsTab.reselect.test.tsx +67 -0
- package/src/components/logs/RayClusterLogsTab.test.tsx +167 -0
- package/src/components/logs/RayClusterLogsTab.tsx +109 -0
- package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +3 -2
- package/src/components/logs/rayClusterPods.ts +32 -0
- package/src/components/outageSince.test.ts +21 -0
- package/src/components/outageSince.ts +10 -0
- package/src/components/resource/PrometheusCharts.overlays.test.ts +12 -0
- package/src/components/resource/PrometheusCharts.tsx +3 -40
- package/src/components/resources/crd/CRDSchemaTab.test.tsx +28 -0
- package/src/components/resources/crd/CRDSchemaTab.tsx +13 -0
- package/src/components/resources/crd/host.tsx +14 -0
- package/src/components/resources/renderers/CustomResourceDefinitionRenderer.test.tsx +27 -0
- package/src/components/resources/renderers/CustomResourceDefinitionRenderer.tsx +12 -0
- package/src/components/resources/renderers/JobAdmissionRenderers.test.tsx +4 -1
- package/src/components/resources/renderers/JobAdmissionRenderers.tsx +4 -3
- package/src/components/resources/renderers/KueueHostRenderers.test.tsx +117 -0
- package/src/components/resources/renderers/KueueQueueRenderers.test.tsx +97 -0
- package/src/components/resources/renderers/KueueQueueRenderers.tsx +139 -0
- package/src/components/resources/renderers/KueueWorkloadRenderer.test.tsx +7 -1
- package/src/components/resources/renderers/KueueWorkloadRenderer.tsx +47 -7
- package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.test.tsx +67 -0
- package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.tsx +31 -0
- package/src/components/resources/renderers/RayClusterRenderer.test.tsx +81 -3
- package/src/components/resources/renderers/RayClusterRenderer.tsx +19 -4
- package/src/components/resources/renderers/ServiceRenderer.test.tsx +15 -2
- package/src/components/resources/renderers/ServiceRenderer.tsx +1 -1
- package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.test.tsx +160 -0
- package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.tsx +128 -0
- package/src/components/traffic/TrafficView.tsx +3 -3
- package/src/components/ui/command-items-crd.test.tsx +23 -0
- package/src/components/ui/command-items.ts +2 -1
- package/src/components/useContextSwitchFlow.test.tsx +61 -0
- package/src/components/useContextSwitchFlow.tsx +21 -4
- package/src/components/whats-new/WhatsNew.test.ts +10 -3
- package/src/components/whats-new/WhatsNew.tsx +5 -1
- package/src/components/whats-new/WhatsNewDialog.test.tsx +17 -3
- package/src/components/whats-new/releaseNotes.ts +77 -4
- package/src/components/workload/RelatedFindingsSection.test.tsx +126 -0
- package/src/components/workload/RelatedFindingsSection.tsx +80 -0
- package/src/components/workload/WorkloadView.test.ts +10 -1
- package/src/components/workload/WorkloadView.tsx +85 -98
- package/src/components/workload/issueResourceOpener.test.ts +20 -0
- package/src/components/workload/issueResourceOpener.ts +17 -0
- package/src/context/ConnectionContext.tsx +133 -60
- package/src/context/ConnectionProvider.retry.test.tsx +176 -0
- package/src/context/ContextSwitchContext.tsx +14 -1
- package/src/context/DiagnoseCustomization.tsx +3 -0
- package/src/context/clusterConnected.ts +10 -0
- package/src/contexts/CapabilitiesContext.tsx +8 -4
- package/src/hooks/useElementSize.ts +30 -0
- package/src/hooks/useResolvedGitOpsOwner.test.ts +22 -0
- package/src/hooks/useResolvedGitOpsOwner.ts +6 -3
- package/src/integrations/resourceHost.test.tsx +1 -0
- package/src/integrations/resourceHost.ts +5 -1
- package/src/integrations/resourceHosts.test.tsx +21 -4
- package/src/integrations/resourceHosts.tsx +17 -0
- package/src/main.tsx +5 -0
- package/src/utils/related-findings.ts +46 -0
|
@@ -49,7 +49,8 @@ export function updateDemandSearchParam(
|
|
|
49
49
|
// demandGroupVerdict synthesizes the one-line answer for the archetypal case:
|
|
50
50
|
// every evaluated pool ruled the group out. The dominant leading reason across
|
|
51
51
|
// incompatible pools headlines; the predicate tables below stay the receipts.
|
|
52
|
-
// Anything short of all-pools-incompatible
|
|
52
|
+
// Anything short of all-pools-incompatible — including a pool Radar could not
|
|
53
|
+
// evaluate — keeps the neutral counts line:
|
|
53
54
|
// declared compatibility is not a scheduling guarantee, and a synthesized
|
|
54
55
|
// verdict must not overclaim past what the evidence supports.
|
|
55
56
|
export function demandGroupVerdict(group: CapacityDemandGroup): {
|
|
@@ -58,7 +59,7 @@ export function demandGroupVerdict(group: CapacityDemandGroup): {
|
|
|
58
59
|
poolCount: number;
|
|
59
60
|
} | null {
|
|
60
61
|
const counts = group.poolEvaluationCounts;
|
|
61
|
-
if (counts.declaredCompatible > 0 || counts.incompatible === 0) return null;
|
|
62
|
+
if (counts.declaredCompatible > 0 || counts.incompatible === 0 || counts.unknown > 0) return null;
|
|
62
63
|
const leading = group.poolEvaluations
|
|
63
64
|
.filter((e) => e.result === "incompatible" && e.evidence.length > 0)
|
|
64
65
|
.map((e) => e.evidence[0]);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import type { CapacityDemandGroup } from "@skyhook-io/k8s-ui";
|
|
3
|
+
import { demandGroupVerdict } from "./CapacityDemand";
|
|
4
|
+
import { quantityText } from "./shared";
|
|
5
|
+
|
|
6
|
+
function group(counts: { declaredCompatible: number; incompatible: number; unknown: number }): CapacityDemandGroup {
|
|
7
|
+
const incompatible = Array.from({ length: counts.incompatible }, (_, i) => ({
|
|
8
|
+
result: "incompatible",
|
|
9
|
+
evidence: [{ predicate: "requirements", explanation: `pool ${i} requires arm64` }],
|
|
10
|
+
}));
|
|
11
|
+
return { poolEvaluationCounts: counts, poolEvaluations: incompatible } as unknown as CapacityDemandGroup;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
describe("demandGroupVerdict", () => {
|
|
15
|
+
it("rules a group out when every evaluated pool is incompatible", () => {
|
|
16
|
+
expect(demandGroupVerdict(group({ declaredCompatible: 0, incompatible: 2, unknown: 0 }))?.poolCount).toBe(2);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("gives no verdict while any pool is unknown", () => {
|
|
20
|
+
expect(demandGroupVerdict(group({ declaredCompatible: 0, incompatible: 5, unknown: 1 }))).toBeNull();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe("quantityText", () => {
|
|
25
|
+
it("names GPU, pod and extended quantities", () => {
|
|
26
|
+
const observation = {
|
|
27
|
+
certainty: "exact",
|
|
28
|
+
resources: { cpu: "100m", memory: "32Mi", "nvidia.com/gpu": "2", pods: "1" },
|
|
29
|
+
};
|
|
30
|
+
expect(quantityText(observation as never)).toBe("0.10 cores · 32 MiB · gpu 2 · 1 pod");
|
|
31
|
+
expect(quantityText({ certainty: "exact", resources: { pods: "3", "example.com/fpga": "1" } } as never)).toBe(
|
|
32
|
+
"example.com/fpga 1 · 3 pods",
|
|
33
|
+
);
|
|
34
|
+
expect(quantityText({ certainty: "exact", resources: { "gpu.intel.com/millicores": "500" } } as never)).toBe(
|
|
35
|
+
"gpu.intel.com/millicores 500",
|
|
36
|
+
);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -51,6 +51,7 @@ import {
|
|
|
51
51
|
type StatusTone,
|
|
52
52
|
} from "@skyhook-io/k8s-ui";
|
|
53
53
|
import { Badge } from "@skyhook-io/k8s-ui/components/ui/Badge";
|
|
54
|
+
import { isGpuCountKey } from "@skyhook-io/k8s-ui/utils/extended-resources";
|
|
54
55
|
import {
|
|
55
56
|
formatCPUString,
|
|
56
57
|
formatMemoryString,
|
|
@@ -302,6 +303,16 @@ export function sortedResourceEntries(
|
|
|
302
303
|
}
|
|
303
304
|
|
|
304
305
|
/** "8 CPU · 32Gi" style compact one-liner for a quantity observation. */
|
|
306
|
+
// CPU and memory read by their units; every other quantity is a bare number
|
|
307
|
+
// without its resource name.
|
|
308
|
+
function labeledQuantity(resource: string, value: string): string {
|
|
309
|
+
const quantity = formatQuantity(resource, value);
|
|
310
|
+
if (resource === "cpu" || resource === "memory") return quantity;
|
|
311
|
+
if (resource === "pods") return `${quantity} ${quantity === "1" ? "pod" : "pods"}`;
|
|
312
|
+
if (isGpuCountKey(resource)) return `gpu ${quantity}`;
|
|
313
|
+
return `${resource} ${quantity}`;
|
|
314
|
+
}
|
|
315
|
+
|
|
305
316
|
export function quantityText(
|
|
306
317
|
observation: CapacityQuantityObservation | undefined,
|
|
307
318
|
options?: { max?: number },
|
|
@@ -312,7 +323,7 @@ export function quantityText(
|
|
|
312
323
|
const max = options?.max ?? 4;
|
|
313
324
|
const shown = entries
|
|
314
325
|
.slice(0, max)
|
|
315
|
-
.map(([resource, value]) =>
|
|
326
|
+
.map(([resource, value]) => labeledQuantity(resource, value));
|
|
316
327
|
if (entries.length > max) shown.push(`+${entries.length - max}`);
|
|
317
328
|
return shown.join(" · ");
|
|
318
329
|
}
|
|
@@ -129,6 +129,8 @@ export function ApplicationCostTab({
|
|
|
129
129
|
state === 'not_found' ||
|
|
130
130
|
state === 'no_cost_source' ||
|
|
131
131
|
state === 'source_unavailable' ||
|
|
132
|
+
state === 'metrics_port_forward_disabled' ||
|
|
133
|
+
state === 'kubecost_port_forward_disabled' ||
|
|
132
134
|
state === 'authentication_error' ||
|
|
133
135
|
state === 'configuration_mismatch' ||
|
|
134
136
|
state === 'deployment_configuration_error' ||
|
|
@@ -401,6 +403,8 @@ export function getApplicationCostState(
|
|
|
401
403
|
reason === 'access_denied' ||
|
|
402
404
|
reason === 'not_found' ||
|
|
403
405
|
reason === 'source_unavailable' ||
|
|
406
|
+
reason === 'metrics_port_forward_disabled' ||
|
|
407
|
+
reason === 'kubecost_port_forward_disabled' ||
|
|
404
408
|
reason === 'authentication_error' ||
|
|
405
409
|
reason === 'configuration_mismatch' ||
|
|
406
410
|
reason === 'deployment_configuration_error' ||
|
|
@@ -511,6 +511,8 @@ export function kubecostTrendUnavailableMessage(
|
|
|
511
511
|
return 'Kubecost rejected Radar’s API key. Check Settings → Cost.'
|
|
512
512
|
case 'source_unavailable':
|
|
513
513
|
return 'Radar could not reach Kubecost. Check Settings → Cost.'
|
|
514
|
+
case 'kubecost_port_forward_disabled':
|
|
515
|
+
return 'Automatic port-forwarding is turned off, so Radar can’t reach the Kubecost Aggregator it found in this cluster. Set the Kubecost URL in Settings → Cost.'
|
|
514
516
|
case 'configuration_mismatch':
|
|
515
517
|
return 'Kubecost returned data for a different cluster. Check the cluster ID in Settings → Cost.'
|
|
516
518
|
case 'cost_settings_error':
|
|
@@ -96,6 +96,8 @@ export function WorkloadCostTab({ kind, namespace, name }: WorkloadCostTabProps)
|
|
|
96
96
|
state === 'not_found' ||
|
|
97
97
|
state === 'no_cost_source' ||
|
|
98
98
|
state === 'source_unavailable' ||
|
|
99
|
+
state === 'metrics_port_forward_disabled' ||
|
|
100
|
+
state === 'kubecost_port_forward_disabled' ||
|
|
99
101
|
state === 'authentication_error' ||
|
|
100
102
|
state === 'configuration_mismatch' ||
|
|
101
103
|
state === 'deployment_configuration_error' ||
|
|
@@ -307,6 +309,8 @@ export function getWorkloadCostState(
|
|
|
307
309
|
reason === 'access_denied' ||
|
|
308
310
|
reason === 'not_found' ||
|
|
309
311
|
reason === 'source_unavailable' ||
|
|
312
|
+
reason === 'metrics_port_forward_disabled' ||
|
|
313
|
+
reason === 'kubecost_port_forward_disabled' ||
|
|
310
314
|
reason === 'authentication_error' ||
|
|
311
315
|
reason === 'configuration_mismatch' ||
|
|
312
316
|
reason === 'deployment_configuration_error' ||
|
|
@@ -12,6 +12,11 @@ describe('cost source presentation', () => {
|
|
|
12
12
|
expect(costConfigurationAction('authentication_error', { ...both, cost: undefined }).label).toBe('Configure cost source')
|
|
13
13
|
expect(costConfigurationAction('configuration_mismatch', both).section).toBe('cost')
|
|
14
14
|
})
|
|
15
|
+
it('sends a turned-off port-forward to the integration that needed it', () => {
|
|
16
|
+
const both = { metrics: 'previous', cost: 'previous', explicitCostBackend: true } as const
|
|
17
|
+
expect(costConfigurationAction('metrics_port_forward_disabled', both).section).toBe('prometheus')
|
|
18
|
+
expect(costConfigurationAction('kubecost_port_forward_disabled', both).section).toBe('cost')
|
|
19
|
+
})
|
|
15
20
|
it('keeps the neutral action and explains reuse in the note', () => {
|
|
16
21
|
const copy = { metrics: 'copy', explicitCostBackend: false } as const
|
|
17
22
|
expect(costConfigurationAction('no_prometheus', copy)).toMatchObject({ section: 'prometheus', label: 'Configure metrics' })
|
|
@@ -3,6 +3,7 @@ import { previousSettingsNote, type PreviousIntegrationSettings } from '../../ho
|
|
|
3
3
|
|
|
4
4
|
export function isCostConfigurable(reason?: string): boolean {
|
|
5
5
|
return reason === 'no_prometheus' || reason === 'no_cost_source' || reason === 'source_unavailable'
|
|
6
|
+
|| reason === 'metrics_port_forward_disabled' || reason === 'kubecost_port_forward_disabled'
|
|
6
7
|
|| reason === 'authentication_error' || reason === 'configuration_mismatch'
|
|
7
8
|
|| reason === 'metrics_settings_error' || reason === 'cost_settings_error'
|
|
8
9
|
}
|
|
@@ -34,6 +35,8 @@ export function costConfigurationAction(reason?: CostUnavailableReason, offers?:
|
|
|
34
35
|
} {
|
|
35
36
|
if (reason === 'metrics_settings_error') return { section: 'prometheus', label: 'Review metrics settings' }
|
|
36
37
|
if (reason === 'cost_settings_error') return { section: 'cost', label: 'Review cost settings' }
|
|
38
|
+
if (reason === 'metrics_port_forward_disabled') return { section: 'prometheus', label: 'Configure metrics' }
|
|
39
|
+
if (reason === 'kubecost_port_forward_disabled') return { section: 'cost', label: 'Configure cost source' }
|
|
37
40
|
const previousKind = reason === 'no_prometheus'
|
|
38
41
|
? offers?.metrics ? 'metrics' : offers?.explicitCostBackend ? 'cost' : undefined
|
|
39
42
|
: reason === 'no_cost_source'
|
|
@@ -119,6 +122,14 @@ export function costIntegrationUnavailableMessage(
|
|
|
119
122
|
return settingsAvailable
|
|
120
123
|
? 'Kubecost Aggregator is unavailable. Check the URL, network path, and cluster ID in Settings → Cost.'
|
|
121
124
|
: 'Kubecost Aggregator is unavailable. Update this cluster’s cost-source configuration in the host application or Radar deployment.'
|
|
125
|
+
case 'metrics_port_forward_disabled':
|
|
126
|
+
return settingsAvailable
|
|
127
|
+
? 'Automatic port-forwarding is turned off, and Prometheus isn’t reachable directly from this machine. Set a metrics URL in Settings → Metrics.'
|
|
128
|
+
: 'Automatic port-forwarding is turned off, and Prometheus isn’t reachable directly. Configure its URL in the host application or Radar deployment.'
|
|
129
|
+
case 'kubecost_port_forward_disabled':
|
|
130
|
+
return settingsAvailable
|
|
131
|
+
? 'Automatic port-forwarding is turned off, so Radar can’t reach the Kubecost Aggregator it found in this cluster. Set the Kubecost URL in Settings → Cost.'
|
|
132
|
+
: 'Automatic port-forwarding is turned off, so Radar can’t reach the Kubecost Aggregator it found in this cluster. Configure its URL in the host application or Radar deployment.'
|
|
122
133
|
case 'metrics_settings_error':
|
|
123
134
|
return 'This cluster’s saved metrics settings need review before cost data can load. Review them in Settings → Metrics.'
|
|
124
135
|
case 'cost_settings_error':
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
2
|
+
import { expect, it } from 'vitest'
|
|
3
|
+
import { ServicePortCards } from '@skyhook-io/k8s-ui/components/resources/renderers/ServiceRenderer'
|
|
4
|
+
import { CurlButton, isHttpishPort } from './ServiceCurlButton'
|
|
5
|
+
|
|
6
|
+
// The UI keeps Curl for every Service shape, including headless, ExternalName
|
|
7
|
+
// and selector-less ones; only MCP's curl_service is narrower.
|
|
8
|
+
it.each([
|
|
9
|
+
['ClusterIP', '10.0.0.8', { app: 'demo' }],
|
|
10
|
+
['LoadBalancer', '10.0.0.8', { app: 'demo' }],
|
|
11
|
+
['ClusterIP', 'None', { app: 'demo' }],
|
|
12
|
+
['ClusterIP', undefined, { app: 'demo' }],
|
|
13
|
+
['ClusterIP', '10.0.0.8', {}],
|
|
14
|
+
['ExternalName', undefined, {}],
|
|
15
|
+
] as const)('preserves UI Service requests through the shared workload port cards: %s %s', (type, clusterIP, selector) => {
|
|
16
|
+
const service = { metadata: { namespace: 'team', name: 'app' }, spec: { type, clusterIP, selector, ports: [{ port: 80, protocol: 'TCP' }] } }
|
|
17
|
+
const html = renderToStaticMarkup(<ServicePortCards service={service} renderPortAction={() => <CurlButton active={false} onClick={() => {}} />} />)
|
|
18
|
+
expect(html).toContain('aria-expanded')
|
|
19
|
+
// Port information remains available even when the HTTP action is unsupported.
|
|
20
|
+
expect(html).toContain('80')
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it.each([
|
|
24
|
+
['TCP', true],
|
|
25
|
+
[undefined, true],
|
|
26
|
+
['tcp', true],
|
|
27
|
+
['UDP', false],
|
|
28
|
+
['SCTP', false],
|
|
29
|
+
] as const)('offers Curl only on TCP ports (HTTP rides TCP): protocol %s', (protocol, offered) => {
|
|
30
|
+
// Port 8080 and name http would otherwise read as HTTP.
|
|
31
|
+
expect(isHttpishPort(8080, 'http', undefined, protocol)).toBe(offered)
|
|
32
|
+
})
|
|
@@ -36,8 +36,8 @@ export function defaultPathForPort(port: number, name?: string, appProtocol?: st
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export function isHttpishPort(port: number, name?: string, appProtocol?: string, protocol?: string): boolean {
|
|
39
|
-
// HTTP rides TCP —
|
|
40
|
-
if (
|
|
39
|
+
// HTTP rides TCP — UDP and SCTP ports are never GET targets (e.g. statsd "metrics-udp").
|
|
40
|
+
if (protocol && protocol.toUpperCase() !== 'TCP') return false
|
|
41
41
|
const proto = (appProtocol || '').toLowerCase()
|
|
42
42
|
if (proto === 'http' || proto === 'https' || proto === 'http2') return true
|
|
43
43
|
if (proto && proto !== 'tcp') {
|
|
@@ -2,10 +2,13 @@ import { useState, type ComponentProps } from "react";
|
|
|
2
2
|
import { AlertTriangle, Copy, Check } from "lucide-react";
|
|
3
3
|
import { Markdown } from "../ui/Markdown";
|
|
4
4
|
import { Tooltip } from "../ui/Tooltip";
|
|
5
|
+
import { useInExampleInvestigation } from "./exampleInvestigation";
|
|
5
6
|
|
|
6
7
|
export function CopyButton({ text, label }: { text: string; label: string }) {
|
|
7
8
|
const [state, setState] = useState<"idle" | "copied" | "failed">("idle");
|
|
9
|
+
const inExample = useInExampleInvestigation();
|
|
8
10
|
const copied = state === "copied";
|
|
11
|
+
if (inExample) return null;
|
|
9
12
|
return (
|
|
10
13
|
<Tooltip
|
|
11
14
|
content={
|
|
@@ -55,4 +55,21 @@ describe("AgentSetupNotice", () => {
|
|
|
55
55
|
expect(html).not.toContain("Install one of these");
|
|
56
56
|
expect(html).toContain("Check again");
|
|
57
57
|
});
|
|
58
|
+
|
|
59
|
+
it("links to the example in every setup state that offers it", () => {
|
|
60
|
+
for (const state of ["needs-install", "needs-restart"] as const) {
|
|
61
|
+
expect(render(state)).not.toContain("See an example investigation");
|
|
62
|
+
const html = renderToStaticMarkup(
|
|
63
|
+
<AgentSetupNotice
|
|
64
|
+
setupState={state}
|
|
65
|
+
cliOverride={false}
|
|
66
|
+
checkingAgents={false}
|
|
67
|
+
agentsCheckFailed={false}
|
|
68
|
+
recheckAgents={async () => {}}
|
|
69
|
+
onOpenExample={() => {}}
|
|
70
|
+
/>,
|
|
71
|
+
);
|
|
72
|
+
expect(html).toContain("See an example investigation");
|
|
73
|
+
}
|
|
74
|
+
});
|
|
58
75
|
});
|
|
@@ -5,6 +5,7 @@ import { copyText } from "@skyhook-io/k8s-ui/utils/clipboard";
|
|
|
5
5
|
import { SUPPORTED_AGENTS, type AgentInstall } from "./agentCatalog";
|
|
6
6
|
import { type DiagnoseSetup } from "./DiagnoseContext";
|
|
7
7
|
import { openExternal } from "../../utils/navigation";
|
|
8
|
+
import { ExampleInvestigationLink } from "./ExampleInvestigationLink";
|
|
8
9
|
|
|
9
10
|
const REPORT_URL =
|
|
10
11
|
"https://github.com/skyhook-io/radar/issues/new?labels=bug&template=bug_report.md";
|
|
@@ -101,12 +102,15 @@ export function AgentSetupNotice({
|
|
|
101
102
|
checkingAgents,
|
|
102
103
|
agentsCheckFailed,
|
|
103
104
|
recheckAgents,
|
|
105
|
+
onOpenExample,
|
|
104
106
|
}: {
|
|
105
107
|
setupState: DiagnoseSetup;
|
|
106
108
|
cliOverride: boolean;
|
|
107
109
|
checkingAgents: boolean;
|
|
108
110
|
agentsCheckFailed: boolean;
|
|
109
111
|
recheckAgents: () => Promise<void>;
|
|
112
|
+
/** Shows what an investigation produces before anything is set up. */
|
|
113
|
+
onOpenExample?: () => void;
|
|
110
114
|
}) {
|
|
111
115
|
// The state the panel was in when a check started. "Still…" is only true when
|
|
112
116
|
// the finished check left it there.
|
|
@@ -123,7 +127,10 @@ export function AgentSetupNotice({
|
|
|
123
127
|
|
|
124
128
|
if (cliOverride) {
|
|
125
129
|
return (
|
|
126
|
-
<SetupFrame
|
|
130
|
+
<SetupFrame
|
|
131
|
+
title="Radar can't run your RADAR_AI_CLI_BIN"
|
|
132
|
+
onOpenExample={onOpenExample}
|
|
133
|
+
>
|
|
127
134
|
<p className="mt-1 text-sm text-theme-text-secondary">
|
|
128
135
|
Fix the path, or remove it and restart Radar.
|
|
129
136
|
</p>
|
|
@@ -139,7 +146,10 @@ export function AgentSetupNotice({
|
|
|
139
146
|
}
|
|
140
147
|
if (setupState === "needs-restart") {
|
|
141
148
|
return (
|
|
142
|
-
<SetupFrame
|
|
149
|
+
<SetupFrame
|
|
150
|
+
title="AI investigations aren't available right now"
|
|
151
|
+
onOpenExample={onOpenExample}
|
|
152
|
+
>
|
|
143
153
|
<p className="mt-1 text-sm text-theme-text-secondary">
|
|
144
154
|
Try again in a moment.
|
|
145
155
|
</p>
|
|
@@ -154,7 +164,7 @@ export function AgentSetupNotice({
|
|
|
154
164
|
);
|
|
155
165
|
}
|
|
156
166
|
return (
|
|
157
|
-
<SetupFrame title="Set up AI investigations">
|
|
167
|
+
<SetupFrame title="Set up AI investigations" onOpenExample={onOpenExample}>
|
|
158
168
|
<p className="mt-1 text-sm text-theme-text-secondary">
|
|
159
169
|
Radar runs investigations through a coding agent CLI on your own
|
|
160
170
|
machine, with no Radar cloud and no API key. Install one of these:
|
|
@@ -186,9 +196,11 @@ export function AgentSetupNotice({
|
|
|
186
196
|
function SetupFrame({
|
|
187
197
|
title,
|
|
188
198
|
children,
|
|
199
|
+
onOpenExample,
|
|
189
200
|
}: {
|
|
190
201
|
title: string;
|
|
191
202
|
children: ReactNode;
|
|
203
|
+
onOpenExample?: () => void;
|
|
192
204
|
}) {
|
|
193
205
|
return (
|
|
194
206
|
<div className="mx-auto max-w-md px-1 py-6">
|
|
@@ -199,6 +211,12 @@ function SetupFrame({
|
|
|
199
211
|
{title}
|
|
200
212
|
</h3>
|
|
201
213
|
{children}
|
|
214
|
+
{onOpenExample && (
|
|
215
|
+
<p className="mt-4 text-sm text-theme-text-secondary">
|
|
216
|
+
Not sure yet?{" "}
|
|
217
|
+
<ExampleInvestigationLink onOpen={onOpenExample} />
|
|
218
|
+
</p>
|
|
219
|
+
)}
|
|
202
220
|
<p className="mt-4 text-xs text-theme-text-tertiary">
|
|
203
221
|
Your agent runs locally. Resource details and logs are sent to its model
|
|
204
222
|
provider under your account, not to Radar.
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from "react";
|
|
3
|
+
import { createRoot, type Root } from "react-dom/client";
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
|
+
import type { RunSummary } from "../../api/diagnose";
|
|
6
|
+
import { ContinueInAgentButton } from "./ContinueInAgentButton";
|
|
7
|
+
|
|
8
|
+
const caps = vi.hoisted(() => ({ localTerminal: true }));
|
|
9
|
+
vi.mock("../../contexts/CapabilitiesContext", () => ({
|
|
10
|
+
useCapabilitiesContext: () => ({
|
|
11
|
+
localTerminal: caps.localTerminal,
|
|
12
|
+
mcpReadOnly: false,
|
|
13
|
+
}),
|
|
14
|
+
}));
|
|
15
|
+
const launch = vi.hoisted(() => ({ openInTerminal: vi.fn() }));
|
|
16
|
+
vi.mock("./launch", async (importOriginal) => ({
|
|
17
|
+
...(await importOriginal<object>()),
|
|
18
|
+
openInTerminal: launch.openInTerminal,
|
|
19
|
+
}));
|
|
20
|
+
const clipboard = vi.hoisted(() => ({ copyText: vi.fn() }));
|
|
21
|
+
vi.mock("@skyhook-io/k8s-ui/utils/clipboard", () => clipboard);
|
|
22
|
+
|
|
23
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
|
|
24
|
+
let root: Root;
|
|
25
|
+
const run: RunSummary = {
|
|
26
|
+
id: "r1",
|
|
27
|
+
kind: "Deployment",
|
|
28
|
+
group: "apps",
|
|
29
|
+
namespace: "shop",
|
|
30
|
+
name: "api",
|
|
31
|
+
context: "test",
|
|
32
|
+
agent: "claude",
|
|
33
|
+
status: "done",
|
|
34
|
+
sessionId: "ses_1",
|
|
35
|
+
createdAt: "2026-10-01T00:00:00Z",
|
|
36
|
+
updatedAt: "2026-10-01T00:00:00Z",
|
|
37
|
+
};
|
|
38
|
+
const flush = () =>
|
|
39
|
+
act(async () => {
|
|
40
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
41
|
+
});
|
|
42
|
+
const caret = () =>
|
|
43
|
+
document.querySelector<HTMLButtonElement>('button[aria-haspopup="dialog"]')!;
|
|
44
|
+
const panel = () => document.querySelector('[role="dialog"]');
|
|
45
|
+
|
|
46
|
+
async function mount(r: RunSummary = run) {
|
|
47
|
+
await act(async () =>
|
|
48
|
+
root.render(<ContinueInAgentButton run={r} command="claude --resume x" />),
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
beforeEach(async () => {
|
|
53
|
+
clipboard.copyText.mockReset();
|
|
54
|
+
launch.openInTerminal.mockReset();
|
|
55
|
+
caps.localTerminal = true;
|
|
56
|
+
const el = document.createElement("div");
|
|
57
|
+
document.body.appendChild(el);
|
|
58
|
+
root = createRoot(el);
|
|
59
|
+
await mount();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
afterEach(async () => {
|
|
63
|
+
await act(async () => root.unmount());
|
|
64
|
+
document.body.replaceChildren();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
async function openPanel() {
|
|
68
|
+
await act(async () => caret().click());
|
|
69
|
+
await flush();
|
|
70
|
+
// The panel animates in over two frames, then takes focus.
|
|
71
|
+
for (let i = 0; i < 2; i++)
|
|
72
|
+
await act(async () => {
|
|
73
|
+
await new Promise((resolve) =>
|
|
74
|
+
requestAnimationFrame(() => resolve(null)),
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
await flush();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
describe("the continue panel", () => {
|
|
81
|
+
it("opens as a dialog holding the command, and copies it", async () => {
|
|
82
|
+
clipboard.copyText.mockResolvedValue(true);
|
|
83
|
+
await openPanel();
|
|
84
|
+
expect(caret().getAttribute("aria-expanded")).toBe("true");
|
|
85
|
+
expect(panel()?.textContent).toContain("claude --resume x");
|
|
86
|
+
const copy = panel()!.querySelector<HTMLButtonElement>(
|
|
87
|
+
'button[aria-label="Copy command"]',
|
|
88
|
+
)!;
|
|
89
|
+
await act(async () => copy.click());
|
|
90
|
+
await flush();
|
|
91
|
+
expect(clipboard.copyText).toHaveBeenCalledWith("claude --resume x");
|
|
92
|
+
expect(copy.getAttribute("aria-label")).toBe("Command copied");
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("says so when the copy fails", async () => {
|
|
96
|
+
clipboard.copyText.mockResolvedValue(false);
|
|
97
|
+
await openPanel();
|
|
98
|
+
const copy = panel()!.querySelector<HTMLButtonElement>(
|
|
99
|
+
'button[aria-label="Copy command"]',
|
|
100
|
+
)!;
|
|
101
|
+
await act(async () => copy.click());
|
|
102
|
+
await flush();
|
|
103
|
+
expect(copy.getAttribute("aria-label")).toBe("Copy failed");
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("closes on Escape without letting it reach the panel underneath", async () => {
|
|
107
|
+
await openPanel();
|
|
108
|
+
const underneath = vi.fn();
|
|
109
|
+
window.addEventListener("keydown", underneath);
|
|
110
|
+
await act(async () =>
|
|
111
|
+
document.activeElement!.dispatchEvent(
|
|
112
|
+
new KeyboardEvent("keydown", { key: "Escape", bubbles: true }),
|
|
113
|
+
),
|
|
114
|
+
);
|
|
115
|
+
expect(caret().getAttribute("aria-expanded")).toBe("false");
|
|
116
|
+
expect(document.activeElement).toBe(caret());
|
|
117
|
+
expect(underneath).not.toHaveBeenCalled();
|
|
118
|
+
window.removeEventListener("keydown", underneath);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("closes when the pane scrolls or resizes, since its placement would be stale", async () => {
|
|
122
|
+
await openPanel();
|
|
123
|
+
await act(async () => document.dispatchEvent(new Event("scroll")));
|
|
124
|
+
expect(caret().getAttribute("aria-expanded")).toBe("false");
|
|
125
|
+
await openPanel();
|
|
126
|
+
await act(async () => window.dispatchEvent(new Event("resize")));
|
|
127
|
+
expect(caret().getAttribute("aria-expanded")).toBe("false");
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("tabs between its buttons, and back to the caret past the last", async () => {
|
|
131
|
+
await openPanel();
|
|
132
|
+
const [runHere, copy] = Array.from(
|
|
133
|
+
panel()!.querySelectorAll<HTMLButtonElement>("button"),
|
|
134
|
+
);
|
|
135
|
+
expect(document.activeElement).toBe(runHere);
|
|
136
|
+
const tab = (shiftKey = false) =>
|
|
137
|
+
act(async () =>
|
|
138
|
+
document.activeElement!.dispatchEvent(
|
|
139
|
+
new KeyboardEvent("keydown", { key: "Tab", shiftKey, bubbles: true }),
|
|
140
|
+
),
|
|
141
|
+
);
|
|
142
|
+
await tab();
|
|
143
|
+
// Not the last button: the panel stays open and the browser moves focus.
|
|
144
|
+
expect(caret().getAttribute("aria-expanded")).toBe("true");
|
|
145
|
+
copy.focus();
|
|
146
|
+
await tab();
|
|
147
|
+
expect(caret().getAttribute("aria-expanded")).toBe("false");
|
|
148
|
+
expect(document.activeElement).toBe(caret());
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it("leads with the trust warning and Run in Radar terminal, focused", async () => {
|
|
152
|
+
await openPanel();
|
|
153
|
+
// Described by the explanation and the warning, so a screen reader reads
|
|
154
|
+
// them when focus lands on the button below.
|
|
155
|
+
const described = (panel()!.getAttribute("aria-describedby") ?? "")
|
|
156
|
+
.split(" ")
|
|
157
|
+
.map((id) => document.getElementById(id)?.textContent ?? "")
|
|
158
|
+
.join(" ");
|
|
159
|
+
expect(described).toContain("Resumes this session");
|
|
160
|
+
expect(described).toContain("Select Yes before pressing Enter");
|
|
161
|
+
const runHere = panel()!.querySelector<HTMLButtonElement>("button")!;
|
|
162
|
+
expect(runHere.textContent).toBe("Run in Radar terminal");
|
|
163
|
+
expect(document.activeElement).toBe(runHere);
|
|
164
|
+
await act(async () => runHere.click());
|
|
165
|
+
expect(launch.openInTerminal).toHaveBeenCalledWith(
|
|
166
|
+
"claude --resume x",
|
|
167
|
+
"Radar Investigation",
|
|
168
|
+
);
|
|
169
|
+
expect(caret().getAttribute("aria-expanded")).toBe("false");
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it("offers copy first without a terminal, and no trust warning for Codex", async () => {
|
|
173
|
+
caps.localTerminal = false;
|
|
174
|
+
await mount({ ...run, agent: "codex" });
|
|
175
|
+
await openPanel();
|
|
176
|
+
expect(panel()!.textContent).not.toContain("Run in Radar terminal");
|
|
177
|
+
expect(panel()!.textContent).not.toContain("Select Yes");
|
|
178
|
+
expect(document.activeElement?.getAttribute("aria-label")).toBe(
|
|
179
|
+
"Copy command",
|
|
180
|
+
);
|
|
181
|
+
});
|
|
182
|
+
});
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
3
|
+
import type { RunSummary } from "../../api/diagnose";
|
|
4
|
+
import { ContinueInAgentButton } from "./ContinueInAgentButton";
|
|
5
|
+
import { canContinueInOwnAgent } from "./investigationState";
|
|
6
|
+
|
|
7
|
+
let mockLocalTerminal = true;
|
|
8
|
+
vi.mock("../../contexts/CapabilitiesContext", () => ({
|
|
9
|
+
useCapabilitiesContext: () => ({
|
|
10
|
+
localTerminal: mockLocalTerminal,
|
|
11
|
+
mcpReadOnly: false,
|
|
12
|
+
}),
|
|
13
|
+
}));
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
mockLocalTerminal = true;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
function run(overrides: Partial<RunSummary> = {}): RunSummary {
|
|
19
|
+
return {
|
|
20
|
+
id: "r1",
|
|
21
|
+
kind: "Deployment",
|
|
22
|
+
group: "apps",
|
|
23
|
+
namespace: "gl-crash-config",
|
|
24
|
+
name: "api",
|
|
25
|
+
context: "test",
|
|
26
|
+
agent: "claude",
|
|
27
|
+
status: "done",
|
|
28
|
+
sessionId: "ses_1",
|
|
29
|
+
createdAt: "2026-10-01T00:00:00Z",
|
|
30
|
+
updatedAt: "2026-10-01T00:00:00Z",
|
|
31
|
+
...overrides,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const settled = {
|
|
36
|
+
run: run(),
|
|
37
|
+
busy: false,
|
|
38
|
+
requestPending: false,
|
|
39
|
+
gone: false,
|
|
40
|
+
streamReady: true,
|
|
41
|
+
verificationPending: false,
|
|
42
|
+
latestTurnStatus: "done" as const,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
describe("canContinueInOwnAgent", () => {
|
|
46
|
+
it("offers the hand-off once the verdict is in", () => {
|
|
47
|
+
expect(canContinueInOwnAgent(settled)).toBe(true);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("waits while any turn is writing to the session", () => {
|
|
51
|
+
expect(canContinueInOwnAgent({ ...settled, busy: true })).toBe(false);
|
|
52
|
+
expect(canContinueInOwnAgent({ ...settled, requestPending: true })).toBe(
|
|
53
|
+
false,
|
|
54
|
+
);
|
|
55
|
+
expect(
|
|
56
|
+
canContinueInOwnAgent({ ...settled, latestTurnStatus: "running" }),
|
|
57
|
+
).toBe(false);
|
|
58
|
+
expect(
|
|
59
|
+
canContinueInOwnAgent({
|
|
60
|
+
...settled,
|
|
61
|
+
run: run({ status: "running" }),
|
|
62
|
+
latestTurnStatus: undefined,
|
|
63
|
+
}),
|
|
64
|
+
).toBe(false);
|
|
65
|
+
expect(
|
|
66
|
+
canContinueInOwnAgent({ ...settled, verificationPending: true }),
|
|
67
|
+
).toBe(false);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("waits for a replay to catch up before trusting the transcript", () => {
|
|
71
|
+
expect(canContinueInOwnAgent({ ...settled, streamReady: false })).toBe(
|
|
72
|
+
false,
|
|
73
|
+
);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("waits through stopping, whose terminal frame precedes the exit", () => {
|
|
77
|
+
expect(
|
|
78
|
+
canContinueInOwnAgent({ ...settled, run: run({ status: "stopping" }) }),
|
|
79
|
+
).toBe(false);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("trusts a finished transcript over a lagging run summary", () => {
|
|
83
|
+
expect(
|
|
84
|
+
canContinueInOwnAgent({ ...settled, run: run({ status: "running" }) }),
|
|
85
|
+
).toBe(true);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("stays hidden on a run that is gone", () => {
|
|
89
|
+
expect(canContinueInOwnAgent({ ...settled, gone: true })).toBe(false);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
describe("ContinueInAgentButton", () => {
|
|
94
|
+
const command =
|
|
95
|
+
"mkdir -p ~/.radar/agent && cd ~/.radar/agent && claude --resume 'ses_1'";
|
|
96
|
+
|
|
97
|
+
it("is one button that opens a dialog, named for the agent", () => {
|
|
98
|
+
const html = renderToStaticMarkup(
|
|
99
|
+
<ContinueInAgentButton run={run()} command={command} />,
|
|
100
|
+
);
|
|
101
|
+
expect(html).toContain('aria-label="Continue in Claude Code"');
|
|
102
|
+
expect(html).toContain("Claude Code…");
|
|
103
|
+
expect(html).toContain('aria-haspopup="dialog"');
|
|
104
|
+
expect(html).toContain('aria-expanded="false"');
|
|
105
|
+
expect(html.match(/<button/g)).toHaveLength(1);
|
|
106
|
+
// Nothing about the trust prompt until the panel opens and shows it.
|
|
107
|
+
expect(html).not.toContain("Select Yes");
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("names the agent that ran the investigation", () => {
|
|
111
|
+
const html = renderToStaticMarkup(
|
|
112
|
+
<ContinueInAgentButton
|
|
113
|
+
run={run({ agent: "codex" })}
|
|
114
|
+
command="codex resume 'ses_1'"
|
|
115
|
+
/>,
|
|
116
|
+
);
|
|
117
|
+
expect(html).toContain('aria-label="Continue in Codex"');
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("is the same button when Radar has no terminal", () => {
|
|
121
|
+
mockLocalTerminal = false;
|
|
122
|
+
const html = renderToStaticMarkup(
|
|
123
|
+
<ContinueInAgentButton run={run()} command={command} />,
|
|
124
|
+
);
|
|
125
|
+
expect(html).toContain('aria-haspopup="dialog"');
|
|
126
|
+
expect(html.match(/<button/g)).toHaveLength(1);
|
|
127
|
+
});
|
|
128
|
+
});
|