@skyhook-io/radar-app 1.18.2 → 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 (78) hide show
  1. package/package.json +4 -4
  2. package/src/App.tsx +0 -1
  3. package/src/api/diagnose.test.ts +33 -2
  4. package/src/api/diagnose.ts +93 -3
  5. package/src/api/radarFeatures.ts +1 -0
  6. package/src/components/diagnose/AIMarkdown.tsx +1 -1
  7. package/src/components/diagnose/ActivityTurn.tsx +34 -14
  8. package/src/components/diagnose/AgentControls.tsx +53 -6
  9. package/src/components/diagnose/AgentSetupNotice.tsx +1 -1
  10. package/src/components/diagnose/AgentSigninNotice.test.tsx +98 -0
  11. package/src/components/diagnose/AgentSigninNotice.tsx +61 -0
  12. package/src/components/diagnose/AnalysisStory.test.tsx +22 -0
  13. package/src/components/diagnose/AnalysisStory.tsx +17 -4
  14. package/src/components/diagnose/AssessmentCard.tsx +39 -8
  15. package/src/components/diagnose/DiagnoseContext.capacity.test.tsx +113 -0
  16. package/src/components/diagnose/DiagnoseContext.question.test.tsx +245 -0
  17. package/src/components/diagnose/DiagnoseContext.tsx +205 -9
  18. package/src/components/diagnose/DiagnoseSurface.test.tsx +54 -0
  19. package/src/components/diagnose/DiagnoseSurface.tsx +93 -21
  20. package/src/components/diagnose/EvidenceCard.tsx +67 -14
  21. package/src/components/diagnose/Home.test.tsx +182 -5
  22. package/src/components/diagnose/Home.tsx +168 -36
  23. package/src/components/diagnose/InvestigationCapacityNotice.test.tsx +246 -0
  24. package/src/components/diagnose/InvestigationCapacityNotice.tsx +241 -0
  25. package/src/components/diagnose/InvestigationEvidencePane.story.test.tsx +97 -6
  26. package/src/components/diagnose/InvestigationEvidencePane.test.tsx +57 -0
  27. package/src/components/diagnose/InvestigationEvidencePane.tsx +59 -11
  28. package/src/components/diagnose/InvestigationEvidenceSections.tsx +5 -1
  29. package/src/components/diagnose/InvestigationView.tsx +156 -29
  30. package/src/components/diagnose/LocalDiagnoseAction.tsx +23 -16
  31. package/src/components/diagnose/QuestionComposer.test.tsx +553 -0
  32. package/src/components/diagnose/QuestionComposer.tsx +487 -0
  33. package/src/components/diagnose/QuestionFocus.test.tsx +38 -0
  34. package/src/components/diagnose/QuestionFocus.tsx +123 -0
  35. package/src/components/diagnose/ResourcePicker.tsx +206 -0
  36. package/src/components/diagnose/StoryExcerpt.tsx +12 -3
  37. package/src/components/diagnose/assessmentCopy.ts +5 -0
  38. package/src/components/diagnose/investigationCase.runs.test.tsx +328 -0
  39. package/src/components/diagnose/investigationCase.ts +33 -1
  40. package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +46 -0
  41. package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +8 -0
  42. package/src/components/diagnose/investigationEvidence/adapters/posture.ts +29 -1
  43. package/src/components/diagnose/investigationEvidence/adapters/prometheus.test.ts +40 -0
  44. package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +27 -1
  45. package/src/components/diagnose/investigationEvidence/bodies/metrics.test.tsx +111 -0
  46. package/src/components/diagnose/investigationEvidence/bodies/metrics.tsx +67 -16
  47. package/src/components/diagnose/investigationEvidence/excerpt.test.ts +18 -5
  48. package/src/components/diagnose/investigationEvidence/excerpt.ts +22 -11
  49. package/src/components/diagnose/investigationEvidence/index.ts +1 -1
  50. package/src/components/diagnose/investigationEvidence/navigation.tsx +2 -0
  51. package/src/components/diagnose/investigationEvidence/types.ts +2 -0
  52. package/src/components/diagnose/investigationEvidencePartition.ts +6 -1
  53. package/src/components/diagnose/investigationFocus.test.ts +271 -0
  54. package/src/components/diagnose/investigationFocus.ts +132 -0
  55. package/src/components/diagnose/parts.test.tsx +20 -0
  56. package/src/components/diagnose/questionSuggestions.test.ts +111 -0
  57. package/src/components/diagnose/questionSuggestions.ts +150 -0
  58. package/src/components/diagnose/storyParts.test.tsx +13 -0
  59. package/src/components/diagnose/target.test.ts +143 -2
  60. package/src/components/diagnose/target.ts +109 -7
  61. package/src/components/diagnose/testdata/story-runs.json +474 -0
  62. package/src/components/diagnose/verdictText.test.tsx +87 -0
  63. package/src/components/diagnose/verdictText.ts +68 -0
  64. package/src/components/home/ClusterHealthCard.tsx +13 -39
  65. package/src/components/home/HomeAgentBlock.test.tsx +113 -0
  66. package/src/components/home/HomeAgentBlock.tsx +94 -0
  67. package/src/components/home/HomeView.tsx +5 -6
  68. package/src/components/home/RadarVersionLine.test.tsx +0 -14
  69. package/src/components/home/RadarVersionLine.tsx +3 -28
  70. package/src/components/ui/Omnibar.investigate.test.tsx +105 -0
  71. package/src/components/ui/Omnibar.tsx +47 -3
  72. package/src/components/ui/RadarOmnibar.test.tsx +1 -0
  73. package/src/components/ui/RadarOmnibar.tsx +11 -0
  74. package/src/components/whats-new/WhatsNewDialog.test.tsx +3 -3
  75. package/src/components/whats-new/releaseNotes.ts +60 -1
  76. package/src/hooks/useAgentSignin.test.tsx +190 -0
  77. package/src/hooks/useAgentSignin.ts +160 -0
  78. package/src/hooks/useApproveAfterSignin.test.tsx +108 -0
@@ -113,10 +113,19 @@ import {
113
113
  } from "./InvestigationEvidencePane";
114
114
  import { partitionInvestigationEvidence } from "./investigationEvidencePartition";
115
115
  import type { DiagnosisResourceRef } from "./diagnoseEvidenceTypes";
116
- import { formatInvestigationTarget } from "./target";
116
+ import { QuestionFocus } from "./QuestionFocus";
117
+ import { focusFromCase } from "./investigationFocus";
118
+ import {
119
+ formatInvestigationTarget,
120
+ formatInvestigationTitle,
121
+ isQuestionOnly,
122
+ questionAskedAt,
123
+ rerunOpening,
124
+ } from "./target";
117
125
  import { parseContextName } from "../../utils/context-name";
118
126
  import type { InvestigationSourceExcerpt } from "./investigationSourceFocus";
119
127
  import { diagnosisHasStoryShape } from "./investigationStory";
128
+ import { assessmentStateLabel, verdictSentence } from "./verdictText";
120
129
  import { assessmentLimitLines } from "./investigationEvidencePresentation";
121
130
 
122
131
  const RECHECK_QUESTION =
@@ -272,6 +281,47 @@ function captureEvidenceCardLayout(container: HTMLElement) {
272
281
 
273
282
  const APPLY_WRITES: GitOpsWrite[] = [{ scope: "spec", description: "The proposed change" }];
274
283
 
284
+ // The card that ends a finished turn in Activity says what was found, so the
285
+ // reader learns the answer before deciding to open Findings. It carries the
286
+ // same qualifications Findings puts beside the sentence (how sure, whether an
287
+ // apply or newer reads have overtaken it), so it never reads more settled
288
+ // than Findings does. A long verdict is cut at three lines; one with no
289
+ // sentence keeps the generic description.
290
+ function CompletionSummary({
291
+ label,
292
+ state,
293
+ sentence,
294
+ }: {
295
+ label: string;
296
+ state?: { text: string; warn: boolean };
297
+ sentence: string;
298
+ }) {
299
+ return (
300
+ <span className="min-w-0 flex-1">
301
+ <span className="block text-xs text-theme-text-tertiary">
302
+ {label}
303
+ {state ? (
304
+ <>
305
+ {" · "}
306
+ <span className={state.warn ? "text-warning-text" : undefined}>
307
+ {state.text}
308
+ </span>
309
+ </>
310
+ ) : null}
311
+ </span>
312
+ {sentence ? (
313
+ <span className="mt-0.5 line-clamp-3 text-sm font-medium leading-snug text-theme-text-primary [overflow-wrap:anywhere]">
314
+ {sentence}
315
+ </span>
316
+ ) : (
317
+ <span className="block text-xs text-theme-text-secondary">
318
+ Assessment, evidence and next steps
319
+ </span>
320
+ )}
321
+ </span>
322
+ );
323
+ }
324
+
275
325
  export function InvestigationView({
276
326
  run,
277
327
  agentLabel,
@@ -294,6 +344,7 @@ export function InvestigationView({
294
344
  const {
295
345
  refreshRuns,
296
346
  openInvestigation,
347
+ openQuestion,
297
348
  startError,
298
349
  startRefusal,
299
350
  dismissError,
@@ -303,25 +354,15 @@ export function InvestigationView({
303
354
  // the picker's: a reopened run keeps the backend it was made with.
304
355
  const runAgent = agents.find((agent) => agent.name === run.agent);
305
356
  const explanationEnabled = supportsAssessmentExplanation(runAgent);
306
- const canApply = runAgent?.apply === true;
357
+ // A question-only run has no resource to bind a confirmed fix to.
358
+ const canApply = runAgent?.apply === true && !isQuestionOnly(run);
307
359
  // Read through a ref by the stream callback, which lives as long as the
308
360
  // run and would otherwise keep the value from before the agents loaded.
309
361
  const verifiesAfterApplyRef = useRef(false);
310
362
  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
363
  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],
364
+ () => openInvestigation(rerunOpening(run)),
365
+ [openInvestigation, run],
325
366
  );
326
367
  const queryClient = useQueryClient();
327
368
  const [turns, setTurns] = useState<Turn[]>([]);
@@ -1181,11 +1222,24 @@ export function InvestigationView({
1181
1222
  : undefined,
1182
1223
  [currentAssessment, currentAssessmentIdx, projection],
1183
1224
  );
1225
+ const questionOnly = isQuestionOnly(run);
1226
+ const questionFocus = useMemo(
1227
+ () => (questionOnly ? focusFromCase(investigationCase) : []),
1228
+ [questionOnly, investigationCase],
1229
+ );
1184
1230
  // Findings is the newest assessment and nothing else: its own citations,
1185
1231
  // its own case, its own story. Earlier assessments stay complete in
1186
1232
  // Activity; answers that did not revise the assessment stay there too.
1187
1233
  const paneResolution = rootCauseEvidenceResolution;
1188
1234
  const storyShape = diagnosisHasStoryShape(currentAssessment?.diagnosis);
1235
+ // A run that stopped without an assessment will never cite anything, so
1236
+ // what it collected is all there is to show.
1237
+ const assessmentPending = !currentAssessment?.diagnosis;
1238
+ const showUncited =
1239
+ assessmentPending &&
1240
+ !busy &&
1241
+ run.status !== "running" &&
1242
+ run.status !== "stopping";
1189
1243
  const visibleEvidenceGroupIds = useMemo(
1190
1244
  () =>
1191
1245
  new Set(
@@ -1194,9 +1248,16 @@ export function InvestigationView({
1194
1248
  paneResolution,
1195
1249
  investigationCase,
1196
1250
  storyShape,
1251
+ showUncited,
1197
1252
  ).collectionByGroup.keys(),
1198
1253
  ),
1199
- [projection.groups, paneResolution, investigationCase, storyShape],
1254
+ [
1255
+ projection.groups,
1256
+ paneResolution,
1257
+ investigationCase,
1258
+ storyShape,
1259
+ showUncited,
1260
+ ],
1200
1261
  );
1201
1262
  const evidenceStepIdsByTurn = useMemo(
1202
1263
  () =>
@@ -1616,7 +1677,8 @@ export function InvestigationView({
1616
1677
  .slice(0, 3);
1617
1678
  return {
1618
1679
  context: {
1619
- target: formatInvestigationTarget(run),
1680
+ target: formatInvestigationTitle(run),
1681
+ asked: isQuestionOnly(run) ? undefined : run.question,
1620
1682
  cluster: run.context,
1621
1683
  startedAt: run.createdAt,
1622
1684
  agent: agentLabel,
@@ -1861,7 +1923,9 @@ export function InvestigationView({
1861
1923
  ? assessmentNeedsCurrentStateVerification
1862
1924
  ? "Proposed before the apply attempt. Current state has not been verified."
1863
1925
  : "Proposed before the latest evidence. Reassess before applying."
1864
- : undefined
1926
+ : questionOnly
1927
+ ? "To apply a fix, investigate the resource it changes from Focused on above."
1928
+ : undefined
1865
1929
  }
1866
1930
  onApply={
1867
1931
  canOfferInvestigationApply({
@@ -2117,6 +2181,11 @@ export function InvestigationView({
2117
2181
  turn={turn}
2118
2182
  agentLabel={agentLabel}
2119
2183
  turnIndex={index}
2184
+ openingQuestion={
2185
+ index === 0 && !turn.question
2186
+ ? run.question
2187
+ : undefined
2188
+ }
2120
2189
  evidenceStepIds={evidenceStepIdsByTurn.get(index)}
2121
2190
  onViewEvidence={viewEvidenceSource}
2122
2191
  sourceRevealRequest={activityRevealRequest}
@@ -2227,16 +2296,35 @@ export function InvestigationView({
2227
2296
  <Files className="h-4 w-4" />
2228
2297
  )}
2229
2298
  </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>
2299
+ <CompletionSummary
2300
+ label={
2301
+ assessmentNeedsCurrentStateVerification
2302
+ ? "Assessment before apply"
2303
+ : hasEvidenceCollectedAfterAssessment
2304
+ ? "Earlier assessment"
2305
+ : turn.verify
2306
+ ? "Verification complete"
2307
+ : "Assessment ready"
2308
+ }
2309
+ state={
2310
+ assessmentNeedsCurrentStateVerification
2311
+ ? {
2312
+ text: "Current state unverified",
2313
+ warn: true,
2314
+ }
2315
+ : turn.diagnosis
2316
+ ? assessmentStateLabel(
2317
+ turn.diagnosis,
2318
+ currentAssessmentEvidenceConflict,
2319
+ )
2320
+ : undefined
2321
+ }
2322
+ sentence={
2323
+ turn.diagnosis
2324
+ ? verdictSentence(turn.diagnosis)
2325
+ : ""
2326
+ }
2327
+ />
2240
2328
  <span className="inline-flex shrink-0 items-center gap-1 text-xs font-medium text-accent-text">
2241
2329
  View Findings
2242
2330
  <ArrowRight className="h-3.5 w-3.5 transition-transform group-hover:translate-x-0.5" />
@@ -2379,9 +2467,11 @@ export function InvestigationView({
2379
2467
  className="investigation-assessment rounded-xl border p-3"
2380
2468
  >
2381
2469
  <div className="flex flex-wrap items-center gap-1.5">
2470
+ {/* A label for the block, not its headline: the
2471
+ verdict sentence below is what a reader looks for. */}
2382
2472
  <h2
2383
2473
  id={`${viewId}-assessment-heading`}
2384
- className="text-lg font-semibold text-theme-text-primary"
2474
+ className="text-sm font-medium text-theme-text-secondary"
2385
2475
  >
2386
2476
  {assessmentNeedsCurrentStateVerification
2387
2477
  ? "Assessment before apply"
@@ -2536,6 +2626,40 @@ export function InvestigationView({
2536
2626
  ) : null}
2537
2627
  </section>
2538
2628
 
2629
+ {questionOnly && investigationCase ? (
2630
+ <QuestionFocus
2631
+ focus={questionFocus}
2632
+ stale={stale}
2633
+ onOpenResource={onOpenResource}
2634
+ // These start a new investigation, so a run that can
2635
+ // no longer take follow-ups doesn't block them.
2636
+ disabled={investigationInteractionsBlocked({
2637
+ streamReady,
2638
+ busy,
2639
+ requestPending,
2640
+ readOnly: false,
2641
+ verificationPending,
2642
+ })}
2643
+ onChooseResource={() =>
2644
+ openQuestion({
2645
+ text: run.question,
2646
+ namespaces: run.namespaces,
2647
+ lookBack: run.lookBack,
2648
+ askedAt: questionAskedAt(run),
2649
+ pickResource: true,
2650
+ })
2651
+ }
2652
+ onInvestigate={(resource) =>
2653
+ openInvestigation({
2654
+ ...resource,
2655
+ question: run.question,
2656
+ lookBack: run.lookBack,
2657
+ askedAt: questionAskedAt(run),
2658
+ })
2659
+ }
2660
+ />
2661
+ ) : null}
2662
+
2539
2663
  {hasMultipleAssessments ? (
2540
2664
  <button
2541
2665
  type="button"
@@ -2556,6 +2680,9 @@ export function InvestigationView({
2556
2680
 
2557
2681
  <InvestigationEvidencePane
2558
2682
  projection={projection}
2683
+ withoutTarget={questionOnly}
2684
+ assessmentPending={assessmentPending}
2685
+ showUncited={showUncited}
2559
2686
  rootCauseEvidence={paneResolution}
2560
2687
  investigationCase={investigationCase}
2561
2688
  story={
@@ -4,7 +4,7 @@ import {
4
4
  useDiagnose,
5
5
  useDiagnoseLayout,
6
6
  } from "./DiagnoseContext";
7
- import { runTargetKey } from "./target";
7
+ import { canonicalKind, runTargetKey } from "./target";
8
8
  import { Tooltip } from "../ui/Tooltip";
9
9
  import type { RenderDiagnoseAction } from "../../context/DiagnoseCustomization";
10
10
 
@@ -34,15 +34,17 @@ function DiagnoseResourceButton({
34
34
  health?: "problem" | "healthy" | "unknown";
35
35
  }) {
36
36
  const d = useDiagnose();
37
- const { runningKeys } = useDiagnoseLayout();
37
+ const { runningRunIds } = useDiagnoseLayout();
38
38
  // Hidden only when the feature can't work here (auth/cloud/--no-mcp). When it's
39
39
  // supported but no agent is installed we KEEP the button — clicking opens the
40
40
  // setup notice so the feature is discoverable rather than silently absent.
41
41
  if (d.setupState === "off" || d.setupState === "unknown") return null;
42
42
  const ready = d.available;
43
43
  const problem = health === "problem";
44
- const running =
45
- ready && runningKeys.has(runTargetKey(kind, namespace, name, group ?? ""));
44
+ const runningRunId = ready
45
+ ? runningRunIds.get(runTargetKey(kind, namespace, name, group ?? ""))
46
+ : undefined;
47
+ const running = !!runningRunId;
46
48
  const tooltip = !ready
47
49
  ? notReadyTooltip(d)
48
50
  : running
@@ -53,23 +55,28 @@ function DiagnoseResourceButton({
53
55
  : `Ask ${d.agentLabel} about this resource — reads its spec, events & logs.`
54
56
  : problem
55
57
  ? `Investigate with your own ${d.agentLabel} — runs locally and reads this resource's spec, events & logs.`
56
- : `Ask your own ${d.agentLabel} about this resource — runs locally, reads its spec, events & logs.`;
58
+ : d.questions
59
+ ? `Ask your own ${d.agentLabel} a question about this resource — runs locally, reads its spec, events & logs.`
60
+ : `Ask your own ${d.agentLabel} about this resource — runs locally, reads its spec, events & logs.`;
57
61
  // While an investigation is live, the button advertises it (and clicking focuses
58
62
  // the existing run rather than starting a new one — openInvestigation dedups).
59
63
  const showLabel = problem || running;
64
+ const asks = d.questions && !problem && !running;
60
65
  return (
61
66
  <Tooltip content={tooltip} position="bottom">
62
67
  <button
63
- onClick={() =>
64
- ready
65
- ? d.openInvestigation({
66
- kind,
67
- group: group ?? "",
68
- namespace,
69
- name,
70
- })
71
- : d.openHome()
72
- }
68
+ onClick={() => {
69
+ const target = { kind, group: group ?? "", namespace, name };
70
+ if (!ready) d.openHome();
71
+ else if (runningRunId) d.openRun(runningRunId);
72
+ // Asking about a resource with no live problem means saying what
73
+ // to ask; a problem, or a run already live, opens straight away.
74
+ else if (asks)
75
+ d.openQuestion({
76
+ pin: { ...target, kind: canonicalKind(kind, group ?? "") },
77
+ });
78
+ else d.openInvestigation(target);
79
+ }}
73
80
  aria-label={
74
81
  !ready
75
82
  ? notReadyTooltip(d)
@@ -163,7 +170,7 @@ export function IssueDiagnoseButton({
163
170
 
164
171
  // The tooltip every AI entry point shows while investigations aren't runnable.
165
172
  // It gives the same reason as the setup notice the button opens.
166
- function notReadyTooltip(d: {
173
+ export function notReadyTooltip(d: {
167
174
  cliOverride: boolean;
168
175
  setupState: DiagnoseSetup;
169
176
  }): string {