@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
@@ -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,
@@ -36,9 +36,11 @@ import {
36
36
  agentLabelFor,
37
37
  openDiagnoseSettings,
38
38
  type DiagnoseView,
39
+ type Target,
39
40
  } from "./DiagnoseContext";
40
41
  import { useDiagnoseCustomization } from "../../context/DiagnoseCustomization";
41
42
  import { InvestigationRefusalAction } from "./InvestigationRefusalAction";
43
+ import { InvestigationCapacityRecovery } from "./InvestigationCapacityNotice";
42
44
  import { useNavCustomization } from "../../context/NavCustomization";
43
45
  import { InvestigationView } from "./InvestigationView";
44
46
  import type { InvestigationTimelineScope } from "./InvestigationEvidencePane";
@@ -49,13 +51,28 @@ import {
49
51
  statusWord,
50
52
  } from "./Home";
51
53
  import { AgentSetupNotice } from "./AgentSetupNotice";
54
+ import {
55
+ EXAMPLE_INVESTIGATION_ID,
56
+ EXAMPLE_INVESTIGATION_RUN,
57
+ exampleInvestigationOffered,
58
+ isExampleInvestigation,
59
+ } from "./exampleInvestigation";
60
+ import { AgentSigninNotice } from "./AgentSigninNotice";
61
+ import {
62
+ useAgentSignin,
63
+ useApproveAfterSignin,
64
+ } from "../../hooks/useAgentSignin";
52
65
  import { ConsentCard } from "./parts";
53
- import { buildLaunchCommand, launchAgentLabel, openInTerminal } from "./launch";
66
+ import type { ConsentSubject } from "./AgentControls";
54
67
  import { type RunSummary, type ExecutionProfile } from "../../api/diagnose";
55
- import { mcpEndpointUrl } from "../../api/config";
56
- import { useCapabilitiesContext } from "../../contexts/CapabilitiesContext";
57
68
  import { useContexts } from "../../api/client";
58
- import { formatInvestigationTarget } from "./target";
69
+ import {
70
+ formatInvestigationTarget,
71
+ formatInvestigationTitle,
72
+ formatQuestionScope,
73
+ isQuestionOnly,
74
+ rerunOpening,
75
+ } from "./target";
59
76
  import type { DiagnosisResourceRef } from "./diagnoseEvidenceTypes";
60
77
 
61
78
  function capWord(s: string): string {
@@ -85,107 +102,6 @@ function buildConfigLine(cfg: {
85
102
  return "via " + parts.join(" · ");
86
103
  }
87
104
 
88
- // InvestigationMenu hands an investigation off to the user's own full agent. The
89
- // PRIMARY action copies a resume command they can paste wherever they actually
90
- // work (terminal, tmux, IDE) — destination-agnostic. Running it in Radar's built-in
91
- // terminal is the secondary "run it here" convenience.
92
- function InvestigationMenu({ run }: { run: RunSummary }) {
93
- const [open, setOpen] = useState(false);
94
- const [copied, setCopied] = useState(false);
95
- const menuRef = useRef<HTMLDivElement>(null);
96
- const { localTerminal, mcpReadOnly } = useCapabilitiesContext();
97
- const label = launchAgentLabel(run);
98
- const command = buildLaunchCommand(
99
- run,
100
- mcpEndpointUrl(mcpReadOnly),
101
- );
102
-
103
- // The diagnose root is a CSS container, so a position:fixed click-away layer
104
- // inside it is panel-bound rather than viewport-bound. Dismiss from the
105
- // document instead; the anchored menu itself can stay next to its trigger.
106
- useEffect(() => {
107
- if (!open) return;
108
- const onPointerDown = (event: PointerEvent) => {
109
- if (!menuRef.current?.contains(event.target as Node)) setOpen(false);
110
- };
111
- const onKeyDown = (event: KeyboardEvent) => {
112
- if (event.key === "Escape") setOpen(false);
113
- };
114
- document.addEventListener("pointerdown", onPointerDown);
115
- document.addEventListener("keydown", onKeyDown);
116
- return () => {
117
- document.removeEventListener("pointerdown", onPointerDown);
118
- document.removeEventListener("keydown", onKeyDown);
119
- };
120
- }, [open]);
121
-
122
- // No resumable session yet (or stale run) → nothing to hand off.
123
- if (!command) return null;
124
- const toggle = () => {
125
- setCopied(false);
126
- setOpen((v) => !v);
127
- };
128
- const copy = () => {
129
- void navigator.clipboard?.writeText(command);
130
- setCopied(true);
131
- setTimeout(() => {
132
- setCopied(false);
133
- setOpen(false);
134
- }, 1100);
135
- };
136
-
137
- return (
138
- <div ref={menuRef} className="relative flex items-center">
139
- <Tooltip content="More" position="bottom">
140
- <button
141
- onClick={toggle}
142
- className="rounded-md p-1 text-theme-text-tertiary hover:bg-theme-hover hover:text-theme-text-primary"
143
- aria-label="More actions"
144
- aria-haspopup="menu"
145
- aria-expanded={open}
146
- >
147
- <MoreVertical className="h-4 w-4" />
148
- </button>
149
- </Tooltip>
150
- {open && (
151
- <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">
152
- <button
153
- onClick={copy}
154
- 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"
155
- >
156
- {copied ? (
157
- <Check className="mt-0.5 h-4 w-4 shrink-0 text-emerald-500" />
158
- ) : (
159
- <Copy className="mt-0.5 h-4 w-4 shrink-0 text-theme-text-tertiary" />
160
- )}
161
- <span>
162
- {copied ? "Copied ✓" : `Copy command to continue in ${label}`}
163
- {!copied && (
164
- <span className="block text-[11px] text-theme-text-tertiary">
165
- Paste it wherever you run {label} — resumes this exact
166
- session.
167
- </span>
168
- )}
169
- </span>
170
- </button>
171
- {localTerminal && (
172
- <button
173
- onClick={() => {
174
- openInTerminal(command, "Radar Investigation");
175
- setOpen(false);
176
- }}
177
- 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"
178
- >
179
- <TerminalSquare className="h-4 w-4 shrink-0 text-theme-text-tertiary" />
180
- Run in a Radar terminal
181
- </button>
182
- )}
183
- </div>
184
- )}
185
- </div>
186
- );
187
- }
188
-
189
105
  // The panel is an ABSOLUTE slot inside the app's body frame (the column under the
190
106
  // header, right of the nav rail) — App renders it there and passes topInset (the
191
107
  // header height; 0 in chromeless embeds). It shares that frame with the resource/
@@ -194,7 +110,7 @@ function InvestigationMenu({ run }: { run: RunSummary }) {
194
110
  // Every clause is a failure this button actually had:
195
111
  //
196
112
  // view Home is the fresh-entry surface, never a re-run action.
197
- // run nothing to take a resource from.
113
+ // run nothing to take a resource or question from.
198
114
  // running/stopping human starts reuse the live run. Automatic investigations
199
115
  // are immutable, so they retain a separate fresh human start.
200
116
  // stale the original session is closed after a cluster switch;
@@ -209,8 +125,7 @@ export function canRerunInvestigation(
209
125
  return (
210
126
  view === "investigation" &&
211
127
  !!run &&
212
- !!run.kind &&
213
- !!run.name &&
128
+ ((!!run.kind && !!run.name) || isQuestionOnly(run)) &&
214
129
  ((run.status !== "running" && run.status !== "stopping") ||
215
130
  run.trigger === "background") &&
216
131
  run.status !== "stale" &&
@@ -232,6 +147,25 @@ export const MAXIMIZED_RUN_META_VISIBILITY_CLASS =
232
147
  export const DIAGNOSE_SURFACE_FRAME_CLASS =
233
148
  "@container/diagnose-surface absolute z-40 flex min-h-0 flex-col overflow-hidden border-l border-theme-border bg-theme-surface shadow-drawer";
234
149
 
150
+ // The consent card names what it is about to investigate, so approving it is
151
+ // approving that run.
152
+ export function consentSubject(
153
+ target: Target | null,
154
+ ): ConsentSubject | undefined {
155
+ if (!target) return undefined;
156
+ if (isQuestionOnly(target)) {
157
+ return {
158
+ title: `“${formatInvestigationTitle(target)}”`,
159
+ detail: formatQuestionScope(target),
160
+ question: true,
161
+ };
162
+ }
163
+ return {
164
+ title: formatInvestigationTarget(target),
165
+ detail: target.question ? `Asked: ${target.question}` : undefined,
166
+ };
167
+ }
168
+
235
169
  export function unavailableInvestigationMessage(embedded: boolean): string {
236
170
  return embedded
237
171
  ? "This investigation is unavailable. It may be private, your access may have changed, or its history may have been cleared. Check your account and organization, or ask the creator for access."
@@ -381,6 +315,28 @@ export function DiagnoseSurface({
381
315
  onBrowseIssues?: () => void;
382
316
  }) {
383
317
  const d = useDiagnose();
318
+ // A hosted agent runs on the host's backend, where a local CLI's sign-in
319
+ // says nothing.
320
+ const signin = useAgentSignin(
321
+ d.selectedAgent,
322
+ d.profile,
323
+ d.needsConsent && !d.hosted,
324
+ );
325
+ const consentActions = useApproveAfterSignin({
326
+ approve: d.approveConsent,
327
+ cancel: d.cancelConsent,
328
+ signin,
329
+ attemptKey: `${d.selectedAgent}\u0000${d.profile}\u0000${d.needsConsent}`,
330
+ });
331
+ const signinNotice =
332
+ signin.status?.state === "signed-out" && signin.status.signinCmd ? (
333
+ <AgentSigninNotice
334
+ agentName={d.agentLabel}
335
+ signinCmd={signin.status.signinCmd}
336
+ rechecking={signin.rechecking}
337
+ onRecheck={signin.recheck}
338
+ />
339
+ ) : null;
384
340
  const { data: contexts } = useContexts();
385
341
  const currentContext = contexts?.find((context) => context.isCurrent)?.name;
386
342
  const [historyCollapsed, setHistoryCollapsed] = useState(false);
@@ -511,10 +467,26 @@ export function DiagnoseSurface({
511
467
  const setupPending =
512
468
  d.setupState === "needs-install" || d.setupState === "needs-restart";
513
469
 
514
- 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;
515
482
  // Consent replaces the detail pane even if goHome retained an older run id.
516
483
  // Header identity and actions must describe what is actually visible.
517
- const visibleRunDetail = d.needsConsent ? null : activeRun;
484
+ const visibleRunDetail =
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);
518
490
  // A focused run shows the agent it actually ran with; Home reflects the current pick.
519
491
  const activeAgentLabel = visibleRunDetail?.agent
520
492
  ? agentLabelFor(visibleRunDetail.agent)
@@ -530,7 +502,7 @@ export function DiagnoseSurface({
530
502
  visibleRunDetail ?? defaultHeaderConfig,
531
503
  );
532
504
  const focusedTitle = visibleRunDetail
533
- ? formatInvestigationTarget(visibleRunDetail)
505
+ ? formatInvestigationTitle(visibleRunDetail)
534
506
  : "AI investigations";
535
507
  const headerPresentation = investigationHeaderPresentation({
536
508
  view: d.view,
@@ -567,22 +539,37 @@ export function DiagnoseSurface({
567
539
  agent={d.selectedAgent}
568
540
  profile={d.profile}
569
541
  copy={consentCopy}
542
+ subject={consentSubject(d.pendingTarget)}
570
543
  onOpenSettings={openSettings ?? undefined}
571
544
  error={d.consentError}
572
- onApprove={d.approveConsent}
573
- onCancel={d.cancelConsent}
545
+ notice={signinNotice}
546
+ approveBusy={consentActions.waiting}
547
+ onApprove={consentActions.approve}
548
+ onCancel={consentActions.cancel}
574
549
  />
575
550
  </div>
576
551
  </div>
552
+ ) : d.startCapacity ? (
553
+ // Before the focused run: the start the user just asked for is what this
554
+ // pane is about, and a focused run's view would bury the way out.
555
+ <InvestigationCapacityRecovery capacity={d.startCapacity} />
577
556
  ) : activeRun ? (
578
557
  <InvestigationView
579
558
  key={activeRun.id}
580
559
  run={activeRun}
581
560
  agentLabel={activeAgentLabel}
582
561
  maximized={maximized}
583
- onOpenResource={onOpenResource ? openEvidenceResource : undefined}
584
- 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
+ }
585
569
  onRevealDestination={revealDestination}
570
+ example={exampleOpen}
571
+ onCloseExample={exampleOpen ? d.goHome : undefined}
572
+ onHandoffAllowedChange={setHandoffAllowed}
586
573
  />
587
574
  ) : d.activeRunId && !d.runsLoaded ? (
588
575
  // Deep-linked to a run before the list has ever loaded: show the load
@@ -613,6 +600,14 @@ export function DiagnoseSurface({
613
600
  <p className="text-sm text-theme-text-secondary">{d.startError}</p>
614
601
  <div className="flex flex-wrap items-center justify-center gap-2">
615
602
  <InvestigationRefusalAction refusal={d.startRefusal} />
603
+ {d.questionDraft?.text && (
604
+ <button
605
+ onClick={d.openHome}
606
+ className="rounded-lg border border-theme-border px-3 py-1.5 text-sm text-theme-text-secondary hover:bg-theme-hover"
607
+ >
608
+ Back to your question
609
+ </button>
610
+ )}
616
611
  <button
617
612
  onClick={d.dismissError}
618
613
  className="rounded-lg border border-theme-border px-3 py-1.5 text-sm text-theme-text-secondary hover:bg-theme-hover"
@@ -629,6 +624,7 @@ export function DiagnoseSurface({
629
624
  checkingAgents={d.checkingAgents}
630
625
  agentsCheckFailed={d.agentsCheckFailed}
631
626
  recheckAgents={d.recheckAgents}
627
+ onOpenExample={openExample}
632
628
  />
633
629
  </div>
634
630
  ) : (
@@ -643,10 +639,13 @@ export function DiagnoseSurface({
643
639
  agent={d.selectedAgent}
644
640
  profile={d.profile}
645
641
  copy={consentCopy}
642
+ subject={consentSubject(d.pendingTarget)}
646
643
  onOpenSettings={openSettings ?? undefined}
647
644
  error={d.consentError}
648
- onApprove={d.approveConsent}
649
- onCancel={d.cancelConsent}
645
+ notice={signinNotice}
646
+ approveBusy={consentActions.waiting}
647
+ onApprove={consentActions.approve}
648
+ onCancel={consentActions.cancel}
650
649
  />
651
650
  </div>
652
651
  ) : setupPending ? (
@@ -657,13 +656,18 @@ export function DiagnoseSurface({
657
656
  checkingAgents={d.checkingAgents}
658
657
  agentsCheckFailed={d.agentsCheckFailed}
659
658
  recheckAgents={d.recheckAgents}
659
+ onOpenExample={openExample}
660
660
  />
661
661
  </div>
662
662
  ) : (
663
663
  <InvestigationHome
664
664
  agentLabel={d.agentLabel}
665
+ questions={d.questions}
666
+ onOpenExample={openExample}
665
667
  onBrowseIssues={
666
- d.runsLoaded && d.runs.length === 0 ? onBrowseIssues : undefined
668
+ d.questions || (d.runsLoaded && d.runs.length === 0)
669
+ ? onBrowseIssues
670
+ : undefined
667
671
  }
668
672
  />
669
673
  );
@@ -770,22 +774,15 @@ export function DiagnoseSurface({
770
774
  </div>
771
775
  <div className="flex shrink-0 items-center gap-1">
772
776
  {activeRun &&
777
+ visibleRunDetail &&
778
+ !exampleOpen &&
773
779
  canRerunInvestigation(d.view, activeRun, d.needsConsent) && (
774
780
  <Tooltip
775
781
  content="Re-run this investigation from scratch"
776
782
  position="bottom"
777
783
  >
778
784
  <button
779
- onClick={() =>
780
- d.openInvestigation({
781
- kind: activeRun.kind,
782
- group: activeRun.group,
783
- namespace: activeRun.namespace,
784
- name: activeRun.name,
785
- issueId: activeRun.issueId,
786
- fresh: true,
787
- })
788
- }
785
+ onClick={() => d.openInvestigation(rerunOpening(activeRun))}
789
786
  className="rounded-md p-1 text-theme-text-tertiary hover:bg-theme-hover hover:text-theme-text-primary"
790
787
  aria-label="Re-run this investigation from scratch"
791
788
  >
@@ -793,7 +790,9 @@ export function DiagnoseSurface({
793
790
  </button>
794
791
  </Tooltip>
795
792
  )}
796
- {visibleRunDetail && headerPresentation.runActionsClass !== null && (
793
+ {visibleRunDetail &&
794
+ !exampleOpen &&
795
+ headerPresentation.runActionsClass !== null && (
797
796
  <div
798
797
  className={`items-center gap-1 ${headerPresentation.runActionsClass || "flex"}`}
799
798
  >
@@ -801,7 +800,12 @@ export function DiagnoseSurface({
801
800
  run: visibleRunDetail,
802
801
  onRunUpdated: d.updateRunSummary,
803
802
  })}
804
- <InvestigationMenu run={visibleRunDetail} />
803
+ {handoffAllowed && handoffCommand && (
804
+ <ContinueInAgentButton
805
+ run={visibleRunDetail}
806
+ command={handoffCommand}
807
+ />
808
+ )}
805
809
  </div>
806
810
  )}
807
811
  {!fullWidthForced && (!maximized || d.canRestoreWorkspace) && (
@@ -874,6 +878,19 @@ export function DiagnoseSurface({
874
878
  if (historyOverlay) dismissHistory();
875
879
  }}
876
880
  historyDegraded={d.historyDegraded}
881
+ loaded={d.runsLoaded}
882
+ loadFailed={d.runsLoadFailed}
883
+ onRetry={d.refreshRuns}
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
+ }
877
894
  />
878
895
  </aside>
879
896
  )}
@@ -1,5 +1,6 @@
1
1
  import { StoryExcerpt } from "./StoryExcerpt";
2
2
  import { storyExcerpt } from "./investigationEvidence/excerpt";
3
+ import { metricsReading } from "./investigationEvidence/bodies/metrics";
3
4
  import {
4
5
  type InvestigationCaseItem,
5
6
  investigationCaseObservationKey,
@@ -61,6 +62,7 @@ export function EvidenceCard({
61
62
  spanFullRow = false,
62
63
  prominence = "primary",
63
64
  compact = false,
65
+ storyPreview = false,
64
66
  placedInStory = false,
65
67
  gapRoles,
66
68
  noteMode = "full",
@@ -87,6 +89,11 @@ export function EvidenceCard({
87
89
  * card. A story log card keeps its cited lines: they are the card.
88
90
  */
89
91
  compact?: boolean;
92
+ /**
93
+ * The card sits in the story's collapsed preview, which bounds its height;
94
+ * a compact card outside it still shows a placed chart.
95
+ */
96
+ storyPreview?: boolean;
90
97
  /** This card also appears inside the story above. */
91
98
  placedInStory?: boolean;
92
99
  /** Roles whose "does not cover" line is shown; undefined shows every gap. */
@@ -109,6 +116,7 @@ export function EvidenceCard({
109
116
  metricsMarkersBySource,
110
117
  caseByGroup,
111
118
  excludedByItem,
119
+ storyReveal,
112
120
  } = useContext(EvidenceNavigationContext);
113
121
  const open = expandedGroupIds?.has(group.id) ?? false;
114
122
  const setOpen = useCallback(
@@ -176,6 +184,7 @@ export function EvidenceCard({
176
184
  evidenceDisplaySnapshot(citedObservation) !==
177
185
  evidenceDisplaySnapshot(observation);
178
186
  const bodyId = `${domId}-body`;
187
+ const chartId = `${domId}-chart`;
179
188
  const hasEvidenceDetails = evidenceHasDetails(
180
189
  observation.data,
181
190
  observation.summary,
@@ -183,6 +192,7 @@ export function EvidenceCard({
183
192
  const excerpt = storyCard
184
193
  ? storyExcerpt(observation, cardItems, {
185
194
  compact,
195
+ preview: storyPreview,
186
196
  scopeNamespace: listingScopeNamespace(observation.source),
187
197
  })
188
198
  : undefined;
@@ -201,7 +211,37 @@ export function EvidenceCard({
201
211
  const storyLogRest = excerpt?.kind === "lines" ? excerpt.rest : [];
202
212
  const hasExpandableBody =
203
213
  (hasEvidenceDetails && !inlineLogs && !inlineMetrics) || meaningfulHistory;
204
- const canExpand = !compact && (hasExpandableBody || storyLogRest.length > 0);
214
+ const bodyExpandable =
215
+ !compact && (hasExpandableBody || storyLogRest.length > 0);
216
+ // A placed chart folds behind the card's chevron, compact or not, starting
217
+ // as the excerpt says until the reader toggles it. Its fold is the card's
218
+ // own: the body behind it (earlier reads) opens and closes with the chart,
219
+ // and the same result's card under Captured results keeps its own state.
220
+ // Keyed by the result so a different chart in this slot starts as its own
221
+ // excerpt says rather than as the reader left the last one.
222
+ const [chartChoice, setChartChoice] = useState<{
223
+ sourceId: string;
224
+ open: boolean;
225
+ }>();
226
+ const chooseChart = (open: boolean) =>
227
+ setChartChoice({ sourceId: observation.source.id, open });
228
+ const chartOpen =
229
+ excerpt?.kind === "chart"
230
+ ? chartChoice?.sourceId === observation.source.id
231
+ ? chartChoice.open
232
+ : !excerpt.folded
233
+ : false;
234
+ const canExpand = inlineMetrics || bodyExpandable;
235
+ const expanded = inlineMetrics ? chartOpen : open;
236
+ const chartReading =
237
+ inlineMetrics && !chartOpen && observation.data.type === "metrics"
238
+ ? metricsReading(observation.data)
239
+ : undefined;
240
+ const toggle = (opening: boolean) => {
241
+ if (inlineMetrics) chooseChart(opening);
242
+ else setOpen(opening);
243
+ revealAfterToggle(opening);
244
+ };
205
245
  const revealHistory = investigationEvidenceShouldRevealHistory(
206
246
  group,
207
247
  revealSourceId,
@@ -216,9 +256,17 @@ export function EvidenceCard({
216
256
  if (
217
257
  revealHistory ||
218
258
  (destination && elementRef.current?.contains(destination))
219
- )
259
+ ) {
220
260
  setOpen(true);
261
+ chooseChart(true);
262
+ }
263
+ // chooseChart is rebuilt per render from the observation on screen.
264
+ // eslint-disable-next-line react-hooks/exhaustive-deps
221
265
  }, [revealHistory, revealSourceId, revealRequestId, elementRef, setOpen]);
266
+ useLayoutEffect(() => {
267
+ if (storyReveal?.domId === domId) chooseChart(true);
268
+ // eslint-disable-next-line react-hooks/exhaustive-deps
269
+ }, [storyReveal?.requestId]);
222
270
  const wide = spanFullRow || evidenceTypePrefersFullRow(observation.data.type);
223
271
  const resourceRef = investigationEvidenceSubjectRef(observation.data);
224
272
  const resourceIdentity = resourceRef
@@ -268,13 +316,21 @@ export function EvidenceCard({
268
316
  <span
269
317
  className={clsx(
270
318
  "mt-0.5 block text-xs leading-relaxed text-theme-text-secondary",
271
- !open && !inlineSecretKeys && "line-clamp-2",
319
+ !expanded && !inlineSecretKeys && "line-clamp-2",
272
320
  "[overflow-wrap:anywhere]",
273
321
  )}
274
322
  >
275
323
  {displaySummary}
276
324
  </span>
277
325
  ) : null}
326
+ {chartReading ? (
327
+ <span
328
+ data-chart-reading
329
+ className="mt-0.5 block font-mono text-xs tabular-nums text-theme-text-secondary"
330
+ >
331
+ {chartReading}
332
+ </span>
333
+ ) : null}
278
334
  {supersededRead ? (
279
335
  <span className="mt-0.5 block text-xs text-theme-text-tertiary">
280
336
  Captured in turn {observation.source.turnIndex + 1} · a newer read
@@ -299,7 +355,7 @@ export function EvidenceCard({
299
355
  ) : null}
300
356
  </span>
301
357
  {canExpand ? (
302
- <CollapseChevron open={open} className="h-4 w-4 self-center" />
358
+ <CollapseChevron open={expanded} className="h-4 w-4 self-center" />
303
359
  ) : null}
304
360
  </>
305
361
  );
@@ -338,13 +394,9 @@ export function EvidenceCard({
338
394
  {canExpand ? (
339
395
  <button
340
396
  type="button"
341
- aria-expanded={open}
342
- aria-controls={bodyId}
343
- onClick={() => {
344
- const opening = !open;
345
- setOpen(opening);
346
- revealAfterToggle(opening);
347
- }}
397
+ aria-expanded={expanded}
398
+ aria-controls={inlineMetrics ? chartId : bodyId}
399
+ onClick={() => toggle(!expanded)}
348
400
  className={clsx(
349
401
  "flex min-w-0 flex-1 items-start text-left hover:bg-theme-hover/60",
350
402
  prominence === "primary"
@@ -419,8 +471,9 @@ export function EvidenceCard({
419
471
  excerpt={excerpt}
420
472
  data={observation.data}
421
473
  prominence={prominence}
422
- open={open}
474
+ open={expanded}
423
475
  canExpand={canExpand}
476
+ chartId={chartId}
424
477
  changeCoverage={metricsMarkersBySource?.get(
425
478
  observation.source.id,
426
479
  )}
@@ -450,9 +503,9 @@ export function EvidenceCard({
450
503
  ))}
451
504
  </div>
452
505
  ) : null}
453
- {canExpand && hasExpandableBody ? (
506
+ {bodyExpandable && hasExpandableBody ? (
454
507
  <div id={bodyId}>
455
- <Collapse open={open}>
508
+ <Collapse open={expanded}>
456
509
  <div
457
510
  className={clsx(
458
511
  "space-y-3 border-t border-theme-border/60",
@@ -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
+ }