@skyhook-io/radar-app 1.18.2 → 1.20.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.
- package/README.md +1 -1
- package/package.json +7 -7
- package/src/App.tsx +31 -6
- 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 +285 -55
- package/src/api/config.ts +21 -0
- package/src/api/diagnose.test.ts +33 -2
- package/src/api/diagnose.ts +97 -3
- package/src/api/radarFeatures.render.test.tsx +33 -1
- package/src/api/radarFeatures.test.ts +47 -0
- package/src/api/radarFeatures.ts +41 -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/diagnose/AIMarkdown.tsx +4 -1
- package/src/components/diagnose/ActivityTurn.tsx +34 -14
- package/src/components/diagnose/AgentControls.tsx +53 -6
- package/src/components/diagnose/AgentSetupNotice.test.tsx +17 -0
- package/src/components/diagnose/AgentSetupNotice.tsx +22 -4
- package/src/components/diagnose/AgentSigninNotice.test.tsx +98 -0
- package/src/components/diagnose/AgentSigninNotice.tsx +61 -0
- package/src/components/diagnose/AnalysisStory.test.tsx +22 -0
- package/src/components/diagnose/AnalysisStory.tsx +17 -4
- package/src/components/diagnose/AssessmentCard.tsx +39 -8
- 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.capacity.test.tsx +113 -0
- package/src/components/diagnose/DiagnoseContext.question.test.tsx +245 -0
- package/src/components/diagnose/DiagnoseContext.tsx +272 -10
- package/src/components/diagnose/DiagnoseSurface.test.tsx +54 -0
- package/src/components/diagnose/DiagnoseSurface.tsx +151 -134
- package/src/components/diagnose/EvidenceCard.tsx +67 -14
- package/src/components/diagnose/ExampleInvestigationLink.tsx +20 -0
- package/src/components/diagnose/Home.test.tsx +208 -5
- package/src/components/diagnose/Home.tsx +187 -36
- package/src/components/diagnose/InvestigationCapacityNotice.test.tsx +246 -0
- package/src/components/diagnose/InvestigationCapacityNotice.tsx +241 -0
- package/src/components/diagnose/InvestigationEvidencePane.story.test.tsx +97 -6
- package/src/components/diagnose/InvestigationEvidencePane.test.tsx +57 -0
- package/src/components/diagnose/InvestigationEvidencePane.tsx +59 -11
- package/src/components/diagnose/InvestigationEvidenceSections.tsx +50 -23
- package/src/components/diagnose/InvestigationView.tsx +249 -54
- package/src/components/diagnose/LocalDiagnoseAction.history.test.tsx +450 -0
- package/src/components/diagnose/LocalDiagnoseAction.tsx +365 -39
- package/src/components/diagnose/NextStepJump.test.tsx +92 -0
- package/src/components/diagnose/NextStepJump.tsx +75 -0
- package/src/components/diagnose/QuestionComposer.test.tsx +553 -0
- package/src/components/diagnose/QuestionComposer.tsx +495 -0
- package/src/components/diagnose/QuestionFocus.test.tsx +38 -0
- package/src/components/diagnose/QuestionFocus.tsx +123 -0
- package/src/components/diagnose/ResourcePicker.tsx +206 -0
- package/src/components/diagnose/StoryExcerpt.tsx +12 -3
- package/src/components/diagnose/assessmentCopy.ts +5 -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.runs.test.tsx +328 -0
- package/src/components/diagnose/investigationCase.test.tsx +9 -1
- package/src/components/diagnose/investigationCase.ts +33 -1
- package/src/components/diagnose/investigationEvidence/adapters/applicationFindings.test.ts +739 -0
- package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +46 -0
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +58 -2
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +9 -0
- package/src/components/diagnose/investigationEvidence/adapters/posture.ts +29 -1
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.test.ts +40 -0
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +27 -1
- package/src/components/diagnose/investigationEvidence/bodies/metrics.test.tsx +111 -0
- package/src/components/diagnose/investigationEvidence/bodies/metrics.tsx +67 -16
- package/src/components/diagnose/investigationEvidence/builder.ts +30 -0
- package/src/components/diagnose/investigationEvidence/excerpt.test.ts +18 -5
- package/src/components/diagnose/investigationEvidence/excerpt.ts +22 -11
- package/src/components/diagnose/investigationEvidence/index.ts +1 -1
- package/src/components/diagnose/investigationEvidence/navigation.tsx +2 -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 +7 -0
- package/src/components/diagnose/investigationEvidencePartition.ts +6 -1
- package/src/components/diagnose/investigationFocus.test.ts +271 -0
- package/src/components/diagnose/investigationFocus.ts +132 -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/parts.test.tsx +20 -0
- package/src/components/diagnose/questionSuggestions.test.ts +111 -0
- package/src/components/diagnose/questionSuggestions.ts +150 -0
- package/src/components/diagnose/storyParts.test.tsx +13 -0
- package/src/components/diagnose/target.test.ts +143 -2
- package/src/components/diagnose/target.ts +109 -7
- package/src/components/diagnose/testdata/story-runs.json +474 -0
- package/src/components/diagnose/toolCallLabel.test.ts +10 -4
- package/src/components/diagnose/verdictText.test.tsx +87 -0
- package/src/components/diagnose/verdictText.ts +68 -0
- 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/home/ClusterHealthCard.tsx +13 -39
- package/src/components/home/HomeAgentBlock.test.tsx +141 -0
- package/src/components/home/HomeAgentBlock.tsx +103 -0
- package/src/components/home/HomeDiagramCard.tsx +47 -0
- package/src/components/home/HomeView.tsx +86 -47
- package/src/components/home/MCPSetupDialog.test.tsx +95 -5
- package/src/components/home/MCPSetupDialog.tsx +30 -5
- package/src/components/home/ProblemsPanel.investigate.test.tsx +171 -0
- package/src/components/home/ProblemsPanel.test.tsx +3 -1
- package/src/components/home/RadarVersionLine.test.tsx +0 -14
- package/src/components/home/RadarVersionLine.tsx +3 -28
- 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 +23 -10
- package/src/components/issues/IssuesPane.test.ts +11 -0
- package/src/components/issues/IssuesPane.tsx +15 -5
- package/src/components/issues/uncheckedSources.test.ts +20 -1
- package/src/components/issues/uncheckedSources.ts +18 -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/traffic/TrafficView.tsx +3 -3
- package/src/components/ui/Omnibar.investigate.test.tsx +105 -0
- package/src/components/ui/Omnibar.tsx +47 -3
- package/src/components/ui/RadarOmnibar.test.tsx +1 -0
- package/src/components/ui/RadarOmnibar.tsx +11 -0
- 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 +18 -4
- package/src/components/whats-new/releaseNotes.ts +136 -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 +6 -4
- package/src/hooks/useAgentSignin.test.tsx +190 -0
- package/src/hooks/useAgentSignin.ts +160 -0
- package/src/hooks/useApproveAfterSignin.test.tsx +108 -0
- package/src/hooks/useElementSize.ts +30 -0
- 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 +12 -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':
|
|
@@ -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={
|
|
@@ -68,7 +71,7 @@ export function tidyFences(md: string): string {
|
|
|
68
71
|
|
|
69
72
|
// Diagnosis output is dense with inline `code`; the shared chip's brand tint is
|
|
70
73
|
// too loud at that density, so neutralize it (border/bg only) for this surface.
|
|
71
|
-
const SOFT_INLINE_CODE =
|
|
74
|
+
export const SOFT_INLINE_CODE =
|
|
72
75
|
"[&_.inline-code]:border-theme-border/60 [&_.inline-code]:bg-theme-base [&_.inline-code]:font-normal";
|
|
73
76
|
|
|
74
77
|
// Markdown for agent-generated text — normalizes flaky fences + softens code.
|
|
@@ -242,8 +242,12 @@ export function TurnView({
|
|
|
242
242
|
onViewEvidence,
|
|
243
243
|
sourceRevealRequest,
|
|
244
244
|
assessmentSources,
|
|
245
|
+
openingQuestion,
|
|
245
246
|
}: {
|
|
246
247
|
turn: Turn;
|
|
248
|
+
/** The question the run opened with, shown as the engineer's message on
|
|
249
|
+
* the opening turn (whose own question is empty by design). */
|
|
250
|
+
openingQuestion?: string;
|
|
247
251
|
agentLabel?: string;
|
|
248
252
|
onApply?: (fix: string) => void;
|
|
249
253
|
onViewExplanation?: () => void;
|
|
@@ -304,6 +308,8 @@ export function TurnView({
|
|
|
304
308
|
: "Plain-language explanation"}
|
|
305
309
|
<span className="text-theme-text-tertiary">· View in Findings</span>
|
|
306
310
|
</button>
|
|
311
|
+
) : openingQuestion ? (
|
|
312
|
+
<QuestionBubble text={openingQuestion} />
|
|
307
313
|
) : (
|
|
308
314
|
turn.question &&
|
|
309
315
|
(turn.verify ? (
|
|
@@ -317,18 +323,7 @@ export function TurnView({
|
|
|
317
323
|
</span>
|
|
318
324
|
</div>
|
|
319
325
|
) : (
|
|
320
|
-
<
|
|
321
|
-
<div className="max-w-[85%]">
|
|
322
|
-
{turn.actor && (
|
|
323
|
-
<div className="mb-0.5 text-right text-[10px] text-theme-text-tertiary">
|
|
324
|
-
{turn.actor}
|
|
325
|
-
</div>
|
|
326
|
-
)}
|
|
327
|
-
<div className="rounded-lg rounded-br-sm bg-accent/10 px-3 py-1.5 text-sm text-theme-text-primary [overflow-wrap:anywhere]">
|
|
328
|
-
{turn.question}
|
|
329
|
-
</div>
|
|
330
|
-
</div>
|
|
331
|
-
</div>
|
|
326
|
+
<QuestionBubble text={turn.question} actor={turn.actor} />
|
|
332
327
|
))
|
|
333
328
|
)}
|
|
334
329
|
<Timeline
|
|
@@ -423,6 +418,23 @@ export function TurnView({
|
|
|
423
418
|
);
|
|
424
419
|
}
|
|
425
420
|
|
|
421
|
+
function QuestionBubble({ text, actor }: { text: string; actor?: string }) {
|
|
422
|
+
return (
|
|
423
|
+
<div className="flex justify-end">
|
|
424
|
+
<div className="max-w-[85%]">
|
|
425
|
+
{actor && (
|
|
426
|
+
<div className="mb-0.5 text-right text-[10px] text-theme-text-tertiary">
|
|
427
|
+
{actor}
|
|
428
|
+
</div>
|
|
429
|
+
)}
|
|
430
|
+
<div className="whitespace-pre-wrap rounded-lg rounded-br-sm bg-accent/10 px-3 py-1.5 text-sm text-theme-text-primary [overflow-wrap:anywhere]">
|
|
431
|
+
{text}
|
|
432
|
+
</div>
|
|
433
|
+
</div>
|
|
434
|
+
</div>
|
|
435
|
+
);
|
|
436
|
+
}
|
|
437
|
+
|
|
426
438
|
export function Timeline({
|
|
427
439
|
items,
|
|
428
440
|
running,
|
|
@@ -1137,10 +1149,18 @@ function ToolResultDialog({
|
|
|
1137
1149
|
};
|
|
1138
1150
|
}, [open, display, language, theme]);
|
|
1139
1151
|
return (
|
|
1140
|
-
<DialogPortal
|
|
1152
|
+
<DialogPortal
|
|
1153
|
+
ariaLabelledBy={titleId}
|
|
1154
|
+
open={open}
|
|
1155
|
+
onClose={onClose}
|
|
1156
|
+
className="w-[min(90vw,820px)]"
|
|
1157
|
+
>
|
|
1141
1158
|
<div className="flex items-center justify-between gap-3 border-b border-theme-border p-3">
|
|
1142
1159
|
<div className="min-w-0">
|
|
1143
|
-
<div
|
|
1160
|
+
<div
|
|
1161
|
+
id={titleId}
|
|
1162
|
+
className="truncate font-mono text-sm text-theme-text-primary"
|
|
1163
|
+
>
|
|
1144
1164
|
{title}
|
|
1145
1165
|
</div>
|
|
1146
1166
|
{truncated && (
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
1
|
+
import { useState, type ReactNode } from "react";
|
|
2
2
|
import { AlertTriangle, Check, ShieldCheck, ChevronDown } from "lucide-react";
|
|
3
3
|
import {
|
|
4
4
|
TRANSITION_MENU,
|
|
@@ -420,11 +420,20 @@ function ConsentCardShell({
|
|
|
420
420
|
approveLabel = "Approve & investigate",
|
|
421
421
|
warning = false,
|
|
422
422
|
error,
|
|
423
|
+
notice,
|
|
424
|
+
approveBusy = false,
|
|
425
|
+
subject,
|
|
423
426
|
onOpenSettings,
|
|
424
427
|
onApprove,
|
|
425
428
|
onCancel,
|
|
426
429
|
}: DiagnoseConsentCopy & {
|
|
427
430
|
warning?: boolean;
|
|
431
|
+
// Something to know before approving, e.g. that the agent isn't signed in.
|
|
432
|
+
// It informs; Approve stays available.
|
|
433
|
+
notice?: ReactNode;
|
|
434
|
+
// Approve was pressed and waits on a check that hasn't answered yet.
|
|
435
|
+
approveBusy?: boolean;
|
|
436
|
+
subject?: ConsentSubject;
|
|
428
437
|
// Why the last approval failed, straight from the server. The card stays up on
|
|
429
438
|
// failure so retrying works in place, which means this is the ONLY chance to
|
|
430
439
|
// say why — a host that records consent above the individual refuses the
|
|
@@ -458,6 +467,18 @@ function ConsentCardShell({
|
|
|
458
467
|
{title}
|
|
459
468
|
</div>
|
|
460
469
|
</div>
|
|
470
|
+
{subject && (
|
|
471
|
+
<div className="mb-3 rounded-md border border-theme-border-subtle bg-theme-surface px-3 py-2">
|
|
472
|
+
<div className="break-words text-sm font-medium text-theme-text-primary">
|
|
473
|
+
{subject.title}
|
|
474
|
+
</div>
|
|
475
|
+
{subject.detail && (
|
|
476
|
+
<div className="mt-0.5 text-xs text-theme-text-tertiary">
|
|
477
|
+
{subject.detail}
|
|
478
|
+
</div>
|
|
479
|
+
)}
|
|
480
|
+
</div>
|
|
481
|
+
)}
|
|
461
482
|
<div className="text-sm leading-relaxed text-theme-text-secondary">
|
|
462
483
|
{body}
|
|
463
484
|
</div>
|
|
@@ -476,6 +497,7 @@ function ConsentCardShell({
|
|
|
476
497
|
{resolvedSettingsLabel}
|
|
477
498
|
</button>
|
|
478
499
|
)}
|
|
500
|
+
{notice}
|
|
479
501
|
{/* Red, not amber: the full-local card is itself amber, so an amber box on
|
|
480
502
|
it reads as another paragraph of body copy. role="alert" because nothing
|
|
481
503
|
else moves on failure — focus stays on Approve, so without it a screen
|
|
@@ -498,9 +520,10 @@ function ConsentCardShell({
|
|
|
498
520
|
</button>
|
|
499
521
|
<button
|
|
500
522
|
onClick={onApprove}
|
|
523
|
+
disabled={approveBusy}
|
|
501
524
|
className="flex-1 rounded-lg btn-brand py-1.5 text-sm"
|
|
502
525
|
>
|
|
503
|
-
{approveLabel}
|
|
526
|
+
{approveBusy ? "Checking sign-in…" : approveLabel}
|
|
504
527
|
</button>
|
|
505
528
|
</div>
|
|
506
529
|
</div>
|
|
@@ -517,12 +540,24 @@ function ConsentCardShell({
|
|
|
517
540
|
// MUST override rather than let Radar assert the local story over its flow.
|
|
518
541
|
// 2. No `copy` — the OSS bring-your-own-local-CLI default, the only tier where
|
|
519
542
|
// "on your machine / no Radar cloud / your account" actually holds.
|
|
543
|
+
// What the consent card is about to investigate: the resource, or the
|
|
544
|
+
// engineer's question and where it starts.
|
|
545
|
+
export interface ConsentSubject {
|
|
546
|
+
title: string;
|
|
547
|
+
detail?: string;
|
|
548
|
+
/** The run starts from a question, not from one resource. */
|
|
549
|
+
question?: boolean;
|
|
550
|
+
}
|
|
551
|
+
|
|
520
552
|
export function ConsentCard({
|
|
521
553
|
agentName,
|
|
522
554
|
agent,
|
|
523
555
|
profile,
|
|
524
556
|
copy,
|
|
525
557
|
error,
|
|
558
|
+
notice,
|
|
559
|
+
approveBusy,
|
|
560
|
+
subject,
|
|
526
561
|
onOpenSettings,
|
|
527
562
|
onApprove,
|
|
528
563
|
onCancel,
|
|
@@ -532,11 +567,23 @@ export function ConsentCard({
|
|
|
532
567
|
profile: ExecutionProfile;
|
|
533
568
|
copy?: DiagnoseConsentCopy;
|
|
534
569
|
error?: string | null;
|
|
570
|
+
notice?: ReactNode;
|
|
571
|
+
approveBusy?: boolean;
|
|
572
|
+
subject?: ConsentSubject;
|
|
535
573
|
onOpenSettings?: () => void;
|
|
536
574
|
onApprove: () => void;
|
|
537
575
|
onCancel: () => void;
|
|
538
576
|
}) {
|
|
539
|
-
const chrome = {
|
|
577
|
+
const chrome = {
|
|
578
|
+
onOpenSettings,
|
|
579
|
+
onApprove,
|
|
580
|
+
onCancel,
|
|
581
|
+
error,
|
|
582
|
+
notice,
|
|
583
|
+
approveBusy,
|
|
584
|
+
subject,
|
|
585
|
+
};
|
|
586
|
+
const about = subject?.question ? "the resources it reads" : "this resource";
|
|
540
587
|
|
|
541
588
|
// Tier 1: a host (e.g. radar-hub-web) supplied its own copy — use it verbatim.
|
|
542
589
|
if (copy) return <ConsentCardShell {...copy} {...chrome} />;
|
|
@@ -562,9 +609,9 @@ export function ConsentCard({
|
|
|
562
609
|
your own {agentName}
|
|
563
610
|
</span>{" "}
|
|
564
611
|
on your machine — no Radar cloud, no API key, no account. Radar sends
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
612
|
+
the spec, recent events, and pod logs of {about} to it (and on to its
|
|
613
|
+
model provider under your account, not to Radar). Transcripts are kept
|
|
614
|
+
in your local Radar history on this machine until cleared.
|
|
568
615
|
{profile === "safeguarded" && (
|
|
569
616
|
<>
|
|
570
617
|
{" "}
|
|
@@ -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,11 +5,12 @@ 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";
|
|
11
12
|
|
|
12
|
-
function CopyButton({ text, label }: { text: string; label: string }) {
|
|
13
|
+
export function CopyButton({ text, label }: { text: string; label: string }) {
|
|
13
14
|
const [copied, setCopied] = useState(false);
|
|
14
15
|
return (
|
|
15
16
|
<button
|
|
@@ -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,98 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
3
|
+
import { AgentSigninNotice } from "./AgentSigninNotice";
|
|
4
|
+
import { ConsentCard } from "./parts";
|
|
5
|
+
|
|
6
|
+
const noop = vi.fn();
|
|
7
|
+
|
|
8
|
+
describe("AgentSigninNotice", () => {
|
|
9
|
+
it("names the agent, the command to run and a re-check", () => {
|
|
10
|
+
const html = renderToStaticMarkup(
|
|
11
|
+
<AgentSigninNotice
|
|
12
|
+
agentName="Claude Code"
|
|
13
|
+
signinCmd="claude auth login"
|
|
14
|
+
rechecking={false}
|
|
15
|
+
onRecheck={noop}
|
|
16
|
+
/>,
|
|
17
|
+
);
|
|
18
|
+
expect(html).toContain("Claude Code isn't signed in");
|
|
19
|
+
expect(html).toContain("claude auth login");
|
|
20
|
+
expect(html).toContain("Copy sign-in command");
|
|
21
|
+
expect(html).toContain("Check again");
|
|
22
|
+
expect(html).not.toContain("Still not signed in");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("shows the re-check in progress", () => {
|
|
26
|
+
const html = renderToStaticMarkup(
|
|
27
|
+
<AgentSigninNotice
|
|
28
|
+
agentName="Codex"
|
|
29
|
+
signinCmd="codex login"
|
|
30
|
+
rechecking
|
|
31
|
+
onRecheck={noop}
|
|
32
|
+
/>,
|
|
33
|
+
);
|
|
34
|
+
expect(html).toContain("Checking…");
|
|
35
|
+
expect(html).toContain("disabled");
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe("ConsentCard sign-in notice", () => {
|
|
40
|
+
it("shows the notice above the actions and keeps Approve available", () => {
|
|
41
|
+
const html = renderToStaticMarkup(
|
|
42
|
+
<ConsentCard
|
|
43
|
+
agentName="Claude Code"
|
|
44
|
+
agent="claude"
|
|
45
|
+
profile="safeguarded"
|
|
46
|
+
notice={
|
|
47
|
+
<AgentSigninNotice
|
|
48
|
+
agentName="Claude Code"
|
|
49
|
+
signinCmd="claude auth login"
|
|
50
|
+
rechecking={false}
|
|
51
|
+
onRecheck={noop}
|
|
52
|
+
/>
|
|
53
|
+
}
|
|
54
|
+
onApprove={noop}
|
|
55
|
+
onCancel={noop}
|
|
56
|
+
/>,
|
|
57
|
+
);
|
|
58
|
+
const notice = html.indexOf("isn't signed in");
|
|
59
|
+
const approve = html.indexOf("Approve & investigate");
|
|
60
|
+
expect(notice).toBeGreaterThan(-1);
|
|
61
|
+
expect(approve).toBeGreaterThan(notice);
|
|
62
|
+
const approveButton = html.slice(html.lastIndexOf("<button", approve), approve);
|
|
63
|
+
expect(approveButton).not.toContain("disabled");
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("says Approve is waiting on the check", () => {
|
|
67
|
+
const html = renderToStaticMarkup(
|
|
68
|
+
<ConsentCard
|
|
69
|
+
agentName="Codex"
|
|
70
|
+
agent="codex"
|
|
71
|
+
profile="safeguarded"
|
|
72
|
+
approveBusy
|
|
73
|
+
onApprove={noop}
|
|
74
|
+
onCancel={noop}
|
|
75
|
+
/>,
|
|
76
|
+
);
|
|
77
|
+
const label = html.indexOf("Checking sign-in…");
|
|
78
|
+
expect(label).toBeGreaterThan(-1);
|
|
79
|
+
expect(html.slice(html.lastIndexOf("<button", label), label)).toContain(
|
|
80
|
+
"disabled",
|
|
81
|
+
);
|
|
82
|
+
expect(html).not.toContain("Approve & investigate");
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("renders as before without a notice (signed in or unknown)", () => {
|
|
86
|
+
const html = renderToStaticMarkup(
|
|
87
|
+
<ConsentCard
|
|
88
|
+
agentName="Claude Code"
|
|
89
|
+
agent="claude"
|
|
90
|
+
profile="safeguarded"
|
|
91
|
+
onApprove={noop}
|
|
92
|
+
onCancel={noop}
|
|
93
|
+
/>,
|
|
94
|
+
);
|
|
95
|
+
expect(html).not.toContain("signed in");
|
|
96
|
+
expect(html).toContain("Approve & investigate");
|
|
97
|
+
});
|
|
98
|
+
});
|