@skyhook-io/radar-app 1.19.0 → 1.20.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 (198) hide show
  1. package/README.md +1 -1
  2. package/package.json +5 -5
  3. package/src/App.tsx +37 -9
  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 +353 -64
  13. package/src/api/config.ts +21 -0
  14. package/src/api/diagnose.ts +4 -0
  15. package/src/api/helmInventory.test.tsx +108 -0
  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 +42 -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/curl/ServiceCurlAvailability.test.tsx +32 -0
  48. package/src/components/curl/ServiceCurlButton.tsx +2 -2
  49. package/src/components/diagnose/AIMarkdown.tsx +3 -0
  50. package/src/components/diagnose/AgentSetupNotice.test.tsx +17 -0
  51. package/src/components/diagnose/AgentSetupNotice.tsx +21 -3
  52. package/src/components/diagnose/ContinueInAgentButton.mounted.test.tsx +182 -0
  53. package/src/components/diagnose/ContinueInAgentButton.test.tsx +128 -0
  54. package/src/components/diagnose/ContinueInAgentButton.tsx +303 -0
  55. package/src/components/diagnose/DiagnoseContext.question.test.tsx +1 -1
  56. package/src/components/diagnose/DiagnoseContext.tsx +68 -2
  57. package/src/components/diagnose/DiagnoseSurface.tsx +58 -113
  58. package/src/components/diagnose/ExampleInvestigationLink.tsx +20 -0
  59. package/src/components/diagnose/Home.test.tsx +26 -0
  60. package/src/components/diagnose/Home.tsx +20 -1
  61. package/src/components/diagnose/InvestigationEvidenceSections.tsx +45 -22
  62. package/src/components/diagnose/InvestigationView.tsx +94 -26
  63. package/src/components/diagnose/LocalDiagnoseAction.history.test.tsx +450 -0
  64. package/src/components/diagnose/LocalDiagnoseAction.tsx +354 -35
  65. package/src/components/diagnose/NextStepJump.test.tsx +92 -0
  66. package/src/components/diagnose/NextStepJump.tsx +75 -0
  67. package/src/components/diagnose/QuestionComposer.tsx +8 -0
  68. package/src/components/diagnose/exampleInvestigation.events.json +191 -0
  69. package/src/components/diagnose/exampleInvestigation.loadFailure.test.tsx +94 -0
  70. package/src/components/diagnose/exampleInvestigation.test.tsx +248 -0
  71. package/src/components/diagnose/exampleInvestigation.ts +121 -0
  72. package/src/components/diagnose/investigationCase.test.tsx +50 -1
  73. package/src/components/diagnose/investigationEvidence/adapters/applicationFindings.test.ts +739 -0
  74. package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +72 -0
  75. package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +50 -2
  76. package/src/components/diagnose/investigationEvidence/adapters/helm.ts +51 -16
  77. package/src/components/diagnose/investigationEvidence/adapters/issues.ts +9 -0
  78. package/src/components/diagnose/investigationEvidence/adapters/listings.ts +34 -4
  79. package/src/components/diagnose/investigationEvidence/adapters/resource.ts +3 -2
  80. package/src/components/diagnose/investigationEvidence/builder.ts +30 -0
  81. package/src/components/diagnose/investigationEvidence/observations.ts +121 -2
  82. package/src/components/diagnose/investigationEvidence/projection.test.ts +85 -3
  83. package/src/components/diagnose/investigationEvidence/types.ts +5 -0
  84. package/src/components/diagnose/investigationState.ts +28 -0
  85. package/src/components/diagnose/lastInvestigation.test.ts +95 -0
  86. package/src/components/diagnose/lastInvestigation.ts +58 -0
  87. package/src/components/diagnose/launch.test.ts +125 -1
  88. package/src/components/diagnose/launch.ts +57 -10
  89. package/src/components/diagnose/toolCallLabel.test.ts +10 -4
  90. package/src/components/execution/BatchExecutionView.tsx +24 -11
  91. package/src/components/execution/JobSetAdmission.test.tsx +42 -0
  92. package/src/components/execution/JobSetAdmission.tsx +18 -3
  93. package/src/components/execution/JobSetMemberComparison.tsx +2 -1
  94. package/src/components/execution/runState.test.ts +14 -0
  95. package/src/components/execution/runState.ts +8 -0
  96. package/src/components/gitops/GitOpsView.rollbackGate.test.tsx +202 -0
  97. package/src/components/gitops/GitOpsView.syncRequest.test.tsx +369 -0
  98. package/src/components/gitops/GitOpsView.tsx +86 -17
  99. package/src/components/gitops/RemoteDestinationCloudHint.tsx +2 -3
  100. package/src/components/gitops/destination-toast.test.ts +1 -1
  101. package/src/components/gitops/destination-toast.ts +2 -2
  102. package/src/components/helm/HelmDrawerFrame.tsx +101 -0
  103. package/src/components/helm/HelmDrawerRouting.test.tsx +86 -0
  104. package/src/components/helm/HelmReleaseDrawer.tsx +23 -86
  105. package/src/components/helm/HelmView.tsx +213 -71
  106. package/src/components/helm/ObservedHelmNotice.tsx +146 -0
  107. package/src/components/helm/ObservedHelmRelease.test.tsx +261 -0
  108. package/src/components/helm/ObservedHelmReleaseDrawer.test.tsx +80 -0
  109. package/src/components/helm/ObservedHelmReleaseDrawer.tsx +228 -0
  110. package/src/components/helm/OwnedResources.tsx +4 -2
  111. package/src/components/home/ClusterHealthCard.restricted.test.tsx +76 -0
  112. package/src/components/home/ClusterHealthCard.tsx +28 -5
  113. package/src/components/home/HelmSummary.tsx +23 -4
  114. package/src/components/home/HelmSummary.unread.test.ts +16 -0
  115. package/src/components/home/HomeAgentBlock.test.tsx +31 -3
  116. package/src/components/home/HomeAgentBlock.tsx +20 -4
  117. package/src/components/home/HomeDiagramCard.tsx +47 -0
  118. package/src/components/home/HomeView.tsx +81 -41
  119. package/src/components/home/MCPSetupDialog.test.tsx +126 -10
  120. package/src/components/home/MCPSetupDialog.tsx +33 -5
  121. package/src/components/home/ProblemsPanel.investigate.test.tsx +171 -0
  122. package/src/components/home/ProblemsPanel.test.tsx +3 -1
  123. package/src/components/home/TopologyPreview.test.tsx +73 -0
  124. package/src/components/home/TopologyPreview.tsx +120 -233
  125. package/src/components/home/TrafficSummary.test.tsx +63 -0
  126. package/src/components/home/TrafficSummary.tsx +135 -138
  127. package/src/components/home/mcpToolCatalog.ts +67 -14
  128. package/src/components/issues/IssuesPane.test.ts +11 -0
  129. package/src/components/issues/IssuesPane.tsx +15 -5
  130. package/src/components/issues/uncheckedSources.test.ts +22 -1
  131. package/src/components/issues/uncheckedSources.ts +21 -0
  132. package/src/components/kueue/KueuePendingPosition.tsx +35 -0
  133. package/src/components/kueue/useRelatedObjects.test.tsx +219 -0
  134. package/src/components/kueue/useRelatedReads.test.ts +56 -0
  135. package/src/components/kueue/useRelatedReads.ts +205 -0
  136. package/src/components/logs/MultiPodLogsTab.test.tsx +93 -0
  137. package/src/components/logs/MultiPodLogsTab.tsx +120 -0
  138. package/src/components/logs/PodLogsUnavailable.test.tsx +18 -0
  139. package/src/components/logs/PodLogsUnavailable.tsx +21 -0
  140. package/src/components/logs/RayClusterLogsTab.reselect.test.tsx +67 -0
  141. package/src/components/logs/RayClusterLogsTab.test.tsx +167 -0
  142. package/src/components/logs/RayClusterLogsTab.tsx +109 -0
  143. package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +3 -2
  144. package/src/components/logs/rayClusterPods.ts +32 -0
  145. package/src/components/outageSince.test.ts +21 -0
  146. package/src/components/outageSince.ts +10 -0
  147. package/src/components/resource/PrometheusCharts.overlays.test.ts +12 -0
  148. package/src/components/resource/PrometheusCharts.tsx +3 -40
  149. package/src/components/resources/crd/CRDSchemaTab.test.tsx +28 -0
  150. package/src/components/resources/crd/CRDSchemaTab.tsx +13 -0
  151. package/src/components/resources/crd/host.tsx +14 -0
  152. package/src/components/resources/renderers/CustomResourceDefinitionRenderer.test.tsx +27 -0
  153. package/src/components/resources/renderers/CustomResourceDefinitionRenderer.tsx +12 -0
  154. package/src/components/resources/renderers/JobAdmissionRenderers.test.tsx +4 -1
  155. package/src/components/resources/renderers/JobAdmissionRenderers.tsx +4 -3
  156. package/src/components/resources/renderers/KueueHostRenderers.test.tsx +117 -0
  157. package/src/components/resources/renderers/KueueQueueRenderers.test.tsx +97 -0
  158. package/src/components/resources/renderers/KueueQueueRenderers.tsx +139 -0
  159. package/src/components/resources/renderers/KueueWorkloadRenderer.test.tsx +7 -1
  160. package/src/components/resources/renderers/KueueWorkloadRenderer.tsx +47 -7
  161. package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.test.tsx +67 -0
  162. package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.tsx +31 -0
  163. package/src/components/resources/renderers/RayClusterRenderer.test.tsx +81 -3
  164. package/src/components/resources/renderers/RayClusterRenderer.tsx +19 -4
  165. package/src/components/resources/renderers/ServiceRenderer.test.tsx +15 -2
  166. package/src/components/resources/renderers/ServiceRenderer.tsx +1 -1
  167. package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.test.tsx +160 -0
  168. package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.tsx +128 -0
  169. package/src/components/traffic/TrafficView.tsx +3 -3
  170. package/src/components/ui/command-items-crd.test.tsx +23 -0
  171. package/src/components/ui/command-items.ts +2 -1
  172. package/src/components/useContextSwitchFlow.test.tsx +61 -0
  173. package/src/components/useContextSwitchFlow.tsx +21 -4
  174. package/src/components/whats-new/WhatsNew.test.ts +10 -3
  175. package/src/components/whats-new/WhatsNew.tsx +5 -1
  176. package/src/components/whats-new/WhatsNewDialog.test.tsx +17 -3
  177. package/src/components/whats-new/releaseNotes.ts +77 -4
  178. package/src/components/workload/RelatedFindingsSection.test.tsx +126 -0
  179. package/src/components/workload/RelatedFindingsSection.tsx +80 -0
  180. package/src/components/workload/WorkloadView.test.ts +10 -1
  181. package/src/components/workload/WorkloadView.tsx +85 -98
  182. package/src/components/workload/issueResourceOpener.test.ts +20 -0
  183. package/src/components/workload/issueResourceOpener.ts +17 -0
  184. package/src/context/ConnectionContext.tsx +133 -60
  185. package/src/context/ConnectionProvider.retry.test.tsx +176 -0
  186. package/src/context/ContextSwitchContext.tsx +14 -1
  187. package/src/context/DiagnoseCustomization.tsx +3 -0
  188. package/src/context/clusterConnected.ts +10 -0
  189. package/src/contexts/CapabilitiesContext.tsx +8 -4
  190. package/src/hooks/useElementSize.ts +30 -0
  191. package/src/hooks/useResolvedGitOpsOwner.test.ts +22 -0
  192. package/src/hooks/useResolvedGitOpsOwner.ts +6 -3
  193. package/src/integrations/resourceHost.test.tsx +1 -0
  194. package/src/integrations/resourceHost.ts +5 -1
  195. package/src/integrations/resourceHosts.test.tsx +21 -4
  196. package/src/integrations/resourceHosts.tsx +17 -0
  197. package/src/main.tsx +5 -0
  198. package/src/utils/related-findings.ts +46 -0
@@ -0,0 +1,303 @@
1
+ import {
2
+ useEffect,
3
+ useId,
4
+ useLayoutEffect,
5
+ useRef,
6
+ useState,
7
+ type FocusEvent,
8
+ type KeyboardEvent,
9
+ } from "react";
10
+ import { Check, Copy, TerminalSquare } from "lucide-react";
11
+ import { clsx } from "clsx";
12
+ import { copyText } from "@skyhook-io/k8s-ui/utils/clipboard";
13
+ import { useAnimatedUnmount } from "../../hooks/useAnimatedUnmount";
14
+ import {
15
+ TRANSITION_MENU,
16
+ overlayExitMs,
17
+ overlayTransitionStyle,
18
+ } from "../../utils/animation";
19
+ import { type RunSummary } from "../../api/diagnose";
20
+ import { mcpEndpointUrl } from "../../api/config";
21
+ import { useCapabilitiesContext } from "../../contexts/CapabilitiesContext";
22
+ import {
23
+ buildLaunchCommand,
24
+ launchAgentLabel,
25
+ launchTrustHint,
26
+ openInTerminal,
27
+ } from "./launch";
28
+
29
+ const TERMINAL_TITLE = "Radar Investigation";
30
+
31
+ export function useContinueInAgentCommand(
32
+ run: RunSummary | null,
33
+ ): string | null {
34
+ const { mcpReadOnly, localShell } = useCapabilitiesContext();
35
+ return run
36
+ ? buildLaunchCommand(run, mcpEndpointUrl(mcpReadOnly), localShell)
37
+ : null;
38
+ }
39
+
40
+ export function ContinueInAgentButton({
41
+ run,
42
+ command,
43
+ }: {
44
+ run: RunSummary;
45
+ command: string;
46
+ }) {
47
+ const { localTerminal } = useCapabilitiesContext();
48
+ const label = launchAgentLabel(run);
49
+ const trustHint = launchTrustHint(run);
50
+ const [open, setOpen] = useState(false);
51
+ const [copy, setCopy] = useState<"idle" | "copied" | "failed">("idle");
52
+ const { shouldRender, isOpen } = useAnimatedUnmount(
53
+ open,
54
+ overlayExitMs("menu"),
55
+ );
56
+ const rootRef = useRef<HTMLDivElement>(null);
57
+ const menuRef = useRef<HTMLDivElement>(null);
58
+ const triggerRef = useRef<HTMLButtonElement>(null);
59
+ const menuId = useId();
60
+ const introId = useId();
61
+ const hintId = useId();
62
+ const copyingRef = useRef(false);
63
+ // The menu lives inside the Findings scroller, which clips it: open toward
64
+ // the side with room, and cap the height when neither side has enough.
65
+ const [placement, setPlacement] = useState<{
66
+ up: boolean;
67
+ maxHeight?: number;
68
+ }>({ up: false });
69
+
70
+ useLayoutEffect(() => {
71
+ if (!open || !shouldRender) return;
72
+ const trigger = rootRef.current?.getBoundingClientRect();
73
+ const menuHeight = menuRef.current?.scrollHeight ?? 0;
74
+ if (!trigger) return;
75
+ const bounds = rootRef.current
76
+ ?.closest("[data-investigation-findings-scroll]")
77
+ ?.getBoundingClientRect() ?? { top: 0, bottom: window.innerHeight };
78
+ const below = bounds.bottom - trigger.bottom - 8;
79
+ const above = trigger.top - bounds.top - 8;
80
+ const up = menuHeight > below && above > below;
81
+ const room = up ? above : below;
82
+ setPlacement({ up, maxHeight: menuHeight > room ? room : undefined });
83
+ }, [open, shouldRender]);
84
+
85
+ useEffect(() => {
86
+ if (!open) return;
87
+ const onPointerDown = (event: PointerEvent) => {
88
+ if (!rootRef.current?.contains(event.target as Node)) setOpen(false);
89
+ };
90
+ // Capture phase, consumed: the Escape that closes this menu must not also
91
+ // close the investigation panel.
92
+ const onKeyDown = (event: globalThis.KeyboardEvent) => {
93
+ if (event.key !== "Escape") return;
94
+ event.preventDefault();
95
+ event.stopPropagation();
96
+ setOpen(false);
97
+ triggerRef.current?.focus();
98
+ };
99
+ // Placement is measured on open, so moving the pane closes the menu.
100
+ const close = () => setOpen(false);
101
+ const onScroll = (event: Event) => {
102
+ if (!menuRef.current?.contains(event.target as Node)) close();
103
+ };
104
+ document.addEventListener("pointerdown", onPointerDown);
105
+ document.addEventListener("keydown", onKeyDown, true);
106
+ window.addEventListener("scroll", onScroll, true);
107
+ window.addEventListener("resize", close);
108
+ return () => {
109
+ document.removeEventListener("pointerdown", onPointerDown);
110
+ document.removeEventListener("keydown", onKeyDown, true);
111
+ window.removeEventListener("scroll", onScroll, true);
112
+ window.removeEventListener("resize", close);
113
+ };
114
+ }, [open]);
115
+
116
+ useEffect(() => {
117
+ if (open && isOpen) {
118
+ menuRef.current
119
+ ?.querySelector<HTMLElement>("button")
120
+ ?.focus({ preventScroll: true });
121
+ }
122
+ }, [open, isOpen]);
123
+
124
+ useEffect(() => {
125
+ if (copy === "idle") return;
126
+ const t = window.setTimeout(() => setCopy("idle"), 1400);
127
+ return () => window.clearTimeout(t);
128
+ }, [copy]);
129
+
130
+ const toggle = () => {
131
+ setCopy("idle");
132
+ setOpen((v) => !v);
133
+ };
134
+ const runInTerminal = () => {
135
+ setOpen(false);
136
+ openInTerminal(command, TERMINAL_TITLE);
137
+ };
138
+ const copyCommand = () => {
139
+ // The clipboard fallback focuses a temporary textarea outside the menu.
140
+ copyingRef.current = true;
141
+ void copyText(command).then((ok) => {
142
+ copyingRef.current = false;
143
+ setCopy(ok ? "copied" : "failed");
144
+ });
145
+ };
146
+ // Only focus that lands somewhere else closes the menu. Safari does not
147
+ // focus a clicked button, so a click inside blurs to nothing; clicks outside
148
+ // are the pointerdown listener's job.
149
+ const onFocusLeave = (event: FocusEvent<HTMLDivElement>) => {
150
+ const next = event.relatedTarget as Node | null;
151
+ if (next && !copyingRef.current && !rootRef.current?.contains(next))
152
+ setOpen(false);
153
+ };
154
+ const onMenuKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
155
+ const items = Array.from(
156
+ menuRef.current?.querySelectorAll<HTMLElement>("button") ?? [],
157
+ );
158
+ if (items.length === 0) return;
159
+ // Tab moves between the panel's buttons; leaving either end closes it
160
+ // and goes back to the button that opened it.
161
+ if (event.key === "Tab") {
162
+ const edge = event.shiftKey ? items[0] : items[items.length - 1];
163
+ if (document.activeElement !== edge) return;
164
+ event.preventDefault();
165
+ setOpen(false);
166
+ triggerRef.current?.focus();
167
+ return;
168
+ }
169
+ if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return;
170
+ event.preventDefault();
171
+ const at = items.indexOf(document.activeElement as HTMLElement);
172
+ const step = event.key === "ArrowDown" ? 1 : -1;
173
+ items[(at + step + items.length) % items.length].focus();
174
+ };
175
+
176
+ // One button that always opens the panel: the hand-off is rare and
177
+ // deliberate, so the panel can say what happens (and warn about Claude
178
+ // Code's trust prompt) before anything runs. Docked, the header is narrow
179
+ // and the label keeps only where it goes.
180
+ return (
181
+ <div
182
+ ref={rootRef}
183
+ onBlur={onFocusLeave}
184
+ className="relative inline-flex shrink-0"
185
+ >
186
+ <button
187
+ ref={triggerRef}
188
+ type="button"
189
+ onClick={toggle}
190
+ aria-haspopup="dialog"
191
+ aria-expanded={open}
192
+ aria-controls={shouldRender ? menuId : undefined}
193
+ aria-label={`Continue in ${label}`}
194
+ className="inline-flex items-center gap-1.5 whitespace-nowrap rounded-md border border-theme-border bg-theme-surface px-2 py-1 text-xs font-medium text-theme-text-primary hover:bg-theme-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50"
195
+ >
196
+ <TerminalSquare
197
+ className="h-3.5 w-3.5 text-theme-text-tertiary"
198
+ aria-hidden
199
+ />
200
+ <span>
201
+ <span className="hidden @min-[640px]/diagnose-surface:inline">
202
+ Continue in{" "}
203
+ </span>
204
+ {label}…
205
+ </span>
206
+ </button>
207
+ {shouldRender && (
208
+ <div
209
+ ref={menuRef}
210
+ id={menuId}
211
+ role="dialog"
212
+ aria-label={`Continue in ${label}`}
213
+ aria-describedby={trustHint ? `${introId} ${hintId}` : introId}
214
+ inert={!open}
215
+ onKeyDown={onMenuKeyDown}
216
+ className={clsx(
217
+ "absolute right-0 z-30 w-[min(22rem,calc(100cqw-2rem))] rounded-lg border border-theme-border bg-theme-surface p-3 shadow-theme-lg",
218
+ placement.maxHeight !== undefined && "overflow-y-auto",
219
+ placement.up
220
+ ? "bottom-full mb-1 origin-bottom-right"
221
+ : "top-full mt-1 origin-top-right",
222
+ TRANSITION_MENU,
223
+ isOpen
224
+ ? "translate-y-0 scale-100 opacity-100"
225
+ : placement.up
226
+ ? "translate-y-1 scale-[0.97] opacity-0"
227
+ : "-translate-y-1 scale-[0.97] opacity-0",
228
+ !open && "pointer-events-none",
229
+ )}
230
+ style={{
231
+ ...overlayTransitionStyle(isOpen, "menu"),
232
+ maxHeight: placement.maxHeight,
233
+ }}
234
+ >
235
+ <p id={introId} className="text-xs text-theme-text-secondary">
236
+ Resumes this session in {label} with Radar&apos;s MCP attached.
237
+ </p>
238
+ {trustHint && (
239
+ <p
240
+ id={hintId}
241
+ data-continue-trust-hint
242
+ className="mt-1 text-xs text-theme-text-tertiary"
243
+ >
244
+ {trustHint}
245
+ </p>
246
+ )}
247
+ {localTerminal && (
248
+ <button
249
+ type="button"
250
+ onClick={runInTerminal}
251
+ className="btn-brand mt-3 inline-flex w-full items-center justify-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50"
252
+ >
253
+ <TerminalSquare className="h-3.5 w-3.5" aria-hidden />
254
+ Run in Radar terminal
255
+ </button>
256
+ )}
257
+ <p className="mt-3 text-[11px] text-theme-text-tertiary">
258
+ {localTerminal ? "Or paste it" : "Paste it"} where you run {label}:
259
+ </p>
260
+ <div className="mt-1 flex items-start gap-1 rounded-md border border-theme-border bg-theme-base py-1 pl-2 pr-1">
261
+ <code
262
+ data-continue-command
263
+ className="max-h-24 min-w-0 flex-1 overflow-y-auto whitespace-pre-wrap break-all py-0.5 font-mono text-[11px] leading-snug text-theme-text-secondary"
264
+ >
265
+ {command}
266
+ </code>
267
+ <button
268
+ type="button"
269
+ onClick={copyCommand}
270
+ aria-label={
271
+ copy === "copied"
272
+ ? "Command copied"
273
+ : copy === "failed"
274
+ ? "Copy failed"
275
+ : "Copy command"
276
+ }
277
+ aria-live="polite"
278
+ className={clsx(
279
+ "inline-flex shrink-0 items-center gap-1 rounded px-1.5 py-1 text-[11px] font-medium hover:bg-theme-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50",
280
+ copy === "copied"
281
+ ? "text-theme-text-primary"
282
+ : copy === "failed"
283
+ ? "text-warning-text"
284
+ : "text-theme-text-tertiary hover:text-theme-text-primary",
285
+ )}
286
+ >
287
+ {copy === "copied" ? (
288
+ <>
289
+ <Check className="h-3.5 w-3.5 text-success" aria-hidden />
290
+ Copied
291
+ </>
292
+ ) : copy === "failed" ? (
293
+ "Copy failed"
294
+ ) : (
295
+ <Copy className="h-3.5 w-3.5" aria-hidden />
296
+ )}
297
+ </button>
298
+ </div>
299
+ </div>
300
+ )}
301
+ </div>
302
+ );
303
+ }
@@ -170,7 +170,7 @@ describe("starting from a question", () => {
170
170
  group: "apps",
171
171
  namespace: "shop",
172
172
  name: "api",
173
- context: "ctx",
173
+ context: "cluster-a",
174
174
  status: "running",
175
175
  question,
176
176
  createdAt: "2026-10-28T09:00:00Z",
@@ -40,6 +40,11 @@ import {
40
40
  type ExecutionProfile,
41
41
  } from "../../api/diagnose";
42
42
  import { isQuestionOnly, runTargetKey } from "./target";
43
+ import {
44
+ type LastInvestigation,
45
+ lastInvestigations,
46
+ } from "./lastInvestigation";
47
+ import { isExampleInvestigation } from "./exampleInvestigation";
43
48
  import { knownKindForPluralWithGroup } from "../../utils/navigation";
44
49
 
45
50
  export interface Target {
@@ -200,6 +205,8 @@ interface DiagnoseLayoutCtx {
200
205
  // doesn't stand in for a fresh resource start.
201
206
  runningRunIds: ReadonlyMap<string, string>;
202
207
  runningCount: number;
208
+ // The newest recent assessment of each resource on the cluster in use.
209
+ lastInvestigations: ReadonlyMap<string, LastInvestigation>;
203
210
  }
204
211
 
205
212
  const Ctx = createContext<DiagnoseCtx | null>(null);
@@ -537,6 +544,7 @@ function RoutedDiagnoseProvider({
537
544
  );
538
545
  const [runs, setRuns] = useState<RunSummary[]>([]);
539
546
  const [runsLoaded, setRunsLoaded] = useState(false);
547
+ const [listedAt, setListedAt] = useState(() => Date.now());
540
548
  const [runsLoadFailed, setRunsLoadFailed] = useState(false);
541
549
  const [historyDegraded, setHistoryDegraded] = useState(false);
542
550
  const [pendingTarget, setPendingTarget] = useState<Target | null>(null);
@@ -743,10 +751,17 @@ function RoutedDiagnoseProvider({
743
751
  return () => window.removeEventListener("resize", onResize);
744
752
  }, []);
745
753
 
754
+ // Fetches overlap (polling, focus, a cluster switch). One that started
755
+ // before the list last changed is dropped, or an older snapshot could
756
+ // restore cleared runs; a slow fetch still lands if nothing newer did.
757
+ const listSeqRef = useRef(0);
758
+ const appliedListSeqRef = useRef(0);
746
759
  const refreshRuns = useCallback(async () => {
747
760
  if (!available) return;
761
+ const seq = ++listSeqRef.current;
748
762
  try {
749
763
  const r = await listRuns();
764
+ if (seq < appliedListSeqRef.current) return;
750
765
  const focusedID = activeRunIdRef.current;
751
766
  let focusedRun: RunSummary | null = null;
752
767
  let retainFocusedSnapshot = false;
@@ -755,7 +770,11 @@ function RoutedDiagnoseProvider({
755
770
  : undefined;
756
771
  if (focusedID && listedFocusedRun) {
757
772
  unavailableRunIDsRef.current.delete(focusedID);
758
- } else if (focusedID && !unavailableRunIDsRef.current.has(focusedID)) {
773
+ } else if (
774
+ focusedID &&
775
+ !isExampleInvestigation(focusedID) &&
776
+ !unavailableRunIDsRef.current.has(focusedID)
777
+ ) {
759
778
  try {
760
779
  // A stable deep link can target a retained run older than the bounded
761
780
  // history page. Refresh it directly too: its status and capabilities
@@ -771,6 +790,9 @@ function RoutedDiagnoseProvider({
771
790
  retainFocusedSnapshot = !unavailable;
772
791
  }
773
792
  }
793
+ if (seq < appliedListSeqRef.current) return;
794
+ appliedListSeqRef.current = seq;
795
+ setListedAt(Date.now());
774
796
  setRuns((prev) => {
775
797
  let nextRuns = r.runs;
776
798
  if (focusedRun) nextRuns = [focusedRun, ...nextRuns];
@@ -797,6 +819,7 @@ function RoutedDiagnoseProvider({
797
819
  setRunsLoadFailed(false);
798
820
  setHistoryDegraded(!!r.historyDegraded);
799
821
  } catch {
822
+ if (seq < appliedListSeqRef.current) return;
800
823
  // Leave runsLoaded false (a missing-run verdict needs a real list) but
801
824
  // record the failure so the panel can say "retrying" instead of
802
825
  // pretending nothing happened. The 4s poll keeps retrying while open.
@@ -836,8 +859,16 @@ function RoutedDiagnoseProvider({
836
859
  // change.
837
860
  // A plain resource run sorts after a question about the same resource, so
838
861
  // it is the one a key maps to when both are live.
862
+ // A local run names the kubeconfig context it ran in, so a same-named
863
+ // resource on another cluster isn't it. A hosted list is already one
864
+ // cluster's and labels it differently. Until the cluster in use is known, a
865
+ // live run can't be ruled out by it.
866
+ const scopeByContext = !hosted && !!currentContext;
839
867
  const runningSig = runningRuns
840
- .filter((r) => !isQuestionOnly(r))
868
+ .filter(
869
+ (r) =>
870
+ !isQuestionOnly(r) && (!scopeByContext || r.context === currentContext),
871
+ )
841
872
  .map(
842
873
  (r) =>
843
874
  `${runTargetKey(r.kind, r.namespace, r.name, r.group)}\t${r.question ? 0 : 1}\t${r.id}`,
@@ -862,6 +893,21 @@ function RoutedDiagnoseProvider({
862
893
  );
863
894
  const runningCount = runningRuns.length;
864
895
  const hasRunning = runningCount > 0;
896
+ // The clock the cutoff reads moves on each fetch and hourly, so an entry
897
+ // ages out while nothing polls.
898
+ useEffect(() => {
899
+ const t = setInterval(() => setListedAt(Date.now()), 60 * 60 * 1000);
900
+ return () => clearInterval(t);
901
+ }, []);
902
+ // Serialized so the buttons re-render only when an entry changes, not on
903
+ // every poll that returns a fresh array.
904
+ const lastSig = JSON.stringify(
905
+ hosted ? [] : [...lastInvestigations(runs, currentContext, listedAt)],
906
+ );
907
+ const lastInvestigationsByKey = useMemo(
908
+ () => new Map<string, LastInvestigation>(JSON.parse(lastSig)),
909
+ [lastSig],
910
+ );
865
911
 
866
912
  // Keep the run list (statuses, new background runs) fresh while the surface is open
867
913
  // OR while any investigation is still running — so the button indicator stays live
@@ -875,6 +921,22 @@ function RoutedDiagnoseProvider({
875
921
  return () => clearInterval(t);
876
922
  }, [open, available, hasRunning, refreshRuns]);
877
923
 
924
+ // A resource shows its last investigation without the panel open, so the
925
+ // list also catches up when the window comes back (another tab's run, a
926
+ // cleared history, a failed first fetch) and when the cluster changes.
927
+ useEffect(() => {
928
+ if (!available) return;
929
+ window.addEventListener("focus", refreshRuns);
930
+ return () => window.removeEventListener("focus", refreshRuns);
931
+ }, [available, refreshRuns]);
932
+ const listedContextRef = useRef(currentContext);
933
+ useEffect(() => {
934
+ if (listedContextRef.current === currentContext) return;
935
+ const switched = listedContextRef.current !== undefined;
936
+ listedContextRef.current = currentContext;
937
+ if (switched) refreshRuns();
938
+ }, [currentContext, refreshRuns]);
939
+
878
940
  const consentedRef = useRef(consented);
879
941
  consentedRef.current = consented;
880
942
 
@@ -960,6 +1022,7 @@ function RoutedDiagnoseProvider({
960
1022
  setView("investigation");
961
1023
  setOpen(true);
962
1024
  writeFocusedRunID(id, true);
1025
+ if (isExampleInvestigation(id)) return;
963
1026
  // A Fleet issue can point at a retained automatic run older than the
964
1027
  // bounded history page. Resolve the exact id instead of waiting for list.
965
1028
  getRun(id)
@@ -1054,6 +1117,7 @@ function RoutedDiagnoseProvider({
1054
1117
  setActiveRunId(id);
1055
1118
  setView("investigation");
1056
1119
  setOpen(true);
1120
+ if (isExampleInvestigation(id)) return;
1057
1121
  getRun(id)
1058
1122
  .then(updateRunSummary)
1059
1123
  .catch((error) => {
@@ -1357,6 +1421,7 @@ function RoutedDiagnoseProvider({
1357
1421
  runningKeys,
1358
1422
  runningRunIds,
1359
1423
  runningCount,
1424
+ lastInvestigations: lastInvestigationsByKey,
1360
1425
  }),
1361
1426
  [
1362
1427
  open,
@@ -1370,6 +1435,7 @@ function RoutedDiagnoseProvider({
1370
1435
  runningKeys,
1371
1436
  runningRunIds,
1372
1437
  runningCount,
1438
+ lastInvestigationsByKey,
1373
1439
  setMaximized,
1374
1440
  setWidth,
1375
1441
  ],