@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyhook-io/radar-app",
3
- "version": "1.18.2",
3
+ "version": "1.19.0",
4
4
  "description": "Radar's full web UI as a reusable React component. Used by Radar's own binary and by external consumers like Radar Cloud.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -58,7 +58,7 @@
58
58
  "@playwright/test": "^1.62.0",
59
59
  "@skyhook-io/k8s-ui": "*",
60
60
  "@tailwindcss/vite": "^4.3.3",
61
- "@tanstack/react-query": "^5.103.1",
61
+ "@tanstack/react-query": "^5.104.5",
62
62
  "@types/node": "^26.6.2",
63
63
  "@types/react": "^19.3.0",
64
64
  "@types/react-dom": "^19.3.0",
@@ -68,7 +68,7 @@
68
68
  "elkjs": "^0.11.1",
69
69
  "eslint": "^10.13.0",
70
70
  "eslint-plugin-react-hooks": "^7.1.1",
71
- "eslint-plugin-react-refresh": "^0.5.3",
71
+ "eslint-plugin-react-refresh": "^0.5.7",
72
72
  "globals": "^17.11.0",
73
73
  "lucide-react": "^1.48.0",
74
74
  "postcss": "^8.5.30",
@@ -79,7 +79,7 @@
79
79
  "tailwind-merge": "^3.7.0",
80
80
  "tailwindcss": "^4.3.3",
81
81
  "typescript": "^6.0.2",
82
- "typescript-eslint": "^8.71.0",
82
+ "typescript-eslint": "^8.72.0",
83
83
  "vite": "^8.3.4"
84
84
  },
85
85
  "sideEffects": [
package/src/App.tsx CHANGED
@@ -2109,7 +2109,6 @@ function AppInner({ manageDocumentTitle = false, documentTitleSuffix, onClusterL
2109
2109
  onNavigateToView={setMainView}
2110
2110
  onNavigateToHelmRelease={navCustomization.embedded ? undefined : navigateToHelmRelease}
2111
2111
  onNavigateToManagerPath={navCustomization.embedded || takeover.gitops ? undefined : navigateToPath}
2112
- onShowWhatsNew={!navCustomization.embedded && whatsNewStatus.available ? openWhatsNew : undefined}
2113
2112
  // Upgrade impact lives under /checks, which a Cloud host takes
2114
2113
  // over wholesale — its fleet pages have no upgrade sub-route, so
2115
2114
  // the version line stays plain text there.
@@ -4,6 +4,8 @@ import {
4
4
  createRun,
5
5
  DiagnoseError,
6
6
  fetchAgents,
7
+ investigationCapacity,
8
+ investigationRefusal,
7
9
  subscribeRun,
8
10
  type DiagnoseStreamEvent,
9
11
  } from "./diagnose";
@@ -315,6 +317,27 @@ describe("refused requests", () => {
315
317
  expect(e.action).toBe("upgrade");
316
318
  });
317
319
 
320
+ it("reads Radar's capacity refusal as recoverable, not a host refusal", async () => {
321
+ refuse(
322
+ 409,
323
+ JSON.stringify({
324
+ error: "3 investigations are already running.",
325
+ code: "investigations_at_capacity",
326
+ limit: 3,
327
+ context: "kind-dev",
328
+ }),
329
+ );
330
+ const e = await startError();
331
+ expect(e.message).toBe("3 investigations are already running.");
332
+ expect(investigationCapacity(e)).toEqual({ limit: 3, context: "kind-dev" });
333
+ expect(investigationRefusal(e)).toBeNull();
334
+ });
335
+
336
+ it("does not read other conflicts as capacity", async () => {
337
+ refuse(409, JSON.stringify({ error: "Codex isn't installed." }));
338
+ expect(investigationCapacity(await startError())).toBeNull();
339
+ });
340
+
318
341
  it("applies the same reading to follow-up turns", async () => {
319
342
  refuse(
320
343
  402,
@@ -360,9 +383,17 @@ describe("refused requests", () => {
360
383
  });
361
384
 
362
385
  it.each([
363
- ["an empty detail", JSON.stringify({ error: "Busy.", detail: "" }), "Busy."],
386
+ [
387
+ "an empty detail",
388
+ JSON.stringify({ error: "Busy.", detail: "" }),
389
+ "Busy.",
390
+ ],
364
391
  ["a non-JSON body", "upstream timeout", "request failed (502)"],
365
- ["no message at all", JSON.stringify({ error: " " }), "request failed (502)"],
392
+ [
393
+ "no message at all",
394
+ JSON.stringify({ error: " " }),
395
+ "request failed (502)",
396
+ ],
366
397
  ])("falls back past %s", async (_name, body, message) => {
367
398
  refuse(502, body);
368
399
  expect((await startError()).message).toBe(message);
@@ -19,6 +19,9 @@ export interface AgentInfo {
19
19
  apply?: boolean;
20
20
  /** The backend re-checks the resource after an Apply. Absent means it does not. */
21
21
  verification?: boolean;
22
+ /** The backend opens a run from a question, with or without a resource.
23
+ * Absent means it accepts only a resource. */
24
+ questions?: boolean;
22
25
  }
23
26
 
24
27
  export interface AgentsResponse {
@@ -239,6 +242,16 @@ export interface RunSummary {
239
242
  effort?: string;
240
243
  managedBy?: string; // GitOps/Helm owner of the target ("Argo CD"/"Flux"/"Helm"), for the Apply warning
241
244
  health?: ResourceHealthSignal;
245
+ /** The engineer's opening question, when the run started with one. A run
246
+ * with a question and an empty name has no resource. */
247
+ question?: string;
248
+ /** Where the question said to start looking; empty means the whole cluster. */
249
+ namespaces?: string[];
250
+ /** How far before the question the problem started: 15m, 1h, 6h or 24h. */
251
+ lookBack?: string;
252
+ /** When the question was first asked, when that was before this run
253
+ * started (a re-run or a narrowed run). */
254
+ askedAt?: string;
242
255
  status: "running" | "stopping" | "done" | "error" | "stopped" | "stale";
243
256
  sessionId?: string;
244
257
  preview?: string;
@@ -274,16 +287,51 @@ export async function fetchAgents(
274
287
  return { ...body, agents: body.agents ?? [] };
275
288
  }
276
289
 
290
+ /**
291
+ * What an agent CLI's own status command says about its sign-in. "unknown"
292
+ * covers agents Radar doesn't check, timeouts and unrecognized answers; only
293
+ * "signed-out" is acted on.
294
+ */
295
+ export interface AgentSigninStatus {
296
+ agent: string;
297
+ state: "signed-in" | "signed-out" | "unknown";
298
+ /** The command that signs the agent in; set only when signed out. */
299
+ signinCmd?: string;
300
+ }
301
+
302
+ // fetchAgentSignin asks the server to run the agent's status command for runs
303
+ // with this profile (cached briefly server-side). refresh discards that cache:
304
+ // the user's "check again".
305
+ export async function fetchAgentSignin(
306
+ agent: string,
307
+ profile: ExecutionProfile,
308
+ refresh: boolean,
309
+ signal?: AbortSignal,
310
+ ): Promise<AgentSigninStatus> {
311
+ const params = new URLSearchParams({ agent, profile });
312
+ if (refresh) params.set("refresh", "1");
313
+ const res = await fetch(`${getApiBase()}/agents/signin?${params}`, {
314
+ credentials: getCredentialsMode(),
315
+ headers: getAuthHeaders(),
316
+ signal,
317
+ });
318
+ if (!res.ok) throw new Error(`agent sign-in: ${res.status}`);
319
+ return res.json();
320
+ }
321
+
277
322
  /**
278
323
  * Why a host refused an investigation, and what would unblock it. Hosts that
279
324
  * meter investigations send these beside the sentence to show, so an embedding
280
- * app can offer the matching action. Radar's own backend never sends them.
325
+ * app can offer the matching action. Radar's own backend sends only
326
+ * INVESTIGATIONS_AT_CAPACITY, with limit.
281
327
  */
282
328
  export interface DiagnoseRefusal {
283
329
  /** Machine-readable code, e.g. "ai_quota_exhausted". */
284
330
  code?: string;
285
331
  reason?: string;
286
332
  action?: string;
333
+ limit?: number;
334
+ context?: string;
287
335
  }
288
336
 
289
337
  // The sentence to show is `detail` when a host sends one, else `error`. A
@@ -306,6 +354,11 @@ async function diagnoseError(res: Response): Promise<DiagnoseError> {
306
354
  code: str(body?.code) ?? (detail && error !== detail ? error : undefined),
307
355
  reason: str(body?.reason),
308
356
  action: str(body?.action),
357
+ limit:
358
+ typeof body?.limit === "number" && body.limit > 0
359
+ ? body.limit
360
+ : undefined,
361
+ context: str(body?.context),
309
362
  });
310
363
  }
311
364
 
@@ -315,13 +368,44 @@ export class DiagnoseError extends Error {
315
368
  code?: string;
316
369
  reason?: string;
317
370
  action?: string;
371
+ /** With INVESTIGATIONS_AT_CAPACITY: how many investigations run at once,
372
+ * and the cluster the start was refused in. */
373
+ limit?: number;
374
+ context?: string;
318
375
  constructor(status: number, message: string, refusal?: DiagnoseRefusal) {
319
376
  super(message);
320
377
  this.status = status;
321
378
  this.code = refusal?.code;
322
379
  this.reason = refusal?.reason;
323
380
  this.action = refusal?.action;
381
+ this.limit = refusal?.limit;
382
+ this.context = refusal?.context;
383
+ }
384
+ }
385
+
386
+ /** Code Radar sends when every investigation slot is taken. */
387
+ export const INVESTIGATIONS_AT_CAPACITY = "investigations_at_capacity";
388
+
389
+ export interface InvestigationCapacity {
390
+ /** How many investigations run at once. */
391
+ limit: number;
392
+ /** The cluster the start was refused in. */
393
+ context?: string;
394
+ }
395
+
396
+ /** Set when error is Radar refusing a start because every investigation slot
397
+ * is taken; otherwise null. */
398
+ export function investigationCapacity(
399
+ error: unknown,
400
+ ): InvestigationCapacity | null {
401
+ if (
402
+ !(error instanceof DiagnoseError) ||
403
+ error.code !== INVESTIGATIONS_AT_CAPACITY ||
404
+ !error.limit
405
+ ) {
406
+ return null;
324
407
  }
408
+ return { limit: error.limit, context: error.context };
325
409
  }
326
410
 
327
411
  /** A host's refusal of an investigation request, with what would unblock it. */
@@ -334,12 +418,14 @@ export interface InvestigationRefusal {
334
418
  action?: string;
335
419
  }
336
420
 
337
- /** The refusal a DiagnoseError carries, or null when the host sent none
338
- * (Radar's own backend never does). */
421
+ /** The refusal a DiagnoseError carries, or null when the host sent none.
422
+ * Radar's own capacity code is not a host refusal: the UI recovers from it
423
+ * itself (see investigationCapacity). */
339
424
  export function investigationRefusal(
340
425
  error: unknown,
341
426
  ): InvestigationRefusal | null {
342
427
  if (!(error instanceof DiagnoseError)) return null;
428
+ if (error.code === INVESTIGATIONS_AT_CAPACITY) return null;
343
429
  if (!error.code && !error.reason && !error.action) return null;
344
430
  return {
345
431
  status: error.status,
@@ -370,6 +456,10 @@ export async function createRun(
370
456
  // otherwise hand back for this target. Inert for Radar's own backend, which
371
457
  // only ever continues an in-flight run — and that one is never bypassed.
372
458
  fresh?: boolean;
459
+ question?: string;
460
+ namespaces?: string[];
461
+ lookBack?: string;
462
+ askedAt?: string;
373
463
  },
374
464
  opts?: {
375
465
  agent?: string;
@@ -44,6 +44,7 @@ export const RADAR_FEATURES = {
44
44
  serviceEndpointSlices: { label: 'Service EndpointSlice inventories', flag: 'serviceEndpointSlices', flagShippedWithEndpoint: true },
45
45
  trafficRecords: { label: 'Flow records for a graph selection', flag: 'trafficRecords', flagShippedWithEndpoint: true },
46
46
  helmSourceIdentity: { label: 'Helm source selection', flag: 'helmSourceIdentity', flagShippedWithEndpoint: true },
47
+ agentSigninCheck: { label: 'Agent sign-in checks', flag: 'agentSigninCheck', flagShippedWithEndpoint: true },
47
48
  } as const satisfies Record<string, RadarFeatureSpec>
48
49
 
49
50
  export type RadarFeature = keyof typeof RADAR_FEATURES
@@ -68,7 +68,7 @@ export function tidyFences(md: string): string {
68
68
 
69
69
  // Diagnosis output is dense with inline `code`; the shared chip's brand tint is
70
70
  // too loud at that density, so neutralize it (border/bg only) for this surface.
71
- const SOFT_INLINE_CODE =
71
+ export const SOFT_INLINE_CODE =
72
72
  "[&_.inline-code]:border-theme-border/60 [&_.inline-code]:bg-theme-base [&_.inline-code]:font-normal";
73
73
 
74
74
  // Markdown for agent-generated text — normalizes flaky fences + softens code.
@@ -242,8 +242,12 @@ export function TurnView({
242
242
  onViewEvidence,
243
243
  sourceRevealRequest,
244
244
  assessmentSources,
245
+ openingQuestion,
245
246
  }: {
246
247
  turn: Turn;
248
+ /** The question the run opened with, shown as the engineer's message on
249
+ * the opening turn (whose own question is empty by design). */
250
+ openingQuestion?: string;
247
251
  agentLabel?: string;
248
252
  onApply?: (fix: string) => void;
249
253
  onViewExplanation?: () => void;
@@ -304,6 +308,8 @@ export function TurnView({
304
308
  : "Plain-language explanation"}
305
309
  <span className="text-theme-text-tertiary">· View in Findings</span>
306
310
  </button>
311
+ ) : openingQuestion ? (
312
+ <QuestionBubble text={openingQuestion} />
307
313
  ) : (
308
314
  turn.question &&
309
315
  (turn.verify ? (
@@ -317,18 +323,7 @@ export function TurnView({
317
323
  </span>
318
324
  </div>
319
325
  ) : (
320
- <div className="flex justify-end">
321
- <div className="max-w-[85%]">
322
- {turn.actor && (
323
- <div className="mb-0.5 text-right text-[10px] text-theme-text-tertiary">
324
- {turn.actor}
325
- </div>
326
- )}
327
- <div className="rounded-lg rounded-br-sm bg-accent/10 px-3 py-1.5 text-sm text-theme-text-primary [overflow-wrap:anywhere]">
328
- {turn.question}
329
- </div>
330
- </div>
331
- </div>
326
+ <QuestionBubble text={turn.question} actor={turn.actor} />
332
327
  ))
333
328
  )}
334
329
  <Timeline
@@ -423,6 +418,23 @@ export function TurnView({
423
418
  );
424
419
  }
425
420
 
421
+ function QuestionBubble({ text, actor }: { text: string; actor?: string }) {
422
+ return (
423
+ <div className="flex justify-end">
424
+ <div className="max-w-[85%]">
425
+ {actor && (
426
+ <div className="mb-0.5 text-right text-[10px] text-theme-text-tertiary">
427
+ {actor}
428
+ </div>
429
+ )}
430
+ <div className="whitespace-pre-wrap rounded-lg rounded-br-sm bg-accent/10 px-3 py-1.5 text-sm text-theme-text-primary [overflow-wrap:anywhere]">
431
+ {text}
432
+ </div>
433
+ </div>
434
+ </div>
435
+ );
436
+ }
437
+
426
438
  export function Timeline({
427
439
  items,
428
440
  running,
@@ -1137,10 +1149,18 @@ function ToolResultDialog({
1137
1149
  };
1138
1150
  }, [open, display, language, theme]);
1139
1151
  return (
1140
- <DialogPortal ariaLabelledBy={titleId} open={open} onClose={onClose} className="w-[min(90vw,820px)]">
1152
+ <DialogPortal
1153
+ ariaLabelledBy={titleId}
1154
+ open={open}
1155
+ onClose={onClose}
1156
+ className="w-[min(90vw,820px)]"
1157
+ >
1141
1158
  <div className="flex items-center justify-between gap-3 border-b border-theme-border p-3">
1142
1159
  <div className="min-w-0">
1143
- <div id={titleId} className="truncate font-mono text-sm text-theme-text-primary">
1160
+ <div
1161
+ id={titleId}
1162
+ className="truncate font-mono text-sm text-theme-text-primary"
1163
+ >
1144
1164
  {title}
1145
1165
  </div>
1146
1166
  {truncated && (
@@ -1,4 +1,4 @@
1
- import { useState } from "react";
1
+ import { useState, type ReactNode } from "react";
2
2
  import { AlertTriangle, Check, ShieldCheck, ChevronDown } from "lucide-react";
3
3
  import {
4
4
  TRANSITION_MENU,
@@ -420,11 +420,20 @@ function ConsentCardShell({
420
420
  approveLabel = "Approve & investigate",
421
421
  warning = false,
422
422
  error,
423
+ notice,
424
+ approveBusy = false,
425
+ subject,
423
426
  onOpenSettings,
424
427
  onApprove,
425
428
  onCancel,
426
429
  }: DiagnoseConsentCopy & {
427
430
  warning?: boolean;
431
+ // Something to know before approving, e.g. that the agent isn't signed in.
432
+ // It informs; Approve stays available.
433
+ notice?: ReactNode;
434
+ // Approve was pressed and waits on a check that hasn't answered yet.
435
+ approveBusy?: boolean;
436
+ subject?: ConsentSubject;
428
437
  // Why the last approval failed, straight from the server. The card stays up on
429
438
  // failure so retrying works in place, which means this is the ONLY chance to
430
439
  // say why — a host that records consent above the individual refuses the
@@ -458,6 +467,18 @@ function ConsentCardShell({
458
467
  {title}
459
468
  </div>
460
469
  </div>
470
+ {subject && (
471
+ <div className="mb-3 rounded-md border border-theme-border-subtle bg-theme-surface px-3 py-2">
472
+ <div className="break-words text-sm font-medium text-theme-text-primary">
473
+ {subject.title}
474
+ </div>
475
+ {subject.detail && (
476
+ <div className="mt-0.5 text-xs text-theme-text-tertiary">
477
+ {subject.detail}
478
+ </div>
479
+ )}
480
+ </div>
481
+ )}
461
482
  <div className="text-sm leading-relaxed text-theme-text-secondary">
462
483
  {body}
463
484
  </div>
@@ -476,6 +497,7 @@ function ConsentCardShell({
476
497
  {resolvedSettingsLabel}
477
498
  </button>
478
499
  )}
500
+ {notice}
479
501
  {/* Red, not amber: the full-local card is itself amber, so an amber box on
480
502
  it reads as another paragraph of body copy. role="alert" because nothing
481
503
  else moves on failure — focus stays on Approve, so without it a screen
@@ -498,9 +520,10 @@ function ConsentCardShell({
498
520
  </button>
499
521
  <button
500
522
  onClick={onApprove}
523
+ disabled={approveBusy}
501
524
  className="flex-1 rounded-lg btn-brand py-1.5 text-sm"
502
525
  >
503
- {approveLabel}
526
+ {approveBusy ? "Checking sign-in…" : approveLabel}
504
527
  </button>
505
528
  </div>
506
529
  </div>
@@ -517,12 +540,24 @@ function ConsentCardShell({
517
540
  // MUST override rather than let Radar assert the local story over its flow.
518
541
  // 2. No `copy` — the OSS bring-your-own-local-CLI default, the only tier where
519
542
  // "on your machine / no Radar cloud / your account" actually holds.
543
+ // What the consent card is about to investigate: the resource, or the
544
+ // engineer's question and where it starts.
545
+ export interface ConsentSubject {
546
+ title: string;
547
+ detail?: string;
548
+ /** The run starts from a question, not from one resource. */
549
+ question?: boolean;
550
+ }
551
+
520
552
  export function ConsentCard({
521
553
  agentName,
522
554
  agent,
523
555
  profile,
524
556
  copy,
525
557
  error,
558
+ notice,
559
+ approveBusy,
560
+ subject,
526
561
  onOpenSettings,
527
562
  onApprove,
528
563
  onCancel,
@@ -532,11 +567,23 @@ export function ConsentCard({
532
567
  profile: ExecutionProfile;
533
568
  copy?: DiagnoseConsentCopy;
534
569
  error?: string | null;
570
+ notice?: ReactNode;
571
+ approveBusy?: boolean;
572
+ subject?: ConsentSubject;
535
573
  onOpenSettings?: () => void;
536
574
  onApprove: () => void;
537
575
  onCancel: () => void;
538
576
  }) {
539
- const chrome = { onOpenSettings, onApprove, onCancel, error };
577
+ const chrome = {
578
+ onOpenSettings,
579
+ onApprove,
580
+ onCancel,
581
+ error,
582
+ notice,
583
+ approveBusy,
584
+ subject,
585
+ };
586
+ const about = subject?.question ? "the resources it reads" : "this resource";
540
587
 
541
588
  // Tier 1: a host (e.g. radar-hub-web) supplied its own copy — use it verbatim.
542
589
  if (copy) return <ConsentCardShell {...copy} {...chrome} />;
@@ -562,9 +609,9 @@ export function ConsentCard({
562
609
  your own {agentName}
563
610
  </span>{" "}
564
611
  on your machine — no Radar cloud, no API key, no account. Radar sends
565
- this resource&apos;s spec, recent events, and pod logs to it (and on
566
- to its model provider under your account, not to Radar). Transcripts
567
- are kept in your local Radar history on this machine until cleared.
612
+ the spec, recent events, and pod logs of {about} to it (and on to its
613
+ model provider under your account, not to Radar). Transcripts are kept
614
+ in your local Radar history on this machine until cleared.
568
615
  {profile === "safeguarded" && (
569
616
  <>
570
617
  {" "}
@@ -9,7 +9,7 @@ import { openExternal } from "../../utils/navigation";
9
9
  const REPORT_URL =
10
10
  "https://github.com/skyhook-io/radar/issues/new?labels=bug&template=bug_report.md";
11
11
 
12
- function CopyButton({ text, label }: { text: string; label: string }) {
12
+ export function CopyButton({ text, label }: { text: string; label: string }) {
13
13
  const [copied, setCopied] = useState(false);
14
14
  return (
15
15
  <button
@@ -0,0 +1,98 @@
1
+ import { describe, expect, it, vi } from "vitest";
2
+ import { renderToStaticMarkup } from "react-dom/server";
3
+ import { AgentSigninNotice } from "./AgentSigninNotice";
4
+ import { ConsentCard } from "./parts";
5
+
6
+ const noop = vi.fn();
7
+
8
+ describe("AgentSigninNotice", () => {
9
+ it("names the agent, the command to run and a re-check", () => {
10
+ const html = renderToStaticMarkup(
11
+ <AgentSigninNotice
12
+ agentName="Claude Code"
13
+ signinCmd="claude auth login"
14
+ rechecking={false}
15
+ onRecheck={noop}
16
+ />,
17
+ );
18
+ expect(html).toContain("Claude Code isn&#x27;t signed in");
19
+ expect(html).toContain("claude auth login");
20
+ expect(html).toContain("Copy sign-in command");
21
+ expect(html).toContain("Check again");
22
+ expect(html).not.toContain("Still not signed in");
23
+ });
24
+
25
+ it("shows the re-check in progress", () => {
26
+ const html = renderToStaticMarkup(
27
+ <AgentSigninNotice
28
+ agentName="Codex"
29
+ signinCmd="codex login"
30
+ rechecking
31
+ onRecheck={noop}
32
+ />,
33
+ );
34
+ expect(html).toContain("Checking…");
35
+ expect(html).toContain("disabled");
36
+ });
37
+ });
38
+
39
+ describe("ConsentCard sign-in notice", () => {
40
+ it("shows the notice above the actions and keeps Approve available", () => {
41
+ const html = renderToStaticMarkup(
42
+ <ConsentCard
43
+ agentName="Claude Code"
44
+ agent="claude"
45
+ profile="safeguarded"
46
+ notice={
47
+ <AgentSigninNotice
48
+ agentName="Claude Code"
49
+ signinCmd="claude auth login"
50
+ rechecking={false}
51
+ onRecheck={noop}
52
+ />
53
+ }
54
+ onApprove={noop}
55
+ onCancel={noop}
56
+ />,
57
+ );
58
+ const notice = html.indexOf("isn&#x27;t signed in");
59
+ const approve = html.indexOf("Approve &amp; investigate");
60
+ expect(notice).toBeGreaterThan(-1);
61
+ expect(approve).toBeGreaterThan(notice);
62
+ const approveButton = html.slice(html.lastIndexOf("<button", approve), approve);
63
+ expect(approveButton).not.toContain("disabled");
64
+ });
65
+
66
+ it("says Approve is waiting on the check", () => {
67
+ const html = renderToStaticMarkup(
68
+ <ConsentCard
69
+ agentName="Codex"
70
+ agent="codex"
71
+ profile="safeguarded"
72
+ approveBusy
73
+ onApprove={noop}
74
+ onCancel={noop}
75
+ />,
76
+ );
77
+ const label = html.indexOf("Checking sign-in…");
78
+ expect(label).toBeGreaterThan(-1);
79
+ expect(html.slice(html.lastIndexOf("<button", label), label)).toContain(
80
+ "disabled",
81
+ );
82
+ expect(html).not.toContain("Approve &amp; investigate");
83
+ });
84
+
85
+ it("renders as before without a notice (signed in or unknown)", () => {
86
+ const html = renderToStaticMarkup(
87
+ <ConsentCard
88
+ agentName="Claude Code"
89
+ agent="claude"
90
+ profile="safeguarded"
91
+ onApprove={noop}
92
+ onCancel={noop}
93
+ />,
94
+ );
95
+ expect(html).not.toContain("signed in");
96
+ expect(html).toContain("Approve &amp; investigate");
97
+ });
98
+ });
@@ -0,0 +1,61 @@
1
+ import { useState } from "react";
2
+ import clsx from "clsx";
3
+ import { RotateCw } from "lucide-react";
4
+ import { AlertBanner } from "@skyhook-io/k8s-ui";
5
+ import { CopyButton } from "./AgentSetupNotice";
6
+
7
+ // Shown on the consent card when the agent's own status command says it is
8
+ // signed out. It warns rather than blocks: status commands can be wrong (a
9
+ // credential they don't see), so Approve stays available.
10
+ export function AgentSigninNotice({
11
+ agentName,
12
+ signinCmd,
13
+ rechecking,
14
+ onRecheck,
15
+ }: {
16
+ agentName: string;
17
+ signinCmd: string;
18
+ rechecking: boolean;
19
+ onRecheck: () => void;
20
+ }) {
21
+ const [asked, setAsked] = useState(false);
22
+ return (
23
+ <AlertBanner
24
+ variant="warning"
25
+ className="mt-3"
26
+ title={`${agentName} isn't signed in`}
27
+ message={
28
+ <>
29
+ The investigation will fail until it is. Run this in a terminal, then
30
+ check again.
31
+ </>
32
+ }
33
+ action={
34
+ <button
35
+ type="button"
36
+ disabled={rechecking}
37
+ onClick={() => {
38
+ setAsked(true);
39
+ onRecheck();
40
+ }}
41
+ className="inline-flex items-center gap-1 text-xs text-accent hover:underline disabled:opacity-60"
42
+ >
43
+ <RotateCw className={clsx("h-3 w-3", rechecking && "animate-spin")} />
44
+ {rechecking ? "Checking…" : "Check again"}
45
+ </button>
46
+ }
47
+ >
48
+ <div className="mt-2 flex items-center gap-1.5 rounded-md bg-theme-base px-2 py-1.5">
49
+ <code className="min-w-0 flex-1 overflow-x-auto whitespace-nowrap font-mono text-xs text-theme-text-secondary">
50
+ {signinCmd}
51
+ </code>
52
+ <CopyButton text={signinCmd} label="Copy sign-in command" />
53
+ </div>
54
+ {asked && !rechecking && (
55
+ <p role="status" className="mt-1.5 text-xs text-theme-text-secondary">
56
+ Still not signed in.
57
+ </p>
58
+ )}
59
+ </AlertBanner>
60
+ );
61
+ }