Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

feat(disk): reclaim space from the panel

Juan Denisf5023c061367
diff --git a/backend/app/__init__.py b/backend/app/__init__.py
index 467d1f5b..42615db6 100644
--- a/backend/app/__init__.py
+++ b/backend/app/__init__.py
@@ -405,6 +405,8 @@ def create_app(config_name=None):
SiteImportService.register_jobs()
from app.services.drift_service import DriftService
DriftService.register_jobs()
+ from app.services import disk_reclaim_service
+ disk_reclaim_service.register_jobs()
from app.services.doctor_service import DoctorService
DoctorService.register_jobs()
from app.services.fleet_doctor_service import FleetDoctorService
diff --git a/backend/app/api/system.py b/backend/app/api/system.py
index 086a2b02..d1edda54 100644
--- a/backend/app/api/system.py
+++ b/backend/app/api/system.py
@@ -4,7 +4,10 @@ import urllib.request
import json
from flask import Blueprint, jsonify, request, current_app
from flask_jwt_extended import jwt_required, get_jwt_identity
+from app.error_reporting import unexpected_response
+from app.exceptions import ValidationError
from app.models import User
+from app.middleware.rbac import admin_required, get_current_user
from app.services.system_service import SystemService
from app.services.resource_tier_service import ResourceTierService
from app.services import install_profile_service
@@ -143,6 +146,79 @@ def get_disk_metrics():
return jsonify(SystemService.get_disk_metrics()), 200
+@system_bp.route('/disk/reclaim/report', methods=['GET'])
+@admin_required
+def get_disk_reclaim_report():
+ """Measure every safe reclaim candidate. Reads only — deletes nothing."""
+ from app.services import disk_reclaim_service as svc
+
+ try:
+ return jsonify(svc.scan()), 200
+ except Exception as exc: # noqa: BLE001 - reported, not swallowed
+ return unexpected_response(exc)
+
+
+@system_bp.route('/disk/reclaim', methods=['POST'])
+@admin_required
+def reclaim_disk_space():
+ """Reclaim a curated safe set of disk-space candidates.
+
+ Body must carry ``{"confirm": true, "keys": [...]}``; every key is
+ re-validated against a fresh scan server-side (safe candidates only).
+ ``?wait=false`` enqueues the work as a background job instead of running
+ it inline — reclaims can take minutes when Docker or a VACUUM is involved.
+ """
+ data = request.get_json(silent=True) or {}
+ if data.get('confirm') is not True:
+ raise ValidationError('Confirmation required: pass {"confirm": true}.')
+ keys = data.get('keys')
+ if (not isinstance(keys, list) or not keys
+ or not all(isinstance(k, str) and k for k in keys)):
+ raise ValidationError("Body must carry a non-empty 'keys' list.")
+
+ user = get_current_user()
+ from app.services import disk_reclaim_service as svc
+
+ try:
+ keys, error = svc.validate_reclaim_keys(keys)
+ except Exception as exc: # noqa: BLE001 - reported, not swallowed
+ return unexpected_response(exc)
+ if error:
+ raise ValidationError(error)
+
+ try:
+ wait = request.args.get('wait', 'true').lower() != 'false'
+ if not wait:
+ from app.jobs.service import JobService
+ job = JobService.enqueue(
+ svc.DISK_RECLAIM_JOB_KIND,
+ payload={'keys': keys},
+ max_attempts=1,
+ owner_type='system',
+ owner_id='disk',
+ )
+ _audit('disk.reclaim', user.id, target_type='job',
+ target_id=str(job.id), details={'keys': keys, 'queued': True})
+ return jsonify({'job_id': job.id, 'kind': svc.DISK_RECLAIM_JOB_KIND}), 202
+
+ result = svc.reclaim(keys)
+ _audit('disk.reclaim', user.id, target_type='host', target_id='disk',
+ details={'keys': keys, 'freed_bytes': result.get('freed_bytes')})
+ return jsonify(result), 200
+ except Exception as exc: # noqa: BLE001 - reported, not swallowed
+ return unexpected_response(exc)
+
+
+def _audit(action, user_id, target_type=None, target_id=None, details=None):
+ """Best-effort audit entry — never breaks the request."""
+ try:
+ from app.services.audit_service import AuditService
+ AuditService.log(action, user_id=user_id, target_type=target_type,
+ target_id=target_id, details=details)
+ except Exception: # noqa: BLE001
+ pass
+
+
@system_bp.route('/network', methods=['GET'])
@jwt_required()
def get_network_metrics():
diff --git a/backend/app/services/disk_reclaim_service.py b/backend/app/services/disk_reclaim_service.py
index d33c0a54..6a02f309 100644
--- a/backend/app/services/disk_reclaim_service.py
+++ b/backend/app/services/disk_reclaim_service.py
@@ -764,3 +764,60 @@ def reclaim(keys, days=DEFAULT_RETENTION_DAYS, keep=DEFAULT_KEEP_SNAPSHOTS,
'disk_before': before,
'disk_after': after,
}
+
+
+# ── Panel surface (safe-only, validated against a fresh scan) ────────────────
+
+DISK_RECLAIM_JOB_KIND = 'disk.reclaim'
+
+
+def safe_candidate_keys(report=None):
+ """Keys the panel may reclaim without extra review ('safety': 'safe').
+
+ The curated guarantee lives here, not in the UI: whatever a client sends,
+ only candidates that a fresh scan currently reports as safe pass.
+ """
+ if report is None:
+ report = scan()
+ return {c['key'] for c in report['candidates'] if c.get('safety') == 'safe'}
+
+
+def validate_reclaim_keys(keys):
+ """Return ``(keys, None)`` when every requested key is currently safe.
+
+ Returns ``(None, message)`` otherwise, naming the rejected keys so the
+ caller can answer with a precise error.
+ """
+ allowed = safe_candidate_keys()
+ invalid = sorted({k for k in keys if k not in allowed})
+ if invalid:
+ return None, (
+ 'Only reviewed-safe candidates can be reclaimed from the panel: '
+ + ', '.join(invalid)
+ )
+ return keys, None
+
+
+def run_reclaim_job(job):
+ """Job handler for ``disk.reclaim``: reclaim the validated safe set.
+
+ Re-runs the safety validation inside the handler — the queue may pick the
+ job up long after the API call validated its request body.
+ """
+ payload = job.get_payload() or {}
+ keys, error = validate_reclaim_keys(list(payload.get('keys') or []))
+ if error:
+ raise RuntimeError(error)
+ result = reclaim(keys)
+ return {
+ 'freed_bytes': result['freed_bytes'],
+ 'results': result['results'],
+ 'disk_after': result['disk_after'],
+ }
+
+
+def register_jobs():
+ """Register the reclaim handler with the job registry.
+ Called once at app startup (see app/__init__.py)."""
+ from app.jobs import registry
+ registry.register(DISK_RECLAIM_JOB_KIND, run_reclaim_job, replace=True)
diff --git a/backend/tests/test_disk_api.py b/backend/tests/test_disk_api.py
new file mode 100644
index 00000000..e8670510
--- /dev/null
+++ b/backend/tests/test_disk_api.py
@@ -0,0 +1,165 @@
+"""Panel disk-reclaim surface — curated safe set, validated server-side."""
+
+import pytest
+
+from app import db
+from app.services import disk_reclaim_service as svc
+
+
+def _scan_report():
+ return {
+ 'disk': {'path': '/', 'total': 100, 'used': 95, 'free': 5,
+ 'percent_used': 95.0},
+ 'candidates': [
+ {'key': 'upgrade-snapshots', 'safety': 'safe', 'title': 'snapshots',
+ 'detail': '', 'bytes': 40},
+ {'key': 'package-caches', 'safety': 'safe', 'title': 'caches',
+ 'detail': '', 'bytes': 20},
+ {'key': 'telemetry', 'safety': 'review', 'title': 'telemetry',
+ 'detail': '', 'bytes': 10},
+ ],
+ 'total_bytes': 70,
+ }
+
+
[email protected](autouse=True)
+def _fake_measurements(monkeypatch):
+ """Keep every scan/reclaim off the real filesystem and Docker."""
+ monkeypatch.setattr(svc, 'scan', lambda *a, **kw: _scan_report())
+ monkeypatch.setattr(svc, 'reclaim', lambda keys, **kw: {
+ 'dry_run': False,
+ 'results': [{'key': k, 'bytes': 1, 'note': ''} for k in keys],
+ 'freed_bytes': len(list(keys)),
+ 'disk_before': {}, 'disk_after': {},
+ })
+
+
+# ── Report ───────────────────────────────────────────────────────────────────
+
+def test_report_requires_admin(client, viewer_headers):
+ response = client.get('/api/v1/system/disk/reclaim/report',
+ headers=viewer_headers)
+ assert response.status_code == 403
+
+
+def test_report_measures_without_deleting(client, auth_headers):
+ response = client.get('/api/v1/system/disk/reclaim/report',
+ headers=auth_headers)
+ assert response.status_code == 200
+ body = response.get_json()
+ assert body['total_bytes'] == 70
+ assert [c['key'] for c in body['candidates']] == [
+ 'upgrade-snapshots', 'package-caches', 'telemetry']
+
+
+# ── Reclaim contract ─────────────────────────────────────────────────────────
+
+def test_reclaim_requires_explicit_confirmation(client, auth_headers):
+ response = client.post('/api/v1/system/disk/reclaim', headers=auth_headers,
+ json={'keys': ['upgrade-snapshots']})
+ assert response.status_code == 400
+ assert 'confirm' in response.get_json()['error'].lower()
+
+
+def test_reclaim_rejects_review_and_unknown_keys(client, auth_headers):
+ for bad in (['telemetry'], ['nope'], ['telemetry', 'upgrade-snapshots']):
+ response = client.post('/api/v1/system/disk/reclaim',
+ headers=auth_headers,
+ json={'confirm': True, 'keys': bad})
+ assert response.status_code == 400, bad
+ body = response.get_json()
+ assert 'reviewed-safe' in body['error']
+ assert any(k in body['error'] for k in ('telemetry', 'nope'))
+
+
+def test_reclaim_rejects_empty_or_malformed_keys(client, auth_headers):
+ for body in ({'confirm': True}, {'confirm': True, 'keys': []},
+ {'confirm': True, 'keys': ['ok', 3]},
+ {'confirm': True, 'keys': 'upgrade-snapshots'}):
+ response = client.post('/api/v1/system/disk/reclaim',
+ headers=auth_headers, json=body)
+ assert response.status_code == 400
+
+
+def test_reclaim_runs_safe_set_inline(client, auth_headers):
+ response = client.post('/api/v1/system/disk/reclaim', headers=auth_headers,
+ json={'confirm': True,
+ 'keys': ['upgrade-snapshots', 'package-caches']})
+ assert response.status_code == 200
+ body = response.get_json()
+ assert body['freed_bytes'] == 2
+ assert [r['key'] for r in body['results']] == [
+ 'upgrade-snapshots', 'package-caches']
+
+
+def test_reclaim_validates_against_a_fresh_scan_not_the_request(
+ client, auth_headers, monkeypatch):
+ """A candidate that was safe when the report was fetched can go stale."""
+ stale = _scan_report()
+ stale['candidates'][0]['safety'] = 'review'
+ monkeypatch.setattr(svc, 'scan', lambda *a, **kw: stale)
+
+ response = client.post('/api/v1/system/disk/reclaim', headers=auth_headers,
+ json={'confirm': True, 'keys': ['upgrade-snapshots']})
+ assert response.status_code == 400
+ assert 'upgrade-snapshots' in response.get_json()['error']
+
+
+# ── Background path ──────────────────────────────────────────────────────────
+
+def test_wait_false_enqueues_a_job_instead_of_running_inline(
+ client, auth_headers, app, monkeypatch):
+ def _unexpected(*args, **kwargs):
+ raise AssertionError('reclaim must run in the job, not the request')
+
+ monkeypatch.setattr(svc, 'reclaim', _unexpected)
+
+ response = client.post('/api/v1/system/disk/reclaim?wait=false',
+ headers=auth_headers,
+ json={'confirm': True,
+ 'keys': ['package-caches']})
+ assert response.status_code == 202
+ body = response.get_json()
+ assert body['kind'] == svc.DISK_RECLAIM_JOB_KIND
+
+ from app.jobs.models import Job
+ job = db.session.get(Job, body['job_id'])
+ assert job is not None
+ assert job.get_payload() == {'keys': ['package-caches']}
+
+
+def test_job_handler_reruns_validation_before_reclaiming(app, monkeypatch):
+ """The queue may pick the job up long after the request was validated."""
+ from app.jobs.service import JobService
+
+ job = JobService.enqueue(svc.DISK_RECLAIM_JOB_KIND,
+ payload={'keys': ['telemetry']}, max_attempts=1)
+ with pytest.raises(RuntimeError, match='reviewed-safe'):
+ svc.run_reclaim_job(job)
+
+
+def test_job_handler_reclaims_the_safe_set(app):
+ from app.jobs.service import JobService
+
+ job = JobService.enqueue(svc.DISK_RECLAIM_JOB_KIND,
+ payload={'keys': ['package-caches']},
+ max_attempts=1)
+ result = svc.run_reclaim_job(job)
+ assert result['freed_bytes'] == 1
+ assert result['results'] == [
+ {'key': 'package-caches', 'bytes': 1, 'note': ''}]
+
+
+# ── Service-level guard ──────────────────────────────────────────────────────
+
+def test_safe_candidate_keys_reads_safety_tags():
+ assert svc.safe_candidate_keys(_scan_report()) == {
+ 'upgrade-snapshots', 'package-caches'}
+
+
+def test_validate_reclaim_keys_names_every_rejected_key():
+ keys, error = svc.validate_reclaim_keys(
+ ['package-caches', 'telemetry', 'nope'])
+ assert keys is None
+ assert error.startswith('Only reviewed-safe candidates')
+ assert 'nope' in error and 'telemetry' in error
diff --git a/frontend/src/components/monitoring/DiskReclaimModal.jsx b/frontend/src/components/monitoring/DiskReclaimModal.jsx
new file mode 100644
index 00000000..0cc5e111
--- /dev/null
+++ b/frontend/src/components/monitoring/DiskReclaimModal.jsx
@@ -0,0 +1,135 @@
+import { useCallback, useEffect, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+import { HardDrive } from 'lucide-react';
+import api from '../../services/api';
+import Modal from '@/components/Modal';
+import { Button } from '@/components/ui/button';
+import { useToast } from '@/contexts/ToastContext';
+import { useOperations } from '@/contexts/OperationsContext';
+import formatBytes from '@/utils/formatBytes';
+import '@/styles/components/disk-reclaim.scss';
+
+/**
+ * Curated "safe" disk reclaim. Shows what a fresh measurement says can be
+ * freed, then hands the run to Operations as a background job — a reclaim can
+ * take minutes when Docker pruning or a VACUUM is involved. The backend
+ * re-validates every key against its own fresh scan before deleting anything,
+ * so this list is a preview, not the authority.
+ */
+const DiskReclaimModal = ({ open, onClose }) => {
+ const { t } = useTranslation();
+ const toast = useToast();
+ const { openRun } = useOperations();
+ const [report, setReport] = useState(null);
+ const [loading, setLoading] = useState(false);
+ const [error, setError] = useState(null);
+ const [running, setRunning] = useState(false);
+
+ const loadReport = useCallback(() => {
+ setLoading(true);
+ setError(null);
+ api.getDiskReclaimReport()
+ .then(setReport)
+ .catch((err) => setError(err.message || t('app.diskReclaim.couldNotMeasure', 'Could not measure reclaimable space')))
+ .finally(() => setLoading(false));
+ }, [t]);
+
+ useEffect(() => {
+ if (open) loadReport();
+ else {
+ setReport(null);
+ setError(null);
+ setRunning(false);
+ }
+ }, [open, loadReport]);
+
+ // Only reviewed-safe candidates with something actually to free are shown;
+ // 'review' items (telemetry retention) stay CLI-only by design.
+ const candidates = (report?.candidates || []).filter(
+ (c) => c.safety === 'safe' && (c.bytes || 0) > 0
+ );
+ const total = candidates.reduce((sum, c) => sum + (c.bytes || 0), 0);
+
+ const reclaim = async () => {
+ try {
+ setRunning(true);
+ const res = await api.runDiskReclaim(
+ candidates.map((c) => c.key),
+ { wait: false }
+ );
+ openRun('job', res.job_id);
+ toast.success(
+ t('app.diskReclaim.reclaimStartedFollowProgressIn', 'Reclaim started — follow progress in Operations'),
+ {
+ duration: 10000,
+ action: {
+ label: t('app.diskReclaim.viewJob', 'View job'),
+ onClick: () => openRun('job', res.job_id),
+ },
+ }
+ );
+ onClose();
+ } catch (err) {
+ toast.error(err.message || t('app.diskReclaim.reclaimFailed', 'Reclaim failed'));
+ setRunning(false);
+ }
+ };
+
+ return (
+ <Modal
+ open={open}
+ onClose={onClose}
+ title={t('app.diskReclaim.title', 'Reclaim disk space')}
+ footer={(
+ <>
+ <Button variant="outline" onClick={onClose} disabled={running}>
+ {t('app.diskReclaim.cancel', 'Cancel')}
+ </Button>
+ <Button onClick={reclaim} disabled={running || loading || Boolean(error) || candidates.length === 0}>
+ <HardDrive size={14} />
+ {running
+ ? t('app.diskReclaim.reclaiming', 'Reclaiming…')
+ : t('app.diskReclaim.reclaimNow', 'Reclaim now')}
+ </Button>
+ </>
+ )}
+ >
+ <p className="sk-modal__subtitle">
+ {t('app.diskReclaim.onlyReviewedSafeCandidatesAreOffered', 'Only reviewed-safe cleanup is offered — upgrade snapshots beyond the newest one, abandoned update staging, oversized logs, package caches, old journal entries and Docker build cache. Nothing here touches your apps or databases.')}
+ </p>
+
+ {loading ? (
+ <p className="disk-reclaim__state">{t('app.diskReclaim.measuring', 'Measuring what can be freed…')}</p>
+ ) : error ? (
+ <div className="disk-reclaim__state disk-reclaim__state--error">
+ <p>{error}</p>
+ <Button size="sm" variant="outline" onClick={loadReport}>
+ {t('app.diskReclaim.retry', 'Retry')}
+ </Button>
+ </div>
+ ) : candidates.length === 0 ? (
+ <p className="disk-reclaim__state">
+ {t('app.diskReclaim.nothingToReclaimRightNowTheCurated', 'Nothing to reclaim right now — the curated candidates are all clear.')}
+ </p>
+ ) : (
+ <>
+ <ul className="disk-reclaim__list">
+ {candidates.map((c) => (
+ <li key={c.key} className="disk-reclaim__item">
+ <span className="disk-reclaim__item-title">{c.title}</span>
+ <span className="disk-reclaim__item-detail">{c.detail}</span>
+ <span className="disk-reclaim__item-size">{formatBytes(c.bytes)}</span>
+ </li>
+ ))}
+ </ul>
+ <div className="disk-reclaim__total">
+ <span>{t('app.diskReclaim.totalReclaimable', 'Total reclaimable')}</span>
+ <span className="disk-reclaim__total-size">{formatBytes(total)}</span>
+ </div>
+ </>
+ )}
+ </Modal>
+ );
+};
+
+export default DiskReclaimModal;
diff --git a/frontend/src/components/monitoring/DoctorPanel.jsx b/frontend/src/components/monitoring/DoctorPanel.jsx
index 32c68039..253cd15c 100644
--- a/frontend/src/components/monitoring/DoctorPanel.jsx
+++ b/frontend/src/components/monitoring/DoctorPanel.jsx
@@ -6,10 +6,11 @@ import { Button } from '@/components/ui/button';
import Modal from '@/components/Modal';
import { Pill, statusKind } from '@/components/ds';
import EmptyState from '../EmptyState';
-import { ChevronDown, ChevronRight, Server, Stethoscope, Wrench } from 'lucide-react';
+import { ChevronDown, ChevronRight, HardDrive, Server, Stethoscope, Wrench } from 'lucide-react';
import { usePolling } from '@/hooks/usePolling';
import { useTranslation } from 'react-i18next';
import { useOperations } from '@/contexts/OperationsContext';
+import DiskReclaimModal from './DiskReclaimModal';
// The fleet sweep fans out across agents over the network, so it is a job
@@ -28,7 +29,7 @@ function formatRanAt(ranAt) {
* doctor and the fleet doctor can share it — a fleet check is the same shape,
* its repair_ref just names a server.
*/
-function DoctorCheck({ check, expanded, onToggleDiff, onRepair, disabled }) {
+function DoctorCheck({ check, expanded, onToggleDiff, onRepair, disabled, action }) {
const { t } = useTranslation();
return (
<article className={`doctor-check doctor-check--${check.status}`}>
@@ -38,6 +39,7 @@ function DoctorCheck({ check, expanded, onToggleDiff, onRepair, disabled }) {
<span className="doctor-check__title">{check.title}</span>
<span className="doctor-check__detail">{check.detail}</span>
</div>
+ {action}
{check.diff && (
<Button
size="sm"
@@ -79,6 +81,8 @@ const DoctorPanel = () => {
const [fleetLoading, setFleetLoading] = useState(true);
const [sweeping, setSweeping] = useState(false);
const [sweepJobId, setSweepJobId] = useState(null);
+ // The disk.headroom finding offers its own fix: a curated safe reclaim.
+ const [reclaimOpen, setReclaimOpen] = useState(false);
const loadFleet = useCallback(async () => {
try {
@@ -267,6 +271,16 @@ const DoctorPanel = () => {
diff: check.diff || null,
scope: 'host',
})}
+ action={check.key === 'disk.headroom' && check.status !== 'ok' ? (
+ <Button
+ size="sm"
+ variant="outline"
+ onClick={() => setReclaimOpen(true)}
+ >
+ <HardDrive size={13} />
+ {t('app.diskReclaim.reclaimSpace', 'Reclaim space')}
+ </Button>
+ ) : undefined}
/>
))}
</div>
@@ -350,6 +364,8 @@ const DoctorPanel = () => {
)}
</section>
+ <DiskReclaimModal open={reclaimOpen} onClose={() => setReclaimOpen(false)} />
+
<Modal
open={Boolean(confirm)}
onClose={() => setConfirm(null)}
diff --git a/frontend/src/components/monitoring/MonitoringOverview.jsx b/frontend/src/components/monitoring/MonitoringOverview.jsx
index 893fadd7..58f7c61c 100644
--- a/frontend/src/components/monitoring/MonitoringOverview.jsx
+++ b/frontend/src/components/monitoring/MonitoringOverview.jsx
@@ -9,6 +9,7 @@ import { AreaChart, KpiBand, MetricCard, Pill, Sparkline } from '@/components/ds
import { Button } from '@/components/ui/button';
import EmptyState from '../EmptyState';
import MonitorsSummary from './MonitorsSummary';
+import DiskReclaimModal from './DiskReclaimModal';
import { HOST_SCOPE, useScopeMetrics, trendOf } from './useMonitorScope';
import { useTranslation } from 'react-i18next';
@@ -48,6 +49,7 @@ export default function MonitoringOverview({
}) {
const { t } = useTranslation();
const [period, setPeriod] = useState('24h');
+ const [reclaimOpen, setReclaimOpen] = useState(false);
const { series, loading } = useScopeMetrics(scope, period, refreshKey);
// The fleet strip: current values per server in one call, CPU history for
@@ -235,6 +237,15 @@ export default function MonitoringOverview({
) : undefined}
>
{tile.sub && <div className="sk-kpi__sub"><span>{tile.sub}</span></div>}
+ {/* A full disk is the one tile alert that comes with
+ its own fix: the curated safe reclaim. Host-only —
+ agents reclaim on their own boxes. */}
+ {isHost && tile.key === 'disk' && alerting && (
+ <Button size="sm" variant="ghost" onClick={() => setReclaimOpen(true)}>
+ <HardDrive size={12} />
+ {t('app.diskReclaim.reclaimSpace', 'Reclaim space')}
+ </Button>
+ )}
</MetricCard>
);
})}
@@ -400,6 +411,8 @@ export default function MonitoringOverview({
)}
</section>
</div>
+
+ <DiskReclaimModal open={reclaimOpen} onClose={() => setReclaimOpen(false)} />
</div>
);
}
diff --git a/frontend/src/i18n/locales/en.json b/frontend/src/i18n/locales/en.json
index 230c8be8..d4ec1d08 100644
--- a/frontend/src/i18n/locales/en.json
+++ b/frontend/src/i18n/locales/en.json
@@ -1947,6 +1947,22 @@
"dialog": {
"close": "Close"
},
+ "diskReclaim": {
+ "cancel": "Cancel",
+ "couldNotMeasure": "Could not measure reclaimable space",
+ "measuring": "Measuring what can be freed…",
+ "nothingToReclaimRightNowTheCurated": "Nothing to reclaim right now — the curated candidates are all clear.",
+ "onlyReviewedSafeCandidatesAreOffered": "Only reviewed-safe cleanup is offered — upgrade snapshots beyond the newest one, abandoned update staging, oversized logs, package caches, old journal entries and Docker build cache. Nothing here touches your apps or databases.",
+ "reclaimFailed": "Reclaim failed",
+ "reclaimNow": "Reclaim now",
+ "reclaimSpace": "Reclaim space",
+ "reclaimStartedFollowProgressIn": "Reclaim started — follow progress in Operations",
+ "reclaiming": "Reclaiming…",
+ "retry": "Retry",
+ "title": "Reclaim disk space",
+ "totalReclaimable": "Total reclaimable",
+ "viewJob": "View job"
+ },
"dnsActivity": {
"action": "Action",
"loadingRecentChanges": "Loading recent changes…",
diff --git a/frontend/src/services/api/disk.js b/frontend/src/services/api/disk.js
new file mode 100644
index 00000000..5f564e9b
--- /dev/null
+++ b/frontend/src/services/api/disk.js
@@ -0,0 +1,14 @@
+// Disk reclaim (panel host): measure safe candidates, then run a curated,
+// server-side-validated reclaim. The panel never picks what to delete on its
+// own — every key is re-checked against a fresh scan by the backend.
+
+export async function getDiskReclaimReport() {
+ return this.request('/system/disk/reclaim/report');
+}
+
+export async function runDiskReclaim(keys, { wait = true } = {}) {
+ return this.request(`/system/disk/reclaim${wait ? '' : '?wait=false'}`, {
+ method: 'POST',
+ body: { confirm: true, keys }
+ });
+}
diff --git a/frontend/src/services/api/index.js b/frontend/src/services/api/index.js
index 12e4180d..7098e243 100644
--- a/frontend/src/services/api/index.js
+++ b/frontend/src/services/api/index.js
@@ -52,6 +52,7 @@ import * as viewMethods from './views.js';
import * as recycleBinMethods from './recycleBin.js';
import * as errorLogMethods from './errorLogs.js';
import * as walkthroughMethods from './walkthroughs.js';
+import * as diskMethods from './disk.js';
class ApiService extends ApiClient {
constructor() {
@@ -111,6 +112,7 @@ class ApiService extends ApiClient {
recycleBinMethods,
errorLogMethods,
walkthroughMethods,
+ diskMethods,
];
for (const mod of modules) {
for (const [key, fn] of Object.entries(mod)) {
diff --git a/frontend/src/styles/components/_disk-reclaim.scss b/frontend/src/styles/components/_disk-reclaim.scss
new file mode 100644
index 00000000..7da7a09d
--- /dev/null
+++ b/frontend/src/styles/components/_disk-reclaim.scss
@@ -0,0 +1,66 @@
+// Curated safe disk-reclaim modal (components/monitoring/DiskReclaimModal.jsx).
+// Reuses .sk-modal geometry; this file only styles the candidate list.
+
+.disk-reclaim__state {
+ padding: $spacing-lg 0;
+ text-align: center;
+ color: $text-muted;
+ font-size: $font-size-sm;
+
+ &--error p {
+ color: var(--amber);
+ margin-bottom: $spacing-sm;
+ }
+}
+
+.disk-reclaim__list {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ display: flex;
+ flex-direction: column;
+}
+
+.disk-reclaim__item {
+ display: grid;
+ grid-template-columns: 1fr auto;
+ grid-template-areas:
+ 'title size'
+ 'detail size';
+ column-gap: $spacing-md;
+ row-gap: 2px;
+ padding: $spacing-sm 0;
+
+ & + & {
+ border-top: 1px solid $border-color;
+ }
+}
+
+.disk-reclaim__item-title {
+ grid-area: title;
+ font-weight: 500;
+}
+
+.disk-reclaim__item-detail {
+ grid-area: detail;
+ font-size: $font-size-xs;
+ color: $text-muted;
+}
+
+.disk-reclaim__item-size {
+ grid-area: size;
+ align-self: center;
+ font-family: $font-mono;
+ font-variant-numeric: tabular-nums;
+ white-space: nowrap;
+}
+
+.disk-reclaim__total {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin-top: $spacing-sm;
+ padding-top: $spacing-md;
+ border-top: 2px solid $border-color;
+ font-weight: 600;
+}
diff --git a/frontend/src/styles/main.scss b/frontend/src/styles/main.scss
index af143ba8..843a0219 100644
--- a/frontend/src/styles/main.scss
+++ b/frontend/src/styles/main.scss
@@ -82,6 +82,7 @@
@import 'components/_setup-health'; // dashboard setup-health card + account nudge
@import 'components/_widget-editor'; // wide preview+settings widget drawer (skwe-* namespace)
@import 'components/_system-notices';
+@import 'components/_disk-reclaim'; // curated safe disk-reclaim modal
@import 'components/_requires-docker';
@import 'components/container-status';
@import 'components/api-key-scopes';