@skyhook-io/radar-app 1.18.0 → 1.18.2
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.
- package/README.md +6 -0
- package/package.json +2 -3
- package/src/App.tsx +43 -12
- package/src/api/client.deleteResource.test.tsx +111 -0
- package/src/api/client.gitops-destination.test.tsx +55 -0
- package/src/api/client.resource-list.test.ts +76 -0
- package/src/api/client.resourceAudit.test.tsx +57 -0
- package/src/api/client.resourcePath.test.ts +107 -0
- package/src/api/client.ts +197 -57
- package/src/api/quotas.ts +9 -20
- package/src/api/radarFeatures.ts +2 -0
- package/src/api/resourceLists.test.ts +84 -0
- package/src/api/resourceLists.ts +71 -0
- package/src/components/capacity/CapacityDemand.tsx +6 -3
- package/src/components/capacity/CapacityOverview.tsx +14 -7
- package/src/components/capacity/CapacityPoolDetail.tsx +7 -5
- package/src/components/capacity/ClusterSchedulingCard.tsx +3 -3
- package/src/components/capacity/shared.tsx +9 -5
- package/src/components/cnpg/CNPGOverview.tsx +4 -1
- package/src/components/cnpg/CNPGView.tsx +1 -0
- package/src/components/cnpg/actions/useCNPGWriteGuard.tsx +1 -0
- package/src/components/compare/CompareResourcePicker.test.tsx +58 -0
- package/src/components/compare/CompareViewRoute.tsx +5 -1
- package/src/components/compare/useCompareCandidates.ts +1 -1
- package/src/components/compare/useCompareLauncher.tsx +4 -2
- package/src/components/diagnose/ApplyDialog.test.tsx +10 -0
- package/src/components/diagnose/ApplyDialog.tsx +8 -1
- package/src/components/diagnose/AssessmentCard.tsx +60 -0
- package/src/components/diagnose/DiagnoseSurface.tsx +5 -0
- package/src/components/diagnose/InvestigationEvidencePane.test.tsx +62 -2
- package/src/components/diagnose/InvestigationEvidenceSections.tsx +6 -5
- package/src/components/diagnose/InvestigationView.tsx +47 -13
- package/src/components/diagnose/StoryExcerpt.tsx +24 -5
- package/src/components/diagnose/assessmentCopy.ts +11 -0
- package/src/components/diagnose/investigationEvidence/adapters/changes.ts +36 -1
- package/src/components/diagnose/investigationEvidence/adapters/crossplane.test.tsx +85 -0
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +1 -0
- package/src/components/diagnose/investigationEvidence/adapters/listCoverage.test.ts +415 -0
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.test.ts +2 -1
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +2 -1
- package/src/components/diagnose/investigationEvidence/adapters/resource.ts +107 -8
- package/src/components/diagnose/investigationEvidence/adapters/testdata/crossplane-paused-get-resource.json +28 -0
- package/src/components/diagnose/investigationEvidence/bodies/index.tsx +2 -0
- package/src/components/diagnose/investigationEvidence/bodies/inventory.tsx +66 -16
- package/src/components/diagnose/investigationEvidence/bodies/workload.tsx +5 -1
- package/src/components/diagnose/investigationEvidence/builder.ts +16 -2
- package/src/components/diagnose/investigationEvidence/cardParts.tsx +7 -2
- package/src/components/diagnose/investigationEvidence/excerpt.ts +2 -0
- package/src/components/diagnose/investigationEvidence/identity.test.ts +1 -1
- package/src/components/diagnose/investigationEvidence/observations.ts +8 -3
- package/src/components/diagnose/investigationEvidence/projection.test.ts +81 -4
- package/src/components/diagnose/investigationEvidence/types.ts +15 -0
- package/src/components/diagnose/investigationEvidencePresentation.test.ts +36 -2
- package/src/components/diagnose/investigationEvidencePresentation.ts +33 -8
- package/src/components/diagnose/storyParts.test.tsx +53 -0
- package/src/components/diagnose/toolCallLabel.test.ts +9 -0
- package/src/components/diagnose/toolCallLabel.ts +2 -0
- package/src/components/execution/BatchExecutionView.image-browse.test.tsx +46 -0
- package/src/components/execution/BatchExecutionView.tsx +6 -4
- package/src/components/gitops/GitOpsView.identity.test.tsx +113 -0
- package/src/components/gitops/GitOpsView.tsx +62 -40
- package/src/components/gitops/useDestinationCluster.ts +2 -1
- package/src/components/helm/ArtifactHubSourceSearch.test.tsx +124 -0
- package/src/components/helm/ArtifactHubSourceSearch.tsx +240 -0
- package/src/components/helm/ChartBrowser.tsx +9 -8
- package/src/components/helm/HelmReleaseDrawer.tsx +6 -2
- package/src/components/helm/HelmView.tsx +34 -23
- package/src/components/helm/InstallWizard.tsx +6 -2
- package/src/components/helm/TrackChartSourceDialog.render.test.tsx +269 -96
- package/src/components/helm/TrackChartSourceDialog.tsx +607 -104
- package/src/components/helm/ValuesViewer.test.tsx +1 -0
- package/src/components/helm/ValuesViewer.tsx +4 -2
- package/src/components/home/ClusterHealthCard.tsx +28 -21
- package/src/components/home/MCPSetupDialog.test.tsx +27 -2
- package/src/components/home/MCPSetupDialog.tsx +14 -2
- package/src/components/home/mcpToolCatalog.ts +39 -2
- package/src/components/issues/IssuesPane.render.test.tsx +5 -5
- package/src/components/nav/PrimaryNavRail.tsx +34 -2
- package/src/components/product-hunt/ProductHuntNotice.render.test.tsx +120 -0
- package/src/components/product-hunt/ProductHuntNotice.test.ts +121 -0
- package/src/components/product-hunt/ProductHuntNotice.tsx +202 -0
- package/src/components/product-hunt/launchWindow.ts +78 -0
- package/src/components/product-hunt/useProductHuntRailEntry.test.tsx +76 -0
- package/src/components/product-hunt/useProductHuntRailEntry.ts +27 -0
- package/src/components/resource/PrometheusCharts.overlays.test.ts +45 -0
- package/src/components/resource/PrometheusCharts.tsx +2 -2
- package/src/components/resources/CompositeRenderer.tsx +4 -0
- package/src/components/resources/ResourcesView.tsx +30 -68
- package/src/components/resources/renderers/PodRenderer.tsx +4 -1
- package/src/components/settings/LocalConnectionSettings.tsx +1 -0
- package/src/components/settings/MyPermissionsDialog.tsx +12 -9
- package/src/components/traffic/TrafficSourcePill.test.tsx +110 -0
- package/src/components/traffic/TrafficSourcePill.tsx +111 -0
- package/src/components/traffic/TrafficView.tsx +9 -55
- package/src/components/ui/DiagnosticsOverlay.test.ts +25 -0
- package/src/components/ui/DiagnosticsOverlay.tsx +2 -1
- package/src/components/ui/Omnibar.note.test.tsx +141 -0
- package/src/components/ui/Omnibar.tsx +82 -18
- package/src/components/ui/RadarOmnibar.test.tsx +201 -0
- package/src/components/ui/RadarOmnibar.tsx +39 -4
- package/src/components/ui/SearchSyntaxHelp.test.tsx +39 -0
- package/src/components/ui/SearchSyntaxHelp.tsx +23 -2
- package/src/components/ui/UpdateNotification.manual.test.tsx +177 -0
- package/src/components/ui/UpdateNotification.test.tsx +4 -1
- package/src/components/ui/UpdateNotification.tsx +61 -10
- package/src/components/ui/omnibar-match.test.ts +15 -8
- package/src/components/ui/omnibar-match.ts +11 -6
- package/src/components/ui/searchCoverage.fixtures.ts +16 -0
- package/src/components/ui/searchCoverageNote.test.ts +245 -0
- package/src/components/ui/searchCoverageNote.ts +222 -0
- package/src/components/usage-data/UsageDataPrompt.tsx +19 -1
- package/src/components/whats-new/WhatsNew.test.ts +10 -0
- package/src/components/whats-new/WhatsNew.tsx +5 -4
- package/src/components/whats-new/WhatsNewDialog.test.tsx +20 -0
- package/src/components/whats-new/releaseNotes.ts +57 -5
- package/src/components/workload/WorkloadView.tsx +18 -6
- package/src/components/workspace/layout.tsx +2 -1
- package/src/contexts/CapabilitiesContext.tsx +1 -0
- package/src/hooks/useGitOpsWriteGuard.test.tsx +126 -2
- package/src/hooks/useGitOpsWriteGuard.ts +25 -3
- package/src/hooks/useResolvedGitOpsOwner.ts +14 -9
- package/src/hooks/useResourceCounts.ts +2 -0
- package/src/index.css +87 -4
- package/src/index.ts +7 -0
- package/src/utils/artifacthub.test.ts +18 -0
- package/src/utils/artifacthub.ts +9 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useState, useMemo, useCallback } from 'react'
|
|
2
2
|
import { useLocation, useNavigate } from 'react-router-dom'
|
|
3
3
|
import { useQuery } from '@tanstack/react-query'
|
|
4
|
-
import {
|
|
4
|
+
import { fetchJSON, isForbiddenError, isKindSyncFailed, isStillLoadingError, useCapabilities, useNamespaceCapabilities, useResources, useSecretCertExpiry, useTopPodMetrics, useTopNodeMetrics, useBulkDeleteResources, useBulkRestartWorkloads, useBulkScaleWorkloads, useAudit, useIssues, fetchResourceList, isListTooLargeError, isUnretryableReadError } from '../../api/client'
|
|
5
5
|
import { isBadgeWorthy } from '../../utils/auditBadges'
|
|
6
6
|
import { ISSUE_SEVERITY_RANK } from '@skyhook-io/k8s-ui'
|
|
7
7
|
import type { Issue, AuditBadgeMessage } from '@skyhook-io/k8s-ui'
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { stripBasename } from '../../api/config'
|
|
9
|
+
import { createListRefetchInterval, type ResourceListResult } from '../../api/resourceLists'
|
|
10
10
|
import { useAPIResources } from '../../api/apiResources'
|
|
11
11
|
import { useConnection } from '../../context/ConnectionContext'
|
|
12
12
|
import { getSecretStoreProviderType } from '@skyhook-io/k8s-ui'
|
|
@@ -22,9 +22,8 @@ import {
|
|
|
22
22
|
CORE_RESOURCES,
|
|
23
23
|
intersectWorkloadWrites,
|
|
24
24
|
hasCuratedColumns,
|
|
25
|
-
sanitizePrinterTable,
|
|
26
25
|
} from '@skyhook-io/k8s-ui'
|
|
27
|
-
import type { Capabilities,
|
|
26
|
+
import type { Capabilities, ResourceQueryResult, WorkloadWritePermissions } from '@skyhook-io/k8s-ui'
|
|
28
27
|
import type { SelectedResource } from '../../types'
|
|
29
28
|
import { apiVersionToGroup, kindToPluralWithGroup, type NavigateToResource } from '../../utils/navigation'
|
|
30
29
|
import { CreateResourceDialog } from '../shared/CreateResourceDialog'
|
|
@@ -134,7 +133,6 @@ export function ResourcesView({ namespaces, selectedResource, onResourceClick, o
|
|
|
134
133
|
const canBulkScaleSelectedKind = useMemo(() => canBulkScaleKind(selectedKind, workloadWrites), [selectedKind, workloadWrites])
|
|
135
134
|
|
|
136
135
|
// Lightweight resource counts for sidebar badges (~2KB instead of ~608MB)
|
|
137
|
-
const namespacesParam = namespaces.join(',')
|
|
138
136
|
const { data: countsData, isError: countsIsError } = useResourceCounts(namespaces)
|
|
139
137
|
|
|
140
138
|
// Determine if selected kind is a CRD (only CRDs should send ?group= to backend)
|
|
@@ -196,23 +194,17 @@ export function ResourcesView({ namespaces, selectedResource, onResourceClick, o
|
|
|
196
194
|
// unguarded on exactly the clusters the guard protects. Counts arrive
|
|
197
195
|
// right after 'connected' and settle the guard then.
|
|
198
196
|
const syncShellActive = connection.state === 'connecting'
|
|
199
|
-
// A
|
|
200
|
-
// the
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
selectedCountUnavailable && countsData?.reasons?.[selectedCountKey] === 'kind_sync_failed'
|
|
205
|
-
// A guarded kind whose informer hasn't finished reports unavailable with a
|
|
206
|
-
// kind_sync_pending reason — "count not known YET", so keep the loading
|
|
207
|
-
// state. Keyed on the reason, not on connection.state: deferred kinds sync
|
|
208
|
-
// after connect. Reasonless unavailable stays a real verification failure
|
|
209
|
-
// and blocks the view as before.
|
|
197
|
+
// A reasoned unavailable count must reach the list endpoint, which supplies
|
|
198
|
+
// the collector error without materializing an unchecked large payload.
|
|
199
|
+
const selectedCountReadFailure = selectedCountUnavailable &&
|
|
200
|
+
Boolean(countsData?.reasons?.[selectedCountKey]) &&
|
|
201
|
+
countsData?.reasons?.[selectedCountKey] !== 'kind_sync_pending'
|
|
210
202
|
const selectedCountPendingSync =
|
|
211
203
|
(selectedCountUnavailable && countsData?.reasons?.[selectedCountKey] === 'kind_sync_pending') ||
|
|
212
|
-
(syncShellActive && selectedCountUnavailable && !
|
|
204
|
+
(syncShellActive && selectedCountUnavailable && !selectedCountReadFailure)
|
|
213
205
|
const waitingForGuardCount = isSelectedKindGuarded &&
|
|
214
206
|
((!countsData && (!countsIsError || syncShellActive)) || selectedCountPendingSync)
|
|
215
|
-
const largeListBlocked = isSelectedKindGuarded && countsData != null && !selectedCountPendingSync && !
|
|
207
|
+
const largeListBlocked = isSelectedKindGuarded && countsData != null && !selectedCountPendingSync && !selectedCountReadFailure &&
|
|
216
208
|
(selectedCountUnavailable || (selectedCountKnown && (selectedCount ?? 0) > selectedKindRowLimit))
|
|
217
209
|
const selectedKindQueryBlocked = waitingForGuardCount || largeListBlocked
|
|
218
210
|
const podCount = countsData?.counts.Pod
|
|
@@ -240,64 +232,30 @@ export function ResourcesView({ namespaces, selectedResource, onResourceClick, o
|
|
|
240
232
|
}
|
|
241
233
|
: null
|
|
242
234
|
|
|
235
|
+
const loadingInterval = useMemo(() => createListRefetchInterval(120000), [])
|
|
236
|
+
|
|
243
237
|
// Fetch full data only for the selected kind
|
|
244
238
|
const selectedKindQuery = useQuery({
|
|
245
239
|
queryKey: ['resources', selectedKind?.name, isSelectedCrd ? selectedKind?.group : '', namespaces],
|
|
246
|
-
queryFn: async (): Promise<
|
|
247
|
-
if (!selectedKind) return { items: [], printerTable: null }
|
|
248
|
-
const params = new URLSearchParams()
|
|
249
|
-
if (namespaces.length > 0) params.set('namespaces', namespacesParam)
|
|
250
|
-
if (isSelectedCrd && selectedKind.group) params.set('group', selectedKind.group)
|
|
251
|
-
if (selectedKindSummaryServed) params.set('include', 'summary')
|
|
240
|
+
queryFn: async ({ signal }): Promise<ResourceListResult<any>> => {
|
|
241
|
+
if (!selectedKind) return { items: [], coverage: { status: 'unknown' }, printerTable: null }
|
|
252
242
|
// Only CRDs can declare printer columns, and a curated kind discards the
|
|
253
243
|
// result — so table mode is requested from exactly the kinds that can use
|
|
254
244
|
// it. Resolving a table costs the server a CRD read per request; doing
|
|
255
245
|
// that for a kind whose columns are hand-curated is pure waste.
|
|
256
|
-
const wantsTable = isSelectedCrd && !!selectedKind.group &&
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
debugNamespaceLog('resources:selected-kind-fetch-start', {
|
|
261
|
-
kind: selectedKind.name,
|
|
262
|
-
group: isSelectedCrd ? selectedKind.group : '',
|
|
263
|
-
namespaces,
|
|
264
|
-
params: params.toString(),
|
|
246
|
+
const wantsTable = isSelectedCrd && !!selectedKind.group && !hasCuratedColumns(selectedKind.name, selectedKind.group)
|
|
247
|
+
return fetchResourceList(selectedKind.name, {
|
|
248
|
+
namespaces, group: isSelectedCrd ? selectedKind.group : undefined,
|
|
249
|
+
summary: selectedKindSummaryServed, table: wantsTable, signal,
|
|
265
250
|
})
|
|
266
|
-
const res = await fetch(apiUrl(`/resources/${selectedKind.name}?${params}`), {
|
|
267
|
-
credentials: getCredentialsMode(),
|
|
268
|
-
headers: getAuthHeaders(),
|
|
269
|
-
})
|
|
270
|
-
debugNamespaceLog('resources:selected-kind-fetch-response', {
|
|
271
|
-
kind: selectedKind.name,
|
|
272
|
-
group: isSelectedCrd ? selectedKind.group : '',
|
|
273
|
-
namespaces,
|
|
274
|
-
params: params.toString(),
|
|
275
|
-
status: res.status,
|
|
276
|
-
durationMs: Math.round(performance.now() - startedAt),
|
|
277
|
-
})
|
|
278
|
-
if (!res.ok) {
|
|
279
|
-
const errorData = await readErrorBody(res)
|
|
280
|
-
throw new ApiError(errorData.error || `Failed to fetch ${selectedKind.name}`, res.status, errorData)
|
|
281
|
-
}
|
|
282
|
-
const body = await res.json()
|
|
283
|
-
// Both branches are current shapes, not a guess at a legacy one: a Radar
|
|
284
|
-
// backend that predates `table` ignores the parameter and answers with
|
|
285
|
-
// the bare array. @skyhook-io/radar-app is versioned independently of the
|
|
286
|
-
// backend it points at, so a consumer can pair a new frontend with an
|
|
287
|
-
// older Radar — and reading that array as a missing envelope would render
|
|
288
|
-
// every CRD list empty. Items and columns still come from one response,
|
|
289
|
-
// so a row can never render against another fetch's cells.
|
|
290
|
-
if (!wantsTable || Array.isArray(body)) return { items: body as any[], printerTable: null }
|
|
291
|
-
return {
|
|
292
|
-
items: Array.isArray(body?.items) ? body.items as any[] : [],
|
|
293
|
-
printerTable: sanitizePrinterTable(body),
|
|
294
|
-
}
|
|
295
251
|
},
|
|
296
252
|
enabled: !!selectedKind && !selectedKindQueryBlocked && resourceKindListMode(selectedKind, hostFeatures, capabilitiesPending) === 'table',
|
|
297
253
|
staleTime: 30000,
|
|
298
|
-
|
|
254
|
+
// Safety net — SSE k8s_event drives near-real-time invalidation. A list
|
|
255
|
+
// whose namespaces are still loading is re-read until they finish.
|
|
256
|
+
refetchInterval: loadingInterval,
|
|
299
257
|
retry: (failureCount: number, error: Error) => {
|
|
300
|
-
if (isForbiddenError(error) || isKindSyncFailed(error)) return false
|
|
258
|
+
if (isForbiddenError(error) || isKindSyncFailed(error) || isUnretryableReadError(error)) return false
|
|
301
259
|
// Cluster still connecting, or this kind's informer still completing
|
|
302
260
|
// its initial sync: keep the query in its loading state and retry —
|
|
303
261
|
// the header's sync-progress label explains the wait.
|
|
@@ -314,13 +272,14 @@ export function ResourcesView({ namespaces, selectedResource, onResourceClick, o
|
|
|
314
272
|
return {
|
|
315
273
|
resourceName: selectedKind.name,
|
|
316
274
|
group: selectedKind.group,
|
|
275
|
+
coverage: selectedKindQuery.data?.coverage,
|
|
317
276
|
data: selectedKindQueryBlocked ? [] : selectedKindQuery.data?.items,
|
|
318
277
|
isLoading: waitingForGuardCount || selectedKindQuery.isLoading,
|
|
319
278
|
error: selectedKindQueryBlocked ? undefined : selectedKindQuery.error,
|
|
320
279
|
refetch: selectedKindQuery.refetch,
|
|
321
280
|
dataUpdatedAt: selectedKindQuery.dataUpdatedAt,
|
|
322
281
|
}
|
|
323
|
-
}, [selectedKind, selectedKindQueryBlocked, waitingForGuardCount, selectedKindQuery.data?.items, selectedKindQuery.isLoading, selectedKindQuery.error, selectedKindQuery.refetch, selectedKindQuery.dataUpdatedAt])
|
|
282
|
+
}, [selectedKind, selectedKindQueryBlocked, waitingForGuardCount, selectedKindQuery.data?.items, selectedKindQuery.data?.coverage, selectedKindQuery.isLoading, selectedKindQuery.error, selectedKindQuery.refetch, selectedKindQuery.dataUpdatedAt])
|
|
324
283
|
|
|
325
284
|
// Metrics
|
|
326
285
|
const { data: topPodMetrics } = useTopPodMetrics({ enabled: topPodMetricsEnabled, namespaces })
|
|
@@ -425,13 +384,16 @@ export function ResourcesView({ namespaces, selectedResource, onResourceClick, o
|
|
|
425
384
|
apiResources={apiResources}
|
|
426
385
|
// Lightweight counts for sidebar (replaces 233 parallel queries)
|
|
427
386
|
resourceCounts={countsData?.counts ?? EMPTY_RESOURCE_COUNTS}
|
|
387
|
+
resourceCoverage={countsData?.coverage}
|
|
428
388
|
resourceForbidden={countsData?.forbidden}
|
|
429
389
|
resourceReasons={countsData?.reasons}
|
|
430
390
|
resourceUnavailable={countsData?.unavailable}
|
|
431
391
|
selectedKindQuery={selectedKindQueryResult}
|
|
432
392
|
printerTable={selectedKindQueryBlocked ? null : selectedKindQuery.data?.printerTable ?? null}
|
|
433
393
|
connectionState={connection.state === 'connecting' && connection.syncStatus ? 'syncing' : connection.state}
|
|
434
|
-
largeListGuard={
|
|
394
|
+
largeListGuard={selectedKind && isListTooLargeError(selectedKindQuery.error)
|
|
395
|
+
? { kind: selectedKind.name, reason: 'too-many', count: typeof selectedKindQuery.error.data?.count === 'number' ? selectedKindQuery.error.data.count : undefined, limit: selectedKindRowLimit, namespaces }
|
|
396
|
+
: largeListGuard}
|
|
435
397
|
onSelectedKindChange={setSelectedKind}
|
|
436
398
|
sidebarCategoryWorkspaces={cnpgSidebarWorkspace}
|
|
437
399
|
topPodMetrics={topPodMetrics}
|
|
@@ -464,7 +426,7 @@ export function ResourcesView({ namespaces, selectedResource, onResourceClick, o
|
|
|
464
426
|
onCreateResource={handleCreateResource}
|
|
465
427
|
renderKindView={renderKindView}
|
|
466
428
|
// Bulk operations
|
|
467
|
-
onBulkDelete={(items, options) => bulkDeleteMutation.mutate({ items, force: options?.force }, { onSuccess: options?.onSuccess })}
|
|
429
|
+
onBulkDelete={(items, options) => bulkDeleteMutation.mutate({ items, force: options?.force }, { onSuccess: results => { if (!results.some(({ result }) => result.outcomeUnknown)) options?.onSuccess?.() } })}
|
|
468
430
|
isBulkDeleting={bulkDeleteMutation.isPending}
|
|
469
431
|
onBulkRestart={canBulkRestartSelectedKind ? (items, options) => bulkRestartMutation.mutate({ items }, { onSuccess: options?.onSuccess }) : undefined}
|
|
470
432
|
isBulkRestarting={canBulkRestartSelectedKind && bulkRestartMutation.isPending}
|
|
@@ -25,6 +25,7 @@ interface PodRendererProps {
|
|
|
25
25
|
export function PodRenderer({ data, onCopy, copied, onNavigate, onOpenLogs, resolvedEnvFrom }: PodRendererProps) {
|
|
26
26
|
const namespace = data.metadata?.namespace
|
|
27
27
|
const podName = data.metadata?.name
|
|
28
|
+
const isTerminal = data.status?.phase === 'Succeeded' || data.status?.phase === 'Failed'
|
|
28
29
|
const environmentEnabled = [...(data.spec?.initContainers ?? []), ...(data.spec?.containers ?? [])]
|
|
29
30
|
.some((container: any) => container.env?.length > 0 || container.envFrom?.length > 0)
|
|
30
31
|
const environmentQuery = usePodEnvironment(namespace ?? '', podName ?? '', environmentEnabled)
|
|
@@ -51,7 +52,7 @@ export function PodRenderer({ data, onCopy, copied, onNavigate, onOpenLogs, reso
|
|
|
51
52
|
const metricsHistoryQuery = usePodMetricsHistory(namespace, podName)
|
|
52
53
|
const { data: metricsHistory } = metricsHistoryQuery
|
|
53
54
|
const historyMetricsUnavailable = metricsHistory?.metricsUnavailable === true
|
|
54
|
-
const liveMetricsEnabled = shouldFetchLiveMetrics(metricsHistoryQuery.isFetched || metricsHistoryQuery.isError, historyMetricsUnavailable)
|
|
55
|
+
const liveMetricsEnabled = !isTerminal && shouldFetchLiveMetrics(metricsHistoryQuery.isFetched || metricsHistoryQuery.isError, historyMetricsUnavailable)
|
|
55
56
|
const { data: metrics } = usePodMetrics(namespace, podName, { enabled: liveMetricsEnabled })
|
|
56
57
|
const metricsUnavailable = historyMetricsUnavailable || isLiveMetricsUnavailable(liveMetricsEnabled, metrics)
|
|
57
58
|
const visibleMetrics = getVisibleLiveMetrics(liveMetricsEnabled, metricsUnavailable, metrics)
|
|
@@ -130,6 +131,8 @@ export function PodRenderer({ data, onCopy, copied, onNavigate, onOpenLogs, reso
|
|
|
130
131
|
)}
|
|
131
132
|
metrics={visibleMetrics}
|
|
132
133
|
metricsHistory={metricsHistory}
|
|
134
|
+
metricsHistoryLoading={metricsHistoryQuery.isLoading}
|
|
135
|
+
metricsHistoryError={metricsHistoryQuery.error}
|
|
133
136
|
metricsUnavailable={metricsUnavailable}
|
|
134
137
|
hideMetricsServer={hideMetricsServer}
|
|
135
138
|
renderImageBrowser={({ image, namespace: ns, podName: pod, pullSecrets, onClose, onSwitchToPodFiles }) => (
|
|
@@ -193,29 +193,32 @@ function displayKind(countKey: string): string {
|
|
|
193
193
|
|
|
194
194
|
// RestrictedResources surfaces the kinds Radar isn't showing the user (the
|
|
195
195
|
// resource-counts `forbidden` set) — the "what's hidden from me" half of access,
|
|
196
|
-
// alongside the SelfSubjectRulesReview rules above.
|
|
197
|
-
//
|
|
198
|
-
//
|
|
196
|
+
// alongside the SelfSubjectRulesReview rules above. Each forbidden kind carries
|
|
197
|
+
// a reason, so only the caller's own RBAC denials are listed. A Radar that
|
|
198
|
+
// predates reasons mixes those with not-installed/not-watched kinds, so its
|
|
199
|
+
// copy says "usually RBAC" rather than asserting a cause. Both link to the docs
|
|
200
|
+
// that carry the unblock RBAC.
|
|
199
201
|
function RestrictedResources({ enabled }: { enabled: boolean }) {
|
|
200
|
-
const { data } = useQuery<{ forbidden?: string[] }>({
|
|
202
|
+
const { data } = useQuery<{ forbidden?: string[]; reasons?: Record<string, string> }>({
|
|
201
203
|
queryKey: ['resource-counts', 'your-access'],
|
|
202
204
|
queryFn: () => fetchJSON('/resource-counts'),
|
|
203
205
|
enabled,
|
|
204
206
|
staleTime: 10000,
|
|
205
207
|
})
|
|
206
|
-
const
|
|
208
|
+
const reasons = data?.reasons
|
|
209
|
+
const forbidden = (data?.forbidden ?? []).filter(key => !reasons || reasons[key] === 'rbac_denied')
|
|
207
210
|
if (forbidden.length === 0) return null
|
|
208
211
|
|
|
209
212
|
return (
|
|
210
213
|
<div>
|
|
211
214
|
<div className="text-xs font-medium text-theme-text-secondary uppercase tracking-wider mb-2 flex items-center gap-1.5">
|
|
212
215
|
<Lock className="w-3.5 h-3.5 text-amber-400" />
|
|
213
|
-
Restricted or unavailable ({forbidden.length})
|
|
216
|
+
{reasons ? 'Restricted resources' : 'Restricted or unavailable'} ({forbidden.length})
|
|
214
217
|
</div>
|
|
215
218
|
<p className="text-xs text-theme-text-tertiary mb-2">
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
+
{reasons
|
|
220
|
+
? 'These kinds are hidden by your permissions.'
|
|
221
|
+
: "Resource types Radar isn't showing you — usually because your RBAC doesn't allow listing them, sometimes because the type isn't installed or watched on this cluster. Either way, not an empty cluster."}
|
|
219
222
|
</p>
|
|
220
223
|
<div className="flex flex-wrap gap-1.5">
|
|
221
224
|
{forbidden.map((k) => (
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act, type ComponentProps } from 'react'
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
5
|
+
import { TrafficSourcePill } from './TrafficSourcePill'
|
|
6
|
+
|
|
7
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
8
|
+
|
|
9
|
+
type Props = ComponentProps<typeof TrafficSourcePill>
|
|
10
|
+
|
|
11
|
+
const props = (overrides: Partial<Props>): Props => ({
|
|
12
|
+
sources: ['hubble', 'istio'],
|
|
13
|
+
active: 'istio',
|
|
14
|
+
connection: 'connected',
|
|
15
|
+
onSwitch: vi.fn(),
|
|
16
|
+
onRetry: vi.fn(),
|
|
17
|
+
...overrides,
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
let container: HTMLDivElement
|
|
21
|
+
let root: Root
|
|
22
|
+
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
container = document.createElement('div')
|
|
25
|
+
document.body.appendChild(container)
|
|
26
|
+
root = createRoot(container)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
afterEach(() => {
|
|
30
|
+
act(() => root.unmount())
|
|
31
|
+
container.remove()
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const render = (p: Props) => act(() => root.render(<TrafficSourcePill {...p} />))
|
|
35
|
+
|
|
36
|
+
const button = (label: string) =>
|
|
37
|
+
Array.from(container.querySelectorAll('button')).find((b) => b.textContent?.trim() === label)
|
|
38
|
+
|
|
39
|
+
const open = () => act(() => button('istio')!.click())
|
|
40
|
+
|
|
41
|
+
describe('TrafficSourcePill', () => {
|
|
42
|
+
it('switches source from the picker when connected', () => {
|
|
43
|
+
const p = props({})
|
|
44
|
+
render(p)
|
|
45
|
+
open()
|
|
46
|
+
act(() => button('hubble')!.click())
|
|
47
|
+
expect(p.onSwitch).toHaveBeenCalledWith('hubble')
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('keeps the picker available when the active source failed to connect', () => {
|
|
51
|
+
const p = props({ connection: 'error' })
|
|
52
|
+
render(p)
|
|
53
|
+
open()
|
|
54
|
+
act(() => button('hubble')!.click())
|
|
55
|
+
expect(p.onSwitch).toHaveBeenCalledWith('hubble')
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('offers retry next to the picker on error', () => {
|
|
59
|
+
const p = props({ connection: 'error' })
|
|
60
|
+
render(p)
|
|
61
|
+
act(() => button('retry')!.click())
|
|
62
|
+
expect(p.onRetry).toHaveBeenCalledTimes(1)
|
|
63
|
+
expect(button('istio')).toBeDefined()
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
it('does not switch when the active source is picked again', () => {
|
|
67
|
+
const p = props({})
|
|
68
|
+
render(p)
|
|
69
|
+
open()
|
|
70
|
+
act(() => container.querySelector<HTMLButtonElement>('[role="option"][aria-selected="true"]')!.click())
|
|
71
|
+
expect(p.onSwitch).not.toHaveBeenCalled()
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
it('shows no picker with a single available source', () => {
|
|
75
|
+
render(props({ sources: ['istio'] }))
|
|
76
|
+
expect(container.querySelector('button[aria-haspopup]')).toBeNull()
|
|
77
|
+
expect(container.textContent).toContain('istio')
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it('shows no picker or retry while connecting', () => {
|
|
81
|
+
render(props({ connection: 'connecting' }))
|
|
82
|
+
expect(container.textContent).toContain('Connecting...')
|
|
83
|
+
expect(container.querySelector('button')).toBeNull()
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
it('does not reopen the menu after a retry made without a mouse', () => {
|
|
87
|
+
const p = props({ connection: 'error' })
|
|
88
|
+
render(p)
|
|
89
|
+
open()
|
|
90
|
+
expect(container.querySelector('[role="listbox"]')).not.toBeNull()
|
|
91
|
+
act(() => button('retry')!.click())
|
|
92
|
+
render({ ...p, connection: 'connecting' })
|
|
93
|
+
render({ ...p, connection: 'connected' })
|
|
94
|
+
const menu = container.querySelector('[role="listbox"]')
|
|
95
|
+
expect(menu === null || menu.hasAttribute('inert')).toBe(true)
|
|
96
|
+
expect(button('istio')!.getAttribute('aria-expanded')).toBe('false')
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it('makes the menu inert while it animates closed, so its options cannot be activated', () => {
|
|
100
|
+
const p = props({})
|
|
101
|
+
render(p)
|
|
102
|
+
open()
|
|
103
|
+
expect(container.querySelector('[role="listbox"]')!.hasAttribute('inert')).toBe(false)
|
|
104
|
+
act(() => {
|
|
105
|
+
document.body.dispatchEvent(new MouseEvent('mousedown', { bubbles: true }))
|
|
106
|
+
})
|
|
107
|
+
const closing = container.querySelector('[role="listbox"]')
|
|
108
|
+
expect(closing === null || closing.hasAttribute('inert')).toBe(true)
|
|
109
|
+
})
|
|
110
|
+
})
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react'
|
|
2
|
+
import { clsx } from 'clsx'
|
|
3
|
+
import { ChevronDown, Loader2 } from 'lucide-react'
|
|
4
|
+
import { StatusDot, toneTextClass } from '@skyhook-io/k8s-ui'
|
|
5
|
+
import { useAnimatedUnmount } from '../../hooks/useAnimatedUnmount'
|
|
6
|
+
import { TRANSITION_MENU, overlayExitMs, overlayTransitionStyle } from '../../utils/animation'
|
|
7
|
+
|
|
8
|
+
export type TrafficSourceConnectionState = 'connecting' | 'error' | 'connected'
|
|
9
|
+
|
|
10
|
+
interface TrafficSourcePillProps {
|
|
11
|
+
sources: string[]
|
|
12
|
+
active: string
|
|
13
|
+
connection: TrafficSourceConnectionState
|
|
14
|
+
onSwitch: (name: string) => void
|
|
15
|
+
onRetry: () => void
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// The picker is shown for every connection state except connecting: a source
|
|
19
|
+
// that cannot connect is the case where the user most needs to pick another.
|
|
20
|
+
export function TrafficSourcePill({ sources, active, connection, onSwitch, onRetry }: TrafficSourcePillProps) {
|
|
21
|
+
const [open, setOpen] = useState(false)
|
|
22
|
+
const pickerRef = useRef<HTMLDivElement>(null)
|
|
23
|
+
const canPick = sources.length > 1
|
|
24
|
+
const menuOpen = open && canPick && connection !== 'connecting'
|
|
25
|
+
const { shouldRender, isOpen } = useAnimatedUnmount(menuOpen, overlayExitMs('menu'))
|
|
26
|
+
|
|
27
|
+
// Capture phase so the handler runs before ReactFlow swallows the event.
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (!open) return
|
|
30
|
+
const handler = (e: MouseEvent) => {
|
|
31
|
+
if (pickerRef.current && !pickerRef.current.contains(e.target as Node)) {
|
|
32
|
+
setOpen(false)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
document.addEventListener('mousedown', handler, true)
|
|
36
|
+
return () => document.removeEventListener('mousedown', handler, true)
|
|
37
|
+
}, [open])
|
|
38
|
+
|
|
39
|
+
const choose = (name: string) => {
|
|
40
|
+
setOpen(false)
|
|
41
|
+
if (name !== active) onSwitch(name)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Keyboard activation of retry fires no outside mousedown, so the menu has to
|
|
45
|
+
// be closed here or it would reappear once the attempt finishes.
|
|
46
|
+
const retry = () => {
|
|
47
|
+
setOpen(false)
|
|
48
|
+
onRetry()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<div className="flex items-center gap-1.5 px-2 py-1 rounded-lg bg-theme-surface/90 backdrop-blur border border-theme-border text-[11px]">
|
|
53
|
+
{connection === 'connecting' ? (
|
|
54
|
+
<>
|
|
55
|
+
<Loader2 className="h-3 w-3 animate-spin text-accent" />
|
|
56
|
+
<span className="text-accent">Connecting...</span>
|
|
57
|
+
</>
|
|
58
|
+
) : (
|
|
59
|
+
<>
|
|
60
|
+
<StatusDot tone={connection === 'error' ? 'degraded' : 'healthy'} size="md" />
|
|
61
|
+
{canPick ? (
|
|
62
|
+
<div className="relative" ref={pickerRef}>
|
|
63
|
+
<button
|
|
64
|
+
type="button"
|
|
65
|
+
onClick={() => setOpen(!open)}
|
|
66
|
+
aria-haspopup="listbox"
|
|
67
|
+
aria-expanded={menuOpen}
|
|
68
|
+
className="flex items-center gap-1 text-theme-text-secondary hover:text-theme-text-primary"
|
|
69
|
+
>
|
|
70
|
+
{active} <ChevronDown className="h-3 w-3" />
|
|
71
|
+
</button>
|
|
72
|
+
{shouldRender && (
|
|
73
|
+
<div
|
|
74
|
+
role="listbox"
|
|
75
|
+
inert={!menuOpen || undefined}
|
|
76
|
+
className={clsx(
|
|
77
|
+
'absolute top-full left-0 mt-1 z-50 bg-theme-surface border border-theme-border rounded-md shadow-theme-lg py-1 min-w-[120px] origin-top-left',
|
|
78
|
+
TRANSITION_MENU,
|
|
79
|
+
isOpen ? 'opacity-100 scale-100' : 'opacity-0 scale-[0.97]',
|
|
80
|
+
!menuOpen && 'pointer-events-none',
|
|
81
|
+
)}
|
|
82
|
+
style={overlayTransitionStyle(isOpen, 'menu')}
|
|
83
|
+
>
|
|
84
|
+
{sources.map(name => (
|
|
85
|
+
<button
|
|
86
|
+
key={name}
|
|
87
|
+
type="button"
|
|
88
|
+
role="option"
|
|
89
|
+
aria-selected={name === active}
|
|
90
|
+
onClick={() => choose(name)}
|
|
91
|
+
className={clsx('w-full text-left px-3 py-1 text-xs hover:bg-theme-hover capitalize', name === active && 'text-accent')}
|
|
92
|
+
>
|
|
93
|
+
{name}
|
|
94
|
+
</button>
|
|
95
|
+
))}
|
|
96
|
+
</div>
|
|
97
|
+
)}
|
|
98
|
+
</div>
|
|
99
|
+
) : (
|
|
100
|
+
<span className="text-theme-text-secondary">{active}</span>
|
|
101
|
+
)}
|
|
102
|
+
{connection === 'error' && (
|
|
103
|
+
<button type="button" onClick={retry} className={clsx('font-medium hover:underline', toneTextClass('degraded'))}>
|
|
104
|
+
retry
|
|
105
|
+
</button>
|
|
106
|
+
)}
|
|
107
|
+
</>
|
|
108
|
+
)}
|
|
109
|
+
</div>
|
|
110
|
+
)
|
|
111
|
+
}
|
|
@@ -7,10 +7,10 @@ import { TrafficWizard } from './TrafficWizard'
|
|
|
7
7
|
import { TrafficGraph, type TrafficGraphSelection } from './TrafficGraph'
|
|
8
8
|
import { TrafficFilterSidebar } from './TrafficFilterSidebar'
|
|
9
9
|
import { TrafficFlowListProvider } from './TrafficFlowListContext'
|
|
10
|
-
import {
|
|
10
|
+
import { Filter, Plug, List, Activity, AlertTriangle, Clock, Crosshair, X } from 'lucide-react'
|
|
11
11
|
import { TrafficFocusSearch } from './TrafficFocusSearch'
|
|
12
|
+
import { TrafficSourcePill } from './TrafficSourcePill'
|
|
12
13
|
import { TrafficGraphTooLarge } from './TrafficGraphTooLarge'
|
|
13
|
-
import { clsx } from 'clsx'
|
|
14
14
|
import { useQueryClient } from '@tanstack/react-query'
|
|
15
15
|
import { useDock } from '../dock'
|
|
16
16
|
import { AlertBanner, EmptyState, PaneLoader, FreshnessControl } from '@skyhook-io/k8s-ui'
|
|
@@ -457,8 +457,6 @@ export function TrafficView({ namespaces, onSetNamespaces }: TrafficViewProps) {
|
|
|
457
457
|
const connectMutation = useTrafficConnect()
|
|
458
458
|
const setSourceMutation = useSetTrafficSource()
|
|
459
459
|
const hasAutoConnectedRef = useRef(false)
|
|
460
|
-
const [sourcePickerOpen, setSourcePickerOpen] = useState(false)
|
|
461
|
-
const sourcePickerRef = useRef<HTMLDivElement>(null)
|
|
462
460
|
|
|
463
461
|
// Track cluster context to reset state on cluster change
|
|
464
462
|
const { data: clusterInfo } = useClusterInfo()
|
|
@@ -479,18 +477,6 @@ export function TrafficView({ namespaces, onSetNamespaces }: TrafficViewProps) {
|
|
|
479
477
|
lastClusterRef.current = currentCluster
|
|
480
478
|
}, [clusterInfo?.context, queryClient])
|
|
481
479
|
|
|
482
|
-
// Close source picker on outside click (capture phase to beat ReactFlow)
|
|
483
|
-
useEffect(() => {
|
|
484
|
-
if (!sourcePickerOpen) return
|
|
485
|
-
const handler = (e: MouseEvent) => {
|
|
486
|
-
if (sourcePickerRef.current && !sourcePickerRef.current.contains(e.target as Node)) {
|
|
487
|
-
setSourcePickerOpen(false)
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
document.addEventListener('mousedown', handler, true)
|
|
491
|
-
return () => document.removeEventListener('mousedown', handler, true)
|
|
492
|
-
}, [sourcePickerOpen])
|
|
493
|
-
|
|
494
480
|
const {
|
|
495
481
|
data: sourcesData,
|
|
496
482
|
isLoading: sourcesLoading,
|
|
@@ -1449,8 +1435,6 @@ export function TrafficView({ namespaces, onSetNamespaces }: TrafficViewProps) {
|
|
|
1449
1435
|
const activeSource = availableSources.find(s => s.name === activeName) || availableSources[0]
|
|
1450
1436
|
|
|
1451
1437
|
const handleSwitchSource = (name: string) => {
|
|
1452
|
-
if (name === activeSource?.name) { setSourcePickerOpen(false); return }
|
|
1453
|
-
setSourcePickerOpen(false)
|
|
1454
1438
|
setIsConnecting(true)
|
|
1455
1439
|
setConnectionError(null)
|
|
1456
1440
|
hasAutoConnectedRef.current = true
|
|
@@ -1509,43 +1493,13 @@ export function TrafficView({ namespaces, onSetNamespaces }: TrafficViewProps) {
|
|
|
1509
1493
|
/>
|
|
1510
1494
|
)}
|
|
1511
1495
|
{activeSource && (
|
|
1512
|
-
<
|
|
1513
|
-
{
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
<>
|
|
1520
|
-
<span className="w-2 h-2 rounded-full bg-yellow-500" />
|
|
1521
|
-
<span className="text-theme-text-secondary">{activeSource.name}</span>
|
|
1522
|
-
<button onClick={() => handleConnect(true)} className="text-yellow-500 hover:text-yellow-400 font-medium">retry</button>
|
|
1523
|
-
</>
|
|
1524
|
-
) : (
|
|
1525
|
-
<>
|
|
1526
|
-
<span className="w-2 h-2 rounded-full bg-green-500" />
|
|
1527
|
-
{availableSources.length > 1 ? (
|
|
1528
|
-
<div className="relative" ref={sourcePickerRef}>
|
|
1529
|
-
<button onClick={() => setSourcePickerOpen(!sourcePickerOpen)} className="flex items-center gap-1 text-theme-text-secondary hover:text-theme-text-primary">
|
|
1530
|
-
{activeSource.name} <ChevronDown className="h-3 w-3" />
|
|
1531
|
-
</button>
|
|
1532
|
-
{sourcePickerOpen && (
|
|
1533
|
-
<div className="absolute top-full left-0 mt-1 z-50 bg-theme-surface border border-theme-border rounded-md shadow-lg py-1 min-w-[120px]">
|
|
1534
|
-
{availableSources.map(source => (
|
|
1535
|
-
<button key={source.name} onClick={() => handleSwitchSource(source.name)}
|
|
1536
|
-
className={clsx('w-full text-left px-3 py-1 text-xs hover:bg-theme-hover capitalize', source.name === activeSource.name && 'text-blue-400')}>
|
|
1537
|
-
{source.name}
|
|
1538
|
-
</button>
|
|
1539
|
-
))}
|
|
1540
|
-
</div>
|
|
1541
|
-
)}
|
|
1542
|
-
</div>
|
|
1543
|
-
) : (
|
|
1544
|
-
<span className="text-theme-text-secondary">{activeSource.name}</span>
|
|
1545
|
-
)}
|
|
1546
|
-
</>
|
|
1547
|
-
)}
|
|
1548
|
-
</div>
|
|
1496
|
+
<TrafficSourcePill
|
|
1497
|
+
sources={availableSources.map(s => s.name)}
|
|
1498
|
+
active={activeSource.name}
|
|
1499
|
+
connection={isConnecting ? 'connecting' : connectionError ? 'error' : 'connected'}
|
|
1500
|
+
onSwitch={handleSwitchSource}
|
|
1501
|
+
onRetry={() => handleConnect(true)}
|
|
1502
|
+
/>
|
|
1549
1503
|
)}
|
|
1550
1504
|
</div>
|
|
1551
1505
|
|
|
@@ -27,6 +27,31 @@ const desktop: NonNullable<DiagnosticsSnapshot['desktop']> = {
|
|
|
27
27
|
gpuPolicy: 'on-demand',
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
describe('formatForGitHub profiling state', () => {
|
|
31
|
+
it.each([
|
|
32
|
+
[true, 'true'],
|
|
33
|
+
[false, 'false'],
|
|
34
|
+
[undefined, 'unknown'],
|
|
35
|
+
] as const)('reports %s as %s', (pprof, expected) => {
|
|
36
|
+
const md = formatForGitHub({
|
|
37
|
+
...baseSnapshot,
|
|
38
|
+
config: {
|
|
39
|
+
port: 9280,
|
|
40
|
+
devMode: false,
|
|
41
|
+
timelineStorage: 'memory',
|
|
42
|
+
historyLimit: 10000,
|
|
43
|
+
debugEvents: false,
|
|
44
|
+
mcpEnabled: true,
|
|
45
|
+
mcpReadOnly: false,
|
|
46
|
+
hasPrometheusURL: false,
|
|
47
|
+
hasPrometheusHeaders: false,
|
|
48
|
+
pprof,
|
|
49
|
+
},
|
|
50
|
+
}, undefined, false)
|
|
51
|
+
expect(md).toContain(`Pprof: ${expected}`)
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
|
|
30
55
|
describe('formatEnvValue', () => {
|
|
31
56
|
it('separates a variable that was never set from one set to empty', () => {
|
|
32
57
|
// Only the second suppresses the desktop app's own WebKit defaults, so
|
|
@@ -622,6 +622,7 @@ function ConfigSection({ data }: { data: DiagnosticsSnapshot }) {
|
|
|
622
622
|
<Section title="Config">
|
|
623
623
|
<Row label="Port" value={cfg.port} />
|
|
624
624
|
<Row label="Dev Mode" value={cfg.devMode ? 'Yes' : 'No'} />
|
|
625
|
+
<Row label="Profiling (pprof)" value={cfg.pprof === undefined ? 'Unknown' : cfg.pprof ? 'Yes' : 'No'} />
|
|
625
626
|
{cfg.namespace && <Row label="Namespace Filter" value={cfg.namespace} />}
|
|
626
627
|
<Row label="Timeline Storage" value={cfg.timelineStorage} />
|
|
627
628
|
<Row label="History Limit" value={cfg.historyLimit.toLocaleString()} />
|
|
@@ -864,7 +865,7 @@ export function formatForGitHub(data: DiagnosticsSnapshot, frontendPerf?: K8sUIP
|
|
|
864
865
|
if (data.config) {
|
|
865
866
|
const cfg = data.config
|
|
866
867
|
lines.push(`### Config`)
|
|
867
|
-
lines.push(`- Port: ${cfg.port} | Dev: ${cfg.devMode} | Timeline: \`${cfg.timelineStorage}\` | History: ${cfg.historyLimit} | MCP: ${cfg.mcpEnabled} | Prometheus URL: ${cfg.hasPrometheusURL ? 'manual' : 'auto'}`)
|
|
868
|
+
lines.push(`- Port: ${cfg.port} | Dev: ${cfg.devMode} | Pprof: ${cfg.pprof ?? 'unknown'} | Timeline: \`${cfg.timelineStorage}\` | History: ${cfg.historyLimit} | MCP: ${cfg.mcpEnabled} | Prometheus URL: ${cfg.hasPrometheusURL ? 'manual' : 'auto'}`)
|
|
868
869
|
lines.push(``)
|
|
869
870
|
}
|
|
870
871
|
|