@skyhook-io/radar-app 1.18.2 → 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.
Files changed (228) hide show
  1. package/README.md +1 -1
  2. package/package.json +7 -7
  3. package/src/App.tsx +31 -6
  4. package/src/api/application-evidence.ts +63 -0
  5. package/src/api/argoSync.test.ts +22 -0
  6. package/src/api/client.audit-gating.test.tsx +48 -0
  7. package/src/api/client.kueuePosition.test.ts +32 -0
  8. package/src/api/client.kueueQueueWorkloads.test.tsx +71 -0
  9. package/src/api/client.resource-identity.test.ts +3 -0
  10. package/src/api/client.resourceIssues.test.tsx +239 -0
  11. package/src/api/client.resourcePath.test.ts +3 -0
  12. package/src/api/client.ts +285 -55
  13. package/src/api/config.ts +21 -0
  14. package/src/api/diagnose.test.ts +33 -2
  15. package/src/api/diagnose.ts +97 -3
  16. package/src/api/radarFeatures.render.test.tsx +33 -1
  17. package/src/api/radarFeatures.test.ts +47 -0
  18. package/src/api/radarFeatures.ts +41 -1
  19. package/src/api/rbac.settled.test.tsx +42 -0
  20. package/src/api/rbac.test.ts +18 -0
  21. package/src/api/rbac.ts +37 -7
  22. package/src/api/traffic.ts +9 -4
  23. package/src/api/usage-data.fixtures.ts +3 -1
  24. package/src/api/usage-data.test.tsx +134 -0
  25. package/src/api/usage-data.ts +35 -7
  26. package/src/api/workloadPodsPolling.test.ts +26 -0
  27. package/src/components/CloudConnectFlow.test.tsx +86 -0
  28. package/src/components/CloudConnectFlow.tsx +65 -27
  29. package/src/components/CloudFunnelButton.test.tsx +140 -5
  30. package/src/components/CloudFunnelButton.tsx +50 -9
  31. package/src/components/ConnectionErrorView.test.tsx +34 -0
  32. package/src/components/ConnectionErrorView.tsx +35 -11
  33. package/src/components/ContextSwitcher.tsx +5 -2
  34. package/src/components/SwitchAwareConnectionError.test.tsx +43 -0
  35. package/src/components/SwitchAwareConnectionError.tsx +85 -0
  36. package/src/components/application-evidence/ApplicationEvidenceAction.flow.test.tsx +234 -0
  37. package/src/components/application-evidence/ApplicationEvidenceAction.test.tsx +144 -0
  38. package/src/components/application-evidence/ApplicationEvidenceAction.tsx +218 -0
  39. package/src/components/capacity/CapacityDemand.tsx +3 -2
  40. package/src/components/capacity/demandSummary.test.ts +38 -0
  41. package/src/components/capacity/shared.tsx +12 -1
  42. package/src/components/cost/ApplicationCostTab.tsx +4 -0
  43. package/src/components/cost/CostTrendChart.tsx +2 -0
  44. package/src/components/cost/WorkloadCostTab.tsx +4 -0
  45. package/src/components/cost/source.test.ts +5 -0
  46. package/src/components/cost/source.ts +11 -0
  47. package/src/components/diagnose/AIMarkdown.tsx +4 -1
  48. package/src/components/diagnose/ActivityTurn.tsx +34 -14
  49. package/src/components/diagnose/AgentControls.tsx +53 -6
  50. package/src/components/diagnose/AgentSetupNotice.test.tsx +17 -0
  51. package/src/components/diagnose/AgentSetupNotice.tsx +22 -4
  52. package/src/components/diagnose/AgentSigninNotice.test.tsx +98 -0
  53. package/src/components/diagnose/AgentSigninNotice.tsx +61 -0
  54. package/src/components/diagnose/AnalysisStory.test.tsx +22 -0
  55. package/src/components/diagnose/AnalysisStory.tsx +17 -4
  56. package/src/components/diagnose/AssessmentCard.tsx +39 -8
  57. package/src/components/diagnose/ContinueInAgentButton.mounted.test.tsx +182 -0
  58. package/src/components/diagnose/ContinueInAgentButton.test.tsx +128 -0
  59. package/src/components/diagnose/ContinueInAgentButton.tsx +303 -0
  60. package/src/components/diagnose/DiagnoseContext.capacity.test.tsx +113 -0
  61. package/src/components/diagnose/DiagnoseContext.question.test.tsx +245 -0
  62. package/src/components/diagnose/DiagnoseContext.tsx +272 -10
  63. package/src/components/diagnose/DiagnoseSurface.test.tsx +54 -0
  64. package/src/components/diagnose/DiagnoseSurface.tsx +151 -134
  65. package/src/components/diagnose/EvidenceCard.tsx +67 -14
  66. package/src/components/diagnose/ExampleInvestigationLink.tsx +20 -0
  67. package/src/components/diagnose/Home.test.tsx +208 -5
  68. package/src/components/diagnose/Home.tsx +187 -36
  69. package/src/components/diagnose/InvestigationCapacityNotice.test.tsx +246 -0
  70. package/src/components/diagnose/InvestigationCapacityNotice.tsx +241 -0
  71. package/src/components/diagnose/InvestigationEvidencePane.story.test.tsx +97 -6
  72. package/src/components/diagnose/InvestigationEvidencePane.test.tsx +57 -0
  73. package/src/components/diagnose/InvestigationEvidencePane.tsx +59 -11
  74. package/src/components/diagnose/InvestigationEvidenceSections.tsx +50 -23
  75. package/src/components/diagnose/InvestigationView.tsx +249 -54
  76. package/src/components/diagnose/LocalDiagnoseAction.history.test.tsx +450 -0
  77. package/src/components/diagnose/LocalDiagnoseAction.tsx +365 -39
  78. package/src/components/diagnose/NextStepJump.test.tsx +92 -0
  79. package/src/components/diagnose/NextStepJump.tsx +75 -0
  80. package/src/components/diagnose/QuestionComposer.test.tsx +553 -0
  81. package/src/components/diagnose/QuestionComposer.tsx +495 -0
  82. package/src/components/diagnose/QuestionFocus.test.tsx +38 -0
  83. package/src/components/diagnose/QuestionFocus.tsx +123 -0
  84. package/src/components/diagnose/ResourcePicker.tsx +206 -0
  85. package/src/components/diagnose/StoryExcerpt.tsx +12 -3
  86. package/src/components/diagnose/assessmentCopy.ts +5 -0
  87. package/src/components/diagnose/exampleInvestigation.events.json +191 -0
  88. package/src/components/diagnose/exampleInvestigation.loadFailure.test.tsx +94 -0
  89. package/src/components/diagnose/exampleInvestigation.test.tsx +248 -0
  90. package/src/components/diagnose/exampleInvestigation.ts +121 -0
  91. package/src/components/diagnose/investigationCase.runs.test.tsx +328 -0
  92. package/src/components/diagnose/investigationCase.test.tsx +9 -1
  93. package/src/components/diagnose/investigationCase.ts +33 -1
  94. package/src/components/diagnose/investigationEvidence/adapters/applicationFindings.test.ts +739 -0
  95. package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +46 -0
  96. package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +58 -2
  97. package/src/components/diagnose/investigationEvidence/adapters/issues.ts +9 -0
  98. package/src/components/diagnose/investigationEvidence/adapters/posture.ts +29 -1
  99. package/src/components/diagnose/investigationEvidence/adapters/prometheus.test.ts +40 -0
  100. package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +27 -1
  101. package/src/components/diagnose/investigationEvidence/bodies/metrics.test.tsx +111 -0
  102. package/src/components/diagnose/investigationEvidence/bodies/metrics.tsx +67 -16
  103. package/src/components/diagnose/investigationEvidence/builder.ts +30 -0
  104. package/src/components/diagnose/investigationEvidence/excerpt.test.ts +18 -5
  105. package/src/components/diagnose/investigationEvidence/excerpt.ts +22 -11
  106. package/src/components/diagnose/investigationEvidence/index.ts +1 -1
  107. package/src/components/diagnose/investigationEvidence/navigation.tsx +2 -0
  108. package/src/components/diagnose/investigationEvidence/observations.ts +121 -2
  109. package/src/components/diagnose/investigationEvidence/projection.test.ts +85 -3
  110. package/src/components/diagnose/investigationEvidence/types.ts +7 -0
  111. package/src/components/diagnose/investigationEvidencePartition.ts +6 -1
  112. package/src/components/diagnose/investigationFocus.test.ts +271 -0
  113. package/src/components/diagnose/investigationFocus.ts +132 -0
  114. package/src/components/diagnose/investigationState.ts +28 -0
  115. package/src/components/diagnose/lastInvestigation.test.ts +95 -0
  116. package/src/components/diagnose/lastInvestigation.ts +58 -0
  117. package/src/components/diagnose/launch.test.ts +125 -1
  118. package/src/components/diagnose/launch.ts +57 -10
  119. package/src/components/diagnose/parts.test.tsx +20 -0
  120. package/src/components/diagnose/questionSuggestions.test.ts +111 -0
  121. package/src/components/diagnose/questionSuggestions.ts +150 -0
  122. package/src/components/diagnose/storyParts.test.tsx +13 -0
  123. package/src/components/diagnose/target.test.ts +143 -2
  124. package/src/components/diagnose/target.ts +109 -7
  125. package/src/components/diagnose/testdata/story-runs.json +474 -0
  126. package/src/components/diagnose/toolCallLabel.test.ts +10 -4
  127. package/src/components/diagnose/verdictText.test.tsx +87 -0
  128. package/src/components/diagnose/verdictText.ts +68 -0
  129. package/src/components/execution/BatchExecutionView.tsx +24 -11
  130. package/src/components/execution/JobSetAdmission.test.tsx +42 -0
  131. package/src/components/execution/JobSetAdmission.tsx +18 -3
  132. package/src/components/execution/JobSetMemberComparison.tsx +2 -1
  133. package/src/components/execution/runState.test.ts +14 -0
  134. package/src/components/execution/runState.ts +8 -0
  135. package/src/components/gitops/GitOpsView.rollbackGate.test.tsx +202 -0
  136. package/src/components/gitops/GitOpsView.syncRequest.test.tsx +369 -0
  137. package/src/components/gitops/GitOpsView.tsx +86 -17
  138. package/src/components/gitops/RemoteDestinationCloudHint.tsx +2 -3
  139. package/src/components/gitops/destination-toast.test.ts +1 -1
  140. package/src/components/gitops/destination-toast.ts +2 -2
  141. package/src/components/home/ClusterHealthCard.tsx +13 -39
  142. package/src/components/home/HomeAgentBlock.test.tsx +141 -0
  143. package/src/components/home/HomeAgentBlock.tsx +103 -0
  144. package/src/components/home/HomeDiagramCard.tsx +47 -0
  145. package/src/components/home/HomeView.tsx +86 -47
  146. package/src/components/home/MCPSetupDialog.test.tsx +95 -5
  147. package/src/components/home/MCPSetupDialog.tsx +30 -5
  148. package/src/components/home/ProblemsPanel.investigate.test.tsx +171 -0
  149. package/src/components/home/ProblemsPanel.test.tsx +3 -1
  150. package/src/components/home/RadarVersionLine.test.tsx +0 -14
  151. package/src/components/home/RadarVersionLine.tsx +3 -28
  152. package/src/components/home/TopologyPreview.test.tsx +73 -0
  153. package/src/components/home/TopologyPreview.tsx +120 -233
  154. package/src/components/home/TrafficSummary.test.tsx +63 -0
  155. package/src/components/home/TrafficSummary.tsx +135 -138
  156. package/src/components/home/mcpToolCatalog.ts +23 -10
  157. package/src/components/issues/IssuesPane.test.ts +11 -0
  158. package/src/components/issues/IssuesPane.tsx +15 -5
  159. package/src/components/issues/uncheckedSources.test.ts +20 -1
  160. package/src/components/issues/uncheckedSources.ts +18 -0
  161. package/src/components/kueue/KueuePendingPosition.tsx +35 -0
  162. package/src/components/kueue/useRelatedObjects.test.tsx +219 -0
  163. package/src/components/kueue/useRelatedReads.test.ts +56 -0
  164. package/src/components/kueue/useRelatedReads.ts +205 -0
  165. package/src/components/logs/MultiPodLogsTab.test.tsx +93 -0
  166. package/src/components/logs/MultiPodLogsTab.tsx +120 -0
  167. package/src/components/logs/PodLogsUnavailable.test.tsx +18 -0
  168. package/src/components/logs/PodLogsUnavailable.tsx +21 -0
  169. package/src/components/logs/RayClusterLogsTab.reselect.test.tsx +67 -0
  170. package/src/components/logs/RayClusterLogsTab.test.tsx +167 -0
  171. package/src/components/logs/RayClusterLogsTab.tsx +109 -0
  172. package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +3 -2
  173. package/src/components/logs/rayClusterPods.ts +32 -0
  174. package/src/components/outageSince.test.ts +21 -0
  175. package/src/components/outageSince.ts +10 -0
  176. package/src/components/resource/PrometheusCharts.overlays.test.ts +12 -0
  177. package/src/components/resource/PrometheusCharts.tsx +3 -40
  178. package/src/components/resources/crd/CRDSchemaTab.test.tsx +28 -0
  179. package/src/components/resources/crd/CRDSchemaTab.tsx +13 -0
  180. package/src/components/resources/crd/host.tsx +14 -0
  181. package/src/components/resources/renderers/CustomResourceDefinitionRenderer.test.tsx +27 -0
  182. package/src/components/resources/renderers/CustomResourceDefinitionRenderer.tsx +12 -0
  183. package/src/components/resources/renderers/JobAdmissionRenderers.test.tsx +4 -1
  184. package/src/components/resources/renderers/JobAdmissionRenderers.tsx +4 -3
  185. package/src/components/resources/renderers/KueueHostRenderers.test.tsx +117 -0
  186. package/src/components/resources/renderers/KueueQueueRenderers.test.tsx +97 -0
  187. package/src/components/resources/renderers/KueueQueueRenderers.tsx +139 -0
  188. package/src/components/resources/renderers/KueueWorkloadRenderer.test.tsx +7 -1
  189. package/src/components/resources/renderers/KueueWorkloadRenderer.tsx +47 -7
  190. package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.test.tsx +67 -0
  191. package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.tsx +31 -0
  192. package/src/components/resources/renderers/RayClusterRenderer.test.tsx +81 -3
  193. package/src/components/resources/renderers/RayClusterRenderer.tsx +19 -4
  194. package/src/components/traffic/TrafficView.tsx +3 -3
  195. package/src/components/ui/Omnibar.investigate.test.tsx +105 -0
  196. package/src/components/ui/Omnibar.tsx +47 -3
  197. package/src/components/ui/RadarOmnibar.test.tsx +1 -0
  198. package/src/components/ui/RadarOmnibar.tsx +11 -0
  199. package/src/components/ui/command-items-crd.test.tsx +23 -0
  200. package/src/components/ui/command-items.ts +2 -1
  201. package/src/components/useContextSwitchFlow.test.tsx +61 -0
  202. package/src/components/useContextSwitchFlow.tsx +21 -4
  203. package/src/components/whats-new/WhatsNew.test.ts +10 -3
  204. package/src/components/whats-new/WhatsNew.tsx +5 -1
  205. package/src/components/whats-new/WhatsNewDialog.test.tsx +18 -4
  206. package/src/components/whats-new/releaseNotes.ts +136 -4
  207. package/src/components/workload/RelatedFindingsSection.test.tsx +126 -0
  208. package/src/components/workload/RelatedFindingsSection.tsx +80 -0
  209. package/src/components/workload/WorkloadView.test.ts +10 -1
  210. package/src/components/workload/WorkloadView.tsx +85 -98
  211. package/src/components/workload/issueResourceOpener.test.ts +20 -0
  212. package/src/components/workload/issueResourceOpener.ts +17 -0
  213. package/src/context/ConnectionContext.tsx +133 -60
  214. package/src/context/ConnectionProvider.retry.test.tsx +176 -0
  215. package/src/context/ContextSwitchContext.tsx +14 -1
  216. package/src/context/DiagnoseCustomization.tsx +3 -0
  217. package/src/context/clusterConnected.ts +10 -0
  218. package/src/contexts/CapabilitiesContext.tsx +6 -4
  219. package/src/hooks/useAgentSignin.test.tsx +190 -0
  220. package/src/hooks/useAgentSignin.ts +160 -0
  221. package/src/hooks/useApproveAfterSignin.test.tsx +108 -0
  222. package/src/hooks/useElementSize.ts +30 -0
  223. package/src/integrations/resourceHost.test.tsx +1 -0
  224. package/src/integrations/resourceHost.ts +5 -1
  225. package/src/integrations/resourceHosts.test.tsx +21 -4
  226. package/src/integrations/resourceHosts.tsx +12 -0
  227. package/src/main.tsx +5 -0
  228. package/src/utils/related-findings.ts +46 -0
@@ -27,7 +27,7 @@ describe('destinationToast', () => {
27
27
  })
28
28
  test('unknown destination', () => {
29
29
  const t = destinationToast('ConfigMap a/b', { canSwitch: true })
30
- expect(t.message).toBe('ConfigMap a/b is on another cluster')
30
+ expect(t.message).toBe("ConfigMap a/b can't be opened from this cluster")
31
31
  expect(t.actionLabel).toBeUndefined()
32
32
  })
33
33
  })
@@ -32,8 +32,8 @@ export function destinationToast(resource: string, dest: DestinationCluster): De
32
32
  }
33
33
  }
34
34
  return {
35
- message: `${resource} is on another cluster`,
36
- detail: "Radar couldn't tell which cluster, so it can't open it from here.",
35
+ message: `${resource} can't be opened from this cluster`,
36
+ detail: "Radar couldn't tell which cluster holds the recorded resource, so it can't open it from here.",
37
37
  }
38
38
  }
39
39
 
@@ -1,15 +1,15 @@
1
- import { useState, type ReactNode } from 'react'
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, Radio, Info,
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 { MCPSetupDialog } from './MCPSetupDialog'
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
- {/* MCP Server indicator. OSS-only: in Cloud, MCP discovery
315
- lives at the hub level (org-wide endpoint, PAT-authed)
316
- rather than per-cluster, so this localhost/no-auth card
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
- <button
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} applicationEvidenceAvailable={caps.mcpApplicationEvidence} />
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 flex items-center gap-1 hover:text-theme-text-secondary transition-colors"
557
+ className="group text-left hover:text-theme-text-secondary transition-colors"
584
558
  >
585
- <span>Kubernetes {version}</span>
559
+ Kubernetes {version}
586
560
  {behind > 0 && (
587
- <span>· Upgrade impact</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,141 @@
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, onInvestigate }: { open: boolean; readOnly?: boolean; onInvestigate?: () => void }) =>
14
+ open ? (
15
+ <div data-testid="mcp-dialog">
16
+ {readOnly ? 'read-only' : 'full'}
17
+ {onInvestigate && <button onClick={onInvestigate}>dialog-investigate</button>}
18
+ </div>
19
+ ) : null,
20
+ }))
21
+
22
+ Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
23
+ let root: Root
24
+ let host: HTMLDivElement
25
+
26
+ function setDiagnose(overrides: Record<string, unknown>) {
27
+ diagnose.current = {
28
+ available: true,
29
+ setupState: 'ready',
30
+ agentLabel: 'Claude Code',
31
+ hosted: false,
32
+ questions: true,
33
+ cliOverride: false,
34
+ openQuestion: vi.fn(),
35
+ openWorkspace: vi.fn(),
36
+ openHome: vi.fn(),
37
+ ...overrides,
38
+ }
39
+ }
40
+
41
+ function render(props: { readOnly?: boolean } = {}) {
42
+ act(() => {
43
+ root.render(<HomeAgentBlock mcpUrl="http://localhost:9280/mcp" {...props} />)
44
+ })
45
+ }
46
+
47
+ const button = (name: RegExp) =>
48
+ [...host.querySelectorAll('button')].find((b) => name.test(b.textContent ?? ''))
49
+
50
+ beforeEach(() => {
51
+ nav.embedded = false
52
+ setDiagnose({})
53
+ host = document.createElement('div')
54
+ document.body.appendChild(host)
55
+ root = createRoot(host)
56
+ })
57
+
58
+ afterEach(() => {
59
+ act(() => root.unmount())
60
+ host.remove()
61
+ })
62
+
63
+ describe('HomeAgentBlock', () => {
64
+ it('names the agent and opens the question composer', () => {
65
+ render()
66
+ const ask = button(/Ask Claude Code about this cluster/)
67
+ expect(ask).toBeTruthy()
68
+ act(() => ask!.click())
69
+ expect(diagnose.current.openQuestion).toHaveBeenCalledWith({})
70
+ })
71
+
72
+ it('opens investigations when the backend does not take questions', () => {
73
+ setDiagnose({ questions: false, agentLabel: 'Codex' })
74
+ render()
75
+ act(() => button(/Investigate with Codex/)!.click())
76
+ expect(diagnose.current.openWorkspace).toHaveBeenCalled()
77
+ expect(diagnose.current.openQuestion).not.toHaveBeenCalled()
78
+ })
79
+
80
+ it('offers agent setup when no agent is installed', () => {
81
+ setDiagnose({ available: false, setupState: 'needs-install' })
82
+ render()
83
+ expect(button(/Ask/)).toBeUndefined()
84
+ act(() => button(/Set up an agent/)!.click())
85
+ expect(diagnose.current.openHome).toHaveBeenCalled()
86
+ })
87
+
88
+ it('points at the setup notice when an installed agent cannot run', () => {
89
+ setDiagnose({ available: false, setupState: 'needs-restart', cliOverride: true })
90
+ render()
91
+ act(() => button(/Check agent setup/)!.click())
92
+ expect(diagnose.current.openHome).toHaveBeenCalled()
93
+ })
94
+
95
+ it.each(['off', 'unknown'])('shows only the MCP line when investigations are %s here', (setupState) => {
96
+ setDiagnose({ available: false, setupState })
97
+ render()
98
+ expect(button(/Ask|Investigate|Set up|Check agent/)).toBeUndefined()
99
+ expect(host.textContent).toContain('MCP live')
100
+ expect(button(/^Connect$/)).toBeTruthy()
101
+ })
102
+
103
+ it('adds nothing for an embedded host', () => {
104
+ nav.embedded = true
105
+ render()
106
+ expect(button(/Ask|Investigate|Set up/)).toBeUndefined()
107
+ expect(host.textContent).toContain('MCP live')
108
+ })
109
+
110
+ it('keeps the MCP endpoint and opens the setup dialog', () => {
111
+ render({ readOnly: true })
112
+ expect(host.textContent).toContain('MCP live (read-only)')
113
+ expect(host.textContent).toContain('localhost:9280/mcp')
114
+ expect(host.querySelector('[data-testid="mcp-dialog"]')).toBeNull()
115
+ act(() => button(/^Connect$/)!.click())
116
+ expect(host.querySelector('[data-testid="mcp-dialog"]')?.textContent).toContain('read-only')
117
+ })
118
+
119
+ it.each([
120
+ [true, 'openQuestion'],
121
+ [false, 'openWorkspace'],
122
+ ])('lets the dialog open the composer when an agent is ready (questions=%s)', (questions, opener) => {
123
+ setDiagnose({ questions })
124
+ render()
125
+ act(() => button(/^Connect$/)!.click())
126
+ act(() => button(/dialog-investigate/)!.click())
127
+ expect(diagnose.current[opener]).toHaveBeenCalled()
128
+ })
129
+
130
+ it.each([
131
+ ['no agent is ready', () => setDiagnose({ available: false, setupState: 'needs-install' })],
132
+ ['investigations are off', () => setDiagnose({ available: false, setupState: 'off' })],
133
+ ['the host is embedded', () => { nav.embedded = true }],
134
+ ])('gives the dialog no in-Radar link when %s', (_, arrange) => {
135
+ arrange()
136
+ render()
137
+ act(() => button(/^Connect$/)!.click())
138
+ expect(host.querySelector('[data-testid="mcp-dialog"]')).toBeTruthy()
139
+ expect(button(/dialog-investigate/)).toBeUndefined()
140
+ })
141
+ })
@@ -0,0 +1,103 @@
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
+ applicationEvidenceAvailable,
18
+ }: {
19
+ mcpUrl: string
20
+ readOnly?: boolean
21
+ execTools?: boolean
22
+ applicationEvidenceAvailable?: boolean
23
+ }) {
24
+ const [mcpDialogOpen, setMcpDialogOpen] = useState(false)
25
+ const d = useDiagnose()
26
+ const { embedded } = useNavCustomization()
27
+ const showInvestigate = !embedded && d.setupState !== 'off' && d.setupState !== 'unknown'
28
+
29
+ return (
30
+ <div className="mt-3 flex flex-col gap-1.5 rounded-md border border-purple-500/20 bg-purple-500/5 p-2">
31
+ {showInvestigate && <InvestigateLine />}
32
+ <div className="flex min-w-0 items-center gap-1.5 text-[11px]">
33
+ <Radio className="h-3 w-3 shrink-0 animate-pulse text-purple-600 dark:text-purple-400" aria-hidden />
34
+ <span className="shrink-0 font-medium text-purple-600 dark:text-purple-400">
35
+ {readOnly ? 'MCP live (read-only)' : 'MCP live'}
36
+ </span>
37
+ <Tooltip content={mcpUrl} wrapperClassName="min-w-0">
38
+ <span className="truncate font-mono text-theme-text-tertiary">{mcpUrl.replace(/^https?:\/\//, '')}</span>
39
+ </Tooltip>
40
+ {/* "Connect your agent" doesn't fit beside the URL in this column;
41
+ the short label keeps the endpoint readable. */}
42
+ <button
43
+ type="button"
44
+ onClick={() => setMcpDialogOpen(true)}
45
+ aria-label="Connect your agent"
46
+ className="ml-auto shrink-0 whitespace-nowrap font-medium text-purple-600 hover:underline dark:text-purple-400"
47
+ >
48
+ Connect
49
+ </button>
50
+ </div>
51
+ <MCPSetupDialog
52
+ open={mcpDialogOpen}
53
+ onClose={() => setMcpDialogOpen(false)}
54
+ mcpUrl={mcpUrl}
55
+ readOnly={readOnly}
56
+ execTools={execTools}
57
+ onInvestigate={showInvestigate && d.available ? () => openComposer(d) : undefined}
58
+ applicationEvidenceAvailable={applicationEvidenceAvailable}
59
+ />
60
+ </div>
61
+ )
62
+ }
63
+
64
+ function openComposer(d: ReturnType<typeof useDiagnose>) {
65
+ if (d.questions) d.openQuestion({})
66
+ else d.openWorkspace()
67
+ }
68
+
69
+ function InvestigateLine() {
70
+ const d = useDiagnose()
71
+ if (!d.available) {
72
+ const label = d.setupState === 'needs-restart' ? 'Check agent setup' : 'Set up an agent'
73
+ return (
74
+ <Tooltip content={notReadyTooltip(d)} wrapperClassName="w-full">
75
+ <button
76
+ type="button"
77
+ onClick={d.openHome}
78
+ className="flex w-full items-center gap-2 rounded px-0.5 text-left text-xs font-medium text-accent-text hover:underline"
79
+ >
80
+ <Sparkles className="h-3.5 w-3.5 shrink-0 text-accent" aria-hidden />
81
+ {label}
82
+ </button>
83
+ </Tooltip>
84
+ )
85
+ }
86
+ const where = d.hosted ? `powered by ${d.agentLabel}` : `runs your own ${d.agentLabel} locally`
87
+ return (
88
+ <Tooltip content={`Start an AI investigation — ${where}`} wrapperClassName="w-full">
89
+ <button
90
+ type="button"
91
+ // Opens the investigations panel's question composer, focused: the
92
+ // composer is where the scope and look-back are chosen before a run.
93
+ onClick={() => openComposer(d)}
94
+ 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"
95
+ >
96
+ <Sparkles className="h-3.5 w-3.5 shrink-0 text-accent" aria-hidden />
97
+ <span className="truncate">
98
+ {d.questions ? `Ask ${d.agentLabel} about this cluster…` : `Investigate with ${d.agentLabel}`}
99
+ </span>
100
+ </button>
101
+ </Tooltip>
102
+ )
103
+ }
@@ -0,0 +1,47 @@
1
+ import type { ReactNode } from 'react'
2
+ import type { LucideIcon } from 'lucide-react'
3
+ import { ArrowRight } from 'lucide-react'
4
+
5
+ interface HomeDiagramCardProps {
6
+ icon: LucideIcon
7
+ title: string
8
+ fact?: ReactNode
9
+ drawing: ReactNode
10
+ caption: ReactNode
11
+ footer: string
12
+ onNavigate: () => void
13
+ }
14
+
15
+ // The frame Home's Topology and Live Traffic cards share: the whole card opens
16
+ // the view, so the drawing and caption carry no controls of their own.
17
+ export function HomeDiagramCard({ icon: Icon, title, fact, drawing, caption, footer, onNavigate }: HomeDiagramCardProps) {
18
+ return (
19
+ <button
20
+ type="button"
21
+ onClick={onNavigate}
22
+ className="group h-[260px] w-full rounded-xl bg-theme-surface shadow-theme-sm hover:-translate-y-1 hover:shadow-theme-md transition-all duration-200 text-left overflow-hidden focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent"
23
+ >
24
+ <div className="flex flex-col h-full w-full">
25
+ <div className="flex items-center justify-between gap-3 px-5 py-3 border-b border-theme-border/50">
26
+ <div className="flex items-center gap-2 shrink-0">
27
+ <Icon className="w-4 h-4 text-theme-text-tertiary" />
28
+ <span className="text-xs font-semibold uppercase tracking-wider text-theme-text-secondary">{title}</span>
29
+ </div>
30
+ {fact && (
31
+ <span className="min-w-0 truncate text-[11px] text-theme-text-tertiary tabular-nums">{fact}</span>
32
+ )}
33
+ </div>
34
+
35
+ <div className="flex-1 min-h-0 flex flex-col px-3 pt-1.5 pb-2.5">
36
+ <div className="flex-1 min-h-0">{drawing}</div>
37
+ <p className="px-2 pt-1 text-[11.5px] leading-snug text-theme-text-secondary">{caption}</p>
38
+ </div>
39
+
40
+ <div className="px-4 py-1.5 border-t border-theme-border/50 flex items-center justify-end gap-1.5 text-[10px] font-semibold uppercase tracking-wider text-theme-text-secondary group-hover:text-theme-text-primary transition-colors">
41
+ {footer}
42
+ <ArrowRight className="w-3.5 h-3.5 transition-transform group-hover:translate-x-0.5" />
43
+ </div>
44
+ </div>
45
+ </button>
46
+ )
47
+ }
@@ -35,6 +35,9 @@ import { UncheckedSourceHelp } from '../issues/UncheckedSourceHelp'
35
35
  import { clsx } from 'clsx'
36
36
  import { getVersionUpdateStatus } from '../../utils/version'
37
37
  import { RadarVersionLine } from './RadarVersionLine'
38
+ import { IssueDiagnoseButton, useIssueDiagnoseShown } from '../diagnose/LocalDiagnoseAction'
39
+ import { recordUsageEvent } from '../../api/usage-data'
40
+ import { HOVER_REVEAL_ACTION, HOVER_REVEAL_HIT, HOVER_REVEAL_REST } from '../../utils/animation'
38
41
 
39
42
  interface HomeViewProps {
40
43
  namespaces: string[]
@@ -54,11 +57,9 @@ interface HomeViewProps {
54
57
  onNavigateToUpgradeImpact?: () => void
55
58
  onNavigateToHelmRelease?: (namespace: string, release: string) => void
56
59
  onNavigateToManagerPath?: (path: string) => void
57
- // Present only when release notes exist for this version.
58
- onShowWhatsNew?: () => void
59
60
  }
60
61
 
61
- export function HomeView({ namespaces, topology, fallbackClusterLoadState, onNavigateToView, onNavigateToResourceKind, onNavigateToResource, onNavigateToCerts, onNavigateToUpgradeImpact, onNavigateToHelmRelease, onNavigateToManagerPath, onShowWhatsNew }: HomeViewProps) {
62
+ export function HomeView({ namespaces, topology, fallbackClusterLoadState, onNavigateToView, onNavigateToResourceKind, onNavigateToResource, onNavigateToCerts, onNavigateToUpgradeImpact, onNavigateToHelmRelease, onNavigateToManagerPath }: HomeViewProps) {
62
63
  // The card itself decides whether the cluster has a capacity story
63
64
  // (available, softened-denied, or karpenterless-with-managers/groups) and
64
65
  // returns null otherwise — the outer gate only excludes states with nothing
@@ -142,11 +143,12 @@ export function HomeView({ namespaces, topology, fallbackClusterLoadState, onNav
142
143
  )}
143
144
  {/* Row 1: Cluster Health Card (combined health + resource counts) */}
144
145
  <ClusterHealthCard
145
- radarVersion={versionInfo && deploymentMode !== 'cloud' ? (
146
+ // A local install shows its version in Settings and upgrades through
147
+ // the update notification; an in-cluster one is upgraded by whoever
148
+ // manages it, and this line is where they confirm the new version.
149
+ radarVersion={versionInfo && deploymentMode === 'in-cluster' ? (
146
150
  <RadarVersionLine
147
151
  version={versionInfo}
148
- showUpgrade={deploymentMode === 'in-cluster'}
149
- onShowWhatsNew={onShowWhatsNew}
150
152
  manager={installationManager}
151
153
  managerLoading={installationManagerLoading}
152
154
  onNavigateToHelmRelease={onNavigateToHelmRelease}
@@ -300,6 +302,26 @@ function BandItem({ children }: { children: ReactNode }) {
300
302
  // Problems Panel (right sidebar, scrollable)
301
303
  // ============================================================================
302
304
 
305
+ // The row's Investigate action is a sibling of the row button (a button can't
306
+ // nest in a button), laid over the right end of line 1. With a pointer, hover
307
+ // or keyboard focus swaps the age and timing chip there for the action; its
308
+ // left edge fades into the hover tint so a long name it overlays isn't
309
+ // hard-clipped. On touch there is no hover, so it sits in the row's flow below
310
+ // the text, always shown.
311
+ const ISSUE_ROW_ACTION_CLASS = clsx(
312
+ 'absolute right-3 top-1.5 flex items-center pl-4',
313
+ 'bg-[linear-gradient(to_right,transparent,var(--color-theme-hover)_1rem)]',
314
+ HOVER_REVEAL_ACTION,
315
+ '[@media(hover:none)]:static [@media(hover:none)]:justify-end [@media(hover:none)]:bg-none [@media(hover:none)]:px-3 [@media(hover:none)]:pb-1.5 [@media(hover:none)]:opacity-100 [@media(hover:none)]:translate-y-0',
316
+ )
317
+ const ISSUE_ROW_ACTION_HIT_CLASS = clsx(HOVER_REVEAL_HIT, 'flex [@media(hover:none)]:pointer-events-auto')
318
+ // Without hover the action isn't in line 1, so nothing there swaps out (the
319
+ // keyboard-focus half of the reveal would otherwise still hide it).
320
+ const ISSUE_ROW_META_TOUCH_CLASS = '[@media(hover:none)]:opacity-100! [@media(hover:none)]:translate-none!'
321
+ // Line 1 is as tall as its kind badge. An invisible zero-width copy of it gives
322
+ // the overlaid action the same height, so it centers on line 1.
323
+ const ISSUE_ROW_STRUT = 'invisible w-0 overflow-hidden px-0 border-x-0 [@media(hover:none)]:hidden'
324
+
303
325
  interface ProblemsPanelProps {
304
326
  issues: Issue[]
305
327
  issueCount: number
@@ -332,6 +354,10 @@ export function ProblemsPanel({
332
354
  onResourceClick,
333
355
  }: ProblemsPanelProps) {
334
356
  const unchecked = uncheckedLines.length > 0
357
+ // While rows swap their age and chip for Investigate, those two lose their
358
+ // tooltips: hovering them is what swaps them out, and the tooltip would open
359
+ // over the action under a pointer that hasn't moved since.
360
+ const canInvestigate = useIssueDiagnoseShown()
335
361
  const hasCriticalIssues = issues.some((issue) => issue.severity === 'critical')
336
362
  const hasIssues = issueCount > 0
337
363
  const hasHardError = !!error && !hasData
@@ -436,50 +462,63 @@ export function ProblemsPanel({
436
462
  const timing = issueTimingForDisplay(issue)
437
463
 
438
464
  return (
439
- <button
440
- key={issue.id}
441
- className="w-full flex items-center gap-2 px-3 py-1.5 hover:bg-theme-hover transition-colors text-left"
442
- onClick={() => onResourceClick({
443
- kind: ref.kind,
444
- namespace: ref.namespace ?? '',
445
- name: ref.name,
446
- group: ref.group ?? '',
447
- })}
448
- >
449
- <StatusDot tone={issue.severity === 'critical' ? 'unhealthy' : 'degraded'} className="shrink-0" />
450
- <div className="min-w-0 flex-1">
451
- <div className="flex items-center gap-1.5">
452
- <span className="text-[10px] text-theme-text-tertiary bg-theme-elevated px-1 py-0.5 rounded">{issue.kind}</span>
453
- <span className="text-xs text-theme-text-primary truncate font-medium">{issue.name}</span>
454
- {(age || timing) && (
455
- <span className="ml-auto flex shrink-0 items-center gap-1">
456
- {age && (
457
- <Tooltip content={issueFirstSeenTitle(issue)} delay={100}>
458
- <span className="text-[10px] text-theme-text-tertiary tabular-nums">{age}</span>
459
- </Tooltip>
460
- )}
461
- {timing && (
462
- <Tooltip content={timing.tooltip} delay={100}>
463
- <span className="badge-sm text-[10px] text-theme-text-secondary">{timing.chip}</span>
464
- </Tooltip>
465
- )}
466
- </span>
465
+ <div key={issue.id} className="group relative">
466
+ <button
467
+ type="button"
468
+ className="w-full flex items-center gap-2 px-3 py-1.5 group-hover:bg-theme-hover group-has-[:focus-visible]:bg-theme-hover transition-colors text-left"
469
+ onClick={() => {
470
+ recordUsageEvent({ type: 'ui', name: 'issue_action:open' })
471
+ onResourceClick({
472
+ kind: ref.kind,
473
+ namespace: ref.namespace ?? '',
474
+ name: ref.name,
475
+ group: ref.group ?? '',
476
+ })
477
+ }}
478
+ >
479
+ <StatusDot tone={issue.severity === 'critical' ? 'unhealthy' : 'degraded'} className="shrink-0" />
480
+ <div className="min-w-0 flex-1">
481
+ <div className="flex items-center gap-1.5">
482
+ <span className="text-[10px] text-theme-text-tertiary bg-theme-elevated px-1 py-0.5 rounded">{issue.kind}</span>
483
+ <span className="text-xs text-theme-text-primary truncate font-medium">{issue.name}</span>
484
+ {(age || timing) && (
485
+ <span className={clsx('ml-auto flex shrink-0 items-center gap-2', canInvestigate && [HOVER_REVEAL_REST, ISSUE_ROW_META_TOUCH_CLASS])}>
486
+ {age && (
487
+ <Tooltip content={issueFirstSeenTitle(issue)} delay={100} disabled={canInvestigate}>
488
+ <span className="text-[10px] text-theme-text-tertiary tabular-nums">{age}</span>
489
+ </Tooltip>
490
+ )}
491
+ {timing && (
492
+ <Tooltip content={timing.tooltip} delay={100} disabled={canInvestigate}>
493
+ <span className="text-[10px] text-theme-text-secondary">{timing.chip}</span>
494
+ </Tooltip>
495
+ )}
496
+ </span>
497
+ )}
498
+ </div>
499
+ <div className="flex items-center gap-1.5 mt-0.5">
500
+ <span className="text-[11px] text-theme-text-secondary truncate">{issueTitle(issue)}</span>
501
+ <span className="text-[10px] text-theme-text-tertiary shrink-0">{groupLabel(issue.category_group)}</span>
502
+ {issue.namespace && <span className="text-[10px] text-theme-text-tertiary shrink-0">{issue.namespace}</span>}
503
+ </div>
504
+ {(issue.reason || issue.message) && (
505
+ <div className="text-[10px] text-theme-text-tertiary truncate mt-0.5">
506
+ {issue.reason}
507
+ {issue.reason && issue.message ? ' - ' : ''}
508
+ {issue.message}
509
+ </div>
467
510
  )}
468
511
  </div>
469
- <div className="flex items-center gap-1.5 mt-0.5">
470
- <span className="text-[11px] text-theme-text-secondary truncate">{issueTitle(issue)}</span>
471
- <span className="text-[10px] text-theme-text-tertiary shrink-0">{groupLabel(issue.category_group)}</span>
472
- {issue.namespace && <span className="text-[10px] text-theme-text-tertiary shrink-0">{issue.namespace}</span>}
512
+ </button>
513
+ {canInvestigate && (
514
+ <div className={ISSUE_ROW_ACTION_CLASS}>
515
+ <span aria-hidden className={clsx(ISSUE_ROW_STRUT, 'text-[10px] py-0.5')}>{'\u200b'}</span>
516
+ <span className={ISSUE_ROW_ACTION_HIT_CLASS}>
517
+ <IssueDiagnoseButton size="compact" kind={ref.kind} group={ref.group} namespace={ref.namespace ?? ''} name={ref.name} />
518
+ </span>
473
519
  </div>
474
- {(issue.reason || issue.message) && (
475
- <div className="text-[10px] text-theme-text-tertiary truncate mt-0.5">
476
- {issue.reason}
477
- {issue.reason && issue.message ? ' - ' : ''}
478
- {issue.message}
479
- </div>
480
- )}
481
- </div>
482
- </button>
520
+ )}
521
+ </div>
483
522
  )
484
523
  })}
485
524
  </div>