@skyhook-io/radar-app 1.20.3 → 1.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/package.json +10 -9
  2. package/src/App.tsx +67 -15
  3. package/src/api/client.audit-gating.test.tsx +105 -5
  4. package/src/api/client.auditBadgesSync.test.tsx +118 -0
  5. package/src/api/client.capabilitiesPoll.test.ts +61 -0
  6. package/src/api/client.ts +129 -5
  7. package/src/api/namespaceScopeRetry.test.ts +14 -0
  8. package/src/api/radarFeatures.ts +11 -0
  9. package/src/api/substrateHealth.ts +134 -0
  10. package/src/api/velero.test.ts +60 -0
  11. package/src/api/velero.ts +377 -0
  12. package/src/api/vulnerabilities.ts +313 -0
  13. package/src/components/NamespaceSwitcher.tsx +3 -1
  14. package/src/components/audit/AuditView.tsx +4 -0
  15. package/src/components/audit/ChecksViewTabs.test.tsx +35 -5
  16. package/src/components/audit/ChecksViewTabs.tsx +12 -1
  17. package/src/components/audit/Java4ShellPanel.test.tsx +31 -0
  18. package/src/components/audit/Java4ShellPanel.tsx +313 -0
  19. package/src/components/audit/UpgradeReadinessView.test.ts +35 -1
  20. package/src/components/audit/UpgradeReadinessView.tsx +60 -2
  21. package/src/components/audit/VulnerabilitiesView.tsx +944 -0
  22. package/src/components/cnpg/CNPGClusterTabs.tsx +3 -1
  23. package/src/components/cnpg/CNPGDrawerTrail.tsx +5 -26
  24. package/src/components/cnpg/CNPGInvestigationAction.test.tsx +27 -6
  25. package/src/components/cnpg/CNPGView.tsx +43 -117
  26. package/src/components/cnpg/CNPGWorkspace.compatibility.test.tsx +30 -0
  27. package/src/components/cnpg/host.tsx +2 -2
  28. package/src/components/cnpg/routes.ts +3 -1
  29. package/src/components/cnpg/shared.tsx +5 -53
  30. package/src/components/cnpg/useCNPGNavigate.ts +1 -21
  31. package/src/components/cnpg/useCNPGSidebarWorkspace.ts +16 -13
  32. package/src/components/community.tsx +42 -0
  33. package/src/components/diagnose/diagnoseEvidenceTypes.ts +2 -0
  34. package/src/components/diagnose/investigationMetrics.test.ts +20 -0
  35. package/src/components/diagnose/investigationMetrics.ts +2 -1
  36. package/src/components/dock/BottomDock.tsx +1 -0
  37. package/src/components/dock/LogsTab.tsx +3 -0
  38. package/src/components/gitops/FluxOperatorCard.test.tsx +37 -0
  39. package/src/components/gitops/FluxOperatorCard.tsx +27 -0
  40. package/src/components/gitops/GitOpsView.rowsSummary.test.tsx +59 -0
  41. package/src/components/gitops/GitOpsView.tsx +8 -5
  42. package/src/components/gitops/gitopsRowEvents.test.ts +48 -0
  43. package/src/components/gitops/gitopsRowEvents.ts +31 -0
  44. package/src/components/helm/HelmDrawerFrame.tsx +1 -1
  45. package/src/components/helm/HelmView.tsx +20 -16
  46. package/src/components/helm/OwnedResources.tsx +4 -3
  47. package/src/components/home/ClusterHealthCard.tsx +3 -1
  48. package/src/components/home/HomeAgentBlock.tsx +3 -0
  49. package/src/components/home/HomeView.tsx +7 -0
  50. package/src/components/home/MCPSetupDialog.test.tsx +19 -12
  51. package/src/components/home/MCPSetupDialog.tsx +4 -2
  52. package/src/components/home/mcpToolCatalog.ts +15 -2
  53. package/src/components/home/useVulnerabilitiesRow.test.ts +26 -0
  54. package/src/components/home/useVulnerabilitiesRow.ts +50 -0
  55. package/src/components/logs/LogsViewer.tsx +3 -1
  56. package/src/components/logs/MultiPodLogsTab.test.tsx +24 -4
  57. package/src/components/logs/MultiPodLogsTab.tsx +9 -5
  58. package/src/components/nav/PrimaryNavRail.test.tsx +17 -0
  59. package/src/components/nav/PrimaryNavRail.tsx +174 -29
  60. package/src/components/resource/PrometheusChartsGrid.tsx +5 -1
  61. package/src/components/resource/SubstrateHealthCharts.test.tsx +143 -0
  62. package/src/components/resource/SubstrateHealthCharts.tsx +254 -0
  63. package/src/components/resource/SubstrateVerdictLine.test.tsx +131 -0
  64. package/src/components/resource/SubstrateVerdictLine.tsx +180 -0
  65. package/src/components/resources/ResourcesView.tsx +12 -6
  66. package/src/components/resources/renderers/UpgradePlanRenderer.test.tsx +20 -0
  67. package/src/components/resources/renderers/UpgradePlanRenderer.tsx +22 -0
  68. package/src/components/resources/renderers/VeleroBackupRenderer.tsx +16 -36
  69. package/src/components/resources/renderers/VeleroRestoreRenderer.tsx +6 -19
  70. package/src/components/resources/renderers/WorkloadRenderer.tsx +8 -0
  71. package/src/components/rightsizing/RightsizingScanView.tsx +3 -2
  72. package/src/components/shared/LargeClusterNamespacePicker.test.tsx +27 -0
  73. package/src/components/shared/LargeClusterNamespacePicker.tsx +8 -2
  74. package/src/components/timeline/TimelineView.tsx +3 -1
  75. package/src/components/traffic/TrafficConnectionsTable.test.tsx +94 -0
  76. package/src/components/traffic/TrafficConnectionsTable.tsx +21 -5
  77. package/src/components/traffic/TrafficData.test.tsx +37 -0
  78. package/src/components/traffic/TrafficData.tsx +27 -0
  79. package/src/components/traffic/TrafficFlowList.tsx +9 -7
  80. package/src/components/traffic/TrafficGraph.layoutEngine.test.tsx +193 -0
  81. package/src/components/traffic/TrafficGraph.test.tsx +269 -0
  82. package/src/components/traffic/TrafficGraph.tsx +135 -64
  83. package/src/components/traffic/TrafficGraphUnavailable.tsx +57 -0
  84. package/src/components/traffic/TrafficView.layoutUnavailable.test.tsx +211 -0
  85. package/src/components/traffic/TrafficView.tsx +46 -129
  86. package/src/components/traffic/trafficFilters.test.ts +172 -1
  87. package/src/components/traffic/trafficFilters.ts +139 -0
  88. package/src/components/ui/DiagnosticsOverlay.tsx +14 -1
  89. package/src/components/ui/UpdateNotification.manual.test.tsx +5 -2
  90. package/src/components/ui/UpdateNotification.test.tsx +31 -2
  91. package/src/components/ui/UpdateNotification.tsx +34 -17
  92. package/src/components/ui/command-items.ts +24 -1
  93. package/src/components/velero/VeleroBackupNow.test.tsx +165 -0
  94. package/src/components/velero/VeleroBackupNow.tsx +143 -0
  95. package/src/components/velero/VeleroDeleteBackup.test.tsx +364 -0
  96. package/src/components/velero/VeleroDeleteBackup.tsx +306 -0
  97. package/src/components/velero/VeleroDetailPage.tsx +158 -0
  98. package/src/components/velero/VeleroKindLists.test.tsx +48 -0
  99. package/src/components/velero/VeleroKindLists.tsx +43 -0
  100. package/src/components/velero/VeleroLocations.expand.test.tsx +27 -0
  101. package/src/components/velero/VeleroLocations.test.tsx +86 -0
  102. package/src/components/velero/VeleroLocations.tsx +240 -0
  103. package/src/components/velero/VeleroOverview.test.tsx +311 -0
  104. package/src/components/velero/VeleroOverview.tsx +485 -0
  105. package/src/components/velero/VeleroPages.test.tsx +516 -0
  106. package/src/components/velero/VeleroPages.tsx +1056 -0
  107. package/src/components/velero/VeleroRunArtifacts.test.tsx +241 -0
  108. package/src/components/velero/VeleroRunArtifacts.tsx +112 -0
  109. package/src/components/velero/VeleroRunLists.tsx +309 -0
  110. package/src/components/velero/VeleroRunMessagesHost.test.tsx +25 -0
  111. package/src/components/velero/VeleroRunMessagesHost.tsx +54 -0
  112. package/src/components/velero/VeleroRunVolumes.test.tsx +247 -0
  113. package/src/components/velero/VeleroRunVolumes.tsx +122 -0
  114. package/src/components/velero/VeleroSchedulePause.test.tsx +211 -0
  115. package/src/components/velero/VeleroSchedulePause.tsx +191 -0
  116. package/src/components/velero/VeleroScheduleStatusBadge.test.tsx +28 -0
  117. package/src/components/velero/VeleroScheduleStatusBadge.tsx +21 -0
  118. package/src/components/velero/VeleroSchedules.tsx +255 -0
  119. package/src/components/velero/VeleroView.tsx +59 -0
  120. package/src/components/velero/VeleroWorkspace.gate.test.tsx +97 -0
  121. package/src/components/velero/attention.test.ts +178 -0
  122. package/src/components/velero/attention.ts +281 -0
  123. package/src/components/velero/backupDelete.test.tsx +91 -0
  124. package/src/components/velero/backupDelete.tsx +182 -0
  125. package/src/components/velero/coverage.test.ts +87 -0
  126. package/src/components/velero/coverage.ts +150 -0
  127. package/src/components/velero/host.tsx +92 -0
  128. package/src/components/velero/routes.ts +78 -0
  129. package/src/components/velero/runs.tsx +121 -0
  130. package/src/components/velero/shared.test.ts +84 -0
  131. package/src/components/velero/shared.tsx +423 -0
  132. package/src/components/velero/useVeleroSidebarWorkspace.test.tsx +28 -0
  133. package/src/components/velero/useVeleroSidebarWorkspace.ts +71 -0
  134. package/src/components/velero/velero.fixtures.ts +61 -0
  135. package/src/components/velero/workspaceRoute.ts +21 -0
  136. package/src/components/vulnerabilities/WorkloadVulnerabilitiesSection.tsx +179 -0
  137. package/src/components/vulnerabilities/parts.test.ts +72 -0
  138. package/src/components/vulnerabilities/parts.tsx +291 -0
  139. package/src/components/whats-new/WhatsNewDialog.test.tsx +6 -4
  140. package/src/components/whats-new/releaseNotes.ts +67 -1
  141. package/src/components/workload/WorkloadView.tsx +64 -27
  142. package/src/components/workspace/DrawerTrailBack.tsx +32 -0
  143. package/src/components/workspace/WorkspaceFrame.tsx +71 -0
  144. package/src/components/workspace/coverage.ts +61 -0
  145. package/src/components/workspace/layout.test.tsx +29 -1
  146. package/src/components/workspace/layout.tsx +15 -5
  147. package/src/components/workspace/sidebar.ts +9 -0
  148. package/src/components/workspace/useWorkspaceDrawer.ts +63 -0
  149. package/src/components/workspace/useWorkspaceNavigate.ts +21 -0
  150. package/src/desktop/AboutDialog.test.ts +12 -0
  151. package/src/desktop/AboutDialog.tsx +151 -0
  152. package/src/desktop/WindowsTitleBar.tsx +359 -0
  153. package/src/desktop/titleBar.test.ts +61 -0
  154. package/src/desktop/titleBar.ts +45 -0
  155. package/src/index.css +19 -0
  156. package/src/integrations/resourceHost.ts +5 -1
  157. package/src/integrations/resourceHosts.test.tsx +14 -2
  158. package/src/integrations/resourceHosts.tsx +22 -6
  159. package/src/integrations/workspaceRoute.ts +1 -1
  160. package/src/integrations/workspaceRoutes.test.ts +11 -0
  161. package/src/integrations/workspaceRoutes.ts +3 -1
  162. package/src/integrations/workspaceScreens.tsx +2 -0
  163. package/src/main.tsx +8 -0
  164. package/src/utils/desktop-zoom.test.ts +53 -0
  165. package/src/utils/desktop-zoom.ts +30 -0
  166. package/src/utils/staleAssetPrompt.test.tsx +76 -0
  167. package/src/utils/staleAssetPrompt.tsx +32 -0
@@ -0,0 +1,309 @@
1
+ import { useMemo, useState, type ReactNode } from 'react'
2
+ import { Plus, Search } from 'lucide-react'
3
+ import { Tooltip, VELERO_MANUAL_RUN, VELERO_MANUAL_RUN_TITLE, toneTextClass } from '@skyhook-io/k8s-ui'
4
+ import { useVeleroRuns, type VeleroRestoreRow, type VeleroRunRow } from '../../api/velero'
5
+ import { useMediaQuery } from '../../hooks/useMediaQuery'
6
+ import { ScreenBody, SectionTable, Segments, Sub, type TableColumn } from '../workspace/layout'
7
+ import { VELERO_WIDE, VeleroName, VeleroWorkspaceHeader, WholeNames, inInstallation, restoredIntoText, veleroResource, type VeleroScreenProps } from './shared'
8
+ import { Expires, RunCounts, RunOutcome, RunReason, RunsReadNotice, When, durationText, expired, runViewOptions, runsEmpty, useRunView } from './runs'
9
+
10
+ // Rows rendered at once; the rest are a click away, and search narrows first.
11
+ const PAGE = 200
12
+
13
+ function SearchBox({ value, onChange, placeholder }: { value: string; onChange: (v: string) => void; placeholder: string }) {
14
+ return (
15
+ <label className="flex min-w-[14rem] items-center gap-2 rounded-lg border border-theme-border bg-theme-surface px-2.5 py-1.5 text-sm">
16
+ <Search className="h-3.5 w-3.5 text-theme-text-tertiary" aria-hidden />
17
+ <input value={value} onChange={(e) => onChange(e.target.value)} placeholder={placeholder} aria-label={placeholder} className="min-w-0 flex-1 bg-transparent text-theme-text-primary outline-none placeholder:text-theme-text-tertiary" />
18
+ </label>
19
+ )
20
+ }
21
+
22
+ function RunTable<R extends VeleroRunRow>({ columns, rows, kind, onInspect, inspected, empty, footer, minWidth }: {
23
+ columns: TableColumn<R>[]
24
+ rows: R[]
25
+ kind: 'Backup' | 'Restore'
26
+ onInspect: VeleroScreenProps['onInspect']
27
+ inspected: VeleroScreenProps['inspected']
28
+ empty: string
29
+ footer?: ReactNode
30
+ minWidth: number
31
+ }) {
32
+ const [limit, setLimit] = useState(PAGE)
33
+ return (
34
+ <SectionTable
35
+ columns={columns}
36
+ rows={rows.slice(0, limit)}
37
+ rowKey={(r) => r.uid || `${r.namespace}/${r.name}`}
38
+ rowResource={(r) => veleroResource(kind, r.namespace, r.name)}
39
+ onInspect={onInspect}
40
+ inspected={inspected}
41
+ minWidth={minWidth}
42
+ empty={empty}
43
+ footer={
44
+ <>
45
+ {rows.length > limit && (
46
+ <button type="button" onClick={() => setLimit((l) => l + PAGE)} className="mr-3 text-accent hover:underline">
47
+ Show {Math.min(PAGE, rows.length - limit)} more of {rows.length - limit}
48
+ </button>
49
+ )}
50
+ {footer}
51
+ </>
52
+ }
53
+ />
54
+ )
55
+ }
56
+
57
+ function CreateButton({ onCreate, kind }: { onCreate?: () => void; kind: string }) {
58
+ if (!onCreate) return null
59
+ return (
60
+ <button type="button" onClick={onCreate} className="btn-secondary ml-auto inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium">
61
+ <Plus className="h-3.5 w-3.5" aria-hidden />
62
+ Create {kind}
63
+ </button>
64
+ )
65
+ }
66
+
67
+ function plural(n: number, word: string): string {
68
+ return `${n} ${word}${n === 1 ? '' : 's'}`
69
+ }
70
+
71
+ /** The outcome and why; on a narrow screen also its errors and warnings, said only when there are some. */
72
+ export function OutcomeCell({ kind, run, counts }: { kind: 'Backup' | 'Restore'; run: VeleroRunRow; counts?: boolean }) {
73
+ return (
74
+ <>
75
+ <RunOutcome kind={kind} phase={run.phase} />
76
+ <RunReason run={run} />
77
+ {counts && (run.errors > 0 || run.warnings > 0) && (
78
+ <Sub>
79
+ {run.errors > 0 && <span className={toneTextClass('unhealthy')}>{plural(run.errors, 'error')}</span>}
80
+ {run.errors > 0 && run.warnings > 0 && ' · '}
81
+ {run.warnings > 0 && <span className={toneTextClass('degraded')}>{plural(run.warnings, 'warning')}</span>}
82
+ </Sub>
83
+ )}
84
+ </>
85
+ )
86
+ }
87
+
88
+ /** Where a restore put things, as its page says it; nothing for one Velero rejected. */
89
+ export function RestoreIntoCell({ run }: { run: VeleroRestoreRow }) {
90
+ if (run.phase === 'FailedValidation') return <span className="text-theme-text-secondary">Nothing — rejected</span>
91
+ const text = restoredIntoText(run)
92
+ return (
93
+ <Tooltip content={text}>
94
+ <span className="line-clamp-2">
95
+ <WholeNames text={text} />
96
+ </span>
97
+ </Tooltip>
98
+ )
99
+ }
100
+
101
+ /**
102
+ * Started, and on a narrow screen how long it took, the items it processed,
103
+ * where it is stored and when Velero deletes it.
104
+ */
105
+ export function StartedCell({ run, folded, items, storedIn, expires }: { run: VeleroRunRow; folded: boolean; items?: boolean; storedIn?: string; expires?: boolean }) {
106
+ const took = durationText(run.started, run.completed)
107
+ const extra = folded ? [took && `took ${took}`, items && run.itemsTotal ? `${run.itemsDone ?? 0} / ${run.itemsTotal} items` : ''].filter(Boolean) : []
108
+ return (
109
+ <>
110
+ <When iso={run.started} fallback="not started" />
111
+ {extra.length > 0 && <Sub>{extra.join(' · ')}</Sub>}
112
+ {folded && storedIn && (
113
+ <Sub>
114
+ <WholeNames text={storedIn} />
115
+ </Sub>
116
+ )}
117
+ {folded && expires && run.expiration && (
118
+ <Sub>
119
+ {!expired(run.expiration) && 'expires '}
120
+ <Expires iso={run.expiration} />
121
+ </Sub>
122
+ )}
123
+ </>
124
+ )
125
+ }
126
+
127
+ /** Where a backup is stored, and whether that location is not available. */
128
+ function storedInText(r: VeleroRunRow, locations: VeleroScreenProps['data']['locations']): { name?: string; state?: string } {
129
+ if (!r.storageLocation) return { state: 'not assigned yet' }
130
+ const loc = locations.find((l) => l.namespace === r.namespace && l.name === r.storageLocation)
131
+ return { name: r.storageLocation, state: loc && loc.phase !== 'Available' ? (loc.phase ? loc.phase.toLowerCase() : 'not validated') : undefined }
132
+ }
133
+
134
+ /**
135
+ * The Backup kind's list: every run across the installations the caller can
136
+ * read, newest first, with the failed ones a segment away.
137
+ */
138
+ export function VeleroBackups({ data, installation, onInstallation, onInspect, inspected, onCreate }: VeleroScreenProps) {
139
+ // The installation narrows the read on the server, so its cap counts only these.
140
+ const query = useVeleroRuns('backups', installation ?? undefined)
141
+ const wide = useMediaQuery(VELERO_WIDE)
142
+ const [search, setSearch] = useState('')
143
+ const rows = useMemo(
144
+ () => inInstallation(query.data?.runs ?? [], installation).filter((r) => !search || r.name.toLowerCase().includes(search.toLowerCase())),
145
+ [query.data, installation, search],
146
+ )
147
+ const { failed, view, setView, shown } = useRunView(rows)
148
+ const locations = data.locations
149
+ const columns: TableColumn<VeleroRunRow>[] = [
150
+ {
151
+ header: 'Backup',
152
+ cell: (r) => (
153
+ <>
154
+ <VeleroName name={r.name} middle />
155
+ <Sub>
156
+ {r.schedule ? <WholeNames text={`schedule ${r.schedule}`} /> : 'On demand'}
157
+ {r.manual && (
158
+ <Tooltip content={VELERO_MANUAL_RUN_TITLE}>
159
+ <span>{` · ${VELERO_MANUAL_RUN}`}</span>
160
+ </Tooltip>
161
+ )}
162
+ </Sub>
163
+ </>
164
+ ),
165
+ },
166
+ { header: 'Outcome', width: wide ? '170px' : '180px', cell: (r) => <OutcomeCell kind="Backup" run={r} counts={!wide} /> },
167
+ {
168
+ header: 'Started',
169
+ width: wide ? '100px' : '190px',
170
+ cell: (r) => {
171
+ const stored = storedInText(r, locations)
172
+ return <StartedCell run={r} folded={!wide} items expires storedIn={stored.name ? `in ${stored.name}${stored.state ? ` · ${stored.state}` : ''}` : stored.state} />
173
+ },
174
+ },
175
+ ...(wide
176
+ ? [
177
+ { header: 'Took', width: '75px', cell: (r: VeleroRunRow) => durationText(r.started, r.completed) ?? '—' },
178
+ { header: 'Items', width: '80px', cell: (r: VeleroRunRow) => (r.itemsTotal ? `${r.itemsDone ?? 0} / ${r.itemsTotal}` : '—') },
179
+ ]
180
+ : []),
181
+ ...(wide
182
+ ? [
183
+ { header: 'Errors · warnings', width: '130px', cell: (r: VeleroRunRow) => <RunCounts errors={r.errors} warnings={r.warnings} /> },
184
+ {
185
+ header: 'Stored in',
186
+ width: '140px',
187
+ cell: (r: VeleroRunRow) => {
188
+ const stored = storedInText(r, locations)
189
+ if (!stored.name) return <span className="text-theme-text-tertiary">{stored.state}</span>
190
+ return (
191
+ <>
192
+ <VeleroName name={stored.name} />
193
+ {stored.state && <Sub>{stored.state}</Sub>}
194
+ </>
195
+ )
196
+ },
197
+ },
198
+ { header: 'Expires', width: '90px', cell: (r: VeleroRunRow) => <Expires iso={r.expiration} /> },
199
+ ]
200
+ : []),
201
+ ]
202
+ return (
203
+ <div className="flex min-h-0 flex-1 flex-col">
204
+ <VeleroWorkspaceHeader title="Backups" data={data} installation={installation} onInstallation={onInstallation} />
205
+ <ScreenBody>
206
+ <div className="flex flex-wrap items-center gap-3">
207
+ <Segments label="Backups" value={view} onChange={setView} options={runViewOptions(failed.length, rows.length, query)} />
208
+ <SearchBox value={search} onChange={setSearch} placeholder="Search backups" />
209
+ <CreateButton onCreate={onCreate} kind="Backup" />
210
+ </div>
211
+ <RunsReadNotice query={query} noun="backups" />
212
+ <RunTable
213
+ columns={columns}
214
+ rows={shown}
215
+ kind="Backup"
216
+ onInspect={onInspect}
217
+ inspected={inspected}
218
+ minWidth={wide ? 1000 : 520}
219
+ empty={runsEmpty(query, 'backups', view === 'failed' ? 'No failed backups' : 'No backups match')}
220
+ footer="Failed counts runs that failed, partially failed or were rejected. Expired backups are eligible for garbage collection."
221
+ />
222
+ </ScreenBody>
223
+ </div>
224
+ )
225
+ }
226
+
227
+ /** The Restore kind's list: every restore, newest first, with the failed ones a segment away. */
228
+ export function VeleroRestores({ data, installation, onInstallation, onInspect, inspected, onCreate }: VeleroScreenProps) {
229
+ const query = useVeleroRuns('restores', installation ?? undefined)
230
+ const wide = useMediaQuery(VELERO_WIDE)
231
+ const [search, setSearch] = useState('')
232
+ const rows = useMemo(
233
+ () => inInstallation(query.data?.runs ?? [], installation).filter((r) => !search || r.name.toLowerCase().includes(search.toLowerCase()) || (r.backupName ?? '').toLowerCase().includes(search.toLowerCase())),
234
+ [query.data, installation, search],
235
+ )
236
+ const { failed, view, setView, shown } = useRunView(rows)
237
+ const fromBackup = (r: VeleroRunRow) =>
238
+ r.backupName ? (
239
+ <button
240
+ type="button"
241
+ onClick={(e) => {
242
+ e.stopPropagation()
243
+ onInspect(veleroResource('Backup', r.namespace, r.backupName!))
244
+ }}
245
+ className="block max-w-full text-left text-accent-text hover:underline"
246
+ >
247
+ <VeleroName name={r.backupName} middle />
248
+ </button>
249
+ ) : r.scheduleName ? (
250
+ <WholeNames text={`newest of ${r.scheduleName}`} />
251
+ ) : (
252
+ '—'
253
+ )
254
+ // Narrow: the backup goes under the restore's name, and errors and warnings under its outcome.
255
+ const columns: TableColumn<VeleroRestoreRow>[] = [
256
+ {
257
+ header: 'Restore',
258
+ cell: (r) => (
259
+ <>
260
+ <VeleroName name={r.name} middle />
261
+ {!wide && (
262
+ <Sub>
263
+ <span className="flex min-w-0 items-baseline gap-1">
264
+ <span className="shrink-0">from</span>
265
+ <span className="min-w-0">{fromBackup(r)}</span>
266
+ </span>
267
+ </Sub>
268
+ )}
269
+ </>
270
+ ),
271
+ },
272
+ { header: 'Outcome', width: '170px', cell: (r) => <OutcomeCell kind="Restore" run={r} counts={!wide} /> },
273
+ ...(wide ? [{ header: 'From backup', cell: fromBackup }] : []),
274
+ {
275
+ header: 'Into',
276
+ width: wide ? '170px' : '150px',
277
+ cell: (r) => <RestoreIntoCell run={r} />,
278
+ },
279
+ { header: 'Started', width: wide ? '100px' : '120px', cell: (r) => <StartedCell run={r} folded={!wide} /> },
280
+ ...(wide
281
+ ? [
282
+ { header: 'Took', width: '75px', cell: (r: VeleroRunRow) => durationText(r.started, r.completed) ?? '—' },
283
+ { header: 'Errors · warnings', width: '130px', cell: (r: VeleroRunRow) => <RunCounts errors={r.errors} warnings={r.warnings} /> },
284
+ ]
285
+ : []),
286
+ ]
287
+ return (
288
+ <div className="flex min-h-0 flex-1 flex-col">
289
+ <VeleroWorkspaceHeader title="Restores" data={data} installation={installation} onInstallation={onInstallation} />
290
+ <ScreenBody>
291
+ <div className="flex flex-wrap items-center gap-3">
292
+ <Segments label="Restores" value={view} onChange={setView} options={runViewOptions(failed.length, rows.length, query)} />
293
+ <SearchBox value={search} onChange={setSearch} placeholder="Search restores" />
294
+ <CreateButton onCreate={onCreate} kind="Restore" />
295
+ </div>
296
+ <RunsReadNotice query={query} noun="restores" />
297
+ <RunTable
298
+ columns={columns}
299
+ rows={shown}
300
+ kind="Restore"
301
+ onInspect={onInspect}
302
+ inspected={inspected}
303
+ minWidth={wide ? 1000 : 560}
304
+ empty={runsEmpty(query, 'restores', view === 'failed' ? 'No failed restores' : 'No restores match')}
305
+ />
306
+ </ScreenBody>
307
+ </div>
308
+ )
309
+ }
@@ -0,0 +1,25 @@
1
+ import { renderToStaticMarkup } from 'react-dom/server'
2
+ import { describe, expect, it, vi } from 'vitest'
3
+
4
+ vi.mock('../../api/policy', () => ({ useVeleroRunMessages: () => ({ isPending: false, mutate: vi.fn() }) }))
5
+
6
+ const { VeleroRunIssueMessages, veleroMessagesInIssue } = await import('./VeleroRunMessagesHost')
7
+
8
+ const run = (phase: string) => ({ metadata: { namespace: 'velero', name: 'nightly-1' }, status: { phase, errors: 9, warnings: 3 } })
9
+
10
+ // The messages are what is wrong with a failed run, so they sit in its issue;
11
+ // only one place shows them.
12
+ describe('where a Velero run’s messages go', () => {
13
+ it('goes in the issue when the drawer shows it, in Status otherwise', () => {
14
+ expect(veleroMessagesInIssue(run('PartiallyFailed'), true)).toBe(true)
15
+ expect(veleroMessagesInIssue(run('PartiallyFailed'), false)).toBe(false)
16
+ // A completed run with warnings raises no issue.
17
+ expect(veleroMessagesInIssue(run('Completed'), true)).toBe(false)
18
+ })
19
+
20
+ it('renders under a failed run’s issue only', () => {
21
+ const html = renderToStaticMarkup(<VeleroRunIssueMessages issue={{ reason: 'BackupPartiallyFailed' }} resource={run('PartiallyFailed')} />)
22
+ expect(html).toContain('Show 9 errors and 3 warnings')
23
+ expect(renderToStaticMarkup(<VeleroRunIssueMessages issue={{ reason: 'VeleroRunStalled' }} resource={run('PartiallyFailed')} />)).toBe('')
24
+ })
25
+ })
@@ -0,0 +1,54 @@
1
+ import { LookupFailureNote } from '@skyhook-io/k8s-ui/components/resources/renderers/LookupFailureNote'
2
+ import { VeleroRunMessages, type VeleroRunMessagesFetch } from '@skyhook-io/k8s-ui/components/resources/renderers/VeleroRunMessages'
3
+ import { getBackupErrors, getBackupWarnings, getRestoreErrors, getRestoreWarnings } from '@skyhook-io/k8s-ui/components/resources/resource-utils-velero'
4
+ import { useVeleroRunMessages } from '../../api/policy'
5
+
6
+ type RunKind = 'backups' | 'restores'
7
+
8
+ // The phases Velero's issues are raised for (veleroPartialPhases and Failed in
9
+ // internal/issues/source_velero.go).
10
+ const FAILED_PHASES = new Set(['Failed', 'PartiallyFailed', 'FinalizingPartiallyFailed', 'WaitingForPluginOperationsPartiallyFailed'])
11
+
12
+ const ISSUE_REASONS: Record<string, RunKind> = {
13
+ BackupFailed: 'backups',
14
+ BackupPartiallyFailed: 'backups',
15
+ RestoreFailed: 'restores',
16
+ RestorePartiallyFailed: 'restores',
17
+ }
18
+
19
+ /**
20
+ * Where a run's messages go: inside its issue's "What's wrong" when the drawer
21
+ * shows that issue, since they are what is wrong; in Status otherwise.
22
+ */
23
+ export function veleroMessagesInIssue(data: any, issuesShown: boolean): boolean {
24
+ return issuesShown && FAILED_PHASES.has(data?.status?.phase ?? '')
25
+ }
26
+
27
+ // Nothing is fetched until the operator asks: reading the messages makes
28
+ // Velero create a DownloadRequest and pulls an object out of storage.
29
+ export function useVeleroRunMessagesFetch(kind: RunKind, data: any): VeleroRunMessagesFetch {
30
+ const namespace = data?.metadata?.namespace ?? ''
31
+ const name = data?.metadata?.name ?? ''
32
+ const fetcher = useVeleroRunMessages(kind, namespace, name)
33
+ return {
34
+ messages: fetcher.data,
35
+ loading: fetcher.isPending,
36
+ lookupNote: fetcher.error ? <LookupFailureNote errors={[fetcher.error]} what="the messages behind these counts" /> : undefined,
37
+ onFetch: namespace && name ? () => fetcher.mutate() : undefined,
38
+ }
39
+ }
40
+
41
+ /** A run's errors and warnings behind its counts, fetched on request. */
42
+ export function RunMessages({ kind, resource }: { kind: RunKind; resource: any }) {
43
+ const fetch = useVeleroRunMessagesFetch(kind, resource)
44
+ const errors = kind === 'backups' ? getBackupErrors(resource) : getRestoreErrors(resource)
45
+ const warnings = kind === 'backups' ? getBackupWarnings(resource) : getRestoreWarnings(resource)
46
+ return <VeleroRunMessages {...fetch} errors={errors} warnings={warnings} />
47
+ }
48
+
49
+ /** A failed run's messages, under its issue in the drawer. */
50
+ export function VeleroRunIssueMessages({ issue, resource }: { issue: { kind?: string; reason?: string }; resource: any }) {
51
+ const kind = ISSUE_REASONS[issue.reason ?? '']
52
+ if (!kind || !resource || !veleroMessagesInIssue(resource, true)) return null
53
+ return <RunMessages kind={kind} resource={resource} />
54
+ }
@@ -0,0 +1,247 @@
1
+ // @vitest-environment jsdom
2
+ import { act, type ReactNode } from 'react'
3
+ import { createRoot, type Root } from 'react-dom/client'
4
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
5
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
6
+ import { guardRadarFeature, type RadarFeatureSupport } from '../../api/radarFeatures'
7
+ import type { VeleroRunVolumesResponse, VeleroVolumeOperationsResponse } from '../../api/velero'
8
+ import { setApiBase } from '../../api/config'
9
+
10
+ const state = vi.hoisted(() => ({ support: 'supported' as RadarFeatureSupport, supportFor: {} as Record<string, RadarFeatureSupport>, fetch: vi.fn() }))
11
+ vi.mock('../../api/client', async (original) => ({
12
+ ...(await original<typeof import('../../api/client')>()),
13
+ useRadarFeature: (feature: 'veleroRunVolumes') => {
14
+ const support = state.supportFor[feature] ?? state.support
15
+ return {
16
+ gatedKey: [support],
17
+ guard: <T,>(request: () => Promise<T>) => guardRadarFeature(feature, support, { currentVersion: 'v1.16.0' }, request),
18
+ }
19
+ },
20
+ fetchJSON: (path: string, init: RequestInit) => state.fetch(path, init),
21
+ }))
22
+
23
+ import { ApiError } from '../../api/client'
24
+ import { VeleroRunVolumes } from './VeleroRunVolumes'
25
+ Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
26
+ let host: HTMLDivElement
27
+ let root: Root
28
+ let client: QueryClient
29
+ const props = { kind: 'backups' as const, namespace: 'velero', name: 'nightly' }
30
+ const record = (patch: Partial<VeleroRunVolumesResponse> = {}): VeleroRunVolumesResponse => ({
31
+ volumes: [
32
+ { pvcName: 'native', pvcNamespace: 'app', pvName: 'pv-native', method: 'NativeSnapshot', preserveLocalSnapshot: false, result: 'succeeded', snapshotDataMoved: false, nativeSnapshotInfo: { snapshotHandle: 'snap-123' } },
33
+ { pvcName: 'csi', method: 'CSISnapshot', preserveLocalSnapshot: true, snapshotDataMoved: false, csiSnapshotInfo: { driver: 'ebs.csi.aws.com', size: 1024 } },
34
+ { pvcName: 'moved', method: 'CSISnapshot', snapshotDataMoved: true, snapshotDataMovementInfo: { dataMover: 'velero', operationID: 'op-moved' } },
35
+ { method: 'PodVolumeBackup', result: 'failed', snapshotDataMoved: false, podVolumeInfo: { podName: 'worker', podNamespace: 'app', volumeName: 'data' } },
36
+ { pvcName: 'skipped', snapshotDataMoved: false, skipped: true, skippedReason: 'excluded by policy' },
37
+ ], total: 5, truncated: false, finishedAtRead: true, ...patch,
38
+ })
39
+ const live = (patch: Partial<VeleroVolumeOperationsResponse> = {}): VeleroVolumeOperationsResponse => ({
40
+ observedAt: '2026-11-15T12:00:00Z', runPhase: 'Completed', coverage: { podVolumeBackups: { state: 'full' }, dataUploads: { state: 'full' } }, operations: [], ...patch,
41
+ })
42
+ function respond(volumes = record(), operations = live()) {
43
+ state.fetch.mockImplementation((path: string) => Promise.resolve(path.includes('volume-operations') ? operations : volumes))
44
+ }
45
+ async function mount(node: ReactNode = <VeleroRunVolumes {...props} />) {
46
+ await act(async () => { root.render(<QueryClientProvider client={client}>{node}</QueryClientProvider>) })
47
+ }
48
+ async function settle(test: () => boolean) {
49
+ for (let i = 0; i < 50 && !test(); i++) await act(async () => { await new Promise((resolve) => setTimeout(resolve, 10)) })
50
+ expect(test()).toBe(true)
51
+ }
52
+ beforeEach(() => {
53
+ state.support = 'supported'
54
+ state.supportFor = {}
55
+ state.fetch.mockReset()
56
+ host = document.createElement('div'); document.body.append(host); root = createRoot(host)
57
+ client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
58
+ })
59
+ afterEach(async () => {
60
+ await act(async () => root.unmount())
61
+ client.clear(); host.remove(); setApiBase('/api'); vi.useRealTimers()
62
+ })
63
+
64
+ describe('Volumes tab', () => {
65
+ it('loads on opening: durable POST and operations GET', async () => {
66
+ state.fetch.mockImplementation(() => new Promise(() => {}))
67
+ expect(state.fetch).not.toHaveBeenCalled()
68
+ await mount()
69
+ expect(host.textContent).toContain('Loading volume record')
70
+ expect(host.textContent).toContain('Loading volume operations')
71
+ expect(state.fetch.mock.calls.find(([path]) => path.endsWith('/volumes?'))?.[1].method).toBe('POST')
72
+ expect(state.fetch.mock.calls.some(([path]) => path.endsWith('/volume-operations'))).toBe(true)
73
+ })
74
+
75
+ // Velero keeps finished operation objects, so they alone don't keep a
76
+ // finished run polling.
77
+ it.each(['inFlight', 'activeOperation', 'retainedOperations', 'completedEmpty', 'syncing'] as const)('polls operations only when needed: %s', async (scenario) => {
78
+ vi.useFakeTimers()
79
+ const operations = scenario === 'retainedOperations' ? [{ kind: 'DataUpload', name: 'done', phase: 'Completed', longRunning: false }] : scenario === 'activeOperation' ? [{ kind: 'DataUpload', name: 'copying', phase: 'InProgress', longRunning: false }] : []
80
+ respond(record(), live({ runPhase: scenario === 'inFlight' ? 'InProgress' : 'Completed', coverage: { dataUploads: { state: scenario === 'syncing' ? 'syncing' : 'full' } }, operations }))
81
+ await mount()
82
+ await act(async () => { await vi.advanceTimersByTimeAsync(50) })
83
+ expect(host.textContent).toContain('snap-123')
84
+ await act(async () => { await vi.advanceTimersByTimeAsync(10_050) })
85
+ expect(state.fetch.mock.calls.filter(([path]) => path.endsWith('/volumes?'))).toHaveLength(1)
86
+ expect(state.fetch.mock.calls.filter(([path]) => path.endsWith('/volume-operations'))).toHaveLength(scenario === 'completedEmpty' || scenario === 'retainedOperations' ? 1 : 2)
87
+ })
88
+
89
+ it('shows all methods, explicit outcomes, skipped reasons and unknown CSI results', async () => {
90
+ respond(); await mount(); await settle(() => host.textContent!.includes('snap-123'))
91
+ for (const text of ['Native snapshot', 'CSI snapshot', 'Copy to the bucket (data mover)', 'File-system backup', 'excluded by policy', 'ebs.csi.aws.com', '1 KB', 'op-moved', 'Succeeded', 'Failed']) expect(host.textContent).toContain(text)
92
+ const skipped = [...host.querySelectorAll('tr')].find((row) => row.textContent!.includes('excluded by policy'))!
93
+ expect(skipped.textContent).toContain('None (skipped)')
94
+ const csi = [...host.querySelectorAll('tr')].find((row) => row.textContent!.includes('CSI snapshot') && !row.textContent!.includes('data mover'))!
95
+ expect(csi.textContent).toContain('Not recorded')
96
+ expect(csi.textContent).not.toContain('Succeeded')
97
+ const native = [...host.querySelectorAll('tr')].find((row) => row.textContent!.includes('snap-123'))!
98
+ expect(native.textContent).not.toContain('Local snapshot retained')
99
+ expect(csi.textContent).toContain('Local snapshot retained: Yes')
100
+ expect(host.querySelector('a')).toBeNull()
101
+ })
102
+
103
+ it('describes restore intent and never renders a result or skipped column', async () => {
104
+ respond(record({ volumes: [{ method: 'PodVolumeRestore', snapshotDataMoved: false, podVolumeInfo: { podName: 'recovered', volumeName: 'data' } }], total: 1 }))
105
+ await mount(<VeleroRunVolumes {...props} kind="restores" />)
106
+ await settle(() => host.textContent!.includes('recovered'))
107
+ expect(host.textContent).toContain('How each volume was to be restored')
108
+ expect(host.textContent).toContain('before plugin operations finish')
109
+ expect(host.textContent).toContain('File-system restore')
110
+ expect([...host.querySelectorAll('th')].map((e) => e.textContent)).not.toContain('Result')
111
+ expect(host.textContent).not.toContain('Succeeded')
112
+ })
113
+
114
+ it.each([['Velero has no volume record for this run', 404], ['no access to this Velero Backup', 403], ['the object store refused it', 503]])('keeps artifact error distinct from operation data: %s', async (message, status) => {
115
+ state.fetch.mockImplementation((path: string) => path.includes('volume-operations') ? Promise.resolve(live()) : Promise.reject(new ApiError(message, status)))
116
+ await mount(); await settle(() => host.textContent!.includes(message))
117
+ expect(host.textContent).toContain('Retry')
118
+ expect(host.textContent).not.toContain('Velero recorded no volumes')
119
+ })
120
+
121
+ // A Radar that serves Contents and Log but predates the Volumes routes.
122
+ it('gates both reads on the new capability', async () => {
123
+ state.supportFor = { veleroRunArtifacts: 'supported', veleroRunVolumes: 'unsupported' }
124
+ await mount(); await settle(() => host.textContent!.includes('needs a newer Radar'))
125
+ expect(state.fetch).not.toHaveBeenCalled()
126
+ })
127
+
128
+ it('says once that a finished run recorded no volumes', async () => {
129
+ respond(record({ volumes: [], total: 0 }))
130
+ await mount(); await settle(() => host.textContent!.includes('Velero recorded no volumes for this run.'))
131
+ expect(host.textContent!.split('Velero recorded no volumes').length).toBe(2)
132
+ expect(host.textContent).not.toContain('They may have been removed')
133
+ expect(host.textContent).not.toContain('No volume operation objects found yet')
134
+ expect(host.textContent).not.toContain('The volume record does not update with live operations')
135
+ expect(host.textContent).not.toContain('0 recorded volumes')
136
+ })
137
+
138
+ it('says operations may have been removed when the record names volumes', async () => {
139
+ respond()
140
+ await mount(); await settle(() => host.textContent!.includes('snap-123') && host.textContent!.includes('They may have been removed'))
141
+ expect(host.textContent).toContain('5 recorded volumes')
142
+ expect(host.textContent).not.toContain('The volume record does not update with live operations')
143
+ })
144
+
145
+ it('reports denied, missing and partial operation kinds without implying none were used', async () => {
146
+ respond(record(), live({ coverage: { podVolumeBackups: { state: 'denied' }, dataUploads: { state: 'notInstalled' }, podVolumeRestores: { state: 'partial', allowedNamespaces: ['velero'] } } }))
147
+ await mount(); await settle(() => host.textContent!.includes('Not available now'))
148
+ expect(host.textContent).toContain('Access denied')
149
+ expect(host.textContent).toContain('Only part of this kind')
150
+ expect(host.textContent).toContain('Unavailable kinds do not mean this run used none')
151
+ })
152
+
153
+ it('groups failures first and shows ten with show all, progress, node-agent context and timestamps', async () => {
154
+ respond(record(), live({ runPhase: 'InProgress', operations: [
155
+ { kind: 'DataUpload', name: 'complete', phase: 'Completed', longRunning: false },
156
+ ...Array.from({ length: 12 }, (_, i) => ({ kind: 'DataUpload', name: `failure-${i}`, phase: 'Failed', pvc: 'data', pvcNamespace: 'app', longRunning: false, message: 'copy failed' })),
157
+ { kind: 'PodVolumeBackup', name: 'copy', phase: 'InProgress', longRunning: true, nodeAgent: 'notRunning' as const, node: 'node-a', bytesDone: 512, bytesTotal: 1024, started: '2026-11-15T11:00:00Z' },
158
+ ] }))
159
+ await mount(); await settle(() => host.textContent!.includes('failure-0'))
160
+ expect([...host.querySelectorAll('h3')].map((e) => e.textContent)).toEqual(['Failed · 12', 'InProgress · 1', 'Completed · 1'])
161
+ expect(host.textContent).not.toContain('failure-11')
162
+ expect(host.textContent).toContain('512 B / 1 KB')
163
+ expect(host.textContent).toContain('No Running node-agent pod found on this node')
164
+ expect(host.textContent).toContain('node-a')
165
+ const progress = host.querySelector('progress')!
166
+ expect(progress.value).toBe(512); expect(progress.max).toBe(1024)
167
+ await act(async () => [...host.querySelectorAll('button')].find((b) => b.textContent === 'Show all 12')!.click())
168
+ expect(host.textContent).toContain('failure-11')
169
+ })
170
+
171
+ it.each(['running', 'unknown'] as const)('shows node-agent %s without guessing progress', async (nodeAgent) => {
172
+ respond(record(), live({ operations: [{ kind: 'DataUpload', name: 'stuck', phase: 'Prepared', node: 'node', longRunning: true, nodeAgent }] }))
173
+ await mount(); await settle(() => host.textContent!.includes('stuck'))
174
+ expect(host.textContent).toContain(nodeAgent === 'running' ? 'Node-agent pod phase: Running on this node' : 'Node-agent status unknown')
175
+ expect(host.textContent).toContain('Unknown / Unknown')
176
+ })
177
+
178
+ it('does not retain another API base’s rows during a cluster switch', async () => {
179
+ respond(); await mount(); await settle(() => host.textContent!.includes('snap-123'))
180
+ setApiBase('/c/other/api'); state.fetch.mockImplementation(() => new Promise(() => {}))
181
+ await mount(); expect(host.textContent).not.toContain('snap-123')
182
+ })
183
+
184
+ it('marks an in-flight record as provisional and refreshes it explicitly', async () => {
185
+ respond(record({ finishedAtRead: false }), live({ runPhase: 'WaitingForPluginOperations' }))
186
+ await mount(); await settle(() => host.textContent!.includes('snap-123'))
187
+ expect(host.textContent).toContain('Velero may write or update its volume record later')
188
+ expect(host.textContent).toContain('The volume record does not update with live operations')
189
+ expect(host.textContent).toContain('Record read:')
190
+ respond(record({ finishedAtRead: false }), live({ runPhase: 'Completed' }))
191
+ await act(async () => [...host.querySelectorAll('button')].find((b) => b.textContent === 'Refresh operations')!.click())
192
+ await settle(() => !host.textContent!.includes('This run is still in progress'))
193
+ expect(host.textContent).not.toContain('The volume record does not update with live operations')
194
+ expect(host.textContent).toContain('The volume record was read before this run finished')
195
+ expect(state.fetch.mock.calls.filter(([path]) => path.endsWith('/volumes?'))).toHaveLength(1)
196
+ respond(record(), live({ runPhase: 'Completed' }))
197
+ await act(async () => [...host.querySelectorAll('button')].find((b) => b.textContent === 'Refresh record')!.click())
198
+ await settle(() => state.fetch.mock.calls.filter(([path]) => path.endsWith('/volumes?')).length === 2)
199
+ await settle(() => !host.textContent!.includes('was read before this run finished'))
200
+ })
201
+
202
+ // Velero rewrites a backup's record as its plugin operations finish, so a
203
+ // record read mid-finalization is provisional even when the first
204
+ // operations read already sees the run complete.
205
+ it('keeps a record read before the run finished provisional when operations already show it complete', async () => {
206
+ respond(record({ finishedAtRead: false }), live({ runPhase: 'Completed' }))
207
+ await mount(); await settle(() => host.textContent!.includes('snap-123'))
208
+ expect(host.textContent).toContain('The volume record was read before this run finished')
209
+ expect(host.textContent).not.toContain('This run is still in progress')
210
+ })
211
+
212
+ it('trusts a final record over an older operations read', async () => {
213
+ respond(record({ finishedAtRead: true }), live({ runPhase: 'Finalizing' }))
214
+ await mount(); await settle(() => host.textContent!.includes('snap-123'))
215
+ expect(host.textContent).not.toContain('This run is still in progress')
216
+ expect(host.textContent).not.toContain('was read before this run finished')
217
+ })
218
+
219
+ it('says a provisional record was read in flight when operations could not be read', async () => {
220
+ state.fetch.mockImplementation((path: string) => path.includes('volume-operations') ? Promise.reject(new ApiError('operations denied', 403)) : Promise.resolve(record({ finishedAtRead: false })))
221
+ await mount(); await settle(() => host.textContent!.includes('operations denied'))
222
+ expect(host.textContent).toContain('The volume record was read while this run was in progress')
223
+ expect(host.textContent).not.toContain('read before this run finished')
224
+ })
225
+
226
+ it('keeps the provisional note when a refresh after completion fails', async () => {
227
+ respond(record({ finishedAtRead: false }), live({ runPhase: 'InProgress' }))
228
+ await mount(); await settle(() => host.textContent!.includes('snap-123'))
229
+ respond(record({ finishedAtRead: false }), live({ runPhase: 'Completed' }))
230
+ await act(async () => [...host.querySelectorAll('button')].find((b) => b.textContent === 'Refresh operations')!.click())
231
+ await settle(() => host.textContent!.includes('was read before this run finished'))
232
+ state.fetch.mockImplementation((path: string) => path.includes('volume-operations') ? Promise.resolve(live()) : Promise.reject(new ApiError('record unavailable', 503)))
233
+ await act(async () => [...host.querySelectorAll('button')].find((b) => b.textContent === 'Refresh record')!.click())
234
+ await settle(() => host.textContent!.includes('record unavailable'))
235
+ expect(host.textContent).toContain('The volume record was read before this run finished')
236
+ })
237
+
238
+ it('shows truncation and retries operations independently', async () => {
239
+ state.fetch.mockImplementation((path: string) => path.includes('volume-operations') ? Promise.reject(new ApiError('operations denied', 403)) : Promise.resolve(record({ total: 5001, truncated: true })))
240
+ await mount(); await settle(() => host.textContent!.includes('operations denied'))
241
+ expect(host.textContent).toContain('first 5,000 of 5001')
242
+ respond()
243
+ await act(async () => [...host.querySelectorAll('button')].find((b) => b.textContent === 'Refresh operations')!.click())
244
+ await settle(() => !host.textContent!.includes('operations denied'))
245
+ expect(state.fetch.mock.calls.filter(([path]) => path.endsWith('/volumes?'))).toHaveLength(1)
246
+ })
247
+ })