@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
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import { RotateCw } from "lucide-react";
|
|
4
|
+
import { AlertBanner } from "@skyhook-io/k8s-ui";
|
|
5
|
+
import { CopyButton } from "./AgentSetupNotice";
|
|
6
|
+
|
|
7
|
+
// Shown on the consent card when the agent's own status command says it is
|
|
8
|
+
// signed out. It warns rather than blocks: status commands can be wrong (a
|
|
9
|
+
// credential they don't see), so Approve stays available.
|
|
10
|
+
export function AgentSigninNotice({
|
|
11
|
+
agentName,
|
|
12
|
+
signinCmd,
|
|
13
|
+
rechecking,
|
|
14
|
+
onRecheck,
|
|
15
|
+
}: {
|
|
16
|
+
agentName: string;
|
|
17
|
+
signinCmd: string;
|
|
18
|
+
rechecking: boolean;
|
|
19
|
+
onRecheck: () => void;
|
|
20
|
+
}) {
|
|
21
|
+
const [asked, setAsked] = useState(false);
|
|
22
|
+
return (
|
|
23
|
+
<AlertBanner
|
|
24
|
+
variant="warning"
|
|
25
|
+
className="mt-3"
|
|
26
|
+
title={`${agentName} isn't signed in`}
|
|
27
|
+
message={
|
|
28
|
+
<>
|
|
29
|
+
The investigation will fail until it is. Run this in a terminal, then
|
|
30
|
+
check again.
|
|
31
|
+
</>
|
|
32
|
+
}
|
|
33
|
+
action={
|
|
34
|
+
<button
|
|
35
|
+
type="button"
|
|
36
|
+
disabled={rechecking}
|
|
37
|
+
onClick={() => {
|
|
38
|
+
setAsked(true);
|
|
39
|
+
onRecheck();
|
|
40
|
+
}}
|
|
41
|
+
className="inline-flex items-center gap-1 text-xs text-accent hover:underline disabled:opacity-60"
|
|
42
|
+
>
|
|
43
|
+
<RotateCw className={clsx("h-3 w-3", rechecking && "animate-spin")} />
|
|
44
|
+
{rechecking ? "Checking…" : "Check again"}
|
|
45
|
+
</button>
|
|
46
|
+
}
|
|
47
|
+
>
|
|
48
|
+
<div className="mt-2 flex items-center gap-1.5 rounded-md bg-theme-base px-2 py-1.5">
|
|
49
|
+
<code className="min-w-0 flex-1 overflow-x-auto whitespace-nowrap font-mono text-xs text-theme-text-secondary">
|
|
50
|
+
{signinCmd}
|
|
51
|
+
</code>
|
|
52
|
+
<CopyButton text={signinCmd} label="Copy sign-in command" />
|
|
53
|
+
</div>
|
|
54
|
+
{asked && !rechecking && (
|
|
55
|
+
<p role="status" className="mt-1.5 text-xs text-theme-text-secondary">
|
|
56
|
+
Still not signed in.
|
|
57
|
+
</p>
|
|
58
|
+
)}
|
|
59
|
+
</AlertBanner>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
@@ -66,6 +66,28 @@ describe("resolveStoryPlacements", () => {
|
|
|
66
66
|
expect(html).toContain('data-story-lost-support="unlinked"');
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
+
it("names which kind of loss each unrendered citation is", () => {
|
|
70
|
+
const html = renderToStaticMarkup(
|
|
71
|
+
<AnalysisStory
|
|
72
|
+
placements={resolveStoryPlacements(
|
|
73
|
+
"One [[radar:evidence=0]]. Two [[radar:evidence=1]]. Three [[radar:evidence=2]].",
|
|
74
|
+
resolver({ 0: "invalid", 1: "unlinked", 2: "unplaced" }),
|
|
75
|
+
)}
|
|
76
|
+
renderPlacement={() => null}
|
|
77
|
+
onReveal={vi.fn()}
|
|
78
|
+
/>,
|
|
79
|
+
);
|
|
80
|
+
expect(html).toMatch(
|
|
81
|
+
/data-story-lost-support="invalid"[^>]*>.*?unknown citation/,
|
|
82
|
+
);
|
|
83
|
+
expect(html).toMatch(
|
|
84
|
+
/data-story-lost-support="unlinked"[^>]*>.*?unverified/,
|
|
85
|
+
);
|
|
86
|
+
expect(html).toMatch(
|
|
87
|
+
/data-story-lost-support="unplaced"[^>]*>.*?unclear citation/,
|
|
88
|
+
);
|
|
89
|
+
});
|
|
90
|
+
|
|
69
91
|
it("places a card under the paragraph that first mentions it inline, and drops that marker from the sentence", () => {
|
|
70
92
|
const story = resolveStoryPlacements(
|
|
71
93
|
"Envoy boots [[radar:evidence=0]] then hangs on xDS.\n\nLater, see [[radar:evidence=0]] again.",
|
|
@@ -212,7 +212,16 @@ function removeInlineMarker(markdown: string, index: number): string {
|
|
|
212
212
|
return before + after;
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
-
|
|
215
|
+
type NamedLoss = Exclude<StoryPlacementLoss, object>;
|
|
216
|
+
|
|
217
|
+
// The chip names which failure it is; the tooltip says what it means.
|
|
218
|
+
const LOSS_LABEL: Record<NamedLoss, string> = {
|
|
219
|
+
invalid: "unknown citation",
|
|
220
|
+
unlinked: "unverified",
|
|
221
|
+
unplaced: "unclear citation",
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
const LOSS_COPY: Record<NamedLoss, string> = {
|
|
216
225
|
invalid: "The agent cited a result Radar cannot identify.",
|
|
217
226
|
unlinked: "Radar could not verify this citation against its record.",
|
|
218
227
|
unplaced:
|
|
@@ -269,7 +278,7 @@ function LostSupport({
|
|
|
269
278
|
className="h-3 w-3 shrink-0 text-amber-500"
|
|
270
279
|
aria-hidden
|
|
271
280
|
/>
|
|
272
|
-
|
|
281
|
+
{LOSS_LABEL[reason]}
|
|
273
282
|
</span>
|
|
274
283
|
</Tooltip>
|
|
275
284
|
);
|
|
@@ -325,10 +334,13 @@ export function AnalysisStory({
|
|
|
325
334
|
}: {
|
|
326
335
|
/** Resolved once by the host, which also needs it for its own counts. */
|
|
327
336
|
placements: StoryPlacements;
|
|
328
|
-
/**
|
|
337
|
+
/**
|
|
338
|
+
* Renders the card for a placed item: `compact` when the agent placed it
|
|
339
|
+
* compact or it sits in the collapsed preview, `preview` for the latter.
|
|
340
|
+
*/
|
|
329
341
|
renderPlacement: (
|
|
330
342
|
target: StoryPlacementTarget,
|
|
331
|
-
options: { compact: boolean },
|
|
343
|
+
options: { compact: boolean; preview: boolean },
|
|
332
344
|
) => ReactNode;
|
|
333
345
|
onReveal: (target: StoryPlacementTarget) => void;
|
|
334
346
|
/** Opens a cited call's raw result in Activity when Radar renders no card for it. */
|
|
@@ -443,6 +455,7 @@ export function AnalysisStory({
|
|
|
443
455
|
>
|
|
444
456
|
{renderPlacement(resolution.target, {
|
|
445
457
|
compact: compact || segment.compact === true,
|
|
458
|
+
preview: compact,
|
|
446
459
|
})}
|
|
447
460
|
</div>
|
|
448
461
|
);
|
|
@@ -32,6 +32,7 @@ import type { InvestigationHealthSignal } from "./investigationState";
|
|
|
32
32
|
import { Badge } from "@skyhook-io/k8s-ui";
|
|
33
33
|
import { diagnosisHasStoryShape, storyPlainText } from "./investigationStory";
|
|
34
34
|
import { useDisclosureReveal } from "./useDisclosureReveal";
|
|
35
|
+
import { verdictParts } from "./verdictText";
|
|
35
36
|
import { FollowupAnswer } from "./ActivityTurn";
|
|
36
37
|
import { ApplyOutcomeCard } from "./ApplyDialog";
|
|
37
38
|
import {
|
|
@@ -40,7 +41,12 @@ import {
|
|
|
40
41
|
STEP_KIND_LABEL,
|
|
41
42
|
assessmentCopyText,
|
|
42
43
|
} from "./assessmentCopy";
|
|
43
|
-
import {
|
|
44
|
+
import {
|
|
45
|
+
AIMarkdown,
|
|
46
|
+
CopyButton,
|
|
47
|
+
SOFT_INLINE_CODE,
|
|
48
|
+
tidyFences,
|
|
49
|
+
} from "./AIMarkdown";
|
|
44
50
|
import { prettyTool } from "./toolCallLabel";
|
|
45
51
|
|
|
46
52
|
export function ResultCard({
|
|
@@ -278,6 +284,25 @@ const HEALTHY_DEFINITION: Record<
|
|
|
278
284
|
* whenever the agent listed anything, and says so when it listed nothing,
|
|
279
285
|
* because a persuasive story needs its caveats above the fold, not inside it.
|
|
280
286
|
*/
|
|
287
|
+
// A verdict is one sentence of prose with the odd `code` span. Rendering it
|
|
288
|
+
// as full markdown would turn a leading "1." or "#" into a list or heading, so
|
|
289
|
+
// only code spans are rendered, with their contents exactly as written.
|
|
290
|
+
export function VerdictText({ text }: { text: string }) {
|
|
291
|
+
return (
|
|
292
|
+
<>
|
|
293
|
+
{verdictParts(text).map((part, index) =>
|
|
294
|
+
part.code ? (
|
|
295
|
+
<code key={index} className="inline-code">
|
|
296
|
+
{part.text}
|
|
297
|
+
</code>
|
|
298
|
+
) : (
|
|
299
|
+
part.text
|
|
300
|
+
),
|
|
301
|
+
)}
|
|
302
|
+
</>
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
|
|
281
306
|
function AssessmentHeadline({
|
|
282
307
|
diagnosis,
|
|
283
308
|
tone,
|
|
@@ -315,8 +340,11 @@ function AssessmentHeadline({
|
|
|
315
340
|
return (
|
|
316
341
|
<div data-assessment-headline className="space-y-2">
|
|
317
342
|
<div className="flex items-start justify-between gap-2">
|
|
318
|
-
|
|
319
|
-
|
|
343
|
+
{/* The answer is the largest text in the assessment, above its label. */}
|
|
344
|
+
<p
|
|
345
|
+
className={`text-lg font-semibold leading-snug text-theme-text-primary [overflow-wrap:anywhere] [text-wrap:pretty] ${SOFT_INLINE_CODE}`}
|
|
346
|
+
>
|
|
347
|
+
<VerdictText text={summary} />
|
|
320
348
|
</p>
|
|
321
349
|
<CopyButton
|
|
322
350
|
text={assessmentCopyText(diagnosis, {
|
|
@@ -1076,7 +1104,13 @@ function DiagnosisResult({
|
|
|
1076
1104
|
data-step-precondition
|
|
1077
1105
|
className="mb-1.5 text-[13px] leading-snug text-warning-text"
|
|
1078
1106
|
>
|
|
1079
|
-
Only if
|
|
1107
|
+
{/* The agent writes a full sentence; after "Only if" its first
|
|
1108
|
+
capital drops when it is an ordinary word ("You"), never
|
|
1109
|
+
for a name with more capitals (API, ConfigMap). */}
|
|
1110
|
+
Only if{" "}
|
|
1111
|
+
{step.precondition
|
|
1112
|
+
.replace(/^(if|when|once)\s+/i, "")
|
|
1113
|
+
.replace(/^[A-Z](?=[a-z]+\b)/, (c) => c.toLowerCase())}
|
|
1080
1114
|
</p>
|
|
1081
1115
|
) : null}
|
|
1082
1116
|
{isRec && diagnosis.recommendedReason && (
|
|
@@ -1567,10 +1601,7 @@ export function InconclusiveCard({
|
|
|
1567
1601
|
</div>
|
|
1568
1602
|
<div className="flex items-start gap-1 px-0.5 text-[11px] text-theme-text-tertiary">
|
|
1569
1603
|
<ShieldCheck className="mt-0.5 h-3 w-3 shrink-0" />
|
|
1570
|
-
<span>
|
|
1571
|
-
Try a follow-up with more context, or investigate again after
|
|
1572
|
-
addressing any errors shown in Activity.
|
|
1573
|
-
</span>
|
|
1604
|
+
<span>Try a follow-up with more context, or investigate again.</span>
|
|
1574
1605
|
</div>
|
|
1575
1606
|
<AssessmentDetails
|
|
1576
1607
|
diagnosis={diagnosis}
|
|
@@ -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
|
+
});
|