@skyhook-io/radar-app 1.19.0 → 1.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/README.md +1 -1
  2. package/package.json +5 -5
  3. package/src/App.tsx +31 -5
  4. package/src/api/application-evidence.ts +63 -0
  5. package/src/api/argoSync.test.ts +22 -0
  6. package/src/api/client.audit-gating.test.tsx +48 -0
  7. package/src/api/client.kueuePosition.test.ts +32 -0
  8. package/src/api/client.kueueQueueWorkloads.test.tsx +71 -0
  9. package/src/api/client.resource-identity.test.ts +3 -0
  10. package/src/api/client.resourceIssues.test.tsx +239 -0
  11. package/src/api/client.resourcePath.test.ts +3 -0
  12. package/src/api/client.ts +285 -55
  13. package/src/api/config.ts +21 -0
  14. package/src/api/diagnose.ts +4 -0
  15. package/src/api/radarFeatures.render.test.tsx +33 -1
  16. package/src/api/radarFeatures.test.ts +47 -0
  17. package/src/api/radarFeatures.ts +40 -1
  18. package/src/api/rbac.settled.test.tsx +42 -0
  19. package/src/api/rbac.test.ts +18 -0
  20. package/src/api/rbac.ts +37 -7
  21. package/src/api/traffic.ts +9 -4
  22. package/src/api/usage-data.fixtures.ts +3 -1
  23. package/src/api/usage-data.test.tsx +134 -0
  24. package/src/api/usage-data.ts +35 -7
  25. package/src/api/workloadPodsPolling.test.ts +26 -0
  26. package/src/components/CloudConnectFlow.test.tsx +86 -0
  27. package/src/components/CloudConnectFlow.tsx +65 -27
  28. package/src/components/CloudFunnelButton.test.tsx +140 -5
  29. package/src/components/CloudFunnelButton.tsx +50 -9
  30. package/src/components/ConnectionErrorView.test.tsx +34 -0
  31. package/src/components/ConnectionErrorView.tsx +35 -11
  32. package/src/components/ContextSwitcher.tsx +5 -2
  33. package/src/components/SwitchAwareConnectionError.test.tsx +43 -0
  34. package/src/components/SwitchAwareConnectionError.tsx +85 -0
  35. package/src/components/application-evidence/ApplicationEvidenceAction.flow.test.tsx +234 -0
  36. package/src/components/application-evidence/ApplicationEvidenceAction.test.tsx +144 -0
  37. package/src/components/application-evidence/ApplicationEvidenceAction.tsx +218 -0
  38. package/src/components/capacity/CapacityDemand.tsx +3 -2
  39. package/src/components/capacity/demandSummary.test.ts +38 -0
  40. package/src/components/capacity/shared.tsx +12 -1
  41. package/src/components/cost/ApplicationCostTab.tsx +4 -0
  42. package/src/components/cost/CostTrendChart.tsx +2 -0
  43. package/src/components/cost/WorkloadCostTab.tsx +4 -0
  44. package/src/components/cost/source.test.ts +5 -0
  45. package/src/components/cost/source.ts +11 -0
  46. package/src/components/diagnose/AIMarkdown.tsx +3 -0
  47. package/src/components/diagnose/AgentSetupNotice.test.tsx +17 -0
  48. package/src/components/diagnose/AgentSetupNotice.tsx +21 -3
  49. package/src/components/diagnose/ContinueInAgentButton.mounted.test.tsx +182 -0
  50. package/src/components/diagnose/ContinueInAgentButton.test.tsx +128 -0
  51. package/src/components/diagnose/ContinueInAgentButton.tsx +303 -0
  52. package/src/components/diagnose/DiagnoseContext.question.test.tsx +1 -1
  53. package/src/components/diagnose/DiagnoseContext.tsx +68 -2
  54. package/src/components/diagnose/DiagnoseSurface.tsx +58 -113
  55. package/src/components/diagnose/ExampleInvestigationLink.tsx +20 -0
  56. package/src/components/diagnose/Home.test.tsx +26 -0
  57. package/src/components/diagnose/Home.tsx +20 -1
  58. package/src/components/diagnose/InvestigationEvidenceSections.tsx +45 -22
  59. package/src/components/diagnose/InvestigationView.tsx +94 -26
  60. package/src/components/diagnose/LocalDiagnoseAction.history.test.tsx +450 -0
  61. package/src/components/diagnose/LocalDiagnoseAction.tsx +354 -35
  62. package/src/components/diagnose/NextStepJump.test.tsx +92 -0
  63. package/src/components/diagnose/NextStepJump.tsx +75 -0
  64. package/src/components/diagnose/QuestionComposer.tsx +8 -0
  65. package/src/components/diagnose/exampleInvestigation.events.json +191 -0
  66. package/src/components/diagnose/exampleInvestigation.loadFailure.test.tsx +94 -0
  67. package/src/components/diagnose/exampleInvestigation.test.tsx +248 -0
  68. package/src/components/diagnose/exampleInvestigation.ts +121 -0
  69. package/src/components/diagnose/investigationCase.test.tsx +9 -1
  70. package/src/components/diagnose/investigationEvidence/adapters/applicationFindings.test.ts +739 -0
  71. package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +50 -2
  72. package/src/components/diagnose/investigationEvidence/adapters/issues.ts +9 -0
  73. package/src/components/diagnose/investigationEvidence/builder.ts +30 -0
  74. package/src/components/diagnose/investigationEvidence/observations.ts +121 -2
  75. package/src/components/diagnose/investigationEvidence/projection.test.ts +85 -3
  76. package/src/components/diagnose/investigationEvidence/types.ts +5 -0
  77. package/src/components/diagnose/investigationState.ts +28 -0
  78. package/src/components/diagnose/lastInvestigation.test.ts +95 -0
  79. package/src/components/diagnose/lastInvestigation.ts +58 -0
  80. package/src/components/diagnose/launch.test.ts +125 -1
  81. package/src/components/diagnose/launch.ts +57 -10
  82. package/src/components/diagnose/toolCallLabel.test.ts +10 -4
  83. package/src/components/execution/BatchExecutionView.tsx +24 -11
  84. package/src/components/execution/JobSetAdmission.test.tsx +42 -0
  85. package/src/components/execution/JobSetAdmission.tsx +18 -3
  86. package/src/components/execution/JobSetMemberComparison.tsx +2 -1
  87. package/src/components/execution/runState.test.ts +14 -0
  88. package/src/components/execution/runState.ts +8 -0
  89. package/src/components/gitops/GitOpsView.rollbackGate.test.tsx +202 -0
  90. package/src/components/gitops/GitOpsView.syncRequest.test.tsx +369 -0
  91. package/src/components/gitops/GitOpsView.tsx +86 -17
  92. package/src/components/gitops/RemoteDestinationCloudHint.tsx +2 -3
  93. package/src/components/gitops/destination-toast.test.ts +1 -1
  94. package/src/components/gitops/destination-toast.ts +2 -2
  95. package/src/components/home/ClusterHealthCard.tsx +1 -1
  96. package/src/components/home/HomeAgentBlock.test.tsx +31 -3
  97. package/src/components/home/HomeAgentBlock.tsx +13 -4
  98. package/src/components/home/HomeDiagramCard.tsx +47 -0
  99. package/src/components/home/HomeView.tsx +81 -41
  100. package/src/components/home/MCPSetupDialog.test.tsx +95 -5
  101. package/src/components/home/MCPSetupDialog.tsx +30 -5
  102. package/src/components/home/ProblemsPanel.investigate.test.tsx +171 -0
  103. package/src/components/home/ProblemsPanel.test.tsx +3 -1
  104. package/src/components/home/TopologyPreview.test.tsx +73 -0
  105. package/src/components/home/TopologyPreview.tsx +120 -233
  106. package/src/components/home/TrafficSummary.test.tsx +63 -0
  107. package/src/components/home/TrafficSummary.tsx +135 -138
  108. package/src/components/home/mcpToolCatalog.ts +23 -10
  109. package/src/components/issues/IssuesPane.test.ts +11 -0
  110. package/src/components/issues/IssuesPane.tsx +15 -5
  111. package/src/components/issues/uncheckedSources.test.ts +20 -1
  112. package/src/components/issues/uncheckedSources.ts +18 -0
  113. package/src/components/kueue/KueuePendingPosition.tsx +35 -0
  114. package/src/components/kueue/useRelatedObjects.test.tsx +219 -0
  115. package/src/components/kueue/useRelatedReads.test.ts +56 -0
  116. package/src/components/kueue/useRelatedReads.ts +205 -0
  117. package/src/components/logs/MultiPodLogsTab.test.tsx +93 -0
  118. package/src/components/logs/MultiPodLogsTab.tsx +120 -0
  119. package/src/components/logs/PodLogsUnavailable.test.tsx +18 -0
  120. package/src/components/logs/PodLogsUnavailable.tsx +21 -0
  121. package/src/components/logs/RayClusterLogsTab.reselect.test.tsx +67 -0
  122. package/src/components/logs/RayClusterLogsTab.test.tsx +167 -0
  123. package/src/components/logs/RayClusterLogsTab.tsx +109 -0
  124. package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +3 -2
  125. package/src/components/logs/rayClusterPods.ts +32 -0
  126. package/src/components/outageSince.test.ts +21 -0
  127. package/src/components/outageSince.ts +10 -0
  128. package/src/components/resource/PrometheusCharts.overlays.test.ts +12 -0
  129. package/src/components/resource/PrometheusCharts.tsx +3 -40
  130. package/src/components/resources/crd/CRDSchemaTab.test.tsx +28 -0
  131. package/src/components/resources/crd/CRDSchemaTab.tsx +13 -0
  132. package/src/components/resources/crd/host.tsx +14 -0
  133. package/src/components/resources/renderers/CustomResourceDefinitionRenderer.test.tsx +27 -0
  134. package/src/components/resources/renderers/CustomResourceDefinitionRenderer.tsx +12 -0
  135. package/src/components/resources/renderers/JobAdmissionRenderers.test.tsx +4 -1
  136. package/src/components/resources/renderers/JobAdmissionRenderers.tsx +4 -3
  137. package/src/components/resources/renderers/KueueHostRenderers.test.tsx +117 -0
  138. package/src/components/resources/renderers/KueueQueueRenderers.test.tsx +97 -0
  139. package/src/components/resources/renderers/KueueQueueRenderers.tsx +139 -0
  140. package/src/components/resources/renderers/KueueWorkloadRenderer.test.tsx +7 -1
  141. package/src/components/resources/renderers/KueueWorkloadRenderer.tsx +47 -7
  142. package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.test.tsx +67 -0
  143. package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.tsx +31 -0
  144. package/src/components/resources/renderers/RayClusterRenderer.test.tsx +81 -3
  145. package/src/components/resources/renderers/RayClusterRenderer.tsx +19 -4
  146. package/src/components/traffic/TrafficView.tsx +3 -3
  147. package/src/components/ui/command-items-crd.test.tsx +23 -0
  148. package/src/components/ui/command-items.ts +2 -1
  149. package/src/components/useContextSwitchFlow.test.tsx +61 -0
  150. package/src/components/useContextSwitchFlow.tsx +21 -4
  151. package/src/components/whats-new/WhatsNew.test.ts +10 -3
  152. package/src/components/whats-new/WhatsNew.tsx +5 -1
  153. package/src/components/whats-new/WhatsNewDialog.test.tsx +17 -3
  154. package/src/components/whats-new/releaseNotes.ts +77 -4
  155. package/src/components/workload/RelatedFindingsSection.test.tsx +126 -0
  156. package/src/components/workload/RelatedFindingsSection.tsx +80 -0
  157. package/src/components/workload/WorkloadView.test.ts +10 -1
  158. package/src/components/workload/WorkloadView.tsx +85 -98
  159. package/src/components/workload/issueResourceOpener.test.ts +20 -0
  160. package/src/components/workload/issueResourceOpener.ts +17 -0
  161. package/src/context/ConnectionContext.tsx +133 -60
  162. package/src/context/ConnectionProvider.retry.test.tsx +176 -0
  163. package/src/context/ContextSwitchContext.tsx +14 -1
  164. package/src/context/DiagnoseCustomization.tsx +3 -0
  165. package/src/context/clusterConnected.ts +10 -0
  166. package/src/contexts/CapabilitiesContext.tsx +6 -4
  167. package/src/hooks/useElementSize.ts +30 -0
  168. package/src/integrations/resourceHost.test.tsx +1 -0
  169. package/src/integrations/resourceHost.ts +5 -1
  170. package/src/integrations/resourceHosts.test.tsx +21 -4
  171. package/src/integrations/resourceHosts.tsx +12 -0
  172. package/src/main.tsx +5 -0
  173. package/src/utils/related-findings.ts +46 -0
@@ -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
  ],
@@ -16,14 +16,14 @@ import {
16
16
  Maximize2,
17
17
  Minimize2,
18
18
  Settings2,
19
- MoreVertical,
20
- TerminalSquare,
21
- Copy,
22
- Check,
23
19
  RotateCcw,
24
20
  PanelLeftOpen,
25
21
  } from "lucide-react";
26
22
  import { Tooltip } from "../ui/Tooltip";
23
+ import {
24
+ ContinueInAgentButton,
25
+ useContinueInAgentCommand,
26
+ } from "./ContinueInAgentButton";
27
27
  import { useAnimatedUnmount } from "../../hooks/useAnimatedUnmount";
28
28
  import {
29
29
  TRANSITION_BACKDROP,
@@ -51,6 +51,12 @@ import {
51
51
  statusWord,
52
52
  } from "./Home";
53
53
  import { AgentSetupNotice } from "./AgentSetupNotice";
54
+ import {
55
+ EXAMPLE_INVESTIGATION_ID,
56
+ EXAMPLE_INVESTIGATION_RUN,
57
+ exampleInvestigationOffered,
58
+ isExampleInvestigation,
59
+ } from "./exampleInvestigation";
54
60
  import { AgentSigninNotice } from "./AgentSigninNotice";
55
61
  import {
56
62
  useAgentSignin,
@@ -58,10 +64,7 @@ import {
58
64
  } from "../../hooks/useAgentSignin";
59
65
  import { ConsentCard } from "./parts";
60
66
  import type { ConsentSubject } from "./AgentControls";
61
- import { buildLaunchCommand, launchAgentLabel, openInTerminal } from "./launch";
62
67
  import { type RunSummary, type ExecutionProfile } from "../../api/diagnose";
63
- import { mcpEndpointUrl } from "../../api/config";
64
- import { useCapabilitiesContext } from "../../contexts/CapabilitiesContext";
65
68
  import { useContexts } from "../../api/client";
66
69
  import {
67
70
  formatInvestigationTarget,
@@ -99,107 +102,6 @@ function buildConfigLine(cfg: {
99
102
  return "via " + parts.join(" · ");
100
103
  }
101
104
 
102
- // InvestigationMenu hands an investigation off to the user's own full agent. The
103
- // PRIMARY action copies a resume command they can paste wherever they actually
104
- // work (terminal, tmux, IDE) — destination-agnostic. Running it in Radar's built-in
105
- // terminal is the secondary "run it here" convenience.
106
- function InvestigationMenu({ run }: { run: RunSummary }) {
107
- const [open, setOpen] = useState(false);
108
- const [copied, setCopied] = useState(false);
109
- const menuRef = useRef<HTMLDivElement>(null);
110
- const { localTerminal, mcpReadOnly } = useCapabilitiesContext();
111
- const label = launchAgentLabel(run);
112
- const command = buildLaunchCommand(
113
- run,
114
- mcpEndpointUrl(mcpReadOnly),
115
- );
116
-
117
- // The diagnose root is a CSS container, so a position:fixed click-away layer
118
- // inside it is panel-bound rather than viewport-bound. Dismiss from the
119
- // document instead; the anchored menu itself can stay next to its trigger.
120
- useEffect(() => {
121
- if (!open) return;
122
- const onPointerDown = (event: PointerEvent) => {
123
- if (!menuRef.current?.contains(event.target as Node)) setOpen(false);
124
- };
125
- const onKeyDown = (event: KeyboardEvent) => {
126
- if (event.key === "Escape") setOpen(false);
127
- };
128
- document.addEventListener("pointerdown", onPointerDown);
129
- document.addEventListener("keydown", onKeyDown);
130
- return () => {
131
- document.removeEventListener("pointerdown", onPointerDown);
132
- document.removeEventListener("keydown", onKeyDown);
133
- };
134
- }, [open]);
135
-
136
- // No resumable session yet (or stale run) → nothing to hand off.
137
- if (!command) return null;
138
- const toggle = () => {
139
- setCopied(false);
140
- setOpen((v) => !v);
141
- };
142
- const copy = () => {
143
- void navigator.clipboard?.writeText(command);
144
- setCopied(true);
145
- setTimeout(() => {
146
- setCopied(false);
147
- setOpen(false);
148
- }, 1100);
149
- };
150
-
151
- return (
152
- <div ref={menuRef} className="relative flex items-center">
153
- <Tooltip content="More" position="bottom">
154
- <button
155
- onClick={toggle}
156
- className="rounded-md p-1 text-theme-text-tertiary hover:bg-theme-hover hover:text-theme-text-primary"
157
- aria-label="More actions"
158
- aria-haspopup="menu"
159
- aria-expanded={open}
160
- >
161
- <MoreVertical className="h-4 w-4" />
162
- </button>
163
- </Tooltip>
164
- {open && (
165
- <div className="absolute right-0 top-full z-20 mt-1 w-64 rounded-lg border border-theme-border bg-theme-surface py-1 shadow-theme-lg">
166
- <button
167
- onClick={copy}
168
- className="flex w-full items-start gap-2 px-3 py-1.5 text-left text-sm text-theme-text-primary hover:bg-theme-hover"
169
- >
170
- {copied ? (
171
- <Check className="mt-0.5 h-4 w-4 shrink-0 text-emerald-500" />
172
- ) : (
173
- <Copy className="mt-0.5 h-4 w-4 shrink-0 text-theme-text-tertiary" />
174
- )}
175
- <span>
176
- {copied ? "Copied ✓" : `Copy command to continue in ${label}`}
177
- {!copied && (
178
- <span className="block text-[11px] text-theme-text-tertiary">
179
- Paste it wherever you run {label} — resumes this exact
180
- session.
181
- </span>
182
- )}
183
- </span>
184
- </button>
185
- {localTerminal && (
186
- <button
187
- onClick={() => {
188
- openInTerminal(command, "Radar Investigation");
189
- setOpen(false);
190
- }}
191
- className="flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm text-theme-text-primary hover:bg-theme-hover"
192
- >
193
- <TerminalSquare className="h-4 w-4 shrink-0 text-theme-text-tertiary" />
194
- Run in a Radar terminal
195
- </button>
196
- )}
197
- </div>
198
- )}
199
- </div>
200
- );
201
- }
202
-
203
105
  // The panel is an ABSOLUTE slot inside the app's body frame (the column under the
204
106
  // header, right of the nav rail) — App renders it there and passes topInset (the
205
107
  // header height; 0 in chromeless embeds). It shares that frame with the resource/
@@ -565,11 +467,26 @@ export function DiagnoseSurface({
565
467
  const setupPending =
566
468
  d.setupState === "needs-install" || d.setupState === "needs-restart";
567
469
 
568
- const activeRun = d.runs.find((r) => r.id === d.activeRunId) ?? null;
470
+ const exampleOpen = isExampleInvestigation(d.activeRunId);
471
+ const activeRun = exampleOpen
472
+ ? EXAMPLE_INVESTIGATION_RUN
473
+ : (d.runs.find((r) => r.id === d.activeRunId) ?? null);
474
+ const openExample = exampleInvestigationOffered({
475
+ runs: d.runs,
476
+ runsLoaded: d.runsLoaded,
477
+ setupPending,
478
+ needsConsent: d.needsConsent,
479
+ })
480
+ ? () => d.openRun(EXAMPLE_INVESTIGATION_ID)
481
+ : undefined;
569
482
  // Consent replaces the detail pane even if goHome retained an older run id.
570
483
  // Header identity and actions must describe what is actually visible.
571
484
  const visibleRunDetail =
572
485
  d.needsConsent || d.startCapacity ? null : activeRun;
486
+ // The investigation view knows when its agent session is quiet; the header
487
+ // offers the hand-off only then.
488
+ const [handoffAllowed, setHandoffAllowed] = useState(false);
489
+ const handoffCommand = useContinueInAgentCommand(visibleRunDetail);
573
490
  // A focused run shows the agent it actually ran with; Home reflects the current pick.
574
491
  const activeAgentLabel = visibleRunDetail?.agent
575
492
  ? agentLabelFor(visibleRunDetail.agent)
@@ -642,9 +559,17 @@ export function DiagnoseSurface({
642
559
  run={activeRun}
643
560
  agentLabel={activeAgentLabel}
644
561
  maximized={maximized}
645
- onOpenResource={onOpenResource ? openEvidenceResource : undefined}
646
- onOpenTimeline={onOpenTimeline ? openEvidenceTimeline : undefined}
562
+ // The example's resources are on a test cluster, not this one.
563
+ onOpenResource={
564
+ onOpenResource && !exampleOpen ? openEvidenceResource : undefined
565
+ }
566
+ onOpenTimeline={
567
+ onOpenTimeline && !exampleOpen ? openEvidenceTimeline : undefined
568
+ }
647
569
  onRevealDestination={revealDestination}
570
+ example={exampleOpen}
571
+ onCloseExample={exampleOpen ? d.goHome : undefined}
572
+ onHandoffAllowedChange={setHandoffAllowed}
648
573
  />
649
574
  ) : d.activeRunId && !d.runsLoaded ? (
650
575
  // Deep-linked to a run before the list has ever loaded: show the load
@@ -699,6 +624,7 @@ export function DiagnoseSurface({
699
624
  checkingAgents={d.checkingAgents}
700
625
  agentsCheckFailed={d.agentsCheckFailed}
701
626
  recheckAgents={d.recheckAgents}
627
+ onOpenExample={openExample}
702
628
  />
703
629
  </div>
704
630
  ) : (
@@ -730,12 +656,14 @@ export function DiagnoseSurface({
730
656
  checkingAgents={d.checkingAgents}
731
657
  agentsCheckFailed={d.agentsCheckFailed}
732
658
  recheckAgents={d.recheckAgents}
659
+ onOpenExample={openExample}
733
660
  />
734
661
  </div>
735
662
  ) : (
736
663
  <InvestigationHome
737
664
  agentLabel={d.agentLabel}
738
665
  questions={d.questions}
666
+ onOpenExample={openExample}
739
667
  onBrowseIssues={
740
668
  d.questions || (d.runsLoaded && d.runs.length === 0)
741
669
  ? onBrowseIssues
@@ -847,6 +775,7 @@ export function DiagnoseSurface({
847
775
  <div className="flex shrink-0 items-center gap-1">
848
776
  {activeRun &&
849
777
  visibleRunDetail &&
778
+ !exampleOpen &&
850
779
  canRerunInvestigation(d.view, activeRun, d.needsConsent) && (
851
780
  <Tooltip
852
781
  content="Re-run this investigation from scratch"
@@ -861,7 +790,9 @@ export function DiagnoseSurface({
861
790
  </button>
862
791
  </Tooltip>
863
792
  )}
864
- {visibleRunDetail && headerPresentation.runActionsClass !== null && (
793
+ {visibleRunDetail &&
794
+ !exampleOpen &&
795
+ headerPresentation.runActionsClass !== null && (
865
796
  <div
866
797
  className={`items-center gap-1 ${headerPresentation.runActionsClass || "flex"}`}
867
798
  >
@@ -869,7 +800,12 @@ export function DiagnoseSurface({
869
800
  run: visibleRunDetail,
870
801
  onRunUpdated: d.updateRunSummary,
871
802
  })}
872
- <InvestigationMenu run={visibleRunDetail} />
803
+ {handoffAllowed && handoffCommand && (
804
+ <ContinueInAgentButton
805
+ run={visibleRunDetail}
806
+ command={handoffCommand}
807
+ />
808
+ )}
873
809
  </div>
874
810
  )}
875
811
  {!fullWidthForced && (!maximized || d.canRestoreWorkspace) && (
@@ -946,6 +882,15 @@ export function DiagnoseSurface({
946
882
  loadFailed={d.runsLoadFailed}
947
883
  onRetry={d.refreshRuns}
948
884
  questions={d.questions}
885
+ // Beside Home on the full page, Home already offers it.
886
+ onOpenExample={
887
+ persistentHistory || exampleOpen || !openExample
888
+ ? undefined
889
+ : () => {
890
+ openExample();
891
+ dismissHistory();
892
+ }
893
+ }
949
894
  />
950
895
  </aside>
951
896
  )}
@@ -0,0 +1,20 @@
1
+ import { ArrowRight } from "lucide-react";
2
+
3
+ export function ExampleInvestigationLink({
4
+ onOpen,
5
+ className = "",
6
+ }: {
7
+ onOpen: () => void;
8
+ className?: string;
9
+ }) {
10
+ return (
11
+ <button
12
+ type="button"
13
+ onClick={onOpen}
14
+ className={`inline-flex items-center gap-1 text-xs font-medium text-accent-text hover:underline ${className}`}
15
+ >
16
+ See an example investigation
17
+ <ArrowRight aria-hidden className="h-3 w-3" />
18
+ </button>
19
+ );
20
+ }
@@ -352,6 +352,32 @@ describe("InvestigationHome", () => {
352
352
  expect(text).toContain("Browse issues");
353
353
  expect(html).not.toContain("textarea");
354
354
  });
355
+
356
+ it("links to the example only when the surface offers it", () => {
357
+ const link = "See an example investigation";
358
+ expect(
359
+ visible(renderToStaticMarkup(<InvestigationHome agentLabel="Codex" />)),
360
+ ).not.toContain(link);
361
+ expect(
362
+ visible(
363
+ renderToStaticMarkup(
364
+ <InvestigationHome agentLabel="Codex" onOpenExample={() => {}} />,
365
+ ),
366
+ ),
367
+ ).toContain(link);
368
+ expect(
369
+ visible(
370
+ renderToStaticMarkup(
371
+ <RecentList
372
+ agentLabel="Codex"
373
+ runs={[]}
374
+ onSelect={() => {}}
375
+ onOpenExample={() => {}}
376
+ />,
377
+ ),
378
+ ),
379
+ ).toContain(link);
380
+ });
355
381
  });
356
382
 
357
383
  describe("RecentList question runs", () => {
@@ -22,6 +22,7 @@ import {
22
22
  import { Tooltip } from "../ui/Tooltip";
23
23
  import { QuestionComposer } from "./QuestionComposer";
24
24
  import { plainVerdictText } from "./verdictText";
25
+ import { ExampleInvestigationLink } from "./ExampleInvestigationLink";
25
26
 
26
27
  function daysBefore(date: Date, now: Date): number {
27
28
  const start = (d: Date) =>
@@ -145,17 +146,22 @@ export function statusWord(status: RunSummary["status"]): {
145
146
  export function InvestigationHome({
146
147
  agentLabel,
147
148
  onBrowseIssues,
149
+ onOpenExample,
148
150
  questions = false,
149
151
  }: {
150
152
  agentLabel: string;
151
153
  onBrowseIssues?: () => void;
154
+ onOpenExample?: () => void;
152
155
  /** The backend opens a run from a question; offer the composer. */
153
156
  questions?: boolean;
154
157
  }) {
155
158
  if (questions) {
156
159
  return (
157
160
  <div className="flex min-h-full w-full items-start justify-center px-4 py-10 sm:px-6">
158
- <QuestionComposer onBrowseIssues={onBrowseIssues} />
161
+ <QuestionComposer
162
+ onBrowseIssues={onBrowseIssues}
163
+ onOpenExample={onOpenExample}
164
+ />
159
165
  </div>
160
166
  );
161
167
  }
@@ -187,6 +193,11 @@ export function InvestigationHome({
187
193
  <ArrowRight className="h-3.5 w-3.5" />
188
194
  </button>
189
195
  )}
196
+ {onOpenExample && (
197
+ <div className="mt-4">
198
+ <ExampleInvestigationLink onOpen={onOpenExample} />
199
+ </div>
200
+ )}
190
201
  </section>
191
202
  </div>
192
203
  );
@@ -202,6 +213,7 @@ export function RecentList({
202
213
  loaded = true,
203
214
  loadFailed = false,
204
215
  onRetry,
216
+ onOpenExample,
205
217
  questions = false,
206
218
  }: {
207
219
  agentLabel: string;
@@ -216,6 +228,7 @@ export function RecentList({
216
228
  /** The latest list request failed. */
217
229
  loadFailed?: boolean;
218
230
  onRetry?: () => void;
231
+ onOpenExample?: () => void;
219
232
  /** Home offers the question composer beside this list. */
220
233
  questions?: boolean;
221
234
  }) {
@@ -355,6 +368,12 @@ export function RecentList({
355
368
  background and are kept in your history here.
356
369
  </p>
357
370
  )}
371
+ {onOpenExample && (
372
+ <ExampleInvestigationLink
373
+ onOpen={onOpenExample}
374
+ className="mt-3"
375
+ />
376
+ )}
358
377
  </div>
359
378
  </div>
360
379
  );
@@ -6,6 +6,7 @@ import {
6
6
  CircleAlert,
7
7
  Info,
8
8
  SearchCheck,
9
+ XCircle,
9
10
  } from "lucide-react";
10
11
  import { Collapse, CollapseChevron } from "@skyhook-io/k8s-ui";
11
12
  import type { EvidenceCoverageGroup } from "./investigationEvidencePresentation";
@@ -25,9 +26,14 @@ import { investigationEvidenceFullRowFlags } from "./investigationEvidencePartit
25
26
  import { EvidenceCard } from "./EvidenceCard";
26
27
 
27
28
  /**
28
- * Hypotheses the agent dropped, each pointing at the Radar observation whose
29
- * result contradicted it. Entries whose item could not be placed on an
30
- * observation are filtered out by the resolver and never rendered here.
29
+ * Hypotheses the agent dropped, each with the claim of the Radar observation
30
+ * whose result contradicted it, so the reason reads without a click. The
31
+ * agent writes a hypothesis as a statement, which on its own reads like a
32
+ * finding; the heading, the mark and the screen-reader prefix say it is not
33
+ * the cause. The exclusion is the agent's reading, so the heading keeps the
34
+ * Agent tag in panel mode, where no "Agent analysis" label sits above it.
35
+ * Entries whose item could not be placed on an observation are filtered out
36
+ * by the resolver and never rendered here.
31
37
  */
32
38
  export function RuledOutBlock({
33
39
  entries,
@@ -47,32 +53,39 @@ export function RuledOutBlock({
47
53
  id={headingId}
48
54
  className="flex items-center gap-2 text-xs font-semibold text-theme-text-secondary"
49
55
  >
50
- Also checked
56
+ Ruled out
51
57
  <span className="text-[10px] font-semibold uppercase tracking-wide text-accent-text">
52
58
  Agent
53
59
  </span>
54
60
  </h3>
55
- <ul className="mt-1.5 space-y-1.5">
61
+ <ul className="mt-1.5 space-y-2">
56
62
  {entries.map((entry, position) => {
57
63
  const observation = entry.item.observation!;
58
64
  return (
59
- <li
60
- key={position}
61
- className="flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-0.5 text-xs"
62
- >
63
- <span className="min-w-0 text-theme-text-secondary [overflow-wrap:anywhere]">
64
- {entry.hypothesis}
65
- </span>
66
- <button
67
- type="button"
68
- onClick={() => onReveal(entry.item)}
69
- className="shrink-0 rounded text-accent-text hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50"
70
- >
71
- See {observation.title}
72
- {entry.item.placement === "revision"
73
- ? " (earlier observation)"
74
- : ""}
75
- </button>
65
+ <li key={position} className="flex min-w-0 gap-2 text-xs">
66
+ <XCircle
67
+ className="mt-0.5 h-3.5 w-3.5 shrink-0 text-theme-text-tertiary"
68
+ aria-hidden
69
+ />
70
+ <div className="min-w-0">
71
+ <p className="font-medium text-theme-text-secondary [overflow-wrap:anywhere]">
72
+ <span className="sr-only">Ruled out: </span>
73
+ {entry.hypothesis}
74
+ </p>
75
+ <p className="text-theme-text-tertiary [overflow-wrap:anywhere]">
76
+ {entry.item.claim ? <>{entry.item.claim} </> : null}
77
+ <button
78
+ type="button"
79
+ onClick={() => onReveal(entry.item)}
80
+ className="rounded text-accent-text hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50"
81
+ >
82
+ See {ruledOutEvidenceLabel(observation)}
83
+ {entry.item.placement === "revision"
84
+ ? " (earlier observation)"
85
+ : ""}
86
+ </button>
87
+ </p>
88
+ </div>
76
89
  </li>
77
90
  );
78
91
  })}
@@ -81,6 +94,16 @@ export function RuledOutBlock({
81
94
  );
82
95
  }
83
96
 
97
+ // An issue's title is only its reason ("IPExhaustion"), which says neither
98
+ // that it is an issue nor which resource it is on; two entries can cite the
99
+ // same reason on different resources.
100
+ function ruledOutEvidenceLabel(
101
+ observation: NonNullable<InvestigationCaseItem["observation"]>,
102
+ ): string {
103
+ if (observation.data.type !== "issue") return observation.title;
104
+ return `${observation.title} issue on ${observation.data.issue.name}`;
105
+ }
106
+
84
107
  export function AssessmentEvidenceQualification({
85
108
  resolution,
86
109
  onViewActivity,