feat(resources): reclaim banner controls and accurate reclaim math (#1318)

* feat(resources): reclaim banner controls and accurate reclaim math

Make the Resources Hub reclaim banner match what it advertises and give
operators control over when it appears.

- "Review & prune" now reclaims every category the banner lists (unused
  images, stopped containers, and dangling volumes) instead of images
  only, so the banner clears in one action. Pruning runs volumes first,
  while stopped containers still reference their named volumes, so a
  stopped stack's data is never cascaded into deletion.
- Add a "Show reclaimable-space banner" toggle under Settings, System,
  Docker hygiene (on by default, per node) and a dismiss control on the
  banner that snoozes it until the reclaimable total grows again.
- Fix the reclaimable-space math: count only containers a prune can
  actually remove (created, exited, dead) and size them by their writable
  layer, so a small, un-prunable remainder no longer keeps the banner up.

* fix(resources): show the reclaim banner when the settings fetch fails

A failed or empty /settings load left the banner's enabled flag at the
previously active node's value, so switching from a node with the banner
turned off to a node whose /settings errored kept the new node's banner
hidden. Set the flag unconditionally after the staleness guard so a
failed fetch falls back to the default-on state for the current node.
This commit is contained in:
Anso
2026-06-05 18:59:33 -04:00
committed by GitHub
parent 716daf77d0
commit 308949282c
11 changed files with 457 additions and 12 deletions
+11 -5
View File
@@ -140,12 +140,18 @@ class DockerController {
const reclaimableContainers = (items: any[]) => {
if (!items || !Array.isArray(items)) return { bytes: 0, count: 0 };
const reclaimable = items.filter(i => i.State !== 'running');
// Count only the containers `docker container prune` will actually
// remove: created, exited, and dead. A paused or restarting container
// survives the prune, so counting it leaves a residue the banner can
// never clear no matter which prune the operator runs.
const prunableStates = new Set(['created', 'exited', 'dead']);
const reclaimable = items.filter(i => prunableStates.has(String(i.State).toLowerCase()));
// Size by the writable layer only. `docker system df` reports a stopped
// container's reclaimable as its SizeRw; SizeRootFs additionally includes
// the read-only image layers, which removing the container never frees,
// so using it over-reports what a prune actually reclaims.
const bytes = reclaimable.reduce((acc, item) => {
let size = item.SizeRw || item.SizeRootFs || 0;
if (item.UsageData && typeof item.UsageData.Size === 'number') {
size = item.UsageData.Size;
}
const size = typeof item.SizeRw === 'number' && item.SizeRw > 0 ? item.SizeRw : 0;
return acc + size;
}, 0);
return { bytes, count: reclaimable.length };