@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
@@ -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",
@@ -81,7 +81,7 @@ describe("RecentList", () => {
81
81
  const html = render([run()]);
82
82
  expect(html.match(/<button\b/g)).toHaveLength(1);
83
83
  expect(html).not.toContain('title="');
84
- expect(html).toContain('aria-label="Deployment.apps shop/checkout');
84
+ expect(html).toContain('aria-label="Deployment shop/checkout');
85
85
  expect(html).toContain('aria-label="Cluster: nonprod"');
86
86
  });
87
87
  it("uses cluster identity instead of lifecycle locks and deterministic initial-issue text", () => {
@@ -103,7 +103,45 @@ describe("RecentList", () => {
103
103
  expect(html).not.toContain("lucide-lock");
104
104
  expect(html).not.toContain("lucide-check");
105
105
  });
106
- it("uses one stable start time per run, sorted into local date groups without previews", () => {
106
+ it("groups older history into this week and earlier, dating each older row", () => {
107
+ const html = render([
108
+ run({ id: "today", name: "today", createdAt: time(2, 9) }),
109
+ run({ id: "week", name: "week", createdAt: time(1 - 3, 9) }),
110
+ run({
111
+ id: "old",
112
+ name: "old",
113
+ createdAt: new Date(2026, 6, 4, 18, 5).toISOString(),
114
+ }),
115
+ ]);
116
+ const text = visible(html);
117
+ expect(
118
+ html.match(/<h3 [^>]*>(Today|Yesterday|Previous 7 days|Earlier)<\/h3>/g),
119
+ ).toHaveLength(3);
120
+ expect(html).toContain(">Previous 7 days</h3>");
121
+ expect(html).toContain(">Earlier</h3>");
122
+ const day = (d: Date) =>
123
+ d.toLocaleDateString(undefined, { month: "short", day: "numeric" });
124
+ expect(text).toContain(`${day(new Date(2026, 6, 4))} · `);
125
+ expect(text).not.toContain(`${day(NOW)} · `);
126
+ });
127
+ it("shows the issue a run started with only until it has a finding", () => {
128
+ const html = render([
129
+ run({
130
+ id: "a",
131
+ name: "found",
132
+ health: { topReason: "ErrImagePull" },
133
+ preview: "A direct edit set a bad tag.",
134
+ }),
135
+ run({
136
+ id: "b",
137
+ name: "pending",
138
+ health: { topReason: "CrashLoopBackOff" },
139
+ }),
140
+ ]);
141
+ expect(html).not.toContain("Started with ErrImagePull");
142
+ expect(html).toContain("Started with CrashLoopBackOff");
143
+ });
144
+ it("uses one stable start time per run, sorted into local date groups, with what each found", () => {
107
145
  const recentTime = time(2, 13);
108
146
  const olderTime = time(1, 12);
109
147
  const html = render([
@@ -112,7 +150,8 @@ describe("RecentList", () => {
112
150
  id: "recent",
113
151
  name: "recent",
114
152
  createdAt: recentTime,
115
- preview: "MONGO_PASSWORD **broken**",
153
+ preview:
154
+ "MONGO_PASSWORD **broken**, see [the runbook](https://example.com/rb) and _why_",
116
155
  }),
117
156
  ]);
118
157
  expect(html.match(/<time /g)).toHaveLength(2);
@@ -120,7 +159,10 @@ describe("RecentList", () => {
120
159
  expect(html).toContain(`dateTime="${olderTime}"`);
121
160
  expect(html).not.toContain(`dateTime="${time(2, 14)}"`);
122
161
  expect(html).not.toContain("ago");
123
- expect(html).not.toContain("MONGO_PASSWORD");
162
+ expect(visible(html)).toContain(
163
+ "MONGO_PASSWORD broken, see the runbook and why",
164
+ );
165
+ expect(html).not.toContain("**");
124
166
  expect(html).toContain(">Today</h3>");
125
167
  expect(html).toContain(">Yesterday</h3>");
126
168
  expect(visible(html).indexOf("recent")).toBeLessThan(
@@ -171,7 +213,7 @@ describe("RecentList", () => {
171
213
  expect(text.indexOf("checkout")).toBeLessThan(
172
214
  text.indexOf("shop · Deployment"),
173
215
  );
174
- expect(html).toContain("Deployment.apps shop/checkout");
216
+ expect(html).toContain("Deployment shop/checkout");
175
217
  });
176
218
 
177
219
  it("does not change displayed time when cluster-switch bookkeeping updates runs", () => {
@@ -311,3 +353,138 @@ describe("InvestigationHome", () => {
311
353
  expect(html).not.toContain("textarea");
312
354
  });
313
355
  });
356
+
357
+ describe("RecentList question runs", () => {
358
+ it("titles a question-only run by its question and shows where it started", () => {
359
+ const html = visible(
360
+ render([
361
+ run({
362
+ kind: "",
363
+ group: "",
364
+ namespace: "",
365
+ name: "",
366
+ question: "checkout returns 502s",
367
+ namespaces: ["shop"],
368
+ lookBack: "1h",
369
+ }),
370
+ ]),
371
+ );
372
+ expect(html).toContain("checkout returns 502s");
373
+ expect(html).toContain("shop · last 1h");
374
+ });
375
+
376
+ it("keeps a question about a resource under the resource, with what was asked", () => {
377
+ const html = visible(render([run({ question: "why did it restart?" })]));
378
+ expect(html).toContain("checkout");
379
+ expect(html).toContain("Asked: why did it restart?");
380
+ });
381
+ });
382
+
383
+ describe("RecentList loading", () => {
384
+ const renderState = (props: { loaded: boolean; loadFailed?: boolean }) =>
385
+ visible(
386
+ renderToStaticMarkup(
387
+ <RecentList
388
+ agentLabel="Codex"
389
+ runs={[]}
390
+ onSelect={() => {}}
391
+ onRetry={() => {}}
392
+ {...props}
393
+ />,
394
+ ),
395
+ );
396
+
397
+ it("never claims there are no investigations before the list arrives", () => {
398
+ expect(renderState({ loaded: false })).not.toContain(
399
+ "No investigations yet",
400
+ );
401
+ expect(
402
+ renderToStaticMarkup(
403
+ <RecentList
404
+ agentLabel="Codex"
405
+ runs={[]}
406
+ onSelect={() => {}}
407
+ loaded={false}
408
+ />,
409
+ ),
410
+ ).toContain('aria-label="Loading investigations"');
411
+ });
412
+
413
+ it("offers a retry when the first load failed", () => {
414
+ const text = renderState({ loaded: false, loadFailed: true });
415
+ expect(text).toContain("Couldn’t load investigations");
416
+ expect(text).toContain("Try again");
417
+ });
418
+
419
+ it("says there are none only after an empty answer", () => {
420
+ expect(renderState({ loaded: true })).toContain("No investigations yet");
421
+ });
422
+ });
423
+
424
+ describe("RecentList findings", () => {
425
+ it("shows what each run found under its title", () => {
426
+ const text = visible(
427
+ render([
428
+ run({
429
+ id: "a",
430
+ preview: "The `api` container exits on a missing **env** var",
431
+ }),
432
+ ]),
433
+ );
434
+ expect(text).toContain("The api container exits on a missing env var");
435
+ });
436
+
437
+ it("does not attribute a question-only run to an issue", () => {
438
+ const text = visible(
439
+ render([
440
+ run({
441
+ kind: "",
442
+ group: "",
443
+ namespace: "",
444
+ name: "",
445
+ question: "checkout is slow",
446
+ health: { topReason: "CrashLoopBackOff" } as RunSummary["health"],
447
+ }),
448
+ ]),
449
+ );
450
+ expect(text).not.toContain("Started with");
451
+ });
452
+ });
453
+
454
+ describe("RecentList beside the question composer", () => {
455
+ it("does not send people to a resource to start", () => {
456
+ const text = visible(
457
+ renderToStaticMarkup(
458
+ <RecentList
459
+ agentLabel="Codex"
460
+ runs={[]}
461
+ onSelect={() => {}}
462
+ questions
463
+ />,
464
+ ),
465
+ );
466
+ expect(text).toContain("No investigations yet");
467
+ expect(text).not.toContain("Open a resource");
468
+ });
469
+ });
470
+
471
+ describe("RecentList refresh failures", () => {
472
+ it("says a kept list is stale when a later refresh fails", () => {
473
+ const text = visible(
474
+ renderToStaticMarkup(
475
+ <RecentList
476
+ agentLabel="Codex"
477
+ runs={[run()]}
478
+ onSelect={() => {}}
479
+ loaded
480
+ loadFailed
481
+ onRetry={() => {}}
482
+ />,
483
+ ),
484
+ );
485
+ expect(text).toContain(
486
+ "Couldn’t refresh investigations; showing the last list.",
487
+ );
488
+ expect(text).toContain("checkout");
489
+ });
490
+ });