@skyhook-io/radar-app 1.21.6 → 1.21.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/README.md +1 -1
  2. package/package.json +7 -7
  3. package/src/App.tsx +31 -4
  4. package/src/RadarApp.tsx +8 -2
  5. package/src/api/client.discoverMetrics.test.tsx +69 -0
  6. package/src/api/client.issueCorrelation.test.tsx +244 -0
  7. package/src/api/client.issueRowChanges.test.tsx +129 -0
  8. package/src/api/client.pendingOwnership.test.tsx +197 -0
  9. package/src/api/client.prometheusStatus.test.ts +4 -0
  10. package/src/api/client.restartError.test.ts +36 -1
  11. package/src/api/client.stopWorkflow.test.tsx +133 -0
  12. package/src/api/client.submitWorkflowTemplate.test.tsx +127 -0
  13. package/src/api/client.ts +582 -114
  14. package/src/api/connectionBinding.test.tsx +3 -1
  15. package/src/api/connectionBinding.ts +14 -2
  16. package/src/api/gitOpsPermissions.render.test.tsx +155 -0
  17. package/src/api/gitOpsPermissions.test.ts +90 -0
  18. package/src/api/gitOpsPermissions.ts +51 -0
  19. package/src/api/httpErrors.test.ts +30 -1
  20. package/src/api/httpErrors.ts +17 -0
  21. package/src/api/openobserveSetup.ts +85 -0
  22. package/src/api/podDebug.test.tsx +137 -0
  23. package/src/api/podDebug.ts +82 -0
  24. package/src/api/prometheusCharts.test.ts +23 -0
  25. package/src/api/prometheusCharts.ts +25 -0
  26. package/src/api/radarFeatures.render.test.tsx +43 -2
  27. package/src/api/radarFeatures.test.ts +18 -1
  28. package/src/api/radarFeatures.ts +17 -4
  29. package/src/api/reviewedActionMutation.ts +9 -2
  30. package/src/api/workloadMetrics.ts +2 -0
  31. package/src/components/NamespaceSwitcher.tsx +6 -2
  32. package/src/components/applications/ApplicationsView.identity.test.ts +35 -7
  33. package/src/components/applications/ApplicationsView.openResource.test.tsx +137 -11
  34. package/src/components/applications/ApplicationsView.tsx +127 -173
  35. package/src/components/cnpg/CNPGOperatorConditions.test.tsx +3 -0
  36. package/src/components/cnpg/CNPGOperatorConditions.tsx +4 -14
  37. package/src/components/cnpg/host.test.tsx +1 -1
  38. package/src/components/cnpg/host.tsx +0 -2
  39. package/src/components/dock/BottomDock.tsx +7 -3
  40. package/src/components/dock/MissingShellDebug.test.tsx +193 -0
  41. package/src/components/dock/MissingShellDebug.tsx +114 -0
  42. package/src/components/dock/PodDebugSession.test.tsx +60 -0
  43. package/src/components/dock/PodDebugSession.tsx +96 -0
  44. package/src/components/dock/TerminalTab.test.tsx +48 -4
  45. package/src/components/dock/TerminalTab.tsx +47 -25
  46. package/src/components/dock/WorkloadLogsTab.test.tsx +24 -1
  47. package/src/components/dock/WorkloadLogsTab.tsx +16 -0
  48. package/src/components/execution/BatchExecutionView.command.test.tsx +69 -0
  49. package/src/components/execution/BatchExecutionView.tsx +88 -5
  50. package/src/components/execution/BatchExecutionView.workflow-stop.test.tsx +69 -0
  51. package/src/components/execution/WorkflowRunStopAction.tsx +8 -0
  52. package/src/components/gitops/GitOpsPermissionRowActions.test.tsx +100 -0
  53. package/src/components/gitops/GitOpsPermissionRowActions.tsx +27 -0
  54. package/src/components/gitops/GitOpsView.identity.test.tsx +1 -0
  55. package/src/components/gitops/GitOpsView.permissions.test.tsx +102 -0
  56. package/src/components/gitops/GitOpsView.syncRequest.test.tsx +95 -7
  57. package/src/components/gitops/GitOpsView.tsx +93 -32
  58. package/src/components/helm/OwnedResources.tsx +1 -0
  59. package/src/components/home/HomeView.tsx +9 -1
  60. package/src/components/home/ProblemsPanel.investigate.test.tsx +12 -2
  61. package/src/components/home/mcpToolCatalog.ts +1 -0
  62. package/src/components/issues/IssuesPane.render.test.tsx +78 -2
  63. package/src/components/issues/IssuesPane.tsx +49 -6
  64. package/src/components/issues/useIssueExpansion.ts +91 -0
  65. package/src/components/resource/MetricsNotConnected.test.tsx +50 -0
  66. package/src/components/resource/MetricsNotConnected.tsx +114 -0
  67. package/src/components/resource/PVCUsageBar.tsx +2 -1
  68. package/src/components/resource/PrometheusCharts.render.test.tsx +47 -0
  69. package/src/components/resource/PrometheusCharts.tsx +14 -2
  70. package/src/components/resource/PrometheusChartsGrid.render.test.tsx +91 -1
  71. package/src/components/resource/PrometheusChartsGrid.tsx +28 -52
  72. package/src/components/resource/RestartChart.tsx +4 -3
  73. package/src/components/resource/RightsizingPanel.source.test.tsx +34 -0
  74. package/src/components/resource/RightsizingStrip.tsx +5 -3
  75. package/src/components/resource/WorkloadMetricsSection.render.test.tsx +6 -0
  76. package/src/components/resource/WorkloadMetricsSection.tsx +14 -11
  77. package/src/components/resource/nameMatchedScope.ts +9 -3
  78. package/src/components/resources/EmptyNamespaceHint.tsx +42 -0
  79. package/src/components/resources/PodDebugAction.test.tsx +157 -0
  80. package/src/components/resources/PodDebugAction.tsx +207 -0
  81. package/src/components/resources/PodDebugPermission.tsx +21 -0
  82. package/src/components/resources/ResourcesView.empty-hint.test.tsx +132 -0
  83. package/src/components/resources/ResourcesView.tsx +39 -5
  84. package/src/components/resources/namespaceHint.test.ts +34 -0
  85. package/src/components/resources/namespaceHint.ts +19 -0
  86. package/src/components/resources/renderers/AdmissionPolicyRenderers.tsx +135 -0
  87. package/src/components/resources/renderers/NodeRenderer.tsx +2 -1
  88. package/src/components/resources/renderers/PodRenderer.tsx +12 -5
  89. package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.test.tsx +24 -1
  90. package/src/components/settings/FormSaveActions.tsx +6 -2
  91. package/src/components/settings/LocalIntegrationStatus.tsx +14 -3
  92. package/src/components/settings/MetricsBackendSwitch.tsx +165 -0
  93. package/src/components/settings/OpenObserveSetup.test.tsx +384 -0
  94. package/src/components/settings/OpenObserveSetup.tsx +328 -0
  95. package/src/components/settings/SettingsDialog.tsx +21 -7
  96. package/src/components/settings/openobserveStatus.test.ts +34 -0
  97. package/src/components/settings/openobserveStatus.ts +55 -0
  98. package/src/components/timeline/TimelineList.selection.test.tsx +40 -0
  99. package/src/components/timeline/TimelineList.test.ts +18 -0
  100. package/src/components/timeline/TimelineList.tsx +19 -5
  101. package/src/components/timeline/TimelineView.tsx +2 -0
  102. package/src/components/workload/WorkloadView.pendingOwnership.test.tsx +34 -0
  103. package/src/components/workload/WorkloadView.tabUrl.test.tsx +44 -0
  104. package/src/components/workload/WorkloadView.tsx +103 -16
  105. package/src/components/workspace/WorkspaceConditions.tsx +56 -0
  106. package/src/components/workspace/layout.test.tsx +20 -0
  107. package/src/components/workspace/layout.tsx +1 -1
  108. package/src/context/TimelineNavigation.test.ts +59 -0
  109. package/src/context/TimelineNavigation.tsx +86 -0
  110. package/src/contexts/CapabilitiesContext.tsx +5 -1
  111. package/src/hooks/useResourceCounts.ts +2 -1
  112. package/src/hooks/useWorkflowStopAction.ts +31 -0
  113. package/src/index.css +1 -0
  114. package/src/integrations/resourceHosts.test.tsx +2 -2
  115. package/src/integrations/resourceHosts.tsx +4 -2
  116. package/src/k8s-ui-exports.test.ts +10 -0
  117. package/src/utils/page-links.ts +15 -1
  118. package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.tsx +0 -128
@@ -46,6 +46,7 @@ interface HomeViewProps {
46
46
  namespaces: string[]
47
47
  topology: Topology | null
48
48
  onNavigateToView: (view: ExtendedMainView, params?: Record<string, string>) => void
49
+ onNavigateToIssue?: (id: string) => void
49
50
  onNavigateToResourceKind: (kind: string, group?: string, filters?: Record<string, string[]>) => void
50
51
  onNavigateToResource: (resource: SelectedResource) => void
51
52
  fallbackClusterLoadState?: ClusterLoadState
@@ -62,7 +63,7 @@ interface HomeViewProps {
62
63
  onNavigateToManagerPath?: (path: string) => void
63
64
  }
64
65
 
65
- export function HomeView({ namespaces, topology, fallbackClusterLoadState, onNavigateToView, onNavigateToResourceKind, onNavigateToResource, onNavigateToCerts, onNavigateToUpgradeImpact, onNavigateToHelmRelease, onNavigateToManagerPath }: HomeViewProps) {
66
+ export function HomeView({ namespaces, topology, fallbackClusterLoadState, onNavigateToView, onNavigateToIssue, onNavigateToResourceKind, onNavigateToResource, onNavigateToCerts, onNavigateToUpgradeImpact, onNavigateToHelmRelease, onNavigateToManagerPath }: HomeViewProps) {
66
67
  // The card itself decides whether the cluster has a capacity story
67
68
  // (available, softened-denied, or karpenterless-with-managers/groups) and
68
69
  // returns null otherwise — the outer gate only excludes states with nothing
@@ -290,6 +291,7 @@ export function HomeView({ namespaces, topology, fallbackClusterLoadState, onNav
290
291
  error={issuesError}
291
292
  totalReturned={issues.length}
292
293
  onNavigateToIssues={() => onNavigateToView('issues')}
294
+ onNavigateToIssue={onNavigateToIssue}
293
295
  onResourceClick={onNavigateToResource}
294
296
  />
295
297
  </div>
@@ -343,6 +345,7 @@ interface ProblemsPanelProps {
343
345
  error: unknown
344
346
  totalReturned: number
345
347
  onNavigateToIssues: () => void
348
+ onNavigateToIssue?: (id: string) => void
346
349
  onResourceClick: (resource: SelectedResource) => void
347
350
  }
348
351
 
@@ -358,6 +361,7 @@ export function ProblemsPanel({
358
361
  error,
359
362
  totalReturned,
360
363
  onNavigateToIssues,
364
+ onNavigateToIssue,
361
365
  onResourceClick,
362
366
  }: ProblemsPanelProps) {
363
367
  const unchecked = uncheckedLines.length > 0
@@ -475,6 +479,10 @@ export function ProblemsPanel({
475
479
  className="w-full flex items-center gap-2 px-3 py-1.5 group-hover:bg-theme-hover group-has-[:focus-visible]:bg-theme-hover transition-colors text-left"
476
480
  onClick={() => {
477
481
  recordUsageEvent({ type: 'ui', name: 'issue_action:open' })
482
+ if (onNavigateToIssue) {
483
+ onNavigateToIssue(issue.id)
484
+ return
485
+ }
478
486
  onResourceClick({
479
487
  kind: ref.kind,
480
488
  namespace: ref.namespace ?? '',
@@ -42,7 +42,7 @@ let root: Root
42
42
  let container: HTMLDivElement
43
43
  const onResourceClick = vi.fn()
44
44
 
45
- function render(rowIssue: Issue = issue) {
45
+ function render(rowIssue: Issue = issue, onNavigateToIssue?: (id: string) => void) {
46
46
  act(() => {
47
47
  root.render(
48
48
  <ProblemsPanel
@@ -55,6 +55,7 @@ function render(rowIssue: Issue = issue) {
55
55
  error={null}
56
56
  totalReturned={1}
57
57
  onNavigateToIssues={() => {}}
58
+ onNavigateToIssue={onNavigateToIssue}
58
59
  onResourceClick={onResourceClick}
59
60
  />,
60
61
  )
@@ -89,7 +90,16 @@ describe('Home Active Issues Investigate action', () => {
89
90
  expect(onResourceClick).not.toHaveBeenCalled()
90
91
  })
91
92
 
92
- it('still opens the resource from the rest of the row', () => {
93
+ it('opens the issue from the row when the Issues page handles links', () => {
94
+ const onNavigateToIssue = vi.fn()
95
+ render(issue, onNavigateToIssue)
96
+ const row = buttons().find((b) => b.textContent?.includes('checkout'))
97
+ act(() => row!.click())
98
+ expect(onNavigateToIssue).toHaveBeenCalledWith(issue.id)
99
+ expect(onResourceClick).not.toHaveBeenCalled()
100
+ })
101
+
102
+ it('still opens the resource from the row when the host takes over Issues', () => {
93
103
  render()
94
104
  const row = buttons().find((b) => b.textContent?.includes('checkout'))
95
105
  act(() => row!.click())
@@ -61,6 +61,7 @@ export const MCP_TOOL_CATALOG: MCPToolInfo[] = [
61
61
  { arg: 'group', desc: 'API group when the kind is ambiguous (e.g. serving.knative.dev for Knative Service vs core Service)' },
62
62
  { arg: 'include', desc: 'events, metrics, changes, issues, drain-plan (Node pod/PDB estimate), revisions (rollback targets for Deployment/StatefulSet/DaemonSet/Rollout)' },
63
63
  { arg: 'context', desc: 'resourceContext tier: basic (default) or none' },
64
+ { arg: 'relationship', desc: 'one relationship field a partial-preview warning named (e.g. dependents), returned with up to 200 entries' },
64
65
  ],
65
66
  },
66
67
  {
@@ -1,19 +1,26 @@
1
+ // @vitest-environment jsdom
2
+ import { act } from 'react'
3
+ import { createRoot } from 'react-dom/client'
1
4
  import { beforeEach, describe, expect, it, vi } from 'vitest'
2
5
  import { renderToString } from 'react-dom/server'
3
- import { MemoryRouter } from 'react-router-dom'
6
+ import { createMemoryRouter, MemoryRouter, RouterProvider } from 'react-router-dom'
7
+ import type { IssueAppInventoryRow } from '@skyhook-io/k8s-ui/components/issues'
4
8
  import type { IssuesResponse, SubjectIssuesResponse } from '../../api/client'
5
9
  import { IssuesPane } from './IssuesPane'
6
10
 
7
11
  const state = vi.hoisted(() => ({
12
+ applications: vi.fn<() => { data?: { applications: IssueAppInventoryRow[] } }>(() => ({})),
8
13
  fleet: { data: undefined as IssuesResponse | undefined, isLoading: false, error: null as Error | null, dataUpdatedAt: 0, refetch: vi.fn() },
9
14
  subject: { data: undefined as SubjectIssuesResponse | undefined, isLoading: false, error: null as Error | null, dataUpdatedAt: 0, refetch: vi.fn() },
10
15
  }))
11
- vi.mock('../../api/client', () => ({ useIssues: () => state.fleet, useSubjectIssues: () => state.subject }))
16
+ vi.mock('../../api/client', () => ({ useApplications: state.applications, useIssues: () => state.fleet, useSubjectIssues: () => state.subject, useIssueCorrelation: () => ({ data: undefined, error: null, isFetching: false, dataUpdatedAt: 0, refetch: vi.fn() }), useIssueRowChanges: () => undefined }))
12
17
  vi.mock('../../api/apiResources', () => ({ useAPIResources: () => ({ data: undefined }), karpenterCapacityAvailable: () => false }))
13
18
  vi.mock('../../contexts/CapabilitiesContext', () => ({ useCapabilitiesContext: () => ({}) }))
14
19
  vi.mock('../../context/ConnectionContext', () => ({ useConnection: () => ({ connection: { state: 'connected' } }) }))
15
20
  vi.mock('../diagnose/LocalDiagnoseAction', () => ({ IssueDiagnoseButton: () => null }))
16
21
 
22
+ Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
23
+
17
24
  const subjectUrl = '/issues?kind=Pod&resource=db%2Fpg-1'
18
25
  const issue = {
19
26
  id: 'pod-failed', severity: 'critical' as const, source: 'problem', category: 'workload', category_group: 'workload', grouping_scope: 'resource',
@@ -25,11 +32,80 @@ function render(url = subjectUrl, namespaces: string[] = []) {
25
32
  }
26
33
 
27
34
  beforeEach(() => {
35
+ state.applications.mockClear()
28
36
  state.fleet = { data: undefined, isLoading: false, error: null, dataUpdatedAt: 0, refetch: vi.fn() }
29
37
  state.subject = { data: { issues: [issue], coverage: 'ok' }, isLoading: false, error: null, dataUpdatedAt: 0, refetch: vi.fn() }
30
38
  })
31
39
 
32
40
  describe('Issues page query ownership', () => {
41
+ it('only requests scoped application inventory for lists that can group', () => {
42
+ state.fleet.data = { issues: [issue] }
43
+ render('/issues', ['db'])
44
+ expect(state.applications).toHaveBeenLastCalledWith(['db'], { enabled: false })
45
+ state.fleet.data.issues.push({ ...issue, id: 'other' })
46
+ render('/issues', ['db'])
47
+ expect(state.applications).toHaveBeenLastCalledWith(['db'], { enabled: true })
48
+ render(subjectUrl, ['db'])
49
+ expect(state.applications).toHaveBeenLastCalledWith(['db'], { enabled: false })
50
+ })
51
+
52
+ it('links the panel to its exact application within the selected namespaces', () => {
53
+ const key = 'helm/db/checkout+api'
54
+ const workload = { kind: 'Deployment', name: 'checkout-api', namespace: 'db', group: 'apps' }
55
+ state.applications.mockReturnValueOnce({ data: { applications: [{ key, name: 'checkout', workloads: [workload] }] } })
56
+ const first = { ...issue, ...workload, grouping_scope: 'workload' }
57
+ state.fleet.data = { issues: [first, { ...first, id: 'other' }] }
58
+
59
+ const container = document.createElement('div')
60
+ container.innerHTML = render('/issues?issue=other', ['db', 'test'])
61
+ const link = container.querySelector<HTMLAnchorElement>('h2 a')!
62
+ expect(link.textContent).toBe('Open checkout application')
63
+ const url = new URL(link.href)
64
+ expect(url.pathname).toBe('/applications')
65
+ expect(Object.fromEntries(url.searchParams)).toEqual({ app: key, namespaces: 'db,test' })
66
+ })
67
+
68
+ it('replaces a link when triaging and reveals the next linked issue through an active filter', async () => {
69
+ state.fleet.data = { issues: [issue, { ...issue, id: 'replicas', severity: 'warning', reason: 'Unavailable' }] }
70
+ const router = createMemoryRouter([
71
+ { path: '/', element: <div>Home</div> },
72
+ { path: '/issues', element: <IssuesPane namespaces={['db']} onNavigateToResource={() => {}} /> },
73
+ ], { initialEntries: ['/', '/issues?namespaces=db&issue=pod-failed'], initialIndex: 1 })
74
+ const container = document.createElement('div')
75
+ const root = createRoot(container)
76
+ const row = (id: string) => container.querySelector(`[data-app-issue-row=":${id}"]`)
77
+ const toggle = (id: string) => row(id)!.querySelector<HTMLElement>('[role=button][aria-expanded]')!
78
+ try {
79
+ await act(async () => { root.render(<RouterProvider router={router} />) })
80
+ expect(toggle('pod-failed').getAttribute('aria-expanded')).toBe('true')
81
+ await act(async () => { toggle('replicas').click() })
82
+ expect(router.state.location.search).toBe('?namespaces=db')
83
+ expect(toggle('replicas').getAttribute('aria-expanded')).toBe('true')
84
+ await act(async () => { await router.navigate(-1) })
85
+ expect(router.state.location.pathname).toBe('/')
86
+
87
+ await act(async () => { await router.navigate('/issues?namespaces=db&issue=replicas') })
88
+ const critical = [...container.querySelectorAll('button')].find(button => button.textContent === '1Critical')!
89
+ await act(async () => { critical.click() })
90
+ expect(row('replicas')).toBeNull()
91
+ expect(router.state.location.search).toBe('?namespaces=db')
92
+ await act(async () => { await router.navigate('/issues?namespaces=db&issue=replicas') })
93
+ expect(toggle('replicas').getAttribute('aria-expanded')).toBe('true')
94
+ expect(row('pod-failed')).toBeTruthy()
95
+ } finally {
96
+ await act(async () => { root.unmount() })
97
+ router.dispose()
98
+ }
99
+ })
100
+
101
+ it('explains a missing issue link while keeping the current issues visible', () => {
102
+ state.fleet.data = { issues: [issue] }
103
+ const html = render('/issues?issue=absent')
104
+ expect(html).toContain('The linked issue is outside the current results.')
105
+ expect(html).toContain(issue.message)
106
+ expect(render('/issues?issue=pod-failed')).not.toContain('outside the current results')
107
+ })
108
+
33
109
  it.each(['loading', 'failed'] as const)('renders subject results while the fleet query is %s', (fleetState) => {
34
110
  state.fleet.isLoading = fleetState === 'loading'
35
111
  state.fleet.error = fleetState === 'failed' ? new Error('Fleet unavailable') : null
@@ -1,6 +1,6 @@
1
1
  import { useMemo, useState } from "react";
2
- import { useNavigate, useSearchParams } from "react-router-dom";
3
- import { useIssues, useSubjectIssues, type SubjectIssuesResponse } from "../../api/client";
2
+ import { Link, useNavigate, useSearchParams } from "react-router-dom";
3
+ import { useApplications, useIssues, useSubjectIssues, type SubjectIssuesResponse } from "../../api/client";
4
4
  import {
5
5
  useAPIResources,
6
6
  karpenterCapacityAvailable,
@@ -22,12 +22,15 @@ import {
22
22
  type IssueSeverity,
23
23
  type SummaryTone,
24
24
  } from "@skyhook-io/k8s-ui";
25
+ import { buildIssueAppIndex } from "@skyhook-io/k8s-ui/components/issues";
25
26
  import { builtinGroupForKind } from "@skyhook-io/k8s-ui/utils/api-resources";
26
27
  import { AlertTriangle } from "lucide-react";
27
28
  import { IssueDiagnoseButton } from "../diagnose/LocalDiagnoseAction";
28
29
  import { recordUsageEvent } from "../../api/usage-data";
29
30
  import { uncheckedSourceLines, uncheckedSubjectWhy } from "./uncheckedSources";
30
31
  import { UncheckedSourceHelp } from "./UncheckedSourceHelp";
32
+ import { useClearLinkedIssue } from "../../utils/page-links";
33
+ import { useIssueExpansion, useIssueRowNotes } from "./useIssueExpansion";
31
34
 
32
35
  // A capacity-relevant issue links to its Karpenter diagnosis. Karpenter is
33
36
  // always single-cluster (unlike Argo hub-and-spoke), so the issue and the
@@ -184,9 +187,16 @@ export function IssuesPane({
184
187
  showNamespace,
185
188
  }: IssuesPaneProps) {
186
189
  const [searchParams, setSearchParams] = useSearchParams();
190
+ const clearLinkedIssue = useClearLinkedIssue();
191
+ const linkedIssueId = searchParams.get("issue") || undefined;
187
192
  const subject = useMemo(() => issueSubjectFromParams(searchParams), [searchParams]);
188
193
  const { data, isLoading, isFetching, error, dataUpdatedAt, refetch } =
189
194
  useIssues(namespaces, !subject);
195
+ const canGroup = !subject && (data?.issues.length ?? 0) > 1;
196
+ const { data: inventory } = useApplications(namespaces, { enabled: canGroup });
197
+ const appForIssue = useMemo(() => canGroup && inventory
198
+ ? buildIssueAppIndex(inventory.applications, { complete: namespaces.length === 0 && inventory.access?.restricted === false })
199
+ : undefined, [canGroup, inventory, namespaces.length]);
190
200
  const { connection } = useConnection();
191
201
  const navigate = useNavigate();
192
202
  const apiResources = useAPIResources();
@@ -198,9 +208,22 @@ export function IssuesPane({
198
208
  new Set(),
199
209
  );
200
210
 
211
+ // A new link reveals its target even if the last view filtered its severity.
212
+ // Removing the link after a click keeps the user's new choice intact.
213
+ const [previousLink, setPreviousLink] = useState(linkedIssueId);
214
+ if (previousLink !== linkedIssueId) {
215
+ setPreviousLink(linkedIssueId);
216
+ if (linkedIssueId && severityFilter.size) setSeverityFilter(new Set());
217
+ }
218
+
201
219
  const subjectHidden =
202
220
  !!subject?.namespace && namespaces.length > 0 && !namespaces.includes(subject.namespace);
203
221
  const related = useSubjectIssues(subject, !subjectHidden);
222
+ const expansion = useIssueExpansion(() => {
223
+ if (subject) void related.refetch();
224
+ else void refetch();
225
+ });
226
+ const rowNotes = useIssueRowNotes();
204
227
  const subjectState = subject
205
228
  ? issueSubjectState(subject, namespaces, related)
206
229
  : null;
@@ -222,6 +245,7 @@ export function IssuesPane({
222
245
  setSearchParams(
223
246
  (prev) => {
224
247
  const next = new URLSearchParams(prev);
248
+ next.delete("issue");
225
249
  next.delete("kind");
226
250
  next.delete("apiGroup");
227
251
  next.delete("resource");
@@ -230,13 +254,15 @@ export function IssuesPane({
230
254
  { replace: true },
231
255
  );
232
256
 
233
- const toggleSeverity = (s: IssueSeverity) =>
257
+ const toggleSeverity = (s: IssueSeverity) => {
258
+ clearLinkedIssue();
234
259
  setSeverityFilter((prev) => {
235
260
  const next = new Set(prev);
236
261
  if (next.has(s)) next.delete(s);
237
262
  else next.add(s);
238
263
  return next;
239
264
  });
265
+ };
240
266
 
241
267
  const onResourceClick = (ref: IssueResourceRef) => {
242
268
  recordUsageEvent({ type: "ui", name: "issue_action:open" });
@@ -265,7 +291,7 @@ export function IssuesPane({
265
291
  <PageHeader
266
292
  icon={AlertTriangle}
267
293
  title="Issues"
268
- description="Live cluster problems — crashes, scheduling failures, bad references — grouped by the resource they affect."
294
+ description="Live cluster problems, with critical issues first."
269
295
  actions={
270
296
  <>
271
297
  {subjectHidden ? null : <FreshnessControl
@@ -301,6 +327,10 @@ export function IssuesPane({
301
327
  }
302
328
  />
303
329
 
330
+ {!subject && linkedIssueId && data && !pageIssues.some((issue) => issue.id === linkedIssueId) && (
331
+ <p className="text-sm text-theme-text-secondary">The linked issue is outside the current results.</p>
332
+ )}
333
+
304
334
  {!subject && error && (
305
335
  <div className="flex items-start gap-2 rounded-lg border border-theme-border bg-theme-elevated px-3 py-2 text-xs text-theme-text-secondary">
306
336
  <AlertTriangle className="mt-0.5 h-4 w-4 shrink-0 text-amber-500" aria-hidden />
@@ -357,7 +387,7 @@ export function IssuesPane({
357
387
  {showNamespace && (
358
388
  <button
359
389
  type="button"
360
- onClick={() => showNamespace.show(subject.namespace)}
390
+ onClick={() => { clearLinkedIssue(); showNamespace.show(subject.namespace); }}
361
391
  className="text-accent-text hover:underline"
362
392
  >
363
393
  {showNamespace.mode === "add" ? "Add" : "Switch to"}{" "}
@@ -396,7 +426,7 @@ export function IssuesPane({
396
426
  <p>No issues match the selected severity.</p>
397
427
  <button
398
428
  type="button"
399
- onClick={() => setSeverityFilter(new Set())}
429
+ onClick={() => { clearLinkedIssue(); setSeverityFilter(new Set()); }}
400
430
  className="text-xs text-skyhook-600 hover:text-skyhook-500 dark:text-skyhook-400"
401
431
  >
402
432
  Clear filter
@@ -422,8 +452,21 @@ export function IssuesPane({
422
452
  list then means "nothing broken" rather than "not connected". */
423
453
  <IssuesView
424
454
  issues={shown}
455
+ appForIssue={appForIssue}
456
+ renderAppLink={(key, label) => {
457
+ const params = new URLSearchParams({ app: key });
458
+ if (namespaces.length) params.set("namespaces", namespaces.join(","));
459
+ return <Link to={{ pathname: "/applications", search: params.toString() }}>{label}</Link>;
460
+ }}
461
+ linkedIssueId={linkedIssueId}
462
+ onManualIssueToggle={clearLinkedIssue}
425
463
  anyData={subject ? !!related.data : !!data}
426
464
  onResourceClick={onResourceClick}
465
+ onOpenIssueChange={expansion.onOpenIssueChange}
466
+ expandedIssue={expansion.expandedIssue}
467
+ timelineLinks={expansion.timelineLinks}
468
+ rowChanges={rowNotes.rowChanges}
469
+ onVisibleIssuesChange={rowNotes.onVisibleIssuesChange}
427
470
  renderActions={({ issue }) => {
428
471
  const capacityHref = capacityHrefForIssue(issue, hasKarpenter);
429
472
  return (
@@ -0,0 +1,91 @@
1
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
2
+ import { issueRowKey, type Issue, type IssueExpansion } from "@skyhook-io/k8s-ui";
3
+ import { useIssueCorrelation, useIssueRowChanges, type CorrelatedIssuesResponse } from "../../api/client";
4
+ import { RadarFeatureUnsupportedError } from "../../api/radarFeatures";
5
+ import { useTimelineEventLinks } from "../../context/TimelineNavigation";
6
+
7
+ interface CorrelationQuery {
8
+ data: CorrelatedIssuesResponse | undefined;
9
+ error: unknown;
10
+ isFetching: boolean;
11
+ dataUpdatedAt: number;
12
+ refetch: () => unknown;
13
+ }
14
+
15
+ /** Maps the correlation request for the open issue onto what the row renders.
16
+ * Data wins over a later refresh error: the row keeps the last answer and says
17
+ * the refresh failed and when that answer arrived. */
18
+ export function issueExpansionFromQuery(issue: Issue, query: CorrelationQuery): IssueExpansion {
19
+ const onRetry = () => { void query.refetch(); };
20
+ const retrying = query.isFetching;
21
+ if (query.data) {
22
+ const status = query.data.correlation_status;
23
+ if (status === "user_forbidden" || status === "read_error") {
24
+ return { recentChanges: { status: "unavailable", reason: status }, onRetry, retrying };
25
+ }
26
+ // An issue Radar doesn't correlate comes back unchanged, with no
27
+ // correlation and no status; the row then shows no Recent changes section.
28
+ const fresh = status === "not_found"
29
+ ? undefined
30
+ : query.data.issues?.find((candidate) => candidate.id === issue.id);
31
+ if (!fresh) return { recentChanges: { status: "not_found" } };
32
+ // An ineligible issue comes back as the list has it. Overriding the row with
33
+ // it would only freeze the row on that copy once later refreshes fail.
34
+ if (!fresh.correlation && !fresh.correlated_changes && !fresh.no_recent_changes) {
35
+ return { recentChanges: { status: "loaded" } };
36
+ }
37
+ return {
38
+ issue: fresh,
39
+ recentChanges: { status: "loaded" },
40
+ onRetry,
41
+ retrying,
42
+ ...(query.error ? { refreshFailed: { fetchedAt: query.dataUpdatedAt } } : {}),
43
+ };
44
+ }
45
+ if (query.error instanceof RadarFeatureUnsupportedError) {
46
+ return { recentChanges: { status: "unsupported", upgrade: query.error.radarUpgrade } };
47
+ }
48
+ if (query.error) return { recentChanges: { status: "failed" }, onRetry, retrying };
49
+ return { recentChanges: { status: "loading" } };
50
+ }
51
+
52
+ /**
53
+ * Wires a host's issue list (IssuesView or ResourceIssuesSection) to the
54
+ * correlation request: the list reports its open row, this fetches for that
55
+ * one issue, and the open row renders the fresh answer. `onNotFound` refreshes
56
+ * the host's list when the open issue is no longer in the subject's answer.
57
+ */
58
+ export function useIssueExpansion(onNotFound?: () => void) {
59
+ const [openIssue, setOpenIssue] = useState<Issue | null>(null);
60
+ const query = useIssueCorrelation(openIssue, openIssue !== null);
61
+ const { data, error, isFetching, refetch, dataUpdatedAt } = query;
62
+ const expansion = useMemo(
63
+ () => (openIssue ? issueExpansionFromQuery(openIssue, { data, error, isFetching, dataUpdatedAt, refetch }) : undefined),
64
+ [openIssue, data, error, isFetching, dataUpdatedAt, refetch],
65
+ );
66
+
67
+ const notFoundRef = useRef(onNotFound);
68
+ notFoundRef.current = onNotFound;
69
+ const notFound = expansion?.recentChanges.status === "not_found";
70
+ useEffect(() => {
71
+ if (notFound) notFoundRef.current?.();
72
+ }, [notFound, dataUpdatedAt]);
73
+
74
+ const openKey = openIssue ? issueRowKey(openIssue) : null;
75
+ const expandedIssue = useCallback(
76
+ (issue: Issue) => (openKey !== null && issueRowKey(issue) === openKey ? expansion : undefined),
77
+ [openKey, expansion],
78
+ );
79
+ const timelineLinks = useTimelineEventLinks();
80
+ return { onOpenIssueChange: setOpenIssue, expandedIssue, timelineLinks };
81
+ }
82
+
83
+ /**
84
+ * Wires a host's issue list to the batched row lookup: the list reports the
85
+ * rows on screen, this fetches the one change each of them names.
86
+ */
87
+ export function useIssueRowNotes() {
88
+ const [visible, setVisible] = useState<Issue[]>([]);
89
+ const rowChanges = useIssueRowChanges(visible);
90
+ return { rowChanges, onVisibleIssuesChange: setVisible };
91
+ }
@@ -0,0 +1,50 @@
1
+ // @vitest-environment jsdom
2
+ import { act } from 'react'
3
+ import { createRoot } from 'react-dom/client'
4
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
5
+ import { expect, it, vi } from 'vitest'
6
+ import type { PrometheusStatus } from '../../api/client'
7
+ import { NavCustomizationProvider } from '../../context/NavCustomization'
8
+ vi.mock('../../hooks/usePreviousIntegrationSettings', () => ({ usePreviousIntegrationSettings: () => ({ metrics: false }) }))
9
+
10
+ const { MetricsNotConnected, OpenObserveUnavailable } = await import('./MetricsNotConnected')
11
+
12
+ vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
13
+
14
+ it('drops a discovery result once the metrics source changes', async () => {
15
+ vi.stubGlobal('fetch', vi.fn<typeof fetch>(async (input) => String(input).includes('/prometheus/connect')
16
+ ? new Response(JSON.stringify({ error: 'Prometheus connection failed' }), { status: 502 })
17
+ : new Response(JSON.stringify({ detected: false }))))
18
+ const client = new QueryClient({ defaultOptions: { mutations: { retry: false }, queries: { retry: false } } })
19
+ const container = document.createElement('div')
20
+ const root = createRoot(container)
21
+ const render = (status: PrometheusStatus) => root.render(
22
+ <QueryClientProvider client={client}><NavCustomizationProvider value={{}}>
23
+ <MetricsNotConnected status={status} isWorkload={false} />
24
+ </NavCustomizationProvider></QueryClientProvider>,
25
+ )
26
+ const before: PrometheusStatus = { available: false, connected: false, openobserve: 'local' }
27
+ await act(async () => render(before))
28
+ const discover = () => [...container.querySelectorAll('button')].find((b) => b.textContent === 'Discover metrics')
29
+ await act(async () => discover()!.click())
30
+ expect(container.querySelector('[role="status"]')?.textContent).toBe('No metrics source found.')
31
+ expect(discover()).toBeUndefined()
32
+
33
+ await act(async () => render({ ...before, source: { kind: 'openobserve', via: 'local', warning: 'Checking…', pending: true } }))
34
+ expect(container.querySelector('[role="status"]')).toBeNull()
35
+ expect(discover()).toBeDefined()
36
+ act(() => root.unmount())
37
+ vi.unstubAllGlobals()
38
+ })
39
+
40
+ it('says OpenObserve unavailable once', async () => {
41
+ vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
42
+ const container = document.createElement('div')
43
+ const root = createRoot(container)
44
+ const status: PrometheusStatus = { available: false, connected: true, source: { kind: 'openobserve', via: 'hub', unavailable: true, error: 'OpenObserve unavailable: Radar Hub could not be reached' } }
45
+ await act(async () => root.render(<NavCustomizationProvider value={{}}><OpenObserveUnavailable status={status} /></NavCustomizationProvider>))
46
+ expect(container.textContent?.match(/OpenObserve unavailable/g)).toHaveLength(1)
47
+ expect(container.textContent).toContain('Radar Hub could not be reached')
48
+ act(() => root.unmount())
49
+ vi.unstubAllGlobals()
50
+ })
@@ -0,0 +1,114 @@
1
+ import { clsx } from "clsx";
2
+ import { Loader2, Wifi, WifiOff } from "lucide-react";
3
+ import {
4
+ usePrometheusConnect,
5
+ useDiscoverMetrics,
6
+ type PrometheusStatus,
7
+ } from "../../api/client";
8
+ import { useNavCustomization } from "../../context/NavCustomization";
9
+ import { unavailableReason } from '../settings/openobserveStatus';
10
+ import { previousSettingsNote, usePreviousIntegrationSettings } from '../../hooks/usePreviousIntegrationSettings';
11
+
12
+ const openMetricsSettings = () => window.dispatchEvent(new CustomEvent('radar:open-settings', { detail: { section: 'prometheus' } }));
13
+
14
+ interface MetricsNotConnectedProps {
15
+ status?: PrometheusStatus;
16
+ isWorkload: boolean;
17
+ }
18
+
19
+ // A discovery result describes the status it ran against, so it starts over
20
+ // once the connection or its source changes.
21
+ export function MetricsNotConnected(props: MetricsNotConnectedProps) {
22
+ const { status } = props;
23
+ return <NotConnected key={`${status?.connected}|${status?.source?.kind}|${status?.source?.via}`} {...props} />;
24
+ }
25
+
26
+ function NotConnected({ status, isWorkload }: MetricsNotConnectedProps) {
27
+ const connectMutation = usePrometheusConnect();
28
+ const discoverMutation = useDiscoverMetrics();
29
+ const settingsAvailable = !useNavCustomization().embedded;
30
+ const offers = usePreviousIntegrationSettings(!!status);
31
+ const previousNote = offers.metrics ? previousSettingsNote('metrics', offers.metrics) : undefined;
32
+ const openObservePath = status?.openobserve;
33
+ const discovery = openObservePath ? discoverMutation : connectMutation;
34
+ const outcome = openObservePath ? discoverMutation.data : undefined;
35
+ const failure = openObservePath ? discoverMutation.error?.message : undefined;
36
+ const notFound = outcome === "none" || outcome === "collector";
37
+ return (
38
+ <div className="flex flex-col items-center justify-center py-12 gap-4">
39
+ <WifiOff className="w-10 h-10 text-theme-text-quaternary" />
40
+ <div className="text-center">
41
+ <p className="text-sm text-theme-text-secondary mb-1">
42
+ {openObservePath ? "No metrics source connected" : "Prometheus not connected"}
43
+ </p>
44
+ <p className="text-xs text-theme-text-tertiary mb-4">
45
+ {status?.error || (openObservePath
46
+ ? "Radar can read metrics from Prometheus or OpenObserve."
47
+ : "Connect to view historical CPU, memory, and network metrics")}
48
+ </p>
49
+ {(notFound || failure) && <p role="status" className="text-sm text-theme-text-secondary mb-4">
50
+ {failure
51
+ ? failure
52
+ : outcome === "none"
53
+ ? "No metrics source found."
54
+ : openObservePath === "hub"
55
+ ? "OpenObserve collector found. Ask your organization owner to connect OpenObserve in Radar Hub."
56
+ : "OpenObserve collector found. Connect it in Settings → Metrics."}
57
+ </p>}
58
+ <div className="flex flex-wrap items-center justify-center gap-3">
59
+ {!notFound && <button
60
+ onClick={() => discovery.mutate()}
61
+ disabled={discovery.isPending}
62
+ className="inline-flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-lg btn-brand"
63
+ >
64
+ {discovery.isPending ? (
65
+ <Loader2 className="w-4 h-4 animate-spin" />
66
+ ) : (
67
+ <Wifi className="w-4 h-4" />
68
+ )}
69
+ {openObservePath ? "Discover metrics" : "Discover Prometheus"}
70
+ </button>}
71
+ {settingsAvailable && <button
72
+ type="button"
73
+ className="text-sm text-accent hover:underline"
74
+ onClick={openMetricsSettings}
75
+ >Configure metrics</button>}
76
+ </div>
77
+ {previousNote && <p className="mt-3 text-xs text-theme-text-secondary">{previousNote}</p>}
78
+ {!settingsAvailable && <p className="mt-3 text-xs text-theme-text-tertiary">Ask your operator to configure the metrics connection for this cluster.</p>}
79
+ {isWorkload && <a className="mt-3 inline-block text-xs text-accent hover:underline" href="https://github.com/skyhook-io/radar/blob/main/docs/workload-metrics.md#what-each-chart-needs" target="_blank" rel="noopener noreferrer">What each chart needs</a>}
80
+ </div>
81
+ </div>
82
+ );
83
+ }
84
+
85
+ export function OpenObserveUnavailable({
86
+ status,
87
+ compact = false,
88
+ }: {
89
+ status: PrometheusStatus;
90
+ compact?: boolean;
91
+ }) {
92
+ const viaHub = status.source?.via === "hub";
93
+ const error = unavailableReason(status.source?.error);
94
+ const settingsAvailable = !useNavCustomization().embedded;
95
+ return (
96
+ <div className={clsx("flex flex-col items-center justify-center gap-4", compact ? "py-4" : "py-12")}>
97
+ <WifiOff className="w-10 h-10 text-theme-text-quaternary" />
98
+ <div className="text-center">
99
+ <p className="text-sm text-theme-text-secondary mb-1">OpenObserve unavailable</p>
100
+ {error && <p className="text-xs text-theme-text-tertiary mb-1">{error}</p>}
101
+ <p className="text-xs text-theme-text-tertiary">
102
+ {viaHub
103
+ ? "This cluster's metrics come from OpenObserve through Radar Hub. Charts come back when it answers again."
104
+ : "This cluster's metrics come from the saved OpenObserve connection. Charts come back when it answers again."}
105
+ </p>
106
+ {!viaHub && settingsAvailable && <button
107
+ type="button"
108
+ className="mt-3 text-sm text-accent hover:underline"
109
+ onClick={openMetricsSettings}
110
+ >Configure metrics</button>}
111
+ </div>
112
+ </div>
113
+ );
114
+ }
@@ -1,3 +1,4 @@
1
+ import { hasPrometheusCharts } from '../../api/prometheusCharts'
1
2
  import { formatMemoryBytes } from '@skyhook-io/k8s-ui/utils/format'
2
3
  import { isForbiddenError, useAutoPromConnect, useCloudRole, usePrometheusPVCUsage, usePrometheusStatus } from '../../api/client'
3
4
  import { useNavCustomization } from '../../context/NavCustomization'
@@ -11,7 +12,7 @@ export function PVCUsageBar({ namespace, name }: { namespace: string; name: stri
11
12
  const settingsAvailable = !useNavCustomization().embedded
12
13
  const canConfigure = settingsAvailable && !roleLoading && canAtLeast('owner')
13
14
  const { data: status, error: statusError } = usePrometheusStatus()
14
- const isConnected = status?.connected === true
15
+ const isConnected = hasPrometheusCharts(status)
15
16
  const { data: usage, error } = usePrometheusPVCUsage(namespace, name, isConnected)
16
17
 
17
18
  let unavailable: string | undefined