@skyhook-io/radar-app 1.18.1 → 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.
Files changed (72) hide show
  1. package/package.json +1 -1
  2. package/src/App.tsx +23 -8
  3. package/src/api/client.deleteResource.test.tsx +111 -0
  4. package/src/api/client.resourceAudit.test.tsx +57 -0
  5. package/src/api/client.resourcePath.test.ts +107 -0
  6. package/src/api/client.ts +136 -37
  7. package/src/components/capacity/CapacityDemand.tsx +6 -3
  8. package/src/components/capacity/CapacityOverview.tsx +14 -7
  9. package/src/components/capacity/CapacityPoolDetail.tsx +7 -5
  10. package/src/components/capacity/ClusterSchedulingCard.tsx +3 -3
  11. package/src/components/capacity/shared.tsx +9 -5
  12. package/src/components/cnpg/CNPGOverview.tsx +4 -1
  13. package/src/components/cnpg/actions/useCNPGWriteGuard.tsx +1 -0
  14. package/src/components/diagnose/ApplyDialog.test.tsx +10 -0
  15. package/src/components/diagnose/ApplyDialog.tsx +8 -1
  16. package/src/components/diagnose/AssessmentCard.tsx +60 -0
  17. package/src/components/diagnose/DiagnoseSurface.tsx +5 -0
  18. package/src/components/diagnose/InvestigationEvidencePane.test.tsx +62 -2
  19. package/src/components/diagnose/InvestigationEvidenceSections.tsx +6 -5
  20. package/src/components/diagnose/InvestigationView.tsx +47 -13
  21. package/src/components/diagnose/assessmentCopy.ts +11 -0
  22. package/src/components/diagnose/investigationEvidence/adapters/changes.ts +36 -1
  23. package/src/components/diagnose/investigationEvidence/adapters/crossplane.test.tsx +85 -0
  24. package/src/components/diagnose/investigationEvidence/adapters/issues.ts +1 -0
  25. package/src/components/diagnose/investigationEvidence/adapters/prometheus.test.ts +2 -1
  26. package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +2 -1
  27. package/src/components/diagnose/investigationEvidence/adapters/testdata/crossplane-paused-get-resource.json +28 -0
  28. package/src/components/diagnose/investigationEvidence/bodies/index.tsx +2 -0
  29. package/src/components/diagnose/investigationEvidence/bodies/workload.tsx +5 -1
  30. package/src/components/diagnose/investigationEvidence/builder.ts +3 -1
  31. package/src/components/diagnose/investigationEvidence/cardParts.tsx +7 -2
  32. package/src/components/diagnose/investigationEvidence/identity.test.ts +1 -1
  33. package/src/components/diagnose/investigationEvidence/observations.ts +7 -3
  34. package/src/components/diagnose/investigationEvidence/projection.test.ts +57 -3
  35. package/src/components/diagnose/investigationEvidencePresentation.test.ts +36 -2
  36. package/src/components/diagnose/investigationEvidencePresentation.ts +33 -8
  37. package/src/components/diagnose/storyParts.test.tsx +53 -0
  38. package/src/components/helm/ChartBrowser.tsx +4 -4
  39. package/src/components/helm/HelmReleaseDrawer.tsx +6 -2
  40. package/src/components/helm/HelmView.tsx +34 -23
  41. package/src/components/helm/InstallWizard.tsx +6 -2
  42. package/src/components/helm/ValuesViewer.test.tsx +1 -0
  43. package/src/components/helm/ValuesViewer.tsx +4 -2
  44. package/src/components/home/ClusterHealthCard.tsx +28 -21
  45. package/src/components/home/MCPSetupDialog.test.tsx +27 -2
  46. package/src/components/home/MCPSetupDialog.tsx +14 -2
  47. package/src/components/home/mcpToolCatalog.ts +29 -2
  48. package/src/components/issues/IssuesPane.render.test.tsx +5 -5
  49. package/src/components/nav/PrimaryNavRail.tsx +34 -2
  50. package/src/components/product-hunt/ProductHuntNotice.render.test.tsx +120 -0
  51. package/src/components/product-hunt/ProductHuntNotice.test.ts +121 -0
  52. package/src/components/product-hunt/ProductHuntNotice.tsx +202 -0
  53. package/src/components/product-hunt/launchWindow.ts +78 -0
  54. package/src/components/product-hunt/useProductHuntRailEntry.test.tsx +76 -0
  55. package/src/components/product-hunt/useProductHuntRailEntry.ts +27 -0
  56. package/src/components/resources/CompositeRenderer.tsx +4 -0
  57. package/src/components/resources/ResourcesView.tsx +1 -1
  58. package/src/components/settings/LocalConnectionSettings.tsx +1 -0
  59. package/src/components/ui/RadarOmnibar.test.tsx +18 -0
  60. package/src/components/ui/RadarOmnibar.tsx +1 -0
  61. package/src/components/ui/SearchSyntaxHelp.test.tsx +39 -0
  62. package/src/components/ui/SearchSyntaxHelp.tsx +23 -2
  63. package/src/components/ui/UpdateNotification.test.tsx +2 -0
  64. package/src/components/ui/UpdateNotification.tsx +32 -5
  65. package/src/components/usage-data/UsageDataPrompt.tsx +19 -1
  66. package/src/components/workload/WorkloadView.tsx +10 -4
  67. package/src/components/workspace/layout.tsx +2 -1
  68. package/src/contexts/CapabilitiesContext.tsx +1 -0
  69. package/src/hooks/useGitOpsWriteGuard.test.tsx +126 -2
  70. package/src/hooks/useGitOpsWriteGuard.ts +25 -3
  71. package/src/hooks/useResolvedGitOpsOwner.ts +14 -9
  72. package/src/index.css +85 -0
@@ -2,6 +2,7 @@ import { useState, useRef, useEffect, useCallback } from 'react'
2
2
  import { createPortal } from 'react-dom'
3
3
  import { HelpCircle } from 'lucide-react'
4
4
  import { clsx } from 'clsx'
5
+ import { isTouchIntent } from '@skyhook-io/k8s-ui'
5
6
 
6
7
  // The query operators recognized by the search engine (internal/search/parse.go).
7
8
  const OPERATORS: { syntax: string; desc: string }[] = [
@@ -16,6 +17,10 @@ const OPERATORS: { syntax: string; desc: string }[] = [
16
17
  // reference tooltip, not a second click-to-open panel stacked over the results).
17
18
  // Self-contained + portaled to <body> so the header's stacking context can't
18
19
  // trap it; a short close grace lets the pointer travel onto the card.
20
+ // A tap also fires mouseenter, and the "?" can sit right under the finger
21
+ // that just opened the search box, so hover ignores a tap's side effects. A
22
+ // click (a tap, or assistive-technology activation) toggles the card, except
23
+ // right after a mouse hover opened it; a tap elsewhere closes it.
19
24
  export function SearchSyntaxHelp() {
20
25
  const [open, setOpen] = useState(false)
21
26
  const btnRef = useRef<HTMLButtonElement>(null)
@@ -24,11 +29,22 @@ export function SearchSyntaxHelp() {
24
29
  const [anchor, setAnchor] = useState<{ right: number; top: number } | null>(null)
25
30
 
26
31
  const show = useCallback(() => { clearTimeout(closeTimer.current); setOpen(true) }, [])
32
+ const openedByHover = useRef(false)
27
33
  const scheduleHide = useCallback(() => {
28
34
  clearTimeout(closeTimer.current)
29
35
  closeTimer.current = setTimeout(() => setOpen(false), 120)
30
36
  }, [])
31
37
 
38
+ useEffect(() => {
39
+ if (!open) return
40
+ const onDown = (e: globalThis.PointerEvent) => {
41
+ const t = e.target as Node
42
+ if (!btnRef.current?.contains(t) && !popRef.current?.contains(t)) setOpen(false)
43
+ }
44
+ document.addEventListener('pointerdown', onDown)
45
+ return () => document.removeEventListener('pointerdown', onDown)
46
+ }, [open])
47
+
32
48
  useEffect(() => () => clearTimeout(closeTimer.current), [])
33
49
 
34
50
  useEffect(() => {
@@ -53,8 +69,13 @@ export function SearchSyntaxHelp() {
53
69
  type="button"
54
70
  tabIndex={-1}
55
71
  aria-label="Search syntax help"
56
- onMouseEnter={show}
57
- onMouseLeave={scheduleHide}
72
+ aria-expanded={open}
73
+ onMouseEnter={() => { if (!isTouchIntent()) { openedByHover.current = !open; show() } }}
74
+ onMouseLeave={() => { openedByHover.current = false; scheduleHide() }}
75
+ onClick={() => {
76
+ if (openedByHover.current) { openedByHover.current = false; return }
77
+ setOpen((o) => !o)
78
+ }}
58
79
  onMouseDown={(e) => e.preventDefault()}
59
80
  className={clsx('shrink-0 rounded p-0.5 cursor-help transition-colors', open ? 'text-theme-text-secondary' : 'text-theme-text-tertiary hover:text-theme-text-secondary')}
60
81
  >
@@ -13,6 +13,8 @@ vi.mock('../../api/client', () => ({
13
13
  updateAvailable: true,
14
14
  installMethod: 'direct',
15
15
  releaseUrl: 'https://github.com/skyhook-io/radar/releases/tag/v1.3.0',
16
+ // Off, so the Product Hunt launch day doesn't take the corner whatever today is.
17
+ productHuntLaunch: { enabled: false, url: '', start: '0001-01-01T00:00:00Z', end: '0001-01-01T00:00:00Z' },
16
18
  },
17
19
  }),
18
20
  useStartDesktopUpdate: () => ({ mutate: vi.fn(), isPending: false }),
@@ -16,6 +16,8 @@ import { WithTooltip } from './Tooltip'
16
16
  import { TRANSITION_MENU, overlayExitMs, overlayTransitionStyle } from '../../utils/animation'
17
17
  import { useAnimatedUnmount } from '../../hooks/useAnimatedUnmount'
18
18
  import { IN_CLUSTER_UPGRADE_URL } from '../../utils/version'
19
+ import { LAUNCH_NOTICE_DISMISSED_EVENT, launchNoticeHoldsCorner, launchPhase, resolveLaunch } from '../product-hunt/launchWindow'
20
+ import { USAGE_PROMPT_VISIBILITY_EVENT, usagePromptOnScreen } from '../usage-data/UsageDataPrompt'
19
21
 
20
22
  const DISMISSED_KEY = 'radar-update-dismissed'
21
23
 
@@ -94,6 +96,23 @@ export function UpdateNotification({ placement = 'floating' }: { placement?: 'fl
94
96
  }
95
97
  }, [queryClient, inSettings, showToast])
96
98
 
99
+ // Runs until the launch window is over, so a notice already on screen when
100
+ // the launch day starts steps aside too.
101
+ const launch = resolveLaunch(versionInfo?.productHuntLaunch)
102
+ const [launchNow, setLaunchNow] = useState(() => Date.now())
103
+ const launchWindowOpen = launchPhase(launch, launchNow) !== null
104
+ const launchHoldsCorner = launchNoticeHoldsCorner(launch, launchNow)
105
+ useEffect(() => {
106
+ if (inSettings || !launchWindowOpen) return
107
+ const recheck = () => setLaunchNow(Date.now())
108
+ window.addEventListener(LAUNCH_NOTICE_DISMISSED_EVENT, recheck)
109
+ const poll = window.setInterval(recheck, 60_000)
110
+ return () => {
111
+ window.removeEventListener(LAUNCH_NOTICE_DISMISSED_EVENT, recheck)
112
+ window.clearInterval(poll)
113
+ }
114
+ }, [inSettings, launchWindowOpen])
115
+
97
116
  // Log version check errors for debugging
98
117
  useEffect(() => {
99
118
  if (versionInfo?.error) {
@@ -101,13 +120,21 @@ export function UpdateNotification({ placement = 'floating' }: { placement?: 'fl
101
120
  }
102
121
  }, [versionInfo?.error])
103
122
 
104
- // Check if this version was already dismissed
123
+ // Dismissal is per release: a newer one found while the page is open shows again.
105
124
  useEffect(() => {
106
- if (versionInfo?.latestVersion && isUpdateDismissed(versionInfo.latestVersion)) {
107
- setDismissed(true)
108
- }
125
+ if (versionInfo?.latestVersion) setDismissed(isUpdateDismissed(versionInfo.latestVersion))
109
126
  }, [versionInfo?.latestVersion])
110
127
 
128
+ // The first-run usage card shares the corner; an update found while it is
129
+ // open waits for it.
130
+ const [usagePromptShowing, setUsagePromptShowing] = useState(usagePromptOnScreen)
131
+ useEffect(() => {
132
+ if (inSettings) return
133
+ const onUsagePrompt = () => setUsagePromptShowing(usagePromptOnScreen())
134
+ window.addEventListener(USAGE_PROMPT_VISIBILITY_EVENT, onUsagePrompt)
135
+ return () => window.removeEventListener(USAGE_PROMPT_VISIBILITY_EVENT, onUsagePrompt)
136
+ }, [inSettings])
137
+
111
138
  // Stop polling when update reaches a terminal state
112
139
  useEffect(() => {
113
140
  if (updateStatus?.state === 'error' || updateStatus?.state === 'idle') {
@@ -149,7 +176,7 @@ export function UpdateNotification({ placement = 'floating' }: { placement?: 'fl
149
176
  // Shared in-cluster viewers get a persistent Home notice instead of a
150
177
  // floating action prompt they may not be able to act on.
151
178
  const available = !!versionInfo?.updateAvailable && deploymentMode !== undefined && deploymentMode !== 'cloud'
152
- const show = available && deploymentMode !== 'in-cluster' && (inSettings ? expanded : !dismissed)
179
+ const show = available && deploymentMode !== 'in-cluster' && (inSettings ? expanded : !dismissed && !launchHoldsCorner && !usagePromptShowing)
153
180
  // Presence outlives `show` by the menu exit so a dismiss fades the chip out
154
181
  // instead of snapping it away; the enter runs the same transition in reverse.
155
182
  const { shouldRender, isOpen } = useAnimatedUnmount(show, overlayExitMs('menu'))
@@ -4,6 +4,7 @@ import { BarChart3, X } from 'lucide-react'
4
4
  import { useMarkUsagePromptShown, useSetUsageData, type UsageDataStatus } from '../../api/usage-data'
5
5
  import { useVersionCheck } from '../../api/client'
6
6
  import { isUpdateDismissed } from '../ui/UpdateNotification'
7
+ import { launchNoticeHoldsCorner, resolveLaunch } from '../product-hunt/launchWindow'
7
8
  import { UsageDataAnswered, UsageDataBlurb } from './UsageDataAsk'
8
9
  import { useAnimatedUnmount } from '../../hooks/useAnimatedUnmount'
9
10
  import { TRANSITION_MENU, overlayExitMs, overlayTransitionStyle } from '../../utils/animation'
@@ -13,6 +14,14 @@ import { TRANSITION_MENU, overlayExitMs, overlayTransitionStyle } from '../../ut
13
14
  export const FIRST_RUN_PROMPT_DELAY_MS = 15_000
14
15
  const THANKS_MS = 4_000
15
16
 
17
+ // The server stops offering the prompt the moment it is shown, so other corner
18
+ // cards read whether it is on screen from here instead.
19
+ let promptOnScreen = false
20
+ export const USAGE_PROMPT_VISIBILITY_EVENT = 'radar:usage-prompt-visibility'
21
+ export function usagePromptOnScreen(): boolean {
22
+ return promptOnScreen
23
+ }
24
+
16
25
  // The update notice uses the same corner. One nudge at a time.
17
26
  export function updateNoticeVisible(latest: string | undefined, updateAvailable: boolean | undefined): boolean {
18
27
  return !!updateAvailable && !!latest && !isUpdateDismissed(latest)
@@ -64,7 +73,7 @@ export function UsageDataPrompt({ status }: { status: UsageDataStatus | undefine
64
73
  const eligible = shouldShowFirstRunPrompt({
65
74
  status,
66
75
  ready,
67
- updateNoticeShowing: updateNoticeVisible(versionInfo?.latestVersion, versionInfo?.updateAvailable),
76
+ updateNoticeShowing: updateNoticeVisible(versionInfo?.latestVersion, versionInfo?.updateAvailable) || launchNoticeHoldsCorner(resolveLaunch(versionInfo?.productHuntLaunch), Date.now()),
68
77
  })
69
78
  useEffect(() => {
70
79
  if (eligible && !recorded.current) {
@@ -81,6 +90,15 @@ export function UsageDataPrompt({ status }: { status: UsageDataStatus | undefine
81
90
  }, [answer])
82
91
 
83
92
  const show = latched && !dismissed && cardStillAsking(status, answer)
93
+ useEffect(() => {
94
+ if (!show) return
95
+ promptOnScreen = true
96
+ window.dispatchEvent(new Event(USAGE_PROMPT_VISIBILITY_EVENT))
97
+ return () => {
98
+ promptOnScreen = false
99
+ window.dispatchEvent(new Event(USAGE_PROMPT_VISIBILITY_EVENT))
100
+ }
101
+ }, [show])
84
102
  const { shouldRender, isOpen } = useAnimatedUnmount(show, overlayExitMs('menu'))
85
103
  if (!shouldRender) return null
86
104
 
@@ -295,6 +295,7 @@ function useActionsBarProps(
295
295
  cascadeEnabled: boolean,
296
296
  nodeUID: string,
297
297
  ) {
298
+ const [deletePreviewOpen, setDeletePreviewOpen] = useState(false)
298
299
  const { showCopied } = useToast()
299
300
  const { features } = useCapabilitiesContext()
300
301
  const openTerminal = useOpenTerminal()
@@ -359,14 +360,14 @@ function useActionsBarProps(
359
360
 
360
361
  const {
361
362
  data: cascadePreview,
362
- isLoading: cascadeLoading,
363
+ isFetching: cascadeLoading,
363
364
  isError: cascadeError,
364
365
  } = useCascadeDeletePreview(
365
366
  kind,
366
367
  namespace,
367
368
  name,
368
369
  group,
369
- cascadeEnabled,
370
+ cascadeEnabled && deletePreviewOpen,
370
371
  )
371
372
 
372
373
  const canNodeWrite = useCanNodeWrite()
@@ -403,8 +404,10 @@ function useActionsBarProps(
403
404
  onDelete: (
404
405
  params: Parameters<typeof deleteMutation.mutate>[0],
405
406
  callbacks?: { onSuccess?: () => void },
406
- ) => deleteMutation.mutate(params, { onSuccess: callbacks?.onSuccess }),
407
+ ) => deleteMutation.mutate(params, { onSuccess: result => { if (!result.outcomeUnknown) callbacks?.onSuccess?.() } }),
407
408
  isDeleting: deleteMutation.isPending,
409
+ onDeletePreviewOpenChange: setDeletePreviewOpen,
410
+ cascadeDetail: cascadePreview,
408
411
  cascadeDependents: cascadePreview?.dependents,
409
412
  cascadeLoading,
410
413
  cascadeRootResolved: cascadePreview?.rootResolved,
@@ -1027,6 +1030,7 @@ export function WorkloadView({
1027
1030
  guard: imageGuard,
1028
1031
  onSelectionChange: setImageSelection,
1029
1032
  selectionKey: setImageSelectionKey(imageSelection),
1033
+ onOpenManager: handleOpenGitOpsResource,
1030
1034
  onOpenOwner: owner
1031
1035
  ? imageOwnerVerified
1032
1036
  ? () => handleOpenGitOpsResource(owner)
@@ -1327,7 +1331,9 @@ export function WorkloadView({
1327
1331
  hasOverviewLead={hasOperationalIssues || Boolean(schedulingEvidence && schedulingEvidence.state !== 'reported')}
1328
1332
  hasOperationalIssues={hasOperationalIssues}
1329
1333
  operationalIssuesPending={issuesPending}
1330
- onOpenGitOpsResource={gitopsOwnerObject ? handleOpenGitOpsResource : undefined}
1334
+ // A manager answer's chip links only managers the server found; a
1335
+ // disagreement has no lead, so no owner object, but its managers link.
1336
+ onOpenGitOpsResource={gitopsOwnerObject || relationships?.ownership?.manager ? handleOpenGitOpsResource : undefined}
1331
1337
  resolvedGitOpsOwner={gitopsOwner}
1332
1338
  gitOpsOwnerVerified={gitOpsOwnerVerified}
1333
1339
  gitOpsOwnerPending={gitOpsOwnerPending}
@@ -30,7 +30,8 @@ export function ScreenEmptyState({
30
30
  }) {
31
31
  return (
32
32
  <div className="flex min-h-0 flex-1 items-center justify-center bg-theme-base p-6">
33
- <div className="max-w-md text-center">
33
+ {/* Phones: shrink to the screen so wide content (YAML) scrolls inside itself. */}
34
+ <div className="max-w-md text-center phone:w-full phone:min-w-0">
34
35
  <Icon className="mx-auto h-9 w-9 text-theme-text-tertiary/50" />
35
36
  <h2 className="mt-3 text-lg font-medium text-theme-text-primary">
36
37
  {title}
@@ -43,6 +43,7 @@ const restrictedCapabilities: Capabilities = {
43
43
  rollouts: false,
44
44
  },
45
45
  mcpEnabled: false,
46
+ mcpExecTools: false,
46
47
  deployment: { mode: 'local' },
47
48
  }
48
49
 
@@ -5,18 +5,25 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
5
5
  import { SetImageDialog, canConfirmGitOpsWrite, setImageSelectionKey, type WorkloadImageInventory } from '@skyhook-io/k8s-ui'
6
6
  import { afterEach, expect, it, vi } from 'vitest'
7
7
  import { useGitOpsWriteGuard, type GitOpsWriteGuardState } from './useGitOpsWriteGuard'
8
+ import { findInheritedGitOpsLookupRef } from './useResolvedGitOpsOwner'
8
9
 
9
10
  const mocks = vi.hoisted(() => ({
10
11
  applications: { data: undefined as unknown[] | undefined, isPending: true, isError: false },
11
12
  inherited: { data: undefined as unknown, isPending: false, isError: false },
12
13
  target: { data: undefined as unknown, relationships: undefined as unknown, isLoading: false, isError: false },
14
+ ownerObject: undefined as unknown,
15
+ resourceRead: vi.fn(),
16
+ resourceList: vi.fn(),
13
17
  evidence: vi.fn(),
14
18
  evidenceUnsupported: false,
15
19
  }))
16
20
  vi.mock('../api/client', () => ({
17
- useResource: (kind: string) => (kind === 'deployments' ? mocks.target : { data: undefined, isLoading: false, isError: false }),
21
+ useResource: (...args: unknown[]) => {
22
+ mocks.resourceRead(...args)
23
+ return args[0] === 'deployments' ? mocks.target : { data: args[0] ? mocks.ownerObject : undefined, isLoading: false, isError: false }
24
+ },
18
25
  useResourceWithRelationships: () => mocks.inherited,
19
- useResources: () => mocks.applications,
26
+ useResources: (...args: unknown[]) => { mocks.resourceList(...args); return mocks.applications },
20
27
  useRadarFeature: () => ({
21
28
  guard: async (fn: () => unknown) => {
22
29
  if (!mocks.evidenceUnsupported) return fn()
@@ -36,6 +43,9 @@ afterEach(() => {
36
43
  mocks.inherited = { data: undefined, isPending: false, isError: false }
37
44
  mocks.target = { data: undefined, relationships: undefined, isLoading: false, isError: false }
38
45
  mocks.evidence.mockReset()
46
+ mocks.ownerObject = undefined
47
+ mocks.resourceRead.mockReset()
48
+ mocks.resourceList.mockReset()
39
49
  })
40
50
 
41
51
  it.each(['resolved', 'failed', 'empty', 'ambiguous'])('waits for Argo Application namespace lookup before handling %s ownership', async (outcome) => {
@@ -455,3 +465,117 @@ it("doesn't hold Update for a host that reports the selection without judging it
455
465
  host.remove()
456
466
  }
457
467
  })
468
+
469
+ const managerApp = { kind: 'Application', group: 'argoproj.io', namespace: 'argocd', name: 'server-app' }
470
+ const managerAnswer: import('@skyhook-io/k8s-ui').ManagerAnswer = { state: 'listed', lead: managerApp, direct: { object: deployment, recorders: [managerApp] } }
471
+
472
+ it.each(['disagree', 'shared', 'claimed'] as const)('fetches evidence for %s without a lead', async state => {
473
+ const manager = { ...managerAnswer, state, lead: undefined, direct: { object: deployment, recorders: state === 'claimed' ? [] : state === 'shared' ? [managerApp, { ...managerApp, name: 'second-recorder' }] : [managerApp], claims: [{ manager: { ...managerApp, name: 'claim' }, source: 'argo-instance-label' as const, check: 'omitted' as const }, ...(state === 'claimed' ? [{ manager: managerApp, source: 'argo-instance-label' as const, check: 'omitted' as const }] : [])] } }
474
+ mocks.evidence.mockResolvedValue({ uid: 'u', resourceVersion: '1', owner: null, manager, policy: null, paths: [] })
475
+ const h = await renderGuard({ target: deployment, resource: {}, relationships: { ownership: { children: { complete: true }, manager } }, writes: replicas })
476
+ try {
477
+ await act(async () => vi.waitFor(() => expect(h.ref.state!.guard?.pending).toBe(false)))
478
+ expect(mocks.evidence).toHaveBeenCalledTimes(1)
479
+ expect(mocks.evidence.mock.calls[0][0].owner).toBeUndefined()
480
+ expect(h.ref.state!.guard?.requiresAck).toBe(true)
481
+ } finally { await h.cleanup() }
482
+ })
483
+
484
+ it('fetches via evidence and names the parent without acknowledgment', async () => {
485
+ const manager = { ...managerAnswer, direct: { object: pod }, via: managerAnswer.direct }
486
+ mocks.evidence.mockResolvedValue({ uid: 'u', resourceVersion: '1', owner: managerApp, manager, policy: null, paths: [] })
487
+ const h = await renderGuard({ target: pod, resource: {}, relationships: { ownership: { children: { complete: true }, manager } }, writes: replicas })
488
+ try {
489
+ await act(async () => vi.waitFor(() => expect(h.ref.state!.guard?.pending).toBe(false)))
490
+ expect(mocks.evidence).toHaveBeenCalledTimes(1)
491
+ expect(h.ref.state!.ownership.inheritedLookupRef).toBeNull()
492
+ expect(h.ref.state!.guard?.level).toBe('info')
493
+ expect(h.ref.state!.guard?.requiresAck).toBe(false)
494
+ expect(h.ref.state!.guard?.summary).toContain('Deployment prod/web')
495
+ } finally { await h.cleanup() }
496
+ })
497
+
498
+ it.each(['none', 'unknown', 'disagree', 'shared', 'claimed', 'listed'] as const)('adopts the server %s answer over a conflicting client lead', async state => {
499
+ const serverManager = { ...managerAnswer, state, lead: state === 'listed' ? managerApp : undefined, direct: { object: deployment } }
500
+ mocks.evidence.mockResolvedValue({ uid: 'u', resourceVersion: '1', owner: managerApp, manager: serverManager, policy: null, paths: [] })
501
+ const clientManager = { ...managerAnswer, lead: { ...managerApp, name: 'stale-client' } }
502
+ const h = await renderGuard({ target: deployment, resource: {}, relationships: { ownership: { children: { complete: true }, manager: clientManager } }, writes: replicas })
503
+ try {
504
+ await act(async () => vi.waitFor(() => expect(h.ref.state!.guard?.pending).toBe(false)))
505
+ expect(h.ref.state!.ownership.manager).toEqual(serverManager)
506
+ expect(h.ref.state!.guard?.owner?.name ?? null).toBe(state === 'listed' ? 'server-app' : null)
507
+ expect(h.ref.state!.guard?.summary).not.toContain('stale-client')
508
+ if (state === 'none' || state === 'unknown') expect(h.ref.state!.guard?.level).toBe('none')
509
+ } finally { await h.cleanup() }
510
+ })
511
+
512
+ // A live answer naming another manager doesn't inherit the cached one's
513
+ // verification or status: a link to it would rest on a check of the old one.
514
+ it("doesn't carry the cached manager's verification to a different live manager", async () => {
515
+ mocks.ownerObject = { status: { sync: { status: 'Synced' }, health: { status: 'Healthy' } } }
516
+ const other = { ...managerApp, name: 'live-app' }
517
+ const live = { state: 'claimed' as const, lead: other, direct: { object: deployment, claims: [{ manager: other, source: 'argo-tracking-id' as const, check: 'missing' as const }] } }
518
+ mocks.evidence.mockResolvedValue({ uid: 'u', resourceVersion: '1', owner: other, manager: live, policy: null, paths: [] })
519
+ const h = await renderGuard({ target: deployment, resource: {}, relationships: { ownership: { children: { complete: true }, manager: managerAnswer } }, writes: replicas })
520
+ try {
521
+ await act(async () => vi.waitFor(() => expect(h.ref.state!.ownership.owner?.name).toBe('live-app')))
522
+ expect(h.ref.state!.ownership.ownerVerified).toBe(false)
523
+ expect(h.ref.state!.ownership.ownerStatus).toBeNull()
524
+ } finally { await h.cleanup() }
525
+ })
526
+
527
+ // An object adopted since the cache saw it has a manager the cache doesn't.
528
+ it('checks a cached none against the live object', async () => {
529
+ const cachedNone = { state: 'none' as const, direct: { object: deployment } }
530
+ mocks.evidence.mockResolvedValue({ uid: 'u', resourceVersion: '1', owner: managerApp, manager: managerAnswer, policy: null, paths: [] })
531
+ const h = await renderGuard({ target: deployment, resource: {}, relationships: { ownership: { children: { complete: true }, manager: cachedNone } }, writes: replicas })
532
+ try {
533
+ await act(async () => vi.waitFor(() => expect(mocks.evidence).toHaveBeenCalled()))
534
+ await act(async () => vi.waitFor(() => expect(h.ref.state!.guard?.owner?.name).toBe('server-app')))
535
+ } finally { await h.cleanup() }
536
+ })
537
+
538
+ it('does not guess an Argo namespace or inherit through the browser with an answer', async () => {
539
+ const unresolved = { ...managerAnswer, state: 'claimed' as const, lead: { ...managerApp, namespace: '' } }
540
+ mocks.applications.data = [{ metadata: { name: managerApp.name, namespace: 'guessed' } }]
541
+ mocks.inherited = { data: { resource: {}, relationships: { managedBy: [managerApp] } }, isPending: false, isError: false }
542
+ mocks.evidence.mockResolvedValue({ uid: 'u', resourceVersion: '1', owner: unresolved.lead, policy: null, paths: [] })
543
+ const h = await renderGuard({ target: pod, resource: {}, relationships: { ...podRelationships, ownership: { children: { complete: true }, manager: unresolved } }, writes: replicas })
544
+ try {
545
+ await act(async () => vi.waitFor(() => expect(h.ref.state!.guard?.pending).toBe(false)))
546
+ expect(h.ref.state!.ownership.owner?.namespace).toBe('')
547
+ expect(h.ref.state!.ownership.ownerMatchedByName).toBe(false)
548
+ expect(h.ref.state!.ownership.inheritedLookupRef).toBeNull()
549
+ expect(mocks.evidence.mock.calls[0][0].owner.namespace).toBe('')
550
+ } finally { await h.cleanup() }
551
+ })
552
+
553
+
554
+ it('still fetches the lead for sync and health without listing namesakes', async () => {
555
+ mocks.ownerObject = { status: { sync: { status: 'Synced' }, health: { status: 'Healthy' } } }
556
+ mocks.evidence.mockResolvedValue({ uid: 'u', resourceVersion: '1', owner: managerApp, manager: managerAnswer, policy: null, paths: [] })
557
+ const h = await renderGuard({ target: deployment, resource: {}, relationships: { ownership: { children: { complete: true }, manager: managerAnswer } }, writes: replicas })
558
+ try {
559
+ await act(async () => vi.waitFor(() => expect(h.ref.state!.guard?.pending).toBe(false)))
560
+ expect(mocks.resourceRead).toHaveBeenCalledWith('applications', 'argocd', 'server-app', 'argoproj.io', expect.objectContaining({ enabled: true }))
561
+ expect(mocks.resourceList).toHaveBeenCalledWith('applications', undefined, 'argoproj.io', expect.objectContaining({ enabled: false }))
562
+ expect(h.ref.state!.ownership.ownerStatus).toMatchObject({ sync: 'Synced', health: 'Healthy' })
563
+ } finally { await h.cleanup() }
564
+ })
565
+
566
+
567
+ it.each(['agree', 'listed', 'claimed', 'disagree', 'shared', 'unknown', 'none'] as const)('image prefetch skips browser inheritance for %s answers', state => {
568
+ expect(findInheritedGitOpsLookupRef({ ...podRelationships, ownership: { children: { complete: true }, manager: { state, direct: { object: pod } } } }, null, pod)).toBeNull()
569
+ })
570
+
571
+
572
+ it.each(['cycle', 'truncated'] as const)('fetches evidence for a %s chain without a stop object', async chainEnd => {
573
+ const manager = { state: 'unknown' as const, direct: { object: deployment }, chainEnd }
574
+ mocks.evidence.mockResolvedValue({ uid: 'u', resourceVersion: '1', owner: null, manager, policy: null, paths: [] })
575
+ const h = await renderGuard({ target: deployment, resource: {}, relationships: { ownership: { children: { complete: true }, manager } }, writes: replicas })
576
+ try {
577
+ await act(async () => vi.waitFor(() => expect(h.ref.state!.guard?.pending).toBe(false)))
578
+ expect(mocks.evidence).toHaveBeenCalledTimes(1)
579
+ expect(h.ref.state!.guard?.level).toBe('may-revert')
580
+ } finally { await h.cleanup() }
581
+ })
@@ -3,6 +3,8 @@ import { useQuery } from '@tanstack/react-query'
3
3
  import {
4
4
  evaluateGitOpsWriteGuard,
5
5
  gitOpsWriteEvidencePaths,
6
+ gitOpsOwnerFromRef,
7
+ managerChoices,
6
8
  type GitOpsWrite,
7
9
  type GitOpsWriteEvidence,
8
10
  type GitOpsWriteGuard,
@@ -81,6 +83,10 @@ export function useGitOpsWriteGuard({
81
83
  const targetLookupFailed = needsTarget && targetQuery.isError
82
84
  const lookupPending = targetLookupPending || ownership.lookupPending
83
85
  const managed = Boolean(ownership.owner || ownership.helmOwner)
86
+ const manager = ownership.manager
87
+ // The server answers from the live object, so any cached answer is checked:
88
+ // an object adopted since the cache last saw it has a manager it doesn't.
89
+ const needsManagerEvidence = Boolean(manager)
84
90
 
85
91
  const writesKey = JSON.stringify(writes)
86
92
  const requestedPathsKey = requestedPaths ? JSON.stringify(requestedPaths) : ''
@@ -99,12 +105,12 @@ export function useGitOpsWriteGuard({
99
105
  }, [ownership.owner, ownership.helmOwner])
100
106
  // An Argo owner without a namespace is still asked about: the server finds
101
107
  // the Application whose status lists the object.
102
- const canFetchEvidence = managed && !lookupPending && !targetLookupFailed && !ownership.lookupError
108
+ const canFetchEvidence = (managed || needsManagerEvidence) && !lookupPending && !targetLookupFailed && !ownership.lookupError
103
109
 
104
110
  const evidenceFeature = useRadarFeature('gitopsWriteEvidence')
105
111
  const evidenceQuery = useQuery({
106
112
  // The API base identifies the cluster when a host switches it (Radar Hub).
107
- queryKey: ['gitops-write-evidence', getApiBase(), target.kind, target.group, target.namespace, target.name, paths, ownerRef, ...evidenceFeature.gatedKey],
113
+ queryKey: ['gitops-write-evidence', getApiBase(), target.kind, target.group, target.namespace, target.name, paths, ownerRef, manager, ...evidenceFeature.gatedKey],
108
114
  queryFn: () =>
109
115
  evidenceFeature.guard(() =>
110
116
  fetchGitOpsWriteEvidence({
@@ -122,7 +128,7 @@ export function useGitOpsWriteGuard({
122
128
  })
123
129
 
124
130
  const targetRelationshipsMissing = needsTarget && targetQuery.data != null && targetQuery.relationships == null
125
- const unresolvedDeclaredManager = Boolean(declaredManager) && !managed && !lookupPending
131
+ const unresolvedDeclaredManager = !manager && Boolean(declaredManager) && !managed && !lookupPending
126
132
  const unknownOwner = "so it can't tell whether a GitOps tool or Helm manages it."
127
133
  const ownershipError = targetLookupFailed
128
134
  ? `Radar couldn't read this resource, ${unknownOwner}`
@@ -143,6 +149,20 @@ export function useGitOpsWriteGuard({
143
149
  // namespace, and the browser's namespace view may hide them; take the
144
150
  // Application the server confirmed.
145
151
  const confirmedOwnership = useMemo<ResolvedGitOpsOwner>(() => {
152
+ if (evidence?.manager) {
153
+ const answer = evidence.manager
154
+ const owner = answer.lead ? gitOpsOwnerFromRef(answer.lead) : null
155
+ const helmOwner = answer.lead?.kind === 'HelmRelease' && !answer.lead.group ? { namespace: answer.lead.namespace, name: answer.lead.name } : null
156
+ const same = (a: typeof owner, b: typeof owner) => Boolean(a && b && a.kind === b.kind && a.namespace === b.namespace && a.name === b.name)
157
+ if (same(owner, ownership.owner)) {
158
+ return { ...ownership, manager: answer, owner, rawOwner: owner, helmOwner, ownerMatchedByName: false }
159
+ }
160
+ // The live answer names another manager: what was read and verified
161
+ // for the cached one doesn't carry over. The server found it when its
162
+ // list names the object or a claim read it.
163
+ const found = Boolean(answer.lead && owner?.namespace && managerChoices(answer).find(c => c.ref.kind === answer.lead!.kind && c.ref.group === answer.lead!.group && c.ref.namespace === answer.lead!.namespace && c.ref.name === answer.lead!.name)?.found)
164
+ return { ...ownership, manager: answer, owner, rawOwner: owner, helmOwner, ownerMatchedByName: false, ownerObject: undefined, ownerStatus: null, ownerVerified: found }
165
+ }
146
166
  const owner = ownership.owner
147
167
  const namespace = evidence?.ownerTracksTarget ? evidence.owner?.namespace : undefined
148
168
  if (!owner || owner.namespace || !namespace) return ownership
@@ -154,6 +174,7 @@ export function useGitOpsWriteGuard({
154
174
  enabled
155
175
  ? evaluateGitOpsWriteGuard({
156
176
  target,
177
+ manager,
157
178
  owner: confirmedOwnership.owner,
158
179
  helmRelease: ownership.helmOwner,
159
180
  // A refetch counts as pending: an earlier verdict may no longer hold.
@@ -177,6 +198,7 @@ export function useGitOpsWriteGuard({
177
198
  target.name,
178
199
  confirmedOwnership.owner,
179
200
  ownership.helmOwner,
201
+ manager,
180
202
  lookupPending,
181
203
  canFetchEvidence,
182
204
  evidenceQuery.isPending,
@@ -2,6 +2,7 @@ import { useMemo } from 'react'
2
2
  import {
3
3
  getGitOpsResourceStatus,
4
4
  gitOpsOwnerFromRelationships,
5
+ type ManagerAnswer,
5
6
  type GitOpsOwnerRef,
6
7
  type GitOpsStatus,
7
8
  type HelmOwnerRef,
@@ -11,6 +12,7 @@ import { kindToPluralWithGroup } from '../utils/navigation'
11
12
  import { useResource, useResourceWithRelationships, useResources } from '../api/client'
12
13
 
13
14
  export interface ResolvedGitOpsOwner {
15
+ manager?: ManagerAnswer
14
16
  /** GitOps owner, with an Argo Application's namespace filled in when the
15
17
  * tracking label omitted it and exactly one Application matches. */
16
18
  owner: GitOpsOwnerRef | null
@@ -60,6 +62,7 @@ export function useResolvedGitOpsOwner({
60
62
  /** Keeps these reads apart from the shared resource cache (see useResource). */
61
63
  cacheScope?: string
62
64
  }): ResolvedGitOpsOwner {
65
+ const manager = enabled ? relationships?.ownership?.manager : undefined
63
66
  const active = enabled && Boolean(relationships)
64
67
  const relationshipGitopsOwner = useMemo(
65
68
  () => (active ? gitOpsOwnerFromRelationships(relationships) : null),
@@ -67,10 +70,10 @@ export function useResolvedGitOpsOwner({
67
70
  )
68
71
  const inheritedLookupRef = useMemo(
69
72
  () =>
70
- active
73
+ active && !manager
71
74
  ? findInheritedGitOpsLookupRef(relationships, relationshipGitopsOwner, { kind, namespace, name, group })
72
75
  : null,
73
- [active, relationships, relationshipGitopsOwner, kind, namespace, name, group],
76
+ [active, manager, relationships, relationshipGitopsOwner, kind, namespace, name, group],
74
77
  )
75
78
  const inherited = useResourceWithRelationships<any>(
76
79
  inheritedLookupRef ? kindToPluralWithGroup(inheritedLookupRef.kind, inheritedLookupRef.group ?? '') : '',
@@ -103,13 +106,13 @@ export function useResolvedGitOpsOwner({
103
106
  const helmOwner = relationshipHelmOwner ?? inheritedHelmOwner
104
107
  const helmSourceResource = relationshipHelmOwner ? resource : inherited.data?.resource
105
108
 
106
- const shouldResolveArgoNamespace = rawOwner?.tool === 'argocd' && !rawOwner.namespace
109
+ const shouldResolveArgoNamespace = !manager && rawOwner?.tool === 'argocd' && !rawOwner.namespace
107
110
  const argoQuery = useResources<any>('applications', undefined, 'argoproj.io', {
108
111
  enabled: shouldResolveArgoNamespace,
109
112
  cacheScope,
110
113
  })
111
114
  const argoApplications = argoQuery.data
112
- const owner = useMemo(() => resolveGitOpsOwner(rawOwner, argoApplications), [rawOwner, argoApplications])
115
+ const owner = useMemo(() => manager ? rawOwner : resolveGitOpsOwner(rawOwner, argoApplications), [manager, rawOwner, argoApplications])
113
116
 
114
117
  const ownerGroup = owner ? gitOpsOwnerGroup(owner) : ''
115
118
  const shouldFetchOwner = Boolean(owner?.namespace)
@@ -124,12 +127,13 @@ export function useResolvedGitOpsOwner({
124
127
 
125
128
  const ownerStatus = useMemo(() => deriveGitOpsOwnerStatus(owner, ownerObject), [owner, ownerObject])
126
129
  const ownerSource = useMemo(
127
- () => describeGitOpsOwnerSource(rawOwner, gitOpsSourceResource),
128
- [rawOwner, gitOpsSourceResource],
130
+ () => manager ? null : describeGitOpsOwnerSource(rawOwner, gitOpsSourceResource),
131
+ [manager, rawOwner, gitOpsSourceResource],
129
132
  )
130
- const helmSource = useMemo(() => describeHelmOwnerSource(helmOwner, helmSourceResource), [helmOwner, helmSourceResource])
133
+ const helmSource = useMemo(() => manager ? null : describeHelmOwnerSource(helmOwner, helmSourceResource), [manager, helmOwner, helmSourceResource])
131
134
 
132
135
  return {
136
+ manager,
133
137
  owner,
134
138
  rawOwner,
135
139
  ownerObject,
@@ -173,7 +177,7 @@ export function findInheritedGitOpsLookupRef(
173
177
  directOwner: GitOpsOwnerRef | null,
174
178
  current: ResourceRef,
175
179
  ): ResourceRef | null {
176
- if (directOwner) return null
180
+ if (relationships?.ownership?.manager || directOwner) return null
177
181
  const inheritedManagerRefs = (relationships?.managedBy ?? []).filter(
178
182
  (ref) => !gitOpsOwnerFromRelationships({ managedBy: [ref] }) && !isNativeHelmManager(ref),
179
183
  )
@@ -188,7 +192,8 @@ export function nativeHelmOwnerFromRelationships(
188
192
  relationships: Relationships | undefined,
189
193
  fallbackNamespace: string,
190
194
  ): HelmOwnerRef | null {
191
- const ref = relationships?.managedBy?.[0]
195
+ const answer = relationships?.ownership?.manager
196
+ const ref = answer ? answer.lead : relationships?.managedBy?.[0]
192
197
  if (!ref || !isNativeHelmManager(ref)) return null
193
198
  return {
194
199
  namespace: ref.namespace || fallbackNamespace,