@skyhook-io/radar-app 1.22.2 → 1.23.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 (196) hide show
  1. package/package.json +8 -8
  2. package/src/App.tsx +35 -10
  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 +122 -24
  9. package/src/api/cloudInstallDiscover.test.tsx +76 -0
  10. package/src/api/diagnose.ts +4 -0
  11. package/src/api/kagent.test.ts +82 -0
  12. package/src/api/kagent.ts +230 -0
  13. package/src/api/prometheusCharts.ts +5 -0
  14. package/src/api/radarFeatures.test.ts +9 -0
  15. package/src/api/radarFeatures.ts +13 -0
  16. package/src/api/substrateWorkspace.test.ts +72 -0
  17. package/src/api/substrateWorkspace.ts +1394 -0
  18. package/src/api/vulnerabilities.ts +207 -9
  19. package/src/api/workloadSource.test.tsx +315 -0
  20. package/src/api/workloadSource.ts +128 -12
  21. package/src/components/CloudConnectFlow.tsx +46 -7
  22. package/src/components/CloudFunnelButton.test.tsx +193 -7
  23. package/src/components/CloudFunnelButton.tsx +127 -32
  24. package/src/components/SelfManagedStart.tsx +12 -2
  25. package/src/components/agentsandbox/AgentSandboxKindLists.tsx +41 -0
  26. package/src/components/agentsandbox/AgentSandboxLists.test.tsx +410 -0
  27. package/src/components/agentsandbox/AgentSandboxOverview.test.tsx +333 -0
  28. package/src/components/agentsandbox/AgentSandboxOverview.tsx +555 -0
  29. package/src/components/agentsandbox/AgentSandboxSidebar.test.tsx +97 -0
  30. package/src/components/agentsandbox/AgentSandboxSummary.test.tsx +439 -0
  31. package/src/components/agentsandbox/AgentSandboxSummary.tsx +956 -0
  32. package/src/components/agentsandbox/AgentSandboxTables.tsx +966 -0
  33. package/src/components/agentsandbox/AgentSandboxView.tsx +34 -0
  34. package/src/components/agentsandbox/agentsandbox.fixtures.ts +135 -0
  35. package/src/components/agentsandbox/data.ts +135 -0
  36. package/src/components/agentsandbox/host.test.ts +27 -0
  37. package/src/components/agentsandbox/host.tsx +85 -0
  38. package/src/components/agentsandbox/labels.test.ts +42 -0
  39. package/src/components/agentsandbox/labels.ts +146 -0
  40. package/src/components/agentsandbox/listFilters.ts +85 -0
  41. package/src/components/agentsandbox/lists.ts +52 -0
  42. package/src/components/agentsandbox/routes.ts +23 -0
  43. package/src/components/agentsandbox/shared.tsx +321 -0
  44. package/src/components/agentsandbox/useAgentSandboxSidebarWorkspace.ts +69 -0
  45. package/src/components/agentsandbox/workspace.fixtures.ts +125 -0
  46. package/src/components/agentsandbox/workspace.tsx +258 -0
  47. package/src/components/agentsandbox/workspaceRoute.ts +18 -0
  48. package/src/components/applications/ApplicationsView.openResource.test.tsx +248 -3
  49. package/src/components/applications/ApplicationsView.tsx +156 -3
  50. package/src/components/audit/VulnerabilitiesColumns.test.tsx +487 -0
  51. package/src/components/audit/VulnerabilitiesRisk.test.tsx +318 -0
  52. package/src/components/audit/VulnerabilitiesView.test.tsx +458 -13
  53. package/src/components/audit/VulnerabilitiesView.tsx +639 -199
  54. package/src/components/cloudHints/AgentSetupCloudRow.tsx +28 -0
  55. package/src/components/cloudHints/CloudHintLink.tsx +29 -0
  56. package/src/components/cloudHints/SharedInstallAiLine.tsx +36 -0
  57. package/src/components/cloudHints/cloudHints.test.ts +126 -0
  58. package/src/components/cloudHints/cloudHints.ts +131 -0
  59. package/src/components/cloudHints/cloudHintsGate.test.tsx +70 -0
  60. package/src/components/cloudHints/cloudLinks.test.ts +52 -0
  61. package/src/components/cloudHints/cloudLinks.ts +31 -0
  62. package/src/components/cloudHints/hintStorage.ts +28 -0
  63. package/src/components/cnpg/CNPGView.tsx +4 -7
  64. package/src/components/diagnose/AgentSetupNotice.tsx +5 -0
  65. package/src/components/diagnose/DiagnoseContext.tsx +7 -0
  66. package/src/components/diagnose/DiagnoseSurface.escape.test.tsx +215 -0
  67. package/src/components/diagnose/DiagnoseSurface.tsx +57 -1
  68. package/src/components/gitops/RemoteDestinationCloudHint.tsx +6 -14
  69. package/src/components/home/HomeAgentBlock.tsx +2 -0
  70. package/src/components/home/HomeView.tsx +3 -3
  71. package/src/components/home/MCPSetupDialog.test.tsx +9 -0
  72. package/src/components/home/MCPSetupDialog.tsx +6 -2
  73. package/src/components/home/McpCloudLine.test.tsx +162 -0
  74. package/src/components/home/McpCloudLine.tsx +95 -0
  75. package/src/components/home/ProblemsPanel.investigate.test.tsx +2 -2
  76. package/src/components/home/mcpToolCatalog.test.ts +10 -0
  77. package/src/components/home/mcpToolCatalog.ts +4 -4
  78. package/src/components/issues/ClusterSchedulingBlockerRow.tsx +35 -0
  79. package/src/components/issues/IssuesPane.render.test.tsx +36 -1
  80. package/src/components/issues/IssuesPane.tsx +181 -23
  81. package/src/components/issues/SinceLastVisitRow.render.test.tsx +302 -0
  82. package/src/components/issues/SinceLastVisitRow.tsx +71 -0
  83. package/src/components/issues/sinceLastVisit.test.ts +266 -0
  84. package/src/components/issues/sinceLastVisit.ts +439 -0
  85. package/src/components/kagent/KagentAgentRenderer.test.ts +32 -0
  86. package/src/components/kagent/KagentAgentRenderer.tsx +87 -0
  87. package/src/components/kagent/KagentAgentSessions.test.tsx +166 -0
  88. package/src/components/kagent/KagentAgentSessions.tsx +124 -0
  89. package/src/components/kagent/KagentDetailPage.tsx +106 -0
  90. package/src/components/kagent/KagentLists.tsx +412 -0
  91. package/src/components/kagent/KagentOverview.tsx +234 -0
  92. package/src/components/kagent/KagentPages.tsx +690 -0
  93. package/src/components/kagent/KagentRuntimeTabs.test.tsx +219 -0
  94. package/src/components/kagent/KagentRuntimeTabs.tsx +283 -0
  95. package/src/components/kagent/KagentSidebar.test.tsx +112 -0
  96. package/src/components/kagent/KagentView.tsx +109 -0
  97. package/src/components/kagent/KagentWorkspace.test.tsx +876 -0
  98. package/src/components/kagent/host.tsx +144 -0
  99. package/src/components/kagent/routes.ts +31 -0
  100. package/src/components/kagent/shared.tsx +336 -0
  101. package/src/components/kagent/useKagentRuntime.test.tsx +77 -0
  102. package/src/components/kagent/useKagentSidebarWorkspace.ts +67 -0
  103. package/src/components/kagent/workspace.fixtures.ts +108 -0
  104. package/src/components/kagent/workspaceRoute.ts +18 -0
  105. package/src/components/resource/MetricsNotConnected.test.tsx +28 -0
  106. package/src/components/resource/MetricsNotConnected.tsx +10 -7
  107. package/src/components/resource/PrometheusCharts.tsx +10 -1
  108. package/src/components/resource/PrometheusChartsGrid.render.test.tsx +9 -0
  109. package/src/components/resource/PrometheusChartsGrid.tsx +3 -3
  110. package/src/components/resource/SubstrateHealthCharts.test.tsx +13 -1
  111. package/src/components/resource/SubstrateHealthCharts.tsx +9 -15
  112. package/src/components/resources/ResourceDetailDrawer.tsx +1 -0
  113. package/src/components/resources/ResourcesView.tsx +2 -6
  114. package/src/components/resources/renderers/PodRenderer.tsx +8 -2
  115. package/src/components/settings/LocalIntegrationStatus.test.tsx +1 -0
  116. package/src/components/settings/LocalIntegrationStatus.tsx +3 -2
  117. package/src/components/settings/SettingsDialog.tsx +84 -16
  118. package/src/components/settings/SubstrateSettings.lifecycle.test.tsx +210 -0
  119. package/src/components/settings/SubstrateSettings.test.tsx +131 -0
  120. package/src/components/settings/SubstrateSettings.tsx +544 -0
  121. package/src/components/settings/settings-state.test.ts +21 -3
  122. package/src/components/settings/settings-state.ts +13 -3
  123. package/src/components/share/ShareLinkButton.test.tsx +360 -0
  124. package/src/components/share/ShareLinkButton.tsx +391 -0
  125. package/src/components/share/openShareInCloud.test.ts +29 -0
  126. package/src/components/share/openShareInCloud.ts +10 -0
  127. package/src/components/share/shareLink.test.ts +129 -0
  128. package/src/components/share/shareLink.ts +175 -0
  129. package/src/components/substrate/SubstrateActorDrawer.tsx +87 -0
  130. package/src/components/substrate/SubstrateActorOverview.tsx +489 -0
  131. package/src/components/substrate/SubstrateActorPage.tsx +384 -0
  132. package/src/components/substrate/SubstrateActors.test.tsx +1094 -0
  133. package/src/components/substrate/SubstrateActors.tsx +612 -0
  134. package/src/components/substrate/SubstrateAttentionList.tsx +441 -0
  135. package/src/components/substrate/SubstrateConnect.tsx +88 -0
  136. package/src/components/substrate/SubstrateOverview.test.tsx +396 -0
  137. package/src/components/substrate/SubstrateOverview.tsx +575 -0
  138. package/src/components/substrate/SubstratePages.test.tsx +478 -0
  139. package/src/components/substrate/SubstratePool.test.tsx +462 -0
  140. package/src/components/substrate/SubstratePoolPage.tsx +95 -0
  141. package/src/components/substrate/SubstratePoolSummary.tsx +485 -0
  142. package/src/components/substrate/SubstrateSidebar.test.tsx +101 -0
  143. package/src/components/substrate/SubstrateStateBar.tsx +63 -0
  144. package/src/components/substrate/SubstrateTemplates.tsx +376 -0
  145. package/src/components/substrate/SubstrateView.tsx +173 -0
  146. package/src/components/substrate/SubstrateWorkerPodContext.tsx +73 -0
  147. package/src/components/substrate/SubstrateWorkers.tsx +389 -0
  148. package/src/components/substrate/attention.ts +81 -0
  149. package/src/components/substrate/contextPin.tsx +69 -0
  150. package/src/components/substrate/host.tsx +83 -0
  151. package/src/components/substrate/kubectlTarget.test.tsx +77 -0
  152. package/src/components/substrate/readings.test.ts +484 -0
  153. package/src/components/substrate/readings.ts +997 -0
  154. package/src/components/substrate/routes.ts +103 -0
  155. package/src/components/substrate/shared.tsx +426 -0
  156. package/src/components/substrate/substrate.fixtures.ts +325 -0
  157. package/src/components/substrate/useSubstrateSidebarWorkspace.ts +87 -0
  158. package/src/components/substrate/workspaceRoute.ts +23 -0
  159. package/src/components/traffic/TrafficConnectionsTable.test.tsx +9 -0
  160. package/src/components/traffic/TrafficConnectionsTable.tsx +4 -2
  161. package/src/components/traffic/TrafficFilterSidebar.tsx +19 -14
  162. package/src/components/traffic/TrafficFlowList.test.tsx +63 -0
  163. package/src/components/traffic/TrafficFlowList.tsx +9 -5
  164. package/src/components/traffic/TrafficGraph.test.tsx +26 -0
  165. package/src/components/traffic/TrafficGraph.tsx +17 -14
  166. package/src/components/traffic/TrafficGraphTooLarge.tsx +2 -0
  167. package/src/components/traffic/TrafficGraphUnavailable.tsx +3 -1
  168. package/src/components/traffic/TrafficView.tsx +26 -56
  169. package/src/components/traffic/trafficFilters.test.ts +61 -1
  170. package/src/components/traffic/trafficFilters.ts +68 -8
  171. package/src/components/velero/VeleroOverview.tsx +2 -2
  172. package/src/components/velero/VeleroView.tsx +3 -6
  173. package/src/components/vulnerabilities/columns.tsx +132 -0
  174. package/src/components/vulnerabilities/filters.tsx +317 -0
  175. package/src/components/vulnerabilities/owner.test.ts +54 -0
  176. package/src/components/vulnerabilities/owner.tsx +163 -0
  177. package/src/components/vulnerabilities/parts.test.ts +126 -12
  178. package/src/components/vulnerabilities/parts.tsx +612 -52
  179. package/src/components/vulnerabilities/traffic.test.tsx +65 -0
  180. package/src/components/vulnerabilities/traffic.tsx +40 -0
  181. package/src/components/workload/WorkloadView.substrateVersion.test.tsx +88 -0
  182. package/src/components/workload/WorkloadView.tsx +52 -13
  183. package/src/components/workspace/layout.tsx +13 -7
  184. package/src/components/workspace/sidebar.test.ts +48 -0
  185. package/src/components/workspace/sidebar.ts +73 -3
  186. package/src/components/workspace/table.ts +2 -1
  187. package/src/contexts/RegistryAccessMode.test.tsx +51 -0
  188. package/src/contexts/RegistryAccessMode.tsx +25 -0
  189. package/src/integrations/resourceHost.ts +12 -6
  190. package/src/integrations/resourceHosts.test.tsx +27 -1
  191. package/src/integrations/resourceHosts.tsx +15 -7
  192. package/src/integrations/sidebarWorkspaces.test.tsx +63 -0
  193. package/src/integrations/sidebarWorkspaces.ts +41 -0
  194. package/src/integrations/workspaceRoute.ts +1 -1
  195. package/src/integrations/workspaceRoutes.ts +7 -1
  196. package/src/integrations/workspaceScreens.tsx +6 -0
@@ -0,0 +1,215 @@
1
+ // @vitest-environment jsdom
2
+ import { act, useEffect } 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
+
7
+ import type { RunSummary } from "../../api/diagnose";
8
+ import {
9
+ DiagnoseProvider,
10
+ useDiagnose,
11
+ useDiagnoseLayout,
12
+ } from "./DiagnoseContext";
13
+ import { DiagnoseSurface } from "./DiagnoseSurface";
14
+
15
+ const api = vi.hoisted(() => ({ runs: [] as RunSummary[] }));
16
+
17
+ vi.mock("../../api/usage-data", async (importOriginal) => ({
18
+ ...(await importOriginal<object>()),
19
+ recordUsageEvent: vi.fn(),
20
+ }));
21
+
22
+ vi.mock("../../api/diagnose", async (importOriginal) => ({
23
+ ...(await importOriginal<object>()),
24
+ fetchAgents: async () => ({
25
+ enabled: true,
26
+ eligible: true,
27
+ consented: { "claude:safeguarded": true },
28
+ agents: [
29
+ {
30
+ name: "claude",
31
+ label: "Claude Code",
32
+ path: "/bin/claude",
33
+ version: "",
34
+ present: true,
35
+ supported: true,
36
+ hosted: false,
37
+ targetQuestions: true,
38
+ profiles: ["safeguarded"],
39
+ consentSurfaces: { safeguarded: "claude:safeguarded" },
40
+ },
41
+ ],
42
+ }),
43
+ listRuns: async () => ({ runs: api.runs }),
44
+ getRun: vi.fn(() => new Promise(() => {})),
45
+ subscribeRun: () => () => {},
46
+ }));
47
+
48
+ vi.mock("../../api/client", async (importOriginal) => ({
49
+ ...(await importOriginal<object>()),
50
+ useContexts: () => ({ data: [{ name: "cluster-a", isCurrent: true }] }),
51
+ }));
52
+
53
+ Object.assign(globalThis, {
54
+ IS_REACT_ACT_ENVIRONMENT: true,
55
+ ResizeObserver: class {
56
+ observe() {}
57
+ unobserve() {}
58
+ disconnect() {}
59
+ },
60
+ });
61
+ let root: Root;
62
+ const probe = {} as {
63
+ d: ReturnType<typeof useDiagnose>;
64
+ layout: ReturnType<typeof useDiagnoseLayout>;
65
+ };
66
+
67
+ function Probe() {
68
+ const d = useDiagnose();
69
+ const layout = useDiagnoseLayout();
70
+ useEffect(() => {
71
+ probe.d = d;
72
+ probe.layout = layout;
73
+ });
74
+ return layout.open ? <DiagnoseSurface /> : null;
75
+ }
76
+
77
+ const flush = () =>
78
+ act(async () => {
79
+ await new Promise((resolve) => setTimeout(resolve, 0));
80
+ });
81
+
82
+ const surface = () =>
83
+ document.querySelector<HTMLElement>('[aria-label="AI investigations"]');
84
+ const button = (label: string) =>
85
+ surface()!.querySelector<HTMLButtonElement>(`button[aria-label="${label}"]`)!;
86
+
87
+ function pressEscape(target: Element) {
88
+ const event = new KeyboardEvent("keydown", {
89
+ key: "Escape",
90
+ bubbles: true,
91
+ cancelable: true,
92
+ });
93
+ act(() => {
94
+ target.dispatchEvent(event);
95
+ });
96
+ return event;
97
+ }
98
+
99
+ async function openPanel(open: () => void) {
100
+ await act(async () =>
101
+ root.render(
102
+ <QueryClientProvider
103
+ client={
104
+ new QueryClient({ defaultOptions: { queries: { enabled: false } } })
105
+ }
106
+ >
107
+ <DiagnoseProvider browserURLState={false}>
108
+ <Probe />
109
+ </DiagnoseProvider>
110
+ </QueryClientProvider>,
111
+ ),
112
+ );
113
+ await flush();
114
+ await act(async () => open());
115
+ await flush();
116
+ expect(surface()).not.toBeNull();
117
+ }
118
+
119
+ beforeEach(() => {
120
+ api.runs = [];
121
+ localStorage.clear();
122
+ const element = document.createElement("div");
123
+ document.body.appendChild(element);
124
+ root = createRoot(element);
125
+ });
126
+
127
+ afterEach(async () => {
128
+ await act(async () => root.unmount());
129
+ document.body.replaceChildren();
130
+ });
131
+
132
+ describe("Escape in the docked investigation panel", () => {
133
+ it("moves focus into the docked panel on launch, closes on immediate Escape, and restores opener focus", async () => {
134
+ api.runs = [
135
+ {
136
+ id: "run-cart",
137
+ kind: "Deployment",
138
+ group: "apps",
139
+ namespace: "shop",
140
+ name: "cart",
141
+ context: "cluster-a",
142
+ status: "running",
143
+ createdAt: "2026-01-01T00:00:00Z",
144
+ updatedAt: "2026-01-01T00:00:00Z",
145
+ },
146
+ ];
147
+ const launcher = document.createElement("button");
148
+ launcher.textContent = "Investigate";
149
+ document.body.appendChild(launcher);
150
+ launcher.focus();
151
+ expect(document.activeElement).toBe(launcher);
152
+
153
+ await openPanel(() => probe.d.openRun("run-cart"));
154
+ expect(surface()!.contains(document.activeElement)).toBe(true);
155
+
156
+ const event = pressEscape(document.activeElement!);
157
+ expect(event.defaultPrevented).toBe(true);
158
+ expect(probe.layout.open).toBe(false);
159
+ expect(surface()).toBeNull();
160
+ expect(document.activeElement).toBe(launcher);
161
+ });
162
+
163
+ it("closes the panel when focus is inside it", async () => {
164
+ await openPanel(() => probe.d.openHome());
165
+ const close = button("Close");
166
+ close.focus();
167
+ const event = pressEscape(close);
168
+ expect(event.defaultPrevented).toBe(true);
169
+ expect(probe.layout.open).toBe(false);
170
+ expect(surface()).toBeNull();
171
+ });
172
+
173
+ it("closes the history overlay first, then the panel", async () => {
174
+ api.runs = [
175
+ {
176
+ id: "run-cart",
177
+ kind: "Deployment",
178
+ group: "apps",
179
+ namespace: "shop",
180
+ name: "cart",
181
+ context: "cluster-a",
182
+ status: "running",
183
+ createdAt: "2026-01-01T00:00:00Z",
184
+ updatedAt: "2026-01-01T00:00:00Z",
185
+ },
186
+ ];
187
+ await openPanel(() => probe.d.openRun("run-cart"));
188
+ const history = button("Investigations");
189
+ expect(history.getAttribute("aria-expanded")).toBe("false");
190
+ await act(async () => history.click());
191
+ expect(history.getAttribute("aria-expanded")).toBe("true");
192
+
193
+ pressEscape(history);
194
+ expect(history.getAttribute("aria-expanded")).toBe("false");
195
+ expect(probe.layout.open).toBe(true);
196
+
197
+ pressEscape(history);
198
+ expect(probe.layout.open).toBe(false);
199
+ });
200
+
201
+ it("leaves the panel open when something inside it consumed the Escape", async () => {
202
+ await openPanel(() => probe.d.openHome());
203
+ const close = button("Close");
204
+ close.addEventListener("keydown", (event) => event.preventDefault());
205
+ pressEscape(close);
206
+ expect(probe.layout.open).toBe(true);
207
+ });
208
+
209
+ it("does not close the maximized workspace surface", async () => {
210
+ await openPanel(() => probe.d.openHome());
211
+ await act(async () => probe.layout.setMaximized(true));
212
+ pressEscape(button("Close"));
213
+ expect(probe.layout.open).toBe(true);
214
+ });
215
+ });
@@ -51,6 +51,8 @@ import {
51
51
  statusWord,
52
52
  } from "./Home";
53
53
  import { AgentSetupNotice } from "./AgentSetupNotice";
54
+ import { AgentSetupCloudRow } from "../cloudHints/AgentSetupCloudRow";
55
+ import { useCloudHintsEnabled } from "../cloudHints/cloudHints";
54
56
  import {
55
57
  EXAMPLE_INVESTIGATION_ID,
56
58
  EXAMPLE_INVESTIGATION_RUN,
@@ -464,6 +466,7 @@ export function DiagnoseSurface({
464
466
  // Feature is eligible here but not runnable yet (no agent installed, or one
465
467
  // found that investigations couldn't start with): Home leads with the setup
466
468
  // notice instead of an empty list.
469
+ const cloudHints = useCloudHintsEnabled();
467
470
  const setupPending =
468
471
  d.setupState === "needs-install" || d.setupState === "needs-restart";
469
472
 
@@ -620,6 +623,7 @@ export function DiagnoseSurface({
620
623
  <div className="flex-1 overflow-y-auto">
621
624
  <AgentSetupNotice
622
625
  setupState={d.setupState}
626
+ cloudOption={cloudHints ? <AgentSetupCloudRow /> : undefined}
623
627
  cliOverride={d.cliOverride}
624
628
  checkingAgents={d.checkingAgents}
625
629
  agentsCheckFailed={d.agentsCheckFailed}
@@ -652,6 +656,7 @@ export function DiagnoseSurface({
652
656
  <div className="mx-auto w-full max-w-3xl px-4 py-8 sm:px-6">
653
657
  <AgentSetupNotice
654
658
  setupState={d.setupState}
659
+ cloudOption={cloudHints ? <AgentSetupCloudRow /> : undefined}
655
660
  cliOverride={d.cliOverride}
656
661
  checkingAgents={d.checkingAgents}
657
662
  agentsCheckFailed={d.agentsCheckFailed}
@@ -680,6 +685,39 @@ export function DiagnoseSurface({
680
685
  ? d.view === "home" || !historyCollapsed
681
686
  : historyOverlay);
682
687
 
688
+ // Capture the opener before child layout effects can move focus, so closing
689
+ // the docked panel restores focus cleanly instead of dropping it to body.
690
+ const openerRef = useRef<HTMLElement | null>(
691
+ typeof document !== "undefined" &&
692
+ document.activeElement instanceof HTMLElement
693
+ ? document.activeElement
694
+ : null,
695
+ );
696
+ const maximizedRef = useRef(maximized);
697
+
698
+ useLayoutEffect(() => {
699
+ maximizedRef.current = maximized;
700
+ if (maximized) return;
701
+ const surface = surfaceRef.current;
702
+ if (surface && !surface.contains(document.activeElement)) {
703
+ surface.focus({ preventScroll: true });
704
+ }
705
+ }, [maximized]);
706
+
707
+ useLayoutEffect(() => {
708
+ const surface = surfaceRef.current;
709
+ const opener = openerRef.current;
710
+ return () => {
711
+ if (maximizedRef.current) return;
712
+ if (
713
+ opener?.isConnected &&
714
+ surface?.contains(document.activeElement)
715
+ ) {
716
+ opener.focus({ preventScroll: true });
717
+ }
718
+ };
719
+ }, []);
720
+
683
721
  useLayoutEffect(() => {
684
722
  if (
685
723
  !historyVisible &&
@@ -692,6 +730,7 @@ export function DiagnoseSurface({
692
730
  return (
693
731
  <div
694
732
  ref={surfaceRef}
733
+ tabIndex={-1}
695
734
  role="dialog"
696
735
  aria-label="AI investigations"
697
736
  onKeyDownCapture={(event) => {
@@ -701,7 +740,24 @@ export function DiagnoseSurface({
701
740
  dismissHistory();
702
741
  }
703
742
  }}
704
- className={DIAGNOSE_SURFACE_FRAME_CLASS}
743
+ // Bubble phase, so a menu or picker inside the panel that consumes its
744
+ // own Escape keeps the panel open. React also bubbles events from
745
+ // portaled children (dialogs), which the DOM check leaves to them. The
746
+ // maximized surface is the workspace page, where close() navigates away.
747
+ onKeyDown={(event) => {
748
+ if (
749
+ event.key !== "Escape" ||
750
+ event.defaultPrevented ||
751
+ event.nativeEvent.isComposing ||
752
+ maximized ||
753
+ !surfaceRef.current?.contains(event.target as Node)
754
+ )
755
+ return;
756
+ event.preventDefault();
757
+ event.stopPropagation();
758
+ d.close();
759
+ }}
760
+ className={`${DIAGNOSE_SURFACE_FRAME_CLASS} focus:outline-none`}
705
761
  style={{
706
762
  ...positionStyle,
707
763
  animation: "slide-in-from-right 0.22s cubic-bezier(0.32,0.72,0,1)",
@@ -1,25 +1,17 @@
1
- import { useNavCustomization } from '../../context/NavCustomization'
2
- import { useCapabilities } from '../../api/client'
3
- import { openCloudFunnel } from '../CloudFunnelButton'
1
+ import { CloudHintLink } from '../cloudHints/CloudHintLink'
2
+ import { useCloudHintsEnabled } from '../cloudHints/cloudHints'
4
3
 
5
4
  // The one sentence a standalone Radar adds for a remote destination: what Radar Cloud
6
5
  // does. "Radar Cloud" opens the same dialog as the top-right button, so
7
6
  // there is one pitch and one connect flow. That dialog connects THIS
8
7
  // cluster; the destination is a second connect from Cloud, which is why the
9
- // copy says "both clusters" and promises the view in Cloud, not here. Rendered only when that button
10
- // is: the server decides whether there is anything to pitch (cloudConnect
11
- // capability), and embedded hosts (Radar Cloud itself) mount neither.
8
+ // copy says "both clusters" and promises the view in Cloud, not here.
12
9
  export function RemoteDestinationCloudHint() {
13
- const { embedded } = useNavCustomization()
14
- const capabilities = useCapabilities()
15
- if (embedded || !capabilities.data?.cloudConnect) return null
10
+ const enabled = useCloudHintsEnabled()
11
+ if (!enabled) return null
16
12
  return (
17
13
  <>
18
- For resources on another cluster, connect both clusters to{' '}
19
- <button type="button" onClick={openCloudFunnel} className="underline decoration-theme-border underline-offset-2 hover:text-theme-text-primary">
20
- Radar Cloud
21
- </button>{' '}
22
- to see this app's resources together.
14
+ For resources on another cluster, connect both clusters to <CloudHintLink entry="gitops-remote" /> to see this app's resources together.
23
15
  </>
24
16
  )
25
17
  }
@@ -5,6 +5,7 @@ import { notReadyTooltip } from '../diagnose/LocalDiagnoseAction'
5
5
  import { useNavCustomization } from '../../context/NavCustomization'
6
6
  import { Tooltip } from '../ui/Tooltip'
7
7
  import { MCPSetupDialog } from './MCPSetupDialog'
8
+ import { McpCloudLine } from './McpCloudLine'
8
9
 
9
10
  // The Home card's AI entry: start an investigation with the user's own agent,
10
11
  // and connect an agent to this Radar's MCP server. The investigation line
@@ -66,6 +67,7 @@ export function HomeAgentBlock({
66
67
  vulnerabilityTools={vulnerabilityTools}
67
68
  onInvestigate={showInvestigate && d.available ? () => openComposer(d) : undefined}
68
69
  applicationEvidenceAvailable={applicationEvidenceAvailable}
70
+ cloudLine={<McpCloudLine onBeforeOpen={() => setMcpDialogOpen(false)} />}
69
71
  />
70
72
  </div>
71
73
  )
@@ -45,7 +45,7 @@ import { HOVER_REVEAL_ACTION, HOVER_REVEAL_HIT, HOVER_REVEAL_REST } from '../../
45
45
  interface HomeViewProps {
46
46
  namespaces: string[]
47
47
  onNavigateToView: (view: ExtendedMainView, params?: Record<string, string>) => void
48
- onNavigateToIssue?: (id: string) => void
48
+ onNavigateToIssue?: (issue: Issue) => void
49
49
  onNavigateToResourceKind: (kind: string, group?: string, filters?: Record<string, string[]>) => void
50
50
  onNavigateToResource: (resource: SelectedResource) => void
51
51
  fallbackClusterLoadState?: ClusterLoadState
@@ -325,7 +325,7 @@ interface ProblemsPanelProps {
325
325
  error: unknown
326
326
  totalReturned: number
327
327
  onNavigateToIssues: () => void
328
- onNavigateToIssue?: (id: string) => void
328
+ onNavigateToIssue?: (issue: Issue) => void
329
329
  onResourceClick: (resource: SelectedResource) => void
330
330
  }
331
331
 
@@ -460,7 +460,7 @@ export function ProblemsPanel({
460
460
  onClick={() => {
461
461
  recordUsageEvent({ type: 'ui', name: 'issue_action:open' })
462
462
  if (onNavigateToIssue) {
463
- onNavigateToIssue(issue.id)
463
+ onNavigateToIssue(issue)
464
464
  return
465
465
  }
466
466
  onResourceClick({
@@ -176,3 +176,12 @@ it('shows registered Helm tools independently of target namespace permissions',
176
176
  const html = renderToStaticMarkup(<MCPSetupDialog open helmTools vulnerabilityTools mcpUrl={mcpEndpointUrl()} onClose={() => {}} />)
177
177
  expect(html).toContain('manage_helm')
178
178
  })
179
+
180
+ describe('MCP setup dialog Cloud line slot', () => {
181
+ it('renders the host-supplied line inside the endpoint section, before the client setup', () => {
182
+ const html = renderToStaticMarkup(<MCPSetupDialog open mcpUrl={mcpEndpointUrl()} onClose={() => {}} cloudLine={<p data-testid="cloud-line">cloud line</p>} />)
183
+ const line = html.indexOf('data-testid="cloud-line"')
184
+ expect(line).toBeGreaterThan(html.indexOf('>Endpoint<'))
185
+ expect(line).toBeLessThan(html.indexOf('Connect your AI tool'))
186
+ })
187
+ })
@@ -1,4 +1,4 @@
1
- import { useRef, useEffect, useState, useCallback } from 'react'
1
+ import { useRef, useEffect, useState, useCallback, type ReactNode } from 'react'
2
2
  import { X, Copy, Check, Radio, Terminal, MessageSquare, Code2, Pin } from 'lucide-react'
3
3
  import { apiUrl, getAuthHeaders, getCredentialsMode } from '../../api/config'
4
4
  import { MCP_TOOL_CATALOG } from './mcpToolCatalog'
@@ -22,6 +22,8 @@ interface MCPSetupDialogProps {
22
22
  mcpUrl: string
23
23
  /** Opens Radar's own investigation composer. Omit where investigations can't run. */
24
24
  onInvestigate?: () => void
25
+ /** A line under the endpoint about Radar Cloud's endpoint; it gates itself. */
26
+ cloudLine?: ReactNode
25
27
  }
26
28
 
27
29
  function CopyButton({ text }: { text: string }) {
@@ -61,7 +63,7 @@ function CodeBlock({ children }: { children: string }) {
61
63
  )
62
64
  }
63
65
 
64
- export function MCPSetupDialog({ open, onClose, mcpUrl, readOnly = false, execTools, httpTools, helmTools, vulnerabilityTools = false, onInvestigate, applicationEvidenceAvailable = false }: MCPSetupDialogProps) {
66
+ export function MCPSetupDialog({ open, onClose, mcpUrl, readOnly = false, execTools, httpTools, helmTools, vulnerabilityTools = false, onInvestigate, applicationEvidenceAvailable = false, cloudLine }: MCPSetupDialogProps) {
65
67
  const dialogRef = useRef<HTMLDivElement>(null)
66
68
  const [isDesktop, setIsDesktop] = useState(false)
67
69
  const [portPinned, setPortPinned] = useState(false)
@@ -298,6 +300,8 @@ export function MCPSetupDialog({ open, onClose, mcpUrl, readOnly = false, execTo
298
300
  </button>.
299
301
  </p>
300
302
  )}
303
+
304
+ {cloudLine}
301
305
  </div>
302
306
 
303
307
  {/* Setup instructions */}
@@ -0,0 +1,162 @@
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 { McpCloudLine } from './McpCloudLine'
6
+ import { clearHintMemory } from '../cloudHints/hintStorage'
7
+
8
+ type CloudConnect = { lane: 'driver' | 'wizard'; appUrl?: string } | undefined
9
+
10
+ const state = vi.hoisted(() => ({
11
+ embedded: false,
12
+ cloudConnect: undefined as CloudConnect,
13
+ mode: 'local' as string | undefined,
14
+ connection: 'connected',
15
+ discovered: { data: undefined as unknown, isError: false, isPending: false },
16
+ discoverEnabled: [] as boolean[],
17
+ }))
18
+ const openCloudFunnel = vi.hoisted(() => vi.fn())
19
+
20
+ vi.mock('../../context/NavCustomization', () => ({ useNavCustomization: () => ({ embedded: state.embedded }) }))
21
+ vi.mock('../../context/ConnectionContext', () => ({
22
+ useConnection: () => ({ connection: { state: state.connection } }),
23
+ }))
24
+ vi.mock('../../api/client', () => ({
25
+ useCapabilities: () => ({ data: { cloudConnect: state.cloudConnect, deployment: { mode: state.mode } } }),
26
+ useClusterInfo: () => ({ data: { context: 'kind-dev' } }),
27
+ useCloudInstallDiscover: (enabled: boolean) => {
28
+ state.discoverEnabled.push(enabled)
29
+ return enabled ? state.discovered : { data: undefined, isError: false, isPending: false }
30
+ },
31
+ }))
32
+ vi.mock('../cloudHints/cloudHints', async (importOriginal) => ({
33
+ ...(await importOriginal<typeof import('../cloudHints/cloudHints')>()),
34
+ openCloudFunnel,
35
+ }))
36
+
37
+ Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
38
+ let root: Root
39
+ let host: HTMLDivElement
40
+
41
+ function render(onBeforeOpen?: () => void) {
42
+ act(() => root.render(<McpCloudLine onBeforeOpen={onBeforeOpen} />))
43
+ }
44
+
45
+ function remount() {
46
+ act(() => root.unmount())
47
+ root = createRoot(host)
48
+ render()
49
+ }
50
+
51
+ const button = (name: RegExp) => [...host.querySelectorAll('button')].find((b) => name.test(b.textContent ?? '') || name.test(b.getAttribute('aria-label') ?? ''))
52
+
53
+ beforeEach(() => {
54
+ state.embedded = false
55
+ state.cloudConnect = { lane: 'driver', appUrl: 'https://app.radarhq.io' }
56
+ state.mode = 'local'
57
+ state.connection = 'connected'
58
+ state.discovered = { data: { connected: [], partialScan: false }, isError: false, isPending: false }
59
+ state.discoverEnabled = []
60
+ openCloudFunnel.mockReset()
61
+ window.localStorage.clear()
62
+ clearHintMemory()
63
+ host = document.createElement('div')
64
+ document.body.appendChild(host)
65
+ root = createRoot(host)
66
+ })
67
+
68
+ afterEach(() => {
69
+ act(() => root.unmount())
70
+ host.remove()
71
+ vi.restoreAllMocks()
72
+ })
73
+
74
+ describe('McpCloudLine', () => {
75
+ it('names the local limit and opens the Radar Cloud dialog after closing its host', () => {
76
+ const order: string[] = []
77
+ openCloudFunnel.mockImplementation(() => order.push('cloud'))
78
+ render(() => order.push('close'))
79
+ expect(host.textContent).toContain('This endpoint covers this cluster while Radar runs on this machine.')
80
+ expect(host.textContent).toContain('gives one endpoint for every connected cluster, reachable from anywhere.')
81
+ act(() => button(/^Radar Cloud$/)!.click())
82
+ expect(order).toEqual(['close', 'cloud'])
83
+ expect(openCloudFunnel).toHaveBeenCalledWith('mcp')
84
+ })
85
+
86
+ it('does not talk about this machine for an in-cluster Radar', () => {
87
+ state.cloudConnect = { lane: 'wizard', appUrl: 'https://app.radarhq.io' }
88
+ state.mode = 'in-cluster'
89
+ render()
90
+ expect(host.textContent).toContain('This endpoint covers this cluster only.')
91
+ expect(host.textContent).not.toContain('this machine')
92
+ expect(state.discoverEnabled.every((e) => !e)).toBe(true)
93
+ })
94
+
95
+ it.each([
96
+ ['the server sends no cloudConnect (cloud mode, tunneled, out of cohort)', () => { state.cloudConnect = undefined }],
97
+ ['an embedding host renders Radar', () => { state.embedded = true }],
98
+ ])('renders nothing when %s', (_, arrange) => {
99
+ arrange()
100
+ render()
101
+ expect(host.innerHTML).toBe('')
102
+ expect(state.discoverEnabled.every((e) => !e)).toBe(true)
103
+ })
104
+
105
+ it('stays hidden after dismissal across remounts', () => {
106
+ render()
107
+ act(() => button(/Hide this line/)!.click())
108
+ expect(host.innerHTML).toBe('')
109
+ expect(window.localStorage.getItem('radar.cloudHint.mcp.dismissed')).toBe('true')
110
+ remount()
111
+ expect(host.innerHTML).toBe('')
112
+ })
113
+
114
+ it('renders and holds a dismissal when storage is denied', () => {
115
+ const denied = () => { throw new DOMException('denied', 'SecurityError') }
116
+ vi.spyOn(Storage.prototype, 'getItem').mockImplementation(denied)
117
+ vi.spyOn(Storage.prototype, 'setItem').mockImplementation(denied)
118
+ render()
119
+ expect(host.textContent).toContain('Radar Cloud')
120
+ act(() => button(/Hide this line/)!.click())
121
+ expect(host.innerHTML).toBe('')
122
+ remount()
123
+ expect(host.innerHTML).toBe('')
124
+ })
125
+
126
+ it('points to Radar Cloud agent setup when this cluster is already connected to this Hub', () => {
127
+ state.discovered = {
128
+ data: { connected: [{ namespace: 'radar', deployment: 'radar', clusterUrl: 'https://app.radarhq.io/clusters/c1' }], partialScan: false },
129
+ isError: false,
130
+ isPending: false,
131
+ }
132
+ render()
133
+ const link = host.querySelector('a')
134
+ expect(link?.textContent).toBe('Radar Cloud')
135
+ expect(host.textContent).toContain('This cluster is already connected to Radar Cloud. Set up an agent there to use one endpoint for every connected cluster.')
136
+ expect(link?.getAttribute('href')).toBe('https://app.radarhq.io/agents?utm_source=radar-oss&utm_medium=app&utm_campaign=cloud-modal&utm_content=mcp-dialog-agents-link')
137
+ expect(button(/^Radar Cloud$/)).toBeUndefined()
138
+ })
139
+
140
+ it.each([
141
+ ['the connected Radar names no cluster page on this Hub', { data: { connected: [{ namespace: 'radar', deployment: 'radar', hubHost: 'hub.example.com' }], partialScan: false }, isError: false, isPending: false }],
142
+ ['the lookup failed', { data: undefined, isError: true, isPending: false }],
143
+ ])('keeps the dialog link when %s', (_, discovered) => {
144
+ state.discovered = discovered
145
+ render()
146
+ expect(host.querySelector('a')).toBeNull()
147
+ expect(button(/^Radar Cloud$/)).toBeTruthy()
148
+ })
149
+
150
+ it('shows nothing until the lookup answers', () => {
151
+ state.discovered = { data: undefined, isError: false, isPending: true }
152
+ render()
153
+ expect(host.innerHTML).toBe('')
154
+ })
155
+
156
+ it('skips the lookup while the cluster is unreachable', () => {
157
+ state.connection = 'disconnected'
158
+ render()
159
+ expect(state.discoverEnabled.every((e) => !e)).toBe(true)
160
+ expect(button(/^Radar Cloud$/)).toBeTruthy()
161
+ })
162
+ })