@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.
Files changed (126) hide show
  1. package/README.md +6 -0
  2. package/package.json +2 -3
  3. package/src/App.tsx +43 -12
  4. package/src/api/client.deleteResource.test.tsx +111 -0
  5. package/src/api/client.gitops-destination.test.tsx +55 -0
  6. package/src/api/client.resource-list.test.ts +76 -0
  7. package/src/api/client.resourceAudit.test.tsx +57 -0
  8. package/src/api/client.resourcePath.test.ts +107 -0
  9. package/src/api/client.ts +197 -57
  10. package/src/api/quotas.ts +9 -20
  11. package/src/api/radarFeatures.ts +2 -0
  12. package/src/api/resourceLists.test.ts +84 -0
  13. package/src/api/resourceLists.ts +71 -0
  14. package/src/components/capacity/CapacityDemand.tsx +6 -3
  15. package/src/components/capacity/CapacityOverview.tsx +14 -7
  16. package/src/components/capacity/CapacityPoolDetail.tsx +7 -5
  17. package/src/components/capacity/ClusterSchedulingCard.tsx +3 -3
  18. package/src/components/capacity/shared.tsx +9 -5
  19. package/src/components/cnpg/CNPGOverview.tsx +4 -1
  20. package/src/components/cnpg/CNPGView.tsx +1 -0
  21. package/src/components/cnpg/actions/useCNPGWriteGuard.tsx +1 -0
  22. package/src/components/compare/CompareResourcePicker.test.tsx +58 -0
  23. package/src/components/compare/CompareViewRoute.tsx +5 -1
  24. package/src/components/compare/useCompareCandidates.ts +1 -1
  25. package/src/components/compare/useCompareLauncher.tsx +4 -2
  26. package/src/components/diagnose/ApplyDialog.test.tsx +10 -0
  27. package/src/components/diagnose/ApplyDialog.tsx +8 -1
  28. package/src/components/diagnose/AssessmentCard.tsx +60 -0
  29. package/src/components/diagnose/DiagnoseSurface.tsx +5 -0
  30. package/src/components/diagnose/InvestigationEvidencePane.test.tsx +62 -2
  31. package/src/components/diagnose/InvestigationEvidenceSections.tsx +6 -5
  32. package/src/components/diagnose/InvestigationView.tsx +47 -13
  33. package/src/components/diagnose/StoryExcerpt.tsx +24 -5
  34. package/src/components/diagnose/assessmentCopy.ts +11 -0
  35. package/src/components/diagnose/investigationEvidence/adapters/changes.ts +36 -1
  36. package/src/components/diagnose/investigationEvidence/adapters/crossplane.test.tsx +85 -0
  37. package/src/components/diagnose/investigationEvidence/adapters/issues.ts +1 -0
  38. package/src/components/diagnose/investigationEvidence/adapters/listCoverage.test.ts +415 -0
  39. package/src/components/diagnose/investigationEvidence/adapters/prometheus.test.ts +2 -1
  40. package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +2 -1
  41. package/src/components/diagnose/investigationEvidence/adapters/resource.ts +107 -8
  42. package/src/components/diagnose/investigationEvidence/adapters/testdata/crossplane-paused-get-resource.json +28 -0
  43. package/src/components/diagnose/investigationEvidence/bodies/index.tsx +2 -0
  44. package/src/components/diagnose/investigationEvidence/bodies/inventory.tsx +66 -16
  45. package/src/components/diagnose/investigationEvidence/bodies/workload.tsx +5 -1
  46. package/src/components/diagnose/investigationEvidence/builder.ts +16 -2
  47. package/src/components/diagnose/investigationEvidence/cardParts.tsx +7 -2
  48. package/src/components/diagnose/investigationEvidence/excerpt.ts +2 -0
  49. package/src/components/diagnose/investigationEvidence/identity.test.ts +1 -1
  50. package/src/components/diagnose/investigationEvidence/observations.ts +8 -3
  51. package/src/components/diagnose/investigationEvidence/projection.test.ts +81 -4
  52. package/src/components/diagnose/investigationEvidence/types.ts +15 -0
  53. package/src/components/diagnose/investigationEvidencePresentation.test.ts +36 -2
  54. package/src/components/diagnose/investigationEvidencePresentation.ts +33 -8
  55. package/src/components/diagnose/storyParts.test.tsx +53 -0
  56. package/src/components/diagnose/toolCallLabel.test.ts +9 -0
  57. package/src/components/diagnose/toolCallLabel.ts +2 -0
  58. package/src/components/execution/BatchExecutionView.image-browse.test.tsx +46 -0
  59. package/src/components/execution/BatchExecutionView.tsx +6 -4
  60. package/src/components/gitops/GitOpsView.identity.test.tsx +113 -0
  61. package/src/components/gitops/GitOpsView.tsx +62 -40
  62. package/src/components/gitops/useDestinationCluster.ts +2 -1
  63. package/src/components/helm/ArtifactHubSourceSearch.test.tsx +124 -0
  64. package/src/components/helm/ArtifactHubSourceSearch.tsx +240 -0
  65. package/src/components/helm/ChartBrowser.tsx +9 -8
  66. package/src/components/helm/HelmReleaseDrawer.tsx +6 -2
  67. package/src/components/helm/HelmView.tsx +34 -23
  68. package/src/components/helm/InstallWizard.tsx +6 -2
  69. package/src/components/helm/TrackChartSourceDialog.render.test.tsx +269 -96
  70. package/src/components/helm/TrackChartSourceDialog.tsx +607 -104
  71. package/src/components/helm/ValuesViewer.test.tsx +1 -0
  72. package/src/components/helm/ValuesViewer.tsx +4 -2
  73. package/src/components/home/ClusterHealthCard.tsx +28 -21
  74. package/src/components/home/MCPSetupDialog.test.tsx +27 -2
  75. package/src/components/home/MCPSetupDialog.tsx +14 -2
  76. package/src/components/home/mcpToolCatalog.ts +39 -2
  77. package/src/components/issues/IssuesPane.render.test.tsx +5 -5
  78. package/src/components/nav/PrimaryNavRail.tsx +34 -2
  79. package/src/components/product-hunt/ProductHuntNotice.render.test.tsx +120 -0
  80. package/src/components/product-hunt/ProductHuntNotice.test.ts +121 -0
  81. package/src/components/product-hunt/ProductHuntNotice.tsx +202 -0
  82. package/src/components/product-hunt/launchWindow.ts +78 -0
  83. package/src/components/product-hunt/useProductHuntRailEntry.test.tsx +76 -0
  84. package/src/components/product-hunt/useProductHuntRailEntry.ts +27 -0
  85. package/src/components/resource/PrometheusCharts.overlays.test.ts +45 -0
  86. package/src/components/resource/PrometheusCharts.tsx +2 -2
  87. package/src/components/resources/CompositeRenderer.tsx +4 -0
  88. package/src/components/resources/ResourcesView.tsx +30 -68
  89. package/src/components/resources/renderers/PodRenderer.tsx +4 -1
  90. package/src/components/settings/LocalConnectionSettings.tsx +1 -0
  91. package/src/components/settings/MyPermissionsDialog.tsx +12 -9
  92. package/src/components/traffic/TrafficSourcePill.test.tsx +110 -0
  93. package/src/components/traffic/TrafficSourcePill.tsx +111 -0
  94. package/src/components/traffic/TrafficView.tsx +9 -55
  95. package/src/components/ui/DiagnosticsOverlay.test.ts +25 -0
  96. package/src/components/ui/DiagnosticsOverlay.tsx +2 -1
  97. package/src/components/ui/Omnibar.note.test.tsx +141 -0
  98. package/src/components/ui/Omnibar.tsx +82 -18
  99. package/src/components/ui/RadarOmnibar.test.tsx +201 -0
  100. package/src/components/ui/RadarOmnibar.tsx +39 -4
  101. package/src/components/ui/SearchSyntaxHelp.test.tsx +39 -0
  102. package/src/components/ui/SearchSyntaxHelp.tsx +23 -2
  103. package/src/components/ui/UpdateNotification.manual.test.tsx +177 -0
  104. package/src/components/ui/UpdateNotification.test.tsx +4 -1
  105. package/src/components/ui/UpdateNotification.tsx +61 -10
  106. package/src/components/ui/omnibar-match.test.ts +15 -8
  107. package/src/components/ui/omnibar-match.ts +11 -6
  108. package/src/components/ui/searchCoverage.fixtures.ts +16 -0
  109. package/src/components/ui/searchCoverageNote.test.ts +245 -0
  110. package/src/components/ui/searchCoverageNote.ts +222 -0
  111. package/src/components/usage-data/UsageDataPrompt.tsx +19 -1
  112. package/src/components/whats-new/WhatsNew.test.ts +10 -0
  113. package/src/components/whats-new/WhatsNew.tsx +5 -4
  114. package/src/components/whats-new/WhatsNewDialog.test.tsx +20 -0
  115. package/src/components/whats-new/releaseNotes.ts +57 -5
  116. package/src/components/workload/WorkloadView.tsx +18 -6
  117. package/src/components/workspace/layout.tsx +2 -1
  118. package/src/contexts/CapabilitiesContext.tsx +1 -0
  119. package/src/hooks/useGitOpsWriteGuard.test.tsx +126 -2
  120. package/src/hooks/useGitOpsWriteGuard.ts +25 -3
  121. package/src/hooks/useResolvedGitOpsOwner.ts +14 -9
  122. package/src/hooks/useResourceCounts.ts +2 -0
  123. package/src/index.css +87 -4
  124. package/src/index.ts +7 -0
  125. package/src/utils/artifacthub.test.ts +18 -0
  126. package/src/utils/artifacthub.ts +9 -0
@@ -0,0 +1,121 @@
1
+ import { afterEach, describe, expect, it, vi } from 'vitest'
2
+
3
+ vi.mock('../../api/client', () => ({ useCapabilities: () => ({ data: undefined }), useVersionCheck: () => ({ data: undefined }) }))
4
+ vi.mock('../../api/usage-data', () => ({ useSetUsageData: () => ({ mutate: vi.fn(), isPending: false }), useMarkUsagePromptShown: () => vi.fn() }))
5
+
6
+ import { launchLink, shouldShowLaunchNotice } from './ProductHuntNotice'
7
+ import { FALLBACK_LAUNCH, isPhaseDismissed, launchDayLabel, launchNoticeHoldsCorner, launchPhase, markPhaseDismissed, resolveLaunch } from './launchWindow'
8
+
9
+ const launch = FALLBACK_LAUNCH
10
+
11
+ describe('launchPhase', () => {
12
+ it('is upcoming before Product Hunt day starts in Pacific time', () => {
13
+ expect(launchPhase(launch, Date.parse('2026-10-28T12:00:00Z'))).toBe('upcoming')
14
+ expect(launchPhase(launch, Date.parse('2026-10-28T23:59:59-07:00'))).toBe('upcoming')
15
+ })
16
+
17
+ it('is live for the whole Pacific day of Oct 29', () => {
18
+ expect(launchPhase(launch, Date.parse('2026-10-29T00:00:00-07:00'))).toBe('live')
19
+ expect(launchPhase(launch, Date.parse('2026-10-29T09:01:00+02:00'))).toBe('live')
20
+ expect(launchPhase(launch, Date.parse('2026-10-29T23:59:59-07:00'))).toBe('live')
21
+ })
22
+
23
+ it('is over once the Pacific day ends', () => {
24
+ expect(launchPhase(launch, Date.parse('2026-10-30T00:00:00-07:00'))).toBe(null)
25
+ expect(launchPhase(launch, Date.parse('2026-11-15T00:00:00Z'))).toBe(null)
26
+ })
27
+ })
28
+
29
+ describe('resolveLaunch', () => {
30
+ it('uses the built-in launch only when the version check says nothing', () => {
31
+ expect(resolveLaunch(undefined)).toBe(FALLBACK_LAUNCH)
32
+ })
33
+
34
+ it('follows a moved or cancelled launch from the version check', () => {
35
+ const moved = resolveLaunch({ enabled: true, url: launch.url, start: '2026-11-05T08:00:00Z', end: '2026-11-06T08:00:00Z' })
36
+ expect(launchPhase(moved, Date.parse('2026-10-29T12:00:00Z'))).toBe('upcoming')
37
+ expect(launchPhase(moved, Date.parse('2026-11-05T12:00:00Z'))).toBe('live')
38
+ expect(launchDayLabel(moved)).toBe('Nov 5')
39
+
40
+ const cancelled = resolveLaunch({ enabled: false, url: '', start: '0001-01-01T00:00:00Z', end: '0001-01-01T00:00:00Z' })
41
+ expect(launchPhase(cancelled, Date.parse('2026-10-28T12:00:00Z'))).toBe(null)
42
+ expect(launchPhase(cancelled, Date.parse('2026-10-29T12:00:00Z'))).toBe(null)
43
+ })
44
+
45
+ it('labels the day on Product Hunt time and tags the link', () => {
46
+ expect(launchDayLabel(launch)).toBe('Oct 29')
47
+ const link = new URL(launchLink(launch))
48
+ expect(link.searchParams.get('launch')).toBe('radar-101')
49
+ expect(link.searchParams.get('utm_source')).toBe('radar-oss')
50
+ expect(link.searchParams.get('utm_campaign')).toBe('ph-launch-2026-10')
51
+ })
52
+ })
53
+
54
+ describe('shouldShowLaunchNotice', () => {
55
+ const base = { phase: 'live' as const, deploymentMode: 'local', dismissed: false, ready: true, cornerBusy: false }
56
+
57
+ it('shows on a local install with the corner free', () => {
58
+ expect(shouldShowLaunchNotice(base)).toBe(true)
59
+ expect(shouldShowLaunchNotice({ ...base, phase: 'upcoming' })).toBe(true)
60
+ })
61
+
62
+ it('shows in-cluster on launch day only, and never in Cloud or before capabilities load', () => {
63
+ expect(shouldShowLaunchNotice({ ...base, deploymentMode: 'in-cluster' })).toBe(true)
64
+ expect(shouldShowLaunchNotice({ ...base, deploymentMode: 'in-cluster', phase: 'upcoming' })).toBe(false)
65
+ expect(shouldShowLaunchNotice({ ...base, deploymentMode: 'cloud' })).toBe(false)
66
+ expect(shouldShowLaunchNotice({ ...base, deploymentMode: undefined })).toBe(false)
67
+ })
68
+
69
+ it('stays away once dismissed, outside the window, before the delay, or while another notice holds the corner', () => {
70
+ expect(shouldShowLaunchNotice({ ...base, dismissed: true })).toBe(false)
71
+ expect(shouldShowLaunchNotice({ ...base, phase: null })).toBe(false)
72
+ expect(shouldShowLaunchNotice({ ...base, ready: false })).toBe(false)
73
+ expect(shouldShowLaunchNotice({ ...base, cornerBusy: true })).toBe(false)
74
+ })
75
+ })
76
+
77
+ describe('isPhaseDismissed', () => {
78
+ const store = new Map<string, string>()
79
+ vi.stubGlobal('localStorage', {
80
+ getItem: (k: string) => store.get(k) ?? null,
81
+ setItem: (k: string, v: string) => void store.set(k, v),
82
+ })
83
+ afterEach(() => store.clear())
84
+
85
+ it('keeps the launch-day card for someone who closed the one before it', () => {
86
+ store.set('radar-product-hunt-dismissed-2026-10-29-upcoming', '1')
87
+ expect(isPhaseDismissed(launch, 'upcoming')).toBe(true)
88
+ expect(isPhaseDismissed(launch, 'live')).toBe(false)
89
+ })
90
+
91
+ it('announces a moved launch again', () => {
92
+ store.set('radar-product-hunt-dismissed-2026-10-29-upcoming', '1')
93
+ const moved = resolveLaunch({ enabled: true, url: launch.url, start: '2026-11-05T08:00:00Z', end: '2026-11-06T08:00:00Z' })
94
+ expect(isPhaseDismissed(moved, 'upcoming')).toBe(false)
95
+ })
96
+
97
+ it('holds the corner on launch day until the launch-day card is dismissed', () => {
98
+ const before = Date.parse('2026-10-28T12:00:00Z')
99
+ const during = Date.parse('2026-10-29T10:00:00-07:00')
100
+ const after = Date.parse('2026-10-30T01:00:00-07:00')
101
+ expect(launchNoticeHoldsCorner(launch, before)).toBe(false)
102
+ expect(launchNoticeHoldsCorner(launch, during)).toBe(true)
103
+ expect(launchNoticeHoldsCorner(launch, after)).toBe(false)
104
+ store.set('radar-product-hunt-dismissed-2026-10-29-live', '1')
105
+ expect(launchNoticeHoldsCorner(launch, during)).toBe(false)
106
+ })
107
+
108
+ it('frees the corner for this page when localStorage refuses the dismissal', () => {
109
+ const later = resolveLaunch({ enabled: true, url: launch.url, start: '2026-11-12T08:00:00Z', end: '2026-11-13T08:00:00Z' })
110
+ const during = Date.parse('2026-11-12T10:00:00-08:00')
111
+ vi.stubGlobal('localStorage', {
112
+ getItem: () => { throw new Error('denied') },
113
+ setItem: () => { throw new Error('denied') },
114
+ })
115
+ vi.stubGlobal('window', { dispatchEvent: vi.fn() })
116
+ expect(launchNoticeHoldsCorner(later, during)).toBe(true)
117
+ markPhaseDismissed(later, 'live')
118
+ expect(launchNoticeHoldsCorner(later, during)).toBe(false)
119
+ expect(isPhaseDismissed(later, 'upcoming')).toBe(false)
120
+ })
121
+ })
@@ -0,0 +1,202 @@
1
+ import { useEffect, useReducer, useState } from 'react'
2
+ import type { CSSProperties } from 'react'
3
+ import { clsx } from 'clsx'
4
+ import { Heart, Rocket, X } from 'lucide-react'
5
+ import { useCapabilities, useVersionCheck } from '../../api/client'
6
+ import type { UsageDataStatus } from '../../api/usage-data'
7
+ import { USAGE_PROMPT_VISIBILITY_EVENT, updateNoticeVisible, usagePromptOnScreen } from '../usage-data/UsageDataPrompt'
8
+ import { useAnimatedUnmount } from '../../hooks/useAnimatedUnmount'
9
+ import { TRANSITION_MENU } from '../../utils/animation'
10
+ import { LAUNCH_NOTICE_REOPEN_EVENT, LAUNCH_RAIL_ITEM_ID, isPhaseDismissed, launchDayLabel, launchPhase, launchShownIn, markPhaseDismissed, resolveLaunch, type LaunchPhase, type ProductHuntLaunch } from './launchWindow'
11
+
12
+ // The same tag for every install: it says the click came from inside Radar,
13
+ // nothing about who clicked.
14
+ const UTM = { utm_source: 'radar-oss', utm_medium: 'app', utm_campaign: 'ph-launch-2026-10' }
15
+ const FEATURE_URL = `https://radarhq.io/product/ai-investigations?${new URLSearchParams(UTM)}`
16
+ const SHOW_DELAY_MS = 10_000
17
+ const LAUNCH_RECHECK_MS = 60 * 60_000
18
+ // Long enough to read as growing out of the sidebar item, not snapping in.
19
+ const ENTER_MS = 320
20
+ const EXIT_MS = 220
21
+
22
+ export function shouldShowLaunchNotice(opts: {
23
+ phase: LaunchPhase | null
24
+ deploymentMode: string | undefined
25
+ dismissed: boolean
26
+ ready: boolean
27
+ cornerBusy: boolean
28
+ }): boolean {
29
+ return opts.phase !== null && launchShownIn(opts.deploymentMode, opts.phase) && !opts.dismissed && opts.ready && !opts.cornerBusy
30
+ }
31
+
32
+ export function launchLink(launch: ProductHuntLaunch): string {
33
+ const url = new URL(launch.url)
34
+ for (const [key, value] of Object.entries(UTM)) url.searchParams.set(key, value)
35
+ return url.toString()
36
+ }
37
+
38
+ // A one-off notice for the October 2026 Product Hunt launch, whose date and
39
+ // link come from the update check. Before the day it waits its turn behind the
40
+ // update notice and the first-run usage prompt; on the day they wait for it.
41
+ // Each phase is dismissed on its own, so the launch-day card still shows to
42
+ // someone who closed the one before.
43
+ export function ProductHuntNotice({ usageData, usageDataPending }: { usageData: UsageDataStatus | undefined; usageDataPending: boolean }) {
44
+ const { data: capabilities } = useCapabilities()
45
+ const { data: versionInfo, isPending: versionPending, refetch: refetchVersion } = useVersionCheck()
46
+ const [now, setNow] = useState(() => Date.now())
47
+ const [ready, setReady] = useState(false)
48
+
49
+ const [usagePromptShowing, setUsagePromptShowing] = useState(usagePromptOnScreen)
50
+ const launch = resolveLaunch(versionInfo?.productHuntLaunch)
51
+ const phase = launchPhase(launch, now)
52
+ const ended = phase === null
53
+
54
+ useEffect(() => {
55
+ if (ended) return
56
+ const delay = window.setTimeout(() => setReady(true), SHOW_DELAY_MS)
57
+ // Re-reads the clock for the phase change, and the update notice's
58
+ // dismissal, which only touches localStorage.
59
+ const poll = window.setInterval(() => setNow(Date.now()), 60_000)
60
+ // Picks up a launch moved or called off while this page stays open.
61
+ const recheck = window.setInterval(() => void refetchVersion(), LAUNCH_RECHECK_MS)
62
+ return () => {
63
+ window.clearTimeout(delay)
64
+ window.clearInterval(poll)
65
+ window.clearInterval(recheck)
66
+ }
67
+ }, [ended, refetchVersion])
68
+
69
+ // Opened again from the sidebar: shows at once, over whatever holds the corner.
70
+ const [reopened, setReopened] = useState(false)
71
+ // Re-renders after a dismissal, which lives outside React state.
72
+ const [, rerender] = useReducer((n: number) => n + 1, 0)
73
+ useEffect(() => {
74
+ const onReopen = () => setReopened(true)
75
+ window.addEventListener(LAUNCH_NOTICE_REOPEN_EVENT, onReopen)
76
+ return () => window.removeEventListener(LAUNCH_NOTICE_REOPEN_EVENT, onReopen)
77
+ }, [])
78
+
79
+ // Tracked whatever the launch, so a launch switched back on sees a usage
80
+ // prompt that opened meanwhile.
81
+ useEffect(() => {
82
+ const onUsagePrompt = () => setUsagePromptShowing(usagePromptOnScreen())
83
+ window.addEventListener(USAGE_PROMPT_VISIBILITY_EVENT, onUsagePrompt)
84
+ return () => window.removeEventListener(USAGE_PROMPT_VISIBILITY_EVENT, onUsagePrompt)
85
+ }, [])
86
+
87
+ const show = shouldShowLaunchNotice({
88
+ phase,
89
+ deploymentMode: capabilities ? (capabilities.deployment?.mode ?? 'local') : undefined,
90
+ dismissed: phase !== null && isPhaseDismissed(launch, phase) && !reopened,
91
+ // Waits for the version check, which says whether the launch is still on.
92
+ ready: (reopened || ready) && !versionPending,
93
+ // A card already on screen keeps the corner, whatever the day.
94
+ cornerBusy: !reopened && (usagePromptShowing || (phase === 'upcoming' && (
95
+ updateNoticeVisible(versionInfo?.latestVersion, versionInfo?.updateAvailable) || usageDataPending || !!usageData?.firstRunPrompt
96
+ ))),
97
+ })
98
+ const { shouldRender, isOpen } = useAnimatedUnmount(show, EXIT_MS)
99
+ // Beside the sidebar's Product Hunt item, growing out of it; the bottom-right
100
+ // corner when the sidebar isn't there (narrow windows, embedded).
101
+ const [anchor, setAnchor] = useState<{ left: number; bottom: number } | null>(null)
102
+ useEffect(() => {
103
+ if (!shouldRender) return
104
+ const item = document.getElementById(LAUNCH_RAIL_ITEM_ID)
105
+ let frame = 0
106
+ const place = () => {
107
+ cancelAnimationFrame(frame)
108
+ frame = requestAnimationFrame(() => {
109
+ const r = item?.getBoundingClientRect()
110
+ setAnchor(r && r.width > 0 ? { left: r.right + 8, bottom: Math.max(16, window.innerHeight - r.bottom) } : null)
111
+ })
112
+ }
113
+ place()
114
+ const observer = item && typeof ResizeObserver !== 'undefined' ? new ResizeObserver(place) : null
115
+ if (item) observer?.observe(item)
116
+ window.addEventListener('resize', place)
117
+ return () => {
118
+ cancelAnimationFrame(frame)
119
+ observer?.disconnect()
120
+ window.removeEventListener('resize', place)
121
+ }
122
+ }, [shouldRender])
123
+ // What the card last showed, kept through the exit fade: the day can end, or
124
+ // the launch be called off, while it is on screen.
125
+ const [shown, setShown] = useState<{ phase: LaunchPhase; launch: ProductHuntLaunch } | null>(null)
126
+ if (show && phase !== null && (shown?.phase !== phase || shown.launch.url !== launch.url || shown.launch.start !== launch.start)) {
127
+ setShown({ phase, launch })
128
+ }
129
+ if (!shouldRender || !shown) return null
130
+
131
+ const dismiss = () => {
132
+ markPhaseDismissed(shown.launch, shown.phase)
133
+ setReopened(false)
134
+ rerender()
135
+ }
136
+
137
+ const placement: CSSProperties = anchor
138
+ ? { left: anchor.left, bottom: anchor.bottom, maxWidth: `calc(100vw - ${anchor.left + 16}px)`, maxHeight: `calc(100vh - ${anchor.bottom + 16}px)` }
139
+ : { right: 16, bottom: 16, maxWidth: 'calc(100vw - 2rem)', maxHeight: 'calc(100vh - 2rem)' }
140
+
141
+ return (
142
+ <div
143
+ role="dialog"
144
+ aria-label="Radar on Product Hunt"
145
+ inert={!show || undefined}
146
+ className={clsx(
147
+ 'launch-border fixed z-40 w-[24rem] rounded-xl border border-emerald-500/40 dark:border-emerald-400/30 shadow-[0_10px_40px_-6px_rgba(16,185,129,0.6)] dark:shadow-[0_10px_40px_-8px_rgba(16,185,129,0.45)]',
148
+ anchor ? 'origin-bottom-left' : 'origin-bottom-right',
149
+ TRANSITION_MENU,
150
+ isOpen ? 'opacity-100 translate-x-0 translate-y-0 scale-100' : anchor ? 'opacity-0 -translate-x-3 scale-75' : 'opacity-0 translate-y-1 scale-[0.97]',
151
+ !show && 'pointer-events-none',
152
+ )}
153
+ style={{ ...placement, transitionDuration: `${isOpen ? ENTER_MS : EXIT_MS}ms` }}
154
+ >
155
+ <div className="relative flex gap-3 p-4 rounded-[11px] max-h-[inherit] overflow-y-auto bg-theme-surface bg-gradient-to-br from-emerald-500/12 via-emerald-500/4 to-transparent dark:from-emerald-400/18 dark:via-emerald-400/6">
156
+ <button
157
+ type="button"
158
+ onClick={dismiss}
159
+ aria-label="Close"
160
+ className="absolute top-2.5 right-2.5 p-1 rounded text-theme-text-tertiary hover:text-theme-text-primary hover:bg-theme-elevated"
161
+ >
162
+ <X className="w-3.5 h-3.5" />
163
+ </button>
164
+ <span className="flex items-center justify-center w-9 h-9 shrink-0 rounded-lg bg-emerald-500 text-white shadow-[0_4px_14px_-4px_rgba(16,185,129,0.6)]">
165
+ <Rocket className="w-4 h-4 animate-launch-rocket" aria-hidden />
166
+ </span>
167
+ <div className="min-w-0">
168
+ <p className="flex items-center gap-1.5 pr-6 text-sm font-medium text-theme-text-primary">
169
+ Radar <Heart className="w-3.5 h-3.5 fill-current text-red-500 dark:text-red-400" aria-label="loves" /> Agents
170
+ </p>
171
+ <p className="text-xs font-medium text-emerald-700 dark:text-emerald-300 mt-0.5">
172
+ {shown.phase === 'live' ? 'Live on Product Hunt today' : `Launching on Product Hunt ${launchDayLabel(shown.launch)}`}
173
+ </p>
174
+ <p className="text-xs text-theme-text-secondary mt-1.5">
175
+ {shown.phase === 'live'
176
+ ? "We're on Product Hunt today with Radar's newly upgraded MCP server and AI investigations. If Radar has made Kubernetes a little easier for you, a comment on the launch would mean a lot. It helps other engineers find Radar."
177
+ : "We're launching Radar's newly upgraded MCP server and AI investigations on Product Hunt. If Radar has made Kubernetes a little easier for you, follow the launch and come say hi on the day. It helps other engineers find Radar."}
178
+ </p>
179
+ <div className="flex items-center gap-3 mt-3">
180
+ <a
181
+ href={launchLink(shown.launch)}
182
+ target="_blank"
183
+ rel="noopener noreferrer"
184
+ onClick={dismiss}
185
+ className="inline-flex items-center rounded-lg bg-emerald-600 hover:bg-emerald-700 dark:bg-emerald-500 dark:hover:bg-emerald-400 px-3 py-1.5 text-xs font-semibold text-white dark:text-emerald-950 whitespace-nowrap transition-colors"
186
+ >
187
+ {shown.phase === 'live' ? 'Comment on Product Hunt →' : 'Follow on Product Hunt →'}
188
+ </a>
189
+ <a
190
+ href={FEATURE_URL}
191
+ target="_blank"
192
+ rel="noopener noreferrer"
193
+ className="text-xs text-theme-text-tertiary hover:text-theme-text-secondary hover:underline whitespace-nowrap"
194
+ >
195
+ How it works
196
+ </a>
197
+ </div>
198
+ </div>
199
+ </div>
200
+ </div>
201
+ )
202
+ }
@@ -0,0 +1,78 @@
1
+ import type { VersionInfo } from '../../api/client'
2
+
3
+ // The launch as the update check last described it (internal/launchday), so it
4
+ // can move or be called off without a release.
5
+ export type ProductHuntLaunch = { enabled: boolean; url: string; start: number; end: number }
6
+
7
+ // Used only when Radar's version check doesn't answer. Product Hunt's day runs
8
+ // midnight to midnight Pacific; PDT is UTC-7 until Nov 1.
9
+ export const FALLBACK_LAUNCH: ProductHuntLaunch = {
10
+ enabled: true,
11
+ url: 'https://www.producthunt.com/products/radar-7?launch=radar-101',
12
+ start: Date.parse('2026-10-29T07:00:00Z'),
13
+ end: Date.parse('2026-10-30T07:00:00Z'),
14
+ }
15
+
16
+ export const LAUNCH_NOTICE_DISMISSED_EVENT = 'radar:product-hunt-notice-dismissed'
17
+ // Sent by the sidebar's Product Hunt item to bring a dismissed card back.
18
+ export const LAUNCH_NOTICE_REOPEN_EVENT = 'radar:product-hunt-notice-reopen'
19
+ // The sidebar item the card opens from and closes into.
20
+ export const LAUNCH_RAIL_ITEM_ID = 'product-hunt-rail-item'
21
+
22
+ export type LaunchPhase = 'upcoming' | 'live'
23
+
24
+ // In-cluster Radar is often shared by people who didn't install it, so they
25
+ // get only the launch day.
26
+ export function launchShownIn(deploymentMode: string | undefined, phase: LaunchPhase): boolean {
27
+ return deploymentMode === 'local' || (deploymentMode === 'in-cluster' && phase === 'live')
28
+ }
29
+
30
+ export function resolveLaunch(fromServer: VersionInfo['productHuntLaunch']): ProductHuntLaunch {
31
+ if (!fromServer) return FALLBACK_LAUNCH
32
+ return { enabled: fromServer.enabled, url: fromServer.url, start: Date.parse(fromServer.start), end: Date.parse(fromServer.end) }
33
+ }
34
+
35
+ export function launchPhase(launch: ProductHuntLaunch, now: number): LaunchPhase | null {
36
+ if (!launch.enabled || !(now < launch.end)) return null
37
+ return now >= launch.start ? 'live' : 'upcoming'
38
+ }
39
+
40
+ // "Oct 29": the launch day on Product Hunt's own clock.
41
+ export function launchDayLabel(launch: ProductHuntLaunch): string {
42
+ return new Date(launch.start).toLocaleDateString('en-US', { month: 'short', day: 'numeric', timeZone: 'America/Los_Angeles' })
43
+ }
44
+
45
+ // Keyed by launch day, so a moved launch is announced again.
46
+ function dismissedKey(launch: ProductHuntLaunch, phase: LaunchPhase): string {
47
+ return `radar-product-hunt-dismissed-${new Date(launch.start).toISOString().slice(0, 10)}-${phase}`
48
+ }
49
+
50
+ // Covers this page when localStorage is unavailable.
51
+ const dismissedThisPage = new Set<string>()
52
+
53
+ export function isPhaseDismissed(launch: ProductHuntLaunch, phase: LaunchPhase): boolean {
54
+ const key = dismissedKey(launch, phase)
55
+ if (dismissedThisPage.has(key)) return true
56
+ try {
57
+ return localStorage.getItem(key) !== null
58
+ } catch {
59
+ return false
60
+ }
61
+ }
62
+
63
+ export function markPhaseDismissed(launch: ProductHuntLaunch, phase: LaunchPhase): void {
64
+ const key = dismissedKey(launch, phase)
65
+ dismissedThisPage.add(key)
66
+ try {
67
+ localStorage.setItem(key, '1')
68
+ } catch {
69
+ // localStorage unavailable: dismissedThisPage keeps it for this page
70
+ }
71
+ window.dispatchEvent(new Event(LAUNCH_NOTICE_DISMISSED_EVENT))
72
+ }
73
+
74
+ // On launch day the Product Hunt card goes first: the update notice and the
75
+ // first-run usage prompt wait until it is dismissed or the day is over.
76
+ export function launchNoticeHoldsCorner(launch: ProductHuntLaunch, now: number): boolean {
77
+ return launchPhase(launch, now) === 'live' && !isPhaseDismissed(launch, 'live')
78
+ }
@@ -0,0 +1,76 @@
1
+ // @vitest-environment jsdom
2
+ import { act } from 'react'
3
+ import { createRoot, type Root } from 'react-dom/client'
4
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
5
+
6
+ const state = vi.hoisted(() => ({ mode: 'local', pending: false }))
7
+ vi.mock('../../api/client', () => ({
8
+ useCapabilities: () => ({ data: { deployment: { mode: state.mode } } }),
9
+ useVersionCheck: () => ({ data: undefined, isPending: state.pending }),
10
+ }))
11
+
12
+ import { useProductHuntRailEntry } from './useProductHuntRailEntry'
13
+
14
+ Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
15
+ let root: Root
16
+ const seen = vi.fn<(entry: ReturnType<typeof useProductHuntRailEntry>) => void>()
17
+ const entry = () => seen.mock.lastCall?.[0]
18
+
19
+ function Probe() {
20
+ seen(useProductHuntRailEntry())
21
+ return null
22
+ }
23
+
24
+ function mount() {
25
+ root = createRoot(document.createElement('div'))
26
+ act(() => root.render(<Probe />))
27
+ }
28
+
29
+ beforeEach(() => {
30
+ vi.useFakeTimers()
31
+ vi.setSystemTime(new Date('2026-10-29T17:00:00Z'))
32
+ localStorage.clear()
33
+ state.mode = 'local'
34
+ state.pending = false
35
+ seen.mockClear()
36
+ })
37
+
38
+ afterEach(() => {
39
+ act(() => root.unmount())
40
+ vi.useRealTimers()
41
+ })
42
+
43
+ describe('useProductHuntRailEntry', () => {
44
+ it('is there for the launch window, and opens the card', () => {
45
+ mount()
46
+ expect(entry()?.id).toBe('product-hunt-rail-item')
47
+ expect(entry()?.badge).toBe('Today')
48
+ const reopen = vi.fn()
49
+ window.addEventListener('radar:product-hunt-notice-reopen', reopen)
50
+ entry()?.onOpen()
51
+ expect(reopen).toHaveBeenCalledTimes(1)
52
+ })
53
+
54
+ it('stays away in-cluster before the day and after the window', () => {
55
+ state.mode = 'in-cluster'
56
+ vi.setSystemTime(new Date('2026-10-28T17:00:00Z'))
57
+ mount()
58
+ expect(entry()).toBeUndefined()
59
+ act(() => root.unmount())
60
+
61
+ state.mode = 'local'
62
+ mount()
63
+ expect(entry()?.badge).toBe('Oct 29')
64
+ act(() => root.unmount())
65
+
66
+ vi.setSystemTime(new Date('2026-10-30T17:00:00Z'))
67
+ mount()
68
+ expect(entry()).toBeUndefined()
69
+ })
70
+
71
+ it('waits for the version check, which may have moved or cancelled the launch', () => {
72
+ state.pending = true
73
+ mount()
74
+ expect(entry()).toBeUndefined()
75
+ })
76
+ })
@@ -0,0 +1,27 @@
1
+ import { useEffect, useState } from 'react'
2
+ import { useCapabilities, useVersionCheck } from '../../api/client'
3
+ import { LAUNCH_NOTICE_REOPEN_EVENT, LAUNCH_RAIL_ITEM_ID, launchDayLabel, launchPhase, launchShownIn, resolveLaunch } from './launchWindow'
4
+
5
+ // The sidebar's Product Hunt item: where the launch card opens from and closes
6
+ // into, there for the launch window to whoever the card is for.
7
+ export function useProductHuntRailEntry(): { onOpen: () => void; id: string; badge: string } | undefined {
8
+ const { data: capabilities } = useCapabilities()
9
+ const { data: versionInfo, isPending: versionPending } = useVersionCheck()
10
+ const [now, setNow] = useState(() => Date.now())
11
+ const launch = resolveLaunch(versionInfo?.productHuntLaunch)
12
+ const phase = launchPhase(launch, now)
13
+ const ended = phase === null
14
+
15
+ useEffect(() => {
16
+ if (ended) return
17
+ const poll = window.setInterval(() => setNow(Date.now()), 60_000)
18
+ return () => window.clearInterval(poll)
19
+ }, [ended])
20
+
21
+ const mode = capabilities ? (capabilities.deployment?.mode ?? 'local') : undefined
22
+ // Waits for the version check, which says whether the launch is still on.
23
+ if (versionPending || phase === null || !launchShownIn(mode, phase)) return undefined
24
+ // Tagged with the day, so it reads as happening now and gone after.
25
+ const badge = phase === 'live' ? 'Today' : launchDayLabel(launch)
26
+ return { id: LAUNCH_RAIL_ITEM_ID, badge, onOpen: () => window.dispatchEvent(new Event(LAUNCH_NOTICE_REOPEN_EVENT)) }
27
+ }
@@ -19,4 +19,49 @@ describe('Pod request and limit overlays', () => {
19
19
  } } } }
20
20
  expect(computeRequestLimitLines(resource, 'Deployment', 'cpu')![0].value).toBeCloseTo(1.2)
21
21
  })
22
+
23
+ it.each([
24
+ ['1024000m', '2048000m'],
25
+ ['1024000000u', '2048000000u'],
26
+ ['1024000000000n', '2048000000000n'],
27
+ ['1.024k', '2.048k'],
28
+ ['1.024K', '2.048K'],
29
+ ])('reads memory request %s and limit %s as bytes', (request, limit) => {
30
+ const resource = { spec: { containers: [
31
+ { resources: { requests: { memory: request }, limits: { memory: limit } } },
32
+ ] } }
33
+ expect(computeRequestLimitLines(resource, 'Pod', 'memory')).toEqual([
34
+ { value: 1024, label: 'request 1KiB', kind: 'request' },
35
+ { value: 2048, label: 'limit 2KiB', kind: 'limit' },
36
+ ])
37
+ })
38
+
39
+ it('sums binary and millibyte quantities across containers and native sidecars', () => {
40
+ const resource = { spec: { template: { spec: {
41
+ containers: [{ resources: { requests: { memory: '16Gi' }, limits: { memory: '16Gi' } } }],
42
+ initContainers: [{ restartPolicy: 'Always', resources: {
43
+ requests: { memory: '1181116006400m' }, limits: { memory: '1073741824000m' },
44
+ } }],
45
+ } } } }
46
+ const lines = computeRequestLimitLines(resource, 'Deployment', 'memory')!
47
+ expect(lines[0].value).toBeCloseTo(18360985190.4)
48
+ expect(lines[0].label).toBe('request 17.1GiB')
49
+ expect(lines[1]).toEqual({ value: 17 * 1024 ** 3, label: 'limit 17.0GiB', kind: 'limit' })
50
+ })
51
+
52
+ it.each(['abcMi', 'abcm', 'abcu', 'abcn', '', undefined])('omits unreadable memory quantities: %s', (memory) => {
53
+ const resource = { spec: { containers: [
54
+ { resources: { requests: { memory }, limits: { memory } } },
55
+ ] } }
56
+ expect(computeRequestLimitLines(resource, 'Pod', 'memory')).toBeUndefined()
57
+ })
58
+
59
+ it('retains a genuine zero request while omitting a zero limit', () => {
60
+ const resource = { spec: { containers: [
61
+ { resources: { requests: { memory: '0m' }, limits: { memory: '0m' } } },
62
+ ] } }
63
+ expect(computeRequestLimitLines(resource, 'Pod', 'memory')).toEqual([
64
+ { value: 0, label: 'request 0KiB', kind: 'request' },
65
+ ])
66
+ })
22
67
  })
@@ -209,7 +209,7 @@ function collectRuntimeContainers(podSpec: any): any[] {
209
209
  const CPU_SUFFIXES: Record<string, number> = { n: 1e-9, u: 1e-6, m: 1e-3 }
210
210
  const MEMORY_SUFFIXES: Record<string, number> = {
211
211
  Ki: 1024, Mi: 1024 ** 2, Gi: 1024 ** 3, Ti: 1024 ** 4, Pi: 1024 ** 5, Ei: 1024 ** 6,
212
- K: 1e3, M: 1e6, G: 1e9, T: 1e12, P: 1e15, E: 1e18,
212
+ n: 1e-9, u: 1e-6, m: 1e-3, k: 1e3, K: 1e3, M: 1e6, G: 1e9, T: 1e12, P: 1e15, E: 1e18,
213
213
  }
214
214
 
215
215
  // NOT a duplicate of @skyhook-io/k8s-ui/utils/format's parseCPUToNanocores /
@@ -232,7 +232,7 @@ function readQuantity(raw: unknown, category: 'cpu' | 'memory'): number | null {
232
232
  for (const suffix of ['Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei']) {
233
233
  if (s.endsWith(suffix)) return scaleOrNull(s, MEMORY_SUFFIXES[suffix])
234
234
  }
235
- for (const suffix of ['K', 'M', 'G', 'T', 'P', 'E']) {
235
+ for (const suffix of ['n', 'u', 'm', 'k', 'K', 'M', 'G', 'T', 'P', 'E']) {
236
236
  if (s.endsWith(suffix)) return scaleOrNull(s, MEMORY_SUFFIXES[suffix])
237
237
  }
238
238
  const v = parseFloat(s)
@@ -8,6 +8,9 @@ import {
8
8
  import {
9
9
  getCrossplaneResourceRefs,
10
10
  getBoundXRRef,
11
+ getCrossplanePauseState,
12
+ isManagedResource,
13
+ isComposite,
11
14
  isClaim,
12
15
  type CrossplaneResourceRef,
13
16
  } from '@skyhook-io/k8s-ui/components/resources/resource-utils-crossplane'
@@ -140,6 +143,7 @@ export function CompositeRenderer({ data, onNavigate }: CompositeRendererProps)
140
143
  const status = getResourceStatus(kindToPluralWithGroup(ref.kind, groupFromApiVersion(ref.apiVersion)), q.data.resource) ?? undefined
141
144
  map.set(key, {
142
145
  ref,
146
+ pauseState: isManagedResource(q.data.resource) || isComposite(q.data.resource) || getCrossplanePauseState(q.data.resource) === 'acknowledged' ? getCrossplanePauseState(q.data.resource) : null,
143
147
  status: status ? { ...status, level: (status as any).level ?? 'unknown' } : undefined,
144
148
  })
145
149
  })