@skyhook-io/radar-app 1.18.1 → 1.19.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 (136) hide show
  1. package/package.json +4 -4
  2. package/src/App.tsx +23 -9
  3. package/src/api/client.deleteResource.test.tsx +111 -0
  4. package/src/api/client.resourceAudit.test.tsx +57 -0
  5. package/src/api/client.resourcePath.test.ts +107 -0
  6. package/src/api/client.ts +136 -37
  7. package/src/api/diagnose.test.ts +33 -2
  8. package/src/api/diagnose.ts +93 -3
  9. package/src/api/radarFeatures.ts +1 -0
  10. package/src/components/capacity/CapacityDemand.tsx +6 -3
  11. package/src/components/capacity/CapacityOverview.tsx +14 -7
  12. package/src/components/capacity/CapacityPoolDetail.tsx +7 -5
  13. package/src/components/capacity/ClusterSchedulingCard.tsx +3 -3
  14. package/src/components/capacity/shared.tsx +9 -5
  15. package/src/components/cnpg/CNPGOverview.tsx +4 -1
  16. package/src/components/cnpg/actions/useCNPGWriteGuard.tsx +1 -0
  17. package/src/components/diagnose/AIMarkdown.tsx +1 -1
  18. package/src/components/diagnose/ActivityTurn.tsx +34 -14
  19. package/src/components/diagnose/AgentControls.tsx +53 -6
  20. package/src/components/diagnose/AgentSetupNotice.tsx +1 -1
  21. package/src/components/diagnose/AgentSigninNotice.test.tsx +98 -0
  22. package/src/components/diagnose/AgentSigninNotice.tsx +61 -0
  23. package/src/components/diagnose/AnalysisStory.test.tsx +22 -0
  24. package/src/components/diagnose/AnalysisStory.tsx +17 -4
  25. package/src/components/diagnose/ApplyDialog.test.tsx +10 -0
  26. package/src/components/diagnose/ApplyDialog.tsx +8 -1
  27. package/src/components/diagnose/AssessmentCard.tsx +99 -8
  28. package/src/components/diagnose/DiagnoseContext.capacity.test.tsx +113 -0
  29. package/src/components/diagnose/DiagnoseContext.question.test.tsx +245 -0
  30. package/src/components/diagnose/DiagnoseContext.tsx +205 -9
  31. package/src/components/diagnose/DiagnoseSurface.test.tsx +54 -0
  32. package/src/components/diagnose/DiagnoseSurface.tsx +98 -21
  33. package/src/components/diagnose/EvidenceCard.tsx +67 -14
  34. package/src/components/diagnose/Home.test.tsx +182 -5
  35. package/src/components/diagnose/Home.tsx +168 -36
  36. package/src/components/diagnose/InvestigationCapacityNotice.test.tsx +246 -0
  37. package/src/components/diagnose/InvestigationCapacityNotice.tsx +241 -0
  38. package/src/components/diagnose/InvestigationEvidencePane.story.test.tsx +97 -6
  39. package/src/components/diagnose/InvestigationEvidencePane.test.tsx +119 -2
  40. package/src/components/diagnose/InvestigationEvidencePane.tsx +59 -11
  41. package/src/components/diagnose/InvestigationEvidenceSections.tsx +11 -6
  42. package/src/components/diagnose/InvestigationView.tsx +203 -42
  43. package/src/components/diagnose/LocalDiagnoseAction.tsx +23 -16
  44. package/src/components/diagnose/QuestionComposer.test.tsx +553 -0
  45. package/src/components/diagnose/QuestionComposer.tsx +487 -0
  46. package/src/components/diagnose/QuestionFocus.test.tsx +38 -0
  47. package/src/components/diagnose/QuestionFocus.tsx +123 -0
  48. package/src/components/diagnose/ResourcePicker.tsx +206 -0
  49. package/src/components/diagnose/StoryExcerpt.tsx +12 -3
  50. package/src/components/diagnose/assessmentCopy.ts +16 -0
  51. package/src/components/diagnose/investigationCase.runs.test.tsx +328 -0
  52. package/src/components/diagnose/investigationCase.ts +33 -1
  53. package/src/components/diagnose/investigationEvidence/adapters/changes.ts +36 -1
  54. package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +46 -0
  55. package/src/components/diagnose/investigationEvidence/adapters/crossplane.test.tsx +85 -0
  56. package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +8 -0
  57. package/src/components/diagnose/investigationEvidence/adapters/issues.ts +1 -0
  58. package/src/components/diagnose/investigationEvidence/adapters/posture.ts +29 -1
  59. package/src/components/diagnose/investigationEvidence/adapters/prometheus.test.ts +42 -1
  60. package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +29 -2
  61. package/src/components/diagnose/investigationEvidence/adapters/testdata/crossplane-paused-get-resource.json +28 -0
  62. package/src/components/diagnose/investigationEvidence/bodies/index.tsx +2 -0
  63. package/src/components/diagnose/investigationEvidence/bodies/metrics.test.tsx +111 -0
  64. package/src/components/diagnose/investigationEvidence/bodies/metrics.tsx +67 -16
  65. package/src/components/diagnose/investigationEvidence/bodies/workload.tsx +5 -1
  66. package/src/components/diagnose/investigationEvidence/builder.ts +3 -1
  67. package/src/components/diagnose/investigationEvidence/cardParts.tsx +7 -2
  68. package/src/components/diagnose/investigationEvidence/excerpt.test.ts +18 -5
  69. package/src/components/diagnose/investigationEvidence/excerpt.ts +22 -11
  70. package/src/components/diagnose/investigationEvidence/identity.test.ts +1 -1
  71. package/src/components/diagnose/investigationEvidence/index.ts +1 -1
  72. package/src/components/diagnose/investigationEvidence/navigation.tsx +2 -0
  73. package/src/components/diagnose/investigationEvidence/observations.ts +7 -3
  74. package/src/components/diagnose/investigationEvidence/projection.test.ts +57 -3
  75. package/src/components/diagnose/investigationEvidence/types.ts +2 -0
  76. package/src/components/diagnose/investigationEvidencePartition.ts +6 -1
  77. package/src/components/diagnose/investigationEvidencePresentation.test.ts +36 -2
  78. package/src/components/diagnose/investigationEvidencePresentation.ts +33 -8
  79. package/src/components/diagnose/investigationFocus.test.ts +271 -0
  80. package/src/components/diagnose/investigationFocus.ts +132 -0
  81. package/src/components/diagnose/parts.test.tsx +20 -0
  82. package/src/components/diagnose/questionSuggestions.test.ts +111 -0
  83. package/src/components/diagnose/questionSuggestions.ts +150 -0
  84. package/src/components/diagnose/storyParts.test.tsx +66 -0
  85. package/src/components/diagnose/target.test.ts +143 -2
  86. package/src/components/diagnose/target.ts +109 -7
  87. package/src/components/diagnose/testdata/story-runs.json +474 -0
  88. package/src/components/diagnose/verdictText.test.tsx +87 -0
  89. package/src/components/diagnose/verdictText.ts +68 -0
  90. package/src/components/helm/ChartBrowser.tsx +4 -4
  91. package/src/components/helm/HelmReleaseDrawer.tsx +6 -2
  92. package/src/components/helm/HelmView.tsx +34 -23
  93. package/src/components/helm/InstallWizard.tsx +6 -2
  94. package/src/components/helm/ValuesViewer.test.tsx +1 -0
  95. package/src/components/helm/ValuesViewer.tsx +4 -2
  96. package/src/components/home/ClusterHealthCard.tsx +40 -59
  97. package/src/components/home/HomeAgentBlock.test.tsx +113 -0
  98. package/src/components/home/HomeAgentBlock.tsx +94 -0
  99. package/src/components/home/HomeView.tsx +5 -6
  100. package/src/components/home/MCPSetupDialog.test.tsx +27 -2
  101. package/src/components/home/MCPSetupDialog.tsx +14 -2
  102. package/src/components/home/RadarVersionLine.test.tsx +0 -14
  103. package/src/components/home/RadarVersionLine.tsx +3 -28
  104. package/src/components/home/mcpToolCatalog.ts +29 -2
  105. package/src/components/issues/IssuesPane.render.test.tsx +5 -5
  106. package/src/components/nav/PrimaryNavRail.tsx +34 -2
  107. package/src/components/product-hunt/ProductHuntNotice.render.test.tsx +120 -0
  108. package/src/components/product-hunt/ProductHuntNotice.test.ts +121 -0
  109. package/src/components/product-hunt/ProductHuntNotice.tsx +202 -0
  110. package/src/components/product-hunt/launchWindow.ts +78 -0
  111. package/src/components/product-hunt/useProductHuntRailEntry.test.tsx +76 -0
  112. package/src/components/product-hunt/useProductHuntRailEntry.ts +27 -0
  113. package/src/components/resources/CompositeRenderer.tsx +4 -0
  114. package/src/components/resources/ResourcesView.tsx +1 -1
  115. package/src/components/settings/LocalConnectionSettings.tsx +1 -0
  116. package/src/components/ui/Omnibar.investigate.test.tsx +105 -0
  117. package/src/components/ui/Omnibar.tsx +47 -3
  118. package/src/components/ui/RadarOmnibar.test.tsx +19 -0
  119. package/src/components/ui/RadarOmnibar.tsx +12 -0
  120. package/src/components/ui/SearchSyntaxHelp.test.tsx +39 -0
  121. package/src/components/ui/SearchSyntaxHelp.tsx +23 -2
  122. package/src/components/ui/UpdateNotification.test.tsx +2 -0
  123. package/src/components/ui/UpdateNotification.tsx +32 -5
  124. package/src/components/usage-data/UsageDataPrompt.tsx +19 -1
  125. package/src/components/whats-new/WhatsNewDialog.test.tsx +3 -3
  126. package/src/components/whats-new/releaseNotes.ts +60 -1
  127. package/src/components/workload/WorkloadView.tsx +10 -4
  128. package/src/components/workspace/layout.tsx +2 -1
  129. package/src/contexts/CapabilitiesContext.tsx +1 -0
  130. package/src/hooks/useAgentSignin.test.tsx +190 -0
  131. package/src/hooks/useAgentSignin.ts +160 -0
  132. package/src/hooks/useApproveAfterSignin.test.tsx +108 -0
  133. package/src/hooks/useGitOpsWriteGuard.test.tsx +126 -2
  134. package/src/hooks/useGitOpsWriteGuard.ts +25 -3
  135. package/src/hooks/useResolvedGitOpsOwner.ts +14 -9
  136. package/src/index.css +85 -0
@@ -8,12 +8,13 @@ import {
8
8
  RefreshCw,
9
9
  } from "lucide-react";
10
10
  import { DialogPortal } from "@skyhook-io/k8s-ui/components/ui/DialogPortal";
11
- import { GitOpsWriteWarning } from "@skyhook-io/k8s-ui";
11
+ import { GitOpsWriteWarning, type GitOpsOwnerRef } from "@skyhook-io/k8s-ui";
12
12
  import {
13
13
  canConfirmGitOpsWrite,
14
14
  gitOpsWriteGuardKey,
15
15
  type GitOpsWriteGuard,
16
16
  } from "@skyhook-io/k8s-ui/utils/gitops-write-guard";
17
+ import { CrossplaneApplyNotice } from "@skyhook-io/k8s-ui/components/ui/CrossplaneOperationNotice";
17
18
  import { parseContextName } from "../../utils/context-name";
18
19
  import type { Diagnosis, ApplyMutationOutcome } from "../../api/diagnose";
19
20
  import { AIMarkdown, CopyButton } from "./AIMarkdown";
@@ -32,7 +33,9 @@ export function ApplyDialog({
32
33
  precondition,
33
34
  gitOpsGuard,
34
35
  onOpenGitOpsOwner,
36
+ onOpenGitOpsManager,
35
37
  confidence,
38
+ resourceData,
36
39
  }: {
37
40
  open: boolean;
38
41
  onClose: () => void;
@@ -48,7 +51,9 @@ export function ApplyDialog({
48
51
  /** GitOps/Helm write guard for the target; undefined blocks Apply. */
49
52
  gitOpsGuard?: GitOpsWriteGuard;
50
53
  onOpenGitOpsOwner?: () => void;
54
+ onOpenGitOpsManager?: (owner: GitOpsOwnerRef) => void;
51
55
  confidence?: number;
56
+ resourceData?: unknown;
52
57
  }) {
53
58
  const titleId = useId();
54
59
  const fixText = fix?.trim();
@@ -144,12 +149,14 @@ export function ApplyDialog({
144
149
  )}
145
150
  </div>
146
151
  <div className="shrink-0 space-y-2 p-4">
152
+ <CrossplaneApplyNotice resources={[resourceData]} />
147
153
  {gitOpsGuard && (
148
154
  <GitOpsWriteWarning
149
155
  guard={gitOpsGuard}
150
156
  acknowledged={acked}
151
157
  onAcknowledgedChange={(value) => setAckedKey(value ? guardKey : "")}
152
158
  onOpenOwner={onOpenGitOpsOwner}
159
+ onOpenManager={onOpenGitOpsManager}
153
160
  />
154
161
  )}
155
162
  {lowConfidence && (
@@ -32,6 +32,7 @@ import type { InvestigationHealthSignal } from "./investigationState";
32
32
  import { Badge } from "@skyhook-io/k8s-ui";
33
33
  import { diagnosisHasStoryShape, storyPlainText } from "./investigationStory";
34
34
  import { useDisclosureReveal } from "./useDisclosureReveal";
35
+ import { verdictParts } from "./verdictText";
35
36
  import { FollowupAnswer } from "./ActivityTurn";
36
37
  import { ApplyOutcomeCard } from "./ApplyDialog";
37
38
  import {
@@ -40,7 +41,12 @@ import {
40
41
  STEP_KIND_LABEL,
41
42
  assessmentCopyText,
42
43
  } from "./assessmentCopy";
43
- import { AIMarkdown, CopyButton, tidyFences } from "./AIMarkdown";
44
+ import {
45
+ AIMarkdown,
46
+ CopyButton,
47
+ SOFT_INLINE_CODE,
48
+ tidyFences,
49
+ } from "./AIMarkdown";
44
50
  import { prettyTool } from "./toolCallLabel";
45
51
 
46
52
  export function ResultCard({
@@ -65,6 +71,7 @@ export function ResultCard({
65
71
  readOnlyAssessment = false,
66
72
  revisedAfter,
67
73
  assessmentLimits,
74
+ assessmentRoutineLimits,
68
75
  assessmentCopy,
69
76
  healthSignals,
70
77
  onRevealSource,
@@ -88,6 +95,8 @@ export function ResultCard({
88
95
  revisedAfter?: string;
89
96
  /** Reads Radar could not complete for this assessment; listed under Still open. */
90
97
  assessmentLimits?: string[];
98
+ /** Sampling caps and history bounds Radar hit; folded beneath Still open. */
99
+ assessmentRoutineLimits?: string[];
91
100
  assessmentCopy?: Pick<AssessmentCopyRadar, "context" | "receipts">;
92
101
  healthSignals?: InvestigationHealthSignal[];
93
102
  onRevealSource?: (sourceId: string) => void;
@@ -150,6 +159,7 @@ export function ResultCard({
150
159
  storyInline={storyInline}
151
160
  revisedAfter={revisedAfter}
152
161
  assessmentLimits={assessmentLimits}
162
+ assessmentRoutineLimits={assessmentRoutineLimits}
153
163
  assessmentCopy={assessmentCopy}
154
164
  healthSignals={healthSignals}
155
165
  onRevealSource={onRevealSource}
@@ -183,6 +193,7 @@ export function ResultCard({
183
193
  storyInline={storyInline}
184
194
  revisedAfter={revisedAfter}
185
195
  assessmentLimits={assessmentLimits}
196
+ assessmentRoutineLimits={assessmentRoutineLimits}
186
197
  assessmentCopy={assessmentCopy}
187
198
  />
188
199
  {section === "full" && (diagnosis.steps?.length ?? 0) > 0 ? (
@@ -234,6 +245,7 @@ export function ResultCard({
234
245
  readOnlyAssessment={readOnlyAssessment}
235
246
  revisedAfter={revisedAfter}
236
247
  assessmentLimits={assessmentLimits}
248
+ assessmentRoutineLimits={assessmentRoutineLimits}
237
249
  assessmentCopy={assessmentCopy}
238
250
  />
239
251
  );
@@ -272,11 +284,31 @@ const HEALTHY_DEFINITION: Record<
272
284
  * whenever the agent listed anything, and says so when it listed nothing,
273
285
  * because a persuasive story needs its caveats above the fold, not inside it.
274
286
  */
287
+ // A verdict is one sentence of prose with the odd `code` span. Rendering it
288
+ // as full markdown would turn a leading "1." or "#" into a list or heading, so
289
+ // only code spans are rendered, with their contents exactly as written.
290
+ export function VerdictText({ text }: { text: string }) {
291
+ return (
292
+ <>
293
+ {verdictParts(text).map((part, index) =>
294
+ part.code ? (
295
+ <code key={index} className="inline-code">
296
+ {part.text}
297
+ </code>
298
+ ) : (
299
+ part.text
300
+ ),
301
+ )}
302
+ </>
303
+ );
304
+ }
305
+
275
306
  function AssessmentHeadline({
276
307
  diagnosis,
277
308
  tone,
278
309
  revisedAfter,
279
310
  limits = [],
311
+ routineLimits = [],
280
312
  signals,
281
313
  flags,
282
314
  copy,
@@ -286,6 +318,8 @@ function AssessmentHeadline({
286
318
  revisedAfter?: string;
287
319
  /** Reads Radar could not complete for this assessment, one line each. */
288
320
  limits?: string[];
321
+ /** Sampling caps and history bounds, one line each; folded beneath Still open. */
322
+ routineLimits?: string[];
289
323
  /** Adverse Radar cards the agent explained, with its position; first in Still open. */
290
324
  signals?: { text: string; onReveal?: () => void }[];
291
325
  /** Adverse Radar cards nothing explains; shown above a healthy verdict, copied with it. */
@@ -306,12 +340,16 @@ function AssessmentHeadline({
306
340
  return (
307
341
  <div data-assessment-headline className="space-y-2">
308
342
  <div className="flex items-start justify-between gap-2">
309
- <p className="text-[15px] font-semibold leading-snug text-theme-text-primary [overflow-wrap:anywhere] [text-wrap:balance]">
310
- {summary}
343
+ {/* The answer is the largest text in the assessment, above its label. */}
344
+ <p
345
+ className={`text-lg font-semibold leading-snug text-theme-text-primary [overflow-wrap:anywhere] [text-wrap:pretty] ${SOFT_INLINE_CODE}`}
346
+ >
347
+ <VerdictText text={summary} />
311
348
  </p>
312
349
  <CopyButton
313
350
  text={assessmentCopyText(diagnosis, {
314
351
  limits,
352
+ routineLimits,
315
353
  signals: (signals ?? []).map((signal) => signal.text),
316
354
  flags,
317
355
  ...copy,
@@ -398,6 +436,44 @@ function AssessmentHeadline({
398
436
  </ul>
399
437
  </div>
400
438
  ) : null}
439
+ {routineLimits.length > 0 ? (
440
+ <RoutineLimits lines={routineLimits} />
441
+ ) : null}
442
+ </div>
443
+ );
444
+ }
445
+
446
+ // Radar's ordinary limits — a capped sample, history that starts when Radar
447
+ // started watching — hold on most runs and rarely bear on the cause. They stay
448
+ // above the fold, and in the channel copy, but folded to one muted line so the
449
+ // agent's own open questions lead.
450
+ function RoutineLimits({ lines }: { lines: string[] }) {
451
+ const [open, setOpen] = useState(false);
452
+ const id = useId();
453
+ return (
454
+ <div data-assessment-routine-limits>
455
+ <button
456
+ type="button"
457
+ aria-expanded={open}
458
+ aria-controls={id}
459
+ onClick={() => setOpen(!open)}
460
+ className="flex items-center gap-1 text-[11px] text-theme-text-tertiary hover:text-theme-text-secondary"
461
+ >
462
+ <CollapseChevron open={open} className="h-3 w-3" />
463
+ Radar&apos;s coverage · {lines.length} routine{" "}
464
+ {lines.length === 1 ? "limit" : "limits"}
465
+ </button>
466
+ <div id={id}>
467
+ <Collapse open={open}>
468
+ <ul className="mt-1 space-y-0.5 pl-4 text-[11px] text-theme-text-tertiary">
469
+ {lines.map((line, index) => (
470
+ <li key={`routine-${index}`} className="[overflow-wrap:anywhere]">
471
+ {line}
472
+ </li>
473
+ ))}
474
+ </ul>
475
+ </Collapse>
476
+ </div>
401
477
  </div>
402
478
  );
403
479
  }
@@ -893,6 +969,7 @@ function DiagnosisResult({
893
969
  readOnlyAssessment = false,
894
970
  revisedAfter,
895
971
  assessmentLimits,
972
+ assessmentRoutineLimits,
896
973
  assessmentCopy,
897
974
  }: {
898
975
  diagnosis: Diagnosis;
@@ -910,6 +987,8 @@ function DiagnosisResult({
910
987
  revisedAfter?: string;
911
988
  /** Reads Radar could not complete for this assessment; listed under Still open. */
912
989
  assessmentLimits?: string[];
990
+ /** Sampling caps and history bounds Radar hit; folded beneath Still open. */
991
+ assessmentRoutineLimits?: string[];
913
992
  assessmentCopy?: Pick<AssessmentCopyRadar, "context" | "receipts">;
914
993
  }) {
915
994
  // The story contract: a summary headline above, the story rendered by the
@@ -1025,7 +1104,13 @@ function DiagnosisResult({
1025
1104
  data-step-precondition
1026
1105
  className="mb-1.5 text-[13px] leading-snug text-warning-text"
1027
1106
  >
1028
- Only if {step.precondition.replace(/^(if|when|once)\s+/i, "")}
1107
+ {/* The agent writes a full sentence; after "Only if" its first
1108
+ capital drops when it is an ordinary word ("You"), never
1109
+ for a name with more capitals (API, ConfigMap). */}
1110
+ Only if{" "}
1111
+ {step.precondition
1112
+ .replace(/^(if|when|once)\s+/i, "")
1113
+ .replace(/^[A-Z](?=[a-z]+\b)/, (c) => c.toLowerCase())}
1029
1114
  </p>
1030
1115
  ) : null}
1031
1116
  {isRec && diagnosis.recommendedReason && (
@@ -1076,6 +1161,7 @@ function DiagnosisResult({
1076
1161
  tone="cause"
1077
1162
  revisedAfter={revisedAfter}
1078
1163
  limits={assessmentLimits}
1164
+ routineLimits={assessmentRoutineLimits}
1079
1165
  copy={assessmentCopy}
1080
1166
  />
1081
1167
  </div>
@@ -1255,6 +1341,7 @@ export function AllClearCard({
1255
1341
  storyInline = false,
1256
1342
  revisedAfter,
1257
1343
  assessmentLimits,
1344
+ assessmentRoutineLimits,
1258
1345
  assessmentCopy,
1259
1346
  healthSignals,
1260
1347
  onRevealSource,
@@ -1272,6 +1359,8 @@ export function AllClearCard({
1272
1359
  revisedAfter?: string;
1273
1360
  /** Reads Radar could not complete for this assessment; listed under Still open. */
1274
1361
  assessmentLimits?: string[];
1362
+ /** Sampling caps and history bounds Radar hit; folded beneath Still open. */
1363
+ assessmentRoutineLimits?: string[];
1275
1364
  assessmentCopy?: Pick<AssessmentCopyRadar, "context" | "receipts">;
1276
1365
  /** Adverse Radar cards with the agent's position on each (story shape). */
1277
1366
  healthSignals?: InvestigationHealthSignal[];
@@ -1376,6 +1465,7 @@ export function AllClearCard({
1376
1465
  revisedAfter={revisedAfter}
1377
1466
  flags={flagged.map(healthFlagSentence)}
1378
1467
  limits={assessmentLimits}
1468
+ routineLimits={assessmentRoutineLimits}
1379
1469
  copy={assessmentCopy}
1380
1470
  signals={stillOpenSignals}
1381
1471
  />
@@ -1459,6 +1549,7 @@ export function InconclusiveCard({
1459
1549
  storyInline = false,
1460
1550
  revisedAfter,
1461
1551
  assessmentLimits,
1552
+ assessmentRoutineLimits,
1462
1553
  assessmentCopy,
1463
1554
  }: {
1464
1555
  diagnosis: Diagnosis;
@@ -1470,6 +1561,8 @@ export function InconclusiveCard({
1470
1561
  assessmentAction?: ReactNode;
1471
1562
  /** Reads Radar could not complete for this assessment; listed under Still open. */
1472
1563
  assessmentLimits?: string[];
1564
+ /** Sampling caps and history bounds Radar hit; folded beneath Still open. */
1565
+ assessmentRoutineLimits?: string[];
1473
1566
  assessmentCopy?: Pick<AssessmentCopyRadar, "context" | "receipts">;
1474
1567
  }) {
1475
1568
  const storyShape = diagnosisHasStoryShape(diagnosis);
@@ -1496,6 +1589,7 @@ export function InconclusiveCard({
1496
1589
  tone="inconclusive"
1497
1590
  revisedAfter={revisedAfter}
1498
1591
  limits={assessmentLimits}
1592
+ routineLimits={assessmentRoutineLimits}
1499
1593
  copy={assessmentCopy}
1500
1594
  />
1501
1595
  ) : null}
@@ -1507,10 +1601,7 @@ export function InconclusiveCard({
1507
1601
  </div>
1508
1602
  <div className="flex items-start gap-1 px-0.5 text-[11px] text-theme-text-tertiary">
1509
1603
  <ShieldCheck className="mt-0.5 h-3 w-3 shrink-0" />
1510
- <span>
1511
- Try a follow-up with more context, or investigate again after
1512
- addressing any errors shown in Activity.
1513
- </span>
1604
+ <span>Try a follow-up with more context, or investigate again.</span>
1514
1605
  </div>
1515
1606
  <AssessmentDetails
1516
1607
  diagnosis={diagnosis}
@@ -0,0 +1,113 @@
1
+ // @vitest-environment jsdom
2
+ import { act, useEffect } from "react";
3
+ import { createRoot, type Root } from "react-dom/client";
4
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
5
+
6
+ import { DiagnoseError } from "../../api/diagnose";
7
+ import { DiagnoseProvider, useDiagnose } from "./DiagnoseContext";
8
+
9
+ const api = vi.hoisted(() => ({ createRun: vi.fn() }));
10
+
11
+ vi.mock("../../api/diagnose", async (importOriginal) => ({
12
+ ...(await importOriginal<object>()),
13
+ fetchAgents: async () => ({
14
+ enabled: true,
15
+ eligible: true,
16
+ consented: { "claude:safeguarded": true },
17
+ agents: [
18
+ {
19
+ name: "claude",
20
+ label: "Claude Code",
21
+ path: "/bin/claude",
22
+ version: "",
23
+ present: true,
24
+ supported: true,
25
+ profiles: ["safeguarded"],
26
+ consentSurfaces: { safeguarded: "claude:safeguarded" },
27
+ },
28
+ ],
29
+ }),
30
+ listRuns: async () => ({ runs: [] }),
31
+ getRun: vi.fn(() => new Promise(() => {})),
32
+ createRun: api.createRun,
33
+ }));
34
+
35
+ vi.mock("../../api/client", async (importOriginal) => ({
36
+ ...(await importOriginal<object>()),
37
+ useContexts: () => ({ data: [{ name: "cluster-a", isCurrent: true }] }),
38
+ }));
39
+
40
+ Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
41
+ let root: Root;
42
+ const probe = {} as { d: ReturnType<typeof useDiagnose> };
43
+
44
+ function Probe() {
45
+ const d = useDiagnose();
46
+ useEffect(() => {
47
+ probe.d = d;
48
+ });
49
+ return null;
50
+ }
51
+
52
+ const flush = () =>
53
+ act(async () => {
54
+ await new Promise((resolve) => setTimeout(resolve, 0));
55
+ });
56
+
57
+ const target = { kind: "Pod", group: "", namespace: "shop", name: "cart-0" };
58
+ const atCapacity = () =>
59
+ new DiagnoseError(409, "3 investigations are already running.", {
60
+ code: "investigations_at_capacity",
61
+ limit: 3,
62
+ context: "cluster-a",
63
+ });
64
+
65
+ beforeEach(async () => {
66
+ api.createRun.mockReset();
67
+ localStorage.clear();
68
+ const element = document.createElement("div");
69
+ document.body.appendChild(element);
70
+ root = createRoot(element);
71
+ await act(async () =>
72
+ root.render(
73
+ <DiagnoseProvider browserURLState={false}>
74
+ <Probe />
75
+ </DiagnoseProvider>,
76
+ ),
77
+ );
78
+ await flush();
79
+ });
80
+
81
+ afterEach(async () => {
82
+ await act(async () => root.unmount());
83
+ document.body.replaceChildren();
84
+ });
85
+
86
+ describe("a start refused at capacity", () => {
87
+ it("keeps the refused start so it can be retried", async () => {
88
+ api.createRun.mockRejectedValue(atCapacity());
89
+ await act(async () => probe.d.openInvestigation(target));
90
+ await flush();
91
+ // The start is bound to the cluster it was made in, so a retry can't
92
+ // land on a same-named resource elsewhere.
93
+ expect(probe.d.startCapacity).toEqual({
94
+ target: { ...target, context: "cluster-a" },
95
+ limit: 3,
96
+ context: "cluster-a",
97
+ });
98
+ expect(probe.d.startRefusal).toBeNull();
99
+ });
100
+
101
+ it("does not take over a run the user opened while it was in flight", async () => {
102
+ let refuse!: () => void;
103
+ api.createRun.mockReturnValue(
104
+ new Promise((_, reject) => (refuse = () => reject(atCapacity()))),
105
+ );
106
+ await act(async () => probe.d.openInvestigation(target));
107
+ await act(async () => probe.d.openRun("run-other"));
108
+ await act(async () => refuse());
109
+ await flush();
110
+ expect(probe.d.startCapacity).toBeNull();
111
+ expect(probe.d.activeRunId).toBe("run-other");
112
+ });
113
+ });
@@ -0,0 +1,245 @@
1
+ // @vitest-environment jsdom
2
+ import { act } from "react";
3
+ import { createRoot, type Root } from "react-dom/client";
4
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
5
+
6
+ import { DiagnoseError } from "../../api/diagnose";
7
+ import {
8
+ DiagnoseProvider,
9
+ useDiagnose,
10
+ useDiagnoseLayout,
11
+ } from "./DiagnoseContext";
12
+ import { runTargetKey } from "./target";
13
+
14
+ const api = vi.hoisted(() => ({
15
+ createRun: vi.fn(),
16
+ recordConsent: vi.fn(),
17
+ consented: {} as Record<string, boolean>,
18
+ runs: [] as unknown[],
19
+ }));
20
+
21
+ vi.mock("../../api/diagnose", async (importOriginal) => ({
22
+ ...(await importOriginal<object>()),
23
+ fetchAgents: async () => ({
24
+ enabled: true,
25
+ eligible: true,
26
+ consented: api.consented,
27
+ agents: [
28
+ {
29
+ name: "claude",
30
+ label: "Claude Code",
31
+ path: "/bin/claude",
32
+ version: "",
33
+ present: true,
34
+ supported: true,
35
+ profiles: ["safeguarded"],
36
+ consentSurfaces: { safeguarded: "claude:safeguarded" },
37
+ questions: true,
38
+ },
39
+ ],
40
+ }),
41
+ listRuns: async () => ({ runs: api.runs }),
42
+ getRun: vi.fn(),
43
+ createRun: api.createRun,
44
+ recordConsent: api.recordConsent,
45
+ }));
46
+
47
+ const cluster = vi.hoisted(() => ({ name: "cluster-a" as string | undefined }));
48
+ vi.mock("../../api/client", async (importOriginal) => ({
49
+ ...(await importOriginal<object>()),
50
+ useContexts: () => ({
51
+ data: cluster.name ? [{ name: cluster.name, isCurrent: true }] : undefined,
52
+ }),
53
+ }));
54
+
55
+ Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
56
+ let root: Root;
57
+ let diagnose: ReturnType<typeof useDiagnose>;
58
+ let layout: ReturnType<typeof useDiagnoseLayout>;
59
+
60
+ function capture(seenDiagnose: typeof diagnose, seenLayout: typeof layout) {
61
+ diagnose = seenDiagnose;
62
+ layout = seenLayout;
63
+ }
64
+
65
+ function Probe() {
66
+ capture(useDiagnose(), useDiagnoseLayout());
67
+ return null;
68
+ }
69
+
70
+ const flush = () =>
71
+ act(async () => {
72
+ await new Promise((resolve) => setTimeout(resolve, 0));
73
+ });
74
+
75
+ const question = {
76
+ kind: "",
77
+ group: "",
78
+ namespace: "",
79
+ name: "",
80
+ question: "checkout returns 502s",
81
+ namespaces: ["shop"],
82
+ lookBack: "1h",
83
+ fromComposer: true,
84
+ };
85
+
86
+ beforeEach(async () => {
87
+ api.createRun.mockReset();
88
+ api.recordConsent.mockReset();
89
+ api.consented = {};
90
+ api.runs = [];
91
+ cluster.name = "cluster-a";
92
+ localStorage.clear();
93
+ const element = document.createElement("div");
94
+ document.body.appendChild(element);
95
+ root = createRoot(element);
96
+ await act(async () =>
97
+ root.render(
98
+ <DiagnoseProvider browserURLState={false}>
99
+ <Probe />
100
+ </DiagnoseProvider>,
101
+ ),
102
+ );
103
+ await flush();
104
+ });
105
+
106
+ afterEach(async () => {
107
+ await act(async () => root.unmount());
108
+ document.body.replaceChildren();
109
+ });
110
+
111
+ describe("starting from a question", () => {
112
+ it("never starts a run whose consent was cancelled while being recorded", async () => {
113
+ let recorded!: () => void;
114
+ api.recordConsent.mockReturnValue(
115
+ new Promise<void>((resolve) => (recorded = resolve)),
116
+ );
117
+ await act(async () => diagnose.openInvestigation(question));
118
+ expect(diagnose.needsConsent).toBe(true);
119
+ await act(async () => diagnose.approveConsent());
120
+ await act(async () => diagnose.cancelConsent());
121
+ await act(async () => recorded());
122
+ await flush();
123
+ expect(api.createRun).not.toHaveBeenCalled();
124
+ expect(diagnose.questionDraft?.text).toBe("checkout returns 502s");
125
+ });
126
+
127
+ it("gives a refused start's question back to the composer", async () => {
128
+ api.consented = { "claude:safeguarded": true };
129
+ await act(async () => diagnose.recheckAgents());
130
+ api.createRun.mockRejectedValue(
131
+ new DiagnoseError(409, "too many investigations running"),
132
+ );
133
+ await act(async () => diagnose.openInvestigation(question));
134
+ await flush();
135
+ expect(diagnose.startError).toContain("too many");
136
+ expect(diagnose.questionDraft).toMatchObject({
137
+ text: "checkout returns 502s",
138
+ namespaces: ["shop"],
139
+ restore: true,
140
+ });
141
+ });
142
+
143
+ it("leaves a saved draft alone when a run is started from elsewhere", async () => {
144
+ api.consented = { "claude:safeguarded": true };
145
+ await act(async () => diagnose.recheckAgents());
146
+ await act(async () => diagnose.saveQuestionDraft({ text: "draft B" }));
147
+ api.createRun.mockRejectedValue(new DiagnoseError(409, "refused"));
148
+ await act(async () =>
149
+ diagnose.openInvestigation({ ...question, fromComposer: undefined }),
150
+ );
151
+ await flush();
152
+ expect(diagnose.questionDraft?.text).toBe("draft B");
153
+ });
154
+
155
+ it("hands back an explicit all-namespaces choice as it was", async () => {
156
+ api.consented = { "claude:safeguarded": true };
157
+ await act(async () => diagnose.recheckAgents());
158
+ api.createRun.mockRejectedValue(new DiagnoseError(409, "refused"));
159
+ await act(async () =>
160
+ diagnose.openInvestigation({ ...question, namespaces: [] }),
161
+ );
162
+ await flush();
163
+ expect(diagnose.questionDraft?.namespaces).toEqual([]);
164
+ });
165
+
166
+ it("points a resource's running indicator at the live run, a question run included", async () => {
167
+ const run = (id: string, question?: string) => ({
168
+ id,
169
+ kind: "Deployment",
170
+ group: "apps",
171
+ namespace: "shop",
172
+ name: "api",
173
+ context: "ctx",
174
+ status: "running",
175
+ question,
176
+ createdAt: "2026-10-28T09:00:00Z",
177
+ updatedAt: "2026-10-28T09:00:00Z",
178
+ });
179
+ const key = runTargetKey("Deployment", "shop", "api", "apps");
180
+ api.runs = [run("asked", "why?")];
181
+ await act(async () => diagnose.refreshRuns());
182
+ await flush();
183
+ expect(layout.runningRunIds.get(key)).toBe("asked");
184
+ api.runs = [run("asked", "why?"), run("plain")];
185
+ await act(async () => diagnose.refreshRuns());
186
+ await flush();
187
+ expect(layout.runningRunIds.get(key)).toBe("plain");
188
+ });
189
+
190
+ it("drops a start waiting on consent when the cluster changes", async () => {
191
+ let recorded!: () => void;
192
+ api.recordConsent.mockReturnValue(
193
+ new Promise<void>((resolve) => (recorded = resolve)),
194
+ );
195
+ await act(async () =>
196
+ diagnose.openInvestigation({
197
+ ...question,
198
+ kind: "Deployment",
199
+ group: "apps",
200
+ namespace: "shop",
201
+ name: "api",
202
+ }),
203
+ );
204
+ expect(diagnose.needsConsent).toBe(true);
205
+ await act(async () => diagnose.approveConsent());
206
+ cluster.name = "cluster-b";
207
+ await act(async () =>
208
+ root.render(
209
+ <DiagnoseProvider browserURLState={false}>
210
+ <Probe />
211
+ </DiagnoseProvider>,
212
+ ),
213
+ );
214
+ await act(async () => recorded());
215
+ await flush();
216
+ expect(diagnose.needsConsent).toBe(false);
217
+ expect(api.createRun).not.toHaveBeenCalled();
218
+ expect(diagnose.questionDraft).toMatchObject({
219
+ text: "checkout returns 502s",
220
+ context: "cluster-a",
221
+ });
222
+ });
223
+
224
+ it("protects a start opened before the cluster was known", async () => {
225
+ const rerender = () =>
226
+ act(async () =>
227
+ root.render(
228
+ <DiagnoseProvider browserURLState={false}>
229
+ <Probe />
230
+ </DiagnoseProvider>,
231
+ ),
232
+ );
233
+ cluster.name = undefined;
234
+ await rerender();
235
+ await act(async () => diagnose.openInvestigation(question));
236
+ expect(diagnose.needsConsent).toBe(true);
237
+ cluster.name = "cluster-a";
238
+ await rerender();
239
+ cluster.name = "cluster-b";
240
+ await rerender();
241
+ await flush();
242
+ expect(diagnose.needsConsent).toBe(false);
243
+ expect(diagnose.questionDraft?.context).toBe("cluster-a");
244
+ });
245
+ });