@skyhook-io/radar-app 1.21.6 → 1.21.8

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 (118) hide show
  1. package/README.md +1 -1
  2. package/package.json +7 -7
  3. package/src/App.tsx +31 -4
  4. package/src/RadarApp.tsx +8 -2
  5. package/src/api/client.discoverMetrics.test.tsx +69 -0
  6. package/src/api/client.issueCorrelation.test.tsx +244 -0
  7. package/src/api/client.issueRowChanges.test.tsx +129 -0
  8. package/src/api/client.pendingOwnership.test.tsx +197 -0
  9. package/src/api/client.prometheusStatus.test.ts +4 -0
  10. package/src/api/client.restartError.test.ts +36 -1
  11. package/src/api/client.stopWorkflow.test.tsx +133 -0
  12. package/src/api/client.submitWorkflowTemplate.test.tsx +127 -0
  13. package/src/api/client.ts +582 -114
  14. package/src/api/connectionBinding.test.tsx +3 -1
  15. package/src/api/connectionBinding.ts +14 -2
  16. package/src/api/gitOpsPermissions.render.test.tsx +155 -0
  17. package/src/api/gitOpsPermissions.test.ts +90 -0
  18. package/src/api/gitOpsPermissions.ts +51 -0
  19. package/src/api/httpErrors.test.ts +30 -1
  20. package/src/api/httpErrors.ts +17 -0
  21. package/src/api/openobserveSetup.ts +85 -0
  22. package/src/api/podDebug.test.tsx +137 -0
  23. package/src/api/podDebug.ts +82 -0
  24. package/src/api/prometheusCharts.test.ts +23 -0
  25. package/src/api/prometheusCharts.ts +25 -0
  26. package/src/api/radarFeatures.render.test.tsx +43 -2
  27. package/src/api/radarFeatures.test.ts +18 -1
  28. package/src/api/radarFeatures.ts +17 -4
  29. package/src/api/reviewedActionMutation.ts +9 -2
  30. package/src/api/workloadMetrics.ts +2 -0
  31. package/src/components/NamespaceSwitcher.tsx +6 -2
  32. package/src/components/applications/ApplicationsView.identity.test.ts +35 -7
  33. package/src/components/applications/ApplicationsView.openResource.test.tsx +137 -11
  34. package/src/components/applications/ApplicationsView.tsx +127 -173
  35. package/src/components/cnpg/CNPGOperatorConditions.test.tsx +3 -0
  36. package/src/components/cnpg/CNPGOperatorConditions.tsx +4 -14
  37. package/src/components/cnpg/host.test.tsx +1 -1
  38. package/src/components/cnpg/host.tsx +0 -2
  39. package/src/components/dock/BottomDock.tsx +7 -3
  40. package/src/components/dock/MissingShellDebug.test.tsx +193 -0
  41. package/src/components/dock/MissingShellDebug.tsx +114 -0
  42. package/src/components/dock/PodDebugSession.test.tsx +60 -0
  43. package/src/components/dock/PodDebugSession.tsx +96 -0
  44. package/src/components/dock/TerminalTab.test.tsx +48 -4
  45. package/src/components/dock/TerminalTab.tsx +47 -25
  46. package/src/components/dock/WorkloadLogsTab.test.tsx +24 -1
  47. package/src/components/dock/WorkloadLogsTab.tsx +16 -0
  48. package/src/components/execution/BatchExecutionView.command.test.tsx +69 -0
  49. package/src/components/execution/BatchExecutionView.tsx +88 -5
  50. package/src/components/execution/BatchExecutionView.workflow-stop.test.tsx +69 -0
  51. package/src/components/execution/WorkflowRunStopAction.tsx +8 -0
  52. package/src/components/gitops/GitOpsPermissionRowActions.test.tsx +100 -0
  53. package/src/components/gitops/GitOpsPermissionRowActions.tsx +27 -0
  54. package/src/components/gitops/GitOpsView.identity.test.tsx +1 -0
  55. package/src/components/gitops/GitOpsView.permissions.test.tsx +102 -0
  56. package/src/components/gitops/GitOpsView.syncRequest.test.tsx +95 -7
  57. package/src/components/gitops/GitOpsView.tsx +93 -32
  58. package/src/components/helm/OwnedResources.tsx +1 -0
  59. package/src/components/home/HomeView.tsx +9 -1
  60. package/src/components/home/ProblemsPanel.investigate.test.tsx +12 -2
  61. package/src/components/home/mcpToolCatalog.ts +1 -0
  62. package/src/components/issues/IssuesPane.render.test.tsx +78 -2
  63. package/src/components/issues/IssuesPane.tsx +49 -6
  64. package/src/components/issues/useIssueExpansion.ts +91 -0
  65. package/src/components/resource/MetricsNotConnected.test.tsx +50 -0
  66. package/src/components/resource/MetricsNotConnected.tsx +114 -0
  67. package/src/components/resource/PVCUsageBar.tsx +2 -1
  68. package/src/components/resource/PrometheusCharts.render.test.tsx +47 -0
  69. package/src/components/resource/PrometheusCharts.tsx +14 -2
  70. package/src/components/resource/PrometheusChartsGrid.render.test.tsx +91 -1
  71. package/src/components/resource/PrometheusChartsGrid.tsx +28 -52
  72. package/src/components/resource/RestartChart.tsx +4 -3
  73. package/src/components/resource/RightsizingPanel.source.test.tsx +34 -0
  74. package/src/components/resource/RightsizingStrip.tsx +5 -3
  75. package/src/components/resource/WorkloadMetricsSection.render.test.tsx +6 -0
  76. package/src/components/resource/WorkloadMetricsSection.tsx +14 -11
  77. package/src/components/resource/nameMatchedScope.ts +9 -3
  78. package/src/components/resources/EmptyNamespaceHint.tsx +42 -0
  79. package/src/components/resources/PodDebugAction.test.tsx +157 -0
  80. package/src/components/resources/PodDebugAction.tsx +207 -0
  81. package/src/components/resources/PodDebugPermission.tsx +21 -0
  82. package/src/components/resources/ResourcesView.empty-hint.test.tsx +132 -0
  83. package/src/components/resources/ResourcesView.tsx +39 -5
  84. package/src/components/resources/namespaceHint.test.ts +34 -0
  85. package/src/components/resources/namespaceHint.ts +19 -0
  86. package/src/components/resources/renderers/AdmissionPolicyRenderers.tsx +135 -0
  87. package/src/components/resources/renderers/NodeRenderer.tsx +2 -1
  88. package/src/components/resources/renderers/PodRenderer.tsx +12 -5
  89. package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.test.tsx +24 -1
  90. package/src/components/settings/FormSaveActions.tsx +6 -2
  91. package/src/components/settings/LocalIntegrationStatus.tsx +14 -3
  92. package/src/components/settings/MetricsBackendSwitch.tsx +165 -0
  93. package/src/components/settings/OpenObserveSetup.test.tsx +384 -0
  94. package/src/components/settings/OpenObserveSetup.tsx +328 -0
  95. package/src/components/settings/SettingsDialog.tsx +21 -7
  96. package/src/components/settings/openobserveStatus.test.ts +34 -0
  97. package/src/components/settings/openobserveStatus.ts +55 -0
  98. package/src/components/timeline/TimelineList.selection.test.tsx +40 -0
  99. package/src/components/timeline/TimelineList.test.ts +18 -0
  100. package/src/components/timeline/TimelineList.tsx +19 -5
  101. package/src/components/timeline/TimelineView.tsx +2 -0
  102. package/src/components/workload/WorkloadView.pendingOwnership.test.tsx +34 -0
  103. package/src/components/workload/WorkloadView.tabUrl.test.tsx +44 -0
  104. package/src/components/workload/WorkloadView.tsx +103 -16
  105. package/src/components/workspace/WorkspaceConditions.tsx +56 -0
  106. package/src/components/workspace/layout.test.tsx +20 -0
  107. package/src/components/workspace/layout.tsx +1 -1
  108. package/src/context/TimelineNavigation.test.ts +59 -0
  109. package/src/context/TimelineNavigation.tsx +86 -0
  110. package/src/contexts/CapabilitiesContext.tsx +5 -1
  111. package/src/hooks/useResourceCounts.ts +2 -1
  112. package/src/hooks/useWorkflowStopAction.ts +31 -0
  113. package/src/index.css +1 -0
  114. package/src/integrations/resourceHosts.test.tsx +2 -2
  115. package/src/integrations/resourceHosts.tsx +4 -2
  116. package/src/k8s-ui-exports.test.ts +10 -0
  117. package/src/utils/page-links.ts +15 -1
  118. package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.tsx +0 -128
@@ -1,6 +1,7 @@
1
1
  import { useCallback, useEffect, useMemo, useState } from "react";
2
2
  import { useNavigate, useSearchParams } from "react-router-dom";
3
3
  import {
4
+ AlertBanner,
4
5
  ApplicationsList,
5
6
  ApplicationDetail,
6
7
  ArgoSyncDetailsContext,
@@ -9,15 +10,17 @@ import {
9
10
  CenteredEmpty,
10
11
  getRadarUpgradeRequirement,
11
12
  PageHeader,
13
+ PaneLoader,
12
14
  RadarUpgradeAction,
13
15
  radarUpgradeDetail,
14
16
  radarUpgradeHeadline,
15
17
  FreshnessControl,
16
- IssueRow,
17
- ISSUE_SEVERITY_RANK,
18
+ IssuesView,
19
+ appRelationshipFields,
18
20
  useToast,
19
21
  orderEnvs,
20
22
  matchWorkloadAcrossInstances,
23
+ resolveAppWorkloadSelection,
21
24
  workloadKey,
22
25
  healthOf,
23
26
  compareVersions,
@@ -29,7 +32,6 @@ import {
29
32
  eventsForApplication,
30
33
  memberRef,
31
34
  subjectRef,
32
- compareIssueSortAnchors,
33
35
  canonicalResourceGroup,
34
36
  type AppRow,
35
37
  type AppWorkload,
@@ -42,6 +44,7 @@ import {
42
44
  type SelectedAppWorkload,
43
45
  type SelectedResource,
44
46
  } from "@skyhook-io/k8s-ui";
47
+ import { buildIssueAppIndex } from "@skyhook-io/k8s-ui/components/issues";
45
48
  import { AlertTriangle, Boxes } from "lucide-react";
46
49
  import { SEVERITY_TEXT } from "@skyhook-io/k8s-ui/utils/badge-colors";
47
50
  import {
@@ -153,6 +156,7 @@ export function ApplicationsView({
153
156
  <AppDetailRoute
154
157
  app={selected}
155
158
  apps={apps}
159
+ completeInventory={namespaces.length === 0 && query.data?.access?.restricted === false}
156
160
  onBack={() => selectApp(null)}
157
161
  onOpenResource={onOpenResource}
158
162
  />
@@ -223,11 +227,13 @@ export function ApplicationsView({
223
227
  function AppDetailRoute({
224
228
  app,
225
229
  apps,
230
+ completeInventory,
226
231
  onBack,
227
232
  onOpenResource,
228
233
  }: {
229
234
  app: AppRow;
230
235
  apps: AppRow[];
236
+ completeInventory: boolean;
231
237
  onBack: () => void;
232
238
  onOpenResource: (resource: SelectedResource) => void;
233
239
  }) {
@@ -254,14 +260,21 @@ function AppDetailRoute({
254
260
  refetchInterval: 10_000,
255
261
  },
256
262
  );
257
- const issuesQuery = useIssues(appNamespaces);
263
+ const issueNamespaces = useMemo(() => {
264
+ if (!completeInventory) return appNamespaces;
265
+ const namespaces = new Set(appNamespaces);
266
+ for (const [field] of appRelationshipFields) {
267
+ for (const ref of app.relationships?.[field] ?? []) {
268
+ if (ref.namespace && !ref.state) namespaces.add(ref.namespace);
269
+ }
270
+ }
271
+ return [...namespaces].sort();
272
+ }, [appNamespaces, app.relationships, completeInventory]);
273
+ const issuesQuery = useIssues(issueNamespaces);
274
+ const issueData = issuesQuery.data;
258
275
  const appIssues = useMemo(
259
- () =>
260
- appIssuesForWorkloads(
261
- issuesQuery.data?.issues ?? [],
262
- app.workloads ?? [],
263
- ),
264
- [issuesQuery.data?.issues, app.workloads],
276
+ () => appIssuesForApplication(issueData?.issues ?? [], app, apps, completeInventory),
277
+ [issueData?.issues, app, apps, completeInventory],
265
278
  );
266
279
 
267
280
  // The selected workload (?workload=<key>) is the scope switch and wins over
@@ -270,27 +283,37 @@ function AppDetailRoute({
270
283
  // workload. A single-workload app does not expose app scope.
271
284
  const [searchParams, setSearchParams] = useSearchParams();
272
285
  const viewParam = searchParams.get("view");
273
- const selectedRouteView = parseApplicationView(viewParam);
274
- const selectedView: ApplicationView =
275
- selectedRouteView === "cost" ? "overview" : selectedRouteView;
276
286
  const selectedWorkloadParam = searchParams.get("workload");
277
287
  const appWorkloads = app.workloads ?? [];
278
288
  const singleWorkloadKey =
279
289
  appWorkloads.length === 1 ? workloadKey(appWorkloads[0]) : null;
280
290
  const selectedWorkloadKey = singleWorkloadKey ?? selectedWorkloadParam;
291
+ const deploysTab = searchParams.get("tab") === "deploys";
292
+ const appDeploysAlias = selectedWorkloadKey === null && !viewParam && deploysTab;
293
+ const selectedRouteView = appDeploysAlias ? "deploys" : parseApplicationView(viewParam);
294
+ const selectedView: ApplicationView =
295
+ selectedRouteView === "cost" ? "overview" : selectedRouteView;
281
296
  const applicationCostAvailable =
282
297
  !singleWorkloadKey &&
283
298
  appWorkloads.some((workload) => isOpenCostWorkloadKind(workload.kind));
284
299
  const applicationCostSelected =
285
300
  selectedRouteView === "cost" && applicationCostAvailable;
301
+ const requestedDeploys = selectedView === "deploys" || deploysTab;
302
+ const deploysInWorkloadScope = requestedDeploys && !singleWorkloadKey &&
303
+ resolveAppWorkloadSelection(appWorkloads.map(workloadKey), selectedWorkloadParam).selected !== null;
286
304
  const historyQuery = useApplicationHistory(app.key, appHistoryNamespaces, {
287
- enabled: !selectedWorkloadKey || Boolean(app.sourceRef),
305
+ enabled: !selectedWorkloadKey || Boolean(app.sourceRef) || (requestedDeploys && !deploysInWorkloadScope),
288
306
  });
289
307
  const readableHistory = historyQuery.isError ? undefined : historyQuery.data;
290
- const deliveryRecords = useMemo(() => applicationDeliveryRecords(historyQuery.data), [historyQuery.data]);
291
- const deliverySource = readableHistory?.sourceRef ?? app.sourceRef;
292
- const requestedDeploys = selectedView === "deploys" || searchParams.get("tab") === "deploys";
293
- const showDeploys = deliveryRecords.length > 0 || (requestedDeploys && Boolean(deliverySource));
308
+ const deliveryRecords = useMemo(() => applicationDeliveryRecords(readableHistory), [readableHistory]);
309
+ const partialSources = readableHistory?.partialSources;
310
+ const sourceUnavailable = !readableHistory?.sourceRef && !!partialSources?.length;
311
+ const deliverySource = sourceUnavailable ? undefined : readableHistory?.sourceRef ?? app.sourceRef;
312
+ const needsDeploySource = requestedDeploys && !deploysInWorkloadScope && !deliverySource;
313
+ const waitingForDeploySource = needsDeploySource && !sourceUnavailable && (historyQuery.isPending || historyQuery.isFetching);
314
+ const clearDeploySelection = deploysInWorkloadScope || (needsDeploySource && !sourceUnavailable && historyQuery.isSuccess && !historyQuery.isFetching);
315
+ const normalizeSingleWorkload = Boolean(singleWorkloadKey && (selectedWorkloadParam !== singleWorkloadKey || viewParam));
316
+ const clearCostSelection = !singleWorkloadKey && selectedRouteView === "cost" && !applicationCostAvailable;
294
317
  const [retainedHistoryRange, setRetainedHistoryRange] =
295
318
  useState<ApplicationHistoryRange>("7d");
296
319
  const historyRangeOptions = useMemo(
@@ -395,7 +418,8 @@ function AppDetailRoute({
395
418
  );
396
419
  useEffect(() => {
397
420
  // Deploys belongs to the app scope, including its single-workload shell.
398
- if (requestedDeploys && (!deliverySource || (!singleWorkloadKey && selectedWorkloadParam))) {
421
+ if (waitingForDeploySource) return;
422
+ if (clearDeploySelection) {
399
423
  const params = new URLSearchParams(searchParams);
400
424
  if (viewParam === "deploys") params.delete("view");
401
425
  if (params.get("tab") === "deploys") params.delete("tab");
@@ -403,8 +427,7 @@ function AppDetailRoute({
403
427
  setSearchParams(params, { replace: true });
404
428
  return;
405
429
  }
406
- if (!singleWorkloadKey) return;
407
- if (selectedWorkloadParam === singleWorkloadKey && !viewParam) return;
430
+ if (!singleWorkloadKey || !normalizeSingleWorkload) return;
408
431
  const params = new URLSearchParams(searchParams);
409
432
  params.delete("view");
410
433
  params.delete("run");
@@ -414,33 +437,28 @@ function AppDetailRoute({
414
437
  setSearchParams(params, { replace: true });
415
438
  }, [
416
439
  searchParams,
417
- requestedDeploys,
418
- deliverySource,
440
+ waitingForDeploySource,
441
+ clearDeploySelection,
442
+ normalizeSingleWorkload,
419
443
  selectedRouteView,
420
- selectedWorkloadParam,
421
444
  setSearchParams,
422
445
  singleWorkloadKey,
423
446
  viewParam,
424
447
  ]);
425
448
  useEffect(() => {
426
- if (
427
- singleWorkloadKey ||
428
- selectedRouteView !== "cost" ||
429
- applicationCostAvailable
430
- )
431
- return;
449
+ if (waitingForDeploySource || clearDeploySelection || !clearCostSelection) return;
432
450
  const params = new URLSearchParams(searchParams);
433
451
  params.delete("view");
434
452
  setSearchParams(params, { replace: true });
435
453
  }, [
436
- applicationCostAvailable,
454
+ clearCostSelection,
455
+ waitingForDeploySource,
456
+ clearDeploySelection,
437
457
  searchParams,
438
- selectedRouteView,
439
458
  setSearchParams,
440
- singleWorkloadKey,
441
459
  ]);
442
460
  const selectView = useCallback(
443
- (view: ApplicationRouteView) => {
461
+ (view: ApplicationRouteView, options?: { replace?: boolean }) => {
444
462
  const params = new URLSearchParams(searchParams);
445
463
  params.delete("tab");
446
464
  params.delete("run");
@@ -457,12 +475,12 @@ function AppDetailRoute({
457
475
  params.set("view", view === "history" ? "timeline" : view);
458
476
  params.delete("workload");
459
477
  }
460
- setSearchParams(params);
478
+ setSearchParams(params, { replace: options?.replace });
461
479
  },
462
480
  [searchParams, setSearchParams, singleWorkloadKey],
463
481
  );
464
482
  const selectWorkload = useCallback(
465
- (key: string | null, options?: { tab?: string }) => {
483
+ (key: string | null, options?: { tab?: string; replace?: boolean }) => {
466
484
  const params = new URLSearchParams(searchParams);
467
485
  params.delete("run");
468
486
  if (key) {
@@ -477,9 +495,13 @@ function AppDetailRoute({
477
495
  } else {
478
496
  params.delete("workload");
479
497
  params.delete("tab");
480
- params.delete("view");
498
+ if (!options?.replace) {
499
+ params.delete("view");
500
+ } else if (!params.get("view") && searchParams.get("tab") === "deploys") {
501
+ params.set("view", "deploys");
502
+ }
481
503
  }
482
- setSearchParams(params);
504
+ setSearchParams(params, { replace: options?.replace });
483
505
  },
484
506
  [searchParams, selectedWorkloadKey, setSearchParams, singleWorkloadKey],
485
507
  );
@@ -663,6 +685,16 @@ function AppDetailRoute({
663
685
  [apps],
664
686
  );
665
687
 
688
+ const renderDeploys = deliverySource && (deliveryRecords.length > 0 || requestedDeploys)
689
+ ? () => <ApplicationDeploys source={deliverySource} records={deliveryRecords} loading={historyQuery.isLoading} unavailable={historyQuery.isError} partialSources={partialSources} onOpenSource={openSource} />
690
+ : needsDeploySource && (historyQuery.isError || sourceUnavailable)
691
+ ? () => <AlertBanner className="m-4" variant="warning" title={sourceUnavailable ? "Delivery records are unavailable" : "Delivery records could not be refreshed"} items={partialSources} />
692
+ : undefined;
693
+ const normalizeDeploysAlias = appDeploysAlias && !!renderDeploys;
694
+ useEffect(() => {
695
+ if (normalizeDeploysAlias) selectView("deploys", { replace: true });
696
+ }, [normalizeDeploysAlias, selectView]);
697
+
666
698
  return (
667
699
  <div className="flex min-h-0 flex-1 flex-col overflow-hidden">
668
700
  <ArgoSyncDetailsContext.Provider value={ArgoSyncDetails}>
@@ -697,8 +729,8 @@ function AppDetailRoute({
697
729
  onSelectWorkload={selectWorkload}
698
730
  selectedView={selectedView}
699
731
  onSelectView={selectView}
700
- renderDeploys={deliverySource && showDeploys ? () =>
701
- <ApplicationDeploys source={deliverySource} records={historyQuery.isError ? [] : deliveryRecords} loading={historyQuery.isLoading} unavailable={historyQuery.isError} partialSources={historyQuery.data?.partialSources} onOpenSource={openSource} /> : undefined}
732
+ selectionLoading={waitingForDeploySource || clearDeploySelection || clearCostSelection}
733
+ renderDeploys={renderDeploys}
702
734
  renderWorkloadRevisions={(workload) => <WorkloadRevisionsButton {...workload} />}
703
735
  costViewSelected={applicationCostSelected}
704
736
  onSelectCostView={() => selectView("cost")}
@@ -717,15 +749,21 @@ function AppDetailRoute({
717
749
  }
718
750
  renderOverviewIssues={() => (
719
751
  <AppOverviewIssues
752
+ key={app.key}
753
+ application={app}
720
754
  issues={appIssues}
721
755
  error={issuesQuery.error}
722
- hasData={Boolean(issuesQuery.data)}
723
- visibility={issuesQuery.data?.visibility}
756
+ hasData={Boolean(issueData)}
757
+ visibility={issueData?.visibility}
758
+ truncated={!!issueData && (issueData.total_matched ?? issueData.issues.length) > issueData.issues.length}
724
759
  onOpenResource={onOpenResource}
725
760
  />
726
761
  )}
727
762
  hasOverviewIssues={appIssues.length > 0}
728
- renderWorkload={(workload: SelectedAppWorkload, context) => (
763
+ renderWorkload={(workload: SelectedAppWorkload, context) => requestedDeploys &&
764
+ (waitingForDeploySource || clearDeploySelection || normalizeSingleWorkload) ? (
765
+ <PaneLoader label="Loading workload view…" className="h-full" />
766
+ ) : (
729
767
  <div className="h-full overflow-hidden">
730
768
  <WorkloadView
731
769
  {...context}
@@ -762,28 +800,26 @@ function applicationHistoryRangeOptions(
762
800
  }
763
801
 
764
802
  function AppOverviewIssues({
803
+ application,
765
804
  issues,
766
805
  error,
767
806
  hasData,
768
807
  visibility,
808
+ truncated,
769
809
  onOpenResource,
770
810
  }: {
811
+ application: Pick<AppRow, "key" | "name">;
771
812
  issues: Issue[];
772
813
  error: unknown;
773
814
  hasData: boolean;
774
815
  visibility?: IssuesResponse["visibility"];
816
+ truncated: boolean;
775
817
  onOpenResource: (resource: SelectedResource) => void;
776
818
  }) {
777
- const [openId, setOpenId] = useState<string | null>(null);
778
- const sorted = useMemo(
779
- () => [...issues].sort(compareAppOverviewIssues),
780
- [issues],
781
- );
782
-
783
819
  if (error && !hasData) {
784
820
  return (
785
821
  <AppOverviewIssuesState
786
- headline="Operational issues unavailable"
822
+ headline="Issues unavailable"
787
823
  body={
788
824
  error instanceof Error
789
825
  ? error.message
@@ -793,57 +829,40 @@ function AppOverviewIssues({
793
829
  );
794
830
  }
795
831
 
796
- if (error) {
797
- return (
798
- <section className="space-y-2">
832
+ if (!error && !visibility?.impact && !truncated && issues.length === 0) return null;
833
+
834
+ const navigate = (ref: IssueResourceRef) => {
835
+ onOpenResource({
836
+ kind: kindToPluralWithGroup(ref.kind, ref.group ?? ""),
837
+ namespace: ref.namespace ?? "",
838
+ name: ref.name,
839
+ group: ref.group ?? "",
840
+ });
841
+ };
842
+
843
+ return (
844
+ <section className="space-y-2">
845
+ {error ? (
799
846
  <AppOverviewIssuesState
800
- headline="Operational issue refresh failed"
847
+ headline="Issue refresh failed"
801
848
  body="Showing the last successful result for this application."
802
849
  />
803
- {sorted.length > 0 && (
804
- <AppOverviewIssueRows
805
- issues={sorted}
806
- openId={openId}
807
- setOpenId={setOpenId}
808
- onOpenResource={onOpenResource}
809
- />
810
- )}
811
- </section>
812
- );
813
- }
814
-
815
- if (visibility?.impact) {
816
- return (
817
- <section className="space-y-2">
850
+ ) : visibility?.impact && (
818
851
  <AppOverviewIssuesState
819
- headline={
820
- sorted.length === 0
821
- ? "No visible operational issues"
822
- : "Operational issue visibility is limited"
823
- }
852
+ headline={issues.length ? "Issue visibility is limited" : "No visible issues"}
824
853
  body={`${visibility.impact} Results may be incomplete.`}
825
854
  />
826
- {sorted.length > 0 && (
827
- <AppOverviewIssueRows
828
- issues={sorted}
829
- openId={openId}
830
- setOpenId={setOpenId}
831
- onOpenResource={onOpenResource}
832
- />
833
- )}
834
- </section>
835
- );
836
- }
837
-
838
- if (sorted.length === 0) return null;
839
-
840
- return (
841
- <AppOverviewIssueRows
842
- issues={sorted}
843
- openId={openId}
844
- setOpenId={setOpenId}
845
- onOpenResource={onOpenResource}
846
- />
855
+ )}
856
+ {truncated && (
857
+ <AppOverviewIssuesState
858
+ headline="Issue results are incomplete"
859
+ body="Radar reached the issue limit for these namespaces. Some issues for this application may be missing."
860
+ />
861
+ )}
862
+ {issues.length > 0 && (
863
+ <IssuesView application={application} anyData issues={issues} onResourceClick={navigate} />
864
+ )}
865
+ </section>
847
866
  );
848
867
  }
849
868
 
@@ -872,90 +891,25 @@ function AppOverviewIssuesState({
872
891
  );
873
892
  }
874
893
 
875
- function AppOverviewIssueRows({
876
- issues: sorted,
877
- openId,
878
- setOpenId,
879
- onOpenResource,
880
- }: {
881
- issues: Issue[];
882
- openId: string | null;
883
- setOpenId: (value: string | null) => void;
884
- onOpenResource: (resource: SelectedResource) => void;
885
- }) {
886
- const navigate = (ref: IssueResourceRef) => {
887
- onOpenResource({
888
- kind: kindToPluralWithGroup(ref.kind, ref.group ?? ""),
889
- namespace: ref.namespace ?? "",
890
- name: ref.name,
891
- group: ref.group ?? "",
892
- });
893
- };
894
-
895
- return (
896
- <section className="space-y-2">
897
- <div className="flex items-center justify-between gap-3">
898
- <div className="flex min-w-0 items-center gap-2 text-sm font-semibold text-theme-text-primary">
899
- <AlertTriangle
900
- className="h-4 w-4 shrink-0 text-theme-text-secondary"
901
- aria-hidden
902
- />
903
- <span>Operational Issues</span>
904
- <span className="badge-sm text-[10px] text-theme-text-secondary">
905
- {sorted.length}
906
- </span>
907
- </div>
908
- <span className="text-xs text-theme-text-tertiary">
909
- Scoped to this application
910
- </span>
911
- </div>
912
- <ol className="flex flex-col gap-1.5">
913
- {sorted.slice(0, 4).map((issue) => {
914
- const rowKey = `${issue.cluster_id ?? ""}:${issue.id}`;
915
- return (
916
- <IssueRow
917
- key={rowKey}
918
- issue={issue}
919
- open={openId === rowKey}
920
- onToggle={() => setOpenId(openId === rowKey ? null : rowKey)}
921
- onResourceClick={navigate}
922
- />
923
- );
924
- })}
925
- </ol>
926
- {sorted.length > 4 ? (
927
- <div className="text-xs text-theme-text-tertiary">
928
- Showing 4 of {sorted.length} issues. Open Issues for the full queue.
929
- </div>
930
- ) : null}
931
- </section>
932
- );
933
- }
934
-
935
- function compareAppOverviewIssues(a: Issue, b: Issue): number {
936
- const severity =
937
- ISSUE_SEVERITY_RANK[b.severity] - ISSUE_SEVERITY_RANK[a.severity];
938
- if (severity !== 0) return severity;
939
- const onset = compareIssueSortAnchors(a, b);
940
- if (onset !== 0) return onset;
941
- const ns = (a.namespace ?? "").localeCompare(b.namespace ?? "");
942
- if (ns !== 0) return ns;
943
- const name = a.name.localeCompare(b.name);
944
- if (name !== 0) return name;
945
- return a.id.localeCompare(b.id);
946
- }
947
-
948
- export function appIssuesForWorkloads(
894
+ export function appIssuesForApplication(
949
895
  issues: Issue[],
950
- workloads: AppWorkload[],
896
+ app: Pick<AppRow, "key" | "workloads">,
897
+ inventory: AppRow[],
898
+ completeInventory: boolean,
951
899
  ): Issue[] {
952
- if (issues.length === 0 || workloads.length === 0) return [];
900
+ if (issues.length === 0) return [];
901
+ const ownerForIssue = buildIssueAppIndex(inventory, { complete: completeInventory });
902
+ const workloads = app.workloads;
953
903
  const workloadKeys = new Set(workloads.map(workloadIssueKey));
954
904
  const out: Issue[] = [];
955
905
  const seen = new Set<string>();
956
906
  for (const issue of issues) {
957
- if (!issueRefs(issue).some((ref) => workloadKeys.has(issueRefKey(ref))))
958
- continue;
907
+ // Diagnostic evidence can show that an issue affects this app even when
908
+ // the queue cannot attribute ownership to a single application.
909
+ if (
910
+ ownerForIssue(issue)?.key !== app.key &&
911
+ !issueRefs(issue).some((ref) => workloadKeys.has(issueRefKey(ref)))
912
+ ) continue;
959
913
  if (seen.has(issue.id)) continue;
960
914
  seen.add(issue.id);
961
915
  out.push(issue);
@@ -41,5 +41,8 @@ it('states that conditions have not been reported', () => {
41
41
  act(() => root.render(<CNPGOperatorConditions conditions={[]} />))
42
42
  expect(host.textContent).toContain('No conditions reported')
43
43
  expect(host.querySelector('button')!.getAttribute('aria-expanded')).toBe('false')
44
+ act(() => host.querySelector('button')!.click())
45
+ expect(host.textContent).toContain('The operator has not reported status.conditions.')
46
+ expect(host.querySelector('section')!.className.split(' ').sort()).toEqual('mx-4 mb-4 rounded-xl border border-theme-border bg-theme-surface px-4 py-3 shadow-theme-sm'.split(' ').sort())
44
47
  act(() => root.unmount())
45
48
  })
@@ -1,16 +1,6 @@
1
- import { Badge, FactGrid, FactRow, FoldSection, Tooltip, formatAge } from '@skyhook-io/k8s-ui'
1
+ import { WorkspaceConditions } from '../workspace/WorkspaceConditions'
2
+ import type { ComponentProps } from 'react'
2
3
 
3
- export function CNPGOperatorConditions({ conditions }: { conditions: { type: string; status: string; reason?: string; message?: string; lastTransitionTime?: string }[] }) {
4
- return (
5
- <section className="mx-4 mb-4 rounded-xl border border-theme-border bg-theme-surface px-4 py-3 shadow-theme-sm">
6
- <FoldSection title="Operator conditions" summary={conditions.length > 0 ? `${conditions.length} reported · status.conditions` : 'No conditions reported'} attention={false}>
7
- <FactGrid>{conditions.map((c) => <FactRow key={c.type} label={<span className="inline-flex flex-wrap items-center gap-2">{c.type}<Badge severity="neutral" size="sm">{c.status}</Badge></span>}>
8
- <div className="text-xs text-theme-text-secondary">Reason: {c.reason || 'Not reported'}</div>
9
- <div className="break-words text-xs text-theme-text-secondary">{c.message || 'No message reported'}</div>
10
- <div className="text-xs text-theme-text-tertiary">Last transition: {c.lastTransitionTime ? <Tooltip content={c.lastTransitionTime}><time dateTime={c.lastTransitionTime}>{formatAge(c.lastTransitionTime)} ago</time></Tooltip> : 'Not reported'}</div>
11
- </FactRow>)}</FactGrid>
12
- {conditions.length === 0 && <p className="text-sm text-theme-text-tertiary">The operator has not reported status.conditions.</p>}
13
- </FoldSection>
14
- </section>
15
- )
4
+ export function CNPGOperatorConditions(props: Pick<ComponentProps<typeof WorkspaceConditions>, 'conditions'>) {
5
+ return <WorkspaceConditions {...props} title="Operator conditions" className="mx-4 mb-4" emptyMessage="The operator has not reported status.conditions." />
16
6
  }
@@ -9,7 +9,7 @@ describe('CNPG host composition', () => {
9
9
  const path = cnpgHost.detailRedirect(resource, search)!
10
10
  const url = new URL(path, 'http://radar.test')
11
11
  expect(url.pathname).toBe('/cnpg/clusters/db/pg')
12
- expect(Object.fromEntries(url.searchParams)).toEqual({ ctx: 'kind-demo', tab: 'activity', drawer: 'pods:pg-1' })
12
+ expect(Object.fromEntries(url.searchParams)).toEqual({ ctx: 'kind-demo', tab: 'timeline', drawer: 'pods:pg-1' })
13
13
  expect(search.get('tab')).toBe('timeline')
14
14
  expect(search.get('apiGroup')).toBe('postgresql.cnpg.io')
15
15
  })
@@ -34,8 +34,6 @@ export const cnpgHost = {
34
34
  if (!plural) return null
35
35
  const params = new URLSearchParams(search)
36
36
  params.delete('apiGroup')
37
- const tab = params.get('tab')
38
- if (plural === 'clusters' && (tab === 'timeline' || tab === 'events')) params.set('tab', 'activity')
39
37
  const base = cnpgDetailPath({ plural, namespace: resource.namespace, name: resource.name })
40
38
  const qs = params.toString()
41
39
  return qs ? `${base}?${qs}` : base
@@ -9,17 +9,21 @@ import { TrafficFlowListTab } from './TrafficFlowListTab'
9
9
  import { useFlowSearch } from '../traffic/TrafficFlowListContext'
10
10
  import { Search } from 'lucide-react'
11
11
 
12
- function renderTabContent(tab: DockTab, isActive: boolean, viewNamespaces: string[]) {
12
+ function renderTabContent(tab: DockTab, isActive: boolean, viewNamespaces: string[], removeTab: (id: string) => void, setTerminalContainer: (id: string, name: string) => void) {
13
13
  if (tab.type === 'terminal') {
14
14
  return (
15
15
  <TerminalTab
16
16
  namespace={tab.namespace!}
17
17
  podName={tab.podName!}
18
+ podUID={tab.podUID}
18
19
  containerName={tab.containerName!}
20
+ onContainerChange={name => setTerminalContainer(tab.id, name)}
19
21
  containers={tab.containers!}
20
22
  isActive={isActive}
21
23
  shell={tab.shell}
22
24
  note={tab.sessionNote}
25
+ debugSession={tab.debugSession}
26
+ onLeaveTerminal={() => removeTab(tab.id)}
23
27
  />
24
28
  )
25
29
  }
@@ -94,8 +98,8 @@ function renderTabHeaderExtra(tab: DockTab) {
94
98
  }
95
99
 
96
100
  export function BottomDock({ viewNamespaces }: { viewNamespaces: string[] }) {
97
- const { leftOffset, tabs } = useDock()
101
+ const { leftOffset, tabs, removeTab, setTerminalContainer } = useDock()
98
102
  const hasTrafficFlows = tabs.some(t => t.type === 'traffic-flows')
99
- const renderContent = useCallback((tab: DockTab, isActive: boolean) => renderTabContent(tab, isActive, viewNamespaces), [viewNamespaces])
103
+ const renderContent = useCallback((tab: DockTab, isActive: boolean) => renderTabContent(tab, isActive, viewNamespaces, removeTab, setTerminalContainer), [viewNamespaces, removeTab, setTerminalContainer])
100
104
  return <K8sBottomDock renderTabContent={renderContent} renderTabHeaderExtra={renderTabHeaderExtra} leftOffset={leftOffset} defaultHeight={hasTrafficFlows ? 300 : undefined} />
101
105
  }