@skyhook-io/radar-app 1.21.1 → 1.21.3

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 (103) hide show
  1. package/README.md +11 -0
  2. package/package.json +2 -2
  3. package/src/App.tsx +50 -28
  4. package/src/api/actions.test.ts +11 -0
  5. package/src/api/actions.ts +5 -0
  6. package/src/api/apiResources.navigation.test.tsx +58 -0
  7. package/src/api/apiResources.ts +22 -16
  8. package/src/api/client.diagnostics.test.ts +52 -0
  9. package/src/api/client.triggerCronJob.test.tsx +49 -0
  10. package/src/api/client.ts +140 -120
  11. package/src/api/connectionBinding.test.tsx +82 -0
  12. package/src/api/connectionBinding.ts +52 -0
  13. package/src/api/contextSwitch.test.ts +11 -0
  14. package/src/api/contextSwitch.ts +58 -0
  15. package/src/api/radarFeatures.ts +7 -0
  16. package/src/api/sealedSecrets.test.ts +22 -0
  17. package/src/api/sealedSecrets.ts +37 -0
  18. package/src/api/vulnerabilities.ts +80 -7
  19. package/src/components/ConnectionErrorView.tsx +13 -0
  20. package/src/components/ContextSwitchActions.tsx +43 -0
  21. package/src/components/ContextSwitcher.tsx +13 -6
  22. package/src/components/SwitchAwareConnectionError.tsx +2 -2
  23. package/src/components/audit/Java4ShellPanel.test.tsx +104 -7
  24. package/src/components/audit/Java4ShellPanel.tsx +169 -72
  25. package/src/components/cost/ApplicationCostTab.test.ts +16 -0
  26. package/src/components/cost/ApplicationCostTab.tsx +41 -9
  27. package/src/components/cost/CostTrendChart.tsx +25 -2
  28. package/src/components/cost/CostTrendWithheld.render.test.tsx +105 -0
  29. package/src/components/cost/CostView.tsx +10 -2
  30. package/src/components/cost/CostViewTabs.test.tsx +18 -0
  31. package/src/components/cost/CostViewTabs.tsx +14 -22
  32. package/src/components/cost/WorkloadCostTab.test.ts +15 -0
  33. package/src/components/cost/WorkloadCostTab.tsx +42 -8
  34. package/src/components/cost/source.test.ts +16 -1
  35. package/src/components/cost/source.ts +34 -0
  36. package/src/components/diagnose/investigationEvidence/adapters/diagnose.test.ts +35 -0
  37. package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +16 -1
  38. package/src/components/dock/NodeTerminalTab.test.tsx +4 -2
  39. package/src/components/dock/NodeTerminalTab.tsx +8 -8
  40. package/src/components/dock/TerminalTab.test.tsx +12 -1
  41. package/src/components/dock/TerminalTab.tsx +6 -3
  42. package/src/components/home/CostCard.test.tsx +49 -0
  43. package/src/components/home/CostCard.tsx +98 -63
  44. package/src/components/home/mcpToolCatalog.ts +1 -0
  45. package/src/components/resource/DatadogRightsizingPanel.test.tsx +118 -0
  46. package/src/components/resource/DatadogRightsizingPanel.tsx +68 -0
  47. package/src/components/resource/DatadogWorkloadCharts.tsx +149 -0
  48. package/src/components/resource/HPACharts.render.test.tsx +42 -0
  49. package/src/components/resource/HPACharts.tsx +34 -1
  50. package/src/components/resource/PrometheusChartsGrid.render.test.tsx +126 -3
  51. package/src/components/resource/PrometheusChartsGrid.tsx +58 -25
  52. package/src/components/resource/RestartChart.render.test.tsx +72 -0
  53. package/src/components/resource/RestartChart.tsx +31 -3
  54. package/src/components/resource/RightsizingPanel.access.test.tsx +24 -0
  55. package/src/components/resource/RightsizingStrip.render.test.tsx +44 -0
  56. package/src/components/resource/RightsizingStrip.test.ts +1 -188
  57. package/src/components/resource/RightsizingStrip.tsx +27 -300
  58. package/src/components/resource/WorkloadMetricsSection.render.test.tsx +22 -0
  59. package/src/components/resource/WorkloadMetricsSection.tsx +14 -4
  60. package/src/components/resource/nameMatchedScope.ts +39 -0
  61. package/src/components/resources/pod-file-upload.ts +3 -0
  62. package/src/components/resources/renderers/CAPIClusterRenderer.tsx +5 -2
  63. package/src/components/resources/renderers/LonghornVolumeRenderer.test.tsx +104 -0
  64. package/src/components/resources/renderers/LonghornVolumeRenderer.tsx +31 -0
  65. package/src/components/resources/renderers/SealedSecretRenderer.test.tsx +41 -0
  66. package/src/components/resources/renderers/SealedSecretRenderer.tsx +14 -0
  67. package/src/components/rightsizing/RightsizingScanLink.tsx +22 -0
  68. package/src/components/rightsizing/RightsizingScanView.tsx +65 -528
  69. package/src/components/rightsizing/model.test.ts +20 -9
  70. package/src/components/rightsizing/model.ts +17 -176
  71. package/src/components/rightsizing/notices.test.tsx +30 -29
  72. package/src/components/traffic/TrafficFlowList.tsx +8 -4
  73. package/src/components/traffic/TrafficGraph.test.tsx +31 -1
  74. package/src/components/traffic/TrafficGraph.tsx +11 -6
  75. package/src/components/traffic/trafficFilters.ts +4 -4
  76. package/src/components/ui/DiagnosticsOverlay.test.ts +3 -2
  77. package/src/components/ui/DiagnosticsOverlay.tsx +23 -13
  78. package/src/components/ui/command-items.ts +3 -4
  79. package/src/components/useContextSwitchFlow.test.tsx +9 -0
  80. package/src/components/useContextSwitchFlow.tsx +43 -5
  81. package/src/components/vulnerabilities/WorkloadVulnerabilitiesSection.test.tsx +54 -0
  82. package/src/components/vulnerabilities/WorkloadVulnerabilitiesSection.tsx +50 -109
  83. package/src/components/whats-new/releaseNotes.ts +1 -1
  84. package/src/components/workload/WorkloadRightsizingSource.test.tsx +83 -0
  85. package/src/components/workload/WorkloadView.test.ts +22 -1
  86. package/src/components/workload/WorkloadView.tsx +57 -16
  87. package/src/context/ConnectionContext.test.ts +1 -0
  88. package/src/context/ConnectionContext.tsx +58 -15
  89. package/src/context/ConnectionProvider.connectionId.test.tsx +92 -0
  90. package/src/context/ConnectionProvider.retry.test.tsx +174 -1
  91. package/src/context/ContextSwitchContext.tsx +15 -1
  92. package/src/context/NavCustomization.tsx +6 -3
  93. package/src/hooks/useEventSource.test.tsx +85 -0
  94. package/src/hooks/useEventSource.ts +43 -16
  95. package/src/hooks/useResetViewsOnContextChange.test.tsx +34 -0
  96. package/src/hooks/useResetViewsOnContextChange.ts +27 -0
  97. package/src/index.ts +3 -0
  98. package/src/integrations/resourceHosts.test.tsx +2 -2
  99. package/src/integrations/resourceHosts.tsx +4 -0
  100. package/src/utils/navigation.ts +1 -15
  101. package/src/utils/page-links.ts +6 -0
  102. package/src/components/rightsizing/presentation.test.ts +0 -150
  103. package/src/components/rightsizing/presentation.ts +0 -109
@@ -1,12 +1,7 @@
1
1
  import { describe, expect, it } from 'vitest'
2
2
  import type { RightsizingScanResponse, RightsizingRow } from '../../api/client'
3
- import {
4
- calculateImpact,
5
- classifyRows,
6
- flattenScanResults,
7
- isActionableClass,
8
- scanClassCounts,
9
- } from './model'
3
+ import { calculateImpact, classifyRows, matchesResultClass, scanClassCounts } from '@skyhook-io/k8s-ui/components/rightsizing/results-model'
4
+ import { flattenScanResults } from './model'
10
5
 
11
6
  function metric(overrides: Partial<RightsizingRow> = {}): RightsizingRow {
12
7
  return {
@@ -29,7 +24,7 @@ function response(
29
24
  replicas = 1,
30
25
  namespace = 'shop',
31
26
  scaledToZero = false,
32
- ): RightsizingScanResponse {
27
+ ): RightsizingScanResponse & { workloads: NonNullable<RightsizingScanResponse['workloads']> } {
33
28
  return {
34
29
  scanId: 'rs_test', scanStatus: 'finished', deadlineAt: '2026-09-19T10:03:00Z',
35
30
  state: 'complete',
@@ -57,6 +52,10 @@ function response(
57
52
  }
58
53
 
59
54
  describe('rightsizing scan model', () => {
55
+ it('can render a retained unavailable scan from a disconnected spoke', () => {
56
+ expect(flattenScanResults({ ...response([]), state: 'unavailable', workloads: null })).toEqual([])
57
+ })
58
+
60
59
  it('prioritizes reliability guidance and explicit safety review', () => {
61
60
  expect(
62
61
  classifyRows([
@@ -193,7 +192,7 @@ describe('rightsizing scan model', () => {
193
192
  expect(rows[0].cpu).toBe(cpu)
194
193
  expect(rows[0].memory).toBe(memory)
195
194
  expect(scanClassCounts(rows)[rows[0].classification]).toBe(1)
196
- const actions = rows.filter((row) => isActionableClass(row.classification))
195
+ const actions = rows.filter((row) => matchesResultClass(row, 'actions'))
197
196
  expect(actions).toHaveLength(classification === 'need_data' ? 0 : 1)
198
197
  })
199
198
  })
@@ -354,3 +353,15 @@ describe('pod-level requests', () => {
354
353
  expect(calculateImpact(rows, 2)).toMatchObject({ cpuChange: 0, memoryChange: 0 })
355
354
  })
356
355
  })
356
+
357
+ it('finds independent actions on one container without counting a guarded proposal as capacity', () => {
358
+ const rows = flattenScanResults(response([
359
+ metric({ fit: 'under_requested', recommendedRequest: '250m', recommendedRequestValue: 0.25,
360
+ currentRequestValue: 0.1, decision: { status: 'review', reasons: ['hpa_evidence_unavailable'] } }),
361
+ metric({ resource: 'memory', fit: 'oversized', recommendedRequest: '128Mi',
362
+ recommendedRequestValue: 128 * 1024 ** 2, currentRequestValue: 256 * 1024 ** 2, decision: { status: 'actionable' } }),
363
+ ]));
364
+ expect(scanClassCounts(rows)).toEqual({ increase: 1, review: 1, reduction: 1, in_range: 0, need_data: 0 });
365
+ expect(matchesResultClass(rows[0], 'actions')).toBe(true);
366
+ expect(rows[0].impact.cpuChange).toBe(0);
367
+ });
@@ -1,183 +1,24 @@
1
- import type { RightsizingScanResponse, RightsizingRow } from '../../api/client'
1
+ import type { RightsizingScanResponse } from '../../api/client'
2
+ import {
3
+ compareScanResults,
4
+ workloadResultRows,
5
+ type RightsizingResultRow,
6
+ isSizingSystemNamespace,
7
+ } from '@skyhook-io/k8s-ui/components/rightsizing/results-model'
2
8
 
3
- export type ScanClass = 'increase' | 'reduction' | 'review' | 'in_range' | 'need_data'
9
+ export type { ScanClass } from '@skyhook-io/k8s-ui/components/rightsizing/results-model'
4
10
 
5
- export interface RightsizingImpact {
6
- replicas: number
7
- cpuChange: number
8
- memoryChange: number
9
- }
10
-
11
- export interface RightsizingScanRow {
12
- id: string
13
- kind: string
14
- namespace: string
15
- name: string
16
- container: string
17
- replicas: number
18
- cpu?: RightsizingRow
19
- memory?: RightsizingRow
20
- classification: ScanClass
21
- impact: RightsizingImpact
11
+ export interface RightsizingScanRow extends RightsizingResultRow {
22
12
  system: boolean
23
- scaledToZero: boolean
24
- }
25
-
26
- const CLASS_RANK: Record<ScanClass, number> = {
27
- increase: 1,
28
- reduction: 2,
29
- review: 3,
30
- need_data: 4,
31
- in_range: 5,
32
- }
33
-
34
- const MIN_CPU_REDUCTION = 0.05
35
- const MIN_MEMORY_REDUCTION = 64 * 1024 * 1024
36
-
37
- export function classifyRows(
38
- rows: RightsizingRow[],
39
- replicas = 1,
40
- scaledToZero = false,
41
- ): ScanClass {
42
- const evidenced = rows.filter((row) => !row.queryError && row.fit !== 'insufficient_history')
43
- if (evidenced.length === 0) return 'need_data'
44
- if (scaledToZero) return 'review'
45
- if (
46
- evidenced.some(
47
- (row) =>
48
- (row.fit === 'under_requested' || row.fit === 'missing_request') && row.recommendedRequest,
49
- )
50
- )
51
- return 'increase'
52
- if (evidenced.some(needsManualReview)) return 'review'
53
- const impact = calculateImpact(evidenced, replicas)
54
- if (-impact.cpuChange >= MIN_CPU_REDUCTION || -impact.memoryChange >= MIN_MEMORY_REDUCTION)
55
- return 'reduction'
56
- return evidenced.length === rows.length ? 'in_range' : 'need_data'
57
- }
58
-
59
- function needsManualReview(row: RightsizingRow): boolean {
60
- return (
61
- row.hpaManaged ||
62
- needsSafetyReview(row) ||
63
- (isReduction(row) && row.bursty === true) ||
64
- row.recommendationReason === 'hpa_evidence_unavailable' ||
65
- row.recommendationReason === 'oom_evidence_unavailable' ||
66
- // Mirrors ManualReviewReasons: Radar does not size a pod-level request.
67
- row.fit === 'pod_level_request'
68
- )
69
- }
70
-
71
- function needsSafetyReview(row: RightsizingRow): boolean {
72
- return (
73
- row.currentPodOOM === true ||
74
- row.windowOomEvidence === true ||
75
- row.limitConflict === true ||
76
- (isReduction(row) && (row.throttleRatio ?? 0) >= 0.1)
77
- )
78
- }
79
-
80
- function scanPriority(row: RightsizingScanRow): number {
81
- if (
82
- !row.scaledToZero &&
83
- [row.cpu, row.memory].some(
84
- (resource) =>
85
- resource &&
86
- !resource.queryError &&
87
- resource.fit !== 'insufficient_history' &&
88
- needsSafetyReview(resource),
89
- )
90
- )
91
- return 0
92
- return CLASS_RANK[row.classification]
93
- }
94
-
95
- function isReduction(row: RightsizingRow): boolean {
96
- return (
97
- row.recommendedRequestValue != null &&
98
- row.currentRequestValue != null &&
99
- row.recommendedRequestValue < row.currentRequestValue
100
- )
101
- }
102
-
103
- export function calculateImpact(rows: RightsizingRow[], replicas: number): RightsizingImpact {
104
- const count = Math.max(replicas, 0)
105
- let cpuChange = 0
106
- let memoryChange = 0
107
- for (const row of rows) {
108
- if (row.recommendedRequestValue == null || needsManualReview(row)) continue
109
- const change = (row.recommendedRequestValue - (row.currentRequestValue ?? 0)) * count
110
- if (row.resource === 'cpu') cpuChange += change
111
- else memoryChange += change
112
- }
113
- return { replicas: count, cpuChange, memoryChange }
114
13
  }
115
14
 
116
15
  export function flattenScanResults(scan: RightsizingScanResponse): RightsizingScanRow[] {
117
- const result: RightsizingScanRow[] = []
118
- for (const workload of scan.workloads ?? []) {
119
- const byContainer = new Map<string, RightsizingRow[]>()
120
- for (const row of workload.rows ?? []) {
121
- const rows = byContainer.get(row.container) ?? []
122
- rows.push(row)
123
- byContainer.set(row.container, rows)
124
- }
125
- for (const [container, rows] of byContainer) {
126
- const replicas = workload.replicas ?? 1
127
- result.push({
128
- id: `${workload.kind}/${workload.namespace}/${workload.name}/${container}`,
129
- kind: workload.kind,
130
- namespace: workload.namespace,
131
- name: workload.name,
132
- container,
133
- replicas,
134
- cpu: rows.find((row) => row.resource === 'cpu'),
135
- memory: rows.find((row) => row.resource === 'memory'),
136
- classification: classifyRows(rows, replicas, workload.scaledToZero),
137
- impact: calculateImpact(rows, replicas),
138
- system: isSystemNamespace(workload.namespace),
139
- scaledToZero: workload.scaledToZero,
140
- })
141
- }
142
- }
143
- return result.sort(
144
- (a, b) =>
145
- scanPriority(a) - scanPriority(b) ||
146
- impactScore(b) - impactScore(a) ||
147
- a.namespace.localeCompare(b.namespace) ||
148
- a.name.localeCompare(b.name) ||
149
- a.container.localeCompare(b.container),
150
- )
151
- }
152
-
153
- function impactScore(row: RightsizingScanRow): number {
154
- return Math.max(
155
- Math.abs(row.impact.cpuChange) / MIN_CPU_REDUCTION,
156
- Math.abs(row.impact.memoryChange) / MIN_MEMORY_REDUCTION,
157
- )
158
- }
159
-
160
- export function scanClassCounts(rows: RightsizingScanRow[]): Record<ScanClass, number> {
161
- const counts: Record<ScanClass, number> = {
162
- increase: 0,
163
- reduction: 0,
164
- review: 0,
165
- in_range: 0,
166
- need_data: 0,
167
- }
168
- for (const row of rows) counts[row.classification]++
169
- return counts
170
- }
171
-
172
- export function isActionableClass(value: ScanClass): boolean {
173
- return value === 'increase' || value === 'reduction' || value === 'review'
174
- }
175
-
176
- function isSystemNamespace(namespace: string): boolean {
177
- return (
178
- namespace === 'kube-system' ||
179
- namespace === 'kube-public' ||
180
- namespace === 'kube-node-lease' ||
181
- namespace.startsWith('gke-managed-')
182
- )
16
+ return (scan.workloads ?? [])
17
+ .flatMap((workload) =>
18
+ workloadResultRows(workload).map((row) => ({
19
+ ...row,
20
+ system: isSizingSystemNamespace(row.namespace),
21
+ })),
22
+ )
23
+ .sort(compareScanResults)
183
24
  }
@@ -1,7 +1,7 @@
1
1
  import { renderToStaticMarkup } from 'react-dom/server'
2
2
  import { describe, expect, it } from 'vitest'
3
- import type { RightsizingRow, RightsizingScanResponse } from '../../api/client'
4
- import { FitWhy, ScanNotices, ScanSummary } from './RightsizingScanView'
3
+ import type { RightsizingScanResponse } from '../../api/client'
4
+ import { ScanNotices, ScanSummary, ScanUnavailableState } from './RightsizingScanView'
5
5
 
6
6
  const scan: RightsizingScanResponse = {
7
7
  scanId: 'rs_test', scanStatus: 'finished', deadlineAt: '2026-09-19T10:03:00Z',
@@ -105,33 +105,6 @@ describe('rightsizing scan notices', () => {
105
105
  })
106
106
  })
107
107
 
108
- describe('rightsizing evidence explanation', () => {
109
- const row: RightsizingRow = {
110
- container: 'app',
111
- resource: 'cpu',
112
- fit: 'insufficient_history',
113
- confidence: 'low',
114
- coverage: 0,
115
- sampleCount: 0,
116
- expectedSamples: 2017,
117
- hpaManaged: false,
118
- hpaEvidenceAvailable: true,
119
- oomEvidenceAvailable: false,
120
- }
121
-
122
- it('distinguishes failed queries from successfully measured short history', () => {
123
- const failed = renderToStaticMarkup(
124
- <FitWhy label="CPU" row={{ ...row, queryError: 'usage query failed' }} />,
125
- )
126
- expect(failed).toContain('Metrics could not be queried')
127
- expect(failed).not.toContain('0.0 days')
128
- expect(failed).not.toContain('Wait for more runtime history')
129
- const short = renderToStaticMarkup(<FitWhy label="CPU" row={row} />)
130
- expect(short).toContain('0.0 days')
131
- expect(short).toContain('Wait for more runtime history')
132
- })
133
- })
134
-
135
108
  describe('rightsizing scope and coverage summary', () => {
136
109
  const counts = {
137
110
  increase: 1,
@@ -174,3 +147,31 @@ describe('rightsizing scope and coverage summary', () => {
174
147
  expect(html).toContain('All visible namespaces')
175
148
  })
176
149
  })
150
+
151
+ describe('rightsizing scan withheld cluster scope', () => {
152
+ it('shows the note once instead of the unavailable message', () => {
153
+ const html = renderToStaticMarkup(
154
+ <ScanUnavailableState
155
+ result={{
156
+ ...scan,
157
+ state: 'unavailable',
158
+ reason: 'cluster_scope_withheld',
159
+ warnings: [{ code: 'cluster_scope_withheld', message: 'This metrics store holds several clusters.' }],
160
+ clusterScope: { state: 'label_missing', note: "The container_cpu_usage_seconds_total series don't carry this cluster's label." },
161
+ }}
162
+ onRun={() => {}}
163
+ />,
164
+ )
165
+ expect(html.match(/role="note"/g)).toHaveLength(1)
166
+ expect(html).toContain("don&#x27;t carry this cluster&#x27;s label")
167
+ expect(html).not.toContain('Rightsizing is unavailable')
168
+ })
169
+
170
+ it('keeps the unavailable message for other reasons and older Radar', () => {
171
+ const html = renderToStaticMarkup(
172
+ <ScanUnavailableState result={{ ...scan, state: 'unavailable', reason: 'owner_metrics_missing' }} onRun={() => {}} />,
173
+ )
174
+ expect(html).toContain('Rightsizing is unavailable')
175
+ expect(html).not.toContain('role="note"')
176
+ })
177
+ })
@@ -224,10 +224,14 @@ export function TrafficFlowList({ flows, responsesCallerOriented }: TrafficFlowL
224
224
  {flow.latencyNs && flow.latencyNs > 0 ? formatLatency(flow.latencyNs) : '—'}
225
225
  </span>
226
226
 
227
- {/* Verdict */}
228
- <span className={clsx('text-right badge badge-sm text-[10px] capitalize', VERDICT_BADGE[flow.verdict] ?? SEVERITY_BADGE.neutral)}>
229
- {flow.verdict}
230
- </span>
227
+ {/* Verdict: sources that only observe traffic (Beyla) report none */}
228
+ {flow.verdict ? (
229
+ <span className={clsx('text-right badge badge-sm text-[10px] capitalize', VERDICT_BADGE[flow.verdict] ?? SEVERITY_BADGE.neutral)}>
230
+ {flow.verdict}
231
+ </span>
232
+ ) : (
233
+ <span className="text-right text-theme-text-tertiary">—</span>
234
+ )}
231
235
  </button>
232
236
 
233
237
  {/* Expanded detail */}
@@ -4,7 +4,7 @@ import { createRoot, type Root } from 'react-dom/client'
4
4
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
5
5
  import type { Edge, Node } from '@xyflow/react'
6
6
  import type { AggregatedFlow } from '../../types'
7
- import { TrafficGraph } from './TrafficGraph'
7
+ import { TrafficGraph, TrafficNode } from './TrafficGraph'
8
8
  import { endpointPair, groupAddonFlows } from './trafficFilters'
9
9
 
10
10
  const { fitView } = vi.hoisted(() => ({ fitView: vi.fn() }))
@@ -267,3 +267,33 @@ describe('TrafficGraph edge labels for traffic measured only in bytes', () => {
267
267
  expect(container.querySelector('[data-edge]')!.textContent).toBe('TCP · 2.4 KB/s · UDP · <1 B/s')
268
268
  })
269
269
  })
270
+
271
+ describe('TrafficNode title', () => {
272
+ // jsdom has no layout or canvas: give the title 100px and every glyph 7px.
273
+ beforeEach(() => {
274
+ vi.stubGlobal('ResizeObserver', class { observe() {} disconnect() {} })
275
+ vi.spyOn(HTMLCanvasElement.prototype, 'getContext').mockReturnValue(
276
+ { font: '', measureText: (t: string) => ({ width: t.length * 7 }) } as unknown as CanvasRenderingContext2D)
277
+ vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockReturnValue({ width: 100 } as DOMRect)
278
+ })
279
+ afterEach(() => vi.restoreAllMocks())
280
+
281
+ it('keeps the end of a long name, so names sharing a prefix stay apart', () => {
282
+ const titles = ['checkout-platform-release-engine', 'checkout-platform-release-redis'].map(label => {
283
+ act(() => root.render(<TrafficNode data={{ label, namespace: 'demo', kind: 'Deployment' }} />))
284
+ const title = container.querySelector(`[title="${label}"]`)!
285
+ return title.lastElementChild!.textContent!
286
+ })
287
+ expect(titles[0]).toBe('checko…engine')
288
+ expect(titles[1]).toMatch(/redis$/)
289
+ expect(titles[0]).not.toBe(titles[1])
290
+ })
291
+
292
+ it('gives screen readers the full name, not the cut one', () => {
293
+ const label = 'checkout-platform-release-engine'
294
+ act(() => root.render(<TrafficNode data={{ label, namespace: 'demo', kind: 'Deployment' }} />))
295
+ const srOnly = container.querySelector('.sr-only')
296
+ expect(srOnly?.textContent).toBe(label)
297
+ expect(container.querySelector(`[title="${label}"]`)!.closest('[aria-hidden="true"]')).not.toBeNull()
298
+ })
299
+ })
@@ -19,7 +19,7 @@ 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
+ import { MiddleEllipsis, PaneLoader } from '@skyhook-io/k8s-ui'
23
23
  import { isClusterAddon, type AddonMode } from './TrafficView'
24
24
  import { SEVERITY_BADGE, SEVERITY_DOT, SEVERITY_TEXT } from '@skyhook-io/k8s-ui/utils/badge-colors'
25
25
  import { getNamespaceColor } from '../../utils/traffic-colors'
@@ -208,7 +208,7 @@ const NODE_PORT_HEIGHT = 18 // Height per port row
208
208
  const MAX_VISIBLE_PORTS = 4 // Maximum ports to show before "+N more"
209
209
 
210
210
  // Custom node component
211
- function TrafficNode({ data }: { data: TrafficNodeData }) {
211
+ export function TrafficNode({ data }: { data: TrafficNodeData }) {
212
212
  const isExternal = isExternalKind(data.kind)
213
213
  const isInternet = data.kind === 'Internet'
214
214
  const isAddonInternet = data.kind === 'AddonInternet' // Separate internet for addon traffic
@@ -269,10 +269,15 @@ function TrafficNode({ data }: { data: TrafficNodeData }) {
269
269
  />
270
270
  )}
271
271
  <div className="flex-1 min-w-0">
272
- <div className={clsx(
273
- 'text-sm font-medium truncate',
274
- isAddonInternet ? 'text-purple-300' : isInternet ? 'text-sky-300' : (isAddon || isAddonNode) ? 'text-purple-200' : hasNamespaceColor ? 'text-white' : 'text-theme-text-primary'
275
- )}>{data.label}</div>
272
+ {/* Middle-cut: workloads of one release share a long prefix and differ only at the end.
273
+ MiddleEllipsis exposes only the cut text, so screen readers get the full name instead. */}
274
+ <span className="sr-only">{data.label}</span>
275
+ <div aria-hidden="true">
276
+ <MiddleEllipsis text={data.label} title={data.label} className={clsx(
277
+ 'text-sm font-medium',
278
+ isAddonInternet ? 'text-purple-300' : isInternet ? 'text-sky-300' : (isAddon || isAddonNode) ? 'text-purple-200' : hasNamespaceColor ? 'text-white' : 'text-theme-text-primary'
279
+ )} />
280
+ </div>
276
281
  {data.namespace ? (
277
282
  <div className={clsx(
278
283
  'text-xs truncate',
@@ -836,10 +836,10 @@ export function connectionRows<T extends AggregatedFlow>(flows: T[]): T[] {
836
836
  }
837
837
 
838
838
  /**
839
- * The verdict filter's choices, from the verdicts the flows contain. Caretta,
840
- * Beyla and Istio report every flow forwarded unless they saw an error, so when
841
- * forwarded is the only verdict present the filter would match everything and
842
- * none is offered. Any other verdict, even one without a chip of its own (Hubble
839
+ * The verdict filter's choices, from the verdicts the flows contain. Caretta
840
+ * and Istio report every flow forwarded unless they saw an error, and Beyla
841
+ * reports no verdict unless it saw one, so when forwarded is the only verdict
842
+ * present the filter would match everything and none is offered. Any other verdict, even one without a chip of its own (Hubble
843
843
  * also reports redirected, audit and more), makes Forwarded a real choice.
844
844
  */
845
845
  export function verdictChoices(seen: Iterable<string>): string[] {
@@ -117,9 +117,10 @@ describe('formatForGitHub kubeconfig section', () => {
117
117
 
118
118
  expect(md).toContain('Mode: `multi-source` | Files: 3 | Directory Files: 2 | Contexts (after source resolution): 7')
119
119
  expect(md).toContain('KUBECONFIG Captured From Shell: Yes | Ignored: Yes — directories-only configuration')
120
+ expect(md).toContain('Current Context Uses Exec: No')
120
121
  })
121
122
 
122
- it('omits directory counts for environment path lists', () => {
123
+ it('omits directory counts and unobserved current-context auth', () => {
123
124
  const md = formatForGitHub({
124
125
  ...baseSnapshot,
125
126
  kubeconfig: {
@@ -130,11 +131,11 @@ describe('formatForGitHub kubeconfig section', () => {
130
131
  enrichedFromShell: false,
131
132
  kubeconfigEnvIgnored: false,
132
133
  kubeconfigEnvIgnoredReason: '',
133
- currentContextUsesExec: true,
134
134
  },
135
135
  }, undefined, false)
136
136
 
137
137
  expect(md).toContain('Mode: `multi-env` | Files: 2 | Contexts (after source resolution): 4')
138
138
  expect(md).not.toContain('Directory Files:')
139
+ expect(md).not.toContain('Current Context Uses Exec:')
139
140
  })
140
141
  })
@@ -19,7 +19,7 @@ interface DiagnosticsOverlayProps {
19
19
  }
20
20
 
21
21
  export function DiagnosticsOverlay({ onClose, isOpen = true, focus, communityUrl }: DiagnosticsOverlayProps) {
22
- const { data, isLoading, error } = useDiagnostics(true)
22
+ const { data, isLoading, isFetching, error, refetch } = useDiagnostics(true)
23
23
  const [copied, setCopied] = useState<'json' | 'formatted' | null>(null)
24
24
  const [reportOpened, setReportOpened] = useState(false)
25
25
  const timelineRef = useRef<HTMLDivElement>(null)
@@ -124,7 +124,11 @@ export function DiagnosticsOverlay({ onClose, isOpen = true, focus, communityUrl
124
124
  <div className="text-sm text-theme-text-tertiary text-center py-8">Loading diagnostics…</div>
125
125
  )}
126
126
  {error && (
127
- <div className="text-sm text-red-400 text-center py-8">Failed to load diagnostics: {(error as Error).message}</div>
127
+ <div role="alert" className="text-sm text-center py-8 space-y-3">
128
+ <p className="text-theme-text-primary">{error.message}</p>
129
+ {data && <p className="text-theme-text-secondary">Showing the snapshot from {new Date(data.timestamp).toLocaleTimeString()}.</p>}
130
+ <button type="button" className="btn-brand px-3 py-1.5 text-sm font-medium" disabled={isFetching} onClick={() => void refetch()}>{isFetching ? 'Retrying…' : 'Retry diagnostics'}</button>
131
+ </div>
128
132
  )}
129
133
  {data && (
130
134
  <>
@@ -156,8 +160,8 @@ export function DiagnosticsOverlay({ onClose, isOpen = true, focus, communityUrl
156
160
 
157
161
  {/* Footer */}
158
162
  <div className="flex items-center gap-2 px-5 py-3 border-t border-theme-border shrink-0">
159
- <CopyButton label="Copy as Markdown" onClick={() => copyToClipboard('formatted')} copied={copied === 'formatted'} />
160
- <CopyButton label="Copy Raw JSON" onClick={() => copyToClipboard('json')} copied={copied === 'json'} />
163
+ <CopyButton disabled={!data} label="Copy as Markdown" onClick={() => copyToClipboard('formatted')} copied={copied === 'formatted'} />
164
+ <CopyButton disabled={!data} label="Copy Raw JSON" onClick={() => copyToClipboard('json')} copied={copied === 'json'} />
161
165
  <div className="flex-1" />
162
166
  {communityUrl && (
163
167
  <a
@@ -236,6 +240,7 @@ function ConnectionSection({ data }: { data: DiagnosticsSnapshot }) {
236
240
  <Row label="State" value={c.state} warn={warn} />
237
241
  <Row label="Context" value={c.context} />
238
242
  {c.clusterName && <Row label="Cluster" value={c.clusterName} />}
243
+ {c.progressMessage && <Row label="Progress" value={c.progressMessage} />}
239
244
  {c.error && <Row label="Error" value={c.error} warn />}
240
245
  {c.errorType && <Row label="Error Type" value={c.errorType} warn />}
241
246
  </Section>
@@ -266,10 +271,9 @@ function KubeconfigSection({ data }: { data: DiagnosticsSnapshot }) {
266
271
  value={k.kubeconfigEnvIgnored ? `Yes — ${k.kubeconfigEnvIgnoredReason}` : 'No'}
267
272
  warn={k.kubeconfigEnvIgnored}
268
273
  />
269
- <Row
270
- label="Current Context Uses Exec"
271
- value={k.currentContextUsesExec ? 'Yes' : 'No'}
272
- />
274
+ {k.currentContextUsesExec !== undefined && (
275
+ <Row label="Current Context Uses Exec" value={k.currentContextUsesExec ? 'Yes' : 'No'} />
276
+ )}
273
277
  {present.length > 0 && (
274
278
  <Row label="Exec Plugins on PATH" value={present.join(', ')} />
275
279
  )}
@@ -289,6 +293,7 @@ function ClusterSection({ data }: { data: DiagnosticsSnapshot }) {
289
293
  const c = data.cluster
290
294
  return (
291
295
  <Section title="Cluster">
296
+ {c.observedAt && <Row label="Last observed" value={new Date(c.observedAt).toLocaleString()} />}
292
297
  <Row label="Platform" value={c.platform} />
293
298
  <Row label="Kubernetes" value={c.kubernetesVersion} />
294
299
  <Row label="Nodes" value={c.nodeCount} />
@@ -385,7 +390,7 @@ function InformersSection({ data }: { data: DiagnosticsSnapshot }) {
385
390
  return (
386
391
  <Section title="Informers" warn={sectionWarn}>
387
392
  <Row label="Typed" value={inf.typedCount} />
388
- <Row label="Dynamic (CRDs)" value={inf.dynamicCount} />
393
+ <Row label="Dynamic (CRDs)" value={inf.dynamicCount ?? 'Unavailable'} />
389
394
  {sync && (
390
395
  <>
391
396
  <Row
@@ -648,12 +653,13 @@ function ConfigSection({ data }: { data: DiagnosticsSnapshot }) {
648
653
 
649
654
  // --- Copy button ---
650
655
 
651
- function CopyButton({ label, onClick, copied }: { label: string; onClick: () => void; copied: boolean }) {
656
+ function CopyButton({ label, onClick, copied, disabled }: { label: string; onClick: () => void; copied: boolean; disabled: boolean }) {
652
657
  return (
653
658
  <button
659
+ disabled={disabled}
654
660
  onClick={onClick}
655
661
  className={clsx(
656
- 'flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md transition-colors',
662
+ 'flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md transition-colors disabled:opacity-50',
657
663
  copied
658
664
  ? 'bg-green-500/20 text-green-400'
659
665
  : 'bg-theme-elevated text-theme-text-secondary hover:text-theme-text-primary hover:bg-theme-elevated/80'
@@ -679,6 +685,7 @@ export function formatForGitHub(data: DiagnosticsSnapshot, frontendPerf?: K8sUIP
679
685
  lines.push(`### Connection`)
680
686
  lines.push(`- State: \`${c.state}\``)
681
687
  lines.push(`- Context: \`${c.context}\``)
688
+ if (c.progressMessage) lines.push(`- Progress: ${c.progressMessage}`)
682
689
  if (c.clusterName) lines.push(`- Cluster: \`${c.clusterName}\``)
683
690
  if (c.error) lines.push(`- Error: ${c.error}`)
684
691
  if (c.errorType) lines.push(`- Error Type: \`${c.errorType}\``)
@@ -693,7 +700,9 @@ export function formatForGitHub(data: DiagnosticsSnapshot, frontendPerf?: K8sUIP
693
700
  : ''
694
701
  lines.push(`- Mode: \`${k.mode || '(not initialized)'}\` | Files: ${k.fileCount}${directoryFiles} | Contexts (after source resolution): ${k.contextCount}`)
695
702
  lines.push(`- KUBECONFIG Captured From Shell: ${k.enrichedFromShell ? 'Yes' : 'No'} | Ignored: ${k.kubeconfigEnvIgnored ? `Yes — ${k.kubeconfigEnvIgnoredReason}` : 'No'}`)
696
- lines.push(`- Current Context Uses Exec: ${k.currentContextUsesExec ? 'Yes' : 'No'}`)
703
+ if (k.currentContextUsesExec !== undefined) {
704
+ lines.push(`- Current Context Uses Exec: ${k.currentContextUsesExec ? 'Yes' : 'No'}`)
705
+ }
697
706
  if (k.execPluginsPresent && k.execPluginsPresent.length > 0) {
698
707
  lines.push(`- Exec Plugins on PATH: \`${k.execPluginsPresent.join('`, `')}\``)
699
708
  }
@@ -706,6 +715,7 @@ export function formatForGitHub(data: DiagnosticsSnapshot, frontendPerf?: K8sUIP
706
715
  if (data.cluster) {
707
716
  const c = data.cluster
708
717
  lines.push(`### Cluster`)
718
+ if (c.observedAt) lines.push(`- Last observed: ${c.observedAt}`)
709
719
  lines.push(`- Platform: \`${c.platform}\` | K8s: \`${c.kubernetesVersion}\` | Nodes: ${c.nodeCount} | Namespaces: ${c.namespaceCount}${c.inCluster ? ' | In-Cluster' : ''}`)
710
720
  lines.push(``)
711
721
  }
@@ -754,7 +764,7 @@ export function formatForGitHub(data: DiagnosticsSnapshot, frontendPerf?: K8sUIP
754
764
  if (data.informers) {
755
765
  const inf = data.informers
756
766
  lines.push(`### Informers`)
757
- lines.push(`- Typed: ${inf.typedCount} | Dynamic: ${inf.dynamicCount}`)
767
+ lines.push(`- Typed: ${inf.typedCount} | Dynamic: ${inf.dynamicCount ?? 'unavailable'}`)
758
768
  if (inf.syncStatus) {
759
769
  const sync = inf.syncStatus
760
770
  lines.push(`- Sync Phase: \`${sync.phase}\` (${formatElapsed(sync.elapsedSec)})`)
@@ -19,6 +19,7 @@ import {
19
19
  Megaphone,
20
20
  } from "lucide-react";
21
21
  import { SlackIcon } from "../community";
22
+ import type { ContextInfo } from "../../types";
22
23
  import { useNamespaces, useContexts } from "../../api/client";
23
24
  import { CORE_RESOURCES, useAPIResources } from "../../api/apiResources";
24
25
  import { getResourceIcon } from "../../utils/resource-icons";
@@ -126,7 +127,7 @@ export function bestScore(item: CommandItem, query: string): number {
126
127
  export interface CommandItemCallbacks {
127
128
  onNavigateView: (view: MainView) => void;
128
129
  onNavigateKind: (kind: string, group: string) => void;
129
- onSwitchContext: (name: string) => void;
130
+ onSwitchContext: (context: ContextInfo) => void;
130
131
  onSetNamespaces: (ns: string[]) => void;
131
132
  onToggleTheme: () => void;
132
133
  onShowDiagnostics?: () => void;
@@ -238,9 +239,7 @@ export function useCommandItems(cb: CommandItemCallbacks): CommandItem[] {
238
239
  sublabel: sub || undefined,
239
240
  category: "Clusters",
240
241
  icon: Server,
241
- action: () => {
242
- if (!ctx.isCurrent) cb.onSwitchContext(ctx.name);
243
- },
242
+ action: () => cb.onSwitchContext(ctx),
244
243
  searchTerms: [ctx.name, account || ""].filter(Boolean),
245
244
  });
246
245
  }
@@ -5,6 +5,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
5
5
  import type { ContextInfo } from '../types'
6
6
 
7
7
  const mocks = vi.hoisted(() => ({
8
+ connection: { errorType: undefined as string | undefined },
8
9
  mutateAsync: vi.fn(),
9
10
  setFailedSwitch: vi.fn(),
10
11
  startSwitch: vi.fn(),
@@ -14,6 +15,7 @@ vi.mock('../api/client', () => ({
14
15
  fetchSessionCounts: async () => ({ portForwards: 0 }),
15
16
  SwitchContextError: class extends Error {},
16
17
  }))
18
+ vi.mock('../context/ConnectionContext', () => ({ useConnection: () => ({ connection: mocks.connection }) }))
17
19
  vi.mock('../context/ContextSwitchContext', () => ({
18
20
  useContextSwitch: () => ({
19
21
  startSwitch: mocks.startSwitch,
@@ -39,6 +41,7 @@ function Probe() {
39
41
 
40
42
  beforeEach(() => {
41
43
  vi.clearAllMocks()
44
+ mocks.connection.errorType = undefined
42
45
  root = createRoot(document.createElement('div'))
43
46
  act(() => root.render(<Probe />))
44
47
  })
@@ -54,6 +57,12 @@ describe('useContextSwitchFlow', () => {
54
57
  expect(mocks.mutateAsync).not.toHaveBeenCalled()
55
58
  })
56
59
 
60
+ it('selecting the stopped target starts a fresh tracked switch', async () => {
61
+ mocks.connection.errorType = 'switch-stopped'
62
+ await act(() => flow().requestSwitch(ctx('current', true)))
63
+ expect(mocks.mutateAsync).toHaveBeenCalledWith({ name: 'current' })
64
+ })
65
+
57
66
  it('picking another cluster still switches', async () => {
58
67
  await act(() => flow().requestSwitch(ctx('staging', false)))
59
68
  expect(mocks.mutateAsync).toHaveBeenCalledWith({ name: 'staging' })