@skyhook-io/radar-app 1.18.2 → 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 +0 -1
- 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/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/AssessmentCard.tsx +39 -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 +93 -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 +57 -0
- package/src/components/diagnose/InvestigationEvidencePane.tsx +59 -11
- package/src/components/diagnose/InvestigationEvidenceSections.tsx +5 -1
- package/src/components/diagnose/InvestigationView.tsx +156 -29
- 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 +5 -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/coverage.test.tsx +46 -0
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +8 -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/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/types.ts +2 -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/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/verdictText.test.tsx +87 -0
- package/src/components/diagnose/verdictText.ts +68 -0
- package/src/components/home/ClusterHealthCard.tsx +13 -39
- 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/RadarVersionLine.test.tsx +0 -14
- package/src/components/home/RadarVersionLine.tsx +3 -28
- 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/whats-new/WhatsNewDialog.test.tsx +3 -3
- package/src/components/whats-new/releaseNotes.ts +60 -1
- package/src/hooks/useAgentSignin.test.tsx +190 -0
- package/src/hooks/useAgentSignin.ts +160 -0
- package/src/hooks/useApproveAfterSignin.test.tsx +108 -0
|
@@ -350,6 +350,19 @@ describe("assessmentCopyText", () => {
|
|
|
350
350
|
expect(text).toContain("2 more steps in Radar.");
|
|
351
351
|
});
|
|
352
352
|
|
|
353
|
+
it("says what was asked about the resource, right under where", () => {
|
|
354
|
+
const text = assessmentCopyText(storyDiagnosis, {
|
|
355
|
+
context: {
|
|
356
|
+
target: "Deployment shop/api",
|
|
357
|
+
asked: "users saw errors\n yesterday",
|
|
358
|
+
},
|
|
359
|
+
});
|
|
360
|
+
expect(text.split("\n\n").slice(0, 2)).toEqual([
|
|
361
|
+
"**Deployment shop/api**",
|
|
362
|
+
"Asked: “users saw errors yesterday”",
|
|
363
|
+
]);
|
|
364
|
+
});
|
|
365
|
+
|
|
353
366
|
it("puts the healthy word on the headline and the flags before Still open", () => {
|
|
354
367
|
const text = assessmentCopyText(
|
|
355
368
|
{
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
canonicalKind,
|
|
5
|
+
formatInvestigationTarget,
|
|
6
|
+
formatInvestigationTitle,
|
|
7
|
+
formatQuestionScope,
|
|
8
|
+
isQuestionOnly,
|
|
9
|
+
questionAskedAt,
|
|
10
|
+
rerunOpening,
|
|
11
|
+
runTargetKey,
|
|
12
|
+
} from "./target";
|
|
4
13
|
|
|
5
14
|
describe("investigation target identity", () => {
|
|
6
15
|
it("uses one running key for singular Kinds and plural resource names", () => {
|
|
@@ -34,7 +43,7 @@ describe("investigation target identity", () => {
|
|
|
34
43
|
namespace: "prod",
|
|
35
44
|
name: "api",
|
|
36
45
|
}),
|
|
37
|
-
).toBe("Deployment
|
|
46
|
+
).toBe("Deployment prod/api");
|
|
38
47
|
expect(
|
|
39
48
|
formatInvestigationTarget({
|
|
40
49
|
kind: "pods",
|
|
@@ -56,3 +65,135 @@ describe("investigation target identity", () => {
|
|
|
56
65
|
).toBe("Service prod/api");
|
|
57
66
|
});
|
|
58
67
|
});
|
|
68
|
+
|
|
69
|
+
describe("question runs", () => {
|
|
70
|
+
const questionOnly = {
|
|
71
|
+
kind: "",
|
|
72
|
+
group: "",
|
|
73
|
+
namespace: "",
|
|
74
|
+
name: "",
|
|
75
|
+
question: "checkout is slow\n since lunch",
|
|
76
|
+
namespaces: ["shop", "payments"],
|
|
77
|
+
lookBack: "1h",
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
it("names a question-only run by its question on one line", () => {
|
|
81
|
+
expect(isQuestionOnly(questionOnly)).toBe(true);
|
|
82
|
+
expect(formatInvestigationTitle(questionOnly)).toBe(
|
|
83
|
+
"checkout is slow since lunch",
|
|
84
|
+
);
|
|
85
|
+
expect(formatQuestionScope(questionOnly)).toBe("shop, payments · last 1h");
|
|
86
|
+
const askedAt = "2026-10-27T09:00:00Z";
|
|
87
|
+
expect(
|
|
88
|
+
formatQuestionScope(
|
|
89
|
+
{ ...questionOnly, askedAt },
|
|
90
|
+
new Date("2026-10-28T12:00:00Z"),
|
|
91
|
+
),
|
|
92
|
+
).toBe(
|
|
93
|
+
`shop, payments · 1h before ${new Date(askedAt).toLocaleString(undefined, { month: "short", day: "numeric", hour: "numeric", minute: "2-digit" })}`,
|
|
94
|
+
);
|
|
95
|
+
expect(formatQuestionScope({ ...questionOnly, namespaces: [] })).toBe(
|
|
96
|
+
"All namespaces · last 1h",
|
|
97
|
+
);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("names a question about a resource by the resource", () => {
|
|
101
|
+
const pinned = {
|
|
102
|
+
...questionOnly,
|
|
103
|
+
kind: "Deployment",
|
|
104
|
+
group: "apps",
|
|
105
|
+
namespace: "shop",
|
|
106
|
+
name: "checkout",
|
|
107
|
+
};
|
|
108
|
+
expect(isQuestionOnly(pinned)).toBe(false);
|
|
109
|
+
expect(formatInvestigationTitle(pinned)).toBe("Deployment shop/checkout");
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
describe("rerunOpening", () => {
|
|
114
|
+
const now = Date.parse("2026-10-28T12:00:00Z");
|
|
115
|
+
it("starts the same question again in a new session", () => {
|
|
116
|
+
expect(
|
|
117
|
+
rerunOpening(
|
|
118
|
+
{
|
|
119
|
+
kind: "",
|
|
120
|
+
group: "",
|
|
121
|
+
namespace: "",
|
|
122
|
+
name: "",
|
|
123
|
+
question: "checkout is slow",
|
|
124
|
+
namespaces: ["shop"],
|
|
125
|
+
lookBack: "6h",
|
|
126
|
+
createdAt: "2026-10-27T09:00:00Z",
|
|
127
|
+
},
|
|
128
|
+
now,
|
|
129
|
+
),
|
|
130
|
+
).toEqual({
|
|
131
|
+
kind: "",
|
|
132
|
+
group: "",
|
|
133
|
+
namespace: "",
|
|
134
|
+
name: "",
|
|
135
|
+
issueId: undefined,
|
|
136
|
+
fresh: true,
|
|
137
|
+
question: "checkout is slow",
|
|
138
|
+
namespaces: ["shop"],
|
|
139
|
+
lookBack: "6h",
|
|
140
|
+
askedAt: "2026-10-27T09:00:00Z",
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it("keeps the first asking time through a chain of re-runs, and none without a question", () => {
|
|
145
|
+
const base = {
|
|
146
|
+
kind: "Deployment",
|
|
147
|
+
group: "apps",
|
|
148
|
+
namespace: "shop",
|
|
149
|
+
name: "api",
|
|
150
|
+
createdAt: "2026-10-28T09:00:00Z",
|
|
151
|
+
};
|
|
152
|
+
expect(
|
|
153
|
+
rerunOpening(
|
|
154
|
+
{
|
|
155
|
+
...base,
|
|
156
|
+
question: "why?",
|
|
157
|
+
askedAt: "2026-10-27T09:00:00Z",
|
|
158
|
+
},
|
|
159
|
+
now,
|
|
160
|
+
).askedAt,
|
|
161
|
+
).toBe("2026-10-27T09:00:00Z");
|
|
162
|
+
expect(rerunOpening(base, now).askedAt).toBeUndefined();
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
describe("questionAskedAt", () => {
|
|
167
|
+
const now = Date.parse("2026-10-28T12:00:00Z");
|
|
168
|
+
it("keeps a recent asking time and drops one past Radar's window", () => {
|
|
169
|
+
const run = {
|
|
170
|
+
kind: "",
|
|
171
|
+
group: "",
|
|
172
|
+
namespace: "",
|
|
173
|
+
name: "",
|
|
174
|
+
question: "why?",
|
|
175
|
+
createdAt: "2026-10-20T12:00:00Z",
|
|
176
|
+
};
|
|
177
|
+
expect(questionAskedAt(run, now)).toBe("2026-10-20T12:00:00Z");
|
|
178
|
+
expect(
|
|
179
|
+
questionAskedAt({ ...run, createdAt: "2026-09-01T12:00:00Z" }, now),
|
|
180
|
+
).toBeUndefined();
|
|
181
|
+
expect(
|
|
182
|
+
questionAskedAt({ ...run, question: undefined }, now),
|
|
183
|
+
).toBeUndefined();
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
describe("canonicalKind", () => {
|
|
188
|
+
it("names a resource by its Kind however the caller spelled it", () => {
|
|
189
|
+
expect(canonicalKind("deployments", "")).toBe("Deployment");
|
|
190
|
+
expect(canonicalKind("deployment", "apps")).toBe("Deployment");
|
|
191
|
+
expect(canonicalKind("Deployment", "apps")).toBe("Deployment");
|
|
192
|
+
expect(canonicalKind("pods", "")).toBe("Pod");
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it("keeps a group's own Kind when its plural matches a core one", () => {
|
|
196
|
+
expect(canonicalKind("PodMetrics", "metrics.k8s.io")).toBe("PodMetrics");
|
|
197
|
+
expect(canonicalKind("nodes", "metrics.k8s.io")).toBe("NodeMetrics");
|
|
198
|
+
});
|
|
199
|
+
});
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { resourceKey } from "@skyhook-io/k8s-ui";
|
|
2
|
+
import { groupQualifiesLaneId } from "@skyhook-io/k8s-ui/utils/navigation";
|
|
2
3
|
|
|
3
4
|
import {
|
|
4
5
|
kindToPluralWithGroup,
|
|
5
6
|
knownKindForPluralWithGroup,
|
|
7
|
+
pluralToKind,
|
|
6
8
|
} from "../../utils/navigation";
|
|
7
9
|
|
|
8
10
|
export interface InvestigationTargetIdentity {
|
|
@@ -29,15 +31,115 @@ export function runTargetKey(
|
|
|
29
31
|
);
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
+
// A custom resource is shown as Kind.api.group, the Kubernetes-qualified
|
|
35
|
+
// identity users can copy, because its Kind can collide with another
|
|
36
|
+
// group's. A built-in group never collides, so its Kind stands alone.
|
|
34
37
|
export function formatInvestigationTarget(
|
|
35
38
|
target: InvestigationTargetIdentity,
|
|
36
39
|
): string {
|
|
37
|
-
const
|
|
38
|
-
knownKindForPluralWithGroup(target.kind, target.group) ?? target.kind;
|
|
39
|
-
const kind = target.group
|
|
40
|
-
? `${canonicalKind}.${target.group}`
|
|
41
|
-
: canonicalKind;
|
|
40
|
+
const kind = formatInvestigationKind(target.kind, target.group);
|
|
42
41
|
return `${kind} ${target.namespace ? `${target.namespace}/` : ""}${target.name}`;
|
|
43
42
|
}
|
|
43
|
+
|
|
44
|
+
export function formatInvestigationKind(kind: string, group: string): string {
|
|
45
|
+
const canonicalKind = knownKindForPluralWithGroup(kind, group) ?? kind;
|
|
46
|
+
return groupQualifiesLaneId(group)
|
|
47
|
+
? `${canonicalKind}.${group}`
|
|
48
|
+
: canonicalKind;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface InvestigationOpening extends InvestigationTargetIdentity {
|
|
52
|
+
question?: string;
|
|
53
|
+
namespaces?: string[];
|
|
54
|
+
lookBack?: string;
|
|
55
|
+
askedAt?: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// When a run's question was first asked: its own start, unless it re-ran or
|
|
59
|
+
// narrowed an earlier question. A run built from it keeps that time, so its
|
|
60
|
+
// look-back still covers the incident the engineer described.
|
|
61
|
+
// Radar accepts an asking time from the last 30 days; an older question is
|
|
62
|
+
// asked again from now rather than refused.
|
|
63
|
+
const ASKED_AT_LIMIT_MS = 29 * 24 * 60 * 60 * 1000;
|
|
64
|
+
|
|
65
|
+
export function questionAskedAt(
|
|
66
|
+
run: InvestigationOpening & { createdAt: string },
|
|
67
|
+
now = Date.now(),
|
|
68
|
+
): string | undefined {
|
|
69
|
+
if (!run.question) return undefined;
|
|
70
|
+
const askedAt = run.askedAt ?? run.createdAt;
|
|
71
|
+
const age = now - Date.parse(askedAt);
|
|
72
|
+
return age >= 0 && age < ASKED_AT_LIMIT_MS ? askedAt : undefined;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// A run opened by a question alone has no resource: no Apply, no
|
|
76
|
+
// per-resource "running" badge, and its question is its title.
|
|
77
|
+
export function isQuestionOnly(run: InvestigationOpening): boolean {
|
|
78
|
+
return !run.name && !!run.question;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// The question's own words name a question-only run; a run about a resource
|
|
82
|
+
// is named by the resource even when it started with a question, because the
|
|
83
|
+
// resource is what a reader scanning the history recognises.
|
|
84
|
+
export function formatInvestigationTitle(run: InvestigationOpening): string {
|
|
85
|
+
return isQuestionOnly(run)
|
|
86
|
+
? (run.question ?? "").replace(/\s+/g, " ").trim()
|
|
87
|
+
: formatInvestigationTarget(run);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Where and since when a question said to start, in the words the composer's
|
|
91
|
+
// chips use: "shop, payments · last 1h".
|
|
92
|
+
// A run carrying an earlier asking time looks back from then, not from now,
|
|
93
|
+
// so it says when: "shop · 1h before Oct 27, 3:04 PM".
|
|
94
|
+
export function formatQuestionScope(
|
|
95
|
+
run: InvestigationOpening,
|
|
96
|
+
now = new Date(),
|
|
97
|
+
): string {
|
|
98
|
+
const where = run.namespaces?.length
|
|
99
|
+
? run.namespaces.join(", ")
|
|
100
|
+
: "All namespaces";
|
|
101
|
+
if (!run.lookBack) return where;
|
|
102
|
+
const asked = run.askedAt ? new Date(run.askedAt) : null;
|
|
103
|
+
if (!asked || Number.isNaN(asked.getTime())) {
|
|
104
|
+
return `${where} · last ${run.lookBack}`;
|
|
105
|
+
}
|
|
106
|
+
const sameDay = asked.toDateString() === now.toDateString();
|
|
107
|
+
const when = asked.toLocaleString(undefined, {
|
|
108
|
+
...(sameDay ? {} : { month: "short", day: "numeric" }),
|
|
109
|
+
hour: "numeric",
|
|
110
|
+
minute: "2-digit",
|
|
111
|
+
});
|
|
112
|
+
return `${where} · ${run.lookBack} before ${when}`;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Investigate again: a new session about the same thing, started the same
|
|
116
|
+
// way. It carries the issue and the question forward and nothing the earlier
|
|
117
|
+
// run found — being handed the previous answer is the one thing someone
|
|
118
|
+
// clicking it doesn't want.
|
|
119
|
+
export function rerunOpening(
|
|
120
|
+
run: InvestigationOpening & { issueId?: string; createdAt: string },
|
|
121
|
+
now = Date.now(),
|
|
122
|
+
): InvestigationOpening & { issueId?: string; fresh: true } {
|
|
123
|
+
return {
|
|
124
|
+
kind: run.kind,
|
|
125
|
+
group: run.group,
|
|
126
|
+
namespace: run.namespace,
|
|
127
|
+
name: run.name,
|
|
128
|
+
issueId: run.issueId,
|
|
129
|
+
fresh: true,
|
|
130
|
+
question: run.question,
|
|
131
|
+
namespaces: run.namespaces,
|
|
132
|
+
lookBack: run.lookBack,
|
|
133
|
+
askedAt: questionAskedAt(run, now),
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Callers name kinds every way Kubernetes accepts: a route's plural
|
|
138
|
+
// (deployments), an agent's lowercase singular (deployment), or the Kind.
|
|
139
|
+
// A resource someone will read about is named by its Kind.
|
|
140
|
+
export function canonicalKind(kind: string, group: string): string {
|
|
141
|
+
// Resolve within the group first: metrics.k8s.io's "pods" are PodMetrics,
|
|
142
|
+
// not Pods.
|
|
143
|
+
const plural = kindToPluralWithGroup(kind, group);
|
|
144
|
+
return knownKindForPluralWithGroup(plural, group) ?? pluralToKind(plural);
|
|
145
|
+
}
|