@skyhook-io/radar-app 1.22.2 → 1.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/package.json +8 -8
  2. package/src/App.tsx +49 -13
  3. package/src/RadarApp.basename.test.tsx +177 -0
  4. package/src/RadarApp.settings.test.tsx +33 -0
  5. package/src/api/agentSandbox.ts +259 -0
  6. package/src/api/client.autoPromConnect.test.tsx +43 -0
  7. package/src/api/client.metricsRelayCheck.test.tsx +134 -0
  8. package/src/api/client.ts +151 -27
  9. package/src/api/client.updateResource.secretExpiry.test.tsx +47 -0
  10. package/src/api/cloudInstallDiscover.test.tsx +76 -0
  11. package/src/api/diagnose.ts +4 -0
  12. package/src/api/kagent.test.ts +82 -0
  13. package/src/api/kagent.ts +230 -0
  14. package/src/api/poll.ts +78 -0
  15. package/src/api/prometheusCharts.ts +5 -0
  16. package/src/api/radarFeatures.test.ts +9 -0
  17. package/src/api/radarFeatures.ts +16 -0
  18. package/src/api/substrateWorkspace.test.ts +72 -0
  19. package/src/api/substrateWorkspace.ts +1394 -0
  20. package/src/api/vulnerabilities.ts +207 -9
  21. package/src/api/workloadSource.test.tsx +315 -0
  22. package/src/api/workloadSource.ts +128 -12
  23. package/src/components/CloudConnectFlow.tsx +46 -7
  24. package/src/components/CloudFunnelButton.test.tsx +193 -7
  25. package/src/components/CloudFunnelButton.tsx +128 -32
  26. package/src/components/SelfManagedStart.tsx +12 -2
  27. package/src/components/agentsandbox/AgentSandboxKindLists.tsx +41 -0
  28. package/src/components/agentsandbox/AgentSandboxLists.test.tsx +410 -0
  29. package/src/components/agentsandbox/AgentSandboxOverview.test.tsx +333 -0
  30. package/src/components/agentsandbox/AgentSandboxOverview.tsx +555 -0
  31. package/src/components/agentsandbox/AgentSandboxSidebar.test.tsx +97 -0
  32. package/src/components/agentsandbox/AgentSandboxSummary.test.tsx +439 -0
  33. package/src/components/agentsandbox/AgentSandboxSummary.tsx +956 -0
  34. package/src/components/agentsandbox/AgentSandboxTables.tsx +966 -0
  35. package/src/components/agentsandbox/AgentSandboxView.tsx +34 -0
  36. package/src/components/agentsandbox/agentsandbox.fixtures.ts +135 -0
  37. package/src/components/agentsandbox/data.ts +135 -0
  38. package/src/components/agentsandbox/host.test.ts +27 -0
  39. package/src/components/agentsandbox/host.tsx +85 -0
  40. package/src/components/agentsandbox/labels.test.ts +42 -0
  41. package/src/components/agentsandbox/labels.ts +146 -0
  42. package/src/components/agentsandbox/listFilters.ts +85 -0
  43. package/src/components/agentsandbox/lists.ts +52 -0
  44. package/src/components/agentsandbox/routes.ts +23 -0
  45. package/src/components/agentsandbox/shared.tsx +321 -0
  46. package/src/components/agentsandbox/useAgentSandboxSidebarWorkspace.ts +69 -0
  47. package/src/components/agentsandbox/workspace.fixtures.ts +125 -0
  48. package/src/components/agentsandbox/workspace.tsx +258 -0
  49. package/src/components/agentsandbox/workspaceRoute.ts +18 -0
  50. package/src/components/applications/ApplicationsView.openResource.test.tsx +248 -3
  51. package/src/components/applications/ApplicationsView.tsx +156 -3
  52. package/src/components/audit/VulnerabilitiesColumns.test.tsx +487 -0
  53. package/src/components/audit/VulnerabilitiesRisk.test.tsx +318 -0
  54. package/src/components/audit/VulnerabilitiesView.test.tsx +458 -13
  55. package/src/components/audit/VulnerabilitiesView.tsx +639 -199
  56. package/src/components/cloudHints/AgentSetupCloudRow.tsx +28 -0
  57. package/src/components/cloudHints/CloudHintLink.tsx +29 -0
  58. package/src/components/cloudHints/SharedInstallAiLine.tsx +36 -0
  59. package/src/components/cloudHints/cloudHints.test.ts +126 -0
  60. package/src/components/cloudHints/cloudHints.ts +131 -0
  61. package/src/components/cloudHints/cloudHintsGate.test.tsx +70 -0
  62. package/src/components/cloudHints/cloudLinks.test.ts +52 -0
  63. package/src/components/cloudHints/cloudLinks.ts +31 -0
  64. package/src/components/cloudHints/hintStorage.ts +28 -0
  65. package/src/components/cnpg/CNPGView.tsx +4 -7
  66. package/src/components/diagnose/AgentSetupNotice.tsx +5 -0
  67. package/src/components/diagnose/DiagnoseContext.tsx +7 -0
  68. package/src/components/diagnose/DiagnoseSurface.escape.test.tsx +215 -0
  69. package/src/components/diagnose/DiagnoseSurface.tsx +57 -1
  70. package/src/components/gitops/RemoteDestinationCloudHint.tsx +6 -14
  71. package/src/components/helm/HelmDrawerRouting.test.tsx +34 -1
  72. package/src/components/helm/HelmReleaseDrawer.tsx +6 -4
  73. package/src/components/helm/HelmView.tsx +4 -3
  74. package/src/components/helm/ObservedHelmNotice.tsx +39 -17
  75. package/src/components/helm/ObservedHelmRelease.test.tsx +62 -3
  76. package/src/components/helm/ObservedHelmReleaseDrawer.test.tsx +18 -0
  77. package/src/components/helm/ObservedHelmReleaseDrawer.tsx +4 -2
  78. package/src/components/home/HomeAgentBlock.tsx +2 -0
  79. package/src/components/home/HomeView.tsx +3 -3
  80. package/src/components/home/MCPSetupDialog.test.tsx +9 -0
  81. package/src/components/home/MCPSetupDialog.tsx +6 -2
  82. package/src/components/home/McpCloudLine.test.tsx +162 -0
  83. package/src/components/home/McpCloudLine.tsx +95 -0
  84. package/src/components/home/ProblemsPanel.investigate.test.tsx +2 -2
  85. package/src/components/home/mcpToolCatalog.test.ts +10 -0
  86. package/src/components/home/mcpToolCatalog.ts +4 -4
  87. package/src/components/issues/ClusterSchedulingBlockerRow.tsx +35 -0
  88. package/src/components/issues/IssuesPane.render.test.tsx +36 -1
  89. package/src/components/issues/IssuesPane.tsx +181 -23
  90. package/src/components/issues/SinceLastVisitRow.render.test.tsx +302 -0
  91. package/src/components/issues/SinceLastVisitRow.tsx +71 -0
  92. package/src/components/issues/sinceLastVisit.test.ts +266 -0
  93. package/src/components/issues/sinceLastVisit.ts +439 -0
  94. package/src/components/issues/uncheckedSources.test.ts +8 -0
  95. package/src/components/issues/uncheckedSources.ts +3 -0
  96. package/src/components/kagent/KagentAgentRenderer.test.ts +32 -0
  97. package/src/components/kagent/KagentAgentRenderer.tsx +87 -0
  98. package/src/components/kagent/KagentAgentSessions.test.tsx +166 -0
  99. package/src/components/kagent/KagentAgentSessions.tsx +124 -0
  100. package/src/components/kagent/KagentDetailPage.tsx +106 -0
  101. package/src/components/kagent/KagentLists.tsx +412 -0
  102. package/src/components/kagent/KagentOverview.tsx +234 -0
  103. package/src/components/kagent/KagentPages.tsx +690 -0
  104. package/src/components/kagent/KagentRuntimeTabs.test.tsx +219 -0
  105. package/src/components/kagent/KagentRuntimeTabs.tsx +283 -0
  106. package/src/components/kagent/KagentSidebar.test.tsx +112 -0
  107. package/src/components/kagent/KagentView.tsx +109 -0
  108. package/src/components/kagent/KagentWorkspace.test.tsx +876 -0
  109. package/src/components/kagent/host.tsx +144 -0
  110. package/src/components/kagent/routes.ts +31 -0
  111. package/src/components/kagent/shared.tsx +336 -0
  112. package/src/components/kagent/useKagentRuntime.test.tsx +77 -0
  113. package/src/components/kagent/useKagentSidebarWorkspace.ts +67 -0
  114. package/src/components/kagent/workspace.fixtures.ts +108 -0
  115. package/src/components/kagent/workspaceRoute.ts +18 -0
  116. package/src/components/nudges/activeNudges.test.ts +39 -0
  117. package/src/components/nudges/activeNudges.ts +76 -0
  118. package/src/components/poll/OssPoll.tsx +871 -0
  119. package/src/components/poll/mount.test.ts +12 -0
  120. package/src/components/poll/pollCloud.test.ts +23 -0
  121. package/src/components/poll/pollCloud.ts +6 -0
  122. package/src/components/poll/pollDefinition.ts +93 -0
  123. package/src/components/poll/pollFlow.test.ts +140 -0
  124. package/src/components/poll/pollFlow.ts +137 -0
  125. package/src/components/poll/pollSender.test.ts +137 -0
  126. package/src/components/poll/pollSender.ts +76 -0
  127. package/src/components/poll/pollStorage.test.ts +53 -0
  128. package/src/components/poll/pollStorage.ts +77 -0
  129. package/src/components/poll/round.json +350 -0
  130. package/src/components/product-hunt/ProductHuntNotice.tsx +2 -0
  131. package/src/components/resource/MetricsNotConnected.test.tsx +28 -0
  132. package/src/components/resource/MetricsNotConnected.tsx +10 -7
  133. package/src/components/resource/PrometheusCharts.tsx +10 -1
  134. package/src/components/resource/PrometheusChartsGrid.render.test.tsx +9 -0
  135. package/src/components/resource/PrometheusChartsGrid.tsx +3 -3
  136. package/src/components/resource/SubstrateHealthCharts.test.tsx +13 -1
  137. package/src/components/resource/SubstrateHealthCharts.tsx +9 -15
  138. package/src/components/resources/ImageFilesystemModal.test.tsx +21 -1
  139. package/src/components/resources/ImageFilesystemModal.tsx +42 -3
  140. package/src/components/resources/ResourceDetailDrawer.tsx +1 -0
  141. package/src/components/resources/ResourcesView.tsx +24 -11
  142. package/src/components/resources/renderers/PodRenderer.tsx +8 -2
  143. package/src/components/settings/LocalIntegrationStatus.test.tsx +1 -0
  144. package/src/components/settings/LocalIntegrationStatus.tsx +3 -2
  145. package/src/components/settings/SettingsDialog.tsx +84 -16
  146. package/src/components/settings/SubstrateSettings.lifecycle.test.tsx +210 -0
  147. package/src/components/settings/SubstrateSettings.test.tsx +131 -0
  148. package/src/components/settings/SubstrateSettings.tsx +544 -0
  149. package/src/components/settings/settings-state.test.ts +21 -3
  150. package/src/components/settings/settings-state.ts +13 -3
  151. package/src/components/share/ShareLinkButton.test.tsx +360 -0
  152. package/src/components/share/ShareLinkButton.tsx +391 -0
  153. package/src/components/share/openShareInCloud.test.ts +29 -0
  154. package/src/components/share/openShareInCloud.ts +10 -0
  155. package/src/components/share/shareLink.test.ts +129 -0
  156. package/src/components/share/shareLink.ts +175 -0
  157. package/src/components/substrate/SubstrateActorDrawer.tsx +87 -0
  158. package/src/components/substrate/SubstrateActorOverview.tsx +489 -0
  159. package/src/components/substrate/SubstrateActorPage.tsx +384 -0
  160. package/src/components/substrate/SubstrateActors.test.tsx +1094 -0
  161. package/src/components/substrate/SubstrateActors.tsx +612 -0
  162. package/src/components/substrate/SubstrateAttentionList.tsx +441 -0
  163. package/src/components/substrate/SubstrateConnect.tsx +88 -0
  164. package/src/components/substrate/SubstrateOverview.test.tsx +396 -0
  165. package/src/components/substrate/SubstrateOverview.tsx +575 -0
  166. package/src/components/substrate/SubstratePages.test.tsx +478 -0
  167. package/src/components/substrate/SubstratePool.test.tsx +462 -0
  168. package/src/components/substrate/SubstratePoolPage.tsx +95 -0
  169. package/src/components/substrate/SubstratePoolSummary.tsx +485 -0
  170. package/src/components/substrate/SubstrateSidebar.test.tsx +101 -0
  171. package/src/components/substrate/SubstrateStateBar.tsx +63 -0
  172. package/src/components/substrate/SubstrateTemplates.tsx +376 -0
  173. package/src/components/substrate/SubstrateView.tsx +173 -0
  174. package/src/components/substrate/SubstrateWorkerPodContext.tsx +73 -0
  175. package/src/components/substrate/SubstrateWorkers.tsx +389 -0
  176. package/src/components/substrate/attention.ts +81 -0
  177. package/src/components/substrate/contextPin.tsx +69 -0
  178. package/src/components/substrate/host.tsx +83 -0
  179. package/src/components/substrate/kubectlTarget.test.tsx +77 -0
  180. package/src/components/substrate/readings.test.ts +484 -0
  181. package/src/components/substrate/readings.ts +997 -0
  182. package/src/components/substrate/routes.ts +103 -0
  183. package/src/components/substrate/shared.tsx +426 -0
  184. package/src/components/substrate/substrate.fixtures.ts +325 -0
  185. package/src/components/substrate/useSubstrateSidebarWorkspace.ts +87 -0
  186. package/src/components/substrate/workspaceRoute.ts +23 -0
  187. package/src/components/traffic/TrafficConnectionsTable.test.tsx +9 -0
  188. package/src/components/traffic/TrafficConnectionsTable.tsx +4 -2
  189. package/src/components/traffic/TrafficFilterSidebar.tsx +19 -14
  190. package/src/components/traffic/TrafficFlowList.test.tsx +63 -0
  191. package/src/components/traffic/TrafficFlowList.tsx +9 -5
  192. package/src/components/traffic/TrafficGraph.test.tsx +26 -0
  193. package/src/components/traffic/TrafficGraph.tsx +17 -14
  194. package/src/components/traffic/TrafficGraphTooLarge.tsx +2 -0
  195. package/src/components/traffic/TrafficGraphUnavailable.tsx +3 -1
  196. package/src/components/traffic/TrafficView.tsx +26 -56
  197. package/src/components/traffic/trafficFilters.test.ts +61 -1
  198. package/src/components/traffic/trafficFilters.ts +68 -8
  199. package/src/components/ui/UpdateNotification.tsx +2 -0
  200. package/src/components/usage-data/UsageDataPrompt.tsx +2 -0
  201. package/src/components/velero/VeleroOverview.tsx +2 -2
  202. package/src/components/velero/VeleroView.tsx +3 -6
  203. package/src/components/vulnerabilities/columns.tsx +132 -0
  204. package/src/components/vulnerabilities/filters.tsx +317 -0
  205. package/src/components/vulnerabilities/owner.test.ts +54 -0
  206. package/src/components/vulnerabilities/owner.tsx +163 -0
  207. package/src/components/vulnerabilities/parts.test.ts +126 -12
  208. package/src/components/vulnerabilities/parts.tsx +612 -52
  209. package/src/components/vulnerabilities/traffic.test.tsx +65 -0
  210. package/src/components/vulnerabilities/traffic.tsx +40 -0
  211. package/src/components/whats-new/WhatsNew.tsx +2 -0
  212. package/src/components/whats-new/releaseNotes.ts +75 -1
  213. package/src/components/workload/WorkloadView.substrateVersion.test.tsx +88 -0
  214. package/src/components/workload/WorkloadView.tsx +52 -13
  215. package/src/components/workspace/layout.tsx +13 -7
  216. package/src/components/workspace/sidebar.test.ts +48 -0
  217. package/src/components/workspace/sidebar.ts +73 -3
  218. package/src/components/workspace/table.ts +2 -1
  219. package/src/contexts/RegistryAccessMode.test.tsx +51 -0
  220. package/src/contexts/RegistryAccessMode.tsx +25 -0
  221. package/src/integrations/resourceHost.ts +12 -6
  222. package/src/integrations/resourceHosts.test.tsx +27 -1
  223. package/src/integrations/resourceHosts.tsx +15 -7
  224. package/src/integrations/sidebarWorkspaces.test.tsx +63 -0
  225. package/src/integrations/sidebarWorkspaces.ts +41 -0
  226. package/src/integrations/workspaceRoute.ts +1 -1
  227. package/src/integrations/workspaceRoutes.ts +7 -1
  228. package/src/integrations/workspaceScreens.tsx +6 -0
@@ -0,0 +1,28 @@
1
+ import { ArrowRight } from 'lucide-react'
2
+ import { openCloudFunnel } from './cloudHints'
3
+
4
+ // One more option under the local agent list, drawn like the agent cards so it
5
+ // reads as a choice, not an ad: its name where theirs is, "Learn more" where
6
+ // their Docs link is, and what it does where their install command is. Its
7
+ // arrow points on, not out: it opens the Cloud dialog here, not a new tab. It
8
+ // always follows the local options. Callers gate on useCloudHintsEnabled.
9
+ export function AgentSetupCloudRow() {
10
+ return (
11
+ <div className="mt-2.5 rounded-lg border border-theme-border bg-theme-base p-3">
12
+ <div className="mb-2 flex items-center justify-between gap-2">
13
+ <span className="text-sm font-medium text-theme-text-primary">Radar Cloud</span>
14
+ <button
15
+ type="button"
16
+ onClick={() => openCloudFunnel('ai-setup')}
17
+ className="inline-flex items-center gap-1 text-xs text-theme-text-tertiary hover:text-theme-text-primary"
18
+ >
19
+ Learn more
20
+ <ArrowRight className="h-3 w-3" aria-hidden />
21
+ </button>
22
+ </div>
23
+ <p className="rounded-md bg-theme-elevated px-2 py-1.5 text-xs leading-relaxed text-theme-text-secondary">
24
+ Runs investigations for you, with no agent CLI or API key on this machine. It can also start one when an alert fires.
25
+ </p>
26
+ </div>
27
+ )
28
+ }
@@ -0,0 +1,29 @@
1
+ import type { ReactNode } from 'react'
2
+ import { openCloudFunnel, type CloudHintEntry } from './cloudHints'
3
+
4
+ // The "Radar Cloud" words in a hint sentence, as a faint link: the sentence's
5
+ // own colour with a quiet underline, so the hint stays a remark rather than a
6
+ // call to action. Opens the one Cloud dialog. Hints whose action is a button
7
+ // name Radar Cloud as plain text instead. Callers gate on useCloudHintsEnabled.
8
+ export function CloudHintLink({
9
+ entry,
10
+ children = 'Radar Cloud',
11
+ onBeforeOpen,
12
+ }: {
13
+ entry: CloudHintEntry
14
+ children?: ReactNode
15
+ // Lets a host close its own dialog first (through its close guard) and open
16
+ // the Cloud dialog only once that has happened.
17
+ onBeforeOpen?: (open: () => void) => void
18
+ }) {
19
+ const open = () => openCloudFunnel(entry)
20
+ return (
21
+ <button
22
+ type="button"
23
+ onClick={() => (onBeforeOpen ? onBeforeOpen(open) : open())}
24
+ className="underline decoration-theme-border underline-offset-2 hover:text-theme-text-primary"
25
+ >
26
+ {children}
27
+ </button>
28
+ )
29
+ }
@@ -0,0 +1,36 @@
1
+ import { useState } from 'react'
2
+ import { Sparkles, X } from 'lucide-react'
3
+ import { CloudHintLink } from './CloudHintLink'
4
+ import { dismissCloudHint, isCloudHintDismissed } from './cloudHints'
5
+ import { Tooltip } from '../ui/Tooltip'
6
+
7
+ // In a team installation, where local AI investigations can't run, the issue
8
+ // list says so once instead of offering an Investigate button that leads
9
+ // nowhere. The X hides it for good. Callers gate on useCloudHintsEnabled and
10
+ // on the server reporting a shared installation.
11
+ export function SharedInstallAiLine() {
12
+ const [hidden, setHidden] = useState(() => isCloudHintDismissed('ai-shared'))
13
+ if (hidden) return null
14
+ return (
15
+ <div role="note" className="flex items-center gap-2.5 rounded-lg border border-theme-border bg-theme-base px-3 py-2">
16
+ <Sparkles className="h-3.5 w-3.5 shrink-0 text-theme-text-tertiary" aria-hidden />
17
+ <span className="min-w-0 flex-1 text-xs text-theme-text-tertiary">
18
+ AI investigations aren't available in this shared installation. Run Radar locally with an agent CLI, or use{' '}
19
+ <CloudHintLink entry="ai-shared" />.
20
+ </span>
21
+ <Tooltip content="Don't show again" delay={100} wrapperClassName="shrink-0">
22
+ <button
23
+ type="button"
24
+ aria-label="Don't show again"
25
+ onClick={() => {
26
+ dismissCloudHint('ai-shared')
27
+ setHidden(true)
28
+ }}
29
+ className="shrink-0 rounded-md p-1 text-theme-text-tertiary transition-colors hover:bg-theme-hover hover:text-theme-text-primary"
30
+ >
31
+ <X className="h-3.5 w-3.5" />
32
+ </button>
33
+ </Tooltip>
34
+ </div>
35
+ )
36
+ }
@@ -0,0 +1,126 @@
1
+ // @vitest-environment jsdom
2
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
3
+ import {
4
+ OPEN_CLOUD_FUNNEL_EVENT,
5
+ dismissCloudHint,
6
+ isCloudHintDismissed,
7
+ isCloudHintEntry,
8
+ readOpenRequest,
9
+ withCloudHintEntry,
10
+ } from './cloudHints'
11
+ import { clearHintMemory } from './hintStorage'
12
+
13
+ beforeEach(() => {
14
+ window.localStorage.clear()
15
+ clearHintMemory()
16
+ })
17
+
18
+ afterEach(() => {
19
+ vi.restoreAllMocks()
20
+ })
21
+
22
+ describe('open request', () => {
23
+ it('accepts a known entry and its subject', () => {
24
+ const event = new CustomEvent(OPEN_CLOUD_FUNNEL_EVENT, {
25
+ detail: { entry: 'share', subject: { intent: 'share', kind: 'Pod', name: 'api-1', namespace: 'shop', context: 'prod' } },
26
+ })
27
+ expect(readOpenRequest(event)).toEqual({
28
+ entry: 'share',
29
+ subject: { intent: 'share', kind: 'Pod', name: 'api-1', namespace: 'shop', context: 'prod' },
30
+ view: 'pitch',
31
+ })
32
+ })
33
+
34
+ it('drops a forged entry, and a subject that arrives without a valid entry', () => {
35
+ const forged = new CustomEvent(OPEN_CLOUD_FUNNEL_EVENT, {
36
+ detail: { entry: '"><script>', subject: { kind: 'Pod', name: 'x' } },
37
+ })
38
+ expect(readOpenRequest(forged)).toEqual({ entry: null, subject: null, view: 'pitch' })
39
+ })
40
+
41
+ it('drops a malformed subject but keeps the entry', () => {
42
+ const event = new CustomEvent(OPEN_CLOUD_FUNNEL_EVENT, { detail: { entry: 'share', subject: { kind: 3 } } })
43
+ expect(readOpenRequest(event)).toEqual({ entry: 'share', subject: null, view: 'pitch' })
44
+ })
45
+
46
+ it('drops a subject that names no cluster, or comes with another entry', () => {
47
+ const read = (detail: unknown) => readOpenRequest(new CustomEvent(OPEN_CLOUD_FUNNEL_EVENT, { detail }))
48
+ const pod = { intent: 'share', kind: 'Pod', name: 'api-1', namespace: 'shop' }
49
+ expect(read({ entry: 'share', subject: pod }).subject).toBeNull()
50
+ expect(read({ entry: 'share', subject: { ...pod, context: '' } }).subject).toBeNull()
51
+ expect(read({ entry: 'ai-setup', subject: { ...pod, context: 'prod' } })).toEqual({ entry: 'ai-setup', subject: null, view: 'pitch' })
52
+ })
53
+
54
+ it('drops a subject with an intent it does not know', () => {
55
+ const event = new CustomEvent(OPEN_CLOUD_FUNNEL_EVENT, {
56
+ detail: { entry: 'share', subject: { intent: 'alert', kind: 'Pod', name: 'api-1' } },
57
+ })
58
+ expect(readOpenRequest(event).subject).toBeNull()
59
+ })
60
+
61
+ it('treats a plain event (the globe button) as no entry', () => {
62
+ expect(readOpenRequest(new Event(OPEN_CLOUD_FUNNEL_EVENT))).toEqual({ entry: null, subject: null, view: 'pitch' })
63
+ })
64
+
65
+ it('knows only the listed entries', () => {
66
+ expect(isCloudHintEntry('ai-setup')).toBe(true)
67
+ expect(isCloudHintEntry('alert-issue')).toBe(false)
68
+ expect(isCloudHintEntry(undefined)).toBe(false)
69
+ })
70
+ })
71
+
72
+ describe('link tagging', () => {
73
+ it('adds utm_term and keeps the existing campaign parameters', () => {
74
+ const tagged = withCloudHintEntry(
75
+ 'https://app.radarhq.io/signup?utm_source=radar-oss&utm_content=wizard-signup-button',
76
+ 'ai-setup',
77
+ )
78
+ const url = new URL(tagged)
79
+ expect(url.searchParams.get('utm_term')).toBe('ai-setup')
80
+ expect(url.searchParams.get('utm_content')).toBe('wizard-signup-button')
81
+ })
82
+
83
+ it('leaves the link alone without an entry, and never breaks an unparsable one', () => {
84
+ expect(withCloudHintEntry('https://app.radarhq.io/signup', null)).toBe('https://app.radarhq.io/signup')
85
+ expect(withCloudHintEntry('not a url', 'settings-ai')).toBe('not a url')
86
+ })
87
+ })
88
+
89
+ describe('dismissal', () => {
90
+ it('persists', () => {
91
+ expect(isCloudHintDismissed('ai-shared')).toBe(false)
92
+ dismissCloudHint('ai-shared')
93
+ expect(isCloudHintDismissed('ai-shared')).toBe(true)
94
+ })
95
+
96
+ it('still works when storage throws', () => {
97
+ vi.spyOn(Storage.prototype, 'getItem').mockImplementation(() => {
98
+ throw new DOMException('denied', 'SecurityError')
99
+ })
100
+ vi.spyOn(Storage.prototype, 'setItem').mockImplementation(() => {
101
+ throw new DOMException('denied', 'SecurityError')
102
+ })
103
+ expect(isCloudHintDismissed('ai-shared')).toBe(false)
104
+ expect(() => dismissCloudHint('ai-shared')).not.toThrow()
105
+ // Holds until reload even though storage refused it.
106
+ expect(isCloudHintDismissed('ai-shared')).toBe(true)
107
+ })
108
+ })
109
+
110
+ describe('poll entry', () => {
111
+ it('reads the view, defaulting to the pitch and ignoring anything else', () => {
112
+ const read = (detail: unknown) => readOpenRequest(new CustomEvent(OPEN_CLOUD_FUNNEL_EVENT, { detail }))
113
+ expect(read({ entry: 'oss-poll', view: 'self-managed' }).view).toBe('self-managed')
114
+ expect(read({ entry: 'oss-poll' }).view).toBe('pitch')
115
+ expect(read({ entry: 'oss-poll', view: 'admin' }).view).toBe('pitch')
116
+ })
117
+
118
+ it('replaces the campaign for the poll only', () => {
119
+ const url = 'https://app.example/signup?utm_source=radar-oss&utm_medium=app&utm_campaign=cloud-modal&utm_content=x'
120
+ const poll = new URL(withCloudHintEntry(url, 'oss-poll')).searchParams
121
+ expect(poll.get('utm_campaign')).toBe('oss-poll')
122
+ expect(poll.get('utm_term')).toBe('oss-poll')
123
+ expect(poll.get('utm_content')).toBe('x')
124
+ expect(new URL(withCloudHintEntry(url, 'share')).searchParams.get('utm_campaign')).toBe('cloud-modal')
125
+ })
126
+ })
@@ -0,0 +1,131 @@
1
+ import { useCapabilities } from '../../api/client'
2
+ import { useNavCustomization } from '../../context/NavCustomization'
3
+ import { local, safeGet, safeSet } from './hintStorage'
4
+
5
+ // In-context pointers to Radar Cloud. Each names the surface it came from,
6
+ // one of the fixed names below, and nothing about the cluster or the person.
7
+ // The name goes out twice: on the dialog's copy fetch to Radar Cloud when the
8
+ // dialog opens, and as utm_term on the Radar Cloud links the person clicks. A
9
+ // share also puts the resource's kind, namespace and name in the one link that
10
+ // opens it in Radar Cloud.
11
+ export const CLOUD_HINT_ENTRIES = [
12
+ 'ai-setup',
13
+ 'ai-shared',
14
+ 'settings-ai',
15
+ 'gitops-remote',
16
+ 'oss-poll',
17
+ 'since-last-visit',
18
+ 'share',
19
+ 'mcp',
20
+ ] as const
21
+ export type CloudHintEntry = (typeof CLOUD_HINT_ENTRIES)[number]
22
+
23
+ const ENTRY_SET: ReadonlySet<string> = new Set(CLOUD_HINT_ENTRIES)
24
+
25
+ // The open event is a window event any script can dispatch, so its payload is
26
+ // validated before it reaches a URL.
27
+ export function isCloudHintEntry(value: unknown): value is CloudHintEntry {
28
+ return typeof value === 'string' && ENTRY_SET.has(value)
29
+ }
30
+
31
+ // What a hint was looking at, shown back in the Cloud dialog and used to build
32
+ // the Radar Cloud link that picks up where the person left off: this resource,
33
+ // for the team to open ("share"). The kubeconfig context names the cluster the
34
+ // resource lives in; a link is built only from that cluster's Radar Cloud URL.
35
+ export interface CloudHintSubject {
36
+ intent?: 'share'
37
+ kind: string
38
+ group?: string
39
+ name: string
40
+ namespace?: string
41
+ context: string
42
+ }
43
+
44
+ function isHintSubject(value: unknown): value is CloudHintSubject {
45
+ if (!value || typeof value !== 'object') return false
46
+ const v = value as Record<string, unknown>
47
+ const optionalString = (x: unknown) => x === undefined || typeof x === 'string'
48
+ return (
49
+ (v.intent === undefined || v.intent === 'share') &&
50
+ optionalString(v.group) &&
51
+ typeof v.kind === 'string' &&
52
+ typeof v.name === 'string' &&
53
+ optionalString(v.namespace) &&
54
+ typeof v.context === 'string' &&
55
+ v.context !== ''
56
+ )
57
+ }
58
+
59
+ // Where the dialog opens: the Radar Cloud pitch, or the Self-Managed view a
60
+ // person reaches from it with "Self-host Radar Cloud in your network".
61
+ export type CloudFunnelView = 'pitch' | 'self-managed'
62
+
63
+ export interface CloudFunnelOpenRequest {
64
+ entry: CloudHintEntry | null
65
+ subject: CloudHintSubject | null
66
+ view: CloudFunnelView
67
+ }
68
+
69
+ export const OPEN_CLOUD_FUNNEL_EVENT = 'radar:open-cloud-funnel'
70
+
71
+ // Other OSS surfaces point at Radar Cloud by asking the top-bar button to open
72
+ // its dialog, so there is one dialog and one connect flow. The button is
73
+ // mounted whenever Radar runs standalone; embedded hosts never mount it, and
74
+ // every hint checks useCloudHintsEnabled before rendering.
75
+ export function openCloudFunnel(entry?: CloudHintEntry, subject?: CloudHintSubject, view?: CloudFunnelView) {
76
+ window.dispatchEvent(new CustomEvent(OPEN_CLOUD_FUNNEL_EVENT, { detail: { entry, subject, view } }))
77
+ }
78
+
79
+ export function readOpenRequest(event: Event): CloudFunnelOpenRequest {
80
+ const detail = event instanceof CustomEvent ? (event.detail as Record<string, unknown> | null) : null
81
+ const entry = isCloudHintEntry(detail?.entry) ? detail.entry : null
82
+ const subject = entry === 'share' && isHintSubject(detail?.subject) ? detail.subject : null
83
+ const view = detail?.view === 'self-managed' ? 'self-managed' : 'pitch'
84
+ return { entry, subject, view }
85
+ }
86
+
87
+ // Entries that are their own campaign rather than one more way into the
88
+ // dialog: their links carry this utm_campaign in place of cloud-modal.
89
+ const ENTRY_CAMPAIGN: Partial<Record<CloudHintEntry, string>> = {
90
+ 'oss-poll': 'oss-poll',
91
+ }
92
+
93
+ // Adds the entry as utm_term to a link into the Hub. utm_content keeps naming
94
+ // the link that was clicked; utm_term says which hint opened the dialog. An
95
+ // entry with a campaign of its own also replaces utm_campaign.
96
+ export function withCloudHintEntry(url: string, entry: CloudHintEntry | null | undefined): string {
97
+ if (!entry || !isCloudHintEntry(entry)) return url
98
+ try {
99
+ const u = new URL(url)
100
+ u.searchParams.set('utm_term', entry)
101
+ const campaign = ENTRY_CAMPAIGN[entry]
102
+ if (campaign) u.searchParams.set('utm_campaign', campaign)
103
+ return u.toString()
104
+ } catch {
105
+ return url
106
+ }
107
+ }
108
+
109
+ // The same rule the top-bar button follows: the server decides whether there
110
+ // is anything to point at (cloudConnect is absent in cloud mode, on a
111
+ // tunneled install, out of the rollout cohort, or with RADAR_CLOUD_FUNNEL=off),
112
+ // and embedded hosts never show Radar Cloud hints. An operator can hide the
113
+ // hints alone (hintsOff) and keep the button.
114
+ export function useCloudHintsEnabled(): boolean {
115
+ const { embedded } = useNavCustomization()
116
+ const capabilities = useCapabilities()
117
+ const cloudConnect = capabilities.data?.cloudConnect
118
+ return !embedded && !!cloudConnect && !cloudConnect.hintsOff
119
+ }
120
+
121
+ export type CloudHintSurface = 'ai-shared'
122
+
123
+ const dismissKey = (surface: CloudHintSurface) => `radar.cloudHint.${surface}.dismissed`
124
+
125
+ export function isCloudHintDismissed(surface: CloudHintSurface): boolean {
126
+ return safeGet(local, dismissKey(surface)) === 'true'
127
+ }
128
+
129
+ export function dismissCloudHint(surface: CloudHintSurface) {
130
+ safeSet(local, dismissKey(surface), 'true')
131
+ }
@@ -0,0 +1,70 @@
1
+ // @vitest-environment jsdom
2
+ import { act } from 'react'
3
+ import { createRoot, type Root } from 'react-dom/client'
4
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
5
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
6
+ import { NavCustomizationProvider } from '../../context/NavCustomization'
7
+ import { useCloudHintsEnabled } from './cloudHints'
8
+
9
+ Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
10
+ let root: Root
11
+ let client: QueryClient
12
+ let capabilities: Record<string, unknown>
13
+
14
+ beforeEach(() => {
15
+ client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
16
+ const element = document.createElement('div')
17
+ document.body.appendChild(element)
18
+ root = createRoot(element)
19
+ vi.stubGlobal('fetch', vi.fn(async () => new Response(JSON.stringify(capabilities), { status: 200 })))
20
+ })
21
+
22
+ afterEach(async () => {
23
+ await act(async () => root.unmount())
24
+ client.clear()
25
+ document.body.replaceChildren()
26
+ vi.unstubAllGlobals()
27
+ })
28
+
29
+ function Probe() {
30
+ return <span data-testid="gate">{useCloudHintsEnabled() ? 'on' : 'off'}</span>
31
+ }
32
+
33
+ async function gate(embedded: boolean) {
34
+ await act(async () => {
35
+ root.render(
36
+ <QueryClientProvider client={client}>
37
+ <NavCustomizationProvider value={{ embedded }}>
38
+ <Probe />
39
+ </NavCustomizationProvider>
40
+ </QueryClientProvider>,
41
+ )
42
+ })
43
+ await vi.waitFor(async () => {
44
+ await act(async () => { await new Promise(resolve => setTimeout(resolve, 0)) })
45
+ expect(client.getQueryData(['capabilities'])).toBeDefined()
46
+ })
47
+ return document.querySelector('[data-testid="gate"]')?.textContent
48
+ }
49
+
50
+ describe('Radar Cloud hint gate', () => {
51
+ it('is on for standalone Radar when the server offers Cloud', async () => {
52
+ capabilities = { cloudConnect: { lane: 'wizard', appUrl: 'https://cloud.example' } }
53
+ expect(await gate(false)).toBe('on')
54
+ })
55
+
56
+ it('stays off in an embedded host even when the capability is present', async () => {
57
+ capabilities = { cloudConnect: { lane: 'wizard', appUrl: 'https://cloud.example' } }
58
+ expect(await gate(true)).toBe('off')
59
+ })
60
+
61
+ it('stays off when the operator hid the hints but kept the button', async () => {
62
+ capabilities = { cloudConnect: { lane: 'wizard', appUrl: 'https://cloud.example', hintsOff: true } }
63
+ expect(await gate(false)).toBe('off')
64
+ })
65
+
66
+ it('stays off when the server offers nothing (RADAR_CLOUD_FUNNEL=off, cloud mode, tunneled)', async () => {
67
+ capabilities = {}
68
+ expect(await gate(false)).toBe('off')
69
+ })
70
+ })
@@ -0,0 +1,52 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import { cloudResourceUrl, clusterIdFromUrl } from './cloudLinks'
3
+
4
+ const subject = {
5
+ intent: 'share' as const,
6
+ kind: 'Deployment',
7
+ group: 'apps',
8
+ name: 'checkout-api',
9
+ namespace: 'shop',
10
+ context: 'prod-eu',
11
+ }
12
+
13
+ describe('clusterIdFromUrl', () => {
14
+ it('reads the cluster ID from a Radar Cloud cluster URL', () => {
15
+ expect(clusterIdFromUrl('https://app.radarhq.io/c/cl_123')).toBe('cl_123')
16
+ expect(clusterIdFromUrl('https://app.radarhq.io/c/cl_123/resources/pods')).toBe('cl_123')
17
+ })
18
+ it('returns nothing for anything else', () => {
19
+ expect(clusterIdFromUrl('https://app.radarhq.io/clusters/one')).toBeUndefined()
20
+ expect(clusterIdFromUrl('not a url')).toBeUndefined()
21
+ expect(clusterIdFromUrl(undefined)).toBeUndefined()
22
+ })
23
+ })
24
+
25
+ describe('cloudResourceUrl', () => {
26
+ it('opens the same resource inside the cluster page, starting nothing', () => {
27
+ const url = cloudResourceUrl('https://app.radarhq.io/c/cl_123/', subject)!
28
+ const u = new URL(url)
29
+ expect(u.pathname).toBe('/c/cl_123/resources/deployments')
30
+ expect(u.searchParams.get('resource')).toBe('shop/checkout-api')
31
+ expect(u.searchParams.get('apiGroup')).toBe('apps')
32
+ expect(url).not.toContain('investigate')
33
+ })
34
+
35
+ it('keeps a query the cluster URL already carries', () => {
36
+ const u = new URL(cloudResourceUrl('https://app.radarhq.io/c/cl_123?utm_source=radar-oss&utm_term=share', subject)!)
37
+ expect(u.pathname).toBe('/c/cl_123/resources/deployments')
38
+ expect(u.searchParams.get('utm_term')).toBe('share')
39
+ expect(u.searchParams.get('resource')).toBe('shop/checkout-api')
40
+ })
41
+
42
+ it('builds from the cluster, whatever page of it the link pointed at', () => {
43
+ const u = new URL(cloudResourceUrl('https://app.radarhq.io/c/cl_123/resources/pods?apiGroup=x', { ...subject, group: '' })!)
44
+ expect(u.pathname).toBe('/c/cl_123/resources/deployments')
45
+ expect(u.searchParams.has('apiGroup')).toBe(false)
46
+ })
47
+
48
+ it('gives no link for anything but a cluster page', () => {
49
+ expect(cloudResourceUrl('https://app.radarhq.io/clusters', subject)).toBeNull()
50
+ expect(cloudResourceUrl('not a url', subject)).toBeNull()
51
+ })
52
+ })
@@ -0,0 +1,31 @@
1
+ import { kindToPluralWithGroup } from '../../utils/navigation'
2
+ import type { CloudHintSubject } from './cloudHints'
3
+
4
+ // Deep links from a Radar that already knows its Radar Cloud cluster.
5
+
6
+ // Radar Cloud cluster URLs are <origin>/c/<clusterId>.
7
+ export function clusterIdFromUrl(url: string | undefined): string | undefined {
8
+ if (!url) return undefined
9
+ try {
10
+ const m = new URL(url).pathname.match(/^\/c\/([A-Za-z0-9_-]{1,64})(?:\/|$)/)
11
+ return m?.[1]
12
+ } catch {
13
+ return undefined
14
+ }
15
+ }
16
+
17
+ // The same resource inside the cluster's page in Radar Cloud, where the team
18
+ // can open it. The cluster URL may already carry a query (tracking tags),
19
+ // which is kept. Anything that isn't a Radar Cloud cluster page gets no deep
20
+ // link.
21
+ export function cloudResourceUrl(clusterUrl: string, subject: CloudHintSubject): string | null {
22
+ const clusterId = clusterIdFromUrl(clusterUrl)
23
+ if (!clusterId) return null
24
+ const url = new URL(clusterUrl)
25
+ const plural = kindToPluralWithGroup(subject.kind, subject.group ?? '')
26
+ url.pathname = `/c/${clusterId}/resources/${encodeURIComponent(plural)}`
27
+ url.searchParams.set('resource', subject.namespace ? `${subject.namespace}/${subject.name}` : subject.name)
28
+ if (subject.group) url.searchParams.set('apiGroup', subject.group)
29
+ else url.searchParams.delete('apiGroup')
30
+ return url.toString()
31
+ }
@@ -0,0 +1,28 @@
1
+ // Storage can throw (SecurityError) where it is denied: sandboxed embeds, some
2
+ // privacy modes. A hint must still render then, and a dismissal must still hold
3
+ // until the page reloads, so writes also land in memory.
4
+ const memory = new Map<string, string>()
5
+
6
+ export function safeGet(storage: () => Storage, key: string): string | null {
7
+ try {
8
+ return storage().getItem(key) ?? memory.get(key) ?? null
9
+ } catch {
10
+ return memory.get(key) ?? null
11
+ }
12
+ }
13
+
14
+ export function safeSet(storage: () => Storage, key: string, value: string) {
15
+ memory.set(key, value)
16
+ try {
17
+ storage().setItem(key, value)
18
+ } catch {
19
+ // Storage denied: the in-memory copy carries it until reload.
20
+ }
21
+ }
22
+
23
+ // Tests share one module instance across cases.
24
+ export function clearHintMemory() {
25
+ memory.clear()
26
+ }
27
+
28
+ export const local = () => window.localStorage
@@ -11,12 +11,11 @@ import { CNPGScreenGate } from './shared'
11
11
  import { CNPGCreateClusterDialog } from './CNPGCreateClusterDialog'
12
12
  import { CNPGDetailPage } from './CNPGDetailPage'
13
13
  import { parseCNPGRoute } from './routes'
14
- import { useCNPGFleet, useCNPGSidebarWorkspace } from './useCNPGSidebarWorkspace'
14
+ import { useIntegrationSidebars } from '../../integrations/sidebarWorkspaces'
15
+ import { useCNPGFleet } from './useCNPGSidebarWorkspace'
15
16
  import { useCNPGScreenParams } from './useCNPGScreenParams'
16
17
  import { useMediaQuery } from '../../hooks/useMediaQuery'
17
- import { useVeleroSidebarWorkspace } from '../velero/useVeleroSidebarWorkspace'
18
18
  import { WorkspaceFrame } from '../workspace/WorkspaceFrame'
19
- import { useMergedSidebarWorkspaces } from '../workspace/sidebar'
20
19
  import { useWorkspaceDrawer } from '../workspace/useWorkspaceDrawer'
21
20
 
22
21
  interface CNPGViewProps {
@@ -42,13 +41,11 @@ export function CNPGView({ namespaces, selectedResource, onOpenResource, onClose
42
41
  const narrow = useMediaQuery('(max-width: 1100px)')
43
42
  const compactNavigation = narrow || (laptop && !!route.detail)
44
43
  const { data: apiResources } = useAPIResources()
45
- const cnpgSidebar = useCNPGSidebarWorkspace({
44
+ const sidebarWorkspace = useIntegrationSidebars({
46
45
  apiResources,
47
46
  namespaces,
48
- active: { screen: route.screen, child: route.detail ? { label: route.detail.name, title: `${route.detail.plural} ${route.detail.namespace}/${route.detail.name}` } : undefined },
47
+ cnpg: { active: { screen: route.screen, child: route.detail ? { label: route.detail.name, title: `${route.detail.plural} ${route.detail.namespace}/${route.detail.name}` } : undefined } },
49
48
  })
50
- const veleroSidebar = useVeleroSidebarWorkspace({ apiResources })
51
- const sidebarWorkspace = useMergedSidebarWorkspaces(cnpgSidebar, veleroSidebar)
52
49
  const { query, fleet } = useCNPGFleet(namespaces)
53
50
  const { drawerTarget, inspect, searchParams } = useWorkspaceDrawer({ selectedResource, onOpenResource, onCloseResource })
54
51
 
@@ -98,6 +98,7 @@ function CheckAgainButton({
98
98
  // say only that and offer a re-check.
99
99
  export function AgentSetupNotice({
100
100
  setupState,
101
+ cloudOption,
101
102
  cliOverride,
102
103
  checkingAgents,
103
104
  agentsCheckFailed,
@@ -105,6 +106,9 @@ export function AgentSetupNotice({
105
106
  onOpenExample,
106
107
  }: {
107
108
  setupState: DiagnoseSetup;
109
+ // A secondary option shown after the local agents (the host's Radar Cloud
110
+ // row); omitted where there is nothing to offer.
111
+ cloudOption?: ReactNode;
108
112
  cliOverride: boolean;
109
113
  checkingAgents: boolean;
110
114
  agentsCheckFailed: boolean;
@@ -174,6 +178,7 @@ export function AgentSetupNotice({
174
178
  <AgentRow key={a.name} agent={a} />
175
179
  ))}
176
180
  </div>
181
+ {cloudOption}
177
182
  <CheckAgainButton checking={checkingAgents} onCheck={check} />
178
183
  {unreachable ||
179
184
  (showResult && (
@@ -119,6 +119,9 @@ export type DiagnoseSetup =
119
119
  interface DiagnoseCtx {
120
120
  available: boolean; // an agent CLI is present (button/entry gate)
121
121
  setupState: DiagnoseSetup; // readiness for the setup nudge (see DiagnoseSetup)
122
+ // Why setupState is "off", when the server says: a team installation
123
+ // ("shared") versus the MCP mount being off ("no-mcp").
124
+ unavailableReason: "" | "shared" | "no-mcp";
122
125
  // Re-reads the agent list; the server turns investigations on if a CLI was
123
126
  // installed since the last check. Resolves once the new state is applied.
124
127
  recheckAgents: () => Promise<void>;
@@ -471,6 +474,8 @@ function RoutedDiagnoseProvider({
471
474
  }, [location]);
472
475
  const [available, setAvailable] = useState(false);
473
476
  const [eligible, setEligible] = useState(false);
477
+ const [unavailableReason, setUnavailableReason] =
478
+ useState<DiagnoseCtx["unavailableReason"]>("");
474
479
  const [agentEligibilityResolved, setAgentEligibilityResolved] =
475
480
  useState(false);
476
481
  const [agents, setAgents] = useState<AgentInfo[]>([]);
@@ -641,6 +646,7 @@ function RoutedDiagnoseProvider({
641
646
  setCliOverride(!!r.cliOverride);
642
647
  setConsented(r.consented ?? {});
643
648
  setEligible(!!r.eligible);
649
+ setUnavailableReason(r.unavailableReason ?? "");
644
650
  const supported = r.agents.filter(
645
651
  (a) =>
646
652
  a.supported &&
@@ -1375,6 +1381,7 @@ function RoutedDiagnoseProvider({
1375
1381
  const value: DiagnoseCtx = {
1376
1382
  available,
1377
1383
  setupState,
1384
+ unavailableReason,
1378
1385
  recheckAgents,
1379
1386
  checkingAgents,
1380
1387
  agentsCheckFailed,