@skyhook-io/radar-app 1.20.1 → 1.20.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/package.json +1 -1
  2. package/src/App.tsx +12 -7
  3. package/src/api/client.namespaceSwitch.hook.test.tsx +170 -1
  4. package/src/api/client.pauseDeployment.test.tsx +77 -0
  5. package/src/api/client.restartError.test.ts +14 -0
  6. package/src/api/client.revisionRefresh.test.tsx +44 -0
  7. package/src/api/client.rollbackError.test.ts +14 -0
  8. package/src/api/client.ts +218 -11
  9. package/src/api/networkAttachments.test.tsx +120 -0
  10. package/src/api/networkAttachments.ts +30 -0
  11. package/src/api/radarFeatures.test.ts +5 -0
  12. package/src/api/radarFeatures.ts +3 -0
  13. package/src/api/secretsStore.test.ts +33 -0
  14. package/src/api/secretsStore.ts +37 -0
  15. package/src/components/ConnectionErrorView.test.tsx +11 -0
  16. package/src/components/ConnectionErrorView.tsx +19 -0
  17. package/src/components/ContextSwitcher.tsx +9 -2
  18. package/src/components/applications/ApplicationsView.openResource.test.tsx +118 -0
  19. package/src/components/applications/ApplicationsView.tsx +8 -11
  20. package/src/components/cost/CostView.tsx +27 -9
  21. package/src/components/diagnose/InvestigationView.tsx +12 -3
  22. package/src/components/diagnose/investigationEvidence/adapters/helm.test.tsx +52 -0
  23. package/src/components/diagnose/investigationEvidence/adapters/helm.ts +10 -0
  24. package/src/components/diagnose/investigationEvidence/bodies/platform.tsx +82 -51
  25. package/src/components/diagnose/investigationEvidence/types.ts +5 -0
  26. package/src/components/dock/TerminalPreferences.query.test.tsx +57 -0
  27. package/src/components/dock/TerminalPreferences.test.tsx +68 -0
  28. package/src/components/dock/TerminalPreferences.tsx +73 -0
  29. package/src/components/gitops/GitOpsView.tsx +1 -9
  30. package/src/components/helm/HelmReleaseDrawer.tsx +24 -12
  31. package/src/components/helm/HelmView.tsx +5 -3
  32. package/src/components/helm/NotCheckedBadge.test.tsx +62 -0
  33. package/src/components/helm/NotCheckedBadge.tsx +39 -0
  34. package/src/components/helm/OwnedResources.test.tsx +86 -0
  35. package/src/components/helm/OwnedResources.tsx +65 -8
  36. package/src/components/home/ClusterHealthCard.heading.test.tsx +72 -0
  37. package/src/components/home/ClusterHealthCard.test.ts +44 -1
  38. package/src/components/home/ClusterHealthCard.tsx +22 -10
  39. package/src/components/home/HelmSummary.tsx +15 -15
  40. package/src/components/home/mcpToolCatalog.ts +2 -2
  41. package/src/components/resource/RightsizingStrip.test.ts +57 -0
  42. package/src/components/resource/RightsizingStrip.tsx +53 -4
  43. package/src/components/resources/ImageFilesystemModal.test.tsx +74 -6
  44. package/src/components/resources/ImageFilesystemModal.tsx +98 -6
  45. package/src/components/resources/PodFileUploadPanel.tsx +150 -0
  46. package/src/components/resources/PodFilesystemModal.tsx +246 -3
  47. package/src/components/resources/pod-file-upload.test.tsx +223 -0
  48. package/src/components/resources/pod-file-upload.ts +266 -0
  49. package/src/components/resources/renderers/HTTPRouteRenderer.test.tsx +50 -0
  50. package/src/components/resources/renderers/HTTPRouteRenderer.tsx +27 -0
  51. package/src/components/resources/renderers/PodRenderer.tsx +26 -1
  52. package/src/components/resources/renderers/SecretProviderClassRenderer.tsx +25 -0
  53. package/src/components/rightsizing/RightsizingScanView.tsx +16 -1
  54. package/src/components/rightsizing/model.test.ts +11 -0
  55. package/src/components/rightsizing/model.ts +3 -1
  56. package/src/components/rightsizing/presentation.test.ts +46 -0
  57. package/src/components/rightsizing/presentation.ts +17 -2
  58. package/src/components/traffic/TrafficView.tsx +27 -27
  59. package/src/components/traffic/trafficFilters.test.ts +18 -1
  60. package/src/components/traffic/trafficFilters.ts +30 -1
  61. package/src/components/ui/Omnibar.tsx +4 -1
  62. package/src/components/ui/RadarOmnibar.test.tsx +55 -2
  63. package/src/components/ui/RadarOmnibar.tsx +7 -1
  64. package/src/components/ui/SearchSyntaxHelp.test.tsx +9 -2
  65. package/src/components/ui/SearchSyntaxHelp.tsx +3 -2
  66. package/src/components/ui/UpdateNotification.test.tsx +23 -1
  67. package/src/components/ui/UpdateNotification.tsx +26 -2
  68. package/src/components/ui/omnibar-match.test.ts +7 -0
  69. package/src/components/ui/omnibar-match.ts +1 -0
  70. package/src/components/ui/searchCoverageNote.test.ts +17 -0
  71. package/src/components/ui/searchCoverageNote.ts +31 -7
  72. package/src/components/useContextSwitchFlow.tsx +9 -1
  73. package/src/components/workload/NodeCertificateEvidence.test.tsx +51 -0
  74. package/src/components/workload/NodeCertificateEvidence.tsx +44 -0
  75. package/src/components/workload/WorkloadView.tsx +51 -11
  76. package/src/context/ConnectionContext.test.ts +1 -0
  77. package/src/context/ConnectionContext.tsx +2 -2
  78. package/src/integrations/resourceHosts.test.tsx +2 -2
  79. package/src/integrations/resourceHosts.tsx +4 -0
  80. package/src/utils/namespacePick.test.ts +87 -0
  81. package/src/utils/namespacePick.ts +88 -0
@@ -7,6 +7,7 @@ import { useContexts, useClusterInfo, useCapabilities } from '../api/client'
7
7
  import type { ContextInfo } from '../types'
8
8
  import { useContextSwitchFlow } from './useContextSwitchFlow'
9
9
  import { useContextSwitch } from '../context/ContextSwitchContext'
10
+ import { useConnection } from '../context/ConnectionContext'
10
11
  import { parseContextForSwitcher, visibleContextQualifier, type ParsedContextName } from '../utils/context-name'
11
12
 
12
13
  interface ContextSwitcherProps {
@@ -31,6 +32,10 @@ export const ContextSwitcher = forwardRef<ContextSwitcherHandle, ContextSwitcher
31
32
  const { data: capabilities } = useCapabilities()
32
33
  const switchFlow = useContextSwitchFlow()
33
34
  const { failedSwitch } = useContextSwitch()
35
+ // A settings error (Desktop's namespace list over the limit) blocks every
36
+ // switch until restart, so offering the list would only lead to a refusal.
37
+ const { connection } = useConnection()
38
+ const settingsBlocked = connection.errorType === 'settings'
34
39
 
35
40
  // Parse contexts and decide whether to render group headers (multi-account only).
36
41
  // hasMultipleSources gates the kubeconfig-source chip — only useful when 2+
@@ -80,7 +85,9 @@ export const ContextSwitcher = forwardRef<ContextSwitcherHandle, ContextSwitcher
80
85
  id: p.context.name,
81
86
  name: p.raw,
82
87
  nameQualifier: visibleContextQualifier(p.nameQualifier, p.context.source, hasMultipleSources),
83
- secondary: p.provider ? p.raw : undefined,
88
+ // The full context under any shortened name: OpenShift writes one context
89
+ // per project for the same server, and only this line tells them apart.
90
+ secondary: p.raw !== p.clusterName ? p.raw : undefined,
84
91
  badge: p.region || undefined,
85
92
  sourceLabel: hasMultipleSources ? p.context.source : undefined,
86
93
  group: { key: groupKey, label: groupLabel },
@@ -134,7 +141,7 @@ export const ContextSwitcher = forwardRef<ContextSwitcherHandle, ContextSwitcher
134
141
  items={items}
135
142
  onSelect={handleSelect}
136
143
  loading={switchFlow.isPending}
137
- disabled={contextsLoading || !capabilities || capabilities.configManagement === 'operator'}
144
+ disabled={settingsBlocked || contextsLoading || !capabilities || capabilities.configManagement === 'operator'}
138
145
  searchable={items.length > 1}
139
146
  currentSelectable={!!failedSwitch}
140
147
  showGroupHeaders={hasMultipleAccounts}
@@ -0,0 +1,118 @@
1
+ // @vitest-environment jsdom
2
+ import { act, useEffect } from 'react'
3
+ import { createRoot } from 'react-dom/client'
4
+ import { MemoryRouter, useLocation } from 'react-router-dom'
5
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
6
+ import { afterEach, beforeEach, expect, it, vi } from 'vitest'
7
+ import { ToastProvider, type AppRow, type AppWorkload, type SelectedResource } from '@skyhook-io/k8s-ui'
8
+ import { ApplicationsView } from './ApplicationsView'
9
+
10
+ let apps: AppRow[] = []
11
+ const idle = { data: undefined, isLoading: false, isError: false, error: null }
12
+
13
+ vi.mock('../../api/client', () => ({
14
+ useApplications: () => ({ ...idle, data: { applications: apps }, isSuccess: true, dataUpdatedAt: 0, refetch: () => {} }),
15
+ useApplicationHistory: () => idle,
16
+ useGitOpsTree: () => idle,
17
+ useHelmRelease: () => idle,
18
+ useIssues: () => idle,
19
+ useTopology: () => idle,
20
+ }))
21
+ vi.mock('../../context/ConnectionContext', () => ({ useConnection: () => ({ connection: { state: 'connected', context: 'test' } }) }))
22
+ vi.mock('../../context/TimelineSource', () => ({
23
+ useTimelineSource: () => ({ capabilities: { mode: 'local' }, useEvents: () => ({ data: [], isLoading: false, isError: false }) }),
24
+ }))
25
+ // The workload view's own content is out of scope here: the stub stands in for
26
+ // any resource the user clicks inside it (a config chip or a topology node).
27
+ vi.mock('../workload/WorkloadView', () => ({
28
+ WorkloadView: ({ name, onNavigateToResource }: { name: string; onNavigateToResource: (r: SelectedResource) => void }) => (
29
+ <div data-testid="workload-view" data-name={name}>
30
+ <button data-testid="open-cm" onClick={() => onNavigateToResource({ kind: 'ConfigMap', namespace: 'shop', name: 'web-config' })} />
31
+ <button data-testid="open-ing" onClick={() => onNavigateToResource({ kind: 'Ingress', namespace: 'shop', name: 'web', group: 'networking.k8s.io' })} />
32
+ </div>
33
+ ),
34
+ }))
35
+ vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
36
+
37
+ function deployment(name: string): AppWorkload {
38
+ return { kind: 'Deployment', group: 'apps', namespace: 'shop', name, health: 'healthy', ready: 1, desired: 1, restarts: 0 }
39
+ }
40
+
41
+ function app(key: string, workloadNames: string[]): AppRow {
42
+ return { key, name: key.split('/').pop() ?? key, namespace: 'shop', health: 'healthy', workloads: workloadNames.map(deployment) }
43
+ }
44
+
45
+ let root: ReturnType<typeof createRoot>
46
+ let container: HTMLDivElement
47
+ let client: QueryClient
48
+ let location = ''
49
+
50
+ function recordLocation(next: string) {
51
+ location = next
52
+ }
53
+
54
+ function LocationProbe({ onChange }: { onChange: (location: string) => void }) {
55
+ const loc = useLocation()
56
+ useEffect(() => onChange(`${loc.pathname}${loc.search}`), [loc, onChange])
57
+ return null
58
+ }
59
+
60
+ beforeEach(() => {
61
+ vi.stubGlobal('matchMedia', () => ({ matches: false, addEventListener: () => {}, removeEventListener: () => {} }))
62
+ container = document.createElement('div')
63
+ document.body.appendChild(container)
64
+ root = createRoot(container)
65
+ client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
66
+ })
67
+
68
+ afterEach(async () => {
69
+ await act(async () => root.unmount())
70
+ container.remove()
71
+ client.clear()
72
+ vi.unstubAllGlobals()
73
+ vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
74
+ })
75
+
76
+ async function renderAt(url: string, onOpenResource = vi.fn()) {
77
+ await act(async () => {
78
+ root.render(
79
+ <QueryClientProvider client={client}>
80
+ <ToastProvider>
81
+ <MemoryRouter initialEntries={[url]}>
82
+ <ApplicationsView namespaces={[]} onOpenResource={onOpenResource} />
83
+ <LocationProbe onChange={recordLocation} />
84
+ </MemoryRouter>
85
+ </ToastProvider>
86
+ </QueryClientProvider>,
87
+ )
88
+ })
89
+ await act(async () => { await new Promise((resolve) => setTimeout(resolve, 0)) })
90
+ return onOpenResource
91
+ }
92
+
93
+ async function click(testId: string) {
94
+ const button = container.querySelector(`[data-testid="${testId}"]`)
95
+ if (!(button instanceof HTMLElement)) throw new Error(`no ${testId} in the workload view`)
96
+ await act(async () => button.click())
97
+ }
98
+
99
+ it('opens a ConfigMap clicked in a single-workload app on its resource page', async () => {
100
+ apps = [app('shop/Deployment/web', ['web'])]
101
+ await renderAt('/applications?app=shop%2FDeployment%2Fweb&tab=topology')
102
+ await click('open-cm')
103
+ const url = new URL(location, 'http://radar.invalid')
104
+ expect(url.pathname).toBe('/resources/configmaps')
105
+ expect(url.searchParams.get('resource')).toBe('shop/web-config')
106
+ })
107
+
108
+ it('keeps the API group, namespace filter and open investigation when opening an Ingress from a single-workload app', async () => {
109
+ apps = [app('shop/Deployment/web', ['web'])]
110
+ await renderAt('/applications?app=shop%2FDeployment%2Fweb&namespaces=shop&ai-run=run-1')
111
+ await click('open-ing')
112
+ const url = new URL(location, 'http://radar.invalid')
113
+ expect(url.pathname).toBe('/resources/ingresses')
114
+ expect(url.searchParams.get('resource')).toBe('shop/web')
115
+ expect(url.searchParams.get('apiGroup')).toBe('networking.k8s.io')
116
+ expect(url.searchParams.get('namespaces')).toBe('shop')
117
+ expect(url.searchParams.get('ai-run')).toBe('run-1')
118
+ })
@@ -52,7 +52,7 @@ import {
52
52
  } from "../../api/client";
53
53
  import { useConnection } from "../../context/ConnectionContext";
54
54
  import { useTimelineSource } from "../../context/TimelineSource";
55
- import { apiVersionToGroup, buildWorkloadPath, kindToPluralWithGroup } from "../../utils/navigation";
55
+ import { apiVersionToGroup, kindToPluralWithGroup, relatedResourcePath, withCrossViewParams } from "../../utils/navigation";
56
56
  import { WorkloadView } from "../workload/WorkloadView";
57
57
  import { ApplicationCostTab } from "../cost/ApplicationCostTab";
58
58
  import { useTimelineRetentionNote } from "../../context/TimelineCustomization";
@@ -484,21 +484,18 @@ function AppDetailRoute({
484
484
  const openWorkloadResource = useCallback(
485
485
  (resource: SelectedResource) => {
486
486
  const pluralKind = kindToPluralWithGroup(resource.kind, resource.group ?? "")
487
- if (pluralKind.toLowerCase() !== "pods") {
487
+ // The peek never covers the inline workload view: opening it drops
488
+ // ?workload so the app overview sits behind it. A single-workload app
489
+ // has no app overview and puts ?workload straight back, which would hide
490
+ // the peek, so its resources open on their own page instead.
491
+ if (pluralKind.toLowerCase() !== "pods" && !singleWorkloadKey) {
488
492
  onOpenResource(resource);
489
493
  return;
490
494
  }
491
495
 
492
- const [pathname, rawSearch = ""] = buildWorkloadPath({
493
- ...resource,
494
- kind: pluralKind,
495
- }).split("?");
496
- const params = new URLSearchParams(rawSearch);
497
- const activeNamespaces = searchParams.get("namespaces");
498
- if (activeNamespaces) params.set("namespaces", activeNamespaces);
499
- navigate({ pathname, search: params.toString() });
496
+ navigate(withCrossViewParams(relatedResourcePath(resource), searchParams.toString()));
500
497
  },
501
- [navigate, onOpenResource, searchParams],
498
+ [navigate, onOpenResource, searchParams, singleWorkloadKey],
502
499
  );
503
500
  const openSource = useCallback(
504
501
  (source: AppSourceRef) => {
@@ -57,6 +57,8 @@ interface CostViewProps {
57
57
  }
58
58
 
59
59
  const SYSTEM_COST_NAMESPACES = new Set(['kube-system', 'kube-public', 'kube-node-lease'])
60
+ const STORAGE_UNKNOWN_HINT =
61
+ "Storage cost couldn't be calculated, so totals here leave it out. It needs volume sizes in Prometheus: kube_persistentvolume_capacity_bytes from kube-state-metrics."
60
62
 
61
63
  export function CostView(props: CostViewProps) {
62
64
  const { pathname } = useLocation()
@@ -170,7 +172,8 @@ function CostOverview({ onBack, onOpenResource }: CostViewProps) {
170
172
  const totalCpu = namespaces.reduce((sum, ns) => sum + ns.cpuCost, 0)
171
173
  const totalMem = namespaces.reduce((sum, ns) => sum + ns.memoryCost, 0)
172
174
  const totalStorage = data.totalStorageCost ?? 0
173
- const hasStorage = totalStorage > 0
175
+ const storageUnknown = data.totalStorageCost === null
176
+ const hasStorage = namespaces.some((ns) => (ns.storageCost ?? 0) > 0)
174
177
  const hasSystemNamespaces = namespaces.some((ns) => isSystemCostNamespace(ns.name))
175
178
 
176
179
  // Compute split percentages (CPU + Memory + optional Storage)
@@ -277,11 +280,20 @@ function CostOverview({ onBack, onOpenResource }: CostViewProps) {
277
280
  <span className="w-2.5 h-2.5 rounded-sm bg-amber-500" />
278
281
  Memory {formatProjectedMonthlyRate(totalMem, currency)}
279
282
  </span>
280
- {hasStorage && (
281
- <span className="flex items-center gap-1.5">
282
- <span className="w-2.5 h-2.5 rounded-sm bg-teal-500" />
283
- Storage {formatProjectedMonthlyRate(totalStorage, currency)}
284
- </span>
283
+ {storageUnknown ? (
284
+ <Tooltip content={STORAGE_UNKNOWN_HINT}>
285
+ <span className="flex items-center gap-1.5 cursor-help">
286
+ <span className="w-2.5 h-2.5 rounded-sm bg-teal-500" />
287
+ Storage unknown
288
+ </span>
289
+ </Tooltip>
290
+ ) : (
291
+ hasStorage && (
292
+ <span className="flex items-center gap-1.5">
293
+ <span className="w-2.5 h-2.5 rounded-sm bg-teal-500" />
294
+ Storage {formatProjectedMonthlyRate(totalStorage, currency)}
295
+ </span>
296
+ )
285
297
  )}
286
298
  </div>
287
299
  </div>
@@ -294,7 +306,7 @@ function CostOverview({ onBack, onOpenResource }: CostViewProps) {
294
306
  className="h-full bg-amber-500 transition-all duration-300"
295
307
  style={{ width: `${memPct}%` }}
296
308
  />
297
- {hasStorage && (
309
+ {hasStorage && !storageUnknown && (
298
310
  <div
299
311
  className="h-full bg-teal-500 transition-all duration-300"
300
312
  style={{ width: `${storagePct}%` }}
@@ -492,9 +504,15 @@ function NamespaceCostRow({
492
504
  <span className="text-[11px] text-theme-text-tertiary tabular-nums text-right">
493
505
  {formatProjectedMonthlyCost(ns.cpuCost, currency)} /{' '}
494
506
  {formatProjectedMonthlyCost(ns.memoryCost, currency)}
495
- {hasStorage &&
507
+ {ns.storageCost === null ? (
508
+ <Tooltip content={STORAGE_UNKNOWN_HINT}>
509
+ <span className="cursor-help"> / storage unknown</span>
510
+ </Tooltip>
511
+ ) : (
512
+ hasStorage &&
496
513
  (ns.storageCost ?? 0) > 0 &&
497
- ` / ${formatProjectedMonthlyCost(ns.storageCost ?? 0, currency)}`}
514
+ ` / ${formatProjectedMonthlyCost(ns.storageCost ?? 0, currency)}`
515
+ )}
498
516
  </span>
499
517
  </button>
500
518
 
@@ -128,6 +128,7 @@ import {
128
128
  rerunOpening,
129
129
  } from "./target";
130
130
  import { parseContextName } from "../../utils/context-name";
131
+ import { Tooltip } from "../ui/Tooltip";
131
132
  import type { InvestigationSourceExcerpt } from "./investigationSourceFocus";
132
133
  import { diagnosisHasStoryShape } from "./investigationStory";
133
134
  import { assessmentStateLabel, verdictSentence } from "./verdictText";
@@ -2012,9 +2013,17 @@ export function InvestigationView({
2012
2013
  <AlertTriangle className="h-4 w-4 shrink-0 text-amber-500" />
2013
2014
  <span className="min-w-0 flex-1">
2014
2015
  This investigation ran on{" "}
2015
- <span className="font-medium text-theme-text-primary">
2016
- {parseContextName(run.context).clusterName}
2017
- </span>
2016
+ <Tooltip
2017
+ content={
2018
+ parseContextName(run.context).clusterName !== run.context
2019
+ ? run.context
2020
+ : ""
2021
+ }
2022
+ >
2023
+ <span className="font-medium text-theme-text-primary">
2024
+ {parseContextName(run.context).clusterName}
2025
+ </span>
2026
+ </Tooltip>
2018
2027
  . It is read-only because its agent session was closed after a
2019
2028
  cluster switch.
2020
2029
  </span>
@@ -3,6 +3,7 @@ import { investigationEvidenceSubjectRef } from "../index";
3
3
  import { groupsOf, project, tool } from "../evidenceFixtures";
4
4
  import { renderToStaticMarkup } from "react-dom/server";
5
5
  import { HelmBody } from "../bodies/platform";
6
+ import { EvidenceNavigationContext } from "../navigation";
6
7
 
7
8
  const helmRelease = {
8
9
  name: "shop",
@@ -302,4 +303,55 @@ describe("helm release card detail", () => {
302
303
  expect(html).toContain("{ color, message }");
303
304
  expect(html).toContain("[2 items]");
304
305
  });
306
+
307
+ it("says how many objects were not checked and does not link them", () => {
308
+ const projection = project([
309
+ tool(
310
+ "helm",
311
+ "get_helm_release",
312
+ {
313
+ ...helmRelease,
314
+ resourceHealth: "unknown",
315
+ statusUnreadCount: 1,
316
+ resources: [
317
+ helmRelease.resources[1],
318
+ {
319
+ kind: "Deployment",
320
+ apiVersion: "apps/v1",
321
+ name: "worker",
322
+ namespace: "shared",
323
+ statusUnread: "user_namespace_not_visible",
324
+ },
325
+ ],
326
+ },
327
+ { summary: JSON.stringify({ namespace: "shop", name: "shop" }) },
328
+ ),
329
+ ]);
330
+ const [group] = groupsOf(projection.groups, "helm");
331
+ const data = group.latest.data;
332
+ if (data.type !== "helm") throw new Error("expected a helm card");
333
+ expect(data.release.statusUnreadCount).toBe(1);
334
+ const html = renderToStaticMarkup(
335
+ <EvidenceNavigationContext.Provider value={{ onOpenResource: () => {} }}>
336
+ <HelmBody data={data} />
337
+ </EvidenceNavigationContext.Provider>,
338
+ );
339
+ expect(html).toContain("1 not checked");
340
+ expect(html).toContain("No access");
341
+ expect(html.match(/<button[^>]*>[^<]*shop\/api/)).not.toBeNull();
342
+ expect(html.match(/<button[^>]*>[^<]*shared\/worker/)).toBeNull();
343
+ });
344
+ it("shows Flux ownership without exposing or linking a hidden controller", () => {
345
+ const projection = project([tool("helm", "get_helm_release", {...helmRelease, managedByFlux: true})]);
346
+ const [group] = groupsOf(projection.groups, "helm");
347
+ const data = group.latest.data;
348
+ if (data.type !== "helm") throw new Error("expected a helm card");
349
+ expect(data.release.managedByFlux).toBe(true);
350
+ expect(data.release.managedByFluxHelmRelease).toBeUndefined();
351
+ const html = renderToStaticMarkup(<HelmBody data={data} />);
352
+ expect(html).toContain("Managed by Flux");
353
+ expect(html).not.toContain("undefined");
354
+ expect(html).not.toContain("private-manager");
355
+ });
356
+
305
357
  });
@@ -36,6 +36,7 @@ function helmOwnedResource(
36
36
  "message",
37
37
  "summary",
38
38
  "issue",
39
+ "statusUnread",
39
40
  ] as const) {
40
41
  if (candidate[field] !== undefined && typeof candidate[field] !== "string")
41
42
  return undefined;
@@ -207,6 +208,10 @@ export function adaptHelmRelease(
207
208
  return;
208
209
  }
209
210
  }
211
+ if (value.managedByFlux !== undefined && typeof value.managedByFlux !== "boolean") {
212
+ invalidPayload(builder, source);
213
+ return;
214
+ }
210
215
  const resourcesRaw =
211
216
  value.resources === undefined || value.resources === null
212
217
  ? []
@@ -249,6 +254,11 @@ export function adaptHelmRelease(
249
254
  resourceHealth: value.resourceHealth as string | undefined,
250
255
  healthIssue: value.healthIssue as string | undefined,
251
256
  healthSummary: value.healthSummary as string | undefined,
257
+ ...(typeof value.statusUnreadCount === "number" &&
258
+ value.statusUnreadCount > 0
259
+ ? { statusUnreadCount: value.statusUnreadCount }
260
+ : {}),
261
+ ...(value.managedByFlux === true ? { managedByFlux: true } : {}),
252
262
  managedByFluxHelmRelease: value.managedByFluxHelmRelease as
253
263
  string | undefined,
254
264
  lastOperation,
@@ -8,6 +8,8 @@ import {
8
8
  ResourceLink,
9
9
  } from "@skyhook-io/k8s-ui";
10
10
  import { apiVersionToGroup } from "../../../../utils/navigation";
11
+ import { readActionFor } from "@skyhook-io/k8s-ui/utils/read-actions";
12
+ import { notCheckedTooltip } from "../../../helm/NotCheckedBadge";
11
13
  import { Tooltip } from "../../../ui/Tooltip";
12
14
  import { EvidenceNavigationContext } from "../navigation";
13
15
  import { type EvidenceDataOf, ResourceFact, severityBadge } from "../cardParts";
@@ -67,6 +69,20 @@ export function HelmBody({ data }: { data: EvidenceDataOf<"helm"> }) {
67
69
  resources {release.resourceHealth}
68
70
  </Badge>
69
71
  ) : null}
72
+ {release.statusUnreadCount ? (
73
+ <Tooltip
74
+ content={
75
+ <div className="max-w-xs">
76
+ {notCheckedTooltip(release.statusUnreadCount, "either", "health")}
77
+ </div>
78
+ }
79
+ delay={150}
80
+ >
81
+ <Badge severity="neutral" size="sm">
82
+ {release.statusUnreadCount} not checked
83
+ </Badge>
84
+ </Tooltip>
85
+ ) : null}
70
86
  <Tooltip
71
87
  content={new Date(release.updated).toLocaleString()}
72
88
  delay={150}
@@ -132,9 +148,9 @@ export function HelmBody({ data }: { data: EvidenceDataOf<"helm"> }) {
132
148
  Release metadata stored in namespace {release.storageNamespace}
133
149
  </p>
134
150
  ) : null}
135
- {release.managedByFluxHelmRelease ? (
151
+ {release.managedByFlux || release.managedByFluxHelmRelease ? (
136
152
  <p className="text-xs text-theme-text-tertiary">
137
- Managed by Flux HelmRelease {release.managedByFluxHelmRelease}
153
+ Managed by Flux{release.managedByFluxHelmRelease ? ` HelmRelease ${release.managedByFluxHelmRelease}` : ''}
138
154
  </p>
139
155
  ) : null}
140
156
  {release.hooks && release.hooks.length > 0 ? (
@@ -244,59 +260,74 @@ export function HelmBody({ data }: { data: EvidenceDataOf<"helm"> }) {
244
260
  ) : null}
245
261
  {release.resources.length > 0 ? (
246
262
  <div className="max-h-52 overflow-y-auto rounded-md border border-theme-border">
247
- {release.resources.map((owned, index) => (
248
- <div
249
- key={`${owned.kind}-${owned.namespace}-${owned.name}`}
250
- className={clsx(
251
- "flex min-w-0 items-center gap-2 px-2.5 py-1.5",
252
- index > 0 && "border-t border-theme-border/60",
253
- )}
254
- >
255
- <StatusDot
256
- tone={mapHealthToTone(
257
- owned.issue ? "unhealthy" : (owned.status ?? ""),
263
+ {release.resources.map((owned, index) => {
264
+ const unread = owned.statusUnread
265
+ ? readActionFor(owned.statusUnread) === "retry"
266
+ ? "Not checked"
267
+ : "No access"
268
+ : undefined;
269
+ return (
270
+ <div
271
+ key={`${owned.kind}-${owned.namespace}-${owned.name}`}
272
+ className={clsx(
273
+ "flex min-w-0 items-center gap-2 px-2.5 py-1.5",
274
+ index > 0 && "border-t border-theme-border/60",
258
275
  )}
259
- className="shrink-0"
260
- />
261
- <Badge tone="structural" size="sm">
262
- {owned.kind}
263
- </Badge>
264
- <span className="min-w-0 flex-1">
265
- <span className="block truncate font-mono text-xs">
266
- <ResourceLink
267
- name={owned.name}
268
- kind={owned.kind}
269
- namespace={owned.namespace}
270
- group={
271
- owned.apiVersion
272
- ? apiVersionToGroup(owned.apiVersion)
273
- : undefined
274
- }
275
- label={`${owned.namespace ? `${owned.namespace}/` : ""}${owned.name}`}
276
- onNavigate={
277
- owned.apiVersion && onOpenResource
278
- ? (ref) => onOpenResource(ref)
279
- : undefined
280
- }
281
- />
282
- </span>
283
- {owned.issue ? (
284
- <span className="block truncate text-xs text-warning-text">
285
- {owned.issue}
276
+ >
277
+ <StatusDot
278
+ tone={mapHealthToTone(
279
+ owned.issue ? "unhealthy" : (owned.status ?? ""),
280
+ )}
281
+ className="shrink-0"
282
+ />
283
+ <Badge tone="structural" size="sm">
284
+ {owned.kind}
285
+ </Badge>
286
+ <span className="min-w-0 flex-1">
287
+ <span className="block truncate font-mono text-xs">
288
+ <ResourceLink
289
+ name={owned.name}
290
+ kind={owned.kind}
291
+ namespace={owned.namespace}
292
+ group={
293
+ owned.apiVersion
294
+ ? apiVersionToGroup(owned.apiVersion)
295
+ : undefined
296
+ }
297
+ label={`${owned.namespace ? `${owned.namespace}/` : ""}${owned.name}`}
298
+ onNavigate={
299
+ owned.apiVersion && onOpenResource && !unread
300
+ ? (ref) => onOpenResource(ref)
301
+ : undefined
302
+ }
303
+ />
286
304
  </span>
287
- ) : owned.summary || owned.message ? (
288
- <span className="block truncate text-xs text-theme-text-tertiary">
289
- {owned.summary || owned.message}
305
+ {owned.issue ? (
306
+ <span className="block truncate text-xs text-warning-text">
307
+ {owned.issue}
308
+ </span>
309
+ ) : owned.summary || owned.message ? (
310
+ <span className="block truncate text-xs text-theme-text-tertiary">
311
+ {owned.summary || owned.message}
312
+ </span>
313
+ ) : null}
314
+ </span>
315
+ {unread ? (
316
+ <Badge
317
+ severity="neutral"
318
+ size="sm"
319
+ className="ml-auto shrink-0"
320
+ >
321
+ {unread}
322
+ </Badge>
323
+ ) : owned.ready || owned.status ? (
324
+ <span className="ml-auto shrink-0 font-mono text-xs text-theme-text-tertiary">
325
+ {owned.ready || owned.status}
290
326
  </span>
291
327
  ) : null}
292
- </span>
293
- {owned.ready || owned.status ? (
294
- <span className="ml-auto shrink-0 font-mono text-xs text-theme-text-tertiary">
295
- {owned.ready || owned.status}
296
- </span>
297
- ) : null}
298
- </div>
299
- ))}
328
+ </div>
329
+ );
330
+ })}
300
331
  </div>
301
332
  ) : null}
302
333
  </div>
@@ -264,6 +264,8 @@ export interface InvestigationHelmOwnedResource {
264
264
  message?: string;
265
265
  summary?: string;
266
266
  issue?: string;
267
+ /** Why the caller isn't shown this object's live status (a read code). */
268
+ statusUnread?: string;
267
269
  }
268
270
  export interface InvestigationHelmRelease {
269
271
  name: string;
@@ -280,6 +282,9 @@ export interface InvestigationHelmRelease {
280
282
  resourceHealth?: string;
281
283
  healthIssue?: string;
282
284
  healthSummary?: string;
285
+ /** Workloads and Pods whose live status wasn't read. */
286
+ statusUnreadCount?: number;
287
+ managedByFlux?: boolean;
283
288
  managedByFluxHelmRelease?: string;
284
289
  lastOperation?: InvestigationHelmOperation;
285
290
  resources: InvestigationHelmOwnedResource[];
@@ -0,0 +1,57 @@
1
+ // @vitest-environment jsdom
2
+ import { act } from 'react'
3
+ import { createRoot } from 'react-dom/client'
4
+ import { QueryClient, QueryClientProvider, useQuery } from '@tanstack/react-query'
5
+ import { expect, it, vi } from 'vitest'
6
+ import { useTerminalCopyOnSelect } from '../../../../packages/k8s-ui/src/components/dock/terminalPreferences'
7
+ import { TerminalPreferences } from './TerminalPreferences'
8
+
9
+ const { request } = vi.hoisted(() => ({ request: vi.fn<(signal: AbortSignal) => Promise<{ authEnabled: boolean; username: string }>>() }))
10
+ vi.mock('../../api/client', () => ({
11
+ useAuthMe: () => useQuery({
12
+ queryKey: ['auth-me'], queryFn: ({ signal }) => request(signal), staleTime: 300000,
13
+ }),
14
+ }))
15
+ Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
16
+
17
+ it('does not verify cached success when removeQueries cancels an account recheck', async () => {
18
+ const responses: Array<(value: { authEnabled: boolean; username: string }) => void> = []
19
+ request.mockImplementation((signal: AbortSignal) => new Promise((resolve, reject) => {
20
+ responses.push(resolve)
21
+ signal.addEventListener('abort', () => reject(new DOMException('Aborted', 'AbortError')), { once: true })
22
+ }))
23
+ let clock = 1000
24
+ const now = vi.spyOn(Date, 'now').mockImplementation(() => clock)
25
+ const client = new QueryClient({ defaultOptions: { queries: { retry: false, refetchOnWindowFocus: false } } })
26
+ client.setQueryData(['auth-me'], { authEnabled: true, username: 'owned-query-a' })
27
+ localStorage.setItem('radar:terminal:copy-on-select:account:owned-query-a', 'true')
28
+ const root = createRoot(document.createElement('div'))
29
+ let preference: ReturnType<typeof useTerminalCopyOnSelect> | undefined
30
+ function Terminal() { preference = useTerminalCopyOnSelect(); return null }
31
+ try {
32
+ await act(async () => root.render(<QueryClientProvider client={client}><TerminalPreferences><Terminal /></TerminalPreferences></QueryClientProvider>))
33
+ clock = 2000
34
+ await act(async () => responses.shift()?.({ authEnabled: true, username: 'owned-query-a' }))
35
+ expect(preference?.getState()).toBe('on')
36
+ clock = 3000
37
+ await act(async () => window.dispatchEvent(new Event('focus')))
38
+ expect(preference?.getState()).toBe('pending')
39
+ expect(request).toHaveBeenCalledTimes(2)
40
+ clock = 3100
41
+ await act(async () => client.removeQueries({ queryKey: ['auth-me'] }))
42
+ expect(preference?.getState()).toBe('pending')
43
+ expect(preference?.available).toBe(false)
44
+ expect(request.mock.calls.length).toBeGreaterThanOrEqual(3)
45
+ responses.shift()
46
+ clock = 4000
47
+ await act(async () => responses.shift()?.({ authEnabled: true, username: 'owned-query-b' }))
48
+ expect(preference?.available).toBe(true)
49
+ expect(preference?.getState()).toBe('off')
50
+ } finally {
51
+ await act(async () => root.unmount())
52
+ client.clear()
53
+ now.mockRestore()
54
+ request.mockReset()
55
+ localStorage.clear()
56
+ }
57
+ })