@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
|
@@ -81,7 +81,7 @@ describe("RecentList", () => {
|
|
|
81
81
|
const html = render([run()]);
|
|
82
82
|
expect(html.match(/<button\b/g)).toHaveLength(1);
|
|
83
83
|
expect(html).not.toContain('title="');
|
|
84
|
-
expect(html).toContain('aria-label="Deployment
|
|
84
|
+
expect(html).toContain('aria-label="Deployment shop/checkout');
|
|
85
85
|
expect(html).toContain('aria-label="Cluster: nonprod"');
|
|
86
86
|
});
|
|
87
87
|
it("uses cluster identity instead of lifecycle locks and deterministic initial-issue text", () => {
|
|
@@ -103,7 +103,45 @@ describe("RecentList", () => {
|
|
|
103
103
|
expect(html).not.toContain("lucide-lock");
|
|
104
104
|
expect(html).not.toContain("lucide-check");
|
|
105
105
|
});
|
|
106
|
-
it("
|
|
106
|
+
it("groups older history into this week and earlier, dating each older row", () => {
|
|
107
|
+
const html = render([
|
|
108
|
+
run({ id: "today", name: "today", createdAt: time(2, 9) }),
|
|
109
|
+
run({ id: "week", name: "week", createdAt: time(1 - 3, 9) }),
|
|
110
|
+
run({
|
|
111
|
+
id: "old",
|
|
112
|
+
name: "old",
|
|
113
|
+
createdAt: new Date(2026, 6, 4, 18, 5).toISOString(),
|
|
114
|
+
}),
|
|
115
|
+
]);
|
|
116
|
+
const text = visible(html);
|
|
117
|
+
expect(
|
|
118
|
+
html.match(/<h3 [^>]*>(Today|Yesterday|Previous 7 days|Earlier)<\/h3>/g),
|
|
119
|
+
).toHaveLength(3);
|
|
120
|
+
expect(html).toContain(">Previous 7 days</h3>");
|
|
121
|
+
expect(html).toContain(">Earlier</h3>");
|
|
122
|
+
const day = (d: Date) =>
|
|
123
|
+
d.toLocaleDateString(undefined, { month: "short", day: "numeric" });
|
|
124
|
+
expect(text).toContain(`${day(new Date(2026, 6, 4))} · `);
|
|
125
|
+
expect(text).not.toContain(`${day(NOW)} · `);
|
|
126
|
+
});
|
|
127
|
+
it("shows the issue a run started with only until it has a finding", () => {
|
|
128
|
+
const html = render([
|
|
129
|
+
run({
|
|
130
|
+
id: "a",
|
|
131
|
+
name: "found",
|
|
132
|
+
health: { topReason: "ErrImagePull" },
|
|
133
|
+
preview: "A direct edit set a bad tag.",
|
|
134
|
+
}),
|
|
135
|
+
run({
|
|
136
|
+
id: "b",
|
|
137
|
+
name: "pending",
|
|
138
|
+
health: { topReason: "CrashLoopBackOff" },
|
|
139
|
+
}),
|
|
140
|
+
]);
|
|
141
|
+
expect(html).not.toContain("Started with ErrImagePull");
|
|
142
|
+
expect(html).toContain("Started with CrashLoopBackOff");
|
|
143
|
+
});
|
|
144
|
+
it("uses one stable start time per run, sorted into local date groups, with what each found", () => {
|
|
107
145
|
const recentTime = time(2, 13);
|
|
108
146
|
const olderTime = time(1, 12);
|
|
109
147
|
const html = render([
|
|
@@ -112,7 +150,8 @@ describe("RecentList", () => {
|
|
|
112
150
|
id: "recent",
|
|
113
151
|
name: "recent",
|
|
114
152
|
createdAt: recentTime,
|
|
115
|
-
preview:
|
|
153
|
+
preview:
|
|
154
|
+
"MONGO_PASSWORD **broken**, see [the runbook](https://example.com/rb) and _why_",
|
|
116
155
|
}),
|
|
117
156
|
]);
|
|
118
157
|
expect(html.match(/<time /g)).toHaveLength(2);
|
|
@@ -120,7 +159,10 @@ describe("RecentList", () => {
|
|
|
120
159
|
expect(html).toContain(`dateTime="${olderTime}"`);
|
|
121
160
|
expect(html).not.toContain(`dateTime="${time(2, 14)}"`);
|
|
122
161
|
expect(html).not.toContain("ago");
|
|
123
|
-
expect(html).
|
|
162
|
+
expect(visible(html)).toContain(
|
|
163
|
+
"MONGO_PASSWORD broken, see the runbook and why",
|
|
164
|
+
);
|
|
165
|
+
expect(html).not.toContain("**");
|
|
124
166
|
expect(html).toContain(">Today</h3>");
|
|
125
167
|
expect(html).toContain(">Yesterday</h3>");
|
|
126
168
|
expect(visible(html).indexOf("recent")).toBeLessThan(
|
|
@@ -171,7 +213,7 @@ describe("RecentList", () => {
|
|
|
171
213
|
expect(text.indexOf("checkout")).toBeLessThan(
|
|
172
214
|
text.indexOf("shop · Deployment"),
|
|
173
215
|
);
|
|
174
|
-
expect(html).toContain("Deployment
|
|
216
|
+
expect(html).toContain("Deployment shop/checkout");
|
|
175
217
|
});
|
|
176
218
|
|
|
177
219
|
it("does not change displayed time when cluster-switch bookkeeping updates runs", () => {
|
|
@@ -310,4 +352,165 @@ describe("InvestigationHome", () => {
|
|
|
310
352
|
expect(text).toContain("Browse issues");
|
|
311
353
|
expect(html).not.toContain("textarea");
|
|
312
354
|
});
|
|
355
|
+
|
|
356
|
+
it("links to the example only when the surface offers it", () => {
|
|
357
|
+
const link = "See an example investigation";
|
|
358
|
+
expect(
|
|
359
|
+
visible(renderToStaticMarkup(<InvestigationHome agentLabel="Codex" />)),
|
|
360
|
+
).not.toContain(link);
|
|
361
|
+
expect(
|
|
362
|
+
visible(
|
|
363
|
+
renderToStaticMarkup(
|
|
364
|
+
<InvestigationHome agentLabel="Codex" onOpenExample={() => {}} />,
|
|
365
|
+
),
|
|
366
|
+
),
|
|
367
|
+
).toContain(link);
|
|
368
|
+
expect(
|
|
369
|
+
visible(
|
|
370
|
+
renderToStaticMarkup(
|
|
371
|
+
<RecentList
|
|
372
|
+
agentLabel="Codex"
|
|
373
|
+
runs={[]}
|
|
374
|
+
onSelect={() => {}}
|
|
375
|
+
onOpenExample={() => {}}
|
|
376
|
+
/>,
|
|
377
|
+
),
|
|
378
|
+
),
|
|
379
|
+
).toContain(link);
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
describe("RecentList question runs", () => {
|
|
384
|
+
it("titles a question-only run by its question and shows where it started", () => {
|
|
385
|
+
const html = visible(
|
|
386
|
+
render([
|
|
387
|
+
run({
|
|
388
|
+
kind: "",
|
|
389
|
+
group: "",
|
|
390
|
+
namespace: "",
|
|
391
|
+
name: "",
|
|
392
|
+
question: "checkout returns 502s",
|
|
393
|
+
namespaces: ["shop"],
|
|
394
|
+
lookBack: "1h",
|
|
395
|
+
}),
|
|
396
|
+
]),
|
|
397
|
+
);
|
|
398
|
+
expect(html).toContain("checkout returns 502s");
|
|
399
|
+
expect(html).toContain("shop · last 1h");
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
it("keeps a question about a resource under the resource, with what was asked", () => {
|
|
403
|
+
const html = visible(render([run({ question: "why did it restart?" })]));
|
|
404
|
+
expect(html).toContain("checkout");
|
|
405
|
+
expect(html).toContain("Asked: why did it restart?");
|
|
406
|
+
});
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
describe("RecentList loading", () => {
|
|
410
|
+
const renderState = (props: { loaded: boolean; loadFailed?: boolean }) =>
|
|
411
|
+
visible(
|
|
412
|
+
renderToStaticMarkup(
|
|
413
|
+
<RecentList
|
|
414
|
+
agentLabel="Codex"
|
|
415
|
+
runs={[]}
|
|
416
|
+
onSelect={() => {}}
|
|
417
|
+
onRetry={() => {}}
|
|
418
|
+
{...props}
|
|
419
|
+
/>,
|
|
420
|
+
),
|
|
421
|
+
);
|
|
422
|
+
|
|
423
|
+
it("never claims there are no investigations before the list arrives", () => {
|
|
424
|
+
expect(renderState({ loaded: false })).not.toContain(
|
|
425
|
+
"No investigations yet",
|
|
426
|
+
);
|
|
427
|
+
expect(
|
|
428
|
+
renderToStaticMarkup(
|
|
429
|
+
<RecentList
|
|
430
|
+
agentLabel="Codex"
|
|
431
|
+
runs={[]}
|
|
432
|
+
onSelect={() => {}}
|
|
433
|
+
loaded={false}
|
|
434
|
+
/>,
|
|
435
|
+
),
|
|
436
|
+
).toContain('aria-label="Loading investigations"');
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
it("offers a retry when the first load failed", () => {
|
|
440
|
+
const text = renderState({ loaded: false, loadFailed: true });
|
|
441
|
+
expect(text).toContain("Couldn’t load investigations");
|
|
442
|
+
expect(text).toContain("Try again");
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
it("says there are none only after an empty answer", () => {
|
|
446
|
+
expect(renderState({ loaded: true })).toContain("No investigations yet");
|
|
447
|
+
});
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
describe("RecentList findings", () => {
|
|
451
|
+
it("shows what each run found under its title", () => {
|
|
452
|
+
const text = visible(
|
|
453
|
+
render([
|
|
454
|
+
run({
|
|
455
|
+
id: "a",
|
|
456
|
+
preview: "The `api` container exits on a missing **env** var",
|
|
457
|
+
}),
|
|
458
|
+
]),
|
|
459
|
+
);
|
|
460
|
+
expect(text).toContain("The api container exits on a missing env var");
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
it("does not attribute a question-only run to an issue", () => {
|
|
464
|
+
const text = visible(
|
|
465
|
+
render([
|
|
466
|
+
run({
|
|
467
|
+
kind: "",
|
|
468
|
+
group: "",
|
|
469
|
+
namespace: "",
|
|
470
|
+
name: "",
|
|
471
|
+
question: "checkout is slow",
|
|
472
|
+
health: { topReason: "CrashLoopBackOff" } as RunSummary["health"],
|
|
473
|
+
}),
|
|
474
|
+
]),
|
|
475
|
+
);
|
|
476
|
+
expect(text).not.toContain("Started with");
|
|
477
|
+
});
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
describe("RecentList beside the question composer", () => {
|
|
481
|
+
it("does not send people to a resource to start", () => {
|
|
482
|
+
const text = visible(
|
|
483
|
+
renderToStaticMarkup(
|
|
484
|
+
<RecentList
|
|
485
|
+
agentLabel="Codex"
|
|
486
|
+
runs={[]}
|
|
487
|
+
onSelect={() => {}}
|
|
488
|
+
questions
|
|
489
|
+
/>,
|
|
490
|
+
),
|
|
491
|
+
);
|
|
492
|
+
expect(text).toContain("No investigations yet");
|
|
493
|
+
expect(text).not.toContain("Open a resource");
|
|
494
|
+
});
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
describe("RecentList refresh failures", () => {
|
|
498
|
+
it("says a kept list is stale when a later refresh fails", () => {
|
|
499
|
+
const text = visible(
|
|
500
|
+
renderToStaticMarkup(
|
|
501
|
+
<RecentList
|
|
502
|
+
agentLabel="Codex"
|
|
503
|
+
runs={[run()]}
|
|
504
|
+
onSelect={() => {}}
|
|
505
|
+
loaded
|
|
506
|
+
loadFailed
|
|
507
|
+
onRetry={() => {}}
|
|
508
|
+
/>,
|
|
509
|
+
),
|
|
510
|
+
);
|
|
511
|
+
expect(text).toContain(
|
|
512
|
+
"Couldn’t refresh investigations; showing the last list.",
|
|
513
|
+
);
|
|
514
|
+
expect(text).toContain("checkout");
|
|
515
|
+
});
|
|
313
516
|
});
|
|
@@ -14,19 +14,44 @@ import {
|
|
|
14
14
|
pluralToKind,
|
|
15
15
|
} from "@skyhook-io/k8s-ui/utils/navigation";
|
|
16
16
|
import { parseContextName } from "../../utils/context-name";
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
formatInvestigationTitle,
|
|
19
|
+
formatQuestionScope,
|
|
20
|
+
isQuestionOnly,
|
|
21
|
+
} from "./target";
|
|
18
22
|
import { Tooltip } from "../ui/Tooltip";
|
|
23
|
+
import { QuestionComposer } from "./QuestionComposer";
|
|
24
|
+
import { plainVerdictText } from "./verdictText";
|
|
25
|
+
import { ExampleInvestigationLink } from "./ExampleInvestigationLink";
|
|
26
|
+
|
|
27
|
+
function daysBefore(date: Date, now: Date): number {
|
|
28
|
+
const start = (d: Date) =>
|
|
29
|
+
new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();
|
|
30
|
+
return Math.round((start(now) - start(date)) / 86_400_000);
|
|
31
|
+
}
|
|
19
32
|
|
|
33
|
+
// A header per day gave sparse history one header per row; four buckets keep
|
|
34
|
+
// the list scannable, and rows older than yesterday carry their own date.
|
|
20
35
|
function historyDay(date: Date, now: Date): string {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (
|
|
25
|
-
return
|
|
36
|
+
const days = daysBefore(date, now);
|
|
37
|
+
if (days <= 0) return "Today";
|
|
38
|
+
if (days === 1) return "Yesterday";
|
|
39
|
+
if (days < 7) return "Previous 7 days";
|
|
40
|
+
return "Earlier";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function historyTime(date: Date, now: Date): string {
|
|
44
|
+
const time = date.toLocaleTimeString(undefined, {
|
|
45
|
+
hour: "numeric",
|
|
46
|
+
minute: "2-digit",
|
|
47
|
+
});
|
|
48
|
+
if (daysBefore(date, now) <= 1) return time;
|
|
49
|
+
const day = date.toLocaleDateString(undefined, {
|
|
26
50
|
month: "short",
|
|
27
51
|
day: "numeric",
|
|
28
52
|
...(date.getFullYear() === now.getFullYear() ? {} : { year: "numeric" }),
|
|
29
53
|
});
|
|
54
|
+
return `${day} · ${time}`;
|
|
30
55
|
}
|
|
31
56
|
|
|
32
57
|
// Relative age makes the list easy to scan; a stable local timestamp makes two
|
|
@@ -116,13 +141,30 @@ export function statusWord(status: RunSummary["status"]): {
|
|
|
116
141
|
}
|
|
117
142
|
}
|
|
118
143
|
|
|
144
|
+
// The run's latest headline as plain text: rows are too small for the
|
|
145
|
+
// markdown a headline may carry.
|
|
119
146
|
export function InvestigationHome({
|
|
120
147
|
agentLabel,
|
|
121
148
|
onBrowseIssues,
|
|
149
|
+
onOpenExample,
|
|
150
|
+
questions = false,
|
|
122
151
|
}: {
|
|
123
152
|
agentLabel: string;
|
|
124
153
|
onBrowseIssues?: () => void;
|
|
154
|
+
onOpenExample?: () => void;
|
|
155
|
+
/** The backend opens a run from a question; offer the composer. */
|
|
156
|
+
questions?: boolean;
|
|
125
157
|
}) {
|
|
158
|
+
if (questions) {
|
|
159
|
+
return (
|
|
160
|
+
<div className="flex min-h-full w-full items-start justify-center px-4 py-10 sm:px-6">
|
|
161
|
+
<QuestionComposer
|
|
162
|
+
onBrowseIssues={onBrowseIssues}
|
|
163
|
+
onOpenExample={onOpenExample}
|
|
164
|
+
/>
|
|
165
|
+
</div>
|
|
166
|
+
);
|
|
167
|
+
}
|
|
126
168
|
return (
|
|
127
169
|
<div className="flex min-h-full w-full items-center justify-center px-4 py-8 sm:px-6">
|
|
128
170
|
<section className="mx-auto max-w-2xl text-center">
|
|
@@ -151,6 +193,11 @@ export function InvestigationHome({
|
|
|
151
193
|
<ArrowRight className="h-3.5 w-3.5" />
|
|
152
194
|
</button>
|
|
153
195
|
)}
|
|
196
|
+
{onOpenExample && (
|
|
197
|
+
<div className="mt-4">
|
|
198
|
+
<ExampleInvestigationLink onOpen={onOpenExample} />
|
|
199
|
+
</div>
|
|
200
|
+
)}
|
|
154
201
|
</section>
|
|
155
202
|
</div>
|
|
156
203
|
);
|
|
@@ -163,6 +210,11 @@ export function RecentList({
|
|
|
163
210
|
selectedId,
|
|
164
211
|
historyDegraded = false,
|
|
165
212
|
currentContext,
|
|
213
|
+
loaded = true,
|
|
214
|
+
loadFailed = false,
|
|
215
|
+
onRetry,
|
|
216
|
+
onOpenExample,
|
|
217
|
+
questions = false,
|
|
166
218
|
}: {
|
|
167
219
|
agentLabel: string;
|
|
168
220
|
runs: RunSummary[];
|
|
@@ -170,6 +222,15 @@ export function RecentList({
|
|
|
170
222
|
selectedId?: string | null;
|
|
171
223
|
historyDegraded?: boolean;
|
|
172
224
|
currentContext?: string;
|
|
225
|
+
/** The first list response has arrived; until then an empty list means
|
|
226
|
+
* nothing is known yet, not that there are no investigations. */
|
|
227
|
+
loaded?: boolean;
|
|
228
|
+
/** The latest list request failed. */
|
|
229
|
+
loadFailed?: boolean;
|
|
230
|
+
onRetry?: () => void;
|
|
231
|
+
onOpenExample?: () => void;
|
|
232
|
+
/** Home offers the question composer beside this list. */
|
|
233
|
+
questions?: boolean;
|
|
173
234
|
}) {
|
|
174
235
|
const now = new Date();
|
|
175
236
|
const contexts = new Map(
|
|
@@ -183,6 +244,7 @@ export function RecentList({
|
|
|
183
244
|
contextsByName.set(parsed.clusterName, names);
|
|
184
245
|
}
|
|
185
246
|
for (const r of runs) {
|
|
247
|
+
if (isQuestionOnly(r)) continue;
|
|
186
248
|
const kind = pluralToKind(r.kind);
|
|
187
249
|
const groups = groupsByKind.get(kind) ?? new Set<string>();
|
|
188
250
|
// Match Radar's resource-lane display convention: built-in API groups
|
|
@@ -224,25 +286,94 @@ export function RecentList({
|
|
|
224
286
|
</div>
|
|
225
287
|
) : null;
|
|
226
288
|
|
|
289
|
+
if (runs.length === 0 && !loaded) {
|
|
290
|
+
return loadFailed ? (
|
|
291
|
+
<div className="flex flex-col items-center px-4 py-12 text-center">
|
|
292
|
+
<CircleAlert className="mb-3 h-6 w-6 text-theme-text-tertiary" />
|
|
293
|
+
<div className="text-sm font-medium text-theme-text-primary">
|
|
294
|
+
Couldn’t load investigations
|
|
295
|
+
</div>
|
|
296
|
+
<p className="mt-1 max-w-xs text-sm text-theme-text-tertiary">
|
|
297
|
+
Radar keeps retrying while this page is open.
|
|
298
|
+
</p>
|
|
299
|
+
{onRetry && (
|
|
300
|
+
<button
|
|
301
|
+
type="button"
|
|
302
|
+
onClick={onRetry}
|
|
303
|
+
className="mt-3 rounded-md border border-theme-border px-2.5 py-1 text-xs text-theme-text-secondary hover:bg-theme-hover hover:text-theme-text-primary"
|
|
304
|
+
>
|
|
305
|
+
Try again
|
|
306
|
+
</button>
|
|
307
|
+
)}
|
|
308
|
+
</div>
|
|
309
|
+
) : (
|
|
310
|
+
<div
|
|
311
|
+
role="status"
|
|
312
|
+
aria-label="Loading investigations"
|
|
313
|
+
className="space-y-3 px-2 py-4"
|
|
314
|
+
>
|
|
315
|
+
{[0, 1, 2].map((row) => (
|
|
316
|
+
<div key={row} className="space-y-1.5">
|
|
317
|
+
<div className="h-3.5 w-2/3 animate-pulse rounded bg-theme-hover" />
|
|
318
|
+
<div className="h-3 w-1/3 animate-pulse rounded bg-theme-hover" />
|
|
319
|
+
</div>
|
|
320
|
+
))}
|
|
321
|
+
</div>
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// After the first answer a failed refresh keeps the last list, and says so.
|
|
326
|
+
const staleNote =
|
|
327
|
+
loaded && loadFailed ? (
|
|
328
|
+
<div
|
|
329
|
+
role="status"
|
|
330
|
+
className="mb-2 flex items-center justify-between gap-2 rounded-md border border-theme-border px-2.5 py-1.5 text-[11px] leading-snug text-theme-text-secondary"
|
|
331
|
+
>
|
|
332
|
+
<span>Couldn’t refresh investigations; showing the last list.</span>
|
|
333
|
+
{onRetry && (
|
|
334
|
+
<button
|
|
335
|
+
type="button"
|
|
336
|
+
onClick={onRetry}
|
|
337
|
+
className="shrink-0 font-medium text-theme-text-primary hover:underline"
|
|
338
|
+
>
|
|
339
|
+
Try again
|
|
340
|
+
</button>
|
|
341
|
+
)}
|
|
342
|
+
</div>
|
|
343
|
+
) : null;
|
|
344
|
+
|
|
227
345
|
if (runs.length === 0) {
|
|
228
346
|
return (
|
|
229
347
|
<div>
|
|
230
348
|
{degradedNote}
|
|
349
|
+
{staleNote}
|
|
231
350
|
<div className="flex flex-col items-center px-4 py-12 text-center">
|
|
232
351
|
<Sparkles className="mb-3 h-7 w-7 text-accent" />
|
|
233
352
|
<div className="text-sm font-medium text-theme-text-primary">
|
|
234
353
|
No investigations yet
|
|
235
354
|
</div>
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
355
|
+
{questions ? (
|
|
356
|
+
<p className="mt-1 max-w-xs text-sm text-theme-text-tertiary">
|
|
357
|
+
Investigations run in the background and are kept here.
|
|
358
|
+
</p>
|
|
359
|
+
) : (
|
|
360
|
+
<p className="mt-1 max-w-xs text-sm text-theme-text-tertiary">
|
|
361
|
+
Open a resource and use its{" "}
|
|
362
|
+
<Sparkles className="inline h-3.5 w-3.5 align-text-bottom text-accent" />{" "}
|
|
363
|
+
action to investigate it with {agentLabel} —{" "}
|
|
364
|
+
<span className="font-medium text-theme-text-secondary">
|
|
365
|
+
Investigate
|
|
366
|
+
</span>{" "}
|
|
367
|
+
a problem, or just ask about it. Investigations run in the
|
|
368
|
+
background and are kept in your history here.
|
|
369
|
+
</p>
|
|
370
|
+
)}
|
|
371
|
+
{onOpenExample && (
|
|
372
|
+
<ExampleInvestigationLink
|
|
373
|
+
onOpen={onOpenExample}
|
|
374
|
+
className="mt-3"
|
|
375
|
+
/>
|
|
376
|
+
)}
|
|
246
377
|
</div>
|
|
247
378
|
</div>
|
|
248
379
|
);
|
|
@@ -251,6 +382,7 @@ export function RecentList({
|
|
|
251
382
|
return (
|
|
252
383
|
<div className="space-y-4">
|
|
253
384
|
{degradedNote}
|
|
385
|
+
{staleNote}
|
|
254
386
|
<h2 className="px-2 text-sm font-medium text-theme-text-secondary">
|
|
255
387
|
Investigations
|
|
256
388
|
</h2>
|
|
@@ -292,12 +424,24 @@ export function RecentList({
|
|
|
292
424
|
})
|
|
293
425
|
? `${parsed.account} · ${parsed.region}`
|
|
294
426
|
: r.context;
|
|
427
|
+
const questionOnly = isQuestionOnly(r);
|
|
428
|
+
const title = formatInvestigationTitle(r);
|
|
295
429
|
const readableKind = pluralToKind(r.kind);
|
|
296
|
-
const
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
430
|
+
const where = questionOnly
|
|
431
|
+
? formatQuestionScope(r)
|
|
432
|
+
: `${r.namespace ? `${r.namespace} · ` : ""}${
|
|
433
|
+
groupsByKind.get(readableKind)!.size > 1
|
|
434
|
+
? `${readableKind} · ${r.group || "core"}`
|
|
435
|
+
: readableKind
|
|
436
|
+
}`;
|
|
437
|
+
const askedAbout = questionOnly ? "" : (r.question ?? "");
|
|
438
|
+
// The engineer's question frames a run better than the issue
|
|
439
|
+
// Radar flagged when it started, so a run shows one or the other.
|
|
440
|
+
const found = plainVerdictText(r.preview);
|
|
441
|
+
// What it found says more than what it started from, so the
|
|
442
|
+
// starting issue shows only until there is a finding.
|
|
443
|
+
const initialIssue =
|
|
444
|
+
r.question || found ? undefined : r.health?.topReason?.trim();
|
|
301
445
|
const isCurrentCluster = currentContext === r.context;
|
|
302
446
|
const visibility =
|
|
303
447
|
r.trigger === "background"
|
|
@@ -307,7 +451,7 @@ export function RecentList({
|
|
|
307
451
|
: r.visibility === "private"
|
|
308
452
|
? "Private"
|
|
309
453
|
: "";
|
|
310
|
-
const identity = `${
|
|
454
|
+
const identity = `${title}${found ? ` · Found: ${found}` : ""}${askedAbout ? ` · Asked: ${askedAbout}` : ""} · ${r.context}${isCurrentCluster ? " · Current cluster" : ""} · ${label}${visibility ? ` · ${visibility}` : ""} · Started ${new Date(r.createdAt).toLocaleString()}${initialIssue ? ` · Started with ${initialIssue}` : ""}`;
|
|
311
455
|
return (
|
|
312
456
|
<button
|
|
313
457
|
key={r.id}
|
|
@@ -322,14 +466,14 @@ export function RecentList({
|
|
|
322
466
|
>
|
|
323
467
|
<span className="flex w-full items-start gap-2">
|
|
324
468
|
<Tooltip
|
|
325
|
-
content={
|
|
469
|
+
content={title}
|
|
326
470
|
position="right"
|
|
327
471
|
delay={600}
|
|
328
472
|
className="pointer-events-none"
|
|
329
473
|
wrapperClassName="min-w-0 flex-1"
|
|
330
474
|
>
|
|
331
475
|
<span className="min-w-0 flex-1 line-clamp-2 break-words text-sm font-medium leading-5 text-theme-text-primary">
|
|
332
|
-
{r.name}
|
|
476
|
+
{questionOnly ? title : r.name}
|
|
333
477
|
</span>
|
|
334
478
|
</Tooltip>
|
|
335
479
|
{(Icon || short) && (
|
|
@@ -346,19 +490,18 @@ export function RecentList({
|
|
|
346
490
|
</span>
|
|
347
491
|
)}
|
|
348
492
|
</span>
|
|
349
|
-
|
|
350
|
-
<span className="
|
|
351
|
-
{
|
|
352
|
-
{kind}
|
|
493
|
+
{found && (
|
|
494
|
+
<span className="line-clamp-2 w-full break-words text-xs leading-4 text-theme-text-secondary">
|
|
495
|
+
{found}
|
|
353
496
|
</span>
|
|
497
|
+
)}
|
|
498
|
+
<span className="flex w-full items-baseline gap-2 text-xs leading-4 text-theme-text-tertiary">
|
|
499
|
+
<span className="min-w-0 flex-1 truncate">{where}</span>
|
|
354
500
|
<time
|
|
355
501
|
dateTime={r.createdAt}
|
|
356
502
|
className="shrink-0 tabular-nums text-theme-text-tertiary"
|
|
357
503
|
>
|
|
358
|
-
{new Date(r.createdAt)
|
|
359
|
-
hour: "numeric",
|
|
360
|
-
minute: "2-digit",
|
|
361
|
-
})}
|
|
504
|
+
{historyTime(new Date(r.createdAt), now)}
|
|
362
505
|
</time>
|
|
363
506
|
</span>
|
|
364
507
|
<Tooltip
|
|
@@ -374,9 +517,12 @@ export function RecentList({
|
|
|
374
517
|
? `Current cluster: ${parsed.clusterName}`
|
|
375
518
|
: `Cluster: ${parsed.clusterName}`
|
|
376
519
|
}
|
|
377
|
-
className=
|
|
520
|
+
className="flex w-full items-center gap-1 text-xs leading-4 text-theme-text-tertiary"
|
|
378
521
|
>
|
|
379
|
-
<Server
|
|
522
|
+
<Server
|
|
523
|
+
className={`h-3 w-3 shrink-0 ${isCurrentCluster ? "text-accent" : ""}`}
|
|
524
|
+
aria-hidden
|
|
525
|
+
/>
|
|
380
526
|
<span className="min-w-0 flex-1 truncate">
|
|
381
527
|
{parsed.clusterName}
|
|
382
528
|
</span>
|
|
@@ -388,12 +534,17 @@ export function RecentList({
|
|
|
388
534
|
</span>
|
|
389
535
|
</Tooltip>
|
|
390
536
|
{collision && qualifier !== parsed.clusterName && (
|
|
391
|
-
<span className="w-full break-words text-xs leading-4 text-theme-text-
|
|
537
|
+
<span className="w-full break-words text-xs leading-4 text-theme-text-tertiary">
|
|
392
538
|
{qualifier}
|
|
393
539
|
</span>
|
|
394
540
|
)}
|
|
541
|
+
{askedAbout && (
|
|
542
|
+
<span className="line-clamp-1 w-full text-xs leading-4 text-theme-text-tertiary">
|
|
543
|
+
Asked: {askedAbout}
|
|
544
|
+
</span>
|
|
545
|
+
)}
|
|
395
546
|
{initialIssue && (
|
|
396
|
-
<span className="line-clamp-1 w-full text-xs leading-4 text-theme-text-
|
|
547
|
+
<span className="line-clamp-1 w-full text-xs leading-4 text-theme-text-tertiary">
|
|
397
548
|
Started with {initialIssue}
|
|
398
549
|
</span>
|
|
399
550
|
)}
|