@skyhook-io/radar-app 1.18.1 → 1.19.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/package.json +4 -4
- package/src/App.tsx +23 -9
- package/src/api/client.deleteResource.test.tsx +111 -0
- package/src/api/client.resourceAudit.test.tsx +57 -0
- package/src/api/client.resourcePath.test.ts +107 -0
- package/src/api/client.ts +136 -37
- package/src/api/diagnose.test.ts +33 -2
- package/src/api/diagnose.ts +93 -3
- package/src/api/radarFeatures.ts +1 -0
- package/src/components/capacity/CapacityDemand.tsx +6 -3
- package/src/components/capacity/CapacityOverview.tsx +14 -7
- package/src/components/capacity/CapacityPoolDetail.tsx +7 -5
- package/src/components/capacity/ClusterSchedulingCard.tsx +3 -3
- package/src/components/capacity/shared.tsx +9 -5
- package/src/components/cnpg/CNPGOverview.tsx +4 -1
- package/src/components/cnpg/actions/useCNPGWriteGuard.tsx +1 -0
- package/src/components/diagnose/AIMarkdown.tsx +1 -1
- package/src/components/diagnose/ActivityTurn.tsx +34 -14
- package/src/components/diagnose/AgentControls.tsx +53 -6
- package/src/components/diagnose/AgentSetupNotice.tsx +1 -1
- 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/ApplyDialog.test.tsx +10 -0
- package/src/components/diagnose/ApplyDialog.tsx +8 -1
- package/src/components/diagnose/AssessmentCard.tsx +99 -8
- 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 +205 -9
- package/src/components/diagnose/DiagnoseSurface.test.tsx +54 -0
- package/src/components/diagnose/DiagnoseSurface.tsx +98 -21
- package/src/components/diagnose/EvidenceCard.tsx +67 -14
- package/src/components/diagnose/Home.test.tsx +182 -5
- package/src/components/diagnose/Home.tsx +168 -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 +119 -2
- package/src/components/diagnose/InvestigationEvidencePane.tsx +59 -11
- package/src/components/diagnose/InvestigationEvidenceSections.tsx +11 -6
- package/src/components/diagnose/InvestigationView.tsx +203 -42
- package/src/components/diagnose/LocalDiagnoseAction.tsx +23 -16
- package/src/components/diagnose/QuestionComposer.test.tsx +553 -0
- package/src/components/diagnose/QuestionComposer.tsx +487 -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 +16 -0
- package/src/components/diagnose/investigationCase.runs.test.tsx +328 -0
- package/src/components/diagnose/investigationCase.ts +33 -1
- package/src/components/diagnose/investigationEvidence/adapters/changes.ts +36 -1
- package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +46 -0
- package/src/components/diagnose/investigationEvidence/adapters/crossplane.test.tsx +85 -0
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +8 -0
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +1 -0
- package/src/components/diagnose/investigationEvidence/adapters/posture.ts +29 -1
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.test.ts +42 -1
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +29 -2
- package/src/components/diagnose/investigationEvidence/adapters/testdata/crossplane-paused-get-resource.json +28 -0
- package/src/components/diagnose/investigationEvidence/bodies/index.tsx +2 -0
- 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/bodies/workload.tsx +5 -1
- package/src/components/diagnose/investigationEvidence/builder.ts +3 -1
- package/src/components/diagnose/investigationEvidence/cardParts.tsx +7 -2
- package/src/components/diagnose/investigationEvidence/excerpt.test.ts +18 -5
- package/src/components/diagnose/investigationEvidence/excerpt.ts +22 -11
- package/src/components/diagnose/investigationEvidence/identity.test.ts +1 -1
- 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 +7 -3
- package/src/components/diagnose/investigationEvidence/projection.test.ts +57 -3
- package/src/components/diagnose/investigationEvidence/types.ts +2 -0
- package/src/components/diagnose/investigationEvidencePartition.ts +6 -1
- package/src/components/diagnose/investigationEvidencePresentation.test.ts +36 -2
- package/src/components/diagnose/investigationEvidencePresentation.ts +33 -8
- package/src/components/diagnose/investigationFocus.test.ts +271 -0
- package/src/components/diagnose/investigationFocus.ts +132 -0
- 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 +66 -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/verdictText.test.tsx +87 -0
- package/src/components/diagnose/verdictText.ts +68 -0
- package/src/components/helm/ChartBrowser.tsx +4 -4
- package/src/components/helm/HelmReleaseDrawer.tsx +6 -2
- package/src/components/helm/HelmView.tsx +34 -23
- package/src/components/helm/InstallWizard.tsx +6 -2
- package/src/components/helm/ValuesViewer.test.tsx +1 -0
- package/src/components/helm/ValuesViewer.tsx +4 -2
- package/src/components/home/ClusterHealthCard.tsx +40 -59
- package/src/components/home/HomeAgentBlock.test.tsx +113 -0
- package/src/components/home/HomeAgentBlock.tsx +94 -0
- package/src/components/home/HomeView.tsx +5 -6
- package/src/components/home/MCPSetupDialog.test.tsx +27 -2
- package/src/components/home/MCPSetupDialog.tsx +14 -2
- package/src/components/home/RadarVersionLine.test.tsx +0 -14
- package/src/components/home/RadarVersionLine.tsx +3 -28
- package/src/components/home/mcpToolCatalog.ts +29 -2
- package/src/components/issues/IssuesPane.render.test.tsx +5 -5
- package/src/components/nav/PrimaryNavRail.tsx +34 -2
- package/src/components/product-hunt/ProductHuntNotice.render.test.tsx +120 -0
- package/src/components/product-hunt/ProductHuntNotice.test.ts +121 -0
- package/src/components/product-hunt/ProductHuntNotice.tsx +202 -0
- package/src/components/product-hunt/launchWindow.ts +78 -0
- package/src/components/product-hunt/useProductHuntRailEntry.test.tsx +76 -0
- package/src/components/product-hunt/useProductHuntRailEntry.ts +27 -0
- package/src/components/resources/CompositeRenderer.tsx +4 -0
- package/src/components/resources/ResourcesView.tsx +1 -1
- package/src/components/settings/LocalConnectionSettings.tsx +1 -0
- 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 +19 -0
- package/src/components/ui/RadarOmnibar.tsx +12 -0
- package/src/components/ui/SearchSyntaxHelp.test.tsx +39 -0
- package/src/components/ui/SearchSyntaxHelp.tsx +23 -2
- package/src/components/ui/UpdateNotification.test.tsx +2 -0
- package/src/components/ui/UpdateNotification.tsx +32 -5
- package/src/components/usage-data/UsageDataPrompt.tsx +19 -1
- package/src/components/whats-new/WhatsNewDialog.test.tsx +3 -3
- package/src/components/whats-new/releaseNotes.ts +60 -1
- package/src/components/workload/WorkloadView.tsx +10 -4
- package/src/components/workspace/layout.tsx +2 -1
- package/src/contexts/CapabilitiesContext.tsx +1 -0
- 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/useGitOpsWriteGuard.test.tsx +126 -2
- package/src/hooks/useGitOpsWriteGuard.ts +25 -3
- package/src/hooks/useResolvedGitOpsOwner.ts +14 -9
- package/src/index.css +85 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { formatRelativeAgeTime } from "@skyhook-io/k8s-ui/utils/format";
|
|
3
|
+
import { stopRun, type RunSummary } from "../../api/diagnose";
|
|
4
|
+
import { useContexts } from "../../api/client";
|
|
5
|
+
import {
|
|
6
|
+
useDiagnose,
|
|
7
|
+
type StartCapacity,
|
|
8
|
+
type Target,
|
|
9
|
+
} from "./DiagnoseContext";
|
|
10
|
+
import { formatInvestigationTarget, formatInvestigationTitle } from "./target";
|
|
11
|
+
|
|
12
|
+
// The runs holding a slot, oldest first: the order they were started in.
|
|
13
|
+
export function runsHoldingSlots(runs: RunSummary[]): RunSummary[] {
|
|
14
|
+
return runs
|
|
15
|
+
.filter((r) => r.status === "running" || r.status === "stopping")
|
|
16
|
+
.sort(
|
|
17
|
+
(a, b) =>
|
|
18
|
+
new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime(),
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// A question-only run is named by its question, as in the history.
|
|
23
|
+
function runLabel(run: RunSummary): string {
|
|
24
|
+
return run.name || run.question
|
|
25
|
+
? formatInvestigationTitle(run)
|
|
26
|
+
: run.preview || "Investigation";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function targetLabel(target: Target): string {
|
|
30
|
+
if (target.name) return formatInvestigationTarget(target);
|
|
31
|
+
return target.question
|
|
32
|
+
? `“${formatInvestigationTitle(target)}”`
|
|
33
|
+
: "this investigation";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// A start refused without a cluster name (a host that sends none) has
|
|
37
|
+
// nothing to compare, so it is taken as this one.
|
|
38
|
+
export function capacityCluster(
|
|
39
|
+
refusedIn: string | undefined,
|
|
40
|
+
current: string | undefined,
|
|
41
|
+
): "same" | "changed" | "unknown" {
|
|
42
|
+
if (!refusedIn || current === refusedIn) return "same";
|
|
43
|
+
return current ? "changed" : "unknown";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function without(set: ReadonlySet<string>, id: string): ReadonlySet<string> {
|
|
47
|
+
const next = new Set(set);
|
|
48
|
+
next.delete(id);
|
|
49
|
+
return next;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const SECONDARY_BUTTON =
|
|
53
|
+
"rounded-lg border border-theme-border px-3 py-1.5 text-sm text-theme-text-secondary hover:bg-theme-hover disabled:cursor-not-allowed disabled:opacity-50";
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The start the user asked for was refused because every investigation slot
|
|
57
|
+
* is taken. Lists what holds them, with a way to open or stop each, and
|
|
58
|
+
* starts the same request again once a slot is free. Starting stays a click:
|
|
59
|
+
* it spends an agent run and takes over the panel, and by the time a slot
|
|
60
|
+
* frees the user may be reading one of the others.
|
|
61
|
+
*
|
|
62
|
+
* runsKnown is false until the runs list has loaded, or while it fails: an
|
|
63
|
+
* empty list then says nothing about free slots, so Start stays available
|
|
64
|
+
* and the server decides.
|
|
65
|
+
*
|
|
66
|
+
* cluster compares the cluster the start was refused in with the current
|
|
67
|
+
* one. A retry resolves the same namespace and name against whatever Radar
|
|
68
|
+
* is connected to, so it waits for a confirmed match.
|
|
69
|
+
*/
|
|
70
|
+
export function InvestigationCapacityNotice({
|
|
71
|
+
capacity,
|
|
72
|
+
runs,
|
|
73
|
+
runsKnown,
|
|
74
|
+
cluster,
|
|
75
|
+
onOpenRun,
|
|
76
|
+
onStop,
|
|
77
|
+
onStart,
|
|
78
|
+
onDismiss,
|
|
79
|
+
}: {
|
|
80
|
+
capacity: StartCapacity;
|
|
81
|
+
runs: RunSummary[];
|
|
82
|
+
runsKnown: boolean;
|
|
83
|
+
cluster: "same" | "changed" | "unknown";
|
|
84
|
+
onOpenRun: (id: string) => void;
|
|
85
|
+
onStop: (id: string) => Promise<void>;
|
|
86
|
+
onStart: () => void;
|
|
87
|
+
onDismiss: () => void;
|
|
88
|
+
}) {
|
|
89
|
+
// Runs whose stop request is in flight, then the ones it settled for. The
|
|
90
|
+
// server marks a run stopped before answering, so a settled run the
|
|
91
|
+
// refreshed list still shows running did not stop.
|
|
92
|
+
const [stopping, setStopping] = useState<ReadonlySet<string>>(new Set());
|
|
93
|
+
const [stopSettled, setStopSettled] = useState<ReadonlySet<string>>(
|
|
94
|
+
new Set(),
|
|
95
|
+
);
|
|
96
|
+
const holding = runsHoldingSlots(runs);
|
|
97
|
+
const slotFree = runsKnown && holding.length < capacity.limit;
|
|
98
|
+
const canStart = cluster === "same" && (!runsKnown || slotFree);
|
|
99
|
+
const target = targetLabel(capacity.target);
|
|
100
|
+
|
|
101
|
+
const stop = (id: string) => {
|
|
102
|
+
setStopping((prev) => new Set(prev).add(id));
|
|
103
|
+
setStopSettled((prev) => without(prev, id));
|
|
104
|
+
const settle = () => {
|
|
105
|
+
setStopping((prev) => without(prev, id));
|
|
106
|
+
setStopSettled((prev) => new Set(prev).add(id));
|
|
107
|
+
};
|
|
108
|
+
onStop(id).then(settle, settle);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
if (cluster === "changed") {
|
|
112
|
+
return (
|
|
113
|
+
<div className="flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center">
|
|
114
|
+
<p className="text-sm text-theme-text-secondary">
|
|
115
|
+
{`The cluster changed since you asked to investigate ${target}, so Radar won’t start it here. Open the resource in this cluster to investigate it.`}
|
|
116
|
+
</p>
|
|
117
|
+
<button type="button" onClick={onDismiss} className={SECONDARY_BUTTON}>
|
|
118
|
+
Dismiss
|
|
119
|
+
</button>
|
|
120
|
+
</div>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<div className="flex flex-1 flex-col overflow-y-auto px-4 py-6">
|
|
126
|
+
<div className="mx-auto flex w-full max-w-xl flex-col gap-4">
|
|
127
|
+
<div>
|
|
128
|
+
<h2 className="text-sm font-medium text-theme-text-primary">
|
|
129
|
+
{slotFree
|
|
130
|
+
? "A slot is free"
|
|
131
|
+
: `${capacity.limit} investigations are already running`}
|
|
132
|
+
</h2>
|
|
133
|
+
<p className="mt-1 text-sm text-theme-text-secondary">
|
|
134
|
+
{slotFree
|
|
135
|
+
? `Start ${target} now.`
|
|
136
|
+
: `Radar runs up to ${capacity.limit} at a time. Stop one to start ${target}, or wait for one to finish.`}
|
|
137
|
+
</p>
|
|
138
|
+
</div>
|
|
139
|
+
{!runsKnown ? (
|
|
140
|
+
<p className="text-sm text-theme-text-tertiary">
|
|
141
|
+
Loading the running investigations…
|
|
142
|
+
</p>
|
|
143
|
+
) : holding.length > 0 ? (
|
|
144
|
+
<ul
|
|
145
|
+
aria-label="Running investigations"
|
|
146
|
+
className="divide-y divide-theme-border rounded-lg border border-theme-border"
|
|
147
|
+
>
|
|
148
|
+
{holding.map((run) => {
|
|
149
|
+
const isStopping =
|
|
150
|
+
stopping.has(run.id) || run.status === "stopping";
|
|
151
|
+
const didNotStop =
|
|
152
|
+
!isStopping &&
|
|
153
|
+
stopSettled.has(run.id) &&
|
|
154
|
+
run.status === "running";
|
|
155
|
+
return (
|
|
156
|
+
<li key={run.id} className="flex items-center gap-3 px-3 py-2">
|
|
157
|
+
<div className="min-w-0 flex-1">
|
|
158
|
+
<div className="truncate text-sm text-theme-text-primary">
|
|
159
|
+
{runLabel(run)}
|
|
160
|
+
</div>
|
|
161
|
+
<div className="text-xs text-theme-text-tertiary">
|
|
162
|
+
{isStopping
|
|
163
|
+
? "Stopping…"
|
|
164
|
+
: didNotStop
|
|
165
|
+
? "Still running. Radar couldn’t stop it; try again."
|
|
166
|
+
: `Started ${formatRelativeAgeTime(run.createdAt)}`}
|
|
167
|
+
</div>
|
|
168
|
+
</div>
|
|
169
|
+
<button
|
|
170
|
+
type="button"
|
|
171
|
+
onClick={() => onOpenRun(run.id)}
|
|
172
|
+
className={SECONDARY_BUTTON}
|
|
173
|
+
>
|
|
174
|
+
Open
|
|
175
|
+
</button>
|
|
176
|
+
<button
|
|
177
|
+
type="button"
|
|
178
|
+
disabled={isStopping}
|
|
179
|
+
onClick={() => stop(run.id)}
|
|
180
|
+
className={SECONDARY_BUTTON}
|
|
181
|
+
aria-label={`Stop ${runLabel(run)}`}
|
|
182
|
+
>
|
|
183
|
+
Stop
|
|
184
|
+
</button>
|
|
185
|
+
</li>
|
|
186
|
+
);
|
|
187
|
+
})}
|
|
188
|
+
</ul>
|
|
189
|
+
) : null}
|
|
190
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
191
|
+
<button
|
|
192
|
+
type="button"
|
|
193
|
+
disabled={!canStart}
|
|
194
|
+
onClick={onStart}
|
|
195
|
+
className="btn-brand px-3 py-1.5 text-sm"
|
|
196
|
+
>
|
|
197
|
+
Start investigation
|
|
198
|
+
</button>
|
|
199
|
+
<button
|
|
200
|
+
type="button"
|
|
201
|
+
onClick={onDismiss}
|
|
202
|
+
className={SECONDARY_BUTTON}
|
|
203
|
+
>
|
|
204
|
+
Cancel
|
|
205
|
+
</button>
|
|
206
|
+
{cluster === "unknown" ? (
|
|
207
|
+
<span className="text-xs text-theme-text-tertiary">
|
|
208
|
+
Checking which cluster Radar is connected to…
|
|
209
|
+
</span>
|
|
210
|
+
) : null}
|
|
211
|
+
</div>
|
|
212
|
+
</div>
|
|
213
|
+
</div>
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** InvestigationCapacityNotice wired to the investigation state. */
|
|
218
|
+
export function InvestigationCapacityRecovery({
|
|
219
|
+
capacity,
|
|
220
|
+
}: {
|
|
221
|
+
capacity: StartCapacity;
|
|
222
|
+
}) {
|
|
223
|
+
const d = useDiagnose();
|
|
224
|
+
const { data: contexts } = useContexts();
|
|
225
|
+
const current = contexts?.find((c) => c.isCurrent)?.name;
|
|
226
|
+
return (
|
|
227
|
+
<InvestigationCapacityNotice
|
|
228
|
+
capacity={capacity}
|
|
229
|
+
runs={d.runs}
|
|
230
|
+
runsKnown={d.runsLoaded && !d.runsLoadFailed}
|
|
231
|
+
cluster={capacityCluster(capacity.context, current)}
|
|
232
|
+
onOpenRun={d.openRun}
|
|
233
|
+
onStop={async (id) => {
|
|
234
|
+
await stopRun(id);
|
|
235
|
+
await d.refreshRuns();
|
|
236
|
+
}}
|
|
237
|
+
onStart={() => d.openInvestigation(capacity.target)}
|
|
238
|
+
onDismiss={d.dismissError}
|
|
239
|
+
/>
|
|
240
|
+
);
|
|
241
|
+
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
1
2
|
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { act } from "react";
|
|
4
|
+
import { createRoot } from "react-dom/client";
|
|
2
5
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
3
6
|
|
|
4
7
|
import { InvestigationEvidencePane } from "./InvestigationEvidencePane";
|
|
@@ -621,7 +624,12 @@ describe("story card defaults", () => {
|
|
|
621
624
|
matches: 1,
|
|
622
625
|
row: { kind: "ConfigMap", namespace: "b", name: "config" },
|
|
623
626
|
},
|
|
624
|
-
{
|
|
627
|
+
{
|
|
628
|
+
key: "ConfigMap//missing",
|
|
629
|
+
label: "missing",
|
|
630
|
+
matches: 0,
|
|
631
|
+
row: undefined,
|
|
632
|
+
},
|
|
625
633
|
]);
|
|
626
634
|
// Rows of a namespace-scoped listing omit their namespace: the scope is
|
|
627
635
|
// theirs, and only that namespace satisfies a namespaced citation.
|
|
@@ -749,21 +757,104 @@ describe("story card defaults", () => {
|
|
|
749
757
|
},
|
|
750
758
|
},
|
|
751
759
|
];
|
|
752
|
-
const
|
|
760
|
+
const render = (report: string, items = evidence) =>
|
|
761
|
+
renderToStaticMarkup(
|
|
762
|
+
<InvestigationEvidencePane
|
|
763
|
+
projection={projection}
|
|
764
|
+
investigationCase={resolveInvestigationCase(
|
|
765
|
+
projection,
|
|
766
|
+
{ evidence: items },
|
|
767
|
+
0,
|
|
768
|
+
)}
|
|
769
|
+
story={{ report, evidence: items }}
|
|
770
|
+
collecting={false}
|
|
771
|
+
animateGroupIds={new Set()}
|
|
772
|
+
onViewSource={() => {}}
|
|
773
|
+
onViewActivity={() => {}}
|
|
774
|
+
/>,
|
|
775
|
+
);
|
|
776
|
+
const symptom = render("Memory climbs.\n\n[[radar:evidence=0]]");
|
|
777
|
+
expect(symptom).toContain("data-story-metrics");
|
|
778
|
+
expect(symptom).not.toContain("height:140px");
|
|
779
|
+
const context = [{ ...evidence[0], role: "context" as const }];
|
|
780
|
+
const contextHtml = render(
|
|
781
|
+
"Memory climbs.\n\n[[radar:evidence=0]]",
|
|
782
|
+
context,
|
|
783
|
+
);
|
|
784
|
+
expect(contextHtml).toContain("data-story-metrics");
|
|
785
|
+
expect(contextHtml).toContain("height:140px");
|
|
786
|
+
expect(contextHtml).toContain('aria-expanded="true"');
|
|
787
|
+
expect(contextHtml).not.toContain("data-chart-reading");
|
|
788
|
+
const folded = render(
|
|
789
|
+
"Memory climbs.\n\n[[radar:evidence=0|compact]]",
|
|
790
|
+
context,
|
|
791
|
+
);
|
|
792
|
+
expect(folded).not.toContain("data-story-metrics");
|
|
793
|
+
expect(folded).toContain('aria-expanded="false"');
|
|
794
|
+
expect(folded).toMatch(/data-chart-reading[^>]*>161\.5 Mi?B?/);
|
|
795
|
+
// Agents mark cards compact for the prose's flow, not their weight, so a
|
|
796
|
+
// compact symptom stays open.
|
|
797
|
+
const compactSymptom = render(
|
|
798
|
+
"Memory climbs.\n\n[[radar:evidence=0|compact]]",
|
|
799
|
+
);
|
|
800
|
+
expect(compactSymptom).toContain("data-story-metrics");
|
|
801
|
+
expect(compactSymptom).not.toContain("height:140px");
|
|
802
|
+
// The collapsed preview bounds its height and leaves the chart out.
|
|
803
|
+
expect(
|
|
804
|
+
render("Memory climbs.\n\n[[radar:evidence=0]]\n\nMore after the fold."),
|
|
805
|
+
).not.toContain("data-story-metrics");
|
|
806
|
+
|
|
807
|
+
const container = document.createElement("div");
|
|
808
|
+
document.body.appendChild(container);
|
|
809
|
+
const root = createRoot(container);
|
|
810
|
+
const pane = (report: string, items: DiagnosisEvidenceItem[]) => (
|
|
753
811
|
<InvestigationEvidencePane
|
|
754
812
|
projection={projection}
|
|
755
813
|
investigationCase={resolveInvestigationCase(
|
|
756
814
|
projection,
|
|
757
|
-
{ evidence },
|
|
815
|
+
{ evidence: items },
|
|
758
816
|
0,
|
|
759
817
|
)}
|
|
760
|
-
story={{ report
|
|
818
|
+
story={{ report, evidence: items }}
|
|
761
819
|
collecting={false}
|
|
762
820
|
animateGroupIds={new Set()}
|
|
763
821
|
onViewSource={() => {}}
|
|
764
822
|
onViewActivity={() => {}}
|
|
765
|
-
|
|
823
|
+
/>
|
|
824
|
+
);
|
|
825
|
+
// The story's card comes first; Captured results follows it.
|
|
826
|
+
const header = () =>
|
|
827
|
+
container.querySelector<HTMLButtonElement>("button[aria-expanded]")!;
|
|
828
|
+
act(() =>
|
|
829
|
+
root.render(
|
|
830
|
+
pane("Memory climbs.\n\n[[radar:evidence=0|compact]]", context),
|
|
831
|
+
),
|
|
832
|
+
);
|
|
833
|
+
expect(container.querySelector("[data-story-metrics]")).toBeNull();
|
|
834
|
+
act(() => header().click());
|
|
835
|
+
expect(header().getAttribute("aria-expanded")).toBe("true");
|
|
836
|
+
expect(container.querySelector("[data-story-metrics]")).not.toBeNull();
|
|
837
|
+
expect(container.querySelector("[data-chart-reading]")).toBeNull();
|
|
838
|
+
act(() => header().click());
|
|
839
|
+
expect(header().getAttribute("aria-expanded")).toBe("false");
|
|
840
|
+
expect(container.querySelector("[data-chart-reading]")).not.toBeNull();
|
|
841
|
+
act(() =>
|
|
842
|
+
root.render(
|
|
843
|
+
pane(
|
|
844
|
+
"Memory climbs.\n\n[[radar:evidence=0|compact]]\n\nSee [[radar:evidence=0]] again.",
|
|
845
|
+
context,
|
|
846
|
+
),
|
|
847
|
+
),
|
|
766
848
|
);
|
|
767
|
-
|
|
849
|
+
act(() => header().click());
|
|
850
|
+
expect(container.querySelector("[data-chart-reading]")).not.toBeNull();
|
|
851
|
+
const reference = container.querySelector<HTMLButtonElement>(
|
|
852
|
+
"[data-story-ref-direction]",
|
|
853
|
+
)!;
|
|
854
|
+
Element.prototype.scrollIntoView ??= () => {};
|
|
855
|
+
act(() => reference.click());
|
|
856
|
+
expect(header().getAttribute("aria-expanded")).toBe("true");
|
|
857
|
+
act(() => root.unmount());
|
|
858
|
+
container.remove();
|
|
768
859
|
});
|
|
769
860
|
});
|
|
@@ -1982,7 +1982,7 @@ describe("InvestigationEvidencePane honest result states", () => {
|
|
|
1982
1982
|
projection.limitations.every((item) => item.presentation === "history"),
|
|
1983
1983
|
).toBe(true);
|
|
1984
1984
|
const html = render(projection);
|
|
1985
|
-
expect(html).toContain("
|
|
1985
|
+
expect(html).toContain("Radar's coverage · 1 routine limit<");
|
|
1986
1986
|
expect(html).not.toContain("Evidence coverage is incomplete");
|
|
1987
1987
|
expect(html).not.toContain("access restrictions");
|
|
1988
1988
|
const header = html.match(
|
|
@@ -2029,10 +2029,70 @@ describe("InvestigationEvidencePane honest result states", () => {
|
|
|
2029
2029
|
);
|
|
2030
2030
|
const html = render(projection);
|
|
2031
2031
|
expect(html).toContain("Evidence coverage is incomplete");
|
|
2032
|
-
expect(html).not.toContain("
|
|
2032
|
+
expect(html).not.toContain("routine limit");
|
|
2033
2033
|
expect(investigationEvidenceCoverageLimited(projection)).toBe(true);
|
|
2034
2034
|
});
|
|
2035
2035
|
|
|
2036
|
+
it("calls sampling caps and history bounds routine, in a neutral tone, and still lists each", () => {
|
|
2037
|
+
const projection = project(
|
|
2038
|
+
tool("empty-history", "get_changes", { changes: [] }),
|
|
2039
|
+
tool("issues-capped", "issues", {
|
|
2040
|
+
issues: [],
|
|
2041
|
+
total: 0,
|
|
2042
|
+
total_matched: 0,
|
|
2043
|
+
recent_changes_truncated: true,
|
|
2044
|
+
}),
|
|
2045
|
+
);
|
|
2046
|
+
expect(
|
|
2047
|
+
projection.limitations.every(
|
|
2048
|
+
(item) =>
|
|
2049
|
+
item.kind === "truncated" ||
|
|
2050
|
+
(item.kind === "unknown" && item.presentation === "history"),
|
|
2051
|
+
),
|
|
2052
|
+
).toBe(true);
|
|
2053
|
+
const html = render(projection);
|
|
2054
|
+
const header =
|
|
2055
|
+
html.match(
|
|
2056
|
+
/<button[^>]*aria-controls="investigation-evidence-coverage"[\s\S]*?<\/button>/,
|
|
2057
|
+
)?.[0] ?? "";
|
|
2058
|
+
expect(header).toContain("Radar's coverage · 2 routine limits");
|
|
2059
|
+
expect(header).not.toContain("Evidence coverage is incomplete");
|
|
2060
|
+
expect(header).not.toContain("text-red");
|
|
2061
|
+
expect(header).not.toContain("text-amber");
|
|
2062
|
+
// Folded, not dropped: every source keeps its row inside the strip.
|
|
2063
|
+
const region = html.slice(
|
|
2064
|
+
html.indexOf('id="investigation-evidence-coverage"'),
|
|
2065
|
+
);
|
|
2066
|
+
expect(region).toContain("Recent changes");
|
|
2067
|
+
expect(region).toContain("Issue-related changes");
|
|
2068
|
+
});
|
|
2069
|
+
|
|
2070
|
+
it("keeps a real failure red and first even when the other limits are routine", () => {
|
|
2071
|
+
const projection = project(
|
|
2072
|
+
tool("empty-history", "get_changes", { changes: [] }),
|
|
2073
|
+
tool(
|
|
2074
|
+
"denied-logs",
|
|
2075
|
+
"get_pod_logs",
|
|
2076
|
+
{ error: "pods/log is forbidden" },
|
|
2077
|
+
{ isError: true },
|
|
2078
|
+
),
|
|
2079
|
+
);
|
|
2080
|
+
const html = render(projection);
|
|
2081
|
+
const header =
|
|
2082
|
+
html.match(
|
|
2083
|
+
/<button[^>]*aria-controls="investigation-evidence-coverage"[\s\S]*?<\/button>/,
|
|
2084
|
+
)?.[0] ?? "";
|
|
2085
|
+
expect(header).toContain("Evidence coverage is incomplete");
|
|
2086
|
+
expect(header).toContain("text-red-400");
|
|
2087
|
+
expect(header).not.toContain("routine limit");
|
|
2088
|
+
const region = html.slice(
|
|
2089
|
+
html.indexOf('id="investigation-evidence-coverage"'),
|
|
2090
|
+
);
|
|
2091
|
+
expect(region.indexOf("pods/log is forbidden")).toBeLessThan(
|
|
2092
|
+
region.indexOf("Recent changes"),
|
|
2093
|
+
);
|
|
2094
|
+
});
|
|
2095
|
+
|
|
2036
2096
|
it("summarizes incomplete coverage and points to Activity for review", () => {
|
|
2037
2097
|
const projection = project(
|
|
2038
2098
|
tool(
|
|
@@ -2742,6 +2802,63 @@ describe("cited broader cards and coverage rows", () => {
|
|
|
2742
2802
|
expect(render(projection)).toContain(
|
|
2743
2803
|
"4 results about other resources are not shown; they appear here when the assessment cites them.",
|
|
2744
2804
|
);
|
|
2805
|
+
// A question with no resource has no "other" resource to speak of.
|
|
2806
|
+
expect(
|
|
2807
|
+
renderToStaticMarkup(
|
|
2808
|
+
<InvestigationEvidencePane
|
|
2809
|
+
projection={projection}
|
|
2810
|
+
collecting={false}
|
|
2811
|
+
animateGroupIds={new Set()}
|
|
2812
|
+
onViewSource={onViewSource}
|
|
2813
|
+
onViewActivity={() => {}}
|
|
2814
|
+
withoutTarget
|
|
2815
|
+
/>,
|
|
2816
|
+
),
|
|
2817
|
+
).toContain(
|
|
2818
|
+
"4 results the assessment didn’t cite are not shown; they appear here when the assessment cites them.",
|
|
2819
|
+
);
|
|
2820
|
+
// Before there is an assessment nothing has been passed over yet.
|
|
2821
|
+
expect(
|
|
2822
|
+
renderToStaticMarkup(
|
|
2823
|
+
<InvestigationEvidencePane
|
|
2824
|
+
projection={projection}
|
|
2825
|
+
collecting
|
|
2826
|
+
animateGroupIds={new Set()}
|
|
2827
|
+
onViewSource={onViewSource}
|
|
2828
|
+
onViewActivity={() => {}}
|
|
2829
|
+
withoutTarget
|
|
2830
|
+
assessmentPending
|
|
2831
|
+
/>,
|
|
2832
|
+
),
|
|
2833
|
+
).toContain(
|
|
2834
|
+
"4 results are held for the assessment; the ones it cites appear here.",
|
|
2835
|
+
);
|
|
2836
|
+
// A run that stopped without one will never cite anything: show it all.
|
|
2837
|
+
const stopped = partitionInvestigationEvidence(
|
|
2838
|
+
projection.groups,
|
|
2839
|
+
undefined,
|
|
2840
|
+
undefined,
|
|
2841
|
+
false,
|
|
2842
|
+
true,
|
|
2843
|
+
);
|
|
2844
|
+
expect(stopped.hiddenBroader).toBe(0);
|
|
2845
|
+
expect(stopped.main.length + stopped.workload.length).toBe(4);
|
|
2846
|
+
const stoppedMarkup = renderToStaticMarkup(
|
|
2847
|
+
<InvestigationEvidencePane
|
|
2848
|
+
projection={projection}
|
|
2849
|
+
collecting={false}
|
|
2850
|
+
animateGroupIds={new Set()}
|
|
2851
|
+
onViewSource={onViewSource}
|
|
2852
|
+
onViewActivity={() => {}}
|
|
2853
|
+
withoutTarget
|
|
2854
|
+
assessmentPending
|
|
2855
|
+
showUncited
|
|
2856
|
+
/>,
|
|
2857
|
+
);
|
|
2858
|
+
expect(stoppedMarkup).not.toContain("not shown");
|
|
2859
|
+
expect(stoppedMarkup).toContain("Evidence collected");
|
|
2860
|
+
expect(stoppedMarkup).not.toContain("about this resource");
|
|
2861
|
+
expect(stoppedMarkup).not.toContain("No relevant evidence");
|
|
2745
2862
|
|
|
2746
2863
|
const resolution = resolveInvestigationRootCauseEvidence(
|
|
2747
2864
|
projection,
|
|
@@ -68,6 +68,9 @@ export function InvestigationEvidencePane({
|
|
|
68
68
|
onViewActivity,
|
|
69
69
|
onOpenResource,
|
|
70
70
|
onOpenTimeline,
|
|
71
|
+
withoutTarget = false,
|
|
72
|
+
assessmentPending = false,
|
|
73
|
+
showUncited = false,
|
|
71
74
|
afterEvidence,
|
|
72
75
|
recordNotes,
|
|
73
76
|
storyShell = false,
|
|
@@ -91,7 +94,6 @@ export function InvestigationEvidencePane({
|
|
|
91
94
|
report: string;
|
|
92
95
|
evidence?: DiagnosisEvidenceItem[];
|
|
93
96
|
};
|
|
94
|
-
/** Open the story fully instead of the bounded preview — when the layout has room for it. */
|
|
95
97
|
collecting: boolean;
|
|
96
98
|
animateGroupIds: ReadonlySet<string>;
|
|
97
99
|
onViewSource: (
|
|
@@ -115,6 +117,13 @@ export function InvestigationEvidencePane({
|
|
|
115
117
|
/** Explicit Activity → Findings navigation, including repeat clicks. */
|
|
116
118
|
revealRequest?: { sourceId: string; requestId: number };
|
|
117
119
|
onRevealReady?: (sourceId: string) => void;
|
|
120
|
+
/** A question with no resource: every result is "about another resource",
|
|
121
|
+
* so withheld ones are counted as uncited instead. */
|
|
122
|
+
withoutTarget?: boolean;
|
|
123
|
+
/** No assessment yet: nothing has been cited, so nothing is "uncited". */
|
|
124
|
+
assessmentPending?: boolean;
|
|
125
|
+
/** The run stopped without an assessment; withheld results are shown. */
|
|
126
|
+
showUncited?: boolean;
|
|
118
127
|
}) {
|
|
119
128
|
const [expandedGroupIds, setExpandedGroupIds] = useState<ReadonlySet<string>>(
|
|
120
129
|
new Set(),
|
|
@@ -142,6 +151,7 @@ export function InvestigationEvidencePane({
|
|
|
142
151
|
rootCauseEvidence,
|
|
143
152
|
investigationCase,
|
|
144
153
|
storyMode,
|
|
154
|
+
showUncited,
|
|
145
155
|
);
|
|
146
156
|
const hasCurrentEvidence =
|
|
147
157
|
partition.main.length + partition.workload.length > 0;
|
|
@@ -352,7 +362,10 @@ export function InvestigationEvidencePane({
|
|
|
352
362
|
projection.groups.map((group) => [group.id, group] as const),
|
|
353
363
|
);
|
|
354
364
|
const renderStoryPlacement = useCallback(
|
|
355
|
-
(
|
|
365
|
+
(
|
|
366
|
+
target: StoryPlacementTarget,
|
|
367
|
+
{ compact, preview }: { compact: boolean; preview: boolean },
|
|
368
|
+
) => {
|
|
356
369
|
const group = target.item.groupId
|
|
357
370
|
? groupsById.get(target.item.groupId)
|
|
358
371
|
: undefined;
|
|
@@ -366,6 +379,7 @@ export function InvestigationEvidencePane({
|
|
|
366
379
|
onViewSource={onViewSource}
|
|
367
380
|
spanFullRow
|
|
368
381
|
compact={compact}
|
|
382
|
+
storyPreview={preview}
|
|
369
383
|
noteMode="chip"
|
|
370
384
|
gapRoles={storyGapRoles}
|
|
371
385
|
/>
|
|
@@ -408,8 +422,16 @@ export function InvestigationEvidencePane({
|
|
|
408
422
|
// A card behind the fold may be mounted and inert, or not mounted at all
|
|
409
423
|
// before the fold first opens; either way the fold opens first and the
|
|
410
424
|
// card is found once it has settled.
|
|
425
|
+
const [storyReveal, setStoryReveal] = useState<{
|
|
426
|
+
domId: string;
|
|
427
|
+
requestId: number;
|
|
428
|
+
}>();
|
|
411
429
|
const revealStoryTarget = useCallback(
|
|
412
430
|
(target: StoryPlacementTarget) => {
|
|
431
|
+
setStoryReveal((previous) => ({
|
|
432
|
+
domId: target.domId,
|
|
433
|
+
requestId: (previous?.requestId ?? 0) + 1,
|
|
434
|
+
}));
|
|
413
435
|
const land = (placed: HTMLElement) => {
|
|
414
436
|
placed.scrollIntoView({
|
|
415
437
|
block: "center",
|
|
@@ -454,10 +476,16 @@ export function InvestigationEvidencePane({
|
|
|
454
476
|
partition.earlier.length;
|
|
455
477
|
const resultsSummary = [
|
|
456
478
|
partition.hiddenBroader > 0
|
|
457
|
-
?
|
|
479
|
+
? withoutTarget
|
|
480
|
+
? assessmentPending
|
|
481
|
+
? `${partition.hiddenBroader} not shown yet`
|
|
482
|
+
: `${partition.hiddenBroader} not cited, not shown`
|
|
483
|
+
: `${partition.hiddenBroader} about other resources not shown`
|
|
458
484
|
: undefined,
|
|
459
485
|
partition.hiddenMetrics > 0
|
|
460
|
-
?
|
|
486
|
+
? withoutTarget && assessmentPending
|
|
487
|
+
? `${partition.hiddenMetrics} metric ${partition.hiddenMetrics === 1 ? "result" : "results"} not shown yet`
|
|
488
|
+
: `${partition.hiddenMetrics} ${withoutTarget ? "uncited" : "broader"} metric ${partition.hiddenMetrics === 1 ? "result" : "results"} not shown`
|
|
461
489
|
: undefined,
|
|
462
490
|
projection.limitations.length > 0
|
|
463
491
|
? `${projection.limitations.length} ${projection.limitations.length === 1 ? "check" : "checks"} limited`
|
|
@@ -485,9 +513,17 @@ export function InvestigationEvidencePane({
|
|
|
485
513
|
className="text-xs text-theme-text-tertiary"
|
|
486
514
|
data-testid="investigation-hidden-evidence"
|
|
487
515
|
>
|
|
488
|
-
{
|
|
489
|
-
?
|
|
490
|
-
|
|
516
|
+
{withoutTarget && assessmentPending
|
|
517
|
+
? partition.hiddenBroader === 1
|
|
518
|
+
? "1 result is held for the assessment; it appears here if the assessment cites it."
|
|
519
|
+
: `${partition.hiddenBroader} results are held for the assessment; the ones it cites appear here.`
|
|
520
|
+
: withoutTarget
|
|
521
|
+
? partition.hiddenBroader === 1
|
|
522
|
+
? "1 result the assessment didn’t cite is not shown; it appears here when the assessment cites it."
|
|
523
|
+
: `${partition.hiddenBroader} results the assessment didn’t cite are not shown; they appear here when the assessment cites them.`
|
|
524
|
+
: partition.hiddenBroader === 1
|
|
525
|
+
? "1 result about another resource is not shown; it appears here when the assessment cites it."
|
|
526
|
+
: `${partition.hiddenBroader} results about other resources are not shown; they appear here when the assessment cites them.`}
|
|
491
527
|
</p>
|
|
492
528
|
) : null}
|
|
493
529
|
|
|
@@ -496,15 +532,20 @@ export function InvestigationEvidencePane({
|
|
|
496
532
|
className="text-xs text-theme-text-tertiary"
|
|
497
533
|
data-testid="investigation-hidden-metrics"
|
|
498
534
|
>
|
|
499
|
-
{
|
|
500
|
-
?
|
|
501
|
-
|
|
535
|
+
{withoutTarget && assessmentPending
|
|
536
|
+
? partition.hiddenMetrics === 1
|
|
537
|
+
? "1 metric result is held for the assessment; it appears here if the assessment cites it."
|
|
538
|
+
: `${partition.hiddenMetrics} metric results are held for the assessment; the ones it cites appear here.`
|
|
539
|
+
: partition.hiddenMetrics === 1
|
|
540
|
+
? `1 ${withoutTarget ? "uncited" : "broader"} metric result is not shown; it appears here when the assessment cites it.`
|
|
541
|
+
: `${partition.hiddenMetrics} ${withoutTarget ? "uncited" : "broader"} metric results are not shown; they appear here when the assessment cites them.`}
|
|
502
542
|
</p>
|
|
503
543
|
) : null}
|
|
504
544
|
|
|
505
545
|
{!hasCurrentEvidence ? (
|
|
506
546
|
<EmptyCollection
|
|
507
547
|
collecting={collecting}
|
|
548
|
+
withoutTarget={withoutTarget}
|
|
508
549
|
hasEarlierEvidence={partition.earlier.length > 0}
|
|
509
550
|
onViewActivity={onViewActivity}
|
|
510
551
|
/>
|
|
@@ -512,7 +553,13 @@ export function InvestigationEvidencePane({
|
|
|
512
553
|
|
|
513
554
|
<CollapsedEvidenceCollection
|
|
514
555
|
id="investigation-workload-evidence"
|
|
515
|
-
title=
|
|
556
|
+
title={
|
|
557
|
+
withoutTarget || showUncited
|
|
558
|
+
? partition.main.length > 0
|
|
559
|
+
? "More evidence collected"
|
|
560
|
+
: "Evidence collected"
|
|
561
|
+
: "More evidence about this resource"
|
|
562
|
+
}
|
|
516
563
|
description=""
|
|
517
564
|
groups={partition.workload}
|
|
518
565
|
totalCount={partition.workload.length + partition.earlier.length}
|
|
@@ -703,6 +750,7 @@ export function InvestigationEvidencePane({
|
|
|
703
750
|
onGroupOpenChange,
|
|
704
751
|
revealSourceId: caseReveal?.sourceId ?? revealRequest?.sourceId,
|
|
705
752
|
revealRequestId: caseReveal?.requestId ?? revealRequest?.requestId,
|
|
753
|
+
storyReveal,
|
|
706
754
|
caseByGroup: investigationCaseByGroup(investigationCase),
|
|
707
755
|
excludedByItem: new Map(
|
|
708
756
|
(investigationCase?.ruledOut ?? []).map((entry) => [
|