@skyhook-io/radar-app 1.20.3 → 1.21.1

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 (167) hide show
  1. package/package.json +10 -9
  2. package/src/App.tsx +67 -15
  3. package/src/api/client.audit-gating.test.tsx +105 -5
  4. package/src/api/client.auditBadgesSync.test.tsx +118 -0
  5. package/src/api/client.capabilitiesPoll.test.ts +61 -0
  6. package/src/api/client.ts +129 -5
  7. package/src/api/namespaceScopeRetry.test.ts +14 -0
  8. package/src/api/radarFeatures.ts +11 -0
  9. package/src/api/substrateHealth.ts +134 -0
  10. package/src/api/velero.test.ts +60 -0
  11. package/src/api/velero.ts +377 -0
  12. package/src/api/vulnerabilities.ts +313 -0
  13. package/src/components/NamespaceSwitcher.tsx +3 -1
  14. package/src/components/audit/AuditView.tsx +4 -0
  15. package/src/components/audit/ChecksViewTabs.test.tsx +35 -5
  16. package/src/components/audit/ChecksViewTabs.tsx +12 -1
  17. package/src/components/audit/Java4ShellPanel.test.tsx +31 -0
  18. package/src/components/audit/Java4ShellPanel.tsx +313 -0
  19. package/src/components/audit/UpgradeReadinessView.test.ts +35 -1
  20. package/src/components/audit/UpgradeReadinessView.tsx +60 -2
  21. package/src/components/audit/VulnerabilitiesView.tsx +944 -0
  22. package/src/components/cnpg/CNPGClusterTabs.tsx +3 -1
  23. package/src/components/cnpg/CNPGDrawerTrail.tsx +5 -26
  24. package/src/components/cnpg/CNPGInvestigationAction.test.tsx +27 -6
  25. package/src/components/cnpg/CNPGView.tsx +43 -117
  26. package/src/components/cnpg/CNPGWorkspace.compatibility.test.tsx +30 -0
  27. package/src/components/cnpg/host.tsx +2 -2
  28. package/src/components/cnpg/routes.ts +3 -1
  29. package/src/components/cnpg/shared.tsx +5 -53
  30. package/src/components/cnpg/useCNPGNavigate.ts +1 -21
  31. package/src/components/cnpg/useCNPGSidebarWorkspace.ts +16 -13
  32. package/src/components/community.tsx +42 -0
  33. package/src/components/diagnose/diagnoseEvidenceTypes.ts +2 -0
  34. package/src/components/diagnose/investigationMetrics.test.ts +20 -0
  35. package/src/components/diagnose/investigationMetrics.ts +2 -1
  36. package/src/components/dock/BottomDock.tsx +1 -0
  37. package/src/components/dock/LogsTab.tsx +3 -0
  38. package/src/components/gitops/FluxOperatorCard.test.tsx +37 -0
  39. package/src/components/gitops/FluxOperatorCard.tsx +27 -0
  40. package/src/components/gitops/GitOpsView.rowsSummary.test.tsx +59 -0
  41. package/src/components/gitops/GitOpsView.tsx +8 -5
  42. package/src/components/gitops/gitopsRowEvents.test.ts +48 -0
  43. package/src/components/gitops/gitopsRowEvents.ts +31 -0
  44. package/src/components/helm/HelmDrawerFrame.tsx +1 -1
  45. package/src/components/helm/HelmView.tsx +20 -16
  46. package/src/components/helm/OwnedResources.tsx +4 -3
  47. package/src/components/home/ClusterHealthCard.tsx +3 -1
  48. package/src/components/home/HomeAgentBlock.tsx +3 -0
  49. package/src/components/home/HomeView.tsx +7 -0
  50. package/src/components/home/MCPSetupDialog.test.tsx +19 -12
  51. package/src/components/home/MCPSetupDialog.tsx +4 -2
  52. package/src/components/home/mcpToolCatalog.ts +15 -2
  53. package/src/components/home/useVulnerabilitiesRow.test.ts +26 -0
  54. package/src/components/home/useVulnerabilitiesRow.ts +50 -0
  55. package/src/components/logs/LogsViewer.tsx +3 -1
  56. package/src/components/logs/MultiPodLogsTab.test.tsx +24 -4
  57. package/src/components/logs/MultiPodLogsTab.tsx +9 -5
  58. package/src/components/nav/PrimaryNavRail.test.tsx +17 -0
  59. package/src/components/nav/PrimaryNavRail.tsx +174 -29
  60. package/src/components/resource/PrometheusChartsGrid.tsx +5 -1
  61. package/src/components/resource/SubstrateHealthCharts.test.tsx +143 -0
  62. package/src/components/resource/SubstrateHealthCharts.tsx +254 -0
  63. package/src/components/resource/SubstrateVerdictLine.test.tsx +131 -0
  64. package/src/components/resource/SubstrateVerdictLine.tsx +180 -0
  65. package/src/components/resources/ResourcesView.tsx +12 -6
  66. package/src/components/resources/renderers/UpgradePlanRenderer.test.tsx +20 -0
  67. package/src/components/resources/renderers/UpgradePlanRenderer.tsx +22 -0
  68. package/src/components/resources/renderers/VeleroBackupRenderer.tsx +16 -36
  69. package/src/components/resources/renderers/VeleroRestoreRenderer.tsx +6 -19
  70. package/src/components/resources/renderers/WorkloadRenderer.tsx +8 -0
  71. package/src/components/rightsizing/RightsizingScanView.tsx +3 -2
  72. package/src/components/shared/LargeClusterNamespacePicker.test.tsx +27 -0
  73. package/src/components/shared/LargeClusterNamespacePicker.tsx +8 -2
  74. package/src/components/timeline/TimelineView.tsx +3 -1
  75. package/src/components/traffic/TrafficConnectionsTable.test.tsx +94 -0
  76. package/src/components/traffic/TrafficConnectionsTable.tsx +21 -5
  77. package/src/components/traffic/TrafficData.test.tsx +37 -0
  78. package/src/components/traffic/TrafficData.tsx +27 -0
  79. package/src/components/traffic/TrafficFlowList.tsx +9 -7
  80. package/src/components/traffic/TrafficGraph.layoutEngine.test.tsx +193 -0
  81. package/src/components/traffic/TrafficGraph.test.tsx +269 -0
  82. package/src/components/traffic/TrafficGraph.tsx +135 -64
  83. package/src/components/traffic/TrafficGraphUnavailable.tsx +57 -0
  84. package/src/components/traffic/TrafficView.layoutUnavailable.test.tsx +211 -0
  85. package/src/components/traffic/TrafficView.tsx +46 -129
  86. package/src/components/traffic/trafficFilters.test.ts +172 -1
  87. package/src/components/traffic/trafficFilters.ts +139 -0
  88. package/src/components/ui/DiagnosticsOverlay.tsx +14 -1
  89. package/src/components/ui/UpdateNotification.manual.test.tsx +5 -2
  90. package/src/components/ui/UpdateNotification.test.tsx +31 -2
  91. package/src/components/ui/UpdateNotification.tsx +34 -17
  92. package/src/components/ui/command-items.ts +24 -1
  93. package/src/components/velero/VeleroBackupNow.test.tsx +165 -0
  94. package/src/components/velero/VeleroBackupNow.tsx +143 -0
  95. package/src/components/velero/VeleroDeleteBackup.test.tsx +364 -0
  96. package/src/components/velero/VeleroDeleteBackup.tsx +306 -0
  97. package/src/components/velero/VeleroDetailPage.tsx +158 -0
  98. package/src/components/velero/VeleroKindLists.test.tsx +48 -0
  99. package/src/components/velero/VeleroKindLists.tsx +43 -0
  100. package/src/components/velero/VeleroLocations.expand.test.tsx +27 -0
  101. package/src/components/velero/VeleroLocations.test.tsx +86 -0
  102. package/src/components/velero/VeleroLocations.tsx +240 -0
  103. package/src/components/velero/VeleroOverview.test.tsx +311 -0
  104. package/src/components/velero/VeleroOverview.tsx +485 -0
  105. package/src/components/velero/VeleroPages.test.tsx +516 -0
  106. package/src/components/velero/VeleroPages.tsx +1056 -0
  107. package/src/components/velero/VeleroRunArtifacts.test.tsx +241 -0
  108. package/src/components/velero/VeleroRunArtifacts.tsx +112 -0
  109. package/src/components/velero/VeleroRunLists.tsx +309 -0
  110. package/src/components/velero/VeleroRunMessagesHost.test.tsx +25 -0
  111. package/src/components/velero/VeleroRunMessagesHost.tsx +54 -0
  112. package/src/components/velero/VeleroRunVolumes.test.tsx +247 -0
  113. package/src/components/velero/VeleroRunVolumes.tsx +122 -0
  114. package/src/components/velero/VeleroSchedulePause.test.tsx +211 -0
  115. package/src/components/velero/VeleroSchedulePause.tsx +191 -0
  116. package/src/components/velero/VeleroScheduleStatusBadge.test.tsx +28 -0
  117. package/src/components/velero/VeleroScheduleStatusBadge.tsx +21 -0
  118. package/src/components/velero/VeleroSchedules.tsx +255 -0
  119. package/src/components/velero/VeleroView.tsx +59 -0
  120. package/src/components/velero/VeleroWorkspace.gate.test.tsx +97 -0
  121. package/src/components/velero/attention.test.ts +178 -0
  122. package/src/components/velero/attention.ts +281 -0
  123. package/src/components/velero/backupDelete.test.tsx +91 -0
  124. package/src/components/velero/backupDelete.tsx +182 -0
  125. package/src/components/velero/coverage.test.ts +87 -0
  126. package/src/components/velero/coverage.ts +150 -0
  127. package/src/components/velero/host.tsx +92 -0
  128. package/src/components/velero/routes.ts +78 -0
  129. package/src/components/velero/runs.tsx +121 -0
  130. package/src/components/velero/shared.test.ts +84 -0
  131. package/src/components/velero/shared.tsx +423 -0
  132. package/src/components/velero/useVeleroSidebarWorkspace.test.tsx +28 -0
  133. package/src/components/velero/useVeleroSidebarWorkspace.ts +71 -0
  134. package/src/components/velero/velero.fixtures.ts +61 -0
  135. package/src/components/velero/workspaceRoute.ts +21 -0
  136. package/src/components/vulnerabilities/WorkloadVulnerabilitiesSection.tsx +179 -0
  137. package/src/components/vulnerabilities/parts.test.ts +72 -0
  138. package/src/components/vulnerabilities/parts.tsx +291 -0
  139. package/src/components/whats-new/WhatsNewDialog.test.tsx +6 -4
  140. package/src/components/whats-new/releaseNotes.ts +67 -1
  141. package/src/components/workload/WorkloadView.tsx +64 -27
  142. package/src/components/workspace/DrawerTrailBack.tsx +32 -0
  143. package/src/components/workspace/WorkspaceFrame.tsx +71 -0
  144. package/src/components/workspace/coverage.ts +61 -0
  145. package/src/components/workspace/layout.test.tsx +29 -1
  146. package/src/components/workspace/layout.tsx +15 -5
  147. package/src/components/workspace/sidebar.ts +9 -0
  148. package/src/components/workspace/useWorkspaceDrawer.ts +63 -0
  149. package/src/components/workspace/useWorkspaceNavigate.ts +21 -0
  150. package/src/desktop/AboutDialog.test.ts +12 -0
  151. package/src/desktop/AboutDialog.tsx +151 -0
  152. package/src/desktop/WindowsTitleBar.tsx +359 -0
  153. package/src/desktop/titleBar.test.ts +61 -0
  154. package/src/desktop/titleBar.ts +45 -0
  155. package/src/index.css +19 -0
  156. package/src/integrations/resourceHost.ts +5 -1
  157. package/src/integrations/resourceHosts.test.tsx +14 -2
  158. package/src/integrations/resourceHosts.tsx +22 -6
  159. package/src/integrations/workspaceRoute.ts +1 -1
  160. package/src/integrations/workspaceRoutes.test.ts +11 -0
  161. package/src/integrations/workspaceRoutes.ts +3 -1
  162. package/src/integrations/workspaceScreens.tsx +2 -0
  163. package/src/main.tsx +8 -0
  164. package/src/utils/desktop-zoom.test.ts +53 -0
  165. package/src/utils/desktop-zoom.ts +30 -0
  166. package/src/utils/staleAssetPrompt.test.tsx +76 -0
  167. package/src/utils/staleAssetPrompt.tsx +32 -0
@@ -0,0 +1,22 @@
1
+ import { UpgradePlanRenderer as BaseUpgradePlanRenderer } from '@skyhook-io/k8s-ui/components/resources/renderers/UpgradePlanRenderer'
2
+ import type { PlanNode } from '@skyhook-io/k8s-ui/components/resources/resource-utils-upgrade-plan'
3
+ import type { ResourceRef } from '@skyhook-io/k8s-ui'
4
+ import type { ResourceCoverage } from '@skyhook-io/k8s-ui/types/resource-coverage'
5
+ import { useResources } from '../../../api/client'
6
+
7
+ // A Node read the caller was denied, or one that covered only part of the
8
+ // cluster, is unreadable: progress is then unknown, never "0 of 0". An older
9
+ // Radar reports no coverage; Nodes are cluster-scoped, so its list is whole.
10
+ export function toPlanNodes(query: { data?: any[]; coverage?: ResourceCoverage; error: unknown; isLoading: boolean }): { nodes: PlanNode[] | null | undefined; loading: boolean } {
11
+ if (query.error) return { nodes: null, loading: false }
12
+ if (query.isLoading && !query.data) return { nodes: undefined, loading: true }
13
+ if (!query.data || (query.coverage && query.coverage.status !== 'complete' && query.coverage.status !== 'unknown')) return { nodes: null, loading: false }
14
+ return { nodes: query.data.map((n) => ({ name: n?.metadata?.name ?? '', labels: n?.metadata?.labels ?? {} })), loading: false }
15
+ }
16
+
17
+ /** Host wrapper: feeds the cluster's Nodes to the Plan drawer's per-node progress. */
18
+ export function UpgradePlanRenderer({ data, onNavigate }: { data: any; onNavigate?: (ref: ResourceRef) => void }) {
19
+ const query = useResources<any>('nodes')
20
+ const { nodes, loading } = toPlanNodes({ data: query.data, coverage: query.coverage, error: query.error, isLoading: query.isLoading })
21
+ return <BaseUpgradePlanRenderer data={data} onNavigate={onNavigate} nodes={nodes} nodesLoading={loading} />
22
+ }
@@ -1,9 +1,8 @@
1
- import { LookupFailureNote } from '@skyhook-io/k8s-ui/components/resources/renderers/LookupFailureNote'
2
1
  import { VeleroBackupRenderer as BaseVeleroBackupRenderer } from '@skyhook-io/k8s-ui/components/resources/renderers/VeleroBackupRenderer'
3
- import { resolveBackupStorageLocation } from '@skyhook-io/k8s-ui/components/resources/resource-utils-velero'
4
- import type { ResourceRef } from '@skyhook-io/k8s-ui'
2
+ import { getBackupStorageLocation } from '@skyhook-io/k8s-ui/components/resources/resource-utils-velero'
3
+ import { useOperationalIssuesShown, type ResourceRef } from '@skyhook-io/k8s-ui'
4
+ import { useVeleroRunMessagesFetch, veleroMessagesInIssue } from '../../velero/VeleroRunMessagesHost'
5
5
  import { useResources } from '../../../api/client'
6
- import { useVeleroRunMessages } from '../../../api/policy'
7
6
 
8
7
  /**
9
8
  * Host wrapper adding the two things a Backup cannot answer from its own status:
@@ -21,55 +20,36 @@ import { useVeleroRunMessages } from '../../../api/policy'
21
20
  * this question.
22
21
  */
23
22
  export function VeleroBackupRenderer({ data, onNavigate }: { data: any; onNavigate?: (ref: ResourceRef) => void }) {
24
- const messages = useRunMessages('backups', data)
23
+ const messages = useVeleroRunMessagesFetch('backups', data)
24
+ // A failed run's messages sit with its issue, which says what is wrong.
25
+ const inIssue = veleroMessagesInIssue(data, useOperationalIssuesShown())
25
26
  const namespace = data?.metadata?.namespace ?? ''
26
27
 
28
+ // An unset spec.storageLocation means Velero has not processed the backup
29
+ // yet; there is no location to look up until it does.
30
+ const name = getBackupStorageLocation(data)
27
31
  const locations = useResources<any>('backupstoragelocations', namespace, 'velero.io', {
28
- enabled: !!namespace,
32
+ enabled: !!namespace && !!name,
29
33
  })
30
34
 
31
- // Everything below is gated on the lookup having answered. A location we have
32
- // not read is not a healthy one, and neither is a name we have not resolved:
33
- // an unset spec.storageLocation means whichever location carries spec.default,
34
- // so resolving it against a list that has not loaded produces the literal
35
- // "default", which is wrong on any install that renamed it — and wrong
36
- // permanently when the list errors rather than for a moment.
37
- const answered = !locations.isLoading && !locations.error && locations.data !== undefined
38
- const resolved = answered ? resolveBackupStorageLocation(data, locations.data) : undefined
39
-
40
- const match = answered
41
- ? (locations.data ?? []).find((l: any) => l?.metadata?.name === resolved)
42
- : undefined
35
+ // A location we have not read is not a healthy one, so nothing is claimed
36
+ // until the lookup answers.
37
+ const answered = !!name && !locations.isLoading && !locations.error && locations.data !== undefined
38
+ const match = answered ? (locations.data ?? []).find((l: any) => l?.metadata?.name === name) : undefined
43
39
  const phase = match?.status?.phase
44
40
 
45
41
  // The location the backup names is gone. Velero restores from the location
46
42
  // recorded on the backup, so this is not restorable — and it is invisible
47
43
  // otherwise, because a location that does not exist has no phase to report.
48
- const missing = answered && !!resolved && match === undefined
44
+ const missing = answered && match === undefined
49
45
 
50
46
  return (
51
47
  <BaseVeleroBackupRenderer
52
48
  data={data}
53
49
  storageLocationPhase={phase}
54
- storageLocationName={resolved}
55
50
  storageLocationMissing={missing}
56
- messages={messages}
51
+ messages={inIssue ? undefined : messages}
57
52
  onNavigate={onNavigate}
58
53
  />
59
54
  )
60
55
  }
61
-
62
- // The messages behind the counts. Nothing is fetched until the operator asks:
63
- // reading them makes Velero create a DownloadRequest and pulls an object out of
64
- // storage, which is not work to do on every drawer open.
65
- function useRunMessages(kind: 'backups' | 'restores', data: any) {
66
- const namespace = data?.metadata?.namespace ?? ''
67
- const name = data?.metadata?.name ?? ''
68
- const fetcher = useVeleroRunMessages(kind, namespace, name)
69
- return {
70
- messages: fetcher.data,
71
- loading: fetcher.isPending,
72
- lookupNote: fetcher.error ? <LookupFailureNote errors={[fetcher.error]} what="the messages behind these counts" /> : undefined,
73
- onFetch: namespace && name ? () => fetcher.mutate() : undefined,
74
- }
75
- }
@@ -1,7 +1,6 @@
1
- import { LookupFailureNote } from '@skyhook-io/k8s-ui/components/resources/renderers/LookupFailureNote'
2
1
  import { VeleroRestoreRenderer as BaseVeleroRestoreRenderer } from '@skyhook-io/k8s-ui/components/resources/renderers/VeleroRestoreRenderer'
3
- import type { ResourceRef } from '@skyhook-io/k8s-ui'
4
- import { useVeleroRunMessages } from '../../../api/policy'
2
+ import { useOperationalIssuesShown, type ResourceRef } from '@skyhook-io/k8s-ui'
3
+ import { useVeleroRunMessagesFetch, veleroMessagesInIssue } from '../../velero/VeleroRunMessagesHost'
5
4
 
6
5
  /**
7
6
  * Host wrapper adding the messages behind the run's error and warning counts.
@@ -16,20 +15,8 @@ import { useVeleroRunMessages } from '../../../api/policy'
16
15
  * object out of storage. Same bargain as the network trace's probes.
17
16
  */
18
17
  export function VeleroRestoreRenderer({ data, onNavigate }: { data: any; onNavigate?: (ref: ResourceRef) => void }) {
19
- const namespace = data?.metadata?.namespace ?? ''
20
- const name = data?.metadata?.name ?? ''
21
- const fetcher = useVeleroRunMessages('restores', namespace, name)
22
-
23
- return (
24
- <BaseVeleroRestoreRenderer
25
- data={data}
26
- onNavigate={onNavigate}
27
- messages={{
28
- messages: fetcher.data,
29
- loading: fetcher.isPending,
30
- lookupNote: fetcher.error ? <LookupFailureNote errors={[fetcher.error]} what="the messages behind these counts" /> : undefined,
31
- onFetch: namespace && name ? () => fetcher.mutate() : undefined,
32
- }}
33
- />
34
- )
18
+ const messages = useVeleroRunMessagesFetch('restores', data)
19
+ // A failed run's messages sit with its issue, which says what is wrong.
20
+ const inIssue = veleroMessagesInIssue(data, useOperationalIssuesShown())
21
+ return <BaseVeleroRestoreRenderer data={data} onNavigate={onNavigate} messages={inIssue ? undefined : messages} />
35
22
  }
@@ -8,6 +8,7 @@ import { useQueries, useQueryClient } from '@tanstack/react-query'
8
8
  import { kindToPlural, kindToPluralWithGroup } from '@skyhook-io/k8s-ui/utils/navigation'
9
9
  import type { Relationships, ResourceRef, ResourceWithRelationships, WorkloadPodInfo } from '../../../types'
10
10
  import type { ScalerDiagnosis } from '@skyhook-io/k8s-ui/components/resources/renderers/WorkloadRenderer'
11
+ import { WorkloadVulnerabilitiesSection } from '../../vulnerabilities/WorkloadVulnerabilitiesSection'
11
12
 
12
13
  // Map plural lowercase kind to singular PascalCase for ownerReferences matching
13
14
  function getOwnerKind(kind: string): string {
@@ -21,6 +22,10 @@ function getOwnerKind(kind: string): string {
21
22
  return kindMap[kind] || kind
22
23
  }
23
24
 
25
+ // The workloads the vulnerability rollup names: a ReplicaSet's Pods are
26
+ // named by their Deployment, so a ReplicaSet drawer has no section.
27
+ const VULNERABILITY_KINDS = new Set(['Deployment', 'StatefulSet', 'DaemonSet'])
28
+
24
29
  interface WorkloadRendererProps {
25
30
  kind: string
26
31
  data: any
@@ -99,6 +104,9 @@ export function WorkloadRenderer({ kind, data, onNavigate, scaleBlockedBy, workl
99
104
  policyLoading={policyLoading}
100
105
  policyError={policyError as Error | null}
101
106
  namespaceLimitRangeNames={limitRangesReady ? podLimitRangeNames(limitRanges) : undefined}
107
+ vulnerabilitySection={VULNERABILITY_KINDS.has(getOwnerKind(kind)) && metadata.name ? (
108
+ <WorkloadVulnerabilitiesSection kind={getOwnerKind(kind)} namespace={namespace} name={metadata.name} />
109
+ ) : undefined}
102
110
  scaleBlockedBy={scaleBlockedBy}
103
111
  workloadPods={workloadPods}
104
112
  scalerDiagnostics={scalerDiagnostics}
@@ -37,6 +37,7 @@ import {
37
37
  } from './presentation'
38
38
  import { useNavCustomization } from '../../context/NavCustomization'
39
39
  import { previousSettingsNote, usePreviousIntegrationSettings } from '../../hooks/usePreviousIntegrationSettings'
40
+ import { clsx } from 'clsx'
40
41
 
41
42
  export const RIGHTSIZING_SCAN_DESCRIPTION =
42
43
  'Find CPU and memory requests to increase, reduce, or review. Radar never changes them.'
@@ -396,7 +397,7 @@ export function RightsizingScanView({ namespaces }: RightsizingScanViewProps) {
396
397
  />
397
398
  ) : (
398
399
  <div>
399
- <div className="grid grid-cols-[minmax(230px,1.15fr)_minmax(190px,1fr)_minmax(200px,1fr)_minmax(220px,.9fr)_28px] gap-3 border-b border-theme-border px-4 py-2 text-[11px] font-medium uppercase tracking-wide text-theme-text-tertiary">
400
+ <div className="grid grid-cols-[minmax(230px,1.15fr)_minmax(190px,1fr)_minmax(200px,1fr)_minmax(220px,.9fr)_28px] gap-3 border-b border-theme-border px-3.5 py-2 text-[11px] font-medium uppercase tracking-wide text-theme-text-tertiary">
400
401
  <span>Workload / container</span>
401
402
  <span>CPU request</span>
402
403
  <span>Memory request</span>
@@ -796,7 +797,7 @@ function ScanResultRow({
796
797
  type="button"
797
798
  onClick={onToggle}
798
799
  aria-expanded={open}
799
- className="grid w-full grid-cols-[minmax(230px,1.15fr)_minmax(190px,1fr)_minmax(200px,1fr)_minmax(220px,.9fr)_28px] items-center gap-3 px-4 py-3 text-left hover:bg-theme-hover/50"
800
+ className={clsx('grid w-full grid-cols-[minmax(230px,1.15fr)_minmax(190px,1fr)_minmax(200px,1fr)_minmax(220px,.9fr)_28px] items-center gap-3 text-left hover:bg-theme-hover/50', 'px-3.5 py-2.5' /* TABLE_DENSITY.cellClass in k8s-ui */)}
800
801
  >
801
802
  <div className="min-w-0">
802
803
  <div className="flex items-center gap-2">
@@ -0,0 +1,27 @@
1
+ // @vitest-environment jsdom
2
+ import { act } from 'react'
3
+ import { createRoot, type Root } from 'react-dom/client'
4
+ import { afterEach, beforeEach, describe, expect, it } from 'vitest'
5
+ import { LargeClusterNamespacePicker } from './LargeClusterNamespacePicker'
6
+
7
+ Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
8
+ let root: Root
9
+
10
+ beforeEach(() => {
11
+ const element = document.createElement('div')
12
+ document.body.appendChild(element)
13
+ root = createRoot(element)
14
+ })
15
+
16
+ afterEach(async () => {
17
+ await act(async () => root.unmount())
18
+ document.body.replaceChildren()
19
+ })
20
+
21
+ describe('LargeClusterNamespacePicker', () => {
22
+ it("says the namespace list couldn't be read instead of loading forever", async () => {
23
+ await act(async () => root.render(<LargeClusterNamespacePicker namespaces={undefined} error="Radar couldn't list namespaces; retry shortly" onSelect={() => {}} />))
24
+ expect(document.body.textContent).toContain("Radar couldn't list namespaces; retry shortly")
25
+ expect(document.body.textContent).not.toContain('Loading namespaces')
26
+ })
27
+ })
@@ -2,8 +2,10 @@ import { useState, useRef, useEffect, useMemo, type ReactNode } from 'react'
2
2
  import { Search } from 'lucide-react'
3
3
  import { Input } from '@skyhook-io/k8s-ui'
4
4
 
5
- export function LargeClusterNamespacePicker({ namespaces, onSelect, ranked = false, renderMeta }: {
5
+ export function LargeClusterNamespacePicker({ namespaces, error, onSelect, ranked = false, renderMeta }: {
6
6
  namespaces: { name: string }[] | undefined
7
+ /** Why the namespace list couldn't be read, when it couldn't. */
8
+ error?: string | null
7
9
  onSelect: (ns: string) => void
8
10
  /** Keep the given order (already ranked) instead of sorting by name. */
9
11
  ranked?: boolean
@@ -42,7 +44,11 @@ export function LargeClusterNamespacePicker({ namespaces, onSelect, ranked = fal
42
44
  />
43
45
  </div>
44
46
  <div className="max-h-[240px] overflow-y-auto rounded-lg border border-theme-border bg-theme-base">
45
- {!namespaces ? (
47
+ {!namespaces && error ? (
48
+ <div role="alert" className="px-3 py-6 text-center text-sm text-theme-text-secondary">
49
+ {error}
50
+ </div>
51
+ ) : !namespaces ? (
46
52
  <div className="px-3 py-6 text-center text-sm text-theme-text-tertiary">
47
53
  Loading namespaces…
48
54
  </div>
@@ -277,6 +277,7 @@ interface TimelineViewProps {
277
277
  initialTimeRange?: TimeRange
278
278
  requiresNamespaceFilter?: boolean
279
279
  availableNamespaces?: { name: string }[]
280
+ availableNamespacesError?: string
280
281
  onNamespaceSelect?: (ns: string) => void
281
282
  onOpenDiagnostics?: () => void
282
283
  }
@@ -297,7 +298,7 @@ export function resolveApplicationTimelineScope(searchParams: URLSearchParams, n
297
298
  }
298
299
  }
299
300
 
300
- export function TimelineView({ namespaces, onResourceClick, initialViewMode, initialFilter, initialTimeRange, requiresNamespaceFilter, availableNamespaces, onNamespaceSelect, onOpenDiagnostics }: TimelineViewProps) {
301
+ export function TimelineView({ namespaces, onResourceClick, initialViewMode, initialFilter, initialTimeRange, requiresNamespaceFilter, availableNamespaces, availableNamespacesError, onNamespaceSelect, onOpenDiagnostics }: TimelineViewProps) {
301
302
  // URL is the source of truth for every control below (deep-linkable +
302
303
  // back/forward-restorable). Read on mount, written on user change.
303
304
  const [searchParams, setSearchParams] = useSearchParams()
@@ -951,6 +952,7 @@ export function TimelineView({ namespaces, onResourceClick, initialViewMode, ini
951
952
  <div className="relative">
952
953
  <LargeClusterNamespacePicker
953
954
  namespaces={availableNamespaces}
955
+ error={availableNamespacesError}
954
956
  onSelect={(ns) => onNamespaceSelect?.(ns)}
955
957
  />
956
958
  </div>
@@ -0,0 +1,94 @@
1
+ // @vitest-environment jsdom
2
+ import { act, type ReactNode } from 'react'
3
+ import { createRoot, type Root } from 'react-dom/client'
4
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
5
+ import type { AggregatedFlow } from '../../types'
6
+ import { TrafficConnectionsTable } from './TrafficConnectionsTable'
7
+
8
+ vi.mock('react-virtuoso', () => ({
9
+ Virtuoso: ({ data, itemContent }: { data: AggregatedFlow[]; itemContent: (index: number, flow: AggregatedFlow) => ReactNode }) =>
10
+ <div>{data.map((flow, index) => <div key={index}>{itemContent(index, flow)}</div>)}</div>,
11
+ }))
12
+
13
+ Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
14
+ let container: HTMLDivElement
15
+ let root: Root
16
+
17
+ beforeEach(() => {
18
+ container = document.createElement('div')
19
+ document.body.appendChild(container)
20
+ root = createRoot(container)
21
+ })
22
+ afterEach(() => {
23
+ act(() => root.unmount())
24
+ container.remove()
25
+ })
26
+
27
+ const tcp: AggregatedFlow = {
28
+ source: { name: 'client', namespace: 'shop', kind: 'Pod' },
29
+ destination: { name: 'db', namespace: 'data', kind: 'Pod' },
30
+ protocol: 'tcp', port: 5432, connections: 0, bytesSent: 1024, bytesRecv: 2048, flowCount: 1, lastSeen: '',
31
+ }
32
+
33
+ describe('TrafficConnectionsTable', () => {
34
+ it('shows unmeasured request rate and Data for a TCP-only map, and keeps row selection', () => {
35
+ const onSelect = vi.fn()
36
+ const props = { flows: [tcp], isRateBased: true, selection: null, onSelect, onFocus: vi.fn() }
37
+ act(() => root.render(<TrafficConnectionsTable {...props} />))
38
+ const row = container.querySelector<HTMLElement>('[role="row"]')!
39
+ expect(container.textContent).toContain('Req/sData')
40
+ expect(row.textContent).toContain('—3 KB')
41
+ expect(container.textContent).not.toContain('5xx')
42
+ act(() => row.click())
43
+ expect(onSelect).toHaveBeenCalledWith({ type: 'edge', sourceId: 'shop/client', destId: 'data/db', port: 5432, directionUnknown: false })
44
+ act(() => root.render(<TrafficConnectionsTable {...props} selection={onSelect.mock.calls[0][0]} />))
45
+ expect(container.querySelector('[role="row"]')!.getAttribute('aria-selected')).toBe('true')
46
+ })
47
+
48
+ it('shows HTTP rate beside bytes-only TCP in a mixed map', () => {
49
+ const http = { ...tcp, destination: { ...tcp.destination, name: 'web' }, port: 80, protocol: 'http', connections: 1, requestRate: 0.25, requestCount: 1 }
50
+ act(() => root.render(<TrafficConnectionsTable flows={[tcp, http]} isRateBased selection={null} onSelect={vi.fn()} onFocus={vi.fn()} />))
51
+ const rows = Array.from(container.querySelectorAll('[role="row"]'))
52
+ expect(rows.find(row => row.textContent?.includes('web'))!.textContent).toContain('0.253 KB')
53
+ expect(rows.find(row => row.textContent?.includes('db'))!.textContent).toContain('—3 KB')
54
+ expect(container.textContent).toContain('5xx')
55
+ })
56
+
57
+ it('hides Data when no row has byte figures, and marks a missing row in a mixed view', () => {
58
+ const noBytes = { ...tcp, destination: { ...tcp.destination, name: 'unmeasured' }, bytesSent: 0, bytesRecv: 0 }
59
+ const props = { isRateBased: true, selection: null, onSelect: vi.fn(), onFocus: vi.fn() }
60
+ act(() => root.render(<TrafficConnectionsTable {...props} flows={[noBytes]} />))
61
+ expect(container.textContent).not.toContain('Data')
62
+ expect(container.textContent).not.toContain('0 B')
63
+ act(() => root.render(<TrafficConnectionsTable {...props} flows={[tcp, noBytes]} />))
64
+ const row = Array.from(container.querySelectorAll('[role="row"]')).find(r => r.textContent?.includes('unmeasured'))!
65
+ expect(container.textContent).toContain('Data')
66
+ expect(row.textContent).toContain('——')
67
+ expect(row.textContent).not.toContain('0 B')
68
+ })
69
+
70
+ it('preserves connection counts for count-based sources and older TCP rates', () => {
71
+ act(() => root.render(<TrafficConnectionsTable flows={[tcp]} isRateBased={false} selection={null} onSelect={vi.fn()} onFocus={vi.fn()} />))
72
+ expect(container.textContent).toContain('ConnsData')
73
+ expect(container.querySelector('[role="row"]')!.textContent).toContain('03 KB')
74
+ act(() => root.render(<TrafficConnectionsTable flows={[{ ...tcp, connections: 2 }]} isRateBased selection={null} onSelect={vi.fn()} onFocus={vi.fn()} />))
75
+ expect(container.querySelector('[role="row"]')!.textContent).toContain('2.03 KB')
76
+ })
77
+ })
78
+
79
+ describe('TrafficConnectionsTable protocol data', () => {
80
+ it('renders compact protocol figures without their mixed sum', () => {
81
+ const mixed = { ...tcp, bytesSent: 38668, bytesRecv: 652404, bytesByProtocol: {
82
+ http: { bytesSent: 5969, bytesRecv: 260965 }, tcp: { bytesSent: 32699, bytesRecv: 391439 },
83
+ } }
84
+ act(() => root.render(<TrafficConnectionsTable flows={[mixed, tcp]} isRateBased selection={null} onSelect={vi.fn()} onFocus={vi.fn()} />))
85
+ const lines = Array.from(container.querySelector('[role="row"]')!.querySelectorAll('div.whitespace-nowrap')).map(line => line.textContent)
86
+ expect(lines).toEqual(['HTTP 260.7 KB', 'TCP 414.2 KB'])
87
+ const gridClasses = Array.from(container.querySelectorAll('[role="row"]')).map(row => row.className.split(' ').find(c => c.startsWith('grid-cols-')))
88
+ expect(new Set(gridClasses).size).toBe(1)
89
+ // One figure per line keeps the Data column narrow, so the endpoint columns keep their room.
90
+ expect(gridClasses[0]).toContain('_5rem_6.5rem_')
91
+ expect(container.firstElementChild!.firstElementChild!.className).toContain(gridClasses[0]!)
92
+ expect(container.textContent).not.toMatch(/674\.9 KB|691,?072/)
93
+ })
94
+ })
@@ -3,11 +3,12 @@ import { Virtuoso } from 'react-virtuoso'
3
3
  import { clsx } from 'clsx'
4
4
  import { ArrowRight, Crosshair, Minus } from 'lucide-react'
5
5
  import type { AggregatedFlow } from '../../types'
6
+ import { TrafficData } from './TrafficData'
6
7
  import { SEVERITY_TEXT } from '@skyhook-io/k8s-ui/utils/badge-colors'
7
8
  import { Tooltip } from '../ui/Tooltip'
8
9
  import type { TrafficGraphSelection } from './TrafficGraph'
9
10
  import {
10
- connectionRows, displayVolume, edgesOnPort, flowDrops, flowErrors, formatRate, graphEndpointId, hasStatusData, isExternalKind,
11
+ dataByProtocol, connectionRows, displayVolume, edgesOnPort, flowDrops, flowErrors, formatRate, graphEndpointId, hasStatusData, isExternalKind,
11
12
  type GraphFlow, type TrafficFocus,
12
13
  } from './trafficFilters'
13
14
 
@@ -21,10 +22,16 @@ interface TrafficConnectionsTableProps {
21
22
  focusedId?: string
22
23
  }
23
24
 
24
- const GRID = 'grid grid-cols-[minmax(0,1fr)_1rem_minmax(0,1fr)_6.5rem_5rem_4.5rem_4.5rem] items-center gap-x-3'
25
+ const GRID = 'grid grid-cols-[minmax(0,1fr)_1rem_minmax(0,1fr)_6.5rem_5rem_5rem_4.5rem_4.5rem] items-center gap-x-3'
25
26
  // Without HTTP status anywhere in view (plain TCP) a 5xx column would read as
26
27
  // "no errors" rather than "not measured".
27
- const GRID_NO_STATUS = 'grid grid-cols-[minmax(0,1fr)_1rem_minmax(0,1fr)_6.5rem_5rem_4.5rem] items-center gap-x-3'
28
+ const GRID_NO_STATUS = 'grid grid-cols-[minmax(0,1fr)_1rem_minmax(0,1fr)_6.5rem_5rem_5rem_4.5rem] items-center gap-x-3'
29
+
30
+ const GRID_PROTOCOL_DATA = 'grid grid-cols-[minmax(0,1fr)_1rem_minmax(0,1fr)_6.5rem_5rem_6.5rem_4.5rem_4.5rem] items-center gap-x-3'
31
+ const GRID_PROTOCOL_DATA_NO_STATUS = 'grid grid-cols-[minmax(0,1fr)_1rem_minmax(0,1fr)_6.5rem_5rem_6.5rem_4.5rem] items-center gap-x-3'
32
+
33
+ const GRID_NO_DATA = 'grid grid-cols-[minmax(0,1fr)_1rem_minmax(0,1fr)_6.5rem_5rem_4.5rem_4.5rem] items-center gap-x-3'
34
+ const GRID_NO_DATA_OR_STATUS = 'grid grid-cols-[minmax(0,1fr)_1rem_minmax(0,1fr)_6.5rem_5rem_4.5rem] items-center gap-x-3'
28
35
 
29
36
  function rowSelection(flow: AggregatedFlow): TrafficGraphSelection {
30
37
  return {
@@ -53,7 +60,10 @@ export function TrafficConnectionsTable({ flows, isRateBased, selection, onSelec
53
60
  const rows = useMemo(() => connectionRows(flows), [flows])
54
61
  const selected = useMemo(() => selectedRows(rows, selection), [rows, selection])
55
62
  const showStatus = useMemo(() => flows.some(hasStatusData), [flows])
56
- const grid = showStatus ? GRID : GRID_NO_STATUS
63
+ const showData = useMemo(() => flows.some(f => f.bytesSent > 0 || f.bytesRecv > 0), [flows])
64
+ const splitData = useMemo(() => flows.some(f => dataByProtocol(f).length > 1), [flows])
65
+ const dataGrid = splitData ? (showStatus ? GRID_PROTOCOL_DATA : GRID_PROTOCOL_DATA_NO_STATUS) : (showStatus ? GRID : GRID_NO_STATUS)
66
+ const grid = showData ? dataGrid : (showStatus ? GRID_NO_DATA : GRID_NO_DATA_OR_STATUS)
57
67
 
58
68
  const endpoint = (e: AggregatedFlow['source']) => {
59
69
  const id = graphEndpointId(e)
@@ -89,6 +99,7 @@ export function TrafficConnectionsTable({ flows, isRateBased, selection, onSelec
89
99
  <span>Destination</span>
90
100
  <span>Port</span>
91
101
  <span className="text-right">{isRateBased ? 'Req/s' : 'Conns'}</span>
102
+ {showData && <span className="text-right">Data</span>}
92
103
  {showStatus && <span className="text-right">5xx</span>}
93
104
  <span className="text-right">Dropped</span>
94
105
  </div>
@@ -125,8 +136,13 @@ export function TrafficConnectionsTable({ flows, isRateBased, selection, onSelec
125
136
  {isExternalKind(flow.destination.kind) && <span className="ml-1 text-theme-text-tertiary">ext</span>}
126
137
  </span>
127
138
  <span className="text-right tabular-nums text-theme-text-secondary">
128
- {isRateBased ? formatRate(displayVolume(flow, true)) : flow.connections.toLocaleString()}
139
+ {isRateBased && !flow.connections ? '—' : isRateBased ? formatRate(displayVolume(flow, true)) : flow.connections.toLocaleString()}
129
140
  </span>
141
+ {showData && (
142
+ <span className="text-right tabular-nums text-theme-text-secondary">
143
+ <TrafficData entries={dataByProtocol(flow)} compact stacked />
144
+ </span>
145
+ )}
130
146
  {showStatus && (
131
147
  <span className={clsx('text-right tabular-nums', errors > 0 ? clsx(SEVERITY_TEXT.error, 'font-medium') : 'text-theme-text-tertiary')}>
132
148
  {errors > 0 ? (isRateBased ? formatRate(errors) : errors.toLocaleString()) : hasStatusData(flow) ? '0' : '—'}
@@ -0,0 +1,37 @@
1
+ // @vitest-environment jsdom
2
+ import { renderToStaticMarkup } from 'react-dom/server'
3
+ import { describe, expect, it } from 'vitest'
4
+ import { TrafficData } from './TrafficData'
5
+ import { dataByProtocol } from './trafficFilters'
6
+
7
+ describe('TrafficData', () => {
8
+ it('keeps single-protocol and released aggregate figures unlabeled', () => {
9
+ for (const bytesByProtocol of [undefined, { http: { bytesSent: 100, bytesRecv: 200 } }]) {
10
+ expect(renderToStaticMarkup(<TrafficData entries={dataByProtocol({ bytesSent: 100, bytesRecv: 200, bytesByProtocol })} directional explainOverlap />)).toBe('300 B')
11
+ }
12
+ })
13
+
14
+ it('keeps unmeasured data absent even with zero-byte buckets', () => {
15
+ expect(renderToStaticMarkup(<TrafficData entries={[{ protocol: 'tcp', sent: 0, recv: 0 }]} />)).toBe('—')
16
+ })
17
+
18
+ for (const protocols of [['http', 'tcp'], ['grpc', 'tcp'], ['tcp', 'udp'], ['http', 'grpc']]) {
19
+ it(`explains overlapping measurement types only for ${protocols.join('+')}`, () => {
20
+ const entries = protocols.map(protocol => ({ protocol, sent: 100, recv: 200 }))
21
+ const html = renderToStaticMarkup(<TrafficData entries={entries} directional explainOverlap />)
22
+ expect(html).toContain('100 B sent · 200 B received')
23
+ expect(html).not.toContain('600 B')
24
+ if (protocols.includes('tcp') && protocols.some(p => p === 'http' || p === 'grpc')) {
25
+ expect(html).toContain(`${protocols[0] === 'grpc' ? 'gRPC' : 'HTTP'} body bytes and TCP connection bytes can describe the same calls; shown separately.`)
26
+ } else expect(html).not.toContain('body bytes')
27
+ })
28
+ }
29
+ })
30
+
31
+
32
+ it('shows no unmeasured protocol as 0 B beside a measured one', () => {
33
+ // e.g. Istio's HTTP byte queries failed while ztunnel's TCP bytes came through
34
+ const bytesByProtocol = { http: { bytesSent: 0, bytesRecv: 0 }, tcp: { bytesSent: 100, bytesRecv: 200 } }
35
+ const html = renderToStaticMarkup(<TrafficData entries={dataByProtocol({ bytesSent: 100, bytesRecv: 200, bytesByProtocol })} directional explainOverlap />)
36
+ expect(html).toBe('300 B')
37
+ })
@@ -0,0 +1,27 @@
1
+ import { formatBytes } from '@skyhook-io/k8s-ui/utils/format'
2
+ import { isPayloadProtocol, protocolName, type ProtocolData } from './trafficFilters'
3
+
4
+ export function TrafficData({ entries, compact = false, stacked = false, directional = false, explainOverlap = false }: {
5
+ entries: ProtocolData[]
6
+ compact?: boolean
7
+ /** One figure per line, for narrow columns. */
8
+ stacked?: boolean
9
+ directional?: boolean
10
+ explainOverlap?: boolean
11
+ }) {
12
+ if (!entries.some(e => e.sent > 0 || e.recv > 0)) return <>—</>
13
+ if (entries.length === 1) return <>{formatBytes(entries[0].sent + entries[0].recv)}</>
14
+ const payloads = entries.filter(e => e.protocol !== null && isPayloadProtocol(e.protocol))
15
+ const caption = explainOverlap && entries.some(e => e.protocol?.toLowerCase() === 'tcp') && payloads.length > 0
16
+ ? `${payloads.map(e => protocolName(e.protocol!)).join('/')} body bytes and TCP connection bytes can describe the same calls; shown separately.`
17
+ : null
18
+ const figures = entries.map(e => `${protocolName(e.protocol ?? '')} ${directional
19
+ ? `${formatBytes(e.sent)} sent · ${formatBytes(e.recv)} received`
20
+ : formatBytes(e.sent + e.recv)}`)
21
+ if (compact && !stacked) return <>{figures.join(' · ')}</>
22
+ if (compact) return <>{figures.map((figure, index) => <div key={entries[index].protocol} className="whitespace-nowrap">{figure}</div>)}</>
23
+ return <>
24
+ {figures.map((figure, index) => <div key={entries[index].protocol}>{figure}</div>)}
25
+ {caption && <div className="mt-1 text-theme-text-tertiary font-normal">{caption}</div>}
26
+ </>
27
+ }
@@ -8,7 +8,7 @@ import { SEVERITY_BADGE, SEVERITY_TEXT } from '@skyhook-io/k8s-ui/utils/badge-co
8
8
  import { pluralize, StatusDot } from '@skyhook-io/k8s-ui'
9
9
  import type { StatusTone } from '@skyhook-io/k8s-ui'
10
10
  import { useFlowSearch } from './TrafficFlowListContext'
11
- import { isPolicyDropReason } from './trafficFilters'
11
+ import { isPolicyDropReason, protocolLabel } from './trafficFilters'
12
12
  import { useQuery } from '@tanstack/react-query'
13
13
  import { fetchJSON } from '../../api/client'
14
14
  import { Tooltip } from '../ui/Tooltip'
@@ -208,7 +208,7 @@ export function TrafficFlowList({ flows, responsesCallerOriented }: TrafficFlowL
208
208
  </>
209
209
  )}
210
210
  {!isHTTP && !isDNS && (
211
- <span className="text-theme-text-tertiary uppercase">{flow.protocol}:{flow.port}</span>
211
+ <span className="text-theme-text-tertiary uppercase">{flow.port ? `${flow.protocol}:${flow.port}` : flow.protocol}</span>
212
212
  )}
213
213
  </div>
214
214
 
@@ -248,13 +248,15 @@ export function TrafficFlowList({ flows, responsesCallerOriented }: TrafficFlowL
248
248
  </div>
249
249
  <div>
250
250
  <span className="text-theme-text-tertiary">Protocol: </span>
251
- <span className="text-theme-text-primary">{flow.l7Protocol ? `${flow.l7Protocol} / ${flow.protocol}` : flow.protocol}</span>
251
+ <span className="text-theme-text-primary">{protocolLabel(flow.l7Protocol, flow.protocol)}</span>
252
252
  {flow.httpProtocol && <span className="text-theme-text-tertiary"> ({flow.httpProtocol})</span>}
253
253
  </div>
254
- <div>
255
- <span className="text-theme-text-tertiary">Port: </span>
256
- <span className="text-theme-text-primary">{flow.port}</span>
257
- </div>
254
+ {flow.port !== 0 && (
255
+ <div>
256
+ <span className="text-theme-text-tertiary">Port: </span>
257
+ <span className="text-theme-text-primary">{flow.port}</span>
258
+ </div>
259
+ )}
258
260
  {flow.trafficDirection && (
259
261
  <div>
260
262
  <span className="text-theme-text-tertiary">Direction: </span>