@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
package/src/api/client.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { createListRefetchInterval, normalizeResourceList, type ResourceListBody, type ResourceListResult } from './resourceLists'
2
+ import type { CascadeDetail } from '@skyhook-io/k8s-ui/components/ui/ForceDeleteConfirmDialog'
2
3
  import { canonicalResourceGroup } from '@skyhook-io/k8s-ui/utils/api-resources'
3
4
  import { pluralize } from '@skyhook-io/k8s-ui/utils/pluralize'
4
5
  import { knownKindForPluralWithGroup, pluralToKind } from '@skyhook-io/k8s-ui/utils/navigation'
@@ -810,12 +811,14 @@ export function useResourceAudit(
810
811
  name: string,
811
812
  group?: string,
812
813
  ) {
814
+ const { segment: emptyNamespaceSegment, pending: capabilitiesPending } = useEmptyNamespaceSegment();
813
815
  const params = new URLSearchParams();
814
816
  if (group) params.set("group", group);
815
817
  const query = params.toString();
816
818
  return useQuery<AuditFinding[]>({
817
- queryKey: ["audit", "resource", kind, group ?? "", namespace, name],
818
- queryFn: () => fetchJSON(`/audit/resource/${kind}/${namespace}/${name}${query ? `?${query}` : ""}`),
819
+ queryKey: ["audit", "resource", kind, group ?? "", namespace, name, namespace ? "" : emptyNamespaceSegment],
820
+ queryFn: () => fetchJSON(`/audit/resource/${resourcePathSegments(kind, namespace, name, emptyNamespaceSegment)}${query ? `?${query}` : ""}`),
821
+ enabled: namespace !== "" || !capabilitiesPending,
819
822
  staleTime: 30000,
820
823
  });
821
824
  }
@@ -1798,6 +1801,7 @@ export interface VersionInfo {
1798
1801
  installMethod: InstallMethod;
1799
1802
  updateCommand?: string;
1800
1803
  error?: string;
1804
+ productHuntLaunch?: { enabled: boolean; url: string; start: string; end: string };
1801
1805
  }
1802
1806
 
1803
1807
  const UPDATE_CHECK_STORAGE_KEY_PREFIX = 'radar-update-check';
@@ -2021,15 +2025,15 @@ const SEARCH_MIN_QUERY = 2;
2021
2025
 
2022
2026
  // useSearch hits the resource-search engine. The caller supplies the (already
2023
2027
  // debounced) query; the hook is enabled only past the min length. include=none
2024
- // keeps the per-hit payload identity-only; context=summary attaches
2025
- // health/issueCount per hit (rich rows). React Query's AbortSignal cancels
2028
+ // keeps the per-hit payload identity-only; context=status attaches health/issueCount,
2029
+ // while context=summary also requests navigation. React Query's AbortSignal cancels
2026
2030
  // overlapping scans on a new query. keepPreviousData avoids flicker while the
2027
2031
  // next query resolves.
2028
2032
  export function useSearch(
2029
2033
  query: string,
2030
2034
  opts?: {
2031
2035
  limit?: number;
2032
- context?: "summary" | "none";
2036
+ context?: "summary" | "status" | "none";
2033
2037
  enabled?: boolean;
2034
2038
  globalNs?: boolean;
2035
2039
  /** Re-query on an interval decided from the latest response. */
@@ -2768,21 +2772,42 @@ export function useArgoRevisionMetadata(
2768
2772
  });
2769
2773
  }
2770
2774
 
2775
+ // A cluster-scoped resource sends "_" as its namespace segment: proxies in
2776
+ // front of Radar (Radar Cloud's among them) merge "//", which drops the
2777
+ // segment and leaves a path no route matches.
2778
+ function resourcePathSegments(
2779
+ kind: string,
2780
+ namespace: string,
2781
+ name: string,
2782
+ emptyNamespaceSegment = "_",
2783
+ ): string {
2784
+ return `${kind}/${namespace || emptyNamespaceSegment}/${name}`;
2785
+ }
2786
+
2787
+ // A Radar without the clusterScopedPlaceholder flag reads "_" on the update and
2788
+ // audit routes as a real namespace, so until the flag is confirmed these
2789
+ // routes keep the empty segment every Radar accepts when reached directly.
2790
+ function useEmptyNamespaceSegment() {
2791
+ const { data: capabilities, isPending } = useCapabilities();
2792
+ return {
2793
+ segment: capabilities?.features?.clusterScopedPlaceholder ? "_" : "",
2794
+ pending: isPending,
2795
+ };
2796
+ }
2797
+
2771
2798
  // Generic resource fetching - returns resource with relationships
2772
- // Uses '_' as placeholder for cluster-scoped resources (empty namespace)
2773
2799
  export function fetchResourceWithRelationships<T>(
2774
2800
  kind: string,
2775
2801
  namespace: string,
2776
2802
  name: string,
2777
2803
  group?: string,
2778
2804
  ): Promise<ResourceWithRelationships<T>> {
2779
- const ns = namespace || "_";
2780
2805
  const params = new URLSearchParams();
2781
2806
  if (group) params.set("group", group);
2782
2807
  const queryString = params.toString();
2783
2808
 
2784
2809
  return fetchJSON(
2785
- `/resources/${kind}/${ns}/${name}${queryString ? `?${queryString}` : ""}`,
2810
+ `/resources/${resourcePathSegments(kind, namespace, name)}${queryString ? `?${queryString}` : ""}`,
2786
2811
  );
2787
2812
  }
2788
2813
 
@@ -4393,6 +4418,7 @@ export function useAvailablePorts(
4393
4418
  // Update a resource with new YAML
4394
4419
  export function useUpdateResource() {
4395
4420
  const queryClient = useQueryClient();
4421
+ const { segment: emptyNamespaceSegment } = useEmptyNamespaceSegment();
4396
4422
 
4397
4423
  return useMutation({
4398
4424
  mutationFn: async ({
@@ -4413,7 +4439,7 @@ export function useUpdateResource() {
4413
4439
  reviewedContext?: string
4414
4440
  }) => {
4415
4441
  const url = new URL(
4416
- `${getApiBase()}/resources/${kind}/${namespace}/${name}`,
4442
+ `${getApiBase()}/resources/${resourcePathSegments(kind, namespace, name, emptyNamespaceSegment)}`,
4417
4443
  window.location.origin,
4418
4444
  );
4419
4445
  if (!force) {
@@ -4487,8 +4513,8 @@ export function useUpdateResource() {
4487
4513
  });
4488
4514
  }
4489
4515
 
4490
- // Cascade delete preview — visible related resources deletion may affect.
4491
- export interface CascadeDeletePreview {
4516
+ // Cached owner-reference projection and root controller cleanup.
4517
+ export interface CascadeDeletePreview extends CascadeDetail {
4492
4518
  root: { kind: string; namespace: string; name: string; group?: string };
4493
4519
  rootResolved: boolean;
4494
4520
  dependents: {
@@ -4510,14 +4536,62 @@ export function useCascadeDeletePreview(
4510
4536
  queryKey: ["cascade-preview", kind, group, namespace, name],
4511
4537
  queryFn: () =>
4512
4538
  fetchJSON<CascadeDeletePreview>(
4513
- `/resources/${kind}/${namespace}/${name}/cascade-preview${group ? `?group=${encodeURIComponent(group)}` : ""}`,
4539
+ `/resources/${resourcePathSegments(kind, namespace, name)}/cascade-preview${group ? `?group=${encodeURIComponent(group)}` : ""}`,
4514
4540
  ),
4515
4541
  enabled,
4516
- staleTime: 30_000,
4542
+ staleTime: 0,
4517
4543
  });
4518
4544
  }
4519
4545
 
4520
4546
  // Delete a resource
4547
+ interface DeleteResourceResult {
4548
+ deletionTimestamp?: string;
4549
+ pendingFinalizers?: string[];
4550
+ observationError?: string;
4551
+ outcomeUnknown?: boolean;
4552
+ }
4553
+
4554
+ async function readDeleteResult(request: Promise<Response>): Promise<DeleteResourceResult> {
4555
+ let response: Response;
4556
+ try {
4557
+ response = await request;
4558
+ } catch (error) {
4559
+ return { outcomeUnknown: true, observationError: String(error) };
4560
+ }
4561
+ if (!response.ok) {
4562
+ const error = await readErrorBody(response);
4563
+ if (response.status >= 500 || response.status === 408) {
4564
+ return { outcomeUnknown: true, observationError: error.error || `HTTP ${response.status}` };
4565
+ }
4566
+ throw new Error(error.error || `HTTP ${response.status}`);
4567
+ }
4568
+ const unconfirmed = { observationError: "Deletion accepted; the response did not confirm cleanup." };
4569
+ try {
4570
+ const result = JSON.parse(await response.text()) as DeleteResourceResult;
4571
+ if (result === null || typeof result !== "object" || Array.isArray(result)
4572
+ || (result.deletionTimestamp !== undefined && typeof result.deletionTimestamp !== "string")
4573
+ || (result.observationError !== undefined && typeof result.observationError !== "string")
4574
+ || (result.pendingFinalizers !== undefined && (!Array.isArray(result.pendingFinalizers) || result.pendingFinalizers.some(value => typeof value !== "string")))) {
4575
+ return unconfirmed;
4576
+ }
4577
+ return result;
4578
+ } catch {
4579
+ return unconfirmed;
4580
+ }
4581
+ }
4582
+
4583
+ function deleteResourceNotification(result: DeleteResourceResult): { message: string; type: "info" | "success"; detail?: string } {
4584
+ if (result.outcomeUnknown) return { message: "Deletion outcome unknown; inspect before retrying", type: "info", detail: result.observationError };
4585
+ if (result.observationError) {
4586
+ return { message: "Deletion accepted; completion unconfirmed", type: "info", detail: result.observationError };
4587
+ }
4588
+ if (result.pendingFinalizers?.length) {
4589
+ return { message: `Deleting — waiting on finalizers: ${result.pendingFinalizers.join(", ")}`, type: "info" };
4590
+ }
4591
+ if (result.deletionTimestamp) return { message: "Deleting…", type: "info" };
4592
+ return { message: "Resource deleted", type: "success" };
4593
+ }
4594
+
4521
4595
  export function useDeleteResource() {
4522
4596
  const queryClient = useQueryClient();
4523
4597
 
@@ -4536,7 +4610,7 @@ export function useDeleteResource() {
4536
4610
  force?: boolean;
4537
4611
  }) => {
4538
4612
  const url = new URL(
4539
- `${getApiBase()}/resources/${kind}/${namespace}/${name}`,
4613
+ apiUrl(`/resources/${resourcePathSegments(kind, namespace, name)}`),
4540
4614
  window.location.origin,
4541
4615
  );
4542
4616
  if (group) {
@@ -4545,21 +4619,18 @@ export function useDeleteResource() {
4545
4619
  if (force) {
4546
4620
  url.searchParams.set("force", "true");
4547
4621
  }
4548
- const response = await apiFetch(url.toString(), {
4549
- method: "DELETE",
4550
- });
4551
- if (!response.ok) {
4552
- const error = await readErrorBody(response);
4553
- throw new Error(error.error || `HTTP ${response.status}`);
4554
- }
4555
- // DELETE returns 204 No Content, no body to parse
4556
- return { success: true };
4622
+ return readDeleteResult(apiFetch(url.toString(), { method: "DELETE" }));
4557
4623
  },
4558
4624
  meta: {
4559
4625
  errorMessage: "Failed to delete resource",
4560
- successMessage: "Resource deleted",
4561
4626
  },
4562
- onSuccess: (_, variables) => {
4627
+ onSuccess: (result, variables) => {
4628
+ const { message, detail, type } = deleteResourceNotification(result);
4629
+ if (type === "success") {
4630
+ showApiSuccess(message, detail);
4631
+ } else {
4632
+ showApiNotice(message, detail, type);
4633
+ }
4563
4634
  queryClient.invalidateQueries({
4564
4635
  queryKey: ["resources", variables.kind],
4565
4636
  });
@@ -4587,32 +4658,60 @@ export function useBulkDeleteResources() {
4587
4658
  const results = await Promise.allSettled(
4588
4659
  items.map(async ({ kind, group, namespace, name }) => {
4589
4660
  const url = new URL(
4590
- `${getApiBase()}/resources/${kind}/${namespace}/${name}`,
4661
+ apiUrl(`/resources/${resourcePathSegments(kind, namespace, name)}`),
4591
4662
  window.location.origin,
4592
4663
  );
4593
4664
  if (group) url.searchParams.set("group", group);
4594
4665
  if (force) url.searchParams.set("force", "true");
4595
- const response = await apiFetch(url.toString(), { method: "DELETE" });
4596
- if (!response.ok) {
4597
- const error = await readErrorBody(response);
4598
- throw new Error(
4599
- error.error || `Failed to delete ${namespace}/${name}`,
4600
- );
4601
- }
4602
- return { kind, namespace, name };
4666
+ return { kind, namespace, name, result: await readDeleteResult(apiFetch(url.toString(), { method: "DELETE" })) };
4603
4667
  }),
4604
4668
  );
4605
4669
  const failed = results.filter((r) => r.status === "rejected");
4606
4670
  if (failed.length > 0) {
4671
+ const unknown = results.filter(result => result.status === "fulfilled" && result.value.result.outcomeUnknown).length;
4607
4672
  throw new Error(
4608
- `Failed to delete ${failed.length} of ${items.length} resources`,
4673
+ `Failed to delete ${failed.length} of ${items.length} ${items.length === 1 ? "resource" : "resources"}${unknown ? `; deletion outcome unknown for ${unknown}; inspect before retrying` : ""}`,
4609
4674
  );
4610
4675
  }
4611
- return { deleted: items.length };
4676
+ return results.flatMap((r) => r.status === "fulfilled" ? [r.value] : []);
4612
4677
  },
4613
4678
  meta: {
4614
4679
  errorMessage: "Failed to delete some resources",
4615
- successMessage: "Resources deleted",
4680
+ },
4681
+ onSuccess: (deleted) => {
4682
+ const pending = deleted.filter(({ result }) => result.pendingFinalizers?.length);
4683
+ const unknown = deleted.filter(({ result }) => result.outcomeUnknown);
4684
+ const unobserved = deleted.filter(({ result }) => result.observationError);
4685
+ const deleting = deleted.filter(({ result }) => result.deletionTimestamp);
4686
+ const resources = `${deleted.length} ${deleted.length === 1 ? "resource" : "resources"}`;
4687
+ let message = `${resources} deleted`;
4688
+ let type: "info" | "success" = "success";
4689
+ const unread = `completion unconfirmed for ${unobserved.length}`;
4690
+ if (unknown.length) {
4691
+ message = `Deletion outcome unknown for ${unknown.length} ${unknown.length === 1 ? "resource" : "resources"}; inspect before retrying${pending.length ? `; ${pending.length} waiting on finalizers` : ""}`;
4692
+ type = "info";
4693
+ } else if (pending.length) {
4694
+ message = `Deleting — ${pending.length} ${pending.length === 1 ? "resource" : "resources"} waiting on finalizers${unobserved.length ? `; ${unread}` : ""}`;
4695
+ type = "info";
4696
+ } else if (unobserved.length) {
4697
+ message = `Deletion accepted for ${resources}; ${unread}`;
4698
+ type = "info";
4699
+ } else if (deleting.length) {
4700
+ message = `Deleting ${deleting.length} ${deleting.length === 1 ? "resource" : "resources"}…`;
4701
+ type = "info";
4702
+ }
4703
+ const details = deleted.flatMap(({ namespace, name, result }) => {
4704
+ const notification = deleteResourceNotification(result);
4705
+ return result.observationError || result.pendingFinalizers?.length || result.deletionTimestamp
4706
+ ? [`${namespace}/${name}: ${notification.message}${notification.detail ? `: ${notification.detail}` : ""}`]
4707
+ : [];
4708
+ });
4709
+ const detail = details.length ? listWithOverflow(details) : undefined;
4710
+ if (type === "success") {
4711
+ showApiSuccess(message, detail);
4712
+ } else {
4713
+ showApiNotice(message, detail, type);
4714
+ }
4616
4715
  },
4617
4716
  // onSettled, not onSuccess — a partial failure still deleted some
4618
4717
  // resources, and the table must refetch to drop them.
@@ -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
@@ -632,6 +632,7 @@ function DemandGroupCard({
632
632
  key={`${constraint.predicate}-${constraint.sourcePath}`}
633
633
  tone="structural"
634
634
  size="sm"
635
+ className="phone:[overflow-wrap:anywhere]"
635
636
  >
636
637
  {constraint.key || constraint.predicate}
637
638
  {constraint.operator ? ` ${constraint.operator}` : ""}
@@ -664,6 +665,7 @@ function DemandGroupCard({
664
665
  key={`${toleration.key ?? "*"}-${toleration.effect ?? "*"}-${index}`}
665
666
  tone="structural"
666
667
  size="sm"
668
+ className="phone:[overflow-wrap:anywhere]"
667
669
  >
668
670
  {toleration.key || "*"}
669
671
  {toleration.value ? `=${toleration.value}` : ""}
@@ -810,14 +812,15 @@ function PoolEvaluationCard({
810
812
  <button
811
813
  type="button"
812
814
  aria-expanded={expanded}
813
- className={`flex w-full items-center gap-2 px-3 py-2.5 text-left ${ROW_HOVER}`}
815
+ className={`flex w-full items-center gap-2 px-3 py-2.5 text-left phone:flex-wrap phone:gap-y-1 ${ROW_HOVER}`}
814
816
  onClick={() => setExpanded((current) => !current)}
815
817
  >
816
818
  <CollapseChevron open={expanded} className="h-4 w-4" />
817
819
  <span
818
820
  role="link"
819
821
  tabIndex={0}
820
- className="font-mono text-sm font-medium text-accent-text hover:underline"
822
+ // Phones: a name longer than the row breaks inside it (chevron + gap = 1.5rem).
823
+ className="font-mono text-sm font-medium text-accent-text hover:underline phone:max-w-[calc(100%-1.5rem)] phone:break-words"
821
824
  onClick={(event) => {
822
825
  event.stopPropagation();
823
826
  onOpenPool(evaluation.pool.name);
@@ -833,7 +836,7 @@ function PoolEvaluationCard({
833
836
  {evaluation.pool.name}
834
837
  </span>
835
838
  <PoolEvaluationBadge result={evaluation.result} />
836
- <span className="ml-auto text-[11px] text-theme-text-tertiary">
839
+ <span className="ml-auto text-[11px] text-theme-text-tertiary phone:whitespace-nowrap">
837
840
  {predicateCount} {predicateCount === 1 ? "predicate" : "predicates"}
838
841
  {evaluation.evidenceMeta.truncated ? " · truncated" : ""}
839
842
  </span>
@@ -346,12 +346,12 @@ export function CapacityOverview({
346
346
  <button
347
347
  type="button"
348
348
  onClick={() => setShowExplain(true)}
349
- className="mt-1 text-xs font-medium text-accent-text hover:underline"
349
+ className="mt-1 text-xs font-medium text-accent-text hover:underline phone:text-left"
350
350
  >
351
351
  Scheduling capacity ≠ actual usage — how to read these numbers
352
352
  </button>
353
353
  </div>
354
- <div className="flex items-center gap-2">
354
+ <div className="flex items-center gap-2 phone:flex-wrap phone:gap-y-1">
355
355
  <ScopeBadges coverage={coverage} />
356
356
  <CapacityFreshness
357
357
  meta={data}
@@ -373,7 +373,9 @@ export function CapacityOverview({
373
373
  </Notice>
374
374
  )}
375
375
 
376
- <div className="grid grid-cols-2 gap-3 lg:grid-cols-3 xl:grid-cols-5">
376
+ {/* Phones: managers take the full row, the counts pair up beside each
377
+ other, and a count left alone on the last row takes it whole. */}
378
+ <div className="grid grid-cols-2 gap-3 phone:[&>:last-child:nth-child(even)]:col-span-2 lg:grid-cols-3 xl:grid-cols-5">
377
379
  <ManagersTile
378
380
  managers={summary.managers}
379
381
  groups={data.groups}
@@ -419,6 +421,8 @@ export function CapacityOverview({
419
421
  "Claim inventory",
420
422
  )}
421
423
  attention={(summary.claimStages?.failed ?? 0) > 0}
424
+ // Keeps the row full when the denied Pending pods tile below takes its own.
425
+ className={podsDeniedFlag ? "phone:col-span-2" : undefined}
422
426
  />
423
427
  )}
424
428
  {podsDeniedFlag ? (
@@ -426,6 +430,8 @@ export function CapacityOverview({
426
430
  label="Pending pods"
427
431
  value="Unavailable"
428
432
  sub="Pod access denied — not zero"
433
+ // "Unavailable" is wider than a half-width tile on a phone.
434
+ className="phone:col-span-2"
429
435
  certainty="unknown"
430
436
  certaintyTitle="Unknown — the current identity cannot list Pods. Absence of data is not zero."
431
437
  />
@@ -496,7 +502,7 @@ export function CapacityOverview({
496
502
  signals.map((signal) => (
497
503
  <div
498
504
  key={signal.key}
499
- className="flex items-start gap-3 px-4 py-2.5 hover:bg-theme-hover/40"
505
+ className="flex items-start gap-3 px-4 py-2.5 hover:bg-theme-hover/40 phone:flex-wrap phone:gap-y-1"
500
506
  >
501
507
  <Badge
502
508
  severity={signal.severity}
@@ -515,7 +521,7 @@ export function CapacityOverview({
515
521
  key={subject.label}
516
522
  type="button"
517
523
  onClick={subject.open}
518
- className="font-mono text-accent-text hover:underline"
524
+ className="font-mono text-accent-text hover:underline phone:max-w-full phone:break-words phone:text-left"
519
525
  >
520
526
  {subject.label}
521
527
  </button>
@@ -526,7 +532,8 @@ export function CapacityOverview({
526
532
  {signal.action && (
527
533
  <LinkButton
528
534
  onClick={signal.action.run}
529
- className="shrink-0 self-center"
535
+ // Phones: the action drops under the text, lined up with it.
536
+ className="shrink-0 self-center phone:basis-full phone:pl-[3.75rem]"
530
537
  >
531
538
  {signal.action.label} →
532
539
  </LinkButton>
@@ -606,7 +613,7 @@ function ManagersTile({
606
613
  ? autoscalerStatus?.observedAt
607
614
  : undefined;
608
615
  return (
609
- <div className="rounded-xl border border-theme-border bg-theme-surface px-4 py-3 shadow-theme-sm">
616
+ <div className="rounded-xl border border-theme-border bg-theme-surface px-4 py-3 shadow-theme-sm phone:col-span-2">
610
617
  <div className="flex items-center gap-1.5">
611
618
  <span className="text-[11px] font-medium uppercase tracking-wide text-theme-text-tertiary">
612
619
  Capacity managers