@skyhook-io/radar-app 1.19.0 → 1.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +5 -5
- package/src/App.tsx +31 -5
- package/src/api/application-evidence.ts +63 -0
- package/src/api/argoSync.test.ts +22 -0
- package/src/api/client.audit-gating.test.tsx +48 -0
- package/src/api/client.kueuePosition.test.ts +32 -0
- package/src/api/client.kueueQueueWorkloads.test.tsx +71 -0
- package/src/api/client.resource-identity.test.ts +3 -0
- package/src/api/client.resourceIssues.test.tsx +239 -0
- package/src/api/client.resourcePath.test.ts +3 -0
- package/src/api/client.ts +285 -55
- package/src/api/config.ts +21 -0
- package/src/api/diagnose.ts +4 -0
- package/src/api/radarFeatures.render.test.tsx +33 -1
- package/src/api/radarFeatures.test.ts +47 -0
- package/src/api/radarFeatures.ts +40 -1
- package/src/api/rbac.settled.test.tsx +42 -0
- package/src/api/rbac.test.ts +18 -0
- package/src/api/rbac.ts +37 -7
- package/src/api/traffic.ts +9 -4
- package/src/api/usage-data.fixtures.ts +3 -1
- package/src/api/usage-data.test.tsx +134 -0
- package/src/api/usage-data.ts +35 -7
- package/src/api/workloadPodsPolling.test.ts +26 -0
- package/src/components/CloudConnectFlow.test.tsx +86 -0
- package/src/components/CloudConnectFlow.tsx +65 -27
- package/src/components/CloudFunnelButton.test.tsx +140 -5
- package/src/components/CloudFunnelButton.tsx +50 -9
- package/src/components/ConnectionErrorView.test.tsx +34 -0
- package/src/components/ConnectionErrorView.tsx +35 -11
- package/src/components/ContextSwitcher.tsx +5 -2
- package/src/components/SwitchAwareConnectionError.test.tsx +43 -0
- package/src/components/SwitchAwareConnectionError.tsx +85 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.flow.test.tsx +234 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.test.tsx +144 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.tsx +218 -0
- package/src/components/capacity/CapacityDemand.tsx +3 -2
- package/src/components/capacity/demandSummary.test.ts +38 -0
- package/src/components/capacity/shared.tsx +12 -1
- package/src/components/cost/ApplicationCostTab.tsx +4 -0
- package/src/components/cost/CostTrendChart.tsx +2 -0
- package/src/components/cost/WorkloadCostTab.tsx +4 -0
- package/src/components/cost/source.test.ts +5 -0
- package/src/components/cost/source.ts +11 -0
- package/src/components/diagnose/AIMarkdown.tsx +3 -0
- package/src/components/diagnose/AgentSetupNotice.test.tsx +17 -0
- package/src/components/diagnose/AgentSetupNotice.tsx +21 -3
- package/src/components/diagnose/ContinueInAgentButton.mounted.test.tsx +182 -0
- package/src/components/diagnose/ContinueInAgentButton.test.tsx +128 -0
- package/src/components/diagnose/ContinueInAgentButton.tsx +303 -0
- package/src/components/diagnose/DiagnoseContext.question.test.tsx +1 -1
- package/src/components/diagnose/DiagnoseContext.tsx +68 -2
- package/src/components/diagnose/DiagnoseSurface.tsx +58 -113
- package/src/components/diagnose/ExampleInvestigationLink.tsx +20 -0
- package/src/components/diagnose/Home.test.tsx +26 -0
- package/src/components/diagnose/Home.tsx +20 -1
- package/src/components/diagnose/InvestigationEvidenceSections.tsx +45 -22
- package/src/components/diagnose/InvestigationView.tsx +94 -26
- package/src/components/diagnose/LocalDiagnoseAction.history.test.tsx +450 -0
- package/src/components/diagnose/LocalDiagnoseAction.tsx +354 -35
- package/src/components/diagnose/NextStepJump.test.tsx +92 -0
- package/src/components/diagnose/NextStepJump.tsx +75 -0
- package/src/components/diagnose/QuestionComposer.tsx +8 -0
- package/src/components/diagnose/exampleInvestigation.events.json +191 -0
- package/src/components/diagnose/exampleInvestigation.loadFailure.test.tsx +94 -0
- package/src/components/diagnose/exampleInvestigation.test.tsx +248 -0
- package/src/components/diagnose/exampleInvestigation.ts +121 -0
- package/src/components/diagnose/investigationCase.test.tsx +9 -1
- package/src/components/diagnose/investigationEvidence/adapters/applicationFindings.test.ts +739 -0
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +50 -2
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +9 -0
- package/src/components/diagnose/investigationEvidence/builder.ts +30 -0
- package/src/components/diagnose/investigationEvidence/observations.ts +121 -2
- package/src/components/diagnose/investigationEvidence/projection.test.ts +85 -3
- package/src/components/diagnose/investigationEvidence/types.ts +5 -0
- package/src/components/diagnose/investigationState.ts +28 -0
- package/src/components/diagnose/lastInvestigation.test.ts +95 -0
- package/src/components/diagnose/lastInvestigation.ts +58 -0
- package/src/components/diagnose/launch.test.ts +125 -1
- package/src/components/diagnose/launch.ts +57 -10
- package/src/components/diagnose/toolCallLabel.test.ts +10 -4
- package/src/components/execution/BatchExecutionView.tsx +24 -11
- package/src/components/execution/JobSetAdmission.test.tsx +42 -0
- package/src/components/execution/JobSetAdmission.tsx +18 -3
- package/src/components/execution/JobSetMemberComparison.tsx +2 -1
- package/src/components/execution/runState.test.ts +14 -0
- package/src/components/execution/runState.ts +8 -0
- package/src/components/gitops/GitOpsView.rollbackGate.test.tsx +202 -0
- package/src/components/gitops/GitOpsView.syncRequest.test.tsx +369 -0
- package/src/components/gitops/GitOpsView.tsx +86 -17
- package/src/components/gitops/RemoteDestinationCloudHint.tsx +2 -3
- package/src/components/gitops/destination-toast.test.ts +1 -1
- package/src/components/gitops/destination-toast.ts +2 -2
- package/src/components/home/ClusterHealthCard.tsx +1 -1
- package/src/components/home/HomeAgentBlock.test.tsx +31 -3
- package/src/components/home/HomeAgentBlock.tsx +13 -4
- package/src/components/home/HomeDiagramCard.tsx +47 -0
- package/src/components/home/HomeView.tsx +81 -41
- package/src/components/home/MCPSetupDialog.test.tsx +95 -5
- package/src/components/home/MCPSetupDialog.tsx +30 -5
- package/src/components/home/ProblemsPanel.investigate.test.tsx +171 -0
- package/src/components/home/ProblemsPanel.test.tsx +3 -1
- package/src/components/home/TopologyPreview.test.tsx +73 -0
- package/src/components/home/TopologyPreview.tsx +120 -233
- package/src/components/home/TrafficSummary.test.tsx +63 -0
- package/src/components/home/TrafficSummary.tsx +135 -138
- package/src/components/home/mcpToolCatalog.ts +23 -10
- package/src/components/issues/IssuesPane.test.ts +11 -0
- package/src/components/issues/IssuesPane.tsx +15 -5
- package/src/components/issues/uncheckedSources.test.ts +20 -1
- package/src/components/issues/uncheckedSources.ts +18 -0
- package/src/components/kueue/KueuePendingPosition.tsx +35 -0
- package/src/components/kueue/useRelatedObjects.test.tsx +219 -0
- package/src/components/kueue/useRelatedReads.test.ts +56 -0
- package/src/components/kueue/useRelatedReads.ts +205 -0
- package/src/components/logs/MultiPodLogsTab.test.tsx +93 -0
- package/src/components/logs/MultiPodLogsTab.tsx +120 -0
- package/src/components/logs/PodLogsUnavailable.test.tsx +18 -0
- package/src/components/logs/PodLogsUnavailable.tsx +21 -0
- package/src/components/logs/RayClusterLogsTab.reselect.test.tsx +67 -0
- package/src/components/logs/RayClusterLogsTab.test.tsx +167 -0
- package/src/components/logs/RayClusterLogsTab.tsx +109 -0
- package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +3 -2
- package/src/components/logs/rayClusterPods.ts +32 -0
- package/src/components/outageSince.test.ts +21 -0
- package/src/components/outageSince.ts +10 -0
- package/src/components/resource/PrometheusCharts.overlays.test.ts +12 -0
- package/src/components/resource/PrometheusCharts.tsx +3 -40
- package/src/components/resources/crd/CRDSchemaTab.test.tsx +28 -0
- package/src/components/resources/crd/CRDSchemaTab.tsx +13 -0
- package/src/components/resources/crd/host.tsx +14 -0
- package/src/components/resources/renderers/CustomResourceDefinitionRenderer.test.tsx +27 -0
- package/src/components/resources/renderers/CustomResourceDefinitionRenderer.tsx +12 -0
- package/src/components/resources/renderers/JobAdmissionRenderers.test.tsx +4 -1
- package/src/components/resources/renderers/JobAdmissionRenderers.tsx +4 -3
- package/src/components/resources/renderers/KueueHostRenderers.test.tsx +117 -0
- package/src/components/resources/renderers/KueueQueueRenderers.test.tsx +97 -0
- package/src/components/resources/renderers/KueueQueueRenderers.tsx +139 -0
- package/src/components/resources/renderers/KueueWorkloadRenderer.test.tsx +7 -1
- package/src/components/resources/renderers/KueueWorkloadRenderer.tsx +47 -7
- package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.test.tsx +67 -0
- package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.tsx +31 -0
- package/src/components/resources/renderers/RayClusterRenderer.test.tsx +81 -3
- package/src/components/resources/renderers/RayClusterRenderer.tsx +19 -4
- package/src/components/traffic/TrafficView.tsx +3 -3
- package/src/components/ui/command-items-crd.test.tsx +23 -0
- package/src/components/ui/command-items.ts +2 -1
- package/src/components/useContextSwitchFlow.test.tsx +61 -0
- package/src/components/useContextSwitchFlow.tsx +21 -4
- package/src/components/whats-new/WhatsNew.test.ts +10 -3
- package/src/components/whats-new/WhatsNew.tsx +5 -1
- package/src/components/whats-new/WhatsNewDialog.test.tsx +17 -3
- package/src/components/whats-new/releaseNotes.ts +77 -4
- package/src/components/workload/RelatedFindingsSection.test.tsx +126 -0
- package/src/components/workload/RelatedFindingsSection.tsx +80 -0
- package/src/components/workload/WorkloadView.test.ts +10 -1
- package/src/components/workload/WorkloadView.tsx +85 -98
- package/src/components/workload/issueResourceOpener.test.ts +20 -0
- package/src/components/workload/issueResourceOpener.ts +17 -0
- package/src/context/ConnectionContext.tsx +133 -60
- package/src/context/ConnectionProvider.retry.test.tsx +176 -0
- package/src/context/ContextSwitchContext.tsx +14 -1
- package/src/context/DiagnoseCustomization.tsx +3 -0
- package/src/context/clusterConnected.ts +10 -0
- package/src/contexts/CapabilitiesContext.tsx +6 -4
- package/src/hooks/useElementSize.ts +30 -0
- package/src/integrations/resourceHost.test.tsx +1 -0
- package/src/integrations/resourceHost.ts +5 -1
- package/src/integrations/resourceHosts.test.tsx +21 -4
- package/src/integrations/resourceHosts.tsx +12 -0
- package/src/main.tsx +5 -0
- package/src/utils/related-findings.ts +46 -0
|
@@ -1,22 +1,33 @@
|
|
|
1
1
|
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
2
4
|
import { renderToStaticMarkup } from 'react-dom/server'
|
|
3
|
-
import { describe, expect, it } from 'vitest'
|
|
5
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
4
6
|
import { MCPSetupDialog } from './MCPSetupDialog'
|
|
5
7
|
import { mcpEndpointUrl, setBasename } from '../../api/config'
|
|
6
8
|
import { MCP_TOOL_CATALOG } from './mcpToolCatalog'
|
|
7
9
|
|
|
10
|
+
const clipboard = vi.hoisted(() => ({ ok: true, copied: [] as string[] }))
|
|
11
|
+
vi.mock('@skyhook-io/k8s-ui/utils/clipboard', () => ({
|
|
12
|
+
copyText: async (text: string) => {
|
|
13
|
+
if (clipboard.ok) clipboard.copied.push(text)
|
|
14
|
+
return clipboard.ok
|
|
15
|
+
},
|
|
16
|
+
}))
|
|
17
|
+
|
|
8
18
|
describe('MCP setup in read-only mode', () => {
|
|
9
19
|
it('generates client configurations for the retained endpoint and hides writes', () => {
|
|
10
20
|
setBasename('/radar')
|
|
11
21
|
try {
|
|
12
22
|
const url = mcpEndpointUrl(true)
|
|
13
|
-
const html = renderToStaticMarkup(<MCPSetupDialog open readOnly mcpUrl={url} onClose={() => {}} />)
|
|
23
|
+
const html = renderToStaticMarkup(<MCPSetupDialog open readOnly applicationEvidenceAvailable mcpUrl={url} onClose={() => {}} />)
|
|
14
24
|
expect(html).toContain(`claude mcp add --transport http radar ${url}`)
|
|
15
25
|
expect(html).toContain(`codex mcp add radar --url ${url}`)
|
|
16
26
|
expect(html).toContain('/radar/mcp-readonly')
|
|
17
27
|
expect(html).toContain('list_namespaces')
|
|
18
28
|
expect(html).not.toContain('apply_resource')
|
|
19
29
|
expect(html).not.toContain('exec_pod')
|
|
30
|
+
expect(html).not.toContain('collect_application_evidence')
|
|
20
31
|
expect(html).not.toContain('in_cluster')
|
|
21
32
|
expect(html).toContain('Read-only mode blocks write tools')
|
|
22
33
|
} finally {
|
|
@@ -31,7 +42,7 @@ describe('MCP setup in read-only mode', () => {
|
|
|
31
42
|
expect(html).toContain('exec_pod')
|
|
32
43
|
expect(html).toContain('is disabled')
|
|
33
44
|
expect(html).toContain('--mcp-exec-tools')
|
|
34
|
-
expect(html).toContain(`${MCP_TOOL_CATALOG.length -
|
|
45
|
+
expect(html).toContain(`${MCP_TOOL_CATALOG.length - 2} tools`)
|
|
35
46
|
})
|
|
36
47
|
|
|
37
48
|
it('does not suggest an unsupported flag when the capability is absent', () => {
|
|
@@ -43,13 +54,92 @@ describe('MCP setup in read-only mode', () => {
|
|
|
43
54
|
it('shows exec and counts it only when enabled', () => {
|
|
44
55
|
const html = renderToStaticMarkup(<MCPSetupDialog open execTools mcpUrl={mcpEndpointUrl()} onClose={() => {}} />)
|
|
45
56
|
expect(html).toContain('exec_pod')
|
|
46
|
-
expect(html).toContain(`${MCP_TOOL_CATALOG.length} tools`)
|
|
57
|
+
expect(html).toContain(`${MCP_TOOL_CATALOG.length - 1} tools`)
|
|
47
58
|
expect(html.indexOf('exec_pod')).toBeGreaterThan(html.indexOf('get_workload_logs'))
|
|
48
59
|
})
|
|
49
60
|
|
|
50
61
|
it('hides exec in read-only mode even if exec is requested', () => {
|
|
51
62
|
const html = renderToStaticMarkup(<MCPSetupDialog open readOnly execTools mcpUrl={mcpEndpointUrl(true)} onClose={() => {}} />)
|
|
52
63
|
expect(html).not.toContain('exec_pod')
|
|
53
|
-
expect(html).toContain(`${MCP_TOOL_CATALOG.filter((tool) => !tool.write).length} tools`)
|
|
64
|
+
expect(html).toContain(`${MCP_TOOL_CATALOG.filter((tool) => !tool.write && !tool.localOnly).length} tools`)
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it('keeps the full catalog in default mode', () => {
|
|
68
|
+
const html = renderToStaticMarkup(<MCPSetupDialog open applicationEvidenceAvailable mcpUrl={mcpEndpointUrl()} onClose={() => {}} />)
|
|
69
|
+
expect(html).toContain('apply_resource')
|
|
70
|
+
expect(html).toContain('in_cluster')
|
|
71
|
+
expect(html).toContain('collect_application_evidence')
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
it('hides local-only tools unless the server advertises availability', () => {
|
|
75
|
+
const html = renderToStaticMarkup(<MCPSetupDialog open mcpUrl={mcpEndpointUrl()} onClose={() => {}} />)
|
|
76
|
+
expect(html).toContain('apply_resource')
|
|
77
|
+
expect(html).not.toContain('collect_application_evidence')
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
describe('MCP setup prompt tip', () => {
|
|
82
|
+
it('tips to name Radar under the client setups, as plain text, without the in-Radar link when no handler is given', () => {
|
|
83
|
+
const host = document.createElement('div')
|
|
84
|
+
host.innerHTML = renderToStaticMarkup(<MCPSetupDialog open mcpUrl={mcpEndpointUrl()} onClose={() => {}} />)
|
|
85
|
+
const tip = [...host.querySelectorAll('p')].find((p) => p.textContent?.startsWith('Tip:'))
|
|
86
|
+
expect(tip?.textContent).toBe(
|
|
87
|
+
"Tip: name Radar in your prompt so your agent uses Radar instead of kubectl, e.g. Use Radar to find what's broken in my cluster and why.",
|
|
88
|
+
)
|
|
89
|
+
expect(tip!.querySelector('code.inline-code')?.textContent).toBe("Use Radar to find what's broken in my cluster and why.")
|
|
90
|
+
expect(tip!.querySelector('button, pre')).toBeNull()
|
|
91
|
+
expect(tip!.nextElementSibling).toBeNull()
|
|
92
|
+
const html = host.innerHTML
|
|
93
|
+
expect(html.indexOf('Tip:')).toBeGreaterThan(html.indexOf('Connect your AI tool'))
|
|
94
|
+
expect(html.indexOf('Tip:')).toBeLessThan(html.indexOf('list_namespaces'))
|
|
95
|
+
expect(html).not.toContain('investigate from Radar itself')
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
it('closes the dialog, then opens the composer from the in-Radar link', () => {
|
|
99
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
100
|
+
const calls: string[] = []
|
|
101
|
+
const host = document.createElement('div')
|
|
102
|
+
document.body.appendChild(host)
|
|
103
|
+
const root = createRoot(host)
|
|
104
|
+
try {
|
|
105
|
+
act(() => root.render(
|
|
106
|
+
<MCPSetupDialog
|
|
107
|
+
open
|
|
108
|
+
mcpUrl={mcpEndpointUrl()}
|
|
109
|
+
onClose={() => calls.push('close')}
|
|
110
|
+
onInvestigate={() => calls.push('investigate')}
|
|
111
|
+
/>,
|
|
112
|
+
))
|
|
113
|
+
const link = [...host.querySelectorAll('button')].find((b) => /investigate from Radar itself/.test(b.textContent ?? ''))
|
|
114
|
+
expect(link).toBeTruthy()
|
|
115
|
+
act(() => link!.click())
|
|
116
|
+
expect(calls).toEqual(['close', 'investigate'])
|
|
117
|
+
} finally {
|
|
118
|
+
act(() => root.unmount())
|
|
119
|
+
host.remove()
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
it.each([
|
|
124
|
+
[true, 'Copied'],
|
|
125
|
+
[false, 'Copy to clipboard'],
|
|
126
|
+
])('copies the endpoint and shows the tick only when the copy worked (ok=%s)', async (ok, label) => {
|
|
127
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
128
|
+
clipboard.ok = ok
|
|
129
|
+
clipboard.copied = []
|
|
130
|
+
const host = document.createElement('div')
|
|
131
|
+
document.body.appendChild(host)
|
|
132
|
+
const root = createRoot(host)
|
|
133
|
+
try {
|
|
134
|
+
act(() => root.render(<MCPSetupDialog open mcpUrl={mcpEndpointUrl()} onClose={() => {}} />))
|
|
135
|
+
const endpoint = [...host.querySelectorAll('code')].find((c) => c.textContent === mcpEndpointUrl())!
|
|
136
|
+
const copy = endpoint.closest('.relative')!.querySelector('button')!
|
|
137
|
+
await act(async () => copy.click())
|
|
138
|
+
expect(clipboard.copied).toEqual(ok ? [mcpEndpointUrl()] : [])
|
|
139
|
+
expect(copy.getAttribute('aria-label')).toBe(label)
|
|
140
|
+
} finally {
|
|
141
|
+
act(() => root.unmount())
|
|
142
|
+
host.remove()
|
|
143
|
+
}
|
|
54
144
|
})
|
|
55
145
|
})
|
|
@@ -4,28 +4,39 @@ import { apiUrl, getAuthHeaders, getCredentialsMode } from '../../api/config'
|
|
|
4
4
|
import { MCP_TOOL_CATALOG } from './mcpToolCatalog'
|
|
5
5
|
import { Tooltip } from '../ui/Tooltip'
|
|
6
6
|
import { Disclosure } from '@skyhook-io/k8s-ui/components/ui/Disclosure'
|
|
7
|
+
import { copyText } from '@skyhook-io/k8s-ui/utils/clipboard'
|
|
8
|
+
|
|
9
|
+
const MCP_EXAMPLE_PROMPT ="Use Radar to find what's broken in my cluster and why."
|
|
7
10
|
|
|
8
11
|
interface MCPSetupDialogProps {
|
|
9
12
|
open: boolean
|
|
10
13
|
onClose: () => void
|
|
11
14
|
readOnly?: boolean
|
|
12
15
|
execTools?: boolean
|
|
16
|
+
applicationEvidenceAvailable?: boolean
|
|
13
17
|
mcpUrl: string
|
|
18
|
+
/** Opens Radar's own investigation composer. Omit where investigations can't run. */
|
|
19
|
+
onInvestigate?: () => void
|
|
14
20
|
}
|
|
15
21
|
|
|
16
22
|
function CopyButton({ text }: { text: string }) {
|
|
17
23
|
const [copied, setCopied] = useState(false)
|
|
18
24
|
|
|
19
25
|
const handleCopy = () => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
// Plain-HTTP origins and denied permission reject the async Clipboard API;
|
|
27
|
+
// copyText falls back, and the tick must not claim a copy that didn't happen.
|
|
28
|
+
void copyText(text).then((ok) => {
|
|
29
|
+
if (!ok) return
|
|
30
|
+
setCopied(true)
|
|
31
|
+
setTimeout(() => setCopied(false), 2000)
|
|
32
|
+
})
|
|
23
33
|
}
|
|
24
34
|
|
|
25
35
|
return (
|
|
26
36
|
<Tooltip content="Copy to clipboard" position="left" wrapperClassName="absolute top-2 right-2">
|
|
27
37
|
<button
|
|
28
38
|
onClick={handleCopy}
|
|
39
|
+
aria-label={copied ? 'Copied' : 'Copy to clipboard'}
|
|
29
40
|
className="p-1.5 rounded-md bg-theme-elevated/50 hover:bg-theme-elevated text-theme-text-tertiary hover:text-theme-text-secondary transition-colors"
|
|
30
41
|
>
|
|
31
42
|
{copied ? <Check className="w-3.5 h-3.5 text-green-500" /> : <Copy className="w-3.5 h-3.5" />}
|
|
@@ -45,7 +56,7 @@ function CodeBlock({ children }: { children: string }) {
|
|
|
45
56
|
)
|
|
46
57
|
}
|
|
47
58
|
|
|
48
|
-
export function MCPSetupDialog({ open, onClose, mcpUrl, readOnly = false, execTools }: MCPSetupDialogProps) {
|
|
59
|
+
export function MCPSetupDialog({ open, onClose, mcpUrl, readOnly = false, execTools, onInvestigate, applicationEvidenceAvailable = false }: MCPSetupDialogProps) {
|
|
49
60
|
const dialogRef = useRef<HTMLDivElement>(null)
|
|
50
61
|
const [isDesktop, setIsDesktop] = useState(false)
|
|
51
62
|
const [portPinned, setPortPinned] = useState(false)
|
|
@@ -119,7 +130,7 @@ export function MCPSetupDialog({ open, onClose, mcpUrl, readOnly = false, execTo
|
|
|
119
130
|
const currentPort = Number(window.location.port) || 80
|
|
120
131
|
|
|
121
132
|
const tools = MCP_TOOL_CATALOG
|
|
122
|
-
.filter((tool) => (!readOnly || !tool.write) && (tool.name !== 'exec_pod' || execTools))
|
|
133
|
+
.filter((tool) => (!readOnly || !tool.write) && (tool.name !== 'exec_pod' || execTools) && (!tool.localOnly || (!readOnly && applicationEvidenceAvailable)))
|
|
123
134
|
.map((tool) => readOnly && tool.name === 'diagnose'
|
|
124
135
|
? { ...tool, params: tool.params.filter((param) => param.arg !== 'in_cluster') }
|
|
125
136
|
: tool)
|
|
@@ -321,6 +332,20 @@ export function MCPSetupDialog({ open, onClose, mcpUrl, readOnly = false, execTo
|
|
|
321
332
|
</div>
|
|
322
333
|
</Disclosure>
|
|
323
334
|
))}
|
|
335
|
+
|
|
336
|
+
<p className="pt-1 text-xs text-theme-text-tertiary leading-relaxed">
|
|
337
|
+
<span className="font-medium text-theme-text-secondary">Tip:</span> name Radar in your prompt so your
|
|
338
|
+
agent uses Radar instead of kubectl, e.g. <code className="inline-code">{MCP_EXAMPLE_PROMPT}</code>
|
|
339
|
+
</p>
|
|
340
|
+
{onInvestigate && (
|
|
341
|
+
<button
|
|
342
|
+
type="button"
|
|
343
|
+
onClick={() => { onClose(); onInvestigate() }}
|
|
344
|
+
className="text-xs text-accent-text hover:underline underline-offset-2"
|
|
345
|
+
>
|
|
346
|
+
Or investigate from Radar itself →
|
|
347
|
+
</button>
|
|
348
|
+
)}
|
|
324
349
|
</div>
|
|
325
350
|
|
|
326
351
|
{/* Available tools */}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act, type ReactNode } from 'react'
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
5
|
+
import type { Issue } from '@skyhook-io/k8s-ui'
|
|
6
|
+
import { ProblemsPanel } from './HomeView'
|
|
7
|
+
import { IssueDiagnoseButton } from '../diagnose/LocalDiagnoseAction'
|
|
8
|
+
import { HOVER_REVEAL_ACTION, HOVER_REVEAL_HIT, HOVER_REVEAL_REST } from '../../utils/animation'
|
|
9
|
+
|
|
10
|
+
const usage = vi.hoisted(() => ({ recordUsageEvent: vi.fn() }))
|
|
11
|
+
vi.mock('../../api/usage-data', async (importOriginal) => ({
|
|
12
|
+
...(await importOriginal<object>()),
|
|
13
|
+
recordUsageEvent: usage.recordUsageEvent,
|
|
14
|
+
}))
|
|
15
|
+
|
|
16
|
+
const diagnose = vi.hoisted(() => ({
|
|
17
|
+
setupState: 'ready' as string,
|
|
18
|
+
available: true,
|
|
19
|
+
hosted: false,
|
|
20
|
+
agentLabel: 'Claude Code',
|
|
21
|
+
cliOverride: false,
|
|
22
|
+
openInvestigation: vi.fn(),
|
|
23
|
+
openHome: vi.fn(),
|
|
24
|
+
}))
|
|
25
|
+
vi.mock('../diagnose/DiagnoseContext', () => ({
|
|
26
|
+
useDiagnose: () => diagnose,
|
|
27
|
+
useDiagnoseLayout: () => ({ runningRunIds: new Map(), lastInvestigations: new Map() }),
|
|
28
|
+
}))
|
|
29
|
+
vi.mock('../ui/Tooltip', () => ({ Tooltip: ({ children }: { children: ReactNode }) => children }))
|
|
30
|
+
|
|
31
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
32
|
+
|
|
33
|
+
const classesOf = (fragment: string) => fragment.split(/\s+/).filter(Boolean)
|
|
34
|
+
|
|
35
|
+
const issue: Issue = {
|
|
36
|
+
id: 'deploy-unavailable', severity: 'critical', source: 'problem', category: 'workload', category_group: 'workload', grouping_scope: 'resource',
|
|
37
|
+
kind: 'Deployment', group: 'apps', namespace: 'gl-shop', name: 'checkout', reason: 'Unavailable', message: 'No ready replicas',
|
|
38
|
+
}
|
|
39
|
+
const target = { kind: 'Deployment', group: 'apps', namespace: 'gl-shop', name: 'checkout' }
|
|
40
|
+
|
|
41
|
+
let root: Root
|
|
42
|
+
let container: HTMLDivElement
|
|
43
|
+
const onResourceClick = vi.fn()
|
|
44
|
+
|
|
45
|
+
function render(rowIssue: Issue = issue) {
|
|
46
|
+
act(() => {
|
|
47
|
+
root.render(
|
|
48
|
+
<ProblemsPanel
|
|
49
|
+
issues={[rowIssue]}
|
|
50
|
+
issueCount={1}
|
|
51
|
+
onRetryIssues={() => {}}
|
|
52
|
+
hasData
|
|
53
|
+
isLoading={false}
|
|
54
|
+
isRefreshing={false}
|
|
55
|
+
error={null}
|
|
56
|
+
totalReturned={1}
|
|
57
|
+
onNavigateToIssues={() => {}}
|
|
58
|
+
onResourceClick={onResourceClick}
|
|
59
|
+
/>,
|
|
60
|
+
)
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const buttons = () => Array.from(container.querySelectorAll('button'))
|
|
65
|
+
const investigateButton = () => buttons().find((b) => b.textContent?.trim() === 'Investigate')
|
|
66
|
+
|
|
67
|
+
beforeEach(() => {
|
|
68
|
+
Object.assign(diagnose, { setupState: 'ready', available: true })
|
|
69
|
+
diagnose.openInvestigation.mockReset()
|
|
70
|
+
diagnose.openHome.mockReset()
|
|
71
|
+
onResourceClick.mockReset()
|
|
72
|
+
container = document.createElement('div')
|
|
73
|
+
document.body.appendChild(container)
|
|
74
|
+
root = createRoot(container)
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
afterEach(() => {
|
|
78
|
+
act(() => root.unmount())
|
|
79
|
+
container.remove()
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
describe('Home Active Issues Investigate action', () => {
|
|
83
|
+
it('starts an investigation for the row resource without opening it', () => {
|
|
84
|
+
render()
|
|
85
|
+
const button = investigateButton()
|
|
86
|
+
expect(button).toBeDefined()
|
|
87
|
+
act(() => button!.click())
|
|
88
|
+
expect(diagnose.openInvestigation).toHaveBeenCalledWith(target)
|
|
89
|
+
expect(onResourceClick).not.toHaveBeenCalled()
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
it('still opens the resource from the rest of the row', () => {
|
|
93
|
+
render()
|
|
94
|
+
const row = buttons().find((b) => b.textContent?.includes('checkout'))
|
|
95
|
+
act(() => row!.click())
|
|
96
|
+
expect(onResourceClick).toHaveBeenCalledWith(target)
|
|
97
|
+
expect(diagnose.openInvestigation).not.toHaveBeenCalled()
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
it('does not nest the action inside the row button', () => {
|
|
101
|
+
render()
|
|
102
|
+
expect(investigateButton()!.parentElement!.closest('button')).toBeNull()
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
it.each(['off', 'unknown'])('is absent where investigations cannot run (%s)', (setupState) => {
|
|
106
|
+
diagnose.setupState = setupState
|
|
107
|
+
render()
|
|
108
|
+
expect(investigateButton()).toBeUndefined()
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
it('opens setup instead of starting a run when no agent is ready', () => {
|
|
112
|
+
Object.assign(diagnose, { setupState: 'needs-install', available: false })
|
|
113
|
+
render()
|
|
114
|
+
act(() => investigateButton()!.click())
|
|
115
|
+
expect(diagnose.openHome).toHaveBeenCalled()
|
|
116
|
+
expect(diagnose.openInvestigation).not.toHaveBeenCalled()
|
|
117
|
+
expect(onResourceClick).not.toHaveBeenCalled()
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
const agedIssue = () => ({ ...issue, first_seen: new Date(Date.now() - 3_600_000).toISOString() })
|
|
121
|
+
const ageSlot = () => container.querySelector('.group button .ml-auto')!
|
|
122
|
+
|
|
123
|
+
it('swaps the age slot for the action on hover or keyboard focus, in the same group', () => {
|
|
124
|
+
render(agedIssue())
|
|
125
|
+
const action = investigateButton()!
|
|
126
|
+
const group = action.closest('.group')!
|
|
127
|
+
expect(ageSlot().textContent).toMatch(/\d/)
|
|
128
|
+
for (const c of classesOf(HOVER_REVEAL_REST)) expect(ageSlot().classList).toContain(c)
|
|
129
|
+
const overlay = group.lastElementChild!
|
|
130
|
+
expect(overlay.contains(action)).toBe(true)
|
|
131
|
+
expect(overlay.classList).toContain('absolute')
|
|
132
|
+
for (const c of classesOf(HOVER_REVEAL_ACTION)) expect(overlay.classList).toContain(c)
|
|
133
|
+
// The overlay itself never takes clicks; only the control inside does.
|
|
134
|
+
expect(overlay.classList).toContain('pointer-events-none')
|
|
135
|
+
const hit = action.parentElement!.closest('span:not([aria-hidden])')!
|
|
136
|
+
expect(hit.parentElement).toBe(overlay)
|
|
137
|
+
for (const c of classesOf(HOVER_REVEAL_HIT)) expect(hit.classList).toContain(c)
|
|
138
|
+
// Keyboard reveal keys on :focus-visible, so a row left focused by a click
|
|
139
|
+
// doesn't keep its action shown.
|
|
140
|
+
expect(HOVER_REVEAL_ACTION).toContain('group-has-[:focus-visible]:opacity-100')
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
it('keeps the age slot in place where there is no action to swap in', () => {
|
|
144
|
+
diagnose.setupState = 'off'
|
|
145
|
+
render(agedIssue())
|
|
146
|
+
expect(ageSlot().textContent).toMatch(/\d/)
|
|
147
|
+
expect(ageSlot().classList).not.toContain('group-hover:opacity-0')
|
|
148
|
+
expect(container.querySelector('.group > div')).toBeNull()
|
|
149
|
+
})
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
describe('opening an issue from Home', () => {
|
|
153
|
+
it('opens its resource and counts it once', () => {
|
|
154
|
+
render()
|
|
155
|
+
usage.recordUsageEvent.mockClear()
|
|
156
|
+
const row = buttons().find((b) => b.textContent?.includes('checkout'))!
|
|
157
|
+
act(() => row.click())
|
|
158
|
+
expect(onResourceClick).toHaveBeenCalledTimes(1)
|
|
159
|
+
expect(usage.recordUsageEvent.mock.calls).toEqual([[{ type: 'ui', name: 'issue_action:open' }]])
|
|
160
|
+
})
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
describe('IssueDiagnoseButton size', () => {
|
|
164
|
+
it('keeps the Issues page look by default and shrinks only when compact', () => {
|
|
165
|
+
act(() => root.render(<><IssueDiagnoseButton {...target} /><IssueDiagnoseButton {...target} size="compact" /></>))
|
|
166
|
+
const [regular, compact] = buttons()
|
|
167
|
+
expect(regular.className).toContain('px-2 py-1 text-xs')
|
|
168
|
+
expect(compact.className).toContain('h-4')
|
|
169
|
+
expect(compact.className).not.toContain('py-1 text-xs')
|
|
170
|
+
})
|
|
171
|
+
})
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest'
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
2
2
|
import { renderToString } from 'react-dom/server'
|
|
3
3
|
import type { Issue } from '@skyhook-io/k8s-ui'
|
|
4
4
|
import { ProblemsPanel } from './HomeView'
|
|
5
5
|
import { uncheckedSourceLines } from '../issues/uncheckedSources'
|
|
6
6
|
import type { IssuesResponse } from '../../api/client'
|
|
7
7
|
|
|
8
|
+
vi.mock('../diagnose/LocalDiagnoseAction', () => ({ IssueDiagnoseButton: () => null, useIssueDiagnoseShown: () => true }))
|
|
9
|
+
|
|
8
10
|
const line = "Helm releases couldn't be checked, so failed or stuck releases may be missing."
|
|
9
11
|
const generic = "Some issue checks couldn't run, so issues may be missing."
|
|
10
12
|
const helm = [{ source: 'helm', reason: 'read_failed' }]
|
|
@@ -0,0 +1,73 @@
|
|
|
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 type { Topology } from '../../types'
|
|
6
|
+
import { TopologyPreview } from './TopologyPreview'
|
|
7
|
+
|
|
8
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
9
|
+
|
|
10
|
+
const largeTopology = { nodes: [], edges: [], requiresNamespaceFilter: true } as unknown as Topology
|
|
11
|
+
const smallTopology = {
|
|
12
|
+
nodes: [
|
|
13
|
+
{ id: 'deployment/default/web', kind: 'Deployment', name: 'web', status: 'healthy', data: {} },
|
|
14
|
+
{ id: 'service/default/web', kind: 'Service', name: 'web', status: 'healthy', data: {} },
|
|
15
|
+
],
|
|
16
|
+
edges: [{ id: 'e1', source: 'service/default/web', target: 'deployment/default/web', type: 'exposes' }],
|
|
17
|
+
} as unknown as Topology
|
|
18
|
+
|
|
19
|
+
let container: HTMLDivElement
|
|
20
|
+
let root: Root
|
|
21
|
+
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
container = document.createElement('div')
|
|
24
|
+
document.body.appendChild(container)
|
|
25
|
+
root = createRoot(container)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
afterEach(() => {
|
|
29
|
+
act(() => root.unmount())
|
|
30
|
+
container.remove()
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
function render(topology: Topology | null, namespaceSelected = false, onNavigate = vi.fn()) {
|
|
34
|
+
act(() => root.render(<TopologyPreview topology={topology} namespaceSelected={namespaceSelected} onNavigate={onNavigate} />))
|
|
35
|
+
return onNavigate
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const header = () => container.querySelector('button > div > div')!.textContent
|
|
39
|
+
|
|
40
|
+
describe('TopologyPreview', () => {
|
|
41
|
+
it('states the graph counts in the header', () => {
|
|
42
|
+
render(smallTopology)
|
|
43
|
+
expect(header()).toContain('2 resources · 1 relationships')
|
|
44
|
+
expect(container.textContent).toContain('How ingresses, services and workloads connect, grouped by namespace.')
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('draws the same picture on a cluster too large to graph, with no counts and no namespaces', () => {
|
|
48
|
+
render(smallTopology)
|
|
49
|
+
const smallDrawing = container.querySelector('svg')!.innerHTML.replace(/_r_\w+_/g, '')
|
|
50
|
+
render(largeTopology)
|
|
51
|
+
expect(header()).toBe('Topology')
|
|
52
|
+
expect(container.querySelector('[data-testid="topology-counts-loading"]')).toBeNull()
|
|
53
|
+
expect(container.querySelector('svg')!.innerHTML.replace(/_r_\w+_/g, '')).toBe(smallDrawing)
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it('keeps loading while a picked namespace is on its way to the server', () => {
|
|
57
|
+
render(largeTopology, true)
|
|
58
|
+
expect(container.querySelector('[data-testid="topology-counts-loading"]')).not.toBeNull()
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it('shows an empty scope as an honest zero, and loading before any graph', () => {
|
|
62
|
+
render({ nodes: [], edges: [] } as unknown as Topology)
|
|
63
|
+
expect(header()).toContain('0 resources · 0 relationships')
|
|
64
|
+
render(null)
|
|
65
|
+
expect(container.querySelector('[data-testid="topology-counts-loading"]')).not.toBeNull()
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('opens Topology from anywhere on the card', () => {
|
|
69
|
+
const onNavigate = render(largeTopology)
|
|
70
|
+
act(() => container.querySelector('svg')!.dispatchEvent(new MouseEvent('click', { bubbles: true })))
|
|
71
|
+
expect(onNavigate).toHaveBeenCalledTimes(1)
|
|
72
|
+
})
|
|
73
|
+
})
|