@skyhook-io/radar-app 1.19.0 → 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 +5 -5
- package/src/App.tsx +31 -5
- 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.ts +4 -0
- package/src/api/radarFeatures.render.test.tsx +33 -1
- package/src/api/radarFeatures.test.ts +47 -0
- package/src/api/radarFeatures.ts +40 -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 +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 +9 -1
- package/src/components/diagnose/investigationEvidence/adapters/applicationFindings.test.ts +739 -0
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +50 -2
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +9 -0
- 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/home/ClusterHealthCard.tsx +1 -1
- package/src/components/home/HomeAgentBlock.test.tsx +31 -3
- package/src/components/home/HomeAgentBlock.tsx +13 -4
- package/src/components/home/HomeDiagramCard.tsx +47 -0
- package/src/components/home/HomeView.tsx +81 -41
- 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/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/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 +6 -4
- 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
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
type QuestionSuggestion,
|
|
33
33
|
} from "./questionSuggestions";
|
|
34
34
|
import { ResourcePicker } from "./ResourcePicker";
|
|
35
|
+
import { ExampleInvestigationLink } from "./ExampleInvestigationLink";
|
|
35
36
|
import { Tooltip } from "../ui/Tooltip";
|
|
36
37
|
import { formatInvestigationTarget } from "./target";
|
|
37
38
|
|
|
@@ -51,8 +52,10 @@ const actionClass =
|
|
|
51
52
|
|
|
52
53
|
export function QuestionComposer({
|
|
53
54
|
onBrowseIssues,
|
|
55
|
+
onOpenExample,
|
|
54
56
|
}: {
|
|
55
57
|
onBrowseIssues?: () => void;
|
|
58
|
+
onOpenExample?: () => void;
|
|
56
59
|
}) {
|
|
57
60
|
const { openInvestigation, agentLabel, questionDraft, saveQuestionDraft } =
|
|
58
61
|
useDiagnose();
|
|
@@ -482,6 +485,11 @@ export function QuestionComposer({
|
|
|
482
485
|
<ArrowRight className="h-3 w-3" />
|
|
483
486
|
</button>
|
|
484
487
|
)}
|
|
488
|
+
{onOpenExample && (
|
|
489
|
+
<div className="mt-3">
|
|
490
|
+
<ExampleInvestigationLink onOpen={onOpenExample} />
|
|
491
|
+
</div>
|
|
492
|
+
)}
|
|
485
493
|
</section>
|
|
486
494
|
);
|
|
487
495
|
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"type": "turn"
|
|
4
|
+
},
|
|
5
|
+
{
|
|
6
|
+
"type": "phase",
|
|
7
|
+
"phase": "investigating"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"type": "phase",
|
|
11
|
+
"phase": "connected"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"type": "phase",
|
|
15
|
+
"phase": "ready",
|
|
16
|
+
"model": "claude-opus-5-5",
|
|
17
|
+
"toolCount": 25,
|
|
18
|
+
"mcpServers": [
|
|
19
|
+
{
|
|
20
|
+
"name": "radar",
|
|
21
|
+
"status": "connected"
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"type": "thinking",
|
|
27
|
+
"token": "I'll start with Radar's diagnose bundle for the Deployment."
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"type": "step",
|
|
31
|
+
"step": {
|
|
32
|
+
"id": "toolu_sample_diagnose_deployment",
|
|
33
|
+
"tool": "diagnose",
|
|
34
|
+
"status": "running",
|
|
35
|
+
"summary": "{\"kind\":\"deployment\",\"namespace\":\"guestbook\",\"name\":\"guestbook-ui\",\"group\":\"apps\"}"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"type": "step",
|
|
40
|
+
"step": {
|
|
41
|
+
"id": "toolu_sample_diagnose_deployment",
|
|
42
|
+
"tool": "",
|
|
43
|
+
"status": "done",
|
|
44
|
+
"ms": 3062,
|
|
45
|
+
"result": "{\"resource\":{\"apiVersion\":\"apps/v1\",\"kind\":\"Deployment\",\"metadata\":{\"annotations\":{\"argocd.argoproj.io/tracking-id\":\"guestbook:apps/Deployment:guestbook/guestbook-ui\",\"deployment.kubernetes.io/revision\":\"4\"},\"creationTimestamp\":\"2026-10-08T10:06:19Z\",\"generation\":4,\"name\":\"guestbook-ui\",\"namespace\":\"guestbook\"},\"spec\":{\"progressDeadlineSeconds\":600,\"replicas\":1,\"revisionHistoryLimit\":3,\"selector\":{\"matchLabels\":{\"app\":\"guestbook-ui\"}},\"strategy\":{\"rollingUpdate\":{\"maxSurge\":\"25%\",\"maxUnavailable\":\"25%\"},\"type\":\"RollingUpdate\"},\"template\":{\"metadata\":{\"labels\":{\"app\":\"guestbook-ui\"}},\"spec\":{\"containers\":[{\"image\":\"gcr.io/google-samples/gb-frontend:v99-missing\",\"name\":\"guestbook-ui\",\"ports\":[{\"containerPort\":80,\"protocol\":\"TCP\"}],\"resources\":{}}],\"restartPolicy\":\"Always\",\"securityContext\":{},\"terminationGracePeriodSeconds\":30}}},\"status\":{\"availableReplicas\":1,\"conditions\":[{\"lastTransitionTime\":\"2026-10-08T10:06:34Z\",\"lastUpdateTime\":\"2026-10-08T10:06:34Z\",\"message\":\"Deployment has minimum availability.\",\"reason\":\"MinimumReplicasAvailable\",\"status\":\"True\",\"type\":\"Available\"},{\"lastTransitionTime\":\"2026-10-08T10:06:20Z\",\"lastUpdateTime\":\"2026-10-08T10:44:55Z\",\"message\":\"ReplicaSet \\\"guestbook-ui-5c4d9dcb47\\\" is progressing.\",\"reason\":\"ReplicaSetUpdated\",\"status\":\"True\",\"type\":\"Progressing\"}],\"readyReplicas\":1,\"replicas\":2,\"unavailableReplicas\":1,\"updatedReplicas\":1}},\"resourceContext\":{\"tier\":\"diagnostic\",\"managedBy\":[{\"kind\":\"Application\",\"group\":\"argoproj.io\",\"name\":\"guestbook\"}],\"exposes\":[{\"kind\":\"Service\",\"namespace\":\"guestbook\",\"name\":\"guestbook-ui\"}],\"statusSummary\":{\"conditions\":[{\"type\":\"Available\",\"status\":\"True\",\"reason\":\"MinimumReplicasAvailable\",\"message\":\"Deployment has minimum availability.\",\"lastTransitionTime\":\"2026-10-08T10:06:34Z\"},{\"type\":\"Progressing\",\"status\":\"True\",\"reason\":\"ReplicaSetUpdated\",\"message\":\"ReplicaSet \\\"guestbook-ui-5c4d9dcb47\\\" is progressing.\",\"lastTransitionTime\":\"2026-10-08T10:06:20Z\"}]},\"workloadSummary\":{\"replicas\":{\"desired\":1,\"ready\":1,\"available\":1,\"updated\":1,\"unavailable\":1}},\"issueSummary\":{\"count\":1,\"highestSeverity\":\"critical\",\"topReason\":\"ImagePullBackOff\",\"bySource\":{\"problem\":1}},\"auditSummary\":{\"count\":11,\"highestSeverity\":\"high\",\"topFinding\":\"privilegeEscalation\"}},\"logsCurrent\":[{\"pod\":\"guestbook-ui-5c4d9dcb47-nqnfz\",\"container\":\"guestbook-ui\",\"logs\":{\"lines\":null,\"totalLines\":0,\"matchedLines\":0,\"fallback\":false},\"error\":\"failed to get logs: container \\\"guestbook-ui\\\" in pod \\\"guestbook-ui-5c4d9dcb47-nqnfz\\\" is waiting to start: trying and failing to pull image\"},{\"pod\":\"guestbook-ui-84774bdc6f-kkx5q\",\"container\":\"guestbook-ui\",\"logs\":{\"lines\":[\"2026-10-08T10:06:34.086788508Z AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 10.0.0.12. Set the 'ServerName' directive globally to suppress this message (repeated ×2, 10:06:34→10:06:34)\",\"2026-10-08T10:06:34.115729612Z [Thu Oct 08 10:06:34.115588 2026] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.4.33 configured -- resuming normal operations\",\"2026-10-08T10:06:34.115746184Z [Thu Oct 08 10:06:34.115696 2026] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'\"],\"totalLines\":4,\"matchedLines\":0,\"fallback\":true}}],\"logsPrevious\":[{\"pod\":\"guestbook-ui-5c4d9dcb47-nqnfz\",\"container\":\"guestbook-ui\",\"logs\":{\"lines\":null,\"totalLines\":0,\"matchedLines\":0,\"fallback\":false},\"error\":\"failed to get logs: previous terminated container \\\"guestbook-ui\\\" in pod \\\"guestbook-ui-5c4d9dcb47-nqnfz\\\" not found\"},{\"pod\":\"guestbook-ui-84774bdc6f-kkx5q\",\"container\":\"guestbook-ui\",\"logs\":{\"lines\":null,\"totalLines\":0,\"matchedLines\":0,\"fallback\":false},\"error\":\"failed to get logs: previous terminated container \\\"guestbook-ui\\\" in pod \\\"guestbook-ui-84774bdc6f-kkx5q\\\" not found\"}],\"events\":[{\"reason\":\"Failed\",\"message\":\"Error: ErrImagePull\",\"type\":\"Warning\",\"count\":3,\"lastTimestamp\":\"2026-10-08T10:45:36Z\"},{\"reason\":\"Failed\",\"message\":\"Failed to pull image \\\"gcr.io/google-samples/gb-frontend:v99-missing\\\": rpc error: code = NotFound desc = failed to pull and unpack image \\\"gcr.io/google-samples/gb-frontend:v99-missing\\\": failed to resolve reference \\\"gcr.io/google-samples/gb-frontend:v99-missing\\\": gcr.io/google-samples/gb-frontend:v99-missing: not found\",\"type\":\"Warning\",\"count\":3,\"lastTimestamp\":\"2026-10-08T10:45:36Z\"},{\"reason\":\"Failed\",\"message\":\"Error: ImagePullBackOff\",\"type\":\"Warning\",\"count\":2,\"lastTimestamp\":\"2026-10-08T10:45:24Z\"}],\"eventsTotalGroups\":3,\"logCoverage\":{\"resolvedPods\":2,\"selectedPods\":2,\"shownLines\":3,\"totalLines\":3,\"shownPods\":1,\"totalPods\":1},\"expectedPreviousLogAbsences\":[{\"pod\":\"guestbook-ui-5c4d9dcb47-nqnfz\",\"container\":\"guestbook-ui\"},{\"pod\":\"guestbook-ui-84774bdc6f-kkx5q\",\"container\":\"guestbook-ui\"}],\"relatedIssues\":[{\"severity\":\"critical\",\"source\":\"problem\",\"category\":\"image_pull_failed\",\"category_group\":\"startup\",\"id\":\"sampleissue0001\",\"grouping_scope\":\"workload\",\"kind\":\"Deployment\",\"group\":\"apps\",\"namespace\":\"guestbook\",\"name\":\"guestbook-ui\",\"reason\":\"ImagePullBackOff\",\"message\":\"Back-off pulling image \\\"gcr.io/google-samples/gb-frontend:v99-missing\\\": ErrImagePull: rpc error: code = NotFound desc = failed to pull and unpack image \\\"gcr.io/google-samples/gb-frontend:v99-missing\\\": failed to resolve reference \\\"gcr.io/google-samples/gb-frontend:v99-missing\\\": gcr.io/google-samples/gb-frontend:v99-missing: not found\",\"cause\":\"Image not found: gcr.io/google-samples/gb-frontend:v99-missing\",\"action\":\"Verify the repository and tag, then update the image reference or publish the missing image.\",\"onset_unknown\":true,\"resource_created_at\":\"2026-10-08T10:44:55Z\",\"last_seen\":\"2026-10-08T10:45:42.822028Z\",\"count\":1,\"affected\":{\"pods\":1},\"members\":[{\"kind\":\"Pod\",\"namespace\":\"guestbook\",\"name\":\"guestbook-ui-5c4d9dcb47-nqnfz\"}],\"diagnostic_context\":{\"role\":\"rollup\",\"facts\":[{\"type\":\"owner_rollup\",\"message\":\"Grouped from 1 affected resource(s) under this Deployment.\",\"refs\":[{\"kind\":\"Pod\",\"namespace\":\"guestbook\",\"name\":\"guestbook-ui-5c4d9dcb47-nqnfz\"}]}]},\"change_context\":{\"changed\":true,\"what\":\"pod_template\",\"when\":\"47s\",\"evidence\":\"generation=4, observedGeneration=4, 3 owned ReplicaSets, newest ReplicaSet guestbook-ui-5c4d9dcb47 created 47s ago\"},\"issue_timing\":\"started_after_resource_was_healthy\",\"issue_timing_basis\":\"pod_creation\"}],\"changeContext\":{\"changed\":true,\"what\":\"pod_template\",\"when\":\"48s\",\"evidence\":\"generation=4, observedGeneration=4, 3 owned ReplicaSets, newest ReplicaSet guestbook-ui-5c4d9dcb47 created 48s ago\"},\"recentChanges\":[{\"kind\":\"Deployment\",\"apiVersion\":\"apps/v1\",\"namespace\":\"guestbook\",\"name\":\"guestbook-ui\",\"changeType\":\"update\",\"summary\":\"image(guestbook-ui): gcr.io/google-samples/gb-frontend:v5→...:v99-missing\",\"timestamp\":\"2026-10-08T10:44:55Z\",\"change_category\":\"spec_config\",\"rank_reason\":\"application configuration field changed\",\"application_configuration_change\":true,\"fields\":[{\"path\":\"spec.template.spec.containers[guestbook-ui].image\",\"oldValue\":\"gcr.io/google-samples/gb-frontend:v5\",\"newValue\":\"gcr.io/google-samples/gb-frontend:v99-missing\"}]},{\"kind\":\"Deployment\",\"apiVersion\":\"apps/v1\",\"namespace\":\"guestbook\",\"name\":\"guestbook-ui\",\"changeType\":\"update\",\"summary\":\"image(guestbook-ui): gcr.io/google-samples/gb-frontend:v4→gcr.io/google-samples/gb-frontend:v5\",\"timestamp\":\"2026-10-08T10:37:33Z\",\"change_category\":\"spec_config\",\"rank_reason\":\"application configuration field changed\",\"application_configuration_change\":true,\"fields\":[{\"path\":\"spec.template.spec.containers[guestbook-ui].image\",\"oldValue\":\"gcr.io/google-samples/gb-frontend:v4\",\"newValue\":\"gcr.io/google-samples/gb-frontend:v5\"}]},{\"kind\":\"Deployment\",\"apiVersion\":\"apps/v1\",\"namespace\":\"guestbook\",\"name\":\"guestbook-ui\",\"changeType\":\"update\",\"summary\":\"image(guestbook-ui): gcr.io/google-samples/gb-frontend:v5→gcr.io/google-samples/gb-frontend:v4\",\"timestamp\":\"2026-10-08T10:31:46Z\",\"change_category\":\"spec_config\",\"rank_reason\":\"application configuration field changed\",\"application_configuration_change\":true,\"fields\":[{\"path\":\"spec.template.spec.containers[guestbook-ui].image\",\"oldValue\":\"gcr.io/google-samples/gb-frontend:v5\",\"newValue\":\"gcr.io/google-samples/gb-frontend:v4\"}]}],\"recentChangesSaturated\":true,\"pods\":2,\"podNames\":[\"guestbook-ui-5c4d9dcb47-nqnfz\",\"guestbook-ui-84774bdc6f-kkx5q\"],\"warnings\":[\"Resource is reconciled by Argo CD (instance: guestbook:apps/Deployment:guestbook/guestbook-ui). Direct edits may be reverted by the next reconciliation; prefer changing the source of truth (chart values / Application spec / operator CR).\"],\"metrics\":{\"window\":{\"start\":\"2026-10-08T09:45:42Z\",\"end\":\"2026-10-08T10:45:42Z\",\"step\":\"0s\"},\"pods\":2,\"series\":[],\"error\":\"prometheus probe did not answer within 3s\"}}",
|
|
46
|
+
"evidenceRef": "ev_sampleinvestigationaaaaaaa_deploymentdiagnosebundleaa",
|
|
47
|
+
"radarEvidence": true,
|
|
48
|
+
"isError": false
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"type": "thinking",
|
|
53
|
+
"token": "I've identified the likely cause, but need to confirm whether the bad tag originated from Git or a direct live edit Argo isn't correcting. I'll check the Argo CD Application's sync status next.\n\n"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"type": "step",
|
|
57
|
+
"step": {
|
|
58
|
+
"id": "toolu_sample_diagnose_application",
|
|
59
|
+
"tool": "diagnose",
|
|
60
|
+
"status": "running",
|
|
61
|
+
"summary": "{\"kind\":\"application\",\"namespace\":\"argocd\",\"name\":\"guestbook\",\"group\":\"argoproj.io\"}"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"type": "step",
|
|
66
|
+
"step": {
|
|
67
|
+
"id": "toolu_sample_diagnose_application",
|
|
68
|
+
"tool": "",
|
|
69
|
+
"status": "done",
|
|
70
|
+
"ms": 13,
|
|
71
|
+
"result": "{\"resource\":{\"apiVersion\":\"argoproj.io/v1alpha1\",\"kind\":\"Application\",\"metadata\":{\"creationTimestamp\":\"2026-10-08T10:06:16Z\",\"generation\":33,\"name\":\"guestbook\",\"namespace\":\"argocd\"},\"spec\":{\"destination\":{\"namespace\":\"guestbook\",\"server\":\"https://kubernetes.default.svc\"},\"project\":\"default\",\"source\":{\"path\":\"guestbook\",\"repoURL\":\"https://github.com/argoproj/argocd-example-apps\",\"targetRevision\":\"HEAD\"},\"syncPolicy\":{\"automated\":{\"prune\":true,\"selfHeal\":false}}},\"status\":{\"controllerNamespace\":\"argocd\",\"health\":{\"lastTransitionTime\":\"2026-10-08T10:44:55Z\",\"status\":\"Progressing\"},\"history\":[{\"deployStartedAt\":\"2026-10-08T10:06:18Z\",\"deployedAt\":\"2026-10-08T10:06:20Z\",\"id\":0,\"initiatedBy\":{\"automated\":true},\"revision\":\"8088f4c0d970abb09e250248cc97e35623447cb5\",\"source\":{\"path\":\"guestbook\",\"repoURL\":\"https://github.com/argoproj/argocd-example-apps\",\"targetRevision\":\"HEAD\"}},{\"deployStartedAt\":\"2026-10-08T10:37:24Z\",\"deployedAt\":\"2026-10-08T10:37:33Z\",\"id\":1,\"initiatedBy\":{\"username\":\"radar\"},\"revision\":\"8088f4c0d970abb09e250248cc97e35623447cb5\",\"source\":{\"path\":\"guestbook\",\"repoURL\":\"https://github.com/argoproj/argocd-example-apps\",\"targetRevision\":\"HEAD\"}}],\"operationState\":{\"finishedAt\":\"2026-10-08T10:37:33Z\",\"message\":\"successfully synced (all tasks run)\",\"operation\":{\"initiatedBy\":{\"automated\":true,\"username\":\"radar\"},\"retry\":{\"limit\":5},\"sync\":{\"prune\":true,\"revision\":\"8088f4c0d970abb09e250248cc97e35623447cb5\",\"source\":{\"path\":\"guestbook\",\"repoURL\":\"https://github.com/argoproj/argocd-example-apps\",\"targetRevision\":\"HEAD\"}}},\"phase\":\"Succeeded\",\"startedAt\":\"2026-10-08T10:37:24Z\",\"syncResult\":{\"resources\":[{\"group\":\"\",\"hookPhase\":\"Running\",\"kind\":\"Service\",\"message\":\"service/guestbook-ui unchanged\",\"name\":\"guestbook-ui\",\"namespace\":\"guestbook\",\"status\":\"Synced\",\"syncPhase\":\"Sync\",\"version\":\"v1\"},{\"group\":\"apps\",\"hookPhase\":\"Running\",\"images\":[\"gcr.io/google-samples/gb-frontend:v5\"],\"kind\":\"Deployment\",\"message\":\"deployment.apps/guestbook-ui configured\",\"name\":\"guestbook-ui\",\"namespace\":\"guestbook\",\"status\":\"Synced\",\"syncPhase\":\"Sync\",\"version\":\"v1\"}],\"revision\":\"8088f4c0d970abb09e250248cc97e35623447cb5\",\"source\":{\"path\":\"guestbook\",\"repoURL\":\"https://github.com/argoproj/argocd-example-apps\",\"targetRevision\":\"HEAD\"}}},\"reconciledAt\":\"2026-10-08T10:44:55Z\",\"resourceHealthSource\":\"appTree\",\"resources\":[{\"kind\":\"Service\",\"name\":\"guestbook-ui\",\"namespace\":\"guestbook\",\"status\":\"Synced\",\"version\":\"v1\"},{\"group\":\"apps\",\"kind\":\"Deployment\",\"name\":\"guestbook-ui\",\"namespace\":\"guestbook\",\"status\":\"OutOfSync\",\"version\":\"v1\"}],\"sourceHydrator\":{},\"sourceType\":\"Directory\",\"summary\":{\"images\":[\"gcr.io/google-samples/gb-frontend:v5\",\"gcr.io/google-samples/gb-frontend:v99-missing\"]},\"sync\":{\"comparedTo\":{\"destination\":{\"namespace\":\"guestbook\",\"server\":\"https://kubernetes.default.svc\"},\"source\":{\"path\":\"guestbook\",\"repoURL\":\"https://github.com/argoproj/argocd-example-apps\",\"targetRevision\":\"HEAD\"}},\"revision\":\"8088f4c0d970abb09e250248cc97e35623447cb5\",\"status\":\"OutOfSync\"}}},\"pods\":0,\"gitopsDiagnosis\":{\"tool\":\"argocd\",\"sync\":\"OutOfSync\",\"health\":\"Progressing\",\"operationPhase\":\"Succeeded\"}}",
|
|
72
|
+
"evidenceRef": "ev_sampleinvestigationaaaaaaa_applicationdiagnosebundlea",
|
|
73
|
+
"radarEvidence": true,
|
|
74
|
+
"isError": false
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"type": "done",
|
|
79
|
+
"diagnosis": {
|
|
80
|
+
"rootCause": "At 10:44:55Z the live Deployment's image was changed from `gcr.io/google-samples/gb-frontend:v5` to `:v99-missing`, a tag that does not exist in the registry, so the new pod fails with ErrImagePull / NotFound. The change did not come from Git: Argo CD reports the Deployment OutOfSync against revision `8088f4c`, which deploys `v5`. Because self-heal is off, Argo will not undo the edit.",
|
|
81
|
+
"summary": "A direct edit set guestbook-ui to a nonexistent image tag; the new pod can't start and the rollout is stuck on the old pod.",
|
|
82
|
+
"certainty": "established",
|
|
83
|
+
"steps": [
|
|
84
|
+
{
|
|
85
|
+
"text": "Re-sync the Deployment from Git to restore the `v5` image: `argocd app sync guestbook --resource apps:Deployment:guestbook-ui` (or use **Sync** on the Deployment in the Argo CD UI).",
|
|
86
|
+
"kind": "mitigate"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"text": "Confirm the rollout finishes and Argo reports Synced: `kubectl -n guestbook rollout status deploy/guestbook-ui` then `argocd app get guestbook`.",
|
|
90
|
+
"kind": "verify"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"text": "If a new version was meant to ship, publish the image, check that it exists with `crane ls gcr.io/google-samples/gb-frontend`, and change the tag in Git (`guestbook/` in argocd-example-apps), not on the live object.",
|
|
94
|
+
"kind": "investigate",
|
|
95
|
+
"precondition": "Someone intended to deploy a version other than v5"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"text": "Find who made the edit at 10:44:55Z in the API server audit log (filter by verb `update`/`patch` on `deployments/guestbook-ui` in `guestbook`).",
|
|
99
|
+
"kind": "investigate"
|
|
100
|
+
}
|
|
101
|
+
],
|
|
102
|
+
"report": "A change to the live Deployment caused this, not a change in Git. At 10:44:55Z the container image was changed from `gb-frontend:v5` to `gb-frontend:v99-missing`. The Deployment started a new pod with that tag, and the registry says the tag doesn't exist.\n\n[[radar:evidence=0]]\n\n[[radar:evidence=1|compact]]\n\nArgo CD manages this Deployment, and its view settles where the edit came from. Its last sync used Git revision `8088f4c` with image `v5`. It now marks the Deployment **OutOfSync**, which means the live object no longer matches Git. Self-heal is turned off for this Application, so Argo won't overwrite the edit by itself. The rollout will stay stuck until someone acts.\n\n[[radar:evidence=2]]\n\nThe service is not down right now. A rolling update only removes the old pod once the new one is ready, so the previous pod is still serving and the Deployment reports 1 of 1 available. I didn't check which tag that old pod runs, and with Prometheus unreachable there are no traffic metrics. With one serving pod there is no redundancy, so if that pod is lost the service has no replacement.\n\nThe fix is to re-sync the Deployment from Git, which brings back `v5`. If whoever made the edit was trying to release a new version, the right path is to publish the image and change the tag in Git. Editing the live object again would just drift from Git again. Nothing I found leaves the cause in doubt. The open item is who made the edit, and only the API server audit log can show that.",
|
|
103
|
+
"notes": "**Evidence ledger**\n- `ev_…deployment…` (diagnose, Deployment): the live pod template uses `gcr.io/google-samples/gb-frontend:v99-missing`. The new pod `guestbook-ui-5c4d9dcb47-nqnfz` is stuck because the registry answered `NotFound` for that tag (3 ErrImagePull events). The change feed shows the image went from `v5` to `v99-missing` at 10:44:55Z. The old pod `guestbook-ui-84774bdc6f-kkx5q` is still Ready, so the Deployment has 1 of 1 available. Not covered: which image the old pod runs, and who made the edit. Metrics were unavailable because Prometheus timed out.\n- `ev_…application…` (diagnose, Application guestbook): Git revision `8088f4c` was last synced at 10:37:33Z with image `v5`. The live Deployment is now **OutOfSync**, and `selfHeal: false`. Not covered: the identity of whoever changed the live object.\n- Alternative: Git changed to the bad tag. Contradicted by `ev_…application…`. The synced revision still deploys `v5`, and the live Deployment differs from Git.\n- Alternative: a registry auth or network problem. Contradicted by `ev_…deployment…`. The registry resolved the request and answered `NotFound` for the tag, which is not an auth or connection error.\n- Alternative: the app crashes after starting. Contradicted by `ev_…deployment…`. The new container never started; it is still waiting for its image to pull.",
|
|
104
|
+
"rootCauseEvidence": {
|
|
105
|
+
"status": "linked",
|
|
106
|
+
"refs": [
|
|
107
|
+
"ev_sampleinvestigationaaaaaaa_deploymentdiagnosebundleaa",
|
|
108
|
+
"ev_sampleinvestigationaaaaaaa_applicationdiagnosebundlea"
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
"evidence": [
|
|
112
|
+
{
|
|
113
|
+
"status": "linked",
|
|
114
|
+
"ref": "ev_sampleinvestigationaaaaaaa_deploymentdiagnosebundleaa",
|
|
115
|
+
"role": "cause",
|
|
116
|
+
"claim": "The pod template image was changed from v5 to v99-missing at 10:44:55Z.",
|
|
117
|
+
"gap": "change feed shows what changed, not who changed it",
|
|
118
|
+
"subject": {
|
|
119
|
+
"group": "apps",
|
|
120
|
+
"kind": "Deployment",
|
|
121
|
+
"namespace": "guestbook",
|
|
122
|
+
"name": "guestbook-ui",
|
|
123
|
+
"observation": "changes"
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"status": "linked",
|
|
128
|
+
"ref": "ev_sampleinvestigationaaaaaaa_deploymentdiagnosebundleaa",
|
|
129
|
+
"role": "symptom",
|
|
130
|
+
"claim": "The registry returns NotFound for gb-frontend:v99-missing, so the new pod's image pull fails.",
|
|
131
|
+
"gap": "events for the new pod only, sampled at this check",
|
|
132
|
+
"subject": {
|
|
133
|
+
"group": "",
|
|
134
|
+
"kind": "Pod",
|
|
135
|
+
"namespace": "guestbook",
|
|
136
|
+
"name": "guestbook-ui-5c4d9dcb47-nqnfz",
|
|
137
|
+
"observation": "events"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"status": "linked",
|
|
142
|
+
"ref": "ev_sampleinvestigationaaaaaaa_applicationdiagnosebundlea",
|
|
143
|
+
"role": "cause",
|
|
144
|
+
"claim": "Argo CD's synced Git revision deploys v5, the live Deployment is OutOfSync, and selfHeal is false, so the edit was made outside Git and nothing reverts it.",
|
|
145
|
+
"gap": "does not identify who edited the live object",
|
|
146
|
+
"subject": {
|
|
147
|
+
"group": "argoproj.io",
|
|
148
|
+
"kind": "Application",
|
|
149
|
+
"namespace": "argocd",
|
|
150
|
+
"name": "guestbook",
|
|
151
|
+
"observation": "resource"
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"status": "linked",
|
|
156
|
+
"ref": "ev_sampleinvestigationaaaaaaa_deploymentdiagnosebundleaa",
|
|
157
|
+
"role": "context",
|
|
158
|
+
"claim": "The previous pod is still Ready and the Deployment reports 1/1 available, so the service is up on one older pod.",
|
|
159
|
+
"gap": "does not show which image tag the old pod runs, and has no traffic metrics",
|
|
160
|
+
"subject": {
|
|
161
|
+
"group": "",
|
|
162
|
+
"kind": "Pod",
|
|
163
|
+
"namespace": "guestbook",
|
|
164
|
+
"name": "guestbook-ui-84774bdc6f-kkx5q",
|
|
165
|
+
"observation": "logs"
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
],
|
|
169
|
+
"ruledOut": [
|
|
170
|
+
{
|
|
171
|
+
"hypothesis": "The bad tag came from a Git commit synced by Argo CD",
|
|
172
|
+
"evidenceIndex": 2
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"hypothesis": "Registry authentication or network failure",
|
|
176
|
+
"evidenceIndex": 1
|
|
177
|
+
}
|
|
178
|
+
],
|
|
179
|
+
"remediation": [
|
|
180
|
+
"Re-sync the Deployment from Git to restore the `v5` image: `argocd app sync guestbook --resource apps:Deployment:guestbook-ui` (or use **Sync** on the Deployment in the Argo CD UI).",
|
|
181
|
+
"Confirm the rollout finishes and Argo reports Synced: `kubectl -n guestbook rollout status deploy/guestbook-ui` then `argocd app get guestbook`.",
|
|
182
|
+
"If a new version was meant to ship, publish the image, check that it exists with `crane ls gcr.io/google-samples/gb-frontend`, and change the tag in Git (`guestbook/` in argocd-example-apps), not on the live object.",
|
|
183
|
+
"Find who made the edit at 10:44:55Z in the API server audit log (filter by verb `update`/`patch` on `deployments/guestbook-ui` in `guestbook`)."
|
|
184
|
+
],
|
|
185
|
+
"confidence": 0.95,
|
|
186
|
+
"recommendedIndex": 1,
|
|
187
|
+
"recommendedReason": "Targeted to one resource and reversible; it restores the Git-declared v5, which may not be the version whoever made the edit was trying to ship.",
|
|
188
|
+
"turns": 3
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
]
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act, type ReactNode } from "react";
|
|
3
|
+
import { createRoot, type Root } from "react-dom/client";
|
|
4
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
5
|
+
import { MemoryRouter } from "react-router-dom";
|
|
6
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
7
|
+
|
|
8
|
+
import type { SubscribeHandlers } from "../../api/diagnose";
|
|
9
|
+
import { EXAMPLE_INVESTIGATION_RUN } from "./exampleInvestigation";
|
|
10
|
+
import { InvestigationView } from "./InvestigationView";
|
|
11
|
+
|
|
12
|
+
const openInvestigation = vi.fn();
|
|
13
|
+
vi.mock("./exampleInvestigation", async (importOriginal) => ({
|
|
14
|
+
...(await importOriginal<typeof import("./exampleInvestigation")>()),
|
|
15
|
+
// The transcript chunk failed to load.
|
|
16
|
+
replayExampleInvestigation: (handlers: SubscribeHandlers) => {
|
|
17
|
+
queueMicrotask(() => handlers.onClosed?.("unavailable"));
|
|
18
|
+
return () => {};
|
|
19
|
+
},
|
|
20
|
+
}));
|
|
21
|
+
vi.mock("./DiagnoseContext", () => ({
|
|
22
|
+
useDiagnose: () => ({
|
|
23
|
+
refreshRuns: vi.fn(),
|
|
24
|
+
openInvestigation,
|
|
25
|
+
openQuestion: vi.fn(),
|
|
26
|
+
startError: null,
|
|
27
|
+
startRefusal: null,
|
|
28
|
+
dismissError: vi.fn(),
|
|
29
|
+
agents: [],
|
|
30
|
+
}),
|
|
31
|
+
}));
|
|
32
|
+
vi.mock("../../context/ThemeContext", () => ({
|
|
33
|
+
useTheme: () => ({ theme: "light", setTheme: vi.fn(), toggleTheme: vi.fn() }),
|
|
34
|
+
}));
|
|
35
|
+
vi.mock("../ui/Tooltip", () => ({
|
|
36
|
+
Tooltip: ({ children }: { children: ReactNode }) => children,
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
describe("the example when its transcript can't load", () => {
|
|
40
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
|
|
41
|
+
let root: Root;
|
|
42
|
+
let container: HTMLDivElement;
|
|
43
|
+
|
|
44
|
+
beforeEach(() => {
|
|
45
|
+
vi.stubGlobal("fetch", vi.fn());
|
|
46
|
+
vi.stubGlobal(
|
|
47
|
+
"ResizeObserver",
|
|
48
|
+
class {
|
|
49
|
+
observe() {}
|
|
50
|
+
unobserve() {}
|
|
51
|
+
disconnect() {}
|
|
52
|
+
},
|
|
53
|
+
);
|
|
54
|
+
vi.stubGlobal("matchMedia", (query: string) => ({
|
|
55
|
+
matches: false,
|
|
56
|
+
media: query,
|
|
57
|
+
addEventListener() {},
|
|
58
|
+
removeEventListener() {},
|
|
59
|
+
addListener() {},
|
|
60
|
+
removeListener() {},
|
|
61
|
+
}));
|
|
62
|
+
container = document.createElement("div");
|
|
63
|
+
document.body.appendChild(container);
|
|
64
|
+
root = createRoot(container);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
afterEach(() => {
|
|
68
|
+
act(() => root.unmount());
|
|
69
|
+
container.remove();
|
|
70
|
+
vi.unstubAllGlobals();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("says so and never offers to investigate the sample resource", async () => {
|
|
74
|
+
await act(async () => {
|
|
75
|
+
root.render(
|
|
76
|
+
<QueryClientProvider client={new QueryClient()}>
|
|
77
|
+
<MemoryRouter>
|
|
78
|
+
<InvestigationView
|
|
79
|
+
run={EXAMPLE_INVESTIGATION_RUN}
|
|
80
|
+
agentLabel="Claude Code"
|
|
81
|
+
maximized
|
|
82
|
+
example
|
|
83
|
+
/>
|
|
84
|
+
</MemoryRouter>
|
|
85
|
+
</QueryClientProvider>,
|
|
86
|
+
);
|
|
87
|
+
});
|
|
88
|
+
await vi.waitFor(() =>
|
|
89
|
+
expect(container.textContent).toContain("couldn't load the example"),
|
|
90
|
+
);
|
|
91
|
+
expect(container.textContent).not.toMatch(/Investigate again/);
|
|
92
|
+
expect(openInvestigation).not.toHaveBeenCalled();
|
|
93
|
+
});
|
|
94
|
+
});
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act, type ReactNode } from "react";
|
|
3
|
+
import { createRoot, type Root } from "react-dom/client";
|
|
4
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
5
|
+
import { MemoryRouter } from "react-router-dom";
|
|
6
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
7
|
+
|
|
8
|
+
import type {
|
|
9
|
+
DiagnoseStreamEvent,
|
|
10
|
+
Diagnosis,
|
|
11
|
+
RunSummary,
|
|
12
|
+
} from "../../api/diagnose";
|
|
13
|
+
import events from "./exampleInvestigation.events.json";
|
|
14
|
+
import {
|
|
15
|
+
EXAMPLE_INVESTIGATION_RUN,
|
|
16
|
+
exampleInvestigationOffered,
|
|
17
|
+
} from "./exampleInvestigation";
|
|
18
|
+
import { isInvestigationEvidenceRef } from "./investigationEvidence/identity";
|
|
19
|
+
import { projectInvestigationEvidence } from "./investigationEvidence";
|
|
20
|
+
import { resolveInvestigationCase } from "./investigationCase";
|
|
21
|
+
import { upsertTool, type Turn } from "./parts";
|
|
22
|
+
import { InvestigationView } from "./InvestigationView";
|
|
23
|
+
|
|
24
|
+
vi.mock("./DiagnoseContext", () => ({
|
|
25
|
+
useDiagnose: () => ({
|
|
26
|
+
refreshRuns: vi.fn(),
|
|
27
|
+
openInvestigation: vi.fn(),
|
|
28
|
+
openQuestion: vi.fn(),
|
|
29
|
+
startError: null,
|
|
30
|
+
startRefusal: null,
|
|
31
|
+
dismissError: vi.fn(),
|
|
32
|
+
// An agent that could apply and explain: the example must still offer neither.
|
|
33
|
+
agents: [
|
|
34
|
+
{
|
|
35
|
+
name: "claude",
|
|
36
|
+
label: "Claude Code",
|
|
37
|
+
path: "",
|
|
38
|
+
version: "",
|
|
39
|
+
present: true,
|
|
40
|
+
supported: true,
|
|
41
|
+
apply: true,
|
|
42
|
+
verification: true,
|
|
43
|
+
assessmentExplanations: true,
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
}),
|
|
47
|
+
}));
|
|
48
|
+
vi.mock("../../context/ThemeContext", () => ({
|
|
49
|
+
useTheme: () => ({ theme: "light", setTheme: vi.fn(), toggleTheme: vi.fn() }),
|
|
50
|
+
}));
|
|
51
|
+
vi.mock("../ui/Tooltip", () => ({
|
|
52
|
+
Tooltip: ({ children }: { children: ReactNode }) => children,
|
|
53
|
+
}));
|
|
54
|
+
|
|
55
|
+
const transcript = events as unknown as DiagnoseStreamEvent[];
|
|
56
|
+
const fixture = JSON.stringify(events) + JSON.stringify(EXAMPLE_INVESTIGATION_RUN);
|
|
57
|
+
|
|
58
|
+
describe("the bundled example's data", () => {
|
|
59
|
+
it("carries none of the values it was recorded with", () => {
|
|
60
|
+
for (const leaked of [
|
|
61
|
+
"radar-test",
|
|
62
|
+
"nonprod",
|
|
63
|
+
"wg-",
|
|
64
|
+
"+03:00",
|
|
65
|
+
"10.0.27.",
|
|
66
|
+
"toolu_01",
|
|
67
|
+
"sessionId",
|
|
68
|
+
"costUsd",
|
|
69
|
+
"ownerPid",
|
|
70
|
+
]) {
|
|
71
|
+
expect(fixture).not.toContain(leaked);
|
|
72
|
+
}
|
|
73
|
+
expect(fixture).not.toMatch(/\b\d{12}\b/);
|
|
74
|
+
expect(fixture).not.toMatch(/[\w.+-]+@[\w-]+\.[\w.]+/);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("ends in a complete verdict whose citations all land on a card", () => {
|
|
78
|
+
let timeline: Turn["timeline"] = [];
|
|
79
|
+
let diagnosis: Diagnosis | undefined;
|
|
80
|
+
for (const event of transcript) {
|
|
81
|
+
if (event.type === "step" && event.step)
|
|
82
|
+
timeline = upsertTool(timeline, event.step, false);
|
|
83
|
+
if (event.type === "done") diagnosis = event.diagnosis;
|
|
84
|
+
}
|
|
85
|
+
expect(transcript.some((event) => event.type === "error")).toBe(false);
|
|
86
|
+
expect(diagnosis?.summary).toBeTruthy();
|
|
87
|
+
const refs = timeline.flatMap((item) =>
|
|
88
|
+
item.kind === "tool" && item.evidenceRef ? [item.evidenceRef] : [],
|
|
89
|
+
);
|
|
90
|
+
expect(refs).toHaveLength(2);
|
|
91
|
+
for (const ref of refs) expect(isInvestigationEvidenceRef(ref)).toBe(true);
|
|
92
|
+
for (const ref of diagnosis!.rootCauseEvidence!.refs!)
|
|
93
|
+
expect(refs).toContain(ref);
|
|
94
|
+
|
|
95
|
+
const projection = projectInvestigationEvidence(
|
|
96
|
+
[{ timeline }],
|
|
97
|
+
EXAMPLE_INVESTIGATION_RUN,
|
|
98
|
+
);
|
|
99
|
+
const investigationCase = resolveInvestigationCase(
|
|
100
|
+
projection,
|
|
101
|
+
diagnosis!,
|
|
102
|
+
0,
|
|
103
|
+
);
|
|
104
|
+
expect(investigationCase.items).toHaveLength(diagnosis!.evidence!.length);
|
|
105
|
+
for (const item of investigationCase.items)
|
|
106
|
+
expect(item.placement).toBe("card");
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
describe("exampleInvestigationOffered", () => {
|
|
111
|
+
const run = (patch: Partial<RunSummary> = {}): RunSummary => ({
|
|
112
|
+
...EXAMPLE_INVESTIGATION_RUN,
|
|
113
|
+
id: "run-1",
|
|
114
|
+
...patch,
|
|
115
|
+
});
|
|
116
|
+
const offered = (
|
|
117
|
+
runs: RunSummary[],
|
|
118
|
+
{ runsLoaded = true, setupPending = false, needsConsent = false } = {},
|
|
119
|
+
) =>
|
|
120
|
+
exampleInvestigationOffered({ runs, runsLoaded, setupPending, needsConsent });
|
|
121
|
+
|
|
122
|
+
it("is offered only while the user has no investigations of their own", () => {
|
|
123
|
+
expect(offered([])).toBe(true);
|
|
124
|
+
expect(offered([run()])).toBe(false);
|
|
125
|
+
expect(offered([run({ ownedByMe: true })])).toBe(false);
|
|
126
|
+
expect(offered([run()], { runsLoaded: false, setupPending: true })).toBe(
|
|
127
|
+
false,
|
|
128
|
+
);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("does not count automatic runs or runs others shared", () => {
|
|
132
|
+
expect(
|
|
133
|
+
offered([run({ trigger: "background" }), run({ ownedByMe: false })]),
|
|
134
|
+
).toBe(true);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("waits for the history before claiming it is empty", () => {
|
|
138
|
+
expect(offered([], { runsLoaded: false })).toBe(false);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it("is offered on the setup step, where no history is fetched", () => {
|
|
142
|
+
expect(offered([], { runsLoaded: false, setupPending: true })).toBe(true);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it("is not offered while a start waits for consent", () => {
|
|
146
|
+
expect(offered([], { needsConsent: true })).toBe(false);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
describe("InvestigationView showing the example", () => {
|
|
151
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
|
|
152
|
+
let root: Root;
|
|
153
|
+
let container: HTMLDivElement;
|
|
154
|
+
const fetchMock = vi.fn();
|
|
155
|
+
|
|
156
|
+
beforeEach(() => {
|
|
157
|
+
vi.stubGlobal("fetch", fetchMock);
|
|
158
|
+
// jsdom has no EventSource: a server subscription would throw.
|
|
159
|
+
vi.stubGlobal(
|
|
160
|
+
"ResizeObserver",
|
|
161
|
+
class {
|
|
162
|
+
observe() {}
|
|
163
|
+
unobserve() {}
|
|
164
|
+
disconnect() {}
|
|
165
|
+
},
|
|
166
|
+
);
|
|
167
|
+
vi.stubGlobal("matchMedia", (query: string) => ({
|
|
168
|
+
matches: false,
|
|
169
|
+
media: query,
|
|
170
|
+
addEventListener() {},
|
|
171
|
+
removeEventListener() {},
|
|
172
|
+
addListener() {},
|
|
173
|
+
removeListener() {},
|
|
174
|
+
}));
|
|
175
|
+
container = document.createElement("div");
|
|
176
|
+
document.body.appendChild(container);
|
|
177
|
+
root = createRoot(container);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
afterEach(() => {
|
|
181
|
+
act(() => root.unmount());
|
|
182
|
+
container.remove();
|
|
183
|
+
vi.unstubAllGlobals();
|
|
184
|
+
fetchMock.mockReset();
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
async function renderExample(onCloseExample = vi.fn()) {
|
|
188
|
+
const client = new QueryClient();
|
|
189
|
+
await act(async () => {
|
|
190
|
+
root.render(
|
|
191
|
+
<QueryClientProvider client={client}>
|
|
192
|
+
<MemoryRouter>
|
|
193
|
+
<InvestigationView
|
|
194
|
+
run={EXAMPLE_INVESTIGATION_RUN}
|
|
195
|
+
agentLabel="Claude Code"
|
|
196
|
+
maximized
|
|
197
|
+
example
|
|
198
|
+
onCloseExample={onCloseExample}
|
|
199
|
+
/>
|
|
200
|
+
</MemoryRouter>
|
|
201
|
+
</QueryClientProvider>,
|
|
202
|
+
);
|
|
203
|
+
});
|
|
204
|
+
await vi.waitFor(() =>
|
|
205
|
+
expect(container.textContent).toContain(
|
|
206
|
+
"A direct edit set guestbook-ui to a nonexistent image tag",
|
|
207
|
+
),
|
|
208
|
+
);
|
|
209
|
+
return onCloseExample;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
it("labels it as an example and renders its findings from the bundle", async () => {
|
|
213
|
+
await renderExample();
|
|
214
|
+
const label = container.querySelector("[data-investigation-example]");
|
|
215
|
+
expect(label?.textContent).toContain("Example");
|
|
216
|
+
expect(label?.textContent).toContain("test cluster");
|
|
217
|
+
expect(container.textContent).toContain("Next steps");
|
|
218
|
+
// Nothing about the example is read from the server or the cluster.
|
|
219
|
+
expect(
|
|
220
|
+
fetchMock.mock.calls
|
|
221
|
+
.map((call) => String(call[0]))
|
|
222
|
+
.filter((url) => /diagnose|resources|guestbook/.test(url)),
|
|
223
|
+
).toEqual([]);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
it("offers nothing that acts on it or sends it anywhere", async () => {
|
|
227
|
+
await renderExample();
|
|
228
|
+
expect(container.querySelector("textarea")).toBeNull();
|
|
229
|
+
const buttons = [...container.querySelectorAll("button")].map(
|
|
230
|
+
(button) =>
|
|
231
|
+
`${button.textContent ?? ""} ${button.getAttribute("aria-label") ?? ""}`,
|
|
232
|
+
);
|
|
233
|
+
for (const label of buttons) {
|
|
234
|
+
expect(label).not.toMatch(
|
|
235
|
+
/copy|apply|send|follow-up|investigate again|check status|explain/i,
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it("closes from its label", async () => {
|
|
241
|
+
const onClose = await renderExample();
|
|
242
|
+
const close = [...container.querySelectorAll("button")].find(
|
|
243
|
+
(button) => button.textContent === "Close example",
|
|
244
|
+
);
|
|
245
|
+
act(() => close!.click());
|
|
246
|
+
expect(onClose).toHaveBeenCalledOnce();
|
|
247
|
+
});
|
|
248
|
+
});
|