@skyhook-io/radar-app 1.20.1 → 1.21.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 (215) hide show
  1. package/package.json +10 -9
  2. package/src/App.tsx +65 -16
  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.namespaceSwitch.hook.test.tsx +170 -1
  7. package/src/api/client.pauseDeployment.test.tsx +77 -0
  8. package/src/api/client.restartError.test.ts +14 -0
  9. package/src/api/client.revisionRefresh.test.tsx +44 -0
  10. package/src/api/client.rollbackError.test.ts +14 -0
  11. package/src/api/client.ts +347 -16
  12. package/src/api/namespaceScopeRetry.test.ts +14 -0
  13. package/src/api/networkAttachments.test.tsx +120 -0
  14. package/src/api/networkAttachments.ts +30 -0
  15. package/src/api/radarFeatures.test.ts +5 -0
  16. package/src/api/radarFeatures.ts +10 -0
  17. package/src/api/secretsStore.test.ts +33 -0
  18. package/src/api/secretsStore.ts +37 -0
  19. package/src/api/substrateHealth.ts +134 -0
  20. package/src/api/velero.test.ts +60 -0
  21. package/src/api/velero.ts +201 -0
  22. package/src/api/vulnerabilities.ts +255 -0
  23. package/src/components/ConnectionErrorView.test.tsx +11 -0
  24. package/src/components/ConnectionErrorView.tsx +19 -0
  25. package/src/components/ContextSwitcher.tsx +9 -2
  26. package/src/components/NamespaceSwitcher.tsx +3 -1
  27. package/src/components/applications/ApplicationsView.openResource.test.tsx +118 -0
  28. package/src/components/applications/ApplicationsView.tsx +8 -11
  29. package/src/components/audit/AuditView.tsx +4 -0
  30. package/src/components/audit/ChecksViewTabs.test.tsx +33 -5
  31. package/src/components/audit/ChecksViewTabs.tsx +11 -1
  32. package/src/components/audit/UpgradeReadinessView.test.ts +35 -1
  33. package/src/components/audit/UpgradeReadinessView.tsx +60 -2
  34. package/src/components/audit/VulnerabilitiesView.tsx +907 -0
  35. package/src/components/cnpg/CNPGClusterTabs.tsx +3 -1
  36. package/src/components/cnpg/CNPGDrawerTrail.tsx +5 -26
  37. package/src/components/cnpg/CNPGInvestigationAction.test.tsx +27 -6
  38. package/src/components/cnpg/CNPGView.tsx +43 -117
  39. package/src/components/cnpg/CNPGWorkspace.compatibility.test.tsx +30 -0
  40. package/src/components/cnpg/host.tsx +2 -2
  41. package/src/components/cnpg/routes.ts +3 -1
  42. package/src/components/cnpg/shared.tsx +5 -53
  43. package/src/components/cnpg/useCNPGNavigate.ts +1 -21
  44. package/src/components/cnpg/useCNPGSidebarWorkspace.ts +16 -13
  45. package/src/components/community.tsx +42 -0
  46. package/src/components/cost/CostView.tsx +27 -9
  47. package/src/components/diagnose/InvestigationView.tsx +12 -3
  48. package/src/components/diagnose/diagnoseEvidenceTypes.ts +2 -0
  49. package/src/components/diagnose/investigationEvidence/adapters/helm.test.tsx +52 -0
  50. package/src/components/diagnose/investigationEvidence/adapters/helm.ts +10 -0
  51. package/src/components/diagnose/investigationEvidence/bodies/platform.tsx +82 -51
  52. package/src/components/diagnose/investigationEvidence/types.ts +5 -0
  53. package/src/components/diagnose/investigationMetrics.test.ts +20 -0
  54. package/src/components/diagnose/investigationMetrics.ts +2 -1
  55. package/src/components/dock/BottomDock.tsx +1 -0
  56. package/src/components/dock/LogsTab.tsx +3 -0
  57. package/src/components/dock/TerminalPreferences.query.test.tsx +57 -0
  58. package/src/components/dock/TerminalPreferences.test.tsx +68 -0
  59. package/src/components/dock/TerminalPreferences.tsx +73 -0
  60. package/src/components/gitops/GitOpsView.tsx +2 -10
  61. package/src/components/helm/HelmDrawerFrame.tsx +1 -1
  62. package/src/components/helm/HelmReleaseDrawer.tsx +24 -12
  63. package/src/components/helm/HelmView.tsx +25 -19
  64. package/src/components/helm/NotCheckedBadge.test.tsx +62 -0
  65. package/src/components/helm/NotCheckedBadge.tsx +39 -0
  66. package/src/components/helm/OwnedResources.test.tsx +86 -0
  67. package/src/components/helm/OwnedResources.tsx +69 -11
  68. package/src/components/home/ClusterHealthCard.heading.test.tsx +72 -0
  69. package/src/components/home/ClusterHealthCard.test.ts +44 -1
  70. package/src/components/home/ClusterHealthCard.tsx +25 -11
  71. package/src/components/home/HelmSummary.tsx +15 -15
  72. package/src/components/home/HomeAgentBlock.tsx +3 -0
  73. package/src/components/home/HomeView.tsx +7 -0
  74. package/src/components/home/MCPSetupDialog.test.tsx +19 -12
  75. package/src/components/home/MCPSetupDialog.tsx +4 -2
  76. package/src/components/home/mcpToolCatalog.ts +17 -4
  77. package/src/components/home/useVulnerabilitiesRow.test.ts +26 -0
  78. package/src/components/home/useVulnerabilitiesRow.ts +50 -0
  79. package/src/components/logs/LogsViewer.tsx +3 -1
  80. package/src/components/logs/MultiPodLogsTab.test.tsx +24 -4
  81. package/src/components/logs/MultiPodLogsTab.tsx +9 -5
  82. package/src/components/nav/PrimaryNavRail.test.tsx +17 -0
  83. package/src/components/nav/PrimaryNavRail.tsx +174 -29
  84. package/src/components/resource/PrometheusChartsGrid.tsx +5 -1
  85. package/src/components/resource/RightsizingStrip.test.ts +57 -0
  86. package/src/components/resource/RightsizingStrip.tsx +53 -4
  87. package/src/components/resource/SubstrateHealthCharts.test.tsx +143 -0
  88. package/src/components/resource/SubstrateHealthCharts.tsx +254 -0
  89. package/src/components/resource/SubstrateVerdictLine.test.tsx +131 -0
  90. package/src/components/resource/SubstrateVerdictLine.tsx +180 -0
  91. package/src/components/resources/ImageFilesystemModal.test.tsx +74 -6
  92. package/src/components/resources/ImageFilesystemModal.tsx +98 -6
  93. package/src/components/resources/PodFileUploadPanel.tsx +150 -0
  94. package/src/components/resources/PodFilesystemModal.tsx +246 -3
  95. package/src/components/resources/ResourcesView.tsx +12 -6
  96. package/src/components/resources/pod-file-upload.test.tsx +223 -0
  97. package/src/components/resources/pod-file-upload.ts +266 -0
  98. package/src/components/resources/renderers/HTTPRouteRenderer.test.tsx +50 -0
  99. package/src/components/resources/renderers/HTTPRouteRenderer.tsx +27 -0
  100. package/src/components/resources/renderers/PodRenderer.tsx +26 -1
  101. package/src/components/resources/renderers/SecretProviderClassRenderer.tsx +25 -0
  102. package/src/components/resources/renderers/UpgradePlanRenderer.test.tsx +20 -0
  103. package/src/components/resources/renderers/UpgradePlanRenderer.tsx +22 -0
  104. package/src/components/resources/renderers/VeleroBackupRenderer.tsx +16 -36
  105. package/src/components/resources/renderers/VeleroRestoreRenderer.tsx +6 -19
  106. package/src/components/resources/renderers/WorkloadRenderer.tsx +8 -0
  107. package/src/components/rightsizing/RightsizingScanView.tsx +19 -3
  108. package/src/components/rightsizing/model.test.ts +11 -0
  109. package/src/components/rightsizing/model.ts +3 -1
  110. package/src/components/rightsizing/presentation.test.ts +46 -0
  111. package/src/components/rightsizing/presentation.ts +17 -2
  112. package/src/components/shared/LargeClusterNamespacePicker.test.tsx +27 -0
  113. package/src/components/shared/LargeClusterNamespacePicker.tsx +8 -2
  114. package/src/components/timeline/TimelineView.tsx +3 -1
  115. package/src/components/traffic/TrafficConnectionsTable.test.tsx +94 -0
  116. package/src/components/traffic/TrafficConnectionsTable.tsx +21 -5
  117. package/src/components/traffic/TrafficData.test.tsx +37 -0
  118. package/src/components/traffic/TrafficData.tsx +27 -0
  119. package/src/components/traffic/TrafficFlowList.tsx +9 -7
  120. package/src/components/traffic/TrafficGraph.layoutEngine.test.tsx +193 -0
  121. package/src/components/traffic/TrafficGraph.test.tsx +269 -0
  122. package/src/components/traffic/TrafficGraph.tsx +135 -64
  123. package/src/components/traffic/TrafficGraphUnavailable.tsx +57 -0
  124. package/src/components/traffic/TrafficView.layoutUnavailable.test.tsx +211 -0
  125. package/src/components/traffic/TrafficView.tsx +72 -155
  126. package/src/components/traffic/trafficFilters.test.ts +189 -1
  127. package/src/components/traffic/trafficFilters.ts +169 -1
  128. package/src/components/ui/DiagnosticsOverlay.tsx +14 -1
  129. package/src/components/ui/Omnibar.tsx +4 -1
  130. package/src/components/ui/RadarOmnibar.test.tsx +55 -2
  131. package/src/components/ui/RadarOmnibar.tsx +7 -1
  132. package/src/components/ui/SearchSyntaxHelp.test.tsx +9 -2
  133. package/src/components/ui/SearchSyntaxHelp.tsx +3 -2
  134. package/src/components/ui/UpdateNotification.manual.test.tsx +5 -2
  135. package/src/components/ui/UpdateNotification.test.tsx +54 -3
  136. package/src/components/ui/UpdateNotification.tsx +60 -19
  137. package/src/components/ui/command-items.ts +24 -1
  138. package/src/components/ui/omnibar-match.test.ts +7 -0
  139. package/src/components/ui/omnibar-match.ts +1 -0
  140. package/src/components/ui/searchCoverageNote.test.ts +17 -0
  141. package/src/components/ui/searchCoverageNote.ts +31 -7
  142. package/src/components/useContextSwitchFlow.tsx +9 -1
  143. package/src/components/velero/VeleroBackupNow.test.tsx +165 -0
  144. package/src/components/velero/VeleroBackupNow.tsx +143 -0
  145. package/src/components/velero/VeleroDeleteBackup.test.tsx +364 -0
  146. package/src/components/velero/VeleroDeleteBackup.tsx +306 -0
  147. package/src/components/velero/VeleroDetailPage.tsx +148 -0
  148. package/src/components/velero/VeleroKindLists.test.tsx +48 -0
  149. package/src/components/velero/VeleroKindLists.tsx +43 -0
  150. package/src/components/velero/VeleroLocations.expand.test.tsx +27 -0
  151. package/src/components/velero/VeleroLocations.test.tsx +86 -0
  152. package/src/components/velero/VeleroLocations.tsx +240 -0
  153. package/src/components/velero/VeleroOverview.test.tsx +311 -0
  154. package/src/components/velero/VeleroOverview.tsx +485 -0
  155. package/src/components/velero/VeleroPages.test.tsx +516 -0
  156. package/src/components/velero/VeleroPages.tsx +1056 -0
  157. package/src/components/velero/VeleroRunLists.tsx +309 -0
  158. package/src/components/velero/VeleroRunMessagesHost.test.tsx +25 -0
  159. package/src/components/velero/VeleroRunMessagesHost.tsx +54 -0
  160. package/src/components/velero/VeleroScheduleStatusBadge.test.tsx +28 -0
  161. package/src/components/velero/VeleroScheduleStatusBadge.tsx +21 -0
  162. package/src/components/velero/VeleroSchedules.tsx +255 -0
  163. package/src/components/velero/VeleroView.tsx +59 -0
  164. package/src/components/velero/VeleroWorkspace.gate.test.tsx +97 -0
  165. package/src/components/velero/attention.test.ts +178 -0
  166. package/src/components/velero/attention.ts +281 -0
  167. package/src/components/velero/backupDelete.test.tsx +91 -0
  168. package/src/components/velero/backupDelete.tsx +182 -0
  169. package/src/components/velero/coverage.test.ts +87 -0
  170. package/src/components/velero/coverage.ts +150 -0
  171. package/src/components/velero/host.tsx +86 -0
  172. package/src/components/velero/routes.ts +78 -0
  173. package/src/components/velero/runs.tsx +121 -0
  174. package/src/components/velero/shared.test.ts +84 -0
  175. package/src/components/velero/shared.tsx +423 -0
  176. package/src/components/velero/useVeleroSidebarWorkspace.test.tsx +28 -0
  177. package/src/components/velero/useVeleroSidebarWorkspace.ts +71 -0
  178. package/src/components/velero/velero.fixtures.ts +61 -0
  179. package/src/components/velero/workspaceRoute.ts +21 -0
  180. package/src/components/vulnerabilities/WorkloadVulnerabilitiesSection.tsx +167 -0
  181. package/src/components/vulnerabilities/parts.test.ts +72 -0
  182. package/src/components/vulnerabilities/parts.tsx +291 -0
  183. package/src/components/workload/NodeCertificateEvidence.test.tsx +51 -0
  184. package/src/components/workload/NodeCertificateEvidence.tsx +44 -0
  185. package/src/components/workload/WorkloadView.tsx +114 -37
  186. package/src/components/workspace/DrawerTrailBack.tsx +32 -0
  187. package/src/components/workspace/WorkspaceFrame.tsx +71 -0
  188. package/src/components/workspace/coverage.ts +61 -0
  189. package/src/components/workspace/layout.test.tsx +29 -1
  190. package/src/components/workspace/layout.tsx +15 -5
  191. package/src/components/workspace/sidebar.ts +9 -0
  192. package/src/components/workspace/useWorkspaceDrawer.ts +63 -0
  193. package/src/components/workspace/useWorkspaceNavigate.ts +21 -0
  194. package/src/context/ConnectionContext.test.ts +1 -0
  195. package/src/context/ConnectionContext.tsx +2 -2
  196. package/src/desktop/AboutDialog.test.ts +12 -0
  197. package/src/desktop/AboutDialog.tsx +151 -0
  198. package/src/desktop/WindowsTitleBar.tsx +359 -0
  199. package/src/desktop/titleBar.test.ts +61 -0
  200. package/src/desktop/titleBar.ts +45 -0
  201. package/src/index.css +19 -0
  202. package/src/integrations/resourceHost.ts +5 -1
  203. package/src/integrations/resourceHosts.test.tsx +15 -3
  204. package/src/integrations/resourceHosts.tsx +26 -6
  205. package/src/integrations/workspaceRoute.ts +1 -1
  206. package/src/integrations/workspaceRoutes.test.ts +11 -0
  207. package/src/integrations/workspaceRoutes.ts +3 -1
  208. package/src/integrations/workspaceScreens.tsx +2 -0
  209. package/src/main.tsx +8 -0
  210. package/src/utils/desktop-zoom.test.ts +53 -0
  211. package/src/utils/desktop-zoom.ts +30 -0
  212. package/src/utils/namespacePick.test.ts +87 -0
  213. package/src/utils/namespacePick.ts +88 -0
  214. package/src/utils/staleAssetPrompt.test.tsx +76 -0
  215. package/src/utils/staleAssetPrompt.tsx +32 -0
@@ -15,17 +15,32 @@ import {
15
15
  type EdgeMouseHandler,
16
16
  } from '@xyflow/react'
17
17
  import '@xyflow/react/dist/style.css'
18
- import ELK from 'elkjs/lib/elk.bundled.js'
18
+ import type { ELK } from 'elkjs/lib/elk.bundled.js'
19
19
  import type { AggregatedFlow } from '../../types'
20
20
  import { clsx } from 'clsx'
21
21
  import { X, ArrowRight, Globe, Server, Activity, Puzzle, Crosshair } from 'lucide-react'
22
+ import { PaneLoader } from '@skyhook-io/k8s-ui'
22
23
  import { isClusterAddon, type AddonMode } from './TrafficView'
23
24
  import { SEVERITY_BADGE, SEVERITY_DOT, SEVERITY_TEXT } from '@skyhook-io/k8s-ui/utils/badge-colors'
24
25
  import { getNamespaceColor } from '../../utils/traffic-colors'
25
26
  import { Tooltip } from '../ui/Tooltip'
26
- import { isRateBasedSource, isExternalKind, requestRateOf, errorRateOf, formatRate, displayVolume, latencyWeightOf, edgesOnPort, type TrafficFocus } from './trafficFilters'
27
-
28
- const elk = new ELK()
27
+ import { TrafficData } from './TrafficData'
28
+ import { dataByProtocol, protocolsOf, throughputLabel, totalDataByProtocol, protocolName, isRateBasedSource, isExternalKind, requestRateOf, errorRateOf, formatRate, displayVolume, latencyWeightOf, edgesOnPort, protocolLabel, type TrafficFocus } from './trafficFilters'
29
+
30
+ // ELK is 1.5 MB; load it with the first traffic layout, not with the app.
31
+ let elkPromise: Promise<ELK> | null = null
32
+ function loadElk(): Promise<ELK> {
33
+ elkPromise ??= import('elkjs/lib/elk.bundled.js')
34
+ .then(({ default: ELKImpl }) => new ELKImpl())
35
+ .catch((err) => {
36
+ // Let a later layout try again where the browser refetches failed
37
+ // modules. Chromium caches the failure until reload, so there the
38
+ // graph stays unavailable until the user reloads.
39
+ elkPromise = null
40
+ throw err
41
+ })
42
+ return elkPromise
43
+ }
29
44
 
30
45
  // ELK layout options for traffic graph
31
46
  const elkOptions = {
@@ -66,6 +81,12 @@ interface TrafficGraphProps {
66
81
  onFocus?: (focus: TrafficFocus) => void
67
82
  /** The focused node, which is not offered as a focus again. */
68
83
  focusedId?: string
84
+ /** Whether the layout engine failed to load, in which case the graph draws
85
+ * nothing and the view lists the connections in its place. */
86
+ onLayoutUnavailable: (unavailable: boolean) => void
87
+ /** Seconds the byte figures cover, so an edge measured only in bytes can be
88
+ * labelled with its throughput. */
89
+ windowSeconds: number
69
90
  }
70
91
 
71
92
  // Phase 2.1: Calculate edge width based on connection count (log scale)
@@ -424,14 +445,6 @@ interface EdgeData {
424
445
  flow?: AggregatedFlow
425
446
  }
426
447
 
427
- // Format bytes for display
428
- function formatBytes(bytes: number): string {
429
- if (bytes >= 1_000_000_000) return `${(bytes / 1_000_000_000).toFixed(1)} GB`
430
- if (bytes >= 1_000_000) return `${(bytes / 1_000_000).toFixed(1)} MB`
431
- if (bytes >= 1_000) return `${(bytes / 1_000).toFixed(1)} KB`
432
- return `${bytes} B`
433
- }
434
-
435
448
  // Details panel component
436
449
  function DetailsPanel({
437
450
  selection,
@@ -453,31 +466,37 @@ function DetailsPanel({
453
466
  const isNode = selection.type === 'node'
454
467
  const nodeData = isNode ? (selection.data as TrafficNodeData) : null
455
468
  const edgeData = !isNode ? (selection.data as EdgeData) : null
469
+ const edgeDataFigures = edgeData?.flow ? dataByProtocol(edgeData.flow) : []
470
+ const edgeProtocolKeys = edgeData?.flow ? protocolsOf(edgeData.flow) : []
471
+ const edgeProtocols = edgeProtocolKeys.map(protocolName).join(' + ')
472
+ const edgeL7 = edgeData?.flow?.l7Protocol
473
+ const distinctL7 = edgeL7 && edgeL7.toLowerCase() !== 'mixed' && !edgeProtocolKeys.some(p => p.toLowerCase() === edgeL7.toLowerCase())
456
474
 
457
475
  // Find related flows for node
458
476
  const relatedFlows = isNode
459
477
  ? flows.filter(f => {
460
478
  const sourceId = f.source.namespace ? `${f.source.namespace}/${f.source.name}` : f.source.name
461
479
  const destId = f.destination.namespace ? `${f.destination.namespace}/${f.destination.name}` : f.destination.name
462
- return sourceId === selection.id || destId === selection.id
480
+ return (f.source.kind !== 'SkipEdge' && sourceId === selection.id) ||
481
+ (f.destination.kind !== 'SkipEdge' && destId === selection.id)
463
482
  })
464
483
  : []
465
484
 
466
485
  // Categorize flows by direction
467
486
  const incomingFlows = relatedFlows.filter(f => {
468
487
  const destId = f.destination.namespace ? `${f.destination.namespace}/${f.destination.name}` : f.destination.name
469
- return destId === selection.id
488
+ return f.destination.kind !== 'SkipEdge' && destId === selection.id
470
489
  })
471
490
  const outgoingFlows = relatedFlows.filter(f => {
472
491
  const sourceId = f.source.namespace ? `${f.source.namespace}/${f.source.name}` : f.source.name
473
- return sourceId === selection.id
492
+ return f.source.kind !== 'SkipEdge' && sourceId === selection.id
474
493
  })
475
494
 
476
495
  // Compute aggregate stats for node
477
496
  const nodeStats = isNode ? {
478
- totalBytes: relatedFlows.reduce((sum, f) => sum + f.bytesSent + f.bytesRecv, 0),
497
+ data: totalDataByProtocol(relatedFlows),
479
498
  protocols: relatedFlows.reduce((acc, f) => {
480
- const proto = f.protocol?.toUpperCase() || 'TCP'
499
+ const proto = protocolName(f.protocol || 'tcp')
481
500
  acc[proto] = (acc[proto] || 0) + displayVolume(f, isRateBased)
482
501
  return acc
483
502
  }, {} as Record<string, number>),
@@ -617,12 +636,12 @@ function DetailsPanel({
617
636
  </div>
618
637
 
619
638
  {/* Stats grid */}
620
- {nodeStats && (nodeStats.totalBytes > 0 || nodeStats.lastSeen || nodeStats.totalRequests > 0) && (
639
+ {nodeStats && (nodeStats.data.some(e => e.sent > 0 || e.recv > 0) || nodeStats.lastSeen || nodeStats.totalRequests > 0) && (
621
640
  <div className="grid grid-cols-2 gap-2">
622
- {nodeStats.totalBytes > 0 && (
641
+ {nodeStats.data.some(e => e.sent > 0 || e.recv > 0) && (
623
642
  <div className="p-2 rounded bg-theme-elevated text-xs">
624
643
  <div className="text-theme-text-tertiary">Data transferred</div>
625
- <div className="text-theme-text-primary font-medium">{formatBytes(nodeStats.totalBytes)}</div>
644
+ <div className="text-theme-text-primary font-medium"><TrafficData entries={nodeStats.data} /></div>
626
645
  </div>
627
646
  )}
628
647
  {nodeStats.flowCount > 1 && (
@@ -664,7 +683,7 @@ function DetailsPanel({
664
683
  .map(([proto, count]) => (
665
684
  <span key={proto} className="inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-theme-bg text-theme-text-secondary">
666
685
  <span className="font-medium">{proto}</span>
667
- <span className="text-theme-text-tertiary">{formatVolume(count, isRateBased)}{isRateBased ? '/s' : ''}</span>
686
+ {!(isRateBased && !count) && <span className="text-theme-text-tertiary">{formatVolume(count, isRateBased)}{isRateBased ? '/s' : ''}</span>}
668
687
  </span>
669
688
  ))}
670
689
  </div>
@@ -746,8 +765,8 @@ function DetailsPanel({
746
765
  )}
747
766
  </div>
748
767
  <div className="flex items-center gap-2 text-[10px]">
749
- <span className="px-1 py-0.5 rounded bg-theme-bg text-theme-text-tertiary uppercase">
750
- {flow.protocol || 'tcp'}
768
+ <span className="px-1 py-0.5 rounded bg-theme-bg text-theme-text-tertiary">
769
+ {protocolName(flow.protocol || 'tcp')}
751
770
  </span>
752
771
  {flow.connections > 0 && (
753
772
  <span className="text-theme-text-secondary">
@@ -756,7 +775,7 @@ function DetailsPanel({
756
775
  )}
757
776
  {(flow.bytesSent > 0 || flow.bytesRecv > 0) && (
758
777
  <span className="text-theme-text-tertiary">
759
- {formatBytes(flow.bytesSent + flow.bytesRecv)}
778
+ <TrafficData entries={dataByProtocol(flow)} compact />
760
779
  </span>
761
780
  )}
762
781
  {flow.errorCount != null && flow.errorCount > 0 && (
@@ -798,8 +817,8 @@ function DetailsPanel({
798
817
  )}
799
818
  </div>
800
819
  <div className="flex items-center gap-2 text-[10px]">
801
- <span className="px-1 py-0.5 rounded bg-theme-bg text-theme-text-tertiary uppercase">
802
- {flow.protocol || 'tcp'}
820
+ <span className="px-1 py-0.5 rounded bg-theme-bg text-theme-text-tertiary">
821
+ {protocolName(flow.protocol || 'tcp')}
803
822
  </span>
804
823
  {flow.connections > 0 && (
805
824
  <span className="text-theme-text-secondary">
@@ -808,7 +827,7 @@ function DetailsPanel({
808
827
  )}
809
828
  {(flow.bytesSent > 0 || flow.bytesRecv > 0) && (
810
829
  <span className="text-theme-text-tertiary">
811
- {formatBytes(flow.bytesSent + flow.bytesRecv)}
830
+ <TrafficData entries={dataByProtocol(flow)} compact />
812
831
  </span>
813
832
  )}
814
833
  {flow.errorCount != null && flow.errorCount > 0 && (
@@ -853,10 +872,10 @@ function DetailsPanel({
853
872
  )}
854
873
  <div className="p-2 rounded bg-theme-elevated">
855
874
  <div className="text-theme-text-tertiary">Protocol</div>
856
- <div className="text-theme-text-primary font-medium uppercase">
857
- {edgeData.flow?.l7Protocol
858
- ? `${edgeData.flow.l7Protocol} / ${edgeData.protocol}`
859
- : edgeData.protocol}
875
+ <div className="text-theme-text-primary font-medium">
876
+ {edgeProtocolKeys.length > 1
877
+ ? distinctL7 ? protocolLabel(protocolName(edgeL7), edgeProtocols) : edgeProtocols
878
+ : protocolLabel(edgeData.flow?.l7Protocol && protocolName(edgeData.flow.l7Protocol), protocolName(edgeData.protocol))}
860
879
  </div>
861
880
  </div>
862
881
  {(!isRateBased || edgeData.connections > 0) && (
@@ -871,14 +890,15 @@ function DetailsPanel({
871
890
  </div>
872
891
  )}
873
892
  {edgeData.flow && (edgeData.flow.bytesSent > 0 || edgeData.flow.bytesRecv > 0) && (
874
- <div className="p-2 rounded bg-theme-elevated">
875
- <div className="text-theme-text-tertiary">Data</div>
893
+ <div className={clsx('p-2 rounded bg-theme-elevated', edgeDataFigures.length > 1 && 'col-span-2')}>
894
+ <div className="text-theme-text-tertiary">{edgeDataFigures.length > 1 ? 'Data by protocol' : 'Data'}</div>
876
895
  <div className="text-theme-text-primary font-medium">
877
- {formatBytes(edgeData.flow.bytesSent + edgeData.flow.bytesRecv)}
896
+ <TrafficData entries={edgeDataFigures} directional explainOverlap />
878
897
  </div>
879
898
  </div>
880
899
  )}
881
- {edgeData.flow && requestRateOf(edgeData.flow) > 0 && (
900
+ {/* Where the Request Rate above already is this figure, it isn't repeated. */}
901
+ {edgeData.flow && requestRateOf(edgeData.flow) > 0 && !(isRateBased && edgeData.flow.requestRate) && (
882
902
  <div className="p-2 rounded bg-theme-elevated">
883
903
  <div className="text-theme-text-tertiary">Requests</div>
884
904
  <div className="text-theme-text-primary font-medium">
@@ -1140,7 +1160,7 @@ function trafficEdgeId(sourceId: string, destId: string, flow: AggregatedFlow):
1140
1160
  return `${sourceId}->${destId}:${flow.port}${flow.directionUnknown ? ':unoriented' : ''}`
1141
1161
  }
1142
1162
 
1143
- export function TrafficGraph({ flows, hotPathThreshold = 0, showNamespaceGroups = false, serviceCategories, addonMode = 'show', trafficSource = '', selection: viewSelection, onSelectionChange, onFocus, focusedId }: TrafficGraphProps) {
1163
+ export function TrafficGraph({ flows, hotPathThreshold = 0, showNamespaceGroups = false, serviceCategories, addonMode = 'show', trafficSource = '', selection: viewSelection, onSelectionChange, onFocus, focusedId, onLayoutUnavailable, windowSeconds }: TrafficGraphProps) {
1144
1164
  // Beyla is rate-based too: its Connections field carries requests per second,
1145
1165
  // not a connection count, so it needs the same label Istio gets.
1146
1166
  const isRateBased = isRateBasedSource(trafficSource)
@@ -1148,6 +1168,7 @@ export function TrafficGraph({ flows, hotPathThreshold = 0, showNamespaceGroups
1148
1168
  const [layoutedNodes, setLayoutedNodes] = useState<Node<TrafficNodeData>[]>([])
1149
1169
  const [layoutedEdges, setLayoutedEdges] = useState<Edge[]>([])
1150
1170
  const [selection, setSelection] = useState<Selection | null>(null)
1171
+ const [elkUnavailable, setElkUnavailable] = useState(false)
1151
1172
 
1152
1173
  // Store flow data by edge ID for click handler lookup
1153
1174
  const flowByEdgeId = useMemo(() => {
@@ -1159,7 +1180,11 @@ export function TrafficGraph({ flows, hotPathThreshold = 0, showNamespaceGroups
1159
1180
  const destId = flow.destination.namespace
1160
1181
  ? `${flow.destination.namespace}/${flow.destination.name}`
1161
1182
  : flow.destination.name
1162
- const edgeId = trafficEdgeId(sourceId, destId, flow)
1183
+ const edgeId = flow.destination.kind === 'AddonGroupTarget'
1184
+ ? `${sourceId}->addon-group`
1185
+ : flow.source.kind === 'AddonGroupSource'
1186
+ ? `addon-group->${destId}`
1187
+ : trafficEdgeId(sourceId, destId, flow)
1163
1188
  map.set(edgeId, flow)
1164
1189
  })
1165
1190
  return map
@@ -1185,24 +1210,21 @@ export function TrafficGraph({ flows, hotPathThreshold = 0, showNamespaceGroups
1185
1210
  ? `${flow.destination.namespace}/${flow.destination.name}`
1186
1211
  : flow.destination.name
1187
1212
 
1188
- connectionCounts.set(sourceId, (connectionCounts.get(sourceId) || 0) + 1)
1189
- connectionCounts.set(destId, (connectionCounts.get(destId) || 0) + 1)
1190
-
1191
- // Sum total connections
1192
- // Display-only sums: the unrounded rate for a rate-based source.
1213
+ // A placeholder retains volume only for the endpoint outside the virtual edge.
1193
1214
  const volume = displayVolume(flow, isRateBased)
1194
- totalConnections.set(sourceId, (totalConnections.get(sourceId) || 0) + volume)
1195
- totalConnections.set(destId, (totalConnections.get(destId) || 0) + volume)
1196
-
1197
- // Track ports for destination nodes
1198
- if (!nodePorts.has(destId)) nodePorts.set(destId, new Map())
1199
- const portCounts = nodePorts.get(destId)!
1200
- portCounts.set(flow.port, (portCounts.get(flow.port) || 0) + volume)
1201
-
1202
- // Track hot path nodes (Phase 2.3)
1203
- if (flow.connections >= hotPathThreshold && hotPathThreshold > 0) {
1204
- hotNodes.add(sourceId)
1205
- hotNodes.add(destId)
1215
+ if (flow.source.kind !== 'SkipEdge') {
1216
+ connectionCounts.set(sourceId, (connectionCounts.get(sourceId) || 0) + 1)
1217
+ totalConnections.set(sourceId, (totalConnections.get(sourceId) || 0) + volume)
1218
+ if (flow.connections >= hotPathThreshold && hotPathThreshold > 0) hotNodes.add(sourceId)
1219
+ }
1220
+ if (flow.destination.kind !== 'SkipEdge') {
1221
+ connectionCounts.set(destId, (connectionCounts.get(destId) || 0) + 1)
1222
+ totalConnections.set(destId, (totalConnections.get(destId) || 0) + volume)
1223
+
1224
+ if (!nodePorts.has(destId)) nodePorts.set(destId, new Map())
1225
+ const portCounts = nodePorts.get(destId)!
1226
+ portCounts.set(flow.port, (portCounts.get(flow.port) || 0) + volume)
1227
+ if (flow.connections >= hotPathThreshold && hotPathThreshold > 0) hotNodes.add(destId)
1206
1228
  }
1207
1229
  })
1208
1230
 
@@ -1381,8 +1403,10 @@ export function TrafficGraph({ flows, hotPathThreshold = 0, showNamespaceGroups
1381
1403
  // A source that measures rates has no count for an edge with no requests on
1382
1404
  // it — a plain TCP conversation, or one whose direction is unknown. Printing
1383
1405
  // "0/s" there reads as no traffic, on an edge that may be carrying megabytes.
1384
- const countLabel = isRateBased && !flow.connections ? '' : connStr
1385
- const edgeLabel = [l7Label + countLabel, latencyLabel, errorLabel]
1406
+ const bytesOnly = isRateBased && !flow.connections
1407
+ const countLabel = bytesOnly ? '' : connStr
1408
+ const throughput = bytesOnly ? throughputLabel(flow, windowSeconds) : ''
1409
+ const edgeLabel = [throughput || l7Label + countLabel, latencyLabel, errorLabel]
1386
1410
  .join('')
1387
1411
  .replace(/^ · /, '')
1388
1412
 
@@ -1436,13 +1460,14 @@ export function TrafficGraph({ flows, hotPathThreshold = 0, showNamespaceGroups
1436
1460
  addonGroupEdge, // Pass this for adding after group is created
1437
1461
  addonGroupOutEdge, // Pass this for adding group → kubernetes edge
1438
1462
  }
1439
- }, [flows, hotPathThreshold, showNamespaceGroups, serviceCategories, addonMode, isRateBased, connLabel])
1463
+ }, [flows, hotPathThreshold, showNamespaceGroups, serviceCategories, addonMode, isRateBased, connLabel, windowSeconds])
1440
1464
 
1441
1465
  // Apply ELK layout
1442
- const applyLayout = useCallback(async () => {
1466
+ const applyLayout = useCallback(async (claim: () => boolean) => {
1443
1467
  if (rawNodes.length === 0) {
1444
1468
  setLayoutedNodes([])
1445
1469
  setLayoutedEdges([])
1470
+ setElkUnavailable(false)
1446
1471
  return
1447
1472
  }
1448
1473
 
@@ -1465,8 +1490,21 @@ export function TrafficGraph({ flows, hotPathThreshold = 0, showNamespaceGroups
1465
1490
  const groupEdgeInfo = addonGroupEdge
1466
1491
  const groupOutEdgeInfo = addonGroupOutEdge
1467
1492
 
1493
+ let elk: ELK
1494
+ try {
1495
+ elk = await loadElk()
1496
+ } catch (error) {
1497
+ if (!claim()) return
1498
+ // A grid of the raw nodes would drop the grouped-addon edges and read as
1499
+ // the real traffic, so the view lists the connections instead.
1500
+ console.error('ELK failed to load:', error)
1501
+ setElkUnavailable(true)
1502
+ return
1503
+ }
1504
+
1468
1505
  try {
1469
1506
  const layoutResult = await elk.layout(elkGraph)
1507
+ if (!claim()) return
1470
1508
 
1471
1509
  // Index ELK's positioned children by id once — a .find() per node here is
1472
1510
  // O(nodes²) and bites on dense traffic graphs.
@@ -1561,7 +1599,7 @@ export function TrafficGraph({ flows, hotPathThreshold = 0, showNamespaceGroups
1561
1599
  target: 'addon-group',
1562
1600
  type: 'smoothstep',
1563
1601
  animated: isHotEdge,
1564
- label: isRateBased ? `${formatRate(displayVolume(groupFlow, isRateBased))}/s` : formatConnections(connections),
1602
+ label: isRateBased && !connections ? throughputLabel(groupFlow, windowSeconds) : isRateBased ? `${formatRate(displayVolume(groupFlow, isRateBased))}/s` : formatConnections(connections),
1565
1603
  labelBgStyle: {
1566
1604
  fill: '#581c87', // purple-900
1567
1605
  fillOpacity: 0.9,
@@ -1595,7 +1633,7 @@ export function TrafficGraph({ flows, hotPathThreshold = 0, showNamespaceGroups
1595
1633
  target: targetId,
1596
1634
  type: 'smoothstep',
1597
1635
  animated: isHotEdge,
1598
- label: isRateBased ? `${formatRate(displayVolume(groupFlow, isRateBased))}/s` : formatConnections(connections),
1636
+ label: isRateBased && !connections ? throughputLabel(groupFlow, windowSeconds) : isRateBased ? `${formatRate(displayVolume(groupFlow, isRateBased))}/s` : formatConnections(connections),
1599
1637
  labelBgStyle: {
1600
1638
  fill: '#581c87', // purple-900
1601
1639
  fillOpacity: 0.9,
@@ -1621,7 +1659,9 @@ export function TrafficGraph({ flows, hotPathThreshold = 0, showNamespaceGroups
1621
1659
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1622
1660
  setLayoutedNodes(finalNodes as any)
1623
1661
  setLayoutedEdges(finalEdges)
1662
+ setElkUnavailable(false)
1624
1663
  } catch (error) {
1664
+ if (!claim()) return
1625
1665
  console.error('ELK layout error:', error)
1626
1666
  // Fallback to simple layout
1627
1667
  const positionedNodes = rawNodes.map((node, index) => ({
@@ -1633,14 +1673,39 @@ export function TrafficGraph({ flows, hotPathThreshold = 0, showNamespaceGroups
1633
1673
  }))
1634
1674
  setLayoutedNodes(positionedNodes)
1635
1675
  setLayoutedEdges(rawEdges)
1676
+ setElkUnavailable(false)
1636
1677
  }
1637
- }, [rawNodes, rawEdges, addonMode, addonGroupEdge, addonGroupOutEdge, hotPathThreshold, isRateBased])
1638
-
1639
- // Run layout when flows change
1678
+ }, [rawNodes, rawEdges, addonMode, addonGroupEdge, addonGroupOutEdge, hotPathThreshold, isRateBased, windowSeconds])
1679
+
1680
+ // Run layout when flows change. Runs install their results in the order
1681
+ // they started, so a fast-changing graph still lands each layout instead of
1682
+ // a newer run discarding every one in flight; a run that finishes after a
1683
+ // newer one already installed, or after unmount, is dropped.
1684
+ const layoutRunRef = useRef(0)
1685
+ const installedRunRef = useRef(0)
1686
+ const mountedRef = useRef(true)
1687
+ useEffect(() => {
1688
+ mountedRef.current = true
1689
+ return () => { mountedRef.current = false }
1690
+ }, [])
1640
1691
  useEffect(() => {
1641
- applyLayout()
1692
+ const run = ++layoutRunRef.current
1693
+ applyLayout(() => {
1694
+ if (!mountedRef.current || run < installedRunRef.current) return false
1695
+ installedRunRef.current = run
1696
+ return true
1697
+ })
1642
1698
  }, [applyLayout])
1643
1699
 
1700
+ // Unmounting clears the report: a remounted graph starts over and says so itself.
1701
+ useEffect(() => {
1702
+ onLayoutUnavailable(elkUnavailable)
1703
+ return () => onLayoutUnavailable(false)
1704
+ }, [elkUnavailable, onLayoutUnavailable])
1705
+
1706
+ // The first layout waits for the ELK chunk; later ones keep the drawn graph.
1707
+ const firstLayoutPending = rawNodes.length > 0 && layoutedNodes.length === 0 && !elkUnavailable
1708
+
1644
1709
  const [nodes, setNodes, onNodesChange] = useNodesState(layoutedNodes)
1645
1710
  const [edges, setEdges, onEdgesChange] = useEdgesState(layoutedEdges)
1646
1711
 
@@ -1717,6 +1782,10 @@ export function TrafficGraph({ flows, hotPathThreshold = 0, showNamespaceGroups
1717
1782
  onSelectionChange?.(null)
1718
1783
  }, [onSelectionChange])
1719
1784
 
1785
+ // Still mounted so later refreshes retry the engine where the browser
1786
+ // refetches a failed module.
1787
+ if (elkUnavailable) return null
1788
+
1720
1789
  return (
1721
1790
  <div className="w-full h-full relative">
1722
1791
  <ReactFlow
@@ -1745,6 +1814,8 @@ export function TrafficGraph({ flows, hotPathThreshold = 0, showNamespaceGroups
1745
1814
  <FitViewOnChange shouldFitViewRef={shouldFitViewRef} layoutedNodes={layoutedNodes} />
1746
1815
  </ReactFlow>
1747
1816
 
1817
+ {firstLayoutPending && <PaneLoader label="Laying out traffic…" className="absolute inset-0" />}
1818
+
1748
1819
  {/* Legend */}
1749
1820
  <TrafficLegend />
1750
1821
 
@@ -0,0 +1,57 @@
1
+ import type { ReactNode } from 'react'
2
+ import { RotateCw } from 'lucide-react'
3
+ import { AlertBanner } from '@skyhook-io/k8s-ui'
4
+ import type { AggregatedFlow } from '../../types'
5
+ import { TrafficConnectionsTable } from './TrafficConnectionsTable'
6
+ import type { TrafficGraphSelection } from './TrafficGraph'
7
+ import type { TrafficFocus } from './trafficFilters'
8
+
9
+ interface TrafficGraphUnavailableProps {
10
+ /** The view's connections as they are, before addons are grouped for drawing. */
11
+ flows: AggregatedFlow[]
12
+ isRateBased: boolean
13
+ selection: TrafficGraphSelection | null
14
+ onSelect: (selection: TrafficGraphSelection | null) => void
15
+ onFocus: (focus: TrafficFocus) => void
16
+ focusedId?: string
17
+ /** Shown above the explanation, in the layout rather than over it. */
18
+ notice?: ReactNode
19
+ }
20
+
21
+ /**
22
+ * Stands in for the map when its layout engine could not be fetched, which is
23
+ * what a tab opened before an upgrade gets: says so, offers the reload that
24
+ * fixes it, and lists the connections so the view still answers something.
25
+ */
26
+ export function TrafficGraphUnavailable({ flows, isRateBased, selection, onSelect, onFocus, focusedId, notice }: TrafficGraphUnavailableProps) {
27
+ return (
28
+ <div className="absolute inset-x-0 bottom-0 top-12 flex flex-col px-3 pb-3 gap-2">
29
+ {notice}
30
+ <AlertBanner
31
+ variant="warning"
32
+ className="mb-0"
33
+ title="The traffic map could not load its layout engine"
34
+ message="Radar may have been updated since this page was opened. Reload to draw the map; the connections are listed below."
35
+ action={
36
+ <button
37
+ type="button"
38
+ onClick={() => window.location.reload()}
39
+ className="btn-brand-muted inline-flex items-center gap-1 text-xs px-2.5 py-1 rounded-md"
40
+ >
41
+ <RotateCw className="h-3.5 w-3.5" /> Reload
42
+ </button>
43
+ }
44
+ />
45
+ <div className="min-h-0 flex-1 overflow-hidden rounded-lg border border-theme-border bg-theme-surface">
46
+ <TrafficConnectionsTable
47
+ flows={flows}
48
+ isRateBased={isRateBased}
49
+ selection={selection}
50
+ onSelect={onSelect}
51
+ onFocus={onFocus}
52
+ focusedId={focusedId}
53
+ />
54
+ </div>
55
+ </div>
56
+ )
57
+ }