@skyhook-io/radar-app 1.18.0 → 1.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/README.md +6 -0
  2. package/package.json +2 -3
  3. package/src/App.tsx +22 -6
  4. package/src/api/client.gitops-destination.test.tsx +55 -0
  5. package/src/api/client.resource-list.test.ts +76 -0
  6. package/src/api/client.ts +61 -20
  7. package/src/api/quotas.ts +9 -20
  8. package/src/api/radarFeatures.ts +2 -0
  9. package/src/api/resourceLists.test.ts +84 -0
  10. package/src/api/resourceLists.ts +71 -0
  11. package/src/components/cnpg/CNPGView.tsx +1 -0
  12. package/src/components/compare/CompareResourcePicker.test.tsx +58 -0
  13. package/src/components/compare/CompareViewRoute.tsx +5 -1
  14. package/src/components/compare/useCompareCandidates.ts +1 -1
  15. package/src/components/compare/useCompareLauncher.tsx +4 -2
  16. package/src/components/diagnose/StoryExcerpt.tsx +24 -5
  17. package/src/components/diagnose/investigationEvidence/adapters/listCoverage.test.ts +415 -0
  18. package/src/components/diagnose/investigationEvidence/adapters/resource.ts +107 -8
  19. package/src/components/diagnose/investigationEvidence/bodies/inventory.tsx +66 -16
  20. package/src/components/diagnose/investigationEvidence/builder.ts +13 -1
  21. package/src/components/diagnose/investigationEvidence/excerpt.ts +2 -0
  22. package/src/components/diagnose/investigationEvidence/observations.ts +1 -0
  23. package/src/components/diagnose/investigationEvidence/projection.test.ts +24 -1
  24. package/src/components/diagnose/investigationEvidence/types.ts +15 -0
  25. package/src/components/diagnose/toolCallLabel.test.ts +9 -0
  26. package/src/components/diagnose/toolCallLabel.ts +2 -0
  27. package/src/components/execution/BatchExecutionView.image-browse.test.tsx +46 -0
  28. package/src/components/execution/BatchExecutionView.tsx +6 -4
  29. package/src/components/gitops/GitOpsView.identity.test.tsx +113 -0
  30. package/src/components/gitops/GitOpsView.tsx +62 -40
  31. package/src/components/gitops/useDestinationCluster.ts +2 -1
  32. package/src/components/helm/ArtifactHubSourceSearch.test.tsx +124 -0
  33. package/src/components/helm/ArtifactHubSourceSearch.tsx +240 -0
  34. package/src/components/helm/ChartBrowser.tsx +5 -4
  35. package/src/components/helm/TrackChartSourceDialog.render.test.tsx +269 -96
  36. package/src/components/helm/TrackChartSourceDialog.tsx +607 -104
  37. package/src/components/home/mcpToolCatalog.ts +10 -0
  38. package/src/components/resource/PrometheusCharts.overlays.test.ts +45 -0
  39. package/src/components/resource/PrometheusCharts.tsx +2 -2
  40. package/src/components/resources/ResourcesView.tsx +29 -67
  41. package/src/components/resources/renderers/PodRenderer.tsx +4 -1
  42. package/src/components/settings/MyPermissionsDialog.tsx +12 -9
  43. package/src/components/traffic/TrafficSourcePill.test.tsx +110 -0
  44. package/src/components/traffic/TrafficSourcePill.tsx +111 -0
  45. package/src/components/traffic/TrafficView.tsx +9 -55
  46. package/src/components/ui/DiagnosticsOverlay.test.ts +25 -0
  47. package/src/components/ui/DiagnosticsOverlay.tsx +2 -1
  48. package/src/components/ui/Omnibar.note.test.tsx +141 -0
  49. package/src/components/ui/Omnibar.tsx +82 -18
  50. package/src/components/ui/RadarOmnibar.test.tsx +183 -0
  51. package/src/components/ui/RadarOmnibar.tsx +38 -4
  52. package/src/components/ui/UpdateNotification.manual.test.tsx +177 -0
  53. package/src/components/ui/UpdateNotification.test.tsx +2 -1
  54. package/src/components/ui/UpdateNotification.tsx +29 -5
  55. package/src/components/ui/omnibar-match.test.ts +15 -8
  56. package/src/components/ui/omnibar-match.ts +11 -6
  57. package/src/components/ui/searchCoverage.fixtures.ts +16 -0
  58. package/src/components/ui/searchCoverageNote.test.ts +245 -0
  59. package/src/components/ui/searchCoverageNote.ts +222 -0
  60. package/src/components/whats-new/WhatsNew.test.ts +10 -0
  61. package/src/components/whats-new/WhatsNew.tsx +5 -4
  62. package/src/components/whats-new/WhatsNewDialog.test.tsx +20 -0
  63. package/src/components/whats-new/releaseNotes.ts +57 -5
  64. package/src/components/workload/WorkloadView.tsx +8 -2
  65. package/src/hooks/useResourceCounts.ts +2 -0
  66. package/src/index.css +2 -4
  67. package/src/index.ts +7 -0
  68. package/src/utils/artifacthub.test.ts +18 -0
  69. package/src/utils/artifacthub.ts +9 -0
package/README.md CHANGED
@@ -66,3 +66,9 @@ Host apps can override Radar's runtime behavior without passing props:
66
66
  - `setCredentialsMode(mode)` — fetch credentials mode (`same-origin` | `include` | `omit`).
67
67
 
68
68
  Call these before mounting `<RadarApp>`.
69
+
70
+ ## Resource list responses
71
+
72
+ New Radar instances advertise `features.resourceReadCoverage` and return `{items, coverage, kind, group}` for resource lists, with `columns`/`cells` when table mode is requested. `coverage` describes the scope the answer covers, what Radar read of it, and coded gaps; namespace sets are `{count, names?}`, listing every member or none, and a gap's set may instead be `{"extent": "all"}` or `{"extent": "unknown"}`. A failed read answers `{error, error_code, coverage?}`. Lists fail when there is no usable inventory: nothing readable, an oversized result, or a changed connection. Partial lists with loading gaps refetch with 5s, 10s, 20s, then 30s delays; complete coverage or a changed query resets the backoff.
73
+
74
+ Hosts making their own requests can call `normalizeResourceList(body)` from this package. It reads the body by its shape, so it needs no capabilities: a bare array or a table envelope without `coverage` (an older instance) produces `coverage.status: 'unknown'`, which cannot establish absence. The adapter returns `{items, coverage, printerTable}`. `fetchResourceList(kind, options)` uses Radar's configured API base/authentication and applies a server list budget, which older instances ignore.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyhook-io/radar-app",
3
- "version": "1.18.0",
3
+ "version": "1.18.1",
4
4
  "description": "Radar's full web UI as a reusable React component. Used by Radar's own binary and by external consumers like Radar Cloud.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -42,7 +42,7 @@
42
42
  "yaml": "^2.9.1"
43
43
  },
44
44
  "peerDependencies": {
45
- "@skyhook-io/k8s-ui": ">=1.17.1",
45
+ "@skyhook-io/k8s-ui": ">=1.18.1",
46
46
  "@tanstack/react-query": ">=5",
47
47
  "@xyflow/react": ">=12.0.0",
48
48
  "clsx": ">=2",
@@ -57,7 +57,6 @@
57
57
  "@eslint/js": "^10.0.1",
58
58
  "@playwright/test": "^1.62.0",
59
59
  "@skyhook-io/k8s-ui": "*",
60
- "@tailwindcss/typography": "^0.5.20",
61
60
  "@tailwindcss/vite": "^4.3.3",
62
61
  "@tanstack/react-query": "^5.103.1",
63
62
  "@types/node": "^26.6.2",
package/src/App.tsx CHANGED
@@ -9,7 +9,7 @@ import { DebugOverlay } from './components/DebugOverlay'
9
9
  import { GlobalDiagnoseButton } from './components/diagnose/LocalDiagnoseAction'
10
10
  import { investigationWorkspaceSearch, isInvestigationWorkspacePath, useDiagnoseLayout } from './components/diagnose/DiagnoseContext'
11
11
  import { DiagnoseSurface } from './components/diagnose/DiagnoseSurface'
12
- import { TopologyGraph, TopologySearch, TopologyBreadcrumb, TopologyFilterSidebar, TopologyControls, FreshnessControl, gitOpsRouteForKind, gitOpsRouteForResource, ScopePill, PaneLoader } from '@skyhook-io/k8s-ui'
12
+ import { TopologyGraph, TopologySearch, TopologyBreadcrumb, TopologyFilterSidebar, TopologyControls, FreshnessControl, gitOpsRouteForKind, gitOpsRouteForResource, ScopePill, PaneLoader, usePhoneLayout } from '@skyhook-io/k8s-ui'
13
13
  import { resetNavigationMap } from '@skyhook-io/k8s-ui/utils/navigation'
14
14
  import { topologyNodeResourceKind } from '@skyhook-io/k8s-ui/utils/topology-neighborhood'
15
15
  import { useAPIResources, findAPIResourceForRoute } from './api/apiResources'
@@ -132,6 +132,11 @@ const FLEET_MODE_KINDS = new Set<NodeKind>([
132
132
  // Extended MainView type that includes traffic and cost
133
133
  type ExtendedMainView = MainView | 'traffic' | 'cost' | 'capacity' | 'cnpg' | 'workload' | 'checks' | 'gitops' | 'compare' | 'helmCompare' | 'issues' | 'applications' | 'investigations'
134
134
 
135
+ // Views that have been laid out for phone width (640px and below). The rest
136
+ // keep their desktop width on a phone and scroll sideways; add a view here in
137
+ // the PR that gives it a phone layout.
138
+ const PHONE_READY_VIEWS: ReadonlySet<ExtendedMainView> = new Set<ExtendedMainView>(['issues'])
139
+
135
140
  // Extract view from URL path
136
141
  function getViewFromPath(pathname: string): ExtendedMainView {
137
142
  if (pathname.replace(/\/+$/, '') === '/helm/compare') return 'helmCompare'
@@ -660,8 +665,11 @@ function AppInner({ manageDocumentTitle = false, documentTitleSuffix, onClusterL
660
665
  // actually renders) — see further down.
661
666
  const drawerExpanded = !!selectedResource && searchParams.get('full') === '1'
662
667
 
663
- // On mobile there's no room for the side drawer — a resource detail is always full-screen.
664
- const isMobile = useMediaQuery('(max-width: 639px)')
668
+ // On a phone there's no room for the side drawer: a resource detail is always full-screen.
669
+ const isMobile = usePhoneLayout()
670
+ // Views with a deliberate phone layout. On a phone every other view keeps
671
+ // its desktop width and scrolls sideways rather than squeezing.
672
+ const phoneScroll = isMobile && !PHONE_READY_VIEWS.has(mainView)
665
673
 
666
674
  // On a history Pop (back/forward) the URL is authoritative. The URL-write
667
675
  // effect, running with not-yet-synced state, would otherwise write the stale
@@ -1800,10 +1808,14 @@ function AppInner({ manageDocumentTitle = false, documentTitleSuffix, onClusterL
1800
1808
  {/* Preserve the ~800px content floor: the rail is a fixed-width sibling, so
1801
1809
  the outer minimum must include it (176px pinned / 56px collapsed) or the
1802
1810
  content column (min-w-0, shrinkable) would fall below the old desktop
1803
- floor at small windows. Embedded mode has no rail → plain 800. */}
1811
+ floor at small windows. Embedded mode has no rail → plain 800.
1812
+ Phones get a 360px floor instead (the narrowest current phones): the
1813
+ content column clips horizontally, so the 800px floor hid the right half
1814
+ of every view with no way to scroll to it. Views without a phone layout
1815
+ scroll sideways at desktop width instead (see PHONE_READY_VIEWS). */}
1804
1816
  <div
1805
1817
  className={`relative flex bg-theme-base ${navCustomization.embedded ? 'h-full min-h-0' : 'h-screen'}`}
1806
- style={{ minWidth: 800 + (showNavRail ? (navRailEffectivePinned ? 176 : 56) : 0) }}
1818
+ style={{ minWidth: (isMobile ? 360 : 800) + (showNavRail ? (navRailEffectivePinned ? 176 : 56) : 0) }}
1807
1819
  >
1808
1820
  {showNavRail && (
1809
1821
  <PrimaryNavRail
@@ -2061,7 +2073,10 @@ function AppInner({ manageDocumentTitle = false, documentTitleSuffix, onClusterL
2061
2073
  {/* inert while a fullscreen detail overlay covers the views — keeps the
2062
2074
  retained background list out of the focus order + a11y tree (the visual
2063
2075
  cover already blocks pointer events). */}
2064
- {(contentReady || shellDuringSync) && <div className="flex-1 flex overflow-hidden" inert={expandedView}>
2076
+ {(contentReady || shellDuringSync) && <div className={phoneScroll ? 'flex-1 flex overflow-x-auto overflow-y-hidden' : 'flex-1 flex overflow-hidden'} inert={expandedView}>
2077
+ {/* A view without a phone layout keeps its desktop width on a phone and
2078
+ scrolls sideways; `contents` leaves every other layout untouched. */}
2079
+ <div className={phoneScroll ? 'flex flex-1 min-h-0 min-w-[800px]' : 'contents'}>
2065
2080
  {/* Search included, not just the path: selection inside a view rides in
2066
2081
  the query (?resource=, ?release=), so a path-only key would still
2067
2082
  strand a crash on the view that produced it. */}
@@ -2412,6 +2427,7 @@ function AppInner({ manageDocumentTitle = false, documentTitleSuffix, onClusterL
2412
2427
  {!viewsSyncGated && mainView === 'compare' && <CompareViewRoute />}
2413
2428
 
2414
2429
  </ErrorBoundary>
2430
+ </div>
2415
2431
  </div>}
2416
2432
  </div>{/* /body frame */}
2417
2433
 
@@ -0,0 +1,55 @@
1
+ // @vitest-environment jsdom
2
+ import { act } from 'react'
3
+ import { createRoot, type Root } from 'react-dom/client'
4
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
5
+ import { afterEach, beforeEach, expect, it, vi } from 'vitest'
6
+ import { useGitOpsDestination } from './client'
7
+
8
+ Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
9
+ let root: Root
10
+ let host: HTMLDivElement
11
+ let client: QueryClient
12
+ const requests: string[] = []
13
+
14
+ function Destination({ group }: { group?: string }) {
15
+ useGitOpsDestination('applications', 'shop', 'wordpress', true, group)
16
+ return null
17
+ }
18
+
19
+ beforeEach(() => {
20
+ requests.length = 0
21
+ vi.stubGlobal('fetch', async (input: string | URL | Request) => {
22
+ requests.push(String(input))
23
+ return new Response(JSON.stringify({ server: 'https://destination.example.com', contexts: [] }), { status: 200 })
24
+ })
25
+ client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
26
+ host = document.createElement('div')
27
+ root = createRoot(host)
28
+ })
29
+
30
+ afterEach(async () => {
31
+ await act(async () => root.unmount())
32
+ client.clear()
33
+ vi.unstubAllGlobals()
34
+ })
35
+
36
+ async function render(group?: string) {
37
+ await act(async () => root.render(<QueryClientProvider client={client}><Destination group={group} /></QueryClientProvider>))
38
+ }
39
+
40
+ it('binds destination requests and cached results to the API group', async () => {
41
+ await render('argoproj.io')
42
+ await vi.waitFor(() => expect(requests).toHaveLength(1))
43
+ await render('app.k8s.io')
44
+ await vi.waitFor(() => expect(requests).toHaveLength(2))
45
+ expect(requests[0]).toBe('/api/gitops/destination/applications/shop/wordpress?group=argoproj.io')
46
+ expect(requests[1]).toBe('/api/gitops/destination/applications/shop/wordpress?group=app.k8s.io')
47
+ const entries = client.getQueryCache().findAll({ queryKey: ['gitops-destination'] })
48
+ expect(entries.map((entry) => entry.queryKey.at(-1))).toEqual(['argoproj.io', 'app.k8s.io'])
49
+ })
50
+
51
+ it('preserves the unqualified request used by existing callers', async () => {
52
+ await render()
53
+ await vi.waitFor(() => expect(requests).toHaveLength(1))
54
+ expect(requests[0]).toBe('/api/gitops/destination/applications/shop/wordpress')
55
+ })
@@ -0,0 +1,76 @@
1
+ import { afterEach, describe, expect, it, vi } from 'vitest'
2
+ import { ApiError, fetchResourceList, isListTooLargeError, isUnretryableReadError } from './client'
3
+ import { setApiBase, setAuthHeadersProvider, setCredentialsMode } from './config'
4
+
5
+ afterEach(() => {
6
+ vi.unstubAllGlobals()
7
+ setApiBase('/api')
8
+ setAuthHeadersProvider(() => ({}))
9
+ setCredentialsMode('same-origin')
10
+ })
11
+
12
+ const coverage = { status: 'complete', scope: { type: 'all_namespaces' }, read: { type: 'all_namespaces' }, gaps: [] }
13
+ const envelope = { items: [], kind: 'pods', coverage, columns: null, cells: null }
14
+
15
+ describe('resource list transport', () => {
16
+ it('uses the configured cluster route and auth with a bounded list', async () => {
17
+ setApiBase('/c/cluster/api')
18
+ setAuthHeadersProvider(() => ({ Authorization: 'Bearer test' }))
19
+ setCredentialsMode('include')
20
+ const mock = vi.fn(async (url: RequestInfo | URL, init?: RequestInit) => {
21
+ expect(url).toBe('/c/cluster/api/resources/pods?namespaces=alpha&maxItems=25000')
22
+ expect(init?.credentials).toBe('include')
23
+ expect(new Headers(init?.headers).get('Authorization')).toBe('Bearer test')
24
+ return new Response(JSON.stringify(envelope), { status: 200 })
25
+ })
26
+ vi.stubGlobal('fetch', mock)
27
+ expect((await fetchResourceList('pods', { namespaces: ['alpha'] })).coverage).toEqual(coverage)
28
+ expect(mock).toHaveBeenCalledTimes(1)
29
+ })
30
+ it('uses the summary budget only for summary requests', async () => {
31
+ vi.stubGlobal('fetch', vi.fn(async (url: RequestInfo | URL) => {
32
+ expect(url).toBe('/api/resources/pods?include=summary&maxItems=50000')
33
+ return new Response(JSON.stringify(envelope), { status: 200 })
34
+ }))
35
+ await fetchResourceList('pods', { summary: true })
36
+ })
37
+ it('reads an older Radar array, sent the same budget it ignores, without inventing complete coverage', async () => {
38
+ const mock = vi.fn(async (url: RequestInfo | URL) => {
39
+ expect(url).toBe('/api/resources/pods?maxItems=25000')
40
+ return new Response('[{"metadata":{"name":"api"}}]', { status: 200 })
41
+ })
42
+ vi.stubGlobal('fetch', mock)
43
+ const result = await fetchResourceList('pods')
44
+ expect(result.items).toEqual([{ metadata: { name: 'api' } }])
45
+ expect(result.coverage).toEqual({ status: 'unknown' })
46
+ expect(mock).toHaveBeenCalledTimes(1)
47
+ })
48
+ it('preserves oversized-list errors instead of returning empty rows', async () => {
49
+ vi.stubGlobal('fetch', vi.fn(async () => new Response(JSON.stringify({ error: 'Too many resources to load; select fewer namespaces', error_code: 'list_too_large', count: 30000, limit: 25000 }), { status: 400, headers: { 'Content-Type': 'application/json' } })))
50
+ const error = await fetchResourceList('pods').catch((e: unknown) => e)
51
+ expect(error).toMatchObject({ status: 400, data: { error_code: 'list_too_large', count: 30000 } })
52
+ expect(isListTooLargeError(error)).toBe(true)
53
+ expect(isListTooLargeError(new ApiError('failed', 400, { error: 'failed', error_code: 'kind_unknown' }))).toBe(false)
54
+ })
55
+ })
56
+
57
+ describe('read errors that a retry cannot answer', () => {
58
+ const failure = (status: number, error_code?: string) => new ApiError('failed', status, error_code ? { error: 'failed', error_code } : { error: 'failed' })
59
+
60
+ it('stops on a request, access or collection problem', () => {
61
+ expect(isUnretryableReadError(failure(400, 'list_too_large'))).toBe(true)
62
+ expect(isUnretryableReadError(failure(400, 'kind_unknown'))).toBe(true)
63
+ expect(isUnretryableReadError(failure(409, 'radar_namespace_not_collected'))).toBe(true)
64
+ expect(isUnretryableReadError(failure(403, 'user_forbidden'))).toBe(true)
65
+ expect(isUnretryableReadError(failure(503, 'kind_sync_timed_out'))).toBe(true)
66
+ // The spellings Radar releases before the shared vocabulary sent.
67
+ expect(isUnretryableReadError(failure(403, 'rbac_denied'))).toBe(true)
68
+ expect(isUnretryableReadError(failure(503, 'kind_sync_failed'))).toBe(true)
69
+ })
70
+ it('retries what may answer on its own', () => {
71
+ expect(isUnretryableReadError(failure(503, 'kind_sync_pending'))).toBe(false)
72
+ expect(isUnretryableReadError(failure(500, 'read_error'))).toBe(false)
73
+ expect(isUnretryableReadError(failure(503))).toBe(false)
74
+ expect(isUnretryableReadError(new Error('network'))).toBe(false)
75
+ })
76
+ })
package/src/api/client.ts CHANGED
@@ -1,8 +1,11 @@
1
+ import { createListRefetchInterval, normalizeResourceList, type ResourceListBody, type ResourceListResult } from './resourceLists'
1
2
  import { canonicalResourceGroup } from '@skyhook-io/k8s-ui/utils/api-resources'
2
3
  import { pluralize } from '@skyhook-io/k8s-ui/utils/pluralize'
3
4
  import { knownKindForPluralWithGroup, pluralToKind } from '@skyhook-io/k8s-ui/utils/navigation'
4
5
  import { useEffect, useRef, useCallback, useMemo } from 'react'
5
6
  import type { KueueAdmissionResponse } from '@skyhook-io/k8s-ui/types/scheduling'
7
+ import { canonicalReadCode, readActionFor } from '@skyhook-io/k8s-ui/utils/read-actions'
8
+ import type { SearchCoverage } from '@skyhook-io/k8s-ui/types/read-coverage'
6
9
  import type { GitOpsWriteEvidence } from '@skyhook-io/k8s-ui/utils/gitops-write-guard'
7
10
  import type {
8
11
  AppHistory,
@@ -291,13 +294,14 @@ export function isStillLoadingError(error: unknown): boolean {
291
294
  return isKindSyncPending(error) || isClusterConnecting(error);
292
295
  }
293
296
 
294
- // isKindSyncFailed matches the terminal variant: the kind never synced within
295
- // the deadline for this connection. Retrying won't help — show the error.
297
+ // isKindSyncFailed matches a kind that missed its sync deadline. Radar keeps
298
+ // loading it, so a later reload may succeed, but retrying at once won't —
299
+ // show the error. Older Radars spelled the code kind_sync_failed.
296
300
  export function isKindSyncFailed(error: unknown): boolean {
297
301
  return (
298
302
  error instanceof ApiError &&
299
303
  error.status === 503 &&
300
- error.data?.error_code === "kind_sync_failed"
304
+ canonicalReadCode(error.data?.error_code) === "kind_sync_timed_out"
301
305
  );
302
306
  }
303
307
 
@@ -853,6 +857,7 @@ export function useResourceIssues(
853
857
  // the caller's RBAC withheld. Polls like the page list.
854
858
  export interface CronJobSchedulingEvidence {
855
859
  uid: string;
860
+ event_id?: string;
856
861
  state: 'reported' | 'configuration_changed' | 'history_incomplete';
857
862
  reason: string;
858
863
  message: string;
@@ -1785,6 +1790,7 @@ export async function markWhatsNewSeen(version: string): Promise<void> {
1785
1790
 
1786
1791
  export interface VersionInfo {
1787
1792
  currentVersion: string;
1793
+ buildChannel?: 'stable' | 'prerelease' | 'custom' | 'development';
1788
1794
  latestVersion?: string;
1789
1795
  updateAvailable: boolean;
1790
1796
  releaseUrl?: string;
@@ -2003,10 +2009,12 @@ export interface SearchResult {
2003
2009
  total: number;
2004
2010
  searched: number;
2005
2011
  total_matched: number;
2006
- /** "time_limit" when scan report findings were only partly searched. */
2012
+ /** From Radars that predate search coverage: "time_limit" when scan report findings were only partly searched. */
2007
2013
  incomplete_findings?: string;
2008
- /** Some namespaces' scan reports were left out, access not confirmed yet. */
2014
+ /** From Radars that predate search coverage: some namespaces' scan reports were left out, access not confirmed yet. */
2009
2015
  access_incomplete?: boolean;
2016
+ /** Absent from Radars that predate search coverage, which say nothing about it. */
2017
+ coverage?: SearchCoverage;
2010
2018
  }
2011
2019
 
2012
2020
  const SEARCH_MIN_QUERY = 2;
@@ -2024,15 +2032,16 @@ export function useSearch(
2024
2032
  context?: "summary" | "none";
2025
2033
  enabled?: boolean;
2026
2034
  globalNs?: boolean;
2035
+ /** Re-query on an interval decided from the latest response. */
2036
+ refetchInterval?: (data: SearchResult | undefined) => number | false;
2027
2037
  },
2028
2038
  ) {
2029
2039
  const trimmed = query.trim();
2030
2040
  const enabled = (opts?.enabled ?? true) && trimmed.length >= SEARCH_MIN_QUERY;
2031
2041
  const limit = opts?.limit ?? 20;
2032
2042
  const context = opts?.context ?? "summary";
2033
- // globalNs makes search ignore the per-user namespace-switcher pick and scan
2034
- // the user's full RBAC ceiling (scope then comes only from the query's `ns:`
2035
- // tokens). The omnibar opts in so ⌘K is a genuinely global lookup.
2043
+ // Searches always ignore the saved namespace pick. Keep globalNs as the
2044
+ // explicit global-search marker used by the omnibar and embedded hosts.
2036
2045
  const globalNs = opts?.globalNs ?? false;
2037
2046
  return useQuery<SearchResult>({
2038
2047
  queryKey: ["search", trimmed, limit, context, globalNs],
@@ -2043,6 +2052,7 @@ export function useSearch(
2043
2052
  ),
2044
2053
  enabled,
2045
2054
  staleTime: 2000,
2055
+ refetchInterval: (q) => opts?.refetchInterval?.(q.state.data) ?? false,
2046
2056
  placeholderData: (prev) => prev, // keepPreviousData
2047
2057
  });
2048
2058
  }
@@ -2897,6 +2907,38 @@ export function useResourceWithRelationships<T>(
2897
2907
  });
2898
2908
  }
2899
2909
 
2910
+ export interface ResourceListOptions {
2911
+ namespaces?: string[]
2912
+ group?: string
2913
+ table?: boolean
2914
+ summary?: boolean
2915
+ signal?: AbortSignal
2916
+ }
2917
+
2918
+ export async function fetchResourceList<T>(kind: string, options: ResourceListOptions = {}): Promise<ResourceListResult<T>> {
2919
+ const params = new URLSearchParams()
2920
+ if (options.namespaces?.length) params.set('namespaces', options.namespaces.join(','))
2921
+ if (options.group) params.set('group', options.group)
2922
+ if (options.table) params.set('table', '1')
2923
+ if (options.summary) params.set('include', 'summary')
2924
+ // A Radar that predates the list budget ignores the parameter.
2925
+ params.set('maxItems', options.summary ? '50000' : '25000')
2926
+ const body = await fetchJSON<ResourceListBody<T>>(`/resources/${encodeURIComponent(kind)}?${params}`, options.signal)
2927
+ return normalizeResourceList<T>(body)
2928
+ }
2929
+
2930
+ // A read failure no retry can answer: the request, the caller's access or
2931
+ // Radar's collection has to change first (too large, outside the collector, a
2932
+ // denial), so it is shown at once.
2933
+ export function isUnretryableReadError(error: unknown): boolean {
2934
+ return error instanceof ApiError && !['retry', undefined].includes(readActionFor(error.data?.error_code))
2935
+ }
2936
+
2937
+ // The list is over the request's size budget; the body carries `count` and `limit`.
2938
+ export function isListTooLargeError(error: unknown): error is ApiError {
2939
+ return error instanceof ApiError && error.data?.error_code === 'list_too_large'
2940
+ }
2941
+
2900
2942
  // List resources - queryKey includes group for cache sharing with ResourcesView
2901
2943
  export function useResources<T>(
2902
2944
  kind: string,
@@ -2904,29 +2946,26 @@ export function useResources<T>(
2904
2946
  group?: string,
2905
2947
  options?: { enabled?: boolean; refetchInterval?: number | false; cacheScope?: string },
2906
2948
  ) {
2907
- const params = new URLSearchParams();
2908
- if (namespace) params.set("namespace", namespace);
2909
- if (group) params.set("group", group);
2910
- const queryString = params.toString();
2911
-
2912
- return useQuery<T[]>({
2949
+ const loadingInterval = useMemo(() => createListRefetchInterval(options?.refetchInterval), [options?.refetchInterval])
2950
+ const query = useQuery<ResourceListResult<T>>({
2913
2951
  queryKey: ["resources", kind, group, namespace, ...(options?.cacheScope ? [options.cacheScope] : [])],
2914
- queryFn: () =>
2915
- fetchJSON(`/resources/${kind}${queryString ? `?${queryString}` : ""}`),
2952
+ queryFn: ({ signal }) => fetchResourceList<T>(kind, { namespaces: namespace ? [namespace] : [], group, signal }),
2916
2953
  enabled: (options?.enabled ?? true) && Boolean(kind),
2917
2954
  staleTime: 30000, // 30 seconds - matches refetchInterval in ResourcesView
2918
- refetchInterval: options?.refetchInterval,
2955
+ refetchInterval: loadingInterval,
2919
2956
  // Kind still completing its initial sync (progressive shell, or a
2920
2957
  // deferred kind shortly after connect): keep polling instead of
2921
2958
  // surfacing an error.
2922
2959
  retry: (failureCount, error) => {
2923
2960
  if (isStillLoadingError(error)) return true;
2924
2961
  if (isKindSyncFailed(error)) return false;
2962
+ if (isUnretryableReadError(error)) return false;
2925
2963
  return failureCount < 1; // one retry, 4xx included, unlike the QueryClient default
2926
2964
  },
2927
2965
  retryDelay: (failureCount, error) =>
2928
2966
  isStillLoadingError(error) ? 2000 : Math.min(1000 * 2 ** failureCount, 30000),
2929
2967
  });
2968
+ return { ...query, data: query.data?.items, coverage: query.data?.coverage };
2930
2969
  }
2931
2970
 
2932
2971
  // Timeline changes (unified view of changes + K8s events)
@@ -7091,10 +7130,11 @@ export function useContexts() {
7091
7130
 
7092
7131
  // Where a remote Argo Application or Flux object (spec.kubeConfig) deploys:
7093
7132
  // the destination's host for display, and the kubeconfig contexts that reach it.
7094
- export function useGitOpsDestination(kind: string, namespace: string, name: string, enabled: boolean) {
7133
+ export function useGitOpsDestination(kind: string, namespace: string, name: string, enabled: boolean, group?: string) {
7134
+ const queryString = group ? `?group=${encodeURIComponent(group)}` : "";
7095
7135
  return useQuery<{ server: string; contexts: string[] }>({
7096
- queryKey: ["gitops-destination", kind, namespace, name],
7097
- queryFn: () => fetchJSON(`/gitops/destination/${encodeURIComponent(kind)}/${encodeURIComponent(namespace)}/${encodeURIComponent(name)}`),
7136
+ queryKey: ["gitops-destination", kind, namespace, name, group ?? ""],
7137
+ queryFn: () => fetchJSON(`/gitops/destination/${encodeURIComponent(kind)}/${encodeURIComponent(namespace)}/${encodeURIComponent(name)}${queryString}`),
7098
7138
  enabled,
7099
7139
  staleTime: 60000,
7100
7140
  retry: false,
@@ -7873,6 +7913,7 @@ export interface DiagnosticsSnapshot {
7873
7913
  debugEvents: boolean;
7874
7914
  mcpEnabled: boolean;
7875
7915
  mcpReadOnly: boolean;
7916
+ pprof?: boolean;
7876
7917
  hasPrometheusURL: boolean;
7877
7918
  hasPrometheusHeaders: boolean;
7878
7919
  };
package/src/api/quotas.ts CHANGED
@@ -1,32 +1,21 @@
1
- import { useQuery } from '@tanstack/react-query'
2
- import { fetchJSON } from './client'
1
+ import { useResources } from './client'
3
2
 
4
3
  // useNamespaceQuotas fetches a namespace's ResourceQuota objects via
5
- // /api/resources/resourcequotas?namespace=<ns> (a bare array). Backs the
4
+ // /api/resources/resourcequotas?namespaces=<ns> (the `{items, coverage}`
5
+ // list envelope; useResources returns the items). Backs the
6
6
  // NamespaceRenderer quota-usage section — quota saturation is otherwise
7
7
  // surfaced nowhere in the UI, yet it's exactly why a namespace stops
8
8
  // admitting new pods.
9
9
  export function useNamespaceQuotas(namespace: string, enabled = true) {
10
- return useQuery<any[]>({
11
- queryKey: ['resourcequotas', namespace],
12
- queryFn: () => fetchJSON<any[]>(`/resources/resourcequotas?namespace=${encodeURIComponent(namespace)}`),
13
- enabled: enabled && !!namespace,
14
- staleTime: 15000,
15
- })
10
+ return useResources<any>('resourcequotas', namespace, undefined, { enabled: enabled && !!namespace })
16
11
  }
17
12
 
18
- // useNamespaceLimitRanges fetches a namespace's LimitRange objects via
19
- // /api/resources/limitranges?namespace=<ns> (a bare array). Backs the
20
- // NamespaceRenderer rules section and the contextual link on Pod/workload
21
- // details — the defaults and constraints applied at admission are otherwise
22
- // only visible by reading the object.
13
+ // useNamespaceLimitRanges fetches a namespace's LimitRange objects the same
14
+ // way. Backs the NamespaceRenderer rules section and the contextual link on
15
+ // Pod/workload details — the defaults and constraints applied at admission
16
+ // are otherwise only visible by reading the object.
23
17
  export function useNamespaceLimitRanges(namespace: string, enabled = true) {
24
- return useQuery<any[]>({
25
- queryKey: ['limitranges', namespace],
26
- queryFn: () => fetchJSON<any[]>(`/resources/limitranges?namespace=${encodeURIComponent(namespace)}`),
27
- enabled: enabled && !!namespace,
28
- staleTime: 15000,
29
- })
18
+ return useResources<any>('limitranges', namespace, undefined, { enabled: enabled && !!namespace })
30
19
  }
31
20
 
32
21
  export function podLimitRangeNames(limitRanges: any[] | undefined): string[] {
@@ -27,6 +27,8 @@ export interface RadarFeatureSpec {
27
27
  }
28
28
 
29
29
  export const RADAR_FEATURES = {
30
+ resourceReadCoverage: { label: 'Resource read coverage', flag: 'resourceReadCoverage', flagShippedWithEndpoint: true },
31
+ searchCoverage: { label: 'Search coverage and object filters', flag: 'searchCoverage', flagShippedWithEndpoint: true },
30
32
  resourceIssues: { label: 'Operational issues', minimumVersion: 'v1.8.0', flag: 'resourceIssues' },
31
33
  resourceIssueCoverage: { label: 'Resource-specific issue views', flag: 'resourceIssueCoverage', flagShippedWithEndpoint: true },
32
34
  podEnvironment: { label: 'Values from ConfigMaps and Secrets', minimumVersion: 'v1.9.0', flag: 'podEnvironment' },
@@ -0,0 +1,84 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import type { ResourceReadCoverage } from '@skyhook-io/k8s-ui/types/resource-coverage'
3
+ import { combinedListStatus, createListRefetchInterval, listSyncPending, normalizeResourceList } from './resourceLists'
4
+
5
+ const complete: ResourceReadCoverage = { status: 'complete', gaps: [], scope: { type: 'cluster' }, read: { type: 'cluster' } }
6
+ const partial: ResourceReadCoverage = { ...complete, status: 'partial', gaps: [{ code: 'radar_namespace_not_collected' }] }
7
+ const columns = [{ name: 'State', type: 'string' }]
8
+
9
+ describe('resource-list responses, read by shape', () => {
10
+ it('reads an older Radar array as rows of unknown coverage', () => {
11
+ const rows = [{ metadata: { name: 'api' } }]
12
+ expect(normalizeResourceList(rows)).toEqual({ items: rows, coverage: { status: 'unknown' }, printerTable: null })
13
+ expect(normalizeResourceList([]).coverage).toEqual({ status: 'unknown' })
14
+ })
15
+ it('reads an older Radar table envelope as a printer table of unknown coverage', () => {
16
+ const body = { items: [{ metadata: { uid: 'one' } }], kind: 'widgets', group: 'example.io', columns, cells: { one: ['Ready'] } }
17
+ const result = normalizeResourceList(body)
18
+ expect(result.items).toEqual(body.items)
19
+ expect(result.coverage).toEqual({ status: 'unknown' })
20
+ expect(result.printerTable?.cells).toEqual(body.cells)
21
+ })
22
+ it('reads the coverage envelope without a table, retaining partial metadata with zero rows', () => {
23
+ expect(normalizeResourceList({ items: [], coverage: partial, kind: 'pods', columns: null, cells: null })).toEqual({ items: [], coverage: partial, printerTable: null })
24
+ })
25
+ it('reads the coverage envelope with a table, keeping rows and cells from the same response', () => {
26
+ const body = { items: [{ metadata: { uid: 'one' } }], kind: 'widgets', group: 'example.io', columns, cells: { one: ['Ready'] }, coverage: complete }
27
+ const result = normalizeResourceList(body)
28
+ expect(result.items).toEqual(body.items)
29
+ expect(result.coverage).toEqual(complete)
30
+ expect(result.printerTable?.cells).toEqual(body.cells)
31
+ })
32
+ })
33
+
34
+ describe('listSyncPending', () => {
35
+ it('holds only while a partial answer has namespaces still loading', () => {
36
+ expect(listSyncPending({ ...partial, gaps: [{ code: 'radar_forbidden' }, { code: 'kind_sync_pending' }] })).toBe(true)
37
+ expect(listSyncPending(partial)).toBe(false)
38
+ expect(listSyncPending(complete)).toBe(false)
39
+ expect(listSyncPending({ status: 'unknown' })).toBe(false)
40
+ expect(listSyncPending(undefined)).toBe(false)
41
+ })
42
+ })
43
+
44
+ describe('combinedListStatus', () => {
45
+ it('is partial when any read failed or was partial', () => {
46
+ expect(combinedListStatus([complete], true, false)).toBe('partial')
47
+ expect(combinedListStatus([complete, partial], false, false)).toBe('partial')
48
+ })
49
+ it("is partial when Radar's collection narrowed a read, since the view shows cluster totals", () => {
50
+ const narrowed = { ...complete, narrowedBy: ['namespace_collection'] }
51
+ expect(combinedListStatus([complete, narrowed], false, false)).toBe('partial')
52
+ expect(combinedListStatus([{ ...complete, narrowedBy: ['user_access'] }], false, false)).toBe('complete')
53
+ })
54
+ it('is complete only when every read was', () => {
55
+ expect(combinedListStatus([complete, complete], false, false)).toBe('complete')
56
+ expect(combinedListStatus([complete, { status: 'unknown' }], false, false)).toBe('unknown')
57
+ })
58
+ it('treats discovery finding nothing to read as complete, and no reads otherwise as unknown', () => {
59
+ expect(combinedListStatus([], false, true)).toBe('complete')
60
+ expect(combinedListStatus([], false, false)).toBe('unknown')
61
+ })
62
+ })
63
+
64
+ describe('loading list backoff', () => {
65
+ it('backs off per response, caps, and resets for coverage or query changes', () => {
66
+ const interval = createListRefetchInterval(120000)
67
+ const pending = { ...partial, gaps: [{ code: 'kind_sync_pending' }] }
68
+ const query = { state: { data: { coverage: pending }, dataUpdateCount: 1 } }
69
+ for (const delay of [5000, 10000, 20000, 30000, 30000]) {
70
+ expect(interval(query)).toBe(delay)
71
+ expect(interval(query)).toBe(delay)
72
+ query.state.dataUpdateCount++
73
+ }
74
+ query.state.data.coverage = complete
75
+ expect(interval(query)).toBe(120000)
76
+ query.state.data.coverage = pending
77
+ expect(interval(query)).toBe(5000)
78
+ query.state.dataUpdateCount++
79
+ expect(interval(query)).toBe(10000)
80
+ const other = { state: { ...query.state } }
81
+ expect(interval(other)).toBe(5000)
82
+ expect(interval(query)).toBe(5000)
83
+ })
84
+ })
@@ -0,0 +1,71 @@
1
+ import { sanitizePrinterTable, type PrinterTable } from '@skyhook-io/k8s-ui/components/resources/printer-columns'
2
+ import type { ResourceCoverage, ResourceListResponse } from '@skyhook-io/k8s-ui/types/resource-coverage'
3
+ import { isLowerBound } from '@skyhook-io/k8s-ui/utils/resource-coverage'
4
+
5
+ export interface ResourceListResult<T> {
6
+ items: T[]
7
+ coverage: ResourceCoverage
8
+ printerTable: PrinterTable | null
9
+ }
10
+
11
+ /**
12
+ * Every list body a supported Radar sends: the coverage envelope, or from a
13
+ * Radar that predates coverage a bare array, or for `?table=1` the printer
14
+ * envelope without `coverage`.
15
+ */
16
+ export type ResourceListBody<T> =
17
+ | ResourceListResponse<T>
18
+ | (Omit<ResourceListResponse<T>, 'coverage'> & { coverage?: undefined })
19
+ | T[]
20
+
21
+ /**
22
+ * Reads a list body by its shape rather than by the cluster's advertised
23
+ * features: a host can point one query client at several clusters, so a cached
24
+ * capabilities answer may describe a different Radar than the one that
25
+ * answered. A response without coverage can't establish absence, so it reads
26
+ * as `unknown`.
27
+ */
28
+ export function normalizeResourceList<T>(body: ResourceListBody<T>): ResourceListResult<T> {
29
+ if (Array.isArray(body)) return { items: body, coverage: { status: 'unknown' }, printerTable: null }
30
+ return { items: body.items, coverage: body.coverage ?? { status: 'unknown' }, printerTable: sanitizePrinterTable(body) }
31
+ }
32
+
33
+ /** Back off once per loading response, resetting for a new query or settled coverage. */
34
+ export function createListRefetchInterval(normalInterval?: number | false) {
35
+ type ListQuery = { state: { data?: { coverage: ResourceCoverage }; dataUpdateCount: number } }
36
+ let previousQuery: ListQuery | undefined
37
+ let previousUpdate = -1
38
+ let delay = 0
39
+ return (query: ListQuery): number | false | undefined => {
40
+ if (query !== previousQuery || !listSyncPending(query.state.data?.coverage)) {
41
+ delay = 0
42
+ previousUpdate = -1
43
+ previousQuery = query
44
+ }
45
+ if (!listSyncPending(query.state.data?.coverage)) return normalInterval
46
+ if (query.state.dataUpdateCount !== previousUpdate) {
47
+ delay = delay === 0 ? 5000 : Math.min(delay * 2, 30000)
48
+ previousUpdate = query.state.dataUpdateCount
49
+ }
50
+ return delay
51
+ }
52
+ }
53
+
54
+ export function listSyncPending(coverage: ResourceCoverage | undefined): boolean {
55
+ return coverage?.status === 'partial' && coverage.gaps.some(gap => gap.code === 'kind_sync_pending')
56
+ }
57
+
58
+ /**
59
+ * One status for a view assembled from several list reads. A failed read makes
60
+ * it partial, and so does one Radar's collection narrowed: the view shows
61
+ * totals for the cluster, which a read of only the collected namespaces can't
62
+ * establish. `nothingToRead` says discovery found no kind to read, which is
63
+ * itself a complete answer.
64
+ */
65
+ export function combinedListStatus(coverage: ResourceCoverage[], failed: boolean, nothingToRead: boolean): 'complete' | 'partial' | 'unknown' {
66
+ if (failed || coverage.some(isLowerBound)) return 'partial'
67
+ if (coverage.length === 0 ? nothingToRead : coverage.every(c => c.status === 'complete')) return 'complete'
68
+ return 'unknown'
69
+ }
70
+
71
+ export { isLowerBound as lowerBound } from '@skyhook-io/k8s-ui/utils/resource-coverage'
@@ -112,6 +112,7 @@ export function CNPGView({ namespaces, selectedResource, onOpenResource, onClose
112
112
  onSelectedKindChange={selectKind}
113
113
  apiResources={apiResources}
114
114
  resourceCounts={counts?.counts}
115
+ resourceCoverage={counts?.coverage}
115
116
  resourceForbidden={counts?.forbidden}
116
117
  resourceUnavailable={counts?.unavailable}
117
118
  pinned={pinned}