@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
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
|
|
4
|
+
import { VerdictText } from "./AssessmentCard";
|
|
5
|
+
import {
|
|
6
|
+
assessmentStateLabel,
|
|
7
|
+
plainVerdictText,
|
|
8
|
+
verdictSentence,
|
|
9
|
+
} from "./verdictText";
|
|
10
|
+
|
|
11
|
+
describe("VerdictText", () => {
|
|
12
|
+
it("renders code spans and nothing else as markup", () => {
|
|
13
|
+
const html = renderToStaticMarkup(
|
|
14
|
+
<VerdictText text="ConfigMap `checkout-settings` is **missing**" />,
|
|
15
|
+
);
|
|
16
|
+
expect(html).toBe(
|
|
17
|
+
'ConfigMap <code class="inline-code">checkout-settings</code> is missing',
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("keeps code contents exactly as written", () => {
|
|
22
|
+
expect(
|
|
23
|
+
renderToStaticMarkup(
|
|
24
|
+
<VerdictText text="`__init__` fails on `*.svc.*` and `[a-z](x)`" />,
|
|
25
|
+
),
|
|
26
|
+
).toBe(
|
|
27
|
+
'<code class="inline-code">__init__</code> fails on <code class="inline-code">*.svc.*</code> and <code class="inline-code">[a-z](x)</code>',
|
|
28
|
+
);
|
|
29
|
+
expect(plainVerdictText("`__init__` fails on `*.svc.*`")).toBe(
|
|
30
|
+
"__init__ fails on *.svc.*",
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("keeps a sentence that looks like markdown structure as text", () => {
|
|
35
|
+
expect(
|
|
36
|
+
renderToStaticMarkup(<VerdictText text="1. pod restarts # times" />),
|
|
37
|
+
).toBe("1. pod restarts # times");
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe("verdictSentence", () => {
|
|
42
|
+
it("is the headline, as one plain line", () => {
|
|
43
|
+
expect(
|
|
44
|
+
verdictSentence({
|
|
45
|
+
summary: "The `api` container\nexits; see [logs](http://x)",
|
|
46
|
+
rootCause: "ignored",
|
|
47
|
+
}),
|
|
48
|
+
).toBe("The api container exits; see logs");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("keeps doubled underscores in prose identifiers", () => {
|
|
52
|
+
expect(plainVerdictText("checkout__config is unset")).toBe(
|
|
53
|
+
"checkout__config is unset",
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("falls back to the cause, and is empty for an answer", () => {
|
|
58
|
+
expect(
|
|
59
|
+
verdictSentence({ summary: " ", rootCause: "DB_PORT is bad" }),
|
|
60
|
+
).toBe("DB_PORT is bad");
|
|
61
|
+
expect(verdictSentence({ rootCause: "DB_PORT is `abc`" })).toBe(
|
|
62
|
+
"DB_PORT is abc",
|
|
63
|
+
);
|
|
64
|
+
expect(verdictSentence({})).toBe("");
|
|
65
|
+
expect(plainVerdictText(undefined)).toBe("");
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe("assessmentStateLabel", () => {
|
|
70
|
+
it("says how sure the assessment is, as Findings does", () => {
|
|
71
|
+
expect(
|
|
72
|
+
assessmentStateLabel({ rootCause: "x", certainty: "suspected" })?.text,
|
|
73
|
+
).toBe("Suspected");
|
|
74
|
+
expect(assessmentStateLabel({ inconclusive: true })?.text).toBe(
|
|
75
|
+
"Couldn't determine",
|
|
76
|
+
);
|
|
77
|
+
expect(assessmentStateLabel({ healthy: true })).toEqual({
|
|
78
|
+
text: "Healthy",
|
|
79
|
+
warn: false,
|
|
80
|
+
});
|
|
81
|
+
expect(assessmentStateLabel({ healthy: true }, true)).toEqual({
|
|
82
|
+
text: "Conflicts with captured evidence",
|
|
83
|
+
warn: true,
|
|
84
|
+
});
|
|
85
|
+
expect(assessmentStateLabel({ rootCause: "x" })).toBeUndefined();
|
|
86
|
+
});
|
|
87
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Diagnosis } from "../../api/diagnose";
|
|
2
|
+
import { CERTAINTY_LABEL } from "./assessmentCopy";
|
|
3
|
+
|
|
4
|
+
// A code span is literal: its contents (`__init__`, `*.svc.*`) are never
|
|
5
|
+
// read as markdown. Splitting on it first keeps cleanup to the prose.
|
|
6
|
+
const CODE_SPAN = /(`[^`\n]+`)/g;
|
|
7
|
+
|
|
8
|
+
function isCodeSpan(part: string): boolean {
|
|
9
|
+
return part.length > 2 && part.startsWith("`") && part.endsWith("`");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type VerdictPart = { code: boolean; text: string };
|
|
13
|
+
|
|
14
|
+
// A verdict split into prose and literal code, prose with its bold and
|
|
15
|
+
// single-character emphasis markers dropped. Doubled underscores stay: in a
|
|
16
|
+
// verdict they are far more often an identifier (checkout__config) than
|
|
17
|
+
// markdown. Shared by every place that shows a verdict sentence.
|
|
18
|
+
export function verdictParts(text: string): VerdictPart[] {
|
|
19
|
+
return text.split(CODE_SPAN).flatMap((part): VerdictPart[] => {
|
|
20
|
+
if (isCodeSpan(part)) return [{ code: true, text: part.slice(1, -1) }];
|
|
21
|
+
const prose = part
|
|
22
|
+
.replace(/\[([^\]]*)\]\([^)]*\)/g, "$1")
|
|
23
|
+
.replace(/\*\*/g, "")
|
|
24
|
+
.replace(/(^|\W)[*_](\S(?:[^*_\n]*\S)?)[*_](?=\W|$)/g, "$1$2");
|
|
25
|
+
return prose ? [{ code: false, text: prose }] : [];
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// A verdict as one plain line, for places that show it outside Findings: the
|
|
30
|
+
// history and the completion card. Markdown links keep their text; emphasis
|
|
31
|
+
// markers are dropped and code keeps its exact contents.
|
|
32
|
+
export function plainVerdictText(text: string | undefined): string {
|
|
33
|
+
return verdictParts(text ?? "")
|
|
34
|
+
.map((part) => part.text)
|
|
35
|
+
.join("")
|
|
36
|
+
.replace(/\s+/g, " ")
|
|
37
|
+
.trim();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// The sentence a finished assessment stands on: its headline when it has
|
|
41
|
+
// one, else the technical cause. Empty for an answer that settled nothing.
|
|
42
|
+
export function verdictSentence(diagnosis: {
|
|
43
|
+
summary?: string;
|
|
44
|
+
rootCause?: string;
|
|
45
|
+
}): string {
|
|
46
|
+
return plainVerdictText(diagnosis.summary?.trim() || diagnosis.rootCause);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// How sure the assessment is, in the words Findings shows beside it, so a
|
|
50
|
+
// sentence repeated elsewhere never reads more certain than Findings does.
|
|
51
|
+
export function assessmentStateLabel(
|
|
52
|
+
diagnosis: Partial<
|
|
53
|
+
Pick<Diagnosis, "inconclusive" | "healthy" | "rootCause" | "certainty">
|
|
54
|
+
>,
|
|
55
|
+
evidenceConflict = false,
|
|
56
|
+
): { text: string; warn: boolean } | undefined {
|
|
57
|
+
if (diagnosis.inconclusive && !diagnosis.rootCause) {
|
|
58
|
+
return { text: "Couldn't determine", warn: false };
|
|
59
|
+
}
|
|
60
|
+
if (diagnosis.healthy && !diagnosis.rootCause) {
|
|
61
|
+
return evidenceConflict
|
|
62
|
+
? { text: "Conflicts with captured evidence", warn: true }
|
|
63
|
+
: { text: "Healthy", warn: false };
|
|
64
|
+
}
|
|
65
|
+
return diagnosis.certainty
|
|
66
|
+
? { text: CERTAINTY_LABEL[diagnosis.certainty], warn: false }
|
|
67
|
+
: undefined;
|
|
68
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
2
|
import type { DashboardResponse, DashboardMetrics, DashboardCRDCount } from '../../api/client'
|
|
3
3
|
import { HealthRing } from './HealthRing'
|
|
4
4
|
import {
|
|
5
5
|
AlertTriangle, CheckCircle, XCircle,
|
|
6
6
|
Cpu, MemoryStick, Database, Container, Globe, Network as NetworkIcon, Briefcase, Clock,
|
|
7
|
-
ArrowRight, Server, Boxes, Shield,
|
|
7
|
+
ArrowRight, Server, Boxes, Shield, Info,
|
|
8
8
|
} from 'lucide-react'
|
|
9
9
|
import { clsx } from 'clsx'
|
|
10
10
|
import { formatCPUMillicores, formatMemoryMiB } from '../../utils/format'
|
|
11
11
|
import { useCapabilitiesContext } from '../../contexts/CapabilitiesContext'
|
|
12
|
-
import {
|
|
12
|
+
import { HomeAgentBlock } from './HomeAgentBlock'
|
|
13
13
|
import { assetUrl, pluralize, parseContextName } from '@skyhook-io/k8s-ui'
|
|
14
14
|
import { Tooltip } from '../ui/Tooltip'
|
|
15
15
|
import { mcpEndpointUrl } from '../../api/config'
|
|
@@ -148,7 +148,6 @@ export function ClusterHealthCard({
|
|
|
148
148
|
}: ClusterHealthCardProps) {
|
|
149
149
|
void _topCRDs // Reserved for future CRD display
|
|
150
150
|
|
|
151
|
-
const [mcpDialogOpen, setMcpDialogOpen] = useState(false)
|
|
152
151
|
const caps = useCapabilitiesContext()
|
|
153
152
|
// Default to local mode when the backend doesn't ship a `deployment`
|
|
154
153
|
// field (older Radar binaries pre-0.2.2). Local rendering is the safe
|
|
@@ -275,17 +274,6 @@ export function ClusterHealthCard({
|
|
|
275
274
|
)}
|
|
276
275
|
{radarVersion}
|
|
277
276
|
<span><span className="font-mono">{counts.namespaces}</span> namespaces</span>
|
|
278
|
-
{/* Show raw kubeconfig context as muted metadata only when
|
|
279
|
-
it differs from the headline AND we're in local mode
|
|
280
|
-
(in-cluster has no meaningful context name, cloud
|
|
281
|
-
shell already renders the canonical name). */}
|
|
282
|
-
{cluster.name && cluster.name !== headlineName && deployment.mode === 'local' && (
|
|
283
|
-
<Tooltip content={cluster.name}>
|
|
284
|
-
<span className="font-mono text-[10px] text-theme-text-disabled break-all leading-snug pt-0.5">
|
|
285
|
-
{cluster.name}
|
|
286
|
-
</span>
|
|
287
|
-
</Tooltip>
|
|
288
|
-
)}
|
|
289
277
|
</div>
|
|
290
278
|
{freshness && <div className="mt-2">{freshness}</div>}
|
|
291
279
|
{nodeVersionSkew && (
|
|
@@ -311,28 +299,12 @@ export function ClusterHealthCard({
|
|
|
311
299
|
</span>
|
|
312
300
|
</Tooltip>
|
|
313
301
|
)}
|
|
314
|
-
{/*
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
would mislead a Cloud user. */}
|
|
302
|
+
{/* OSS-only: in Cloud, MCP discovery lives at the hub level
|
|
303
|
+
(org-wide endpoint, PAT-authed) rather than per-cluster, so this
|
|
304
|
+
localhost/no-auth entry would mislead a Cloud user. */}
|
|
318
305
|
{showLocalMcpCard && (
|
|
319
|
-
<
|
|
320
|
-
onClick={() => setMcpDialogOpen(true)}
|
|
321
|
-
className="flex items-center gap-2 mt-3 px-2.5 py-2 bg-purple-500/5 hover:bg-purple-500/10 border border-purple-500/20 rounded-md transition-colors w-full"
|
|
322
|
-
>
|
|
323
|
-
<Radio className="w-3.5 h-3.5 text-purple-400 animate-pulse shrink-0" />
|
|
324
|
-
<div className="flex flex-col gap-0.5 min-w-0 flex-1 text-left">
|
|
325
|
-
<span className="text-xs font-medium text-purple-400">{caps.mcpReadOnly ? 'MCP Server Live (read-only)' : 'MCP Server Live'}</span>
|
|
326
|
-
<Tooltip content={mcpUrl} wrapperClassName="min-w-0">
|
|
327
|
-
<span className="text-[10px] text-theme-text-tertiary truncate font-mono">
|
|
328
|
-
HTTP · {mcpUrl}
|
|
329
|
-
</span>
|
|
330
|
-
</Tooltip>
|
|
331
|
-
</div>
|
|
332
|
-
<Info className="w-3.5 h-3.5 text-purple-400/60 shrink-0" />
|
|
333
|
-
</button>
|
|
306
|
+
<HomeAgentBlock mcpUrl={mcpUrl} readOnly={caps.mcpReadOnly} execTools={caps.mcpExecTools} />
|
|
334
307
|
)}
|
|
335
|
-
<MCPSetupDialog open={mcpDialogOpen} onClose={() => setMcpDialogOpen(false)} mcpUrl={mcpUrl} readOnly={caps.mcpReadOnly} execTools={caps.mcpExecTools} />
|
|
336
308
|
</div>
|
|
337
309
|
|
|
338
310
|
{/* Center: Three health rings */}
|
|
@@ -578,15 +550,17 @@ function KubernetesVersionLine({
|
|
|
578
550
|
}
|
|
579
551
|
wrapperClassName="w-fit"
|
|
580
552
|
>
|
|
553
|
+
{/* Inline text, not flex: flex items shrink and wrap separately, which
|
|
554
|
+
splits a long distribution version and the link into two columns. */}
|
|
581
555
|
<button
|
|
582
556
|
onClick={onNavigate}
|
|
583
|
-
className="group
|
|
557
|
+
className="group text-left hover:text-theme-text-secondary transition-colors"
|
|
584
558
|
>
|
|
585
|
-
|
|
559
|
+
Kubernetes {version}
|
|
586
560
|
{behind > 0 && (
|
|
587
|
-
<span
|
|
561
|
+
<> · <span className="whitespace-nowrap">Upgrade impact</span></>
|
|
588
562
|
)}
|
|
589
|
-
<ArrowRight className="w-3 h-3 opacity-0 group-hover:opacity-100 transition-opacity" />
|
|
563
|
+
<ArrowRight className="inline-block w-3 h-3 ml-1 align-[-2px] opacity-0 group-hover:opacity-100 transition-opacity" />
|
|
590
564
|
</button>
|
|
591
565
|
</Tooltip>
|
|
592
566
|
)
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
5
|
+
import { HomeAgentBlock } from './HomeAgentBlock'
|
|
6
|
+
|
|
7
|
+
const diagnose = vi.hoisted(() => ({ current: {} as Record<string, unknown> }))
|
|
8
|
+
const nav = vi.hoisted(() => ({ embedded: false }))
|
|
9
|
+
|
|
10
|
+
vi.mock('../diagnose/DiagnoseContext', () => ({ useDiagnose: () => diagnose.current }))
|
|
11
|
+
vi.mock('../../context/NavCustomization', () => ({ useNavCustomization: () => nav }))
|
|
12
|
+
vi.mock('./MCPSetupDialog', () => ({
|
|
13
|
+
MCPSetupDialog: ({ open, readOnly }: { open: boolean; readOnly?: boolean }) =>
|
|
14
|
+
open ? <div data-testid="mcp-dialog">{readOnly ? 'read-only' : 'full'}</div> : null,
|
|
15
|
+
}))
|
|
16
|
+
|
|
17
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
18
|
+
let root: Root
|
|
19
|
+
let host: HTMLDivElement
|
|
20
|
+
|
|
21
|
+
function setDiagnose(overrides: Record<string, unknown>) {
|
|
22
|
+
diagnose.current = {
|
|
23
|
+
available: true,
|
|
24
|
+
setupState: 'ready',
|
|
25
|
+
agentLabel: 'Claude Code',
|
|
26
|
+
hosted: false,
|
|
27
|
+
questions: true,
|
|
28
|
+
cliOverride: false,
|
|
29
|
+
openQuestion: vi.fn(),
|
|
30
|
+
openWorkspace: vi.fn(),
|
|
31
|
+
openHome: vi.fn(),
|
|
32
|
+
...overrides,
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function render(props: { readOnly?: boolean } = {}) {
|
|
37
|
+
act(() => {
|
|
38
|
+
root.render(<HomeAgentBlock mcpUrl="http://localhost:9280/mcp" {...props} />)
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const button = (name: RegExp) =>
|
|
43
|
+
[...host.querySelectorAll('button')].find((b) => name.test(b.textContent ?? ''))
|
|
44
|
+
|
|
45
|
+
beforeEach(() => {
|
|
46
|
+
nav.embedded = false
|
|
47
|
+
setDiagnose({})
|
|
48
|
+
host = document.createElement('div')
|
|
49
|
+
document.body.appendChild(host)
|
|
50
|
+
root = createRoot(host)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
afterEach(() => {
|
|
54
|
+
act(() => root.unmount())
|
|
55
|
+
host.remove()
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
describe('HomeAgentBlock', () => {
|
|
59
|
+
it('names the agent and opens the question composer', () => {
|
|
60
|
+
render()
|
|
61
|
+
const ask = button(/Ask Claude Code about this cluster/)
|
|
62
|
+
expect(ask).toBeTruthy()
|
|
63
|
+
act(() => ask!.click())
|
|
64
|
+
expect(diagnose.current.openQuestion).toHaveBeenCalledWith({})
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it('opens investigations when the backend does not take questions', () => {
|
|
68
|
+
setDiagnose({ questions: false, agentLabel: 'Codex' })
|
|
69
|
+
render()
|
|
70
|
+
act(() => button(/Investigate with Codex/)!.click())
|
|
71
|
+
expect(diagnose.current.openWorkspace).toHaveBeenCalled()
|
|
72
|
+
expect(diagnose.current.openQuestion).not.toHaveBeenCalled()
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it('offers agent setup when no agent is installed', () => {
|
|
76
|
+
setDiagnose({ available: false, setupState: 'needs-install' })
|
|
77
|
+
render()
|
|
78
|
+
expect(button(/Ask/)).toBeUndefined()
|
|
79
|
+
act(() => button(/Set up an agent/)!.click())
|
|
80
|
+
expect(diagnose.current.openHome).toHaveBeenCalled()
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
it('points at the setup notice when an installed agent cannot run', () => {
|
|
84
|
+
setDiagnose({ available: false, setupState: 'needs-restart', cliOverride: true })
|
|
85
|
+
render()
|
|
86
|
+
act(() => button(/Check agent setup/)!.click())
|
|
87
|
+
expect(diagnose.current.openHome).toHaveBeenCalled()
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
it.each(['off', 'unknown'])('shows only the MCP line when investigations are %s here', (setupState) => {
|
|
91
|
+
setDiagnose({ available: false, setupState })
|
|
92
|
+
render()
|
|
93
|
+
expect(button(/Ask|Investigate|Set up|Check agent/)).toBeUndefined()
|
|
94
|
+
expect(host.textContent).toContain('MCP live')
|
|
95
|
+
expect(button(/^Connect$/)).toBeTruthy()
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
it('adds nothing for an embedded host', () => {
|
|
99
|
+
nav.embedded = true
|
|
100
|
+
render()
|
|
101
|
+
expect(button(/Ask|Investigate|Set up/)).toBeUndefined()
|
|
102
|
+
expect(host.textContent).toContain('MCP live')
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
it('keeps the MCP endpoint and opens the setup dialog', () => {
|
|
106
|
+
render({ readOnly: true })
|
|
107
|
+
expect(host.textContent).toContain('MCP live (read-only)')
|
|
108
|
+
expect(host.textContent).toContain('localhost:9280/mcp')
|
|
109
|
+
expect(host.querySelector('[data-testid="mcp-dialog"]')).toBeNull()
|
|
110
|
+
act(() => button(/^Connect$/)!.click())
|
|
111
|
+
expect(host.querySelector('[data-testid="mcp-dialog"]')?.textContent).toBe('read-only')
|
|
112
|
+
})
|
|
113
|
+
})
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { Radio, Sparkles } from 'lucide-react'
|
|
3
|
+
import { useDiagnose } from '../diagnose/DiagnoseContext'
|
|
4
|
+
import { notReadyTooltip } from '../diagnose/LocalDiagnoseAction'
|
|
5
|
+
import { useNavCustomization } from '../../context/NavCustomization'
|
|
6
|
+
import { Tooltip } from '../ui/Tooltip'
|
|
7
|
+
import { MCPSetupDialog } from './MCPSetupDialog'
|
|
8
|
+
|
|
9
|
+
// The Home card's AI entry: start an investigation with the user's own agent,
|
|
10
|
+
// and connect an agent to this Radar's MCP server. The investigation line
|
|
11
|
+
// follows the other AI entry points: hidden where investigations can't run
|
|
12
|
+
// here, a setup prompt when no agent is ready.
|
|
13
|
+
export function HomeAgentBlock({
|
|
14
|
+
mcpUrl,
|
|
15
|
+
readOnly,
|
|
16
|
+
execTools,
|
|
17
|
+
}: {
|
|
18
|
+
mcpUrl: string
|
|
19
|
+
readOnly?: boolean
|
|
20
|
+
execTools?: boolean
|
|
21
|
+
}) {
|
|
22
|
+
const [mcpDialogOpen, setMcpDialogOpen] = useState(false)
|
|
23
|
+
const d = useDiagnose()
|
|
24
|
+
const { embedded } = useNavCustomization()
|
|
25
|
+
const showInvestigate = !embedded && d.setupState !== 'off' && d.setupState !== 'unknown'
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<div className="mt-3 flex flex-col gap-1.5 rounded-md border border-purple-500/20 bg-purple-500/5 p-2">
|
|
29
|
+
{showInvestigate && <InvestigateLine />}
|
|
30
|
+
<div className="flex min-w-0 items-center gap-1.5 text-[11px]">
|
|
31
|
+
<Radio className="h-3 w-3 shrink-0 animate-pulse text-purple-600 dark:text-purple-400" aria-hidden />
|
|
32
|
+
<span className="shrink-0 font-medium text-purple-600 dark:text-purple-400">
|
|
33
|
+
{readOnly ? 'MCP live (read-only)' : 'MCP live'}
|
|
34
|
+
</span>
|
|
35
|
+
<Tooltip content={mcpUrl} wrapperClassName="min-w-0">
|
|
36
|
+
<span className="truncate font-mono text-theme-text-tertiary">{mcpUrl.replace(/^https?:\/\//, '')}</span>
|
|
37
|
+
</Tooltip>
|
|
38
|
+
{/* "Connect your agent" doesn't fit beside the URL in this column;
|
|
39
|
+
the short label keeps the endpoint readable. */}
|
|
40
|
+
<button
|
|
41
|
+
type="button"
|
|
42
|
+
onClick={() => setMcpDialogOpen(true)}
|
|
43
|
+
aria-label="Connect your agent"
|
|
44
|
+
className="ml-auto shrink-0 whitespace-nowrap font-medium text-purple-600 hover:underline dark:text-purple-400"
|
|
45
|
+
>
|
|
46
|
+
Connect
|
|
47
|
+
</button>
|
|
48
|
+
</div>
|
|
49
|
+
<MCPSetupDialog
|
|
50
|
+
open={mcpDialogOpen}
|
|
51
|
+
onClose={() => setMcpDialogOpen(false)}
|
|
52
|
+
mcpUrl={mcpUrl}
|
|
53
|
+
readOnly={readOnly}
|
|
54
|
+
execTools={execTools}
|
|
55
|
+
/>
|
|
56
|
+
</div>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function InvestigateLine() {
|
|
61
|
+
const d = useDiagnose()
|
|
62
|
+
if (!d.available) {
|
|
63
|
+
const label = d.setupState === 'needs-restart' ? 'Check agent setup' : 'Set up an agent'
|
|
64
|
+
return (
|
|
65
|
+
<Tooltip content={notReadyTooltip(d)} wrapperClassName="w-full">
|
|
66
|
+
<button
|
|
67
|
+
type="button"
|
|
68
|
+
onClick={d.openHome}
|
|
69
|
+
className="flex w-full items-center gap-2 rounded px-0.5 text-left text-xs font-medium text-purple-600 hover:underline dark:text-purple-400"
|
|
70
|
+
>
|
|
71
|
+
<Sparkles className="h-3.5 w-3.5 shrink-0" aria-hidden />
|
|
72
|
+
{label}
|
|
73
|
+
</button>
|
|
74
|
+
</Tooltip>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
const where = d.hosted ? `powered by ${d.agentLabel}` : `runs your own ${d.agentLabel} locally`
|
|
78
|
+
return (
|
|
79
|
+
<Tooltip content={`Start an AI investigation — ${where}`} wrapperClassName="w-full">
|
|
80
|
+
<button
|
|
81
|
+
type="button"
|
|
82
|
+
// Opens the investigations panel's question composer, focused: the
|
|
83
|
+
// composer is where the scope and look-back are chosen before a run.
|
|
84
|
+
onClick={() => (d.questions ? d.openQuestion({}) : d.openWorkspace())}
|
|
85
|
+
className="flex w-full items-center gap-2 rounded border border-theme-border bg-theme-surface px-2 py-1.5 text-left text-xs text-theme-text-tertiary transition-colors hover:border-purple-500/40 hover:text-theme-text-secondary"
|
|
86
|
+
>
|
|
87
|
+
<Sparkles className="h-3.5 w-3.5 shrink-0 text-purple-600 dark:text-purple-400" aria-hidden />
|
|
88
|
+
<span className="truncate">
|
|
89
|
+
{d.questions ? `Ask ${d.agentLabel} about this cluster…` : `Investigate with ${d.agentLabel}`}
|
|
90
|
+
</span>
|
|
91
|
+
</button>
|
|
92
|
+
</Tooltip>
|
|
93
|
+
)
|
|
94
|
+
}
|
|
@@ -54,11 +54,9 @@ interface HomeViewProps {
|
|
|
54
54
|
onNavigateToUpgradeImpact?: () => void
|
|
55
55
|
onNavigateToHelmRelease?: (namespace: string, release: string) => void
|
|
56
56
|
onNavigateToManagerPath?: (path: string) => void
|
|
57
|
-
// Present only when release notes exist for this version.
|
|
58
|
-
onShowWhatsNew?: () => void
|
|
59
57
|
}
|
|
60
58
|
|
|
61
|
-
export function HomeView({ namespaces, topology, fallbackClusterLoadState, onNavigateToView, onNavigateToResourceKind, onNavigateToResource, onNavigateToCerts, onNavigateToUpgradeImpact, onNavigateToHelmRelease, onNavigateToManagerPath
|
|
59
|
+
export function HomeView({ namespaces, topology, fallbackClusterLoadState, onNavigateToView, onNavigateToResourceKind, onNavigateToResource, onNavigateToCerts, onNavigateToUpgradeImpact, onNavigateToHelmRelease, onNavigateToManagerPath }: HomeViewProps) {
|
|
62
60
|
// The card itself decides whether the cluster has a capacity story
|
|
63
61
|
// (available, softened-denied, or karpenterless-with-managers/groups) and
|
|
64
62
|
// returns null otherwise — the outer gate only excludes states with nothing
|
|
@@ -142,11 +140,12 @@ export function HomeView({ namespaces, topology, fallbackClusterLoadState, onNav
|
|
|
142
140
|
)}
|
|
143
141
|
{/* Row 1: Cluster Health Card (combined health + resource counts) */}
|
|
144
142
|
<ClusterHealthCard
|
|
145
|
-
|
|
143
|
+
// A local install shows its version in Settings and upgrades through
|
|
144
|
+
// the update notification; an in-cluster one is upgraded by whoever
|
|
145
|
+
// manages it, and this line is where they confirm the new version.
|
|
146
|
+
radarVersion={versionInfo && deploymentMode === 'in-cluster' ? (
|
|
146
147
|
<RadarVersionLine
|
|
147
148
|
version={versionInfo}
|
|
148
|
-
showUpgrade={deploymentMode === 'in-cluster'}
|
|
149
|
-
onShowWhatsNew={onShowWhatsNew}
|
|
150
149
|
manager={installationManager}
|
|
151
150
|
managerLoading={installationManagerLoading}
|
|
152
151
|
onNavigateToHelmRelease={onNavigateToHelmRelease}
|
|
@@ -142,18 +142,4 @@ describe('RadarVersionLine', () => {
|
|
|
142
142
|
expect(html).toContain('Open the in-cluster upgrade instructions and apply the change through GitOps')
|
|
143
143
|
expect(html).not.toContain('Open it to upgrade through GitOps')
|
|
144
144
|
})
|
|
145
|
-
|
|
146
|
-
it('offers What\'s new only when the host can open it', () => {
|
|
147
|
-
const upToDate = { ...version, latestVersion: '1.2.3', updateAvailable: false }
|
|
148
|
-
expect(renderToString(<RadarVersionLine version={upToDate} />)).not.toContain('What's new')
|
|
149
|
-
expect(renderToString(<RadarVersionLine version={upToDate} onShowWhatsNew={() => {}} />)).toContain('What's new')
|
|
150
|
-
expect(renderToString(<RadarVersionLine version={version} onShowWhatsNew={() => {}} />)).toContain('What's new')
|
|
151
|
-
})
|
|
152
|
-
|
|
153
|
-
it('hides upgrade guidance when the host handles upgrades elsewhere', () => {
|
|
154
|
-
const html = renderToString(<RadarVersionLine version={version} showUpgrade={false} onShowWhatsNew={() => {}} />)
|
|
155
|
-
expect(html).toContain('v1.2.3')
|
|
156
|
-
expect(html).not.toContain('available')
|
|
157
|
-
expect(html).toContain('What's new')
|
|
158
|
-
})
|
|
159
145
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArrowUpCircle
|
|
1
|
+
import { ArrowUpCircle } from 'lucide-react'
|
|
2
2
|
import { gitOpsRouteForResource } from '@skyhook-io/k8s-ui'
|
|
3
3
|
import type { CloudConnectSelf, VersionInfo } from '../../api/client'
|
|
4
4
|
import {
|
|
@@ -14,10 +14,6 @@ interface RadarVersionLineProps {
|
|
|
14
14
|
managerLoading?: boolean
|
|
15
15
|
onNavigateToHelmRelease?: (namespace: string, release: string) => void
|
|
16
16
|
onNavigateToGitOps?: (path: string) => void
|
|
17
|
-
// Local installs upgrade through the update notification, and this line's
|
|
18
|
-
// upgrade link points at in-cluster instructions.
|
|
19
|
-
showUpgrade?: boolean
|
|
20
|
-
onShowWhatsNew?: () => void
|
|
21
17
|
}
|
|
22
18
|
|
|
23
19
|
function displayVersion(version: string): string {
|
|
@@ -30,33 +26,13 @@ export function RadarVersionLine({
|
|
|
30
26
|
managerLoading = false,
|
|
31
27
|
onNavigateToHelmRelease,
|
|
32
28
|
onNavigateToGitOps,
|
|
33
|
-
showUpgrade: upgradeAllowed = true,
|
|
34
|
-
onShowWhatsNew,
|
|
35
29
|
}: RadarVersionLineProps) {
|
|
36
30
|
const latestVersion = version.latestVersion
|
|
37
31
|
const updateStatus = getVersionUpdateStatus(version.currentVersion, latestVersion)
|
|
38
|
-
const showUpgrade =
|
|
39
|
-
const whatsNew = onShowWhatsNew && (
|
|
40
|
-
<span className="inline-flex items-center gap-1">
|
|
41
|
-
<span aria-hidden>·</span>
|
|
42
|
-
<button
|
|
43
|
-
type="button"
|
|
44
|
-
onClick={onShowWhatsNew}
|
|
45
|
-
className="inline-flex items-center gap-1 text-accent-text hover:text-accent transition-colors"
|
|
46
|
-
>
|
|
47
|
-
<Megaphone className="h-3.5 w-3.5 shrink-0" aria-hidden />
|
|
48
|
-
What's new
|
|
49
|
-
</button>
|
|
50
|
-
</span>
|
|
51
|
-
)
|
|
32
|
+
const showUpgrade = version.updateAvailable && !!latestVersion && updateStatus.tier !== 'none'
|
|
52
33
|
|
|
53
34
|
if (!showUpgrade) {
|
|
54
|
-
return (
|
|
55
|
-
<span className="inline-flex flex-wrap items-center gap-x-1">
|
|
56
|
-
<span>Radar <span className="font-mono">{displayVersion(version.currentVersion)}</span></span>
|
|
57
|
-
{whatsNew}
|
|
58
|
-
</span>
|
|
59
|
-
)
|
|
35
|
+
return <span>Radar <span className="font-mono">{displayVersion(version.currentVersion)}</span></span>
|
|
60
36
|
}
|
|
61
37
|
|
|
62
38
|
const controller = manager?.controllerRef
|
|
@@ -135,7 +111,6 @@ export function RadarVersionLine({
|
|
|
135
111
|
{action}
|
|
136
112
|
</Tooltip>
|
|
137
113
|
</span>
|
|
138
|
-
{whatsNew}
|
|
139
114
|
</span>
|
|
140
115
|
)
|
|
141
116
|
}
|