@skyhook-io/radar-app 1.22.0 → 1.22.2

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 (95) hide show
  1. package/package.json +1 -1
  2. package/src/App.tsx +98 -29
  3. package/src/RadarApp.tsx +5 -0
  4. package/src/api/client.ts +18 -1
  5. package/src/api/cnpg-history.ts +3 -3
  6. package/src/api/cnpg-storage.ts +3 -3
  7. package/src/api/diagnose.test.ts +34 -0
  8. package/src/api/diagnose.ts +17 -4
  9. package/src/api/radarFeatures.test.ts +13 -1
  10. package/src/api/radarFeatures.ts +2 -0
  11. package/src/api/resourceActions.test.ts +829 -0
  12. package/src/api/resourceActions.ts +584 -0
  13. package/src/api/resourceActions.ui.test.tsx +1882 -0
  14. package/src/api/reviewedActionMutation.ts +56 -28
  15. package/src/api/substrateHealth.ts +2 -3
  16. package/src/api/traffic.ts +13 -5
  17. package/src/api/workloadMetrics.test.ts +11 -2
  18. package/src/api/workloadMetrics.ts +2 -2
  19. package/src/api/workloadSource.test.tsx +857 -0
  20. package/src/api/workloadSource.ts +292 -0
  21. package/src/components/APIUnreachableBanner.test.tsx +19 -0
  22. package/src/components/APIUnreachableBanner.tsx +20 -0
  23. package/src/components/ConnectionErrorView.test.tsx +63 -2
  24. package/src/components/ConnectionErrorView.tsx +88 -68
  25. package/src/components/diagnose/ActivityTurn.tsx +6 -4
  26. package/src/components/diagnose/AnalysisStory.test.tsx +12 -0
  27. package/src/components/diagnose/AssessmentCard.tsx +1 -2
  28. package/src/components/diagnose/ContinueInAgentButton.test.tsx +7 -0
  29. package/src/components/diagnose/DiagnoseContext.question.test.tsx +34 -1
  30. package/src/components/diagnose/DiagnoseContext.tsx +28 -3
  31. package/src/components/diagnose/DiagnoseSurface.tsx +5 -4
  32. package/src/components/diagnose/Home.test.tsx +6 -0
  33. package/src/components/diagnose/Home.tsx +13 -3
  34. package/src/components/diagnose/InvestigationEvidencePane.story.test.tsx +1 -1
  35. package/src/components/diagnose/InvestigationEvidencePane.test.tsx +61 -0
  36. package/src/components/diagnose/InvestigationEvidencePane.tsx +19 -2
  37. package/src/components/diagnose/InvestigationFindingsFooter.test.tsx +413 -0
  38. package/src/components/diagnose/InvestigationView.followupFailure.test.tsx +122 -0
  39. package/src/components/diagnose/InvestigationView.tsx +130 -25
  40. package/src/components/diagnose/LocalDiagnoseAction.history.test.tsx +1 -1
  41. package/src/components/diagnose/LocalDiagnoseAction.tsx +2 -2
  42. package/src/components/diagnose/QuestionComposer.test.tsx +16 -2
  43. package/src/components/diagnose/QuestionComposer.tsx +13 -8
  44. package/src/components/diagnose/diagnoseEvidenceTypes.ts +47 -8
  45. package/src/components/diagnose/investigationEvidence/adapters/diagnose.test.ts +153 -0
  46. package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +9 -13
  47. package/src/components/diagnose/investigationEvidence/adapters/issues.ts +21 -5
  48. package/src/components/diagnose/investigationEvidence/bodies/network.tsx +63 -26
  49. package/src/components/diagnose/investigationEvidence/identity.test.ts +1 -1
  50. package/src/components/diagnose/investigationEvidence/projection.test.ts +1 -1
  51. package/src/components/diagnose/investigationState.ts +9 -0
  52. package/src/components/diagnose/launch.ts +1 -1
  53. package/src/components/diagnose/parts.test.tsx +11 -3
  54. package/src/components/diagnose/toolCallLabel.ts +3 -0
  55. package/src/components/dock/PodDebugSession.test.tsx +66 -0
  56. package/src/components/dock/PodDebugSession.tsx +3 -1
  57. package/src/components/dock/TerminalTab.test.tsx +43 -3
  58. package/src/components/dock/TerminalTab.tsx +10 -1
  59. package/src/components/helm/HelmReleaseDrawer.tsx +1 -1
  60. package/src/components/helm/InstallWizard.tsx +1 -1
  61. package/src/components/home/ActivitySummary.tsx +3 -8
  62. package/src/components/home/ClusterHealthCard.tsx +91 -17
  63. package/src/components/home/ClusterHealthCard.utilization.test.tsx +187 -0
  64. package/src/components/home/HomeView.tsx +6 -26
  65. package/src/components/home/TopologyPreview.test.tsx +31 -30
  66. package/src/components/home/TopologyPreview.tsx +19 -28
  67. package/src/components/home/mcpToolCatalog.ts +4 -4
  68. package/src/components/resources/PodEvictAction.test.tsx +951 -0
  69. package/src/components/resources/PodEvictAction.tsx +167 -0
  70. package/src/components/resources/ResourcesView.tsx +3 -0
  71. package/src/components/resources/renderers/JobAdmissionRenderers.tsx +5 -4
  72. package/src/components/resources/renderers/RolloutRenderer.tsx +4 -1
  73. package/src/components/resources/renderers/WorkloadRenderer.tsx +7 -1
  74. package/src/components/settings/LocalConnectionSettings.tsx +4 -4
  75. package/src/components/settings/SettingsDialog.tsx +23 -18
  76. package/src/components/settings/integrationQueries.test.ts +98 -0
  77. package/src/components/settings/integrationQueries.ts +36 -0
  78. package/src/components/traffic/TrafficView.reconnect.test.tsx +229 -0
  79. package/src/components/traffic/TrafficView.tsx +91 -35
  80. package/src/components/ui/Markdown.test.tsx +37 -0
  81. package/src/components/ui/Markdown.tsx +15 -2
  82. package/src/components/useContextSwitchFlow.test.tsx +27 -2
  83. package/src/components/useContextSwitchFlow.tsx +20 -22
  84. package/src/components/workload/WorkloadView.tsx +83 -4
  85. package/src/components/workload/WorkloadView.workloadSource.test.tsx +121 -0
  86. package/src/context/ConnectionContext.tsx +24 -5
  87. package/src/context/ConnectionProvider.connectionId.test.tsx +14 -0
  88. package/src/context/ConnectionProvider.handover.test.tsx +94 -0
  89. package/src/context/DiagnoseCustomization.tsx +20 -2
  90. package/src/hooks/useEventSource.test.tsx +275 -4
  91. package/src/hooks/useEventSource.ts +278 -51
  92. package/src/index.ts +1 -0
  93. package/src/utils/navigation.test.ts +1 -6
  94. package/src/utils/navigation.ts +9 -44
  95. package/src/utils/network-policy-navigation.test.ts +21 -36
@@ -85,6 +85,13 @@ describe("canContinueInOwnAgent", () => {
85
85
  ).toBe(true);
86
86
  });
87
87
 
88
+ it("keeps the investigator's private agent session out of an assigned reader's controls", () => {
89
+ expect(canContinueInOwnAgent({
90
+ ...settled,
91
+ run: run({ visibility: "private", ownedByMe: false, status: "running" }),
92
+ })).toBe(false);
93
+ });
94
+
88
95
  it("stays hidden on a run that is gone", () => {
89
96
  expect(canContinueInOwnAgent({ ...settled, gone: true })).toBe(false);
90
97
  });
@@ -13,6 +13,8 @@ import { runTargetKey } from "./target";
13
13
 
14
14
  const api = vi.hoisted(() => ({
15
15
  createRun: vi.fn(),
16
+ fullQuestions: true,
17
+ targetedQuestions: false,
16
18
  recordConsent: vi.fn(),
17
19
  consented: {} as Record<string, boolean>,
18
20
  runs: [] as unknown[],
@@ -34,7 +36,8 @@ vi.mock("../../api/diagnose", async (importOriginal) => ({
34
36
  supported: true,
35
37
  profiles: ["safeguarded"],
36
38
  consentSurfaces: { safeguarded: "claude:safeguarded" },
37
- questions: true,
39
+ questions: api.fullQuestions,
40
+ targetQuestions: api.targetedQuestions,
38
41
  },
39
42
  ],
40
43
  }),
@@ -85,6 +88,8 @@ const question = {
85
88
 
86
89
  beforeEach(async () => {
87
90
  api.createRun.mockReset();
91
+ api.fullQuestions = true;
92
+ api.targetedQuestions = false;
88
93
  api.recordConsent.mockReset();
89
94
  api.consented = {};
90
95
  api.runs = [];
@@ -243,3 +248,31 @@ describe("starting from a question", () => {
243
248
  expect(diagnose.questionDraft?.context).toBe("cluster-a");
244
249
  });
245
250
  });
251
+
252
+ it("requires one selected resource on target-only agents, including starts replayed after consent", async () => {
253
+ api.fullQuestions = false;
254
+ api.targetedQuestions = true;
255
+ api.recordConsent.mockResolvedValue(undefined);
256
+ await act(async () => diagnose.recheckAgents());
257
+ await act(async () => diagnose.openInvestigation(question));
258
+ await act(async () => diagnose.approveConsent());
259
+ await flush();
260
+ expect(api.createRun).not.toHaveBeenCalled();
261
+ expect(diagnose.startError).toContain("Choose a resource");
262
+ expect(diagnose.questionDraft?.text).toBe(question.question);
263
+ });
264
+
265
+ it("sends the exact pinned resource and question, without the composer's local state", async () => {
266
+ api.fullQuestions = false;
267
+ api.targetedQuestions = true;
268
+ api.consented = { "claude:safeguarded": true };
269
+ await act(async () => diagnose.recheckAgents());
270
+ expect(diagnose.questions).toBe(false);
271
+ expect(diagnose.targetQuestions).toBe(true);
272
+ api.createRun.mockResolvedValue({ id: "run-resource" });
273
+ await act(async () => diagnose.openInvestigation({ ...question, kind: "Deployment", group: "apps", namespace: "shop", name: "checkout" }));
274
+ expect(api.createRun.mock.calls[0][0]).toEqual({
275
+ kind: "Deployment", group: "apps", namespace: "shop", name: "checkout",
276
+ question: question.question, namespaces: question.namespaces, lookBack: "1h",
277
+ });
278
+ });
@@ -130,7 +130,8 @@ interface DiagnoseCtx {
130
130
  cliOverride: boolean;
131
131
  agentLabel: string; // label of the selected agent, e.g. "Claude Code"
132
132
  hosted: boolean; // selected agent runs on the host's backend, not this machine
133
- questions: boolean; // the selected agent's backend opens a run from a question
133
+ questions: boolean; // the selected agent accepts a question without a resource
134
+ targetQuestions: boolean; // the agent accepts a question pinned to a resource
134
135
  agents: AgentInfo[]; // supported agents detected on PATH (for the picker)
135
136
  selectedAgent: string; // name of the chosen backend ("claude"/"codex")
136
137
  setSelectedAgent: (name: string) => void;
@@ -723,6 +724,8 @@ function RoutedDiagnoseProvider({
723
724
  : (selectedAgentInfo?.profiles?.[0] ?? profile);
724
725
  const agentLabel = agentLabelFor(selectedAgent, selectedAgentInfo?.label);
725
726
  const hosted = !!selectedAgentInfo?.hosted;
727
+ const questions = selectedAgentInfo?.questions === true;
728
+ const targetQuestions = questions || selectedAgentInfo?.targetQuestions === true;
726
729
  // Hosted Radar uses its existing per-user disclosure surface and supplies its
727
730
  // own copy. Local agents use the execution profile as the consent contract.
728
731
  const consentSurface = hosted
@@ -946,8 +949,29 @@ function RoutedDiagnoseProvider({
946
949
  const startRunRef = useRef<(t: Target) => void>(() => {});
947
950
  startRunRef.current = (t: Target) => {
948
951
  const seq = ++startSeqRef.current;
952
+ if (t.question && (!targetQuestions || (!questions && (!t.kind || !t.name)))) {
953
+ giveQuestionBack(t);
954
+ setStartFailure({
955
+ refusal: null,
956
+ message: targetQuestions
957
+ ? "Choose a resource to investigate this question."
958
+ : "This agent does not accept an opening question.",
959
+ });
960
+ return;
961
+ }
949
962
  createRun(
950
- { ...t, kind: knownKindForPluralWithGroup(t.kind, t.group) ?? t.kind },
963
+ {
964
+ kind: knownKindForPluralWithGroup(t.kind, t.group) ?? t.kind,
965
+ group: t.group,
966
+ namespace: t.namespace,
967
+ name: t.name,
968
+ issueId: t.issueId,
969
+ fresh: t.fresh,
970
+ question: t.question,
971
+ namespaces: t.namespaces,
972
+ lookBack: t.lookBack,
973
+ askedAt: t.askedAt,
974
+ },
951
975
  {
952
976
  agent: selectedAgent || undefined,
953
977
  profile: hosted ? undefined : effectiveProfile,
@@ -1357,7 +1381,8 @@ function RoutedDiagnoseProvider({
1357
1381
  cliOverride,
1358
1382
  agentLabel,
1359
1383
  hosted,
1360
- questions: selectedAgentInfo?.questions === true,
1384
+ questions,
1385
+ targetQuestions,
1361
1386
  agents,
1362
1387
  selectedAgent,
1363
1388
  setSelectedAgent,
@@ -113,7 +113,7 @@ function buildConfigLine(cfg: {
113
113
  // run nothing to take a resource or question from.
114
114
  // running/stopping human starts reuse the live run. Automatic investigations
115
115
  // are immutable, so they retain a separate fresh human start.
116
- // stale the original session is closed after a cluster switch;
116
+ // stale the cluster connection it ran on has closed;
117
117
  // the resource may not exist in the active context. Do not
118
118
  // silently start a different-cluster investigation from here.
119
119
  // needsConsent the consent card owns the surface until it's answered.
@@ -662,10 +662,11 @@ export function DiagnoseSurface({
662
662
  ) : (
663
663
  <InvestigationHome
664
664
  agentLabel={d.agentLabel}
665
- questions={d.questions}
665
+ questions={d.targetQuestions}
666
+ requireResource={d.targetQuestions && !d.questions}
666
667
  onOpenExample={openExample}
667
668
  onBrowseIssues={
668
- d.questions || (d.runsLoaded && d.runs.length === 0)
669
+ d.targetQuestions || (d.runsLoaded && d.runs.length === 0)
669
670
  ? onBrowseIssues
670
671
  : undefined
671
672
  }
@@ -881,7 +882,7 @@ export function DiagnoseSurface({
881
882
  loaded={d.runsLoaded}
882
883
  loadFailed={d.runsLoadFailed}
883
884
  onRetry={d.refreshRuns}
884
- questions={d.questions}
885
+ questions={d.targetQuestions}
885
886
  // Beside Home on the full page, Home already offers it.
886
887
  onOpenExample={
887
888
  persistentHistory || exampleOpen || !openExample
@@ -77,6 +77,12 @@ describe("RecentList", () => {
77
77
  );
78
78
  });
79
79
 
80
+ it("identifies an invited private run without implying organization-wide access", () => {
81
+ const html = visible(render([run({ ownedByMe: false, visibility: "private" })]));
82
+ expect(html).toContain("Shared with you for review");
83
+ expect(html).not.toContain("Organization");
84
+ });
85
+
80
86
  it("keeps the whole row as one button and labels individual identity fields without native tooltips", () => {
81
87
  const html = render([run()]);
82
88
  expect(html.match(/<button\b/g)).toHaveLength(1);
@@ -21,6 +21,7 @@ import {
21
21
  } from "./target";
22
22
  import { Tooltip } from "../ui/Tooltip";
23
23
  import { QuestionComposer } from "./QuestionComposer";
24
+ import { isPrivateRunReviewer } from "./investigationState";
24
25
  import { plainVerdictText } from "./verdictText";
25
26
  import { ExampleInvestigationLink } from "./ExampleInvestigationLink";
26
27
 
@@ -148,17 +149,20 @@ export function InvestigationHome({
148
149
  onBrowseIssues,
149
150
  onOpenExample,
150
151
  questions = false,
152
+ requireResource = false,
151
153
  }: {
152
154
  agentLabel: string;
153
155
  onBrowseIssues?: () => void;
154
156
  onOpenExample?: () => void;
155
157
  /** The backend opens a run from a question; offer the composer. */
156
158
  questions?: boolean;
159
+ requireResource?: boolean;
157
160
  }) {
158
161
  if (questions) {
159
162
  return (
160
163
  <div className="flex min-h-full w-full items-start justify-center px-4 py-10 sm:px-6">
161
164
  <QuestionComposer
165
+ requireResource={requireResource}
162
166
  onBrowseIssues={onBrowseIssues}
163
167
  onOpenExample={onOpenExample}
164
168
  />
@@ -252,13 +256,19 @@ export function RecentList({
252
256
  groups.add(groupQualifiesLaneId(r.group) ? r.group : "");
253
257
  groupsByKind.set(kind, groups);
254
258
  }
259
+ const reviewRuns = runs.filter(isPrivateRunReviewer);
255
260
  const organizationRuns = runs.filter(
256
- (r) => r.trigger === "background" || r.ownedByMe === false,
261
+ (r) =>
262
+ !isPrivateRunReviewer(r) &&
263
+ (r.trigger === "background" || r.ownedByMe === false),
257
264
  );
258
- const yourRuns = runs.filter((r) => !organizationRuns.includes(r));
259
- const collections = organizationRuns.length
265
+ const yourRuns = runs.filter(
266
+ (r) => r.trigger !== "background" && r.ownedByMe !== false,
267
+ );
268
+ const collections = reviewRuns.length || organizationRuns.length
260
269
  ? [
261
270
  { label: "Your investigations", runs: yourRuns },
271
+ { label: "Shared with you for review", runs: reviewRuns },
262
272
  { label: "Organization", runs: organizationRuns },
263
273
  ].filter((collection) => collection.runs.length > 0)
264
274
  : [{ label: "", runs }];
@@ -190,7 +190,7 @@ describe("InvestigationEvidencePane under a story", () => {
190
190
  );
191
191
  expect(html).toContain('data-story-lost-support="nocard"');
192
192
  expect(html).toContain("Result in Activity");
193
- expect(html).toContain("None shown above");
193
+ expect(html).toContain("Recorded during this investigation");
194
194
  expect(html).toMatch(
195
195
  /aria-expanded="true"[^>]*aria-controls="investigation-captured-results"/,
196
196
  );
@@ -1116,6 +1116,67 @@ describe("InvestigationEvidencePane hierarchy and provenance", () => {
1116
1116
  expect(html).not.toMatch(/<button[^>]*>shop\/api\.example\.test<\/button>/);
1117
1117
  });
1118
1118
 
1119
+ it("shows a stored CoreDNS rule as copied text with its source and no severity", () => {
1120
+ const rule =
1121
+ "rewrite name regex .*\\.nodes\\.vcluster\\.com kubernetes.default.svc.cluster.local";
1122
+ const html = render(
1123
+ project(
1124
+ tool("diagnose-dns-rules", "diagnose", {
1125
+ resource: {
1126
+ apiVersion: "apps/v1",
1127
+ kind: "Deployment",
1128
+ metadata: { namespace: "shop", name: "api" },
1129
+ },
1130
+ resourceContext: { tier: "basic" },
1131
+ pods: 0,
1132
+ events: [],
1133
+ dnsContext: {
1134
+ signals: ["pod logs contain DNS resolution failures"],
1135
+ coreDNSRules: [
1136
+ {
1137
+ kind: "ConfigMap",
1138
+ namespace: "kube-system",
1139
+ name: "coredns",
1140
+ key: "Corefile",
1141
+ line: 5,
1142
+ text: rule,
1143
+ truncated: true,
1144
+ },
1145
+ ],
1146
+ // The verdict shape some Radar versions send.
1147
+ coreDNSFindings: [
1148
+ {
1149
+ kind: "ConfigMap",
1150
+ namespace: "kube-system",
1151
+ name: "coredns-custom",
1152
+ severity: "warning",
1153
+ reason: "CoreDNS service DNS rewrite",
1154
+ message: "CoreDNS Corefile contains a rule.",
1155
+ },
1156
+ ],
1157
+ omittedCoreDNSRules: 3,
1158
+ },
1159
+ }),
1160
+ ),
1161
+ false,
1162
+ undefined,
1163
+ undefined,
1164
+ () => {},
1165
+ );
1166
+
1167
+ expect(html).toContain("rules in the CoreDNS config");
1168
+ expect(html).toContain("rewrite name regex");
1169
+ expect(html).toContain("Corefile, line 5");
1170
+ expect(html).toContain("Open the ConfigMap for the whole rule");
1171
+ expect(html).toContain("3 more rules are not shown");
1172
+ expect(html).toMatch(/<button[^>]*>kube-system\/coredns<\/button>/);
1173
+ expect(html).toMatch(/<button[^>]*>kube-system\/coredns-custom<\/button>/);
1174
+ expect(html).toContain(
1175
+ "CoreDNS service DNS rewrite: CoreDNS Corefile contains a rule.",
1176
+ );
1177
+ expect(html).not.toMatch(/>warning</);
1178
+ });
1179
+
1119
1180
  it("waits for disclosure motion only when reduced motion is not requested", () => {
1120
1181
  expect(investigationDisclosureSettleDelay(false)).toBe(
1121
1182
  INVESTIGATION_DISCLOSURE_SETTLE_MS,
@@ -205,6 +205,13 @@ export function InvestigationEvidencePane({
205
205
  },
206
206
  [onGroupOpenChange, collectionByGroup, storyMode, resultsOpen],
207
207
  );
208
+ const revealPrimaryGroupId = revealRequest
209
+ ? projection.sources.find((item) => item.id === revealRequest.sourceId)
210
+ ?.primaryGroupId
211
+ : undefined;
212
+ const revealInMain =
213
+ revealPrimaryGroupId !== undefined &&
214
+ collectionByGroup.get(revealPrimaryGroupId) === "main";
208
215
  const revealCollection = revealRequest
209
216
  ? investigationEvidenceRevealCollection(
210
217
  projection,
@@ -237,7 +244,15 @@ export function InvestigationEvidencePane({
237
244
  setEarlierOpen(true);
238
245
  return;
239
246
  }
240
- if (storyMode && revealCollection && !resultsOpen) {
247
+ const placedStoryCard =
248
+ storyMode && revealInMain && revealPrimaryGroupId
249
+ ? document.getElementById(`story-${revealPrimaryGroupId}`)
250
+ : null;
251
+ const needsCapturedResults =
252
+ Boolean(revealCollection) ||
253
+ (revealInMain &&
254
+ (!placedStoryCard || Boolean(placedStoryCard.closest("[inert]"))));
255
+ if (storyMode && needsCapturedResults && !resultsOpen) {
241
256
  openingForRevealRequestRef.current = requestId;
242
257
  setResultsOpen(true);
243
258
  return;
@@ -272,6 +287,8 @@ export function InvestigationEvidencePane({
272
287
  }, [
273
288
  revealRequest,
274
289
  revealCollection,
290
+ revealInMain,
291
+ revealPrimaryGroupId,
275
292
  onRevealReady,
276
293
  earlierOpen,
277
294
  coverageOpen,
@@ -699,7 +716,7 @@ export function InvestigationEvidencePane({
699
716
  ? `${placedCount} shown above`
700
717
  : collecting
701
718
  ? `${capturedTotal} collected so far`
702
- : "None shown above",
719
+ : "Recorded during this investigation",
703
720
  resultsSummary,
704
721
  ]
705
722
  .filter(Boolean)