@skyhook-io/radar-app 1.18.2 → 1.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/README.md +1 -1
  2. package/package.json +7 -7
  3. package/src/App.tsx +31 -6
  4. package/src/api/application-evidence.ts +63 -0
  5. package/src/api/argoSync.test.ts +22 -0
  6. package/src/api/client.audit-gating.test.tsx +48 -0
  7. package/src/api/client.kueuePosition.test.ts +32 -0
  8. package/src/api/client.kueueQueueWorkloads.test.tsx +71 -0
  9. package/src/api/client.resource-identity.test.ts +3 -0
  10. package/src/api/client.resourceIssues.test.tsx +239 -0
  11. package/src/api/client.resourcePath.test.ts +3 -0
  12. package/src/api/client.ts +285 -55
  13. package/src/api/config.ts +21 -0
  14. package/src/api/diagnose.test.ts +33 -2
  15. package/src/api/diagnose.ts +97 -3
  16. package/src/api/radarFeatures.render.test.tsx +33 -1
  17. package/src/api/radarFeatures.test.ts +47 -0
  18. package/src/api/radarFeatures.ts +41 -1
  19. package/src/api/rbac.settled.test.tsx +42 -0
  20. package/src/api/rbac.test.ts +18 -0
  21. package/src/api/rbac.ts +37 -7
  22. package/src/api/traffic.ts +9 -4
  23. package/src/api/usage-data.fixtures.ts +3 -1
  24. package/src/api/usage-data.test.tsx +134 -0
  25. package/src/api/usage-data.ts +35 -7
  26. package/src/api/workloadPodsPolling.test.ts +26 -0
  27. package/src/components/CloudConnectFlow.test.tsx +86 -0
  28. package/src/components/CloudConnectFlow.tsx +65 -27
  29. package/src/components/CloudFunnelButton.test.tsx +140 -5
  30. package/src/components/CloudFunnelButton.tsx +50 -9
  31. package/src/components/ConnectionErrorView.test.tsx +34 -0
  32. package/src/components/ConnectionErrorView.tsx +35 -11
  33. package/src/components/ContextSwitcher.tsx +5 -2
  34. package/src/components/SwitchAwareConnectionError.test.tsx +43 -0
  35. package/src/components/SwitchAwareConnectionError.tsx +85 -0
  36. package/src/components/application-evidence/ApplicationEvidenceAction.flow.test.tsx +234 -0
  37. package/src/components/application-evidence/ApplicationEvidenceAction.test.tsx +144 -0
  38. package/src/components/application-evidence/ApplicationEvidenceAction.tsx +218 -0
  39. package/src/components/capacity/CapacityDemand.tsx +3 -2
  40. package/src/components/capacity/demandSummary.test.ts +38 -0
  41. package/src/components/capacity/shared.tsx +12 -1
  42. package/src/components/cost/ApplicationCostTab.tsx +4 -0
  43. package/src/components/cost/CostTrendChart.tsx +2 -0
  44. package/src/components/cost/WorkloadCostTab.tsx +4 -0
  45. package/src/components/cost/source.test.ts +5 -0
  46. package/src/components/cost/source.ts +11 -0
  47. package/src/components/diagnose/AIMarkdown.tsx +4 -1
  48. package/src/components/diagnose/ActivityTurn.tsx +34 -14
  49. package/src/components/diagnose/AgentControls.tsx +53 -6
  50. package/src/components/diagnose/AgentSetupNotice.test.tsx +17 -0
  51. package/src/components/diagnose/AgentSetupNotice.tsx +22 -4
  52. package/src/components/diagnose/AgentSigninNotice.test.tsx +98 -0
  53. package/src/components/diagnose/AgentSigninNotice.tsx +61 -0
  54. package/src/components/diagnose/AnalysisStory.test.tsx +22 -0
  55. package/src/components/diagnose/AnalysisStory.tsx +17 -4
  56. package/src/components/diagnose/AssessmentCard.tsx +39 -8
  57. package/src/components/diagnose/ContinueInAgentButton.mounted.test.tsx +182 -0
  58. package/src/components/diagnose/ContinueInAgentButton.test.tsx +128 -0
  59. package/src/components/diagnose/ContinueInAgentButton.tsx +303 -0
  60. package/src/components/diagnose/DiagnoseContext.capacity.test.tsx +113 -0
  61. package/src/components/diagnose/DiagnoseContext.question.test.tsx +245 -0
  62. package/src/components/diagnose/DiagnoseContext.tsx +272 -10
  63. package/src/components/diagnose/DiagnoseSurface.test.tsx +54 -0
  64. package/src/components/diagnose/DiagnoseSurface.tsx +151 -134
  65. package/src/components/diagnose/EvidenceCard.tsx +67 -14
  66. package/src/components/diagnose/ExampleInvestigationLink.tsx +20 -0
  67. package/src/components/diagnose/Home.test.tsx +208 -5
  68. package/src/components/diagnose/Home.tsx +187 -36
  69. package/src/components/diagnose/InvestigationCapacityNotice.test.tsx +246 -0
  70. package/src/components/diagnose/InvestigationCapacityNotice.tsx +241 -0
  71. package/src/components/diagnose/InvestigationEvidencePane.story.test.tsx +97 -6
  72. package/src/components/diagnose/InvestigationEvidencePane.test.tsx +57 -0
  73. package/src/components/diagnose/InvestigationEvidencePane.tsx +59 -11
  74. package/src/components/diagnose/InvestigationEvidenceSections.tsx +50 -23
  75. package/src/components/diagnose/InvestigationView.tsx +249 -54
  76. package/src/components/diagnose/LocalDiagnoseAction.history.test.tsx +450 -0
  77. package/src/components/diagnose/LocalDiagnoseAction.tsx +365 -39
  78. package/src/components/diagnose/NextStepJump.test.tsx +92 -0
  79. package/src/components/diagnose/NextStepJump.tsx +75 -0
  80. package/src/components/diagnose/QuestionComposer.test.tsx +553 -0
  81. package/src/components/diagnose/QuestionComposer.tsx +495 -0
  82. package/src/components/diagnose/QuestionFocus.test.tsx +38 -0
  83. package/src/components/diagnose/QuestionFocus.tsx +123 -0
  84. package/src/components/diagnose/ResourcePicker.tsx +206 -0
  85. package/src/components/diagnose/StoryExcerpt.tsx +12 -3
  86. package/src/components/diagnose/assessmentCopy.ts +5 -0
  87. package/src/components/diagnose/exampleInvestigation.events.json +191 -0
  88. package/src/components/diagnose/exampleInvestigation.loadFailure.test.tsx +94 -0
  89. package/src/components/diagnose/exampleInvestigation.test.tsx +248 -0
  90. package/src/components/diagnose/exampleInvestigation.ts +121 -0
  91. package/src/components/diagnose/investigationCase.runs.test.tsx +328 -0
  92. package/src/components/diagnose/investigationCase.test.tsx +9 -1
  93. package/src/components/diagnose/investigationCase.ts +33 -1
  94. package/src/components/diagnose/investigationEvidence/adapters/applicationFindings.test.ts +739 -0
  95. package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +46 -0
  96. package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +58 -2
  97. package/src/components/diagnose/investigationEvidence/adapters/issues.ts +9 -0
  98. package/src/components/diagnose/investigationEvidence/adapters/posture.ts +29 -1
  99. package/src/components/diagnose/investigationEvidence/adapters/prometheus.test.ts +40 -0
  100. package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +27 -1
  101. package/src/components/diagnose/investigationEvidence/bodies/metrics.test.tsx +111 -0
  102. package/src/components/diagnose/investigationEvidence/bodies/metrics.tsx +67 -16
  103. package/src/components/diagnose/investigationEvidence/builder.ts +30 -0
  104. package/src/components/diagnose/investigationEvidence/excerpt.test.ts +18 -5
  105. package/src/components/diagnose/investigationEvidence/excerpt.ts +22 -11
  106. package/src/components/diagnose/investigationEvidence/index.ts +1 -1
  107. package/src/components/diagnose/investigationEvidence/navigation.tsx +2 -0
  108. package/src/components/diagnose/investigationEvidence/observations.ts +121 -2
  109. package/src/components/diagnose/investigationEvidence/projection.test.ts +85 -3
  110. package/src/components/diagnose/investigationEvidence/types.ts +7 -0
  111. package/src/components/diagnose/investigationEvidencePartition.ts +6 -1
  112. package/src/components/diagnose/investigationFocus.test.ts +271 -0
  113. package/src/components/diagnose/investigationFocus.ts +132 -0
  114. package/src/components/diagnose/investigationState.ts +28 -0
  115. package/src/components/diagnose/lastInvestigation.test.ts +95 -0
  116. package/src/components/diagnose/lastInvestigation.ts +58 -0
  117. package/src/components/diagnose/launch.test.ts +125 -1
  118. package/src/components/diagnose/launch.ts +57 -10
  119. package/src/components/diagnose/parts.test.tsx +20 -0
  120. package/src/components/diagnose/questionSuggestions.test.ts +111 -0
  121. package/src/components/diagnose/questionSuggestions.ts +150 -0
  122. package/src/components/diagnose/storyParts.test.tsx +13 -0
  123. package/src/components/diagnose/target.test.ts +143 -2
  124. package/src/components/diagnose/target.ts +109 -7
  125. package/src/components/diagnose/testdata/story-runs.json +474 -0
  126. package/src/components/diagnose/toolCallLabel.test.ts +10 -4
  127. package/src/components/diagnose/verdictText.test.tsx +87 -0
  128. package/src/components/diagnose/verdictText.ts +68 -0
  129. package/src/components/execution/BatchExecutionView.tsx +24 -11
  130. package/src/components/execution/JobSetAdmission.test.tsx +42 -0
  131. package/src/components/execution/JobSetAdmission.tsx +18 -3
  132. package/src/components/execution/JobSetMemberComparison.tsx +2 -1
  133. package/src/components/execution/runState.test.ts +14 -0
  134. package/src/components/execution/runState.ts +8 -0
  135. package/src/components/gitops/GitOpsView.rollbackGate.test.tsx +202 -0
  136. package/src/components/gitops/GitOpsView.syncRequest.test.tsx +369 -0
  137. package/src/components/gitops/GitOpsView.tsx +86 -17
  138. package/src/components/gitops/RemoteDestinationCloudHint.tsx +2 -3
  139. package/src/components/gitops/destination-toast.test.ts +1 -1
  140. package/src/components/gitops/destination-toast.ts +2 -2
  141. package/src/components/home/ClusterHealthCard.tsx +13 -39
  142. package/src/components/home/HomeAgentBlock.test.tsx +141 -0
  143. package/src/components/home/HomeAgentBlock.tsx +103 -0
  144. package/src/components/home/HomeDiagramCard.tsx +47 -0
  145. package/src/components/home/HomeView.tsx +86 -47
  146. package/src/components/home/MCPSetupDialog.test.tsx +95 -5
  147. package/src/components/home/MCPSetupDialog.tsx +30 -5
  148. package/src/components/home/ProblemsPanel.investigate.test.tsx +171 -0
  149. package/src/components/home/ProblemsPanel.test.tsx +3 -1
  150. package/src/components/home/RadarVersionLine.test.tsx +0 -14
  151. package/src/components/home/RadarVersionLine.tsx +3 -28
  152. package/src/components/home/TopologyPreview.test.tsx +73 -0
  153. package/src/components/home/TopologyPreview.tsx +120 -233
  154. package/src/components/home/TrafficSummary.test.tsx +63 -0
  155. package/src/components/home/TrafficSummary.tsx +135 -138
  156. package/src/components/home/mcpToolCatalog.ts +23 -10
  157. package/src/components/issues/IssuesPane.test.ts +11 -0
  158. package/src/components/issues/IssuesPane.tsx +15 -5
  159. package/src/components/issues/uncheckedSources.test.ts +20 -1
  160. package/src/components/issues/uncheckedSources.ts +18 -0
  161. package/src/components/kueue/KueuePendingPosition.tsx +35 -0
  162. package/src/components/kueue/useRelatedObjects.test.tsx +219 -0
  163. package/src/components/kueue/useRelatedReads.test.ts +56 -0
  164. package/src/components/kueue/useRelatedReads.ts +205 -0
  165. package/src/components/logs/MultiPodLogsTab.test.tsx +93 -0
  166. package/src/components/logs/MultiPodLogsTab.tsx +120 -0
  167. package/src/components/logs/PodLogsUnavailable.test.tsx +18 -0
  168. package/src/components/logs/PodLogsUnavailable.tsx +21 -0
  169. package/src/components/logs/RayClusterLogsTab.reselect.test.tsx +67 -0
  170. package/src/components/logs/RayClusterLogsTab.test.tsx +167 -0
  171. package/src/components/logs/RayClusterLogsTab.tsx +109 -0
  172. package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +3 -2
  173. package/src/components/logs/rayClusterPods.ts +32 -0
  174. package/src/components/outageSince.test.ts +21 -0
  175. package/src/components/outageSince.ts +10 -0
  176. package/src/components/resource/PrometheusCharts.overlays.test.ts +12 -0
  177. package/src/components/resource/PrometheusCharts.tsx +3 -40
  178. package/src/components/resources/crd/CRDSchemaTab.test.tsx +28 -0
  179. package/src/components/resources/crd/CRDSchemaTab.tsx +13 -0
  180. package/src/components/resources/crd/host.tsx +14 -0
  181. package/src/components/resources/renderers/CustomResourceDefinitionRenderer.test.tsx +27 -0
  182. package/src/components/resources/renderers/CustomResourceDefinitionRenderer.tsx +12 -0
  183. package/src/components/resources/renderers/JobAdmissionRenderers.test.tsx +4 -1
  184. package/src/components/resources/renderers/JobAdmissionRenderers.tsx +4 -3
  185. package/src/components/resources/renderers/KueueHostRenderers.test.tsx +117 -0
  186. package/src/components/resources/renderers/KueueQueueRenderers.test.tsx +97 -0
  187. package/src/components/resources/renderers/KueueQueueRenderers.tsx +139 -0
  188. package/src/components/resources/renderers/KueueWorkloadRenderer.test.tsx +7 -1
  189. package/src/components/resources/renderers/KueueWorkloadRenderer.tsx +47 -7
  190. package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.test.tsx +67 -0
  191. package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.tsx +31 -0
  192. package/src/components/resources/renderers/RayClusterRenderer.test.tsx +81 -3
  193. package/src/components/resources/renderers/RayClusterRenderer.tsx +19 -4
  194. package/src/components/traffic/TrafficView.tsx +3 -3
  195. package/src/components/ui/Omnibar.investigate.test.tsx +105 -0
  196. package/src/components/ui/Omnibar.tsx +47 -3
  197. package/src/components/ui/RadarOmnibar.test.tsx +1 -0
  198. package/src/components/ui/RadarOmnibar.tsx +11 -0
  199. package/src/components/ui/command-items-crd.test.tsx +23 -0
  200. package/src/components/ui/command-items.ts +2 -1
  201. package/src/components/useContextSwitchFlow.test.tsx +61 -0
  202. package/src/components/useContextSwitchFlow.tsx +21 -4
  203. package/src/components/whats-new/WhatsNew.test.ts +10 -3
  204. package/src/components/whats-new/WhatsNew.tsx +5 -1
  205. package/src/components/whats-new/WhatsNewDialog.test.tsx +18 -4
  206. package/src/components/whats-new/releaseNotes.ts +136 -4
  207. package/src/components/workload/RelatedFindingsSection.test.tsx +126 -0
  208. package/src/components/workload/RelatedFindingsSection.tsx +80 -0
  209. package/src/components/workload/WorkloadView.test.ts +10 -1
  210. package/src/components/workload/WorkloadView.tsx +85 -98
  211. package/src/components/workload/issueResourceOpener.test.ts +20 -0
  212. package/src/components/workload/issueResourceOpener.ts +17 -0
  213. package/src/context/ConnectionContext.tsx +133 -60
  214. package/src/context/ConnectionProvider.retry.test.tsx +176 -0
  215. package/src/context/ContextSwitchContext.tsx +14 -1
  216. package/src/context/DiagnoseCustomization.tsx +3 -0
  217. package/src/context/clusterConnected.ts +10 -0
  218. package/src/contexts/CapabilitiesContext.tsx +6 -4
  219. package/src/hooks/useAgentSignin.test.tsx +190 -0
  220. package/src/hooks/useAgentSignin.ts +160 -0
  221. package/src/hooks/useApproveAfterSignin.test.tsx +108 -0
  222. package/src/hooks/useElementSize.ts +30 -0
  223. package/src/integrations/resourceHost.test.tsx +1 -0
  224. package/src/integrations/resourceHost.ts +5 -1
  225. package/src/integrations/resourceHosts.test.tsx +21 -4
  226. package/src/integrations/resourceHosts.tsx +12 -0
  227. package/src/main.tsx +5 -0
  228. package/src/utils/related-findings.ts +46 -0
@@ -41,6 +41,7 @@ import {
41
41
  investigationPaneCenteredScrollTop,
42
42
  canStopInvestigation,
43
43
  canContinueInvestigation,
44
+ canContinueInOwnAgent,
44
45
  readOnlyNotice,
45
46
  canInvestigateFurther,
46
47
  } from "./investigationState";
@@ -87,6 +88,10 @@ import {
87
88
  type RunSummary,
88
89
  } from "../../api/diagnose";
89
90
  import { useDiagnose } from "./DiagnoseContext";
91
+ import {
92
+ ExampleInvestigationProvider,
93
+ replayExampleInvestigation,
94
+ } from "./exampleInvestigation";
90
95
  import { InvestigationRefusalAction } from "./InvestigationRefusalAction";
91
96
  import {
92
97
  TurnView,
@@ -97,8 +102,8 @@ import {
97
102
  mergeStartupSignal,
98
103
  upsertTool,
99
104
  type Turn,
100
- remediationHeadline,
101
105
  } from "./parts";
106
+ import { NextStepJump, recommendedStepHeadline } from "./NextStepJump";
102
107
  import {
103
108
  investigationActivitySourceDomId,
104
109
  investigationEvidenceStepIdsByTurn,
@@ -113,10 +118,19 @@ import {
113
118
  } from "./InvestigationEvidencePane";
114
119
  import { partitionInvestigationEvidence } from "./investigationEvidencePartition";
115
120
  import type { DiagnosisResourceRef } from "./diagnoseEvidenceTypes";
116
- import { formatInvestigationTarget } from "./target";
121
+ import { QuestionFocus } from "./QuestionFocus";
122
+ import { focusFromCase } from "./investigationFocus";
123
+ import {
124
+ formatInvestigationTarget,
125
+ formatInvestigationTitle,
126
+ isQuestionOnly,
127
+ questionAskedAt,
128
+ rerunOpening,
129
+ } from "./target";
117
130
  import { parseContextName } from "../../utils/context-name";
118
131
  import type { InvestigationSourceExcerpt } from "./investigationSourceFocus";
119
132
  import { diagnosisHasStoryShape } from "./investigationStory";
133
+ import { assessmentStateLabel, verdictSentence } from "./verdictText";
120
134
  import { assessmentLimitLines } from "./investigationEvidencePresentation";
121
135
 
122
136
  const RECHECK_QUESTION =
@@ -272,6 +286,47 @@ function captureEvidenceCardLayout(container: HTMLElement) {
272
286
 
273
287
  const APPLY_WRITES: GitOpsWrite[] = [{ scope: "spec", description: "The proposed change" }];
274
288
 
289
+ // The card that ends a finished turn in Activity says what was found, so the
290
+ // reader learns the answer before deciding to open Findings. It carries the
291
+ // same qualifications Findings puts beside the sentence (how sure, whether an
292
+ // apply or newer reads have overtaken it), so it never reads more settled
293
+ // than Findings does. A long verdict is cut at three lines; one with no
294
+ // sentence keeps the generic description.
295
+ function CompletionSummary({
296
+ label,
297
+ state,
298
+ sentence,
299
+ }: {
300
+ label: string;
301
+ state?: { text: string; warn: boolean };
302
+ sentence: string;
303
+ }) {
304
+ return (
305
+ <span className="min-w-0 flex-1">
306
+ <span className="block text-xs text-theme-text-tertiary">
307
+ {label}
308
+ {state ? (
309
+ <>
310
+ {" · "}
311
+ <span className={state.warn ? "text-warning-text" : undefined}>
312
+ {state.text}
313
+ </span>
314
+ </>
315
+ ) : null}
316
+ </span>
317
+ {sentence ? (
318
+ <span className="mt-0.5 line-clamp-3 text-sm font-medium leading-snug text-theme-text-primary [overflow-wrap:anywhere]">
319
+ {sentence}
320
+ </span>
321
+ ) : (
322
+ <span className="block text-xs text-theme-text-secondary">
323
+ Assessment, evidence and next steps
324
+ </span>
325
+ )}
326
+ </span>
327
+ );
328
+ }
329
+
275
330
  export function InvestigationView({
276
331
  run,
277
332
  agentLabel,
@@ -279,21 +334,32 @@ export function InvestigationView({
279
334
  onOpenResource,
280
335
  onOpenTimeline,
281
336
  onRevealDestination,
337
+ example = false,
338
+ onCloseExample,
339
+ onHandoffAllowedChange,
282
340
  }: {
283
341
  run: RunSummary;
284
342
  agentLabel: string;
285
343
  maximized: boolean;
344
+ /** The bundled example: replayed from the bundle, with nothing that acts
345
+ * on it or sends it anywhere. */
346
+ example?: boolean;
347
+ onCloseExample?: () => void;
286
348
  /** Opens an unambiguous evidence subject in Radar's native resource views. */
287
349
  onOpenResource?: (ref: DiagnosisResourceRef) => void;
288
350
  /** Opens Radar's Timeline filtered to the resource a changes card is about. */
289
351
  onOpenTimeline?: (scope: InvestigationTimelineScope) => void;
290
352
  /** Makes a page this view navigates to visible: restores or closes the panel. */
291
353
  onRevealDestination?: () => void;
354
+ /** Whether nothing is writing to the agent's session, so the header may
355
+ * offer to continue it in the user's own agent. */
356
+ onHandoffAllowedChange?: (allowed: boolean) => void;
292
357
  }) {
293
358
  const { kind, namespace, name } = run;
294
359
  const {
295
360
  refreshRuns,
296
361
  openInvestigation,
362
+ openQuestion,
297
363
  startError,
298
364
  startRefusal,
299
365
  dismissError,
@@ -302,26 +368,18 @@ export function InvestigationView({
302
368
  // Capabilities are the declared ones of the agent that ran this run, not
303
369
  // the picker's: a reopened run keeps the backend it was made with.
304
370
  const runAgent = agents.find((agent) => agent.name === run.agent);
305
- const explanationEnabled = supportsAssessmentExplanation(runAgent);
306
- const canApply = runAgent?.apply === true;
371
+ const explanationEnabled =
372
+ !example && supportsAssessmentExplanation(runAgent);
373
+ // A question-only run has no resource to bind a confirmed fix to.
374
+ const canApply =
375
+ !example && runAgent?.apply === true && !isQuestionOnly(run);
307
376
  // Read through a ref by the stream callback, which lives as long as the
308
377
  // run and would otherwise keep the value from before the agents loaded.
309
378
  const verifiesAfterApplyRef = useRef(false);
310
379
  verifiesAfterApplyRef.current = runAgent?.verification === true;
311
- // Investigate again means look again, so it asks for a new session explicitly and only
312
- // carries the issue forward — being handed the previous answer is the one
313
- // thing someone clicking this doesn't want.
314
380
  const retryDiagnosis = useCallback(
315
- () =>
316
- openInvestigation({
317
- kind,
318
- group: run.group,
319
- namespace,
320
- name,
321
- issueId: run.issueId,
322
- fresh: true,
323
- }),
324
- [openInvestigation, kind, namespace, name, run.group, run.issueId],
381
+ () => openInvestigation(rerunOpening(run)),
382
+ [openInvestigation, run],
325
383
  );
326
384
  const queryClient = useQueryClient();
327
385
  const [turns, setTurns] = useState<Turn[]>([]);
@@ -575,7 +633,11 @@ export function InvestigationView({
575
633
  activityRevealRequestIdRef.current = 0;
576
634
  evidenceCardLayoutRef.current.clear();
577
635
  evidenceProjectionTurnsRef.current = [];
578
- const cancel = subscribeRun(run.id, {
636
+ const subscribe = example
637
+ ? (_id: string, handlers: Parameters<typeof subscribeRun>[1]) =>
638
+ replayExampleInvestigation(handlers)
639
+ : subscribeRun;
640
+ const cancel = subscribe(run.id, {
579
641
  onEvent: (ev: DiagnoseStreamEvent, sequence?: number) => {
580
642
  const live = replayCompleteRef.current;
581
643
  switch (ev.type) {
@@ -1181,11 +1243,24 @@ export function InvestigationView({
1181
1243
  : undefined,
1182
1244
  [currentAssessment, currentAssessmentIdx, projection],
1183
1245
  );
1246
+ const questionOnly = isQuestionOnly(run);
1247
+ const questionFocus = useMemo(
1248
+ () => (questionOnly ? focusFromCase(investigationCase) : []),
1249
+ [questionOnly, investigationCase],
1250
+ );
1184
1251
  // Findings is the newest assessment and nothing else: its own citations,
1185
1252
  // its own case, its own story. Earlier assessments stay complete in
1186
1253
  // Activity; answers that did not revise the assessment stay there too.
1187
1254
  const paneResolution = rootCauseEvidenceResolution;
1188
1255
  const storyShape = diagnosisHasStoryShape(currentAssessment?.diagnosis);
1256
+ // A run that stopped without an assessment will never cite anything, so
1257
+ // what it collected is all there is to show.
1258
+ const assessmentPending = !currentAssessment?.diagnosis;
1259
+ const showUncited =
1260
+ assessmentPending &&
1261
+ !busy &&
1262
+ run.status !== "running" &&
1263
+ run.status !== "stopping";
1189
1264
  const visibleEvidenceGroupIds = useMemo(
1190
1265
  () =>
1191
1266
  new Set(
@@ -1194,9 +1269,16 @@ export function InvestigationView({
1194
1269
  paneResolution,
1195
1270
  investigationCase,
1196
1271
  storyShape,
1272
+ showUncited,
1197
1273
  ).collectionByGroup.keys(),
1198
1274
  ),
1199
- [projection.groups, paneResolution, investigationCase, storyShape],
1275
+ [
1276
+ projection.groups,
1277
+ paneResolution,
1278
+ investigationCase,
1279
+ storyShape,
1280
+ showUncited,
1281
+ ],
1200
1282
  );
1201
1283
  const evidenceStepIdsByTurn = useMemo(
1202
1284
  () =>
@@ -1593,20 +1675,31 @@ export function InvestigationView({
1593
1675
  currentAssessment?.diagnosis &&
1594
1676
  (currentAssessment.diagnosis.remediation?.length ?? 0) > 0,
1595
1677
  );
1678
+ const handoffAllowed =
1679
+ !example &&
1680
+ canContinueInOwnAgent({
1681
+ run,
1682
+ busy,
1683
+ requestPending,
1684
+ gone,
1685
+ streamReady,
1686
+ verificationPending,
1687
+ latestTurnStatus: lastTurn?.status,
1688
+ });
1689
+ useEffect(() => {
1690
+ onHandoffAllowedChange?.(handoffAllowed);
1691
+ }, [handoffAllowed, onHandoffAllowedChange]);
1692
+ useEffect(
1693
+ () => () => onHandoffAllowedChange?.(false),
1694
+ [onHandoffAllowedChange],
1695
+ );
1596
1696
  const earlierPlan =
1597
1697
  assessmentNeedsCurrentStateVerification ||
1598
1698
  hasEvidenceCollectedAfterAssessment;
1599
1699
  // The jump link names the decision it leads to, not the section.
1600
- const nextStepLabel = (() => {
1601
- const dx = currentAssessment?.diagnosis;
1602
- if (!dx) return "Next steps ↓";
1603
- const index = dx.recommendedIndex ? dx.recommendedIndex - 1 : 0;
1604
- const text =
1605
- dx.steps?.[index]?.text ?? dx.remediation?.[index] ?? dx.remediation?.[0];
1606
- if (!text) return "Next steps ↓";
1607
- const headline = remediationHeadline(text);
1608
- return `Next: ${headline.length > 56 ? `${headline.slice(0, 56).trimEnd()}…` : headline} ↓`;
1609
- })();
1700
+ const nextStepHeadline = recommendedStepHeadline(
1701
+ currentAssessment?.diagnosis,
1702
+ );
1610
1703
  // What a reader in a channel needs with the verdict: where, when, and the
1611
1704
  // receipts behind it, cause first, at most three.
1612
1705
  const assessmentCopy = useMemo(() => {
@@ -1616,7 +1709,8 @@ export function InvestigationView({
1616
1709
  .slice(0, 3);
1617
1710
  return {
1618
1711
  context: {
1619
- target: formatInvestigationTarget(run),
1712
+ target: formatInvestigationTitle(run),
1713
+ asked: isQuestionOnly(run) ? undefined : run.question,
1620
1714
  cluster: run.context,
1621
1715
  startedAt: run.createdAt,
1622
1716
  agent: agentLabel,
@@ -1739,7 +1833,7 @@ export function InvestigationView({
1739
1833
  setEvidenceUpdateAvailable(false);
1740
1834
  };
1741
1835
 
1742
- const composer = !unavailable ? (
1836
+ const composer = example ? null : !unavailable ? (
1743
1837
  <div className="shrink-0 border-t border-theme-border px-3 py-2.5">
1744
1838
  {canStop ? (
1745
1839
  <button
@@ -1861,7 +1955,9 @@ export function InvestigationView({
1861
1955
  ? assessmentNeedsCurrentStateVerification
1862
1956
  ? "Proposed before the apply attempt. Current state has not been verified."
1863
1957
  : "Proposed before the latest evidence. Reassess before applying."
1864
- : undefined
1958
+ : questionOnly
1959
+ ? "To apply a fix, investigate the resource it changes from Focused on above."
1960
+ : undefined
1865
1961
  }
1866
1962
  onApply={
1867
1963
  canOfferInvestigationApply({
@@ -1883,10 +1979,34 @@ export function InvestigationView({
1883
1979
  ) : undefined;
1884
1980
 
1885
1981
  return (
1982
+ <ExampleInvestigationProvider value={example}>
1886
1983
  <div
1887
1984
  data-investigation-view
1888
1985
  className={`@container/investigation relative flex min-h-0 flex-1 flex-col bg-theme-surface ${maximized ? "investigation-split-enabled" : ""}`}
1889
1986
  >
1987
+ {example ? (
1988
+ <div
1989
+ data-investigation-example
1990
+ className="flex items-center gap-2 border-b border-theme-border bg-theme-elevated px-3 py-2 text-xs text-theme-text-secondary"
1991
+ >
1992
+ <Badge severity="info" size="sm">
1993
+ Example
1994
+ </Badge>
1995
+ <span className="min-w-0 flex-1">
1996
+ A sample investigation from a test cluster, not from yours. It is
1997
+ read-only.
1998
+ </span>
1999
+ {onCloseExample ? (
2000
+ <button
2001
+ type="button"
2002
+ onClick={onCloseExample}
2003
+ className="shrink-0 rounded-md border border-theme-border px-2 py-1 font-medium text-theme-text-primary hover:bg-theme-hover"
2004
+ >
2005
+ Close example
2006
+ </button>
2007
+ ) : null}
2008
+ </div>
2009
+ ) : null}
1890
2010
  {stale ? (
1891
2011
  <div className="flex items-center gap-2 border-b border-amber-500/35 bg-amber-500/10 px-3 py-2 text-xs text-theme-text-secondary">
1892
2012
  <AlertTriangle className="h-4 w-4 shrink-0 text-amber-500" />
@@ -1900,7 +2020,17 @@ export function InvestigationView({
1900
2020
  </span>
1901
2021
  </div>
1902
2022
  ) : null}
1903
- {!stale && gone ? (
2023
+ {example && gone ? (
2024
+ <div
2025
+ role="alert"
2026
+ className="flex items-center gap-2 border-b border-theme-border bg-theme-elevated px-3 py-2 text-xs text-theme-text-secondary"
2027
+ >
2028
+ <AlertTriangle className="h-4 w-4 shrink-0 text-amber-500" />
2029
+ <span className="min-w-0 flex-1">
2030
+ Radar couldn&apos;t load the example. Close it and open it again.
2031
+ </span>
2032
+ </div>
2033
+ ) : !stale && gone ? (
1904
2034
  <div className="flex items-center gap-2 border-b border-theme-border bg-theme-elevated px-3 py-2 text-xs text-theme-text-secondary">
1905
2035
  <AlertTriangle className="h-4 w-4 shrink-0 text-amber-500" />
1906
2036
  <span className="min-w-0 flex-1">
@@ -1918,7 +2048,7 @@ export function InvestigationView({
1918
2048
  </button>
1919
2049
  </div>
1920
2050
  ) : null}
1921
- {!stale && !gone && endedEarly ? (
2051
+ {!example && !stale && !gone && endedEarly ? (
1922
2052
  <div
1923
2053
  role="status"
1924
2054
  className="flex items-center gap-2 border-b border-theme-border bg-theme-elevated px-3 py-2 text-xs text-theme-text-secondary"
@@ -2117,6 +2247,11 @@ export function InvestigationView({
2117
2247
  turn={turn}
2118
2248
  agentLabel={agentLabel}
2119
2249
  turnIndex={index}
2250
+ openingQuestion={
2251
+ index === 0 && !turn.question
2252
+ ? run.question
2253
+ : undefined
2254
+ }
2120
2255
  evidenceStepIds={evidenceStepIdsByTurn.get(index)}
2121
2256
  onViewEvidence={viewEvidenceSource}
2122
2257
  sourceRevealRequest={activityRevealRequest}
@@ -2135,7 +2270,8 @@ export function InvestigationView({
2135
2270
  turn.status === "error" &&
2136
2271
  !turn.question &&
2137
2272
  !turn.apply &&
2138
- !stale
2273
+ !stale &&
2274
+ !example
2139
2275
  ? retryDiagnosis
2140
2276
  : undefined
2141
2277
  }
@@ -2227,16 +2363,35 @@ export function InvestigationView({
2227
2363
  <Files className="h-4 w-4" />
2228
2364
  )}
2229
2365
  </span>
2230
- <span className="min-w-0 flex-1">
2231
- <span className="block text-xs font-semibold text-theme-text-primary">
2232
- {turn.verify
2233
- ? "Verification complete"
2234
- : "Assessment ready"}
2235
- </span>
2236
- <span className="block text-[11px] text-theme-text-tertiary">
2237
- Assessment, evidence and next steps
2238
- </span>
2239
- </span>
2366
+ <CompletionSummary
2367
+ label={
2368
+ assessmentNeedsCurrentStateVerification
2369
+ ? "Assessment before apply"
2370
+ : hasEvidenceCollectedAfterAssessment
2371
+ ? "Earlier assessment"
2372
+ : turn.verify
2373
+ ? "Verification complete"
2374
+ : "Assessment ready"
2375
+ }
2376
+ state={
2377
+ assessmentNeedsCurrentStateVerification
2378
+ ? {
2379
+ text: "Current state unverified",
2380
+ warn: true,
2381
+ }
2382
+ : turn.diagnosis
2383
+ ? assessmentStateLabel(
2384
+ turn.diagnosis,
2385
+ currentAssessmentEvidenceConflict,
2386
+ )
2387
+ : undefined
2388
+ }
2389
+ sentence={
2390
+ turn.diagnosis
2391
+ ? verdictSentence(turn.diagnosis)
2392
+ : ""
2393
+ }
2394
+ />
2240
2395
  <span className="inline-flex shrink-0 items-center gap-1 text-xs font-medium text-accent-text">
2241
2396
  View Findings
2242
2397
  <ArrowRight className="h-3.5 w-3.5 transition-transform group-hover:translate-x-0.5" />
@@ -2379,9 +2534,11 @@ export function InvestigationView({
2379
2534
  className="investigation-assessment rounded-xl border p-3"
2380
2535
  >
2381
2536
  <div className="flex flex-wrap items-center gap-1.5">
2537
+ {/* A label for the block, not its headline: the
2538
+ verdict sentence below is what a reader looks for. */}
2382
2539
  <h2
2383
2540
  id={`${viewId}-assessment-heading`}
2384
- className="text-lg font-semibold text-theme-text-primary"
2541
+ className="text-sm font-medium text-theme-text-secondary"
2385
2542
  >
2386
2543
  {assessmentNeedsCurrentStateVerification
2387
2544
  ? "Assessment before apply"
@@ -2448,8 +2605,13 @@ export function InvestigationView({
2448
2605
  }
2449
2606
  assessmentAction={
2450
2607
  hasNextSteps ? (
2451
- <button
2452
- type="button"
2608
+ <NextStepJump
2609
+ label={
2610
+ earlierPlan
2611
+ ? "Earlier proposed steps"
2612
+ : undefined
2613
+ }
2614
+ headline={nextStepHeadline}
2453
2615
  onClick={() => {
2454
2616
  const section = nextStepsRef.current;
2455
2617
  const scroller = evidenceScrollRef.current;
@@ -2466,12 +2628,7 @@ export function InvestigationView({
2466
2628
  : "smooth",
2467
2629
  });
2468
2630
  }}
2469
- className="ml-auto rounded-md px-2 py-1 text-xs font-medium text-accent-text hover:bg-theme-hover"
2470
- >
2471
- {earlierPlan
2472
- ? "Earlier proposed steps ↓"
2473
- : nextStepLabel}
2474
- </button>
2631
+ />
2475
2632
  ) : null
2476
2633
  }
2477
2634
  explanation={explanationFor(currentAssessment)}
@@ -2536,6 +2693,40 @@ export function InvestigationView({
2536
2693
  ) : null}
2537
2694
  </section>
2538
2695
 
2696
+ {questionOnly && investigationCase ? (
2697
+ <QuestionFocus
2698
+ focus={questionFocus}
2699
+ stale={stale}
2700
+ onOpenResource={onOpenResource}
2701
+ // These start a new investigation, so a run that can
2702
+ // no longer take follow-ups doesn't block them.
2703
+ disabled={investigationInteractionsBlocked({
2704
+ streamReady,
2705
+ busy,
2706
+ requestPending,
2707
+ readOnly: false,
2708
+ verificationPending,
2709
+ })}
2710
+ onChooseResource={() =>
2711
+ openQuestion({
2712
+ text: run.question,
2713
+ namespaces: run.namespaces,
2714
+ lookBack: run.lookBack,
2715
+ askedAt: questionAskedAt(run),
2716
+ pickResource: true,
2717
+ })
2718
+ }
2719
+ onInvestigate={(resource) =>
2720
+ openInvestigation({
2721
+ ...resource,
2722
+ question: run.question,
2723
+ lookBack: run.lookBack,
2724
+ askedAt: questionAskedAt(run),
2725
+ })
2726
+ }
2727
+ />
2728
+ ) : null}
2729
+
2539
2730
  {hasMultipleAssessments ? (
2540
2731
  <button
2541
2732
  type="button"
@@ -2556,6 +2747,9 @@ export function InvestigationView({
2556
2747
 
2557
2748
  <InvestigationEvidencePane
2558
2749
  projection={projection}
2750
+ withoutTarget={questionOnly}
2751
+ assessmentPending={assessmentPending}
2752
+ showUncited={showUncited}
2559
2753
  rootCauseEvidence={paneResolution}
2560
2754
  investigationCase={investigationCase}
2561
2755
  story={
@@ -2622,5 +2816,6 @@ export function InvestigationView({
2622
2816
  confidence={turns[lastRemediationIdx]?.diagnosis?.confidence}
2623
2817
  />
2624
2818
  </div>
2819
+ </ExampleInvestigationProvider>
2625
2820
  );
2626
2821
  }