@skyhook-io/radar-app 1.21.8 → 1.22.1
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 +1 -1
- package/src/App.tsx +16 -1
- package/src/api/client.ts +18 -0
- package/src/api/cnpg-history.ts +3 -3
- package/src/api/cnpg-storage.ts +3 -3
- package/src/api/diagnose.test.ts +34 -0
- package/src/api/diagnose.ts +17 -4
- package/src/api/radarFeatures.test.ts +13 -1
- package/src/api/radarFeatures.ts +6 -0
- package/src/api/resourceActions.test.ts +829 -0
- package/src/api/resourceActions.ts +584 -0
- package/src/api/resourceActions.ui.test.tsx +1882 -0
- package/src/api/reviewedActionMutation.ts +56 -28
- package/src/api/substrateHealth.ts +2 -3
- package/src/api/traefik.ts +33 -0
- package/src/api/traffic.ts +14 -5
- package/src/api/workloadMetrics.test.ts +11 -2
- package/src/api/workloadMetrics.ts +2 -2
- package/src/components/CloudFunnelButton.test.tsx +39 -1
- package/src/components/CloudFunnelButton.tsx +10 -3
- package/src/components/cnpg/CNPGOverview.test.tsx +75 -3
- package/src/components/cnpg/CNPGOverview.tsx +62 -4
- package/src/components/diagnose/AnalysisStory.test.tsx +12 -0
- package/src/components/diagnose/DiagnoseContext.question.test.tsx +34 -1
- package/src/components/diagnose/DiagnoseContext.tsx +28 -3
- package/src/components/diagnose/DiagnoseSurface.tsx +5 -4
- package/src/components/diagnose/Home.tsx +3 -0
- package/src/components/diagnose/InvestigationEvidencePane.test.tsx +61 -0
- package/src/components/diagnose/InvestigationView.followupFailure.test.tsx +122 -0
- package/src/components/diagnose/InvestigationView.tsx +10 -2
- package/src/components/diagnose/LocalDiagnoseAction.history.test.tsx +1 -1
- package/src/components/diagnose/LocalDiagnoseAction.tsx +2 -2
- package/src/components/diagnose/QuestionComposer.test.tsx +16 -2
- package/src/components/diagnose/QuestionComposer.tsx +13 -8
- package/src/components/diagnose/diagnoseEvidenceTypes.ts +47 -8
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.test.ts +153 -0
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +9 -13
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +21 -5
- package/src/components/diagnose/investigationEvidence/bodies/network.tsx +63 -26
- package/src/components/diagnose/launch.ts +1 -1
- package/src/components/dock/PodDebugSession.test.tsx +66 -0
- package/src/components/dock/PodDebugSession.tsx +3 -1
- package/src/components/dock/TerminalTab.test.tsx +43 -3
- package/src/components/dock/TerminalTab.tsx +10 -1
- package/src/components/helm/HelmReleaseDrawer.tsx +1 -1
- package/src/components/helm/InstallWizard.tsx +1 -1
- package/src/components/home/NetworkPolicyCoverageCard.test.tsx +37 -0
- package/src/components/home/NetworkPolicyCoverageCard.tsx +26 -2
- package/src/components/home/mcpToolCatalog.ts +1 -1
- package/src/components/resources/PodEvictAction.test.tsx +951 -0
- package/src/components/resources/PodEvictAction.tsx +167 -0
- package/src/components/resources/ResourcesView.tsx +3 -0
- package/src/components/resources/renderers/TraefikIngressRouteRenderer.test.tsx +23 -0
- package/src/components/resources/renderers/TraefikIngressRouteRenderer.tsx +23 -0
- package/src/components/resources/renderers/TraefikMiddlewareRenderer.test.tsx +23 -0
- package/src/components/resources/renderers/TraefikMiddlewareRenderer.tsx +29 -0
- package/src/components/resources/renderers/WorkloadRenderer.tsx +3 -0
- package/src/components/settings/LocalConnectionSettings.tsx +4 -4
- package/src/components/settings/SettingsDialog.tsx +23 -18
- package/src/components/settings/integrationQueries.test.ts +98 -0
- package/src/components/settings/integrationQueries.ts +36 -0
- package/src/components/traffic/TrafficConnectionsTable.test.tsx +23 -0
- package/src/components/traffic/TrafficConnectionsTable.tsx +5 -4
- package/src/components/traffic/TrafficFilterSidebar.test.tsx +14 -0
- package/src/components/traffic/TrafficFilterSidebar.tsx +17 -0
- package/src/components/traffic/TrafficFlowList.tsx +5 -5
- package/src/components/traffic/TrafficGraph.test.tsx +11 -0
- package/src/components/traffic/TrafficGraph.tsx +31 -19
- package/src/components/traffic/TrafficView.reconnect.test.tsx +229 -0
- package/src/components/traffic/TrafficView.tsx +108 -41
- package/src/components/traffic/traffic-export.test.ts +8 -0
- package/src/components/traffic/traffic-export.ts +7 -4
- package/src/components/traffic/trafficFilters.test.ts +51 -1
- package/src/components/traffic/trafficFilters.ts +39 -11
- package/src/components/ui/Markdown.test.tsx +37 -0
- package/src/components/ui/Markdown.tsx +15 -2
- package/src/components/ui/command-items-crd.test.tsx +23 -8
- package/src/components/useContextSwitchFlow.test.tsx +27 -2
- package/src/components/useContextSwitchFlow.tsx +20 -22
- package/src/components/whats-new/releaseNotes.ts +75 -1
- package/src/components/workload/WorkloadView.tsx +16 -3
- package/src/integrations/resourceHosts.test.tsx +1 -1
- package/src/integrations/resourceHosts.tsx +3 -0
|
@@ -13,6 +13,8 @@ import { runTargetKey } from "./target";
|
|
|
13
13
|
|
|
14
14
|
const api = vi.hoisted(() => ({
|
|
15
15
|
createRun: vi.fn(),
|
|
16
|
+
fullQuestions: true,
|
|
17
|
+
targetedQuestions: false,
|
|
16
18
|
recordConsent: vi.fn(),
|
|
17
19
|
consented: {} as Record<string, boolean>,
|
|
18
20
|
runs: [] as unknown[],
|
|
@@ -34,7 +36,8 @@ vi.mock("../../api/diagnose", async (importOriginal) => ({
|
|
|
34
36
|
supported: true,
|
|
35
37
|
profiles: ["safeguarded"],
|
|
36
38
|
consentSurfaces: { safeguarded: "claude:safeguarded" },
|
|
37
|
-
questions:
|
|
39
|
+
questions: api.fullQuestions,
|
|
40
|
+
targetQuestions: api.targetedQuestions,
|
|
38
41
|
},
|
|
39
42
|
],
|
|
40
43
|
}),
|
|
@@ -85,6 +88,8 @@ const question = {
|
|
|
85
88
|
|
|
86
89
|
beforeEach(async () => {
|
|
87
90
|
api.createRun.mockReset();
|
|
91
|
+
api.fullQuestions = true;
|
|
92
|
+
api.targetedQuestions = false;
|
|
88
93
|
api.recordConsent.mockReset();
|
|
89
94
|
api.consented = {};
|
|
90
95
|
api.runs = [];
|
|
@@ -243,3 +248,31 @@ describe("starting from a question", () => {
|
|
|
243
248
|
expect(diagnose.questionDraft?.context).toBe("cluster-a");
|
|
244
249
|
});
|
|
245
250
|
});
|
|
251
|
+
|
|
252
|
+
it("requires one selected resource on target-only agents, including starts replayed after consent", async () => {
|
|
253
|
+
api.fullQuestions = false;
|
|
254
|
+
api.targetedQuestions = true;
|
|
255
|
+
api.recordConsent.mockResolvedValue(undefined);
|
|
256
|
+
await act(async () => diagnose.recheckAgents());
|
|
257
|
+
await act(async () => diagnose.openInvestigation(question));
|
|
258
|
+
await act(async () => diagnose.approveConsent());
|
|
259
|
+
await flush();
|
|
260
|
+
expect(api.createRun).not.toHaveBeenCalled();
|
|
261
|
+
expect(diagnose.startError).toContain("Choose a resource");
|
|
262
|
+
expect(diagnose.questionDraft?.text).toBe(question.question);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
it("sends the exact pinned resource and question, without the composer's local state", async () => {
|
|
266
|
+
api.fullQuestions = false;
|
|
267
|
+
api.targetedQuestions = true;
|
|
268
|
+
api.consented = { "claude:safeguarded": true };
|
|
269
|
+
await act(async () => diagnose.recheckAgents());
|
|
270
|
+
expect(diagnose.questions).toBe(false);
|
|
271
|
+
expect(diagnose.targetQuestions).toBe(true);
|
|
272
|
+
api.createRun.mockResolvedValue({ id: "run-resource" });
|
|
273
|
+
await act(async () => diagnose.openInvestigation({ ...question, kind: "Deployment", group: "apps", namespace: "shop", name: "checkout" }));
|
|
274
|
+
expect(api.createRun.mock.calls[0][0]).toEqual({
|
|
275
|
+
kind: "Deployment", group: "apps", namespace: "shop", name: "checkout",
|
|
276
|
+
question: question.question, namespaces: question.namespaces, lookBack: "1h",
|
|
277
|
+
});
|
|
278
|
+
});
|
|
@@ -130,7 +130,8 @@ interface DiagnoseCtx {
|
|
|
130
130
|
cliOverride: boolean;
|
|
131
131
|
agentLabel: string; // label of the selected agent, e.g. "Claude Code"
|
|
132
132
|
hosted: boolean; // selected agent runs on the host's backend, not this machine
|
|
133
|
-
questions: boolean; // the selected agent
|
|
133
|
+
questions: boolean; // the selected agent accepts a question without a resource
|
|
134
|
+
targetQuestions: boolean; // the agent accepts a question pinned to a resource
|
|
134
135
|
agents: AgentInfo[]; // supported agents detected on PATH (for the picker)
|
|
135
136
|
selectedAgent: string; // name of the chosen backend ("claude"/"codex")
|
|
136
137
|
setSelectedAgent: (name: string) => void;
|
|
@@ -723,6 +724,8 @@ function RoutedDiagnoseProvider({
|
|
|
723
724
|
: (selectedAgentInfo?.profiles?.[0] ?? profile);
|
|
724
725
|
const agentLabel = agentLabelFor(selectedAgent, selectedAgentInfo?.label);
|
|
725
726
|
const hosted = !!selectedAgentInfo?.hosted;
|
|
727
|
+
const questions = selectedAgentInfo?.questions === true;
|
|
728
|
+
const targetQuestions = questions || selectedAgentInfo?.targetQuestions === true;
|
|
726
729
|
// Hosted Radar uses its existing per-user disclosure surface and supplies its
|
|
727
730
|
// own copy. Local agents use the execution profile as the consent contract.
|
|
728
731
|
const consentSurface = hosted
|
|
@@ -946,8 +949,29 @@ function RoutedDiagnoseProvider({
|
|
|
946
949
|
const startRunRef = useRef<(t: Target) => void>(() => {});
|
|
947
950
|
startRunRef.current = (t: Target) => {
|
|
948
951
|
const seq = ++startSeqRef.current;
|
|
952
|
+
if (t.question && (!targetQuestions || (!questions && (!t.kind || !t.name)))) {
|
|
953
|
+
giveQuestionBack(t);
|
|
954
|
+
setStartFailure({
|
|
955
|
+
refusal: null,
|
|
956
|
+
message: targetQuestions
|
|
957
|
+
? "Choose a resource to investigate this question."
|
|
958
|
+
: "This agent does not accept an opening question.",
|
|
959
|
+
});
|
|
960
|
+
return;
|
|
961
|
+
}
|
|
949
962
|
createRun(
|
|
950
|
-
{
|
|
963
|
+
{
|
|
964
|
+
kind: knownKindForPluralWithGroup(t.kind, t.group) ?? t.kind,
|
|
965
|
+
group: t.group,
|
|
966
|
+
namespace: t.namespace,
|
|
967
|
+
name: t.name,
|
|
968
|
+
issueId: t.issueId,
|
|
969
|
+
fresh: t.fresh,
|
|
970
|
+
question: t.question,
|
|
971
|
+
namespaces: t.namespaces,
|
|
972
|
+
lookBack: t.lookBack,
|
|
973
|
+
askedAt: t.askedAt,
|
|
974
|
+
},
|
|
951
975
|
{
|
|
952
976
|
agent: selectedAgent || undefined,
|
|
953
977
|
profile: hosted ? undefined : effectiveProfile,
|
|
@@ -1357,7 +1381,8 @@ function RoutedDiagnoseProvider({
|
|
|
1357
1381
|
cliOverride,
|
|
1358
1382
|
agentLabel,
|
|
1359
1383
|
hosted,
|
|
1360
|
-
questions
|
|
1384
|
+
questions,
|
|
1385
|
+
targetQuestions,
|
|
1361
1386
|
agents,
|
|
1362
1387
|
selectedAgent,
|
|
1363
1388
|
setSelectedAgent,
|
|
@@ -113,7 +113,7 @@ function buildConfigLine(cfg: {
|
|
|
113
113
|
// run nothing to take a resource or question from.
|
|
114
114
|
// running/stopping human starts reuse the live run. Automatic investigations
|
|
115
115
|
// are immutable, so they retain a separate fresh human start.
|
|
116
|
-
// stale the
|
|
116
|
+
// stale the cluster connection it ran on has closed;
|
|
117
117
|
// the resource may not exist in the active context. Do not
|
|
118
118
|
// silently start a different-cluster investigation from here.
|
|
119
119
|
// needsConsent the consent card owns the surface until it's answered.
|
|
@@ -662,10 +662,11 @@ export function DiagnoseSurface({
|
|
|
662
662
|
) : (
|
|
663
663
|
<InvestigationHome
|
|
664
664
|
agentLabel={d.agentLabel}
|
|
665
|
-
questions={d.
|
|
665
|
+
questions={d.targetQuestions}
|
|
666
|
+
requireResource={d.targetQuestions && !d.questions}
|
|
666
667
|
onOpenExample={openExample}
|
|
667
668
|
onBrowseIssues={
|
|
668
|
-
d.
|
|
669
|
+
d.targetQuestions || (d.runsLoaded && d.runs.length === 0)
|
|
669
670
|
? onBrowseIssues
|
|
670
671
|
: undefined
|
|
671
672
|
}
|
|
@@ -881,7 +882,7 @@ export function DiagnoseSurface({
|
|
|
881
882
|
loaded={d.runsLoaded}
|
|
882
883
|
loadFailed={d.runsLoadFailed}
|
|
883
884
|
onRetry={d.refreshRuns}
|
|
884
|
-
questions={d.
|
|
885
|
+
questions={d.targetQuestions}
|
|
885
886
|
// Beside Home on the full page, Home already offers it.
|
|
886
887
|
onOpenExample={
|
|
887
888
|
persistentHistory || exampleOpen || !openExample
|
|
@@ -148,17 +148,20 @@ export function InvestigationHome({
|
|
|
148
148
|
onBrowseIssues,
|
|
149
149
|
onOpenExample,
|
|
150
150
|
questions = false,
|
|
151
|
+
requireResource = false,
|
|
151
152
|
}: {
|
|
152
153
|
agentLabel: string;
|
|
153
154
|
onBrowseIssues?: () => void;
|
|
154
155
|
onOpenExample?: () => void;
|
|
155
156
|
/** The backend opens a run from a question; offer the composer. */
|
|
156
157
|
questions?: boolean;
|
|
158
|
+
requireResource?: boolean;
|
|
157
159
|
}) {
|
|
158
160
|
if (questions) {
|
|
159
161
|
return (
|
|
160
162
|
<div className="flex min-h-full w-full items-start justify-center px-4 py-10 sm:px-6">
|
|
161
163
|
<QuestionComposer
|
|
164
|
+
requireResource={requireResource}
|
|
162
165
|
onBrowseIssues={onBrowseIssues}
|
|
163
166
|
onOpenExample={onOpenExample}
|
|
164
167
|
/>
|
|
@@ -1116,6 +1116,67 @@ describe("InvestigationEvidencePane hierarchy and provenance", () => {
|
|
|
1116
1116
|
expect(html).not.toMatch(/<button[^>]*>shop\/api\.example\.test<\/button>/);
|
|
1117
1117
|
});
|
|
1118
1118
|
|
|
1119
|
+
it("shows a stored CoreDNS rule as copied text with its source and no severity", () => {
|
|
1120
|
+
const rule =
|
|
1121
|
+
"rewrite name regex .*\\.nodes\\.vcluster\\.com kubernetes.default.svc.cluster.local";
|
|
1122
|
+
const html = render(
|
|
1123
|
+
project(
|
|
1124
|
+
tool("diagnose-dns-rules", "diagnose", {
|
|
1125
|
+
resource: {
|
|
1126
|
+
apiVersion: "apps/v1",
|
|
1127
|
+
kind: "Deployment",
|
|
1128
|
+
metadata: { namespace: "shop", name: "api" },
|
|
1129
|
+
},
|
|
1130
|
+
resourceContext: { tier: "basic" },
|
|
1131
|
+
pods: 0,
|
|
1132
|
+
events: [],
|
|
1133
|
+
dnsContext: {
|
|
1134
|
+
signals: ["pod logs contain DNS resolution failures"],
|
|
1135
|
+
coreDNSRules: [
|
|
1136
|
+
{
|
|
1137
|
+
kind: "ConfigMap",
|
|
1138
|
+
namespace: "kube-system",
|
|
1139
|
+
name: "coredns",
|
|
1140
|
+
key: "Corefile",
|
|
1141
|
+
line: 5,
|
|
1142
|
+
text: rule,
|
|
1143
|
+
truncated: true,
|
|
1144
|
+
},
|
|
1145
|
+
],
|
|
1146
|
+
// The verdict shape some Radar versions send.
|
|
1147
|
+
coreDNSFindings: [
|
|
1148
|
+
{
|
|
1149
|
+
kind: "ConfigMap",
|
|
1150
|
+
namespace: "kube-system",
|
|
1151
|
+
name: "coredns-custom",
|
|
1152
|
+
severity: "warning",
|
|
1153
|
+
reason: "CoreDNS service DNS rewrite",
|
|
1154
|
+
message: "CoreDNS Corefile contains a rule.",
|
|
1155
|
+
},
|
|
1156
|
+
],
|
|
1157
|
+
omittedCoreDNSRules: 3,
|
|
1158
|
+
},
|
|
1159
|
+
}),
|
|
1160
|
+
),
|
|
1161
|
+
false,
|
|
1162
|
+
undefined,
|
|
1163
|
+
undefined,
|
|
1164
|
+
() => {},
|
|
1165
|
+
);
|
|
1166
|
+
|
|
1167
|
+
expect(html).toContain("rules in the CoreDNS config");
|
|
1168
|
+
expect(html).toContain("rewrite name regex");
|
|
1169
|
+
expect(html).toContain("Corefile, line 5");
|
|
1170
|
+
expect(html).toContain("Open the ConfigMap for the whole rule");
|
|
1171
|
+
expect(html).toContain("3 more rules are not shown");
|
|
1172
|
+
expect(html).toMatch(/<button[^>]*>kube-system\/coredns<\/button>/);
|
|
1173
|
+
expect(html).toMatch(/<button[^>]*>kube-system\/coredns-custom<\/button>/);
|
|
1174
|
+
expect(html).toContain(
|
|
1175
|
+
"CoreDNS service DNS rewrite: CoreDNS Corefile contains a rule.",
|
|
1176
|
+
);
|
|
1177
|
+
expect(html).not.toMatch(/>warning</);
|
|
1178
|
+
});
|
|
1179
|
+
|
|
1119
1180
|
it("waits for disclosure motion only when reduced motion is not requested", () => {
|
|
1120
1181
|
expect(investigationDisclosureSettleDelay(false)).toBe(
|
|
1121
1182
|
INVESTIGATION_DISCLOSURE_SETTLE_MS,
|
|
@@ -0,0 +1,122 @@
|
|
|
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, expect, it, vi } from "vitest";
|
|
7
|
+
|
|
8
|
+
import { DiagnoseError, type SubscribeHandlers } from "../../api/diagnose";
|
|
9
|
+
import { EXAMPLE_INVESTIGATION_RUN } from "./exampleInvestigation";
|
|
10
|
+
import { InvestigationView } from "./InvestigationView";
|
|
11
|
+
|
|
12
|
+
const addTurn = vi.fn();
|
|
13
|
+
vi.mock("../../api/diagnose", async (importOriginal) => ({
|
|
14
|
+
...(await importOriginal<typeof import("../../api/diagnose")>()),
|
|
15
|
+
subscribeRun: (_id: string, handlers: SubscribeHandlers) => {
|
|
16
|
+
queueMicrotask(() => handlers.onEvent({ type: "replay_complete" } as never));
|
|
17
|
+
return () => {};
|
|
18
|
+
},
|
|
19
|
+
addTurn: (...args: unknown[]) => addTurn(...args),
|
|
20
|
+
}));
|
|
21
|
+
vi.mock("./DiagnoseContext", () => ({
|
|
22
|
+
useDiagnose: () => ({
|
|
23
|
+
refreshRuns: vi.fn(),
|
|
24
|
+
openInvestigation: vi.fn(),
|
|
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
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
|
|
40
|
+
let root: Root;
|
|
41
|
+
let container: HTMLDivElement;
|
|
42
|
+
|
|
43
|
+
beforeEach(() => {
|
|
44
|
+
vi.stubGlobal("fetch", vi.fn());
|
|
45
|
+
vi.stubGlobal(
|
|
46
|
+
"ResizeObserver",
|
|
47
|
+
class {
|
|
48
|
+
observe() {}
|
|
49
|
+
unobserve() {}
|
|
50
|
+
disconnect() {}
|
|
51
|
+
},
|
|
52
|
+
);
|
|
53
|
+
vi.stubGlobal("matchMedia", (query: string) => ({
|
|
54
|
+
matches: false,
|
|
55
|
+
media: query,
|
|
56
|
+
addEventListener() {},
|
|
57
|
+
removeEventListener() {},
|
|
58
|
+
addListener() {},
|
|
59
|
+
removeListener() {},
|
|
60
|
+
}));
|
|
61
|
+
container = document.createElement("div");
|
|
62
|
+
document.body.appendChild(container);
|
|
63
|
+
root = createRoot(container);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
afterEach(() => {
|
|
67
|
+
act(() => root.unmount());
|
|
68
|
+
container.remove();
|
|
69
|
+
vi.unstubAllGlobals();
|
|
70
|
+
addTurn.mockReset();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
function typeInto(textarea: HTMLTextAreaElement, value: string) {
|
|
74
|
+
const setter = Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, "value")!.set!;
|
|
75
|
+
setter.call(textarea, value);
|
|
76
|
+
textarea.dispatchEvent(new Event("input", { bubbles: true }));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function mountFollowupBox() {
|
|
80
|
+
await act(async () => {
|
|
81
|
+
root.render(
|
|
82
|
+
<QueryClientProvider client={new QueryClient()}>
|
|
83
|
+
<MemoryRouter>
|
|
84
|
+
<InvestigationView run={{ ...EXAMPLE_INVESTIGATION_RUN, id: "run-1", canContinue: true }} agentLabel="Claude Code" maximized />
|
|
85
|
+
</MemoryRouter>
|
|
86
|
+
</QueryClientProvider>,
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
const box = await vi.waitFor(() => {
|
|
90
|
+
const el = container.querySelector<HTMLTextAreaElement>('textarea[placeholder="Ask a follow-up or refine…"]');
|
|
91
|
+
expect(el).not.toBeNull();
|
|
92
|
+
return el!;
|
|
93
|
+
});
|
|
94
|
+
return box;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async function send(box: HTMLTextAreaElement, question: string) {
|
|
98
|
+
await act(async () => typeInto(box, question));
|
|
99
|
+
await act(async () => {
|
|
100
|
+
container.querySelector<HTMLButtonElement>('button[aria-label="Send follow-up"]')!.click();
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
it("gives a refused follow-up back with the reason, instead of losing it", async () => {
|
|
105
|
+
const question = "é".repeat(2001);
|
|
106
|
+
addTurn.mockRejectedValue(new DiagnoseError(400, "question is too long (at most 2000 characters)"));
|
|
107
|
+
const box = await mountFollowupBox();
|
|
108
|
+
await send(box, question);
|
|
109
|
+
|
|
110
|
+
expect(addTurn).toHaveBeenCalledWith("run-1", { question });
|
|
111
|
+
await vi.waitFor(() => expect(container.textContent).toContain("question is too long (at most 2000 characters)"));
|
|
112
|
+
expect(box.value).toBe(question);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("does not give back a follow-up when the network failed, since the server may have taken it", async () => {
|
|
116
|
+
addTurn.mockRejectedValue(new TypeError("Failed to fetch"));
|
|
117
|
+
const box = await mountFollowupBox();
|
|
118
|
+
await send(box, "why did it restart?");
|
|
119
|
+
|
|
120
|
+
await vi.waitFor(() => expect(container.textContent).toContain("Couldn't send."));
|
|
121
|
+
expect(box.value).toBe("");
|
|
122
|
+
});
|
|
@@ -391,6 +391,7 @@ export function InvestigationView({
|
|
|
391
391
|
const [busy, setBusy] = useState(false);
|
|
392
392
|
const [requestPending, setRequestPending] = useState(false);
|
|
393
393
|
const explanationRequestSerial = useRef(0);
|
|
394
|
+
const followupRequestSerial = useRef(0);
|
|
394
395
|
const [explanationRequest, setExplanationRequest] = useState<{
|
|
395
396
|
sequence: number;
|
|
396
397
|
status: "running" | "error";
|
|
@@ -946,9 +947,16 @@ export function InvestigationView({
|
|
|
946
947
|
setNarrowPane("activity");
|
|
947
948
|
suppressEvidenceMotionRef.current = false;
|
|
948
949
|
pinnedRef.current = true; // a user-initiated turn always follows to the bottom
|
|
950
|
+
const serial = ++followupRequestSerial.current;
|
|
949
951
|
setRequestPending(true);
|
|
950
952
|
addTurn(run.id, { question: q }).catch((e) => {
|
|
951
953
|
setRequestPending(false);
|
|
954
|
+
// Hand the question back so a refusal (too long, say) can be fixed
|
|
955
|
+
// instead of retyped. Only when the server answered with a refusal: a
|
|
956
|
+
// network failure may hide an accepted turn. Not when a newer follow-up
|
|
957
|
+
// was sent since, or the engineer has started typing.
|
|
958
|
+
if (e instanceof DiagnoseError && serial === followupRequestSerial.current)
|
|
959
|
+
setInput((current) => (current === "" ? q : current));
|
|
952
960
|
setActionError(e instanceof DiagnoseError ? e.message : "Couldn't send.");
|
|
953
961
|
setActionRefusal(investigationRefusal(e));
|
|
954
962
|
});
|
|
@@ -2024,8 +2032,8 @@ export function InvestigationView({
|
|
|
2024
2032
|
{parseContextName(run.context).clusterName}
|
|
2025
2033
|
</span>
|
|
2026
2034
|
</Tooltip>
|
|
2027
|
-
. It is read-only because
|
|
2028
|
-
|
|
2035
|
+
. It is read-only because the cluster connection it ran on has
|
|
2036
|
+
closed.
|
|
2029
2037
|
</span>
|
|
2030
2038
|
</div>
|
|
2031
2039
|
) : null}
|
|
@@ -37,7 +37,7 @@ vi.mock("../../api/diagnose", async (importOriginal) => ({
|
|
|
37
37
|
present: true,
|
|
38
38
|
supported: true,
|
|
39
39
|
hosted: api.hosted,
|
|
40
|
-
|
|
40
|
+
targetQuestions: true,
|
|
41
41
|
profiles: ["safeguarded"],
|
|
42
42
|
consentSurfaces: { safeguarded: "claude:safeguarded" },
|
|
43
43
|
},
|
|
@@ -86,13 +86,13 @@ function DiagnoseResourceButton({
|
|
|
86
86
|
: `Ask ${d.agentLabel} about this resource — reads its spec, events & logs.`
|
|
87
87
|
: problem
|
|
88
88
|
? `Investigate with your own ${d.agentLabel} — runs locally and reads this resource's spec, events & logs.`
|
|
89
|
-
: d.
|
|
89
|
+
: d.targetQuestions
|
|
90
90
|
? `Ask your own ${d.agentLabel} a question about this resource — runs locally, reads its spec, events & logs.`
|
|
91
91
|
: `Ask your own ${d.agentLabel} about this resource — runs locally, reads its spec, events & logs.`;
|
|
92
92
|
// While an investigation is live, the button advertises it (and clicking focuses
|
|
93
93
|
// the existing run rather than starting a new one — openInvestigation dedups).
|
|
94
94
|
const showLabel = problem || running;
|
|
95
|
-
const asks = d.
|
|
95
|
+
const asks = d.targetQuestions && !problem && !running;
|
|
96
96
|
// Asking about a resource with no live problem means saying what to ask; a
|
|
97
97
|
// problem, or a run already live, opens straight away.
|
|
98
98
|
const act = () => {
|
|
@@ -75,8 +75,8 @@ afterEach(async () => {
|
|
|
75
75
|
document.body.replaceChildren();
|
|
76
76
|
});
|
|
77
77
|
|
|
78
|
-
async function render() {
|
|
79
|
-
await act(async () => root.render(<QuestionComposer />));
|
|
78
|
+
async function render(requireResource = false) {
|
|
79
|
+
await act(async () => root.render(<QuestionComposer requireResource={requireResource} />));
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
function textarea() {
|
|
@@ -551,3 +551,17 @@ describe("QuestionComposer", () => {
|
|
|
551
551
|
expect(document.body.textContent).toContain("Still loading");
|
|
552
552
|
});
|
|
553
553
|
});
|
|
554
|
+
|
|
555
|
+
it("requires a resource before starting a target-only question, including Enter after unpinning", async () => {
|
|
556
|
+
state.questionDraft = { seq: 1, pin: { kind: "Deployment", group: "apps", namespace: "shop", name: "checkout" } };
|
|
557
|
+
await render(true);
|
|
558
|
+
await type("Can we scale checkout to five replicas?");
|
|
559
|
+
const submit = document.querySelector<HTMLButtonElement>('button[type="submit"]')!;
|
|
560
|
+
expect(submit.disabled).toBe(false);
|
|
561
|
+
await act(async () => document.querySelector<HTMLButtonElement>('[aria-label="Unpin resource"]')!.click());
|
|
562
|
+
expect(submit.disabled).toBe(true);
|
|
563
|
+
expect(document.body.textContent).toContain("Choose a resource");
|
|
564
|
+
expect(document.body.textContent).not.toContain("Start in");
|
|
565
|
+
await press("Enter");
|
|
566
|
+
expect(state.openInvestigation).not.toHaveBeenCalled();
|
|
567
|
+
});
|
|
@@ -53,9 +53,11 @@ const actionClass =
|
|
|
53
53
|
export function QuestionComposer({
|
|
54
54
|
onBrowseIssues,
|
|
55
55
|
onOpenExample,
|
|
56
|
+
requireResource = false,
|
|
56
57
|
}: {
|
|
57
58
|
onBrowseIssues?: () => void;
|
|
58
59
|
onOpenExample?: () => void;
|
|
60
|
+
requireResource?: boolean;
|
|
59
61
|
}) {
|
|
60
62
|
const { openInvestigation, agentLabel, questionDraft, saveQuestionDraft } =
|
|
61
63
|
useDiagnose();
|
|
@@ -74,7 +76,7 @@ export function QuestionComposer({
|
|
|
74
76
|
? { text: questionDraft.text.trim(), askedAt: questionDraft.askedAt }
|
|
75
77
|
: null,
|
|
76
78
|
);
|
|
77
|
-
const [pickerOpen, setPickerOpen] = useState(!!questionDraft?.pickResource);
|
|
79
|
+
const [pickerOpen, setPickerOpen] = useState(!!questionDraft?.pickResource || (requireResource && !questionDraft?.pin));
|
|
78
80
|
const textRef = useRef<HTMLTextAreaElement>(null);
|
|
79
81
|
const pickerInputRef = useRef<HTMLInputElement>(null);
|
|
80
82
|
// Focus now so typing straight away lands in the box; once new text has
|
|
@@ -124,8 +126,8 @@ export function QuestionComposer({
|
|
|
124
126
|
(pin
|
|
125
127
|
? suggestionsForPin(pinIssues ?? [], pin)
|
|
126
128
|
: suggestionsFromIssues(issuesData?.issues ?? [])
|
|
127
|
-
).filter((suggestion) => !asked.includes(suggestion.question)),
|
|
128
|
-
[pin, pinIssues, issuesData, asked],
|
|
129
|
+
).filter((suggestion) => (!requireResource || pin || suggestion.pin) && !asked.includes(suggestion.question)),
|
|
130
|
+
[pin, pinIssues, issuesData, asked, requireResource],
|
|
129
131
|
);
|
|
130
132
|
|
|
131
133
|
useEffect(() => {
|
|
@@ -210,8 +212,9 @@ export function QuestionComposer({
|
|
|
210
212
|
|
|
211
213
|
const question = text.trim();
|
|
212
214
|
const tooLong = [...question].length > MAX_QUESTION_LENGTH;
|
|
215
|
+
const canSubmit = !!question && !tooLong && (!requireResource || !!pin);
|
|
213
216
|
const submit = () => {
|
|
214
|
-
if (!
|
|
217
|
+
if (!canSubmit) return;
|
|
215
218
|
submitted.current = true;
|
|
216
219
|
openInvestigation({
|
|
217
220
|
fromComposer: true,
|
|
@@ -248,7 +251,7 @@ export function QuestionComposer({
|
|
|
248
251
|
What are you seeing?
|
|
249
252
|
</h1>
|
|
250
253
|
<p className="mt-1 text-sm text-theme-text-tertiary">
|
|
251
|
-
Describe a problem, or ask whether something looks right. {agentLabel}{" "}
|
|
254
|
+
{requireResource ? "Choose a resource and describe what you want to investigate or change." : "Describe a problem, or ask whether something looks right."} {agentLabel}{" "}
|
|
252
255
|
investigates it with Radar’s read-only tools and shows what it found,
|
|
253
256
|
with the evidence.
|
|
254
257
|
</p>
|
|
@@ -302,7 +305,7 @@ export function QuestionComposer({
|
|
|
302
305
|
</span>
|
|
303
306
|
<button
|
|
304
307
|
type="button"
|
|
305
|
-
onClick={() => setPin(null)}
|
|
308
|
+
onClick={() => { setPin(null); if (requireResource) setPickerOpen(true); }}
|
|
306
309
|
aria-label="Unpin resource"
|
|
307
310
|
className="rounded text-theme-text-tertiary hover:text-theme-text-primary"
|
|
308
311
|
>
|
|
@@ -311,6 +314,7 @@ export function QuestionComposer({
|
|
|
311
314
|
</span>
|
|
312
315
|
) : (
|
|
313
316
|
<>
|
|
317
|
+
{!requireResource && <>
|
|
314
318
|
<span className="text-xs text-theme-text-tertiary">Start in</span>
|
|
315
319
|
{startIn.length === 0 ? (
|
|
316
320
|
<Tooltip
|
|
@@ -357,6 +361,7 @@ export function QuestionComposer({
|
|
|
357
361
|
))}
|
|
358
362
|
</select>
|
|
359
363
|
)}
|
|
364
|
+
</>}
|
|
360
365
|
<button
|
|
361
366
|
type="button"
|
|
362
367
|
onClick={() => setPickerOpen((open) => !open)}
|
|
@@ -364,7 +369,7 @@ export function QuestionComposer({
|
|
|
364
369
|
className={actionClass}
|
|
365
370
|
>
|
|
366
371
|
<AtSign className="h-3 w-3" />
|
|
367
|
-
Pin a resource
|
|
372
|
+
{requireResource ? "Choose a resource" : "Pin a resource"}
|
|
368
373
|
</button>
|
|
369
374
|
</>
|
|
370
375
|
)}
|
|
@@ -395,7 +400,7 @@ export function QuestionComposer({
|
|
|
395
400
|
</span>
|
|
396
401
|
<button
|
|
397
402
|
type="submit"
|
|
398
|
-
disabled={!
|
|
403
|
+
disabled={!canSubmit}
|
|
399
404
|
className="btn-brand ml-1 inline-flex items-center gap-1 rounded-md px-2.5 py-1 text-xs font-medium disabled:opacity-50"
|
|
400
405
|
>
|
|
401
406
|
Investigate
|
|
@@ -142,16 +142,55 @@ export interface DiagnosisChangeContext {
|
|
|
142
142
|
evidence?: string;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
+
// A rewrite or template rule copied from a stored CoreDNS Corefile. It is what
|
|
146
|
+
// the ConfigMap says, with no verdict.
|
|
147
|
+
export interface DiagnosisCoreDNSRule {
|
|
148
|
+
kind: string;
|
|
149
|
+
namespace: string;
|
|
150
|
+
name: string;
|
|
151
|
+
key: string;
|
|
152
|
+
line: number;
|
|
153
|
+
text: string;
|
|
154
|
+
truncated?: boolean;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// A verdict on a CoreDNS ConfigMap, in the `coreDNSFindings` shape. Some Radar
|
|
158
|
+
// versions send it in place of `coreDNSRules`, and Radar Hub shows their
|
|
159
|
+
// clusters with this UI.
|
|
160
|
+
export interface DiagnosisLegacyCoreDNSFinding {
|
|
161
|
+
kind: string;
|
|
162
|
+
namespace: string;
|
|
163
|
+
name: string;
|
|
164
|
+
severity?: string;
|
|
165
|
+
reason?: string;
|
|
166
|
+
message?: string;
|
|
167
|
+
}
|
|
168
|
+
|
|
145
169
|
export interface DiagnosisDNSContext {
|
|
146
170
|
signals?: string[];
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
171
|
+
coreDNSRules?: DiagnosisCoreDNSRule[];
|
|
172
|
+
// Stored rules left out of coreDNSRules by the server's cap.
|
|
173
|
+
omittedCoreDNSRules?: number;
|
|
174
|
+
coreDNSFindings?: DiagnosisLegacyCoreDNSFinding[];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// The configuration facts Radar sends as DNS signals. Each names a resource, so
|
|
178
|
+
// its text is never searched for failure words: a workload can be called
|
|
179
|
+
// "errors-api".
|
|
180
|
+
const DNS_CONFIGURATION_SIGNAL =
|
|
181
|
+
/ uses dnsPolicy=| sets dnsConfig\.|^CoreDNS Deployment |^Radar observed ConfigMap /;
|
|
182
|
+
|
|
183
|
+
// Whether a DNS signal reports a failed lookup, as opposed to a configuration
|
|
184
|
+
// fact such as a pod's dnsPolicy or a CoreDNS rollout.
|
|
185
|
+
export function dnsSignalReportsFailure(signal: string): boolean {
|
|
186
|
+
return (
|
|
187
|
+
!DNS_CONFIGURATION_SIGNAL.test(signal) &&
|
|
188
|
+
/\b(errors?|failed|failures?|timeouts?|nxdomain|servfail)\b/i.test(signal)
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function coreDNSRulesSummary(count: number): string {
|
|
193
|
+
return `${count} CoreDNS rule${count === 1 ? "" : "s"}`;
|
|
155
194
|
}
|
|
156
195
|
|
|
157
196
|
export type DiagnosisEvidenceTone =
|