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.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
feat(restore-points): add server restore points UI
Juan Denis69182c3d957b
diff --git a/frontend/src/components/deployments/ConfigDiffModal.jsx b/frontend/src/components/deployments/ConfigDiffModal.jsxindex 8d6db312..2664fc27 100644--- a/frontend/src/components/deployments/ConfigDiffModal.jsx+++ b/frontend/src/components/deployments/ConfigDiffModal.jsx@@ -1,16 +1,22 @@-import { useState, useEffect } from 'react';-import { RotateCcw, Info } from 'lucide-react';+import { useEffect, useState } from 'react';+import { AlertTriangle, Info, RotateCcw, ShieldCheck } from 'lucide-react';import api from '../../services/api';import Modal from '@/components/Modal';import { Button } from '@/components/ui/button';+import { Pill } from '@/components/ds';import { useToast } from '../../contexts/ToastContext';+import { useConfirm } from '../../hooks/useConfirm';import { useTranslation } from 'react-i18next';-// Modal showing a structured config diff between a snapshot and another-// (default: the previous snapshot). Env vars are compared by KEY only — values-// are never shown, so secrets can't leak. Sections: env (added/removed/changed-// keys), domains, image/tag, build method, volumes. A Restore button re-applies-// the snapshot's config and triggers a redeploy.+function displayValue(value, notSet) {+ if (value === null || value === undefined || value === '') return notSet;+ if (typeof value === 'string') return value;+ try {+ return JSON.stringify(value);+ } catch {+ return String(value);+ }+}function DiffList({ title, added = [], removed = [], changed = [] }) {const { t } = useTranslation();@@ -27,19 +33,19 @@ function DiffList({ title, added = [], removed = [], changed = [] }) {<div className="config-diff__section"><h4 className="config-diff__section-title">{title}</h4><ul className="config-diff__lines">- {added.map((k) => (- <li key={`a-${k}`} className="config-diff__line config-diff__line--add">- <span className="config-diff__sign">+</span> {k}+ {added.map((key) => (+ <li key={`a-${key}`} className="config-diff__line config-diff__line--add">+ <span className="config-diff__sign">+</span> {key}</li>))}- {removed.map((k) => (- <li key={`r-${k}`} className="config-diff__line config-diff__line--remove">- <span className="config-diff__sign">−</span> {k}+ {removed.map((key) => (+ <li key={`r-${key}`} className="config-diff__line config-diff__line--remove">+ <span className="config-diff__sign">-</span> {key}</li>))}- {changed.map((k) => (- <li key={`c-${k}`} className="config-diff__line config-diff__line--change">- <span className="config-diff__sign">~</span> {k}+ {changed.map((key) => (+ <li key={`c-${key}`} className="config-diff__line config-diff__line--change">+ <span className="config-diff__sign">~</span> {key}</li>))}</ul>@@ -49,46 +55,147 @@ function DiffList({ title, added = [], removed = [], changed = [] }) {function ScalarDiff({ title, oldVal, newVal, changed }) {const { t } = useTranslation();+ const notSet = t('app.configDiffModal.notSet', 'Not set');return (<div className="config-diff__section"><h4 className="config-diff__section-title">{title}</h4>{changed ? (<div className="config-diff__scalar">- <span className="config-diff__old">{oldVal || '—'}</span>- <span className="config-diff__arrow">→</span>- <span className="config-diff__new">{newVal || '—'}</span>+ <span className="config-diff__old">{displayValue(oldVal, notSet)}</span>+ <span className="config-diff__arrow" aria-hidden="true">→</span>+ <span className="config-diff__new">{displayValue(newVal, notSet)}</span></div>) : (- <p className="config-diff__none">{t('app.configDiffModal.noChange', 'No change (')}{newVal || '—'})</p>+ <p className="config-diff__none">+ {t('app.configDiffModal.noChangeValue', 'No change ({{value}})', {+ value: displayValue(newVal, notSet),+ })}+ </p>+ )}+ </div>+ );+}++function entries(value) {+ if (Array.isArray(value)) return value.map((item, index) => [String(index + 1), item]);+ if (value && typeof value === 'object') return Object.entries(value);+ return value === undefined || value === null || value === '' ? [] : [['', value]];+}++function GenericDiff({ title, diff }) {+ const { t } = useTranslation();+ const notSet = t('app.configDiffModal.notSet', 'Not set');+ const added = entries(diff?.added);+ const removed = entries(diff?.removed);+ const changed = entries(diff?.changed);+ const hasChanges = added.length || removed.length || changed.length;++ return (+ <div className="config-diff__section">+ <h4 className="config-diff__section-title">{title}</h4>+ {!hasChanges ? (+ <p className="config-diff__none">{t('app.configDiffModal.noChanges', 'No changes')}</p>+ ) : (+ <ul className="config-diff__lines">+ {added.map(([key, value]) => (+ <li key={`added-${key}-${displayValue(value, notSet)}`} className="config-diff__line config-diff__line--add">+ <span className="config-diff__sign">+</span>+ <span className="config-diff__path">{key || t('app.configDiffModal.value', 'Value')}</span>+ <span className="config-diff__value">{displayValue(value, notSet)}</span>+ </li>+ ))}+ {removed.map(([key, value]) => (+ <li key={`removed-${key}-${displayValue(value, notSet)}`} className="config-diff__line config-diff__line--remove">+ <span className="config-diff__sign">-</span>+ <span className="config-diff__path">{key || t('app.configDiffModal.value', 'Value')}</span>+ <span className="config-diff__value">{displayValue(value, notSet)}</span>+ </li>+ ))}+ {changed.map(([key, value]) => {+ const isPair = value && typeof value === 'object'+ && Object.prototype.hasOwnProperty.call(value, 'old')+ && Object.prototype.hasOwnProperty.call(value, 'new');+ return (+ <li key={`changed-${key}`} className="config-diff__line config-diff__line--change">+ <span className="config-diff__sign">~</span>+ <span className="config-diff__path">{key || t('app.configDiffModal.value', 'Value')}</span>+ <span className="config-diff__value">+ {isPair+ ? `${displayValue(value.old, notSet)} → ${displayValue(value.new, notSet)}`+ : displayValue(value, notSet)}+ </span>+ </li>+ );+ })}+ </ul>)}</div>);}-const ConfigDiffModal = ({ appId, snapId, against = 'previous', onClose, onRestored }) => {+const ConfigDiffModal = ({+ appId,+ snapId,+ restorePointId,+ restorePoint,+ against = 'previous',+ onClose,+ onRestored,+}) => {const { t } = useTranslation();const toast = useToast();+ const { confirm } = useConfirm();+ const isRestorePoint = Boolean(restorePointId);const [diff, setDiff] = useState(null);const [meta, setMeta] = useState(null);+ const [preview, setPreview] = useState(null);const [loading, setLoading] = useState(true);const [error, setError] = useState(null);+ const [previewError, setPreviewError] = useState(null);const [restoring, setRestoring] = useState(false);- const [confirmRestore, setConfirmRestore] = useState(false);useEffect(() => {let cancelled = false;(async () => {try {setLoading(true);- const res = await api.getSnapshotDiff(appId, snapId, against);- if (cancelled) return;- setDiff(res.diff);- setMeta({- summary: res.summary,- hasChanges: res.has_changes,- againstId: res.against_id,- });setError(null);+ setPreviewError(null);+ if (restorePointId) {+ const [diffResult, previewResult] = await Promise.allSettled([+ api.getRestorePointDiff(restorePointId, against),+ api.previewRestorePoint(restorePointId),+ ]);+ if (cancelled) return;+ if (diffResult.status === 'fulfilled') {+ const diffRes = diffResult.value;+ setDiff(diffRes.diff || null);+ setMeta({+ hasChanges: diffRes.has_changes,+ againstId: diffRes.against_point_id,+ });+ } else {+ setDiff(null);+ setMeta(null);+ setError(diffResult.reason?.message || t('app.configDiffModal.diffUnavailable', 'Diff unavailable'));+ }+ if (previewResult.status === 'fulfilled') {+ setPreview(previewResult.value);+ } else {+ setPreview(null);+ setPreviewError(previewResult.reason?.message || t('app.configDiffModal.previewUnavailable', 'Restore preview unavailable'));+ }+ } else {+ const res = await api.getSnapshotDiff(appId, snapId, against);+ if (cancelled) return;+ setDiff(res.diff);+ setMeta({+ summary: res.summary,+ hasChanges: res.has_changes,+ againstId: res.against_id,+ });+ setPreview(null);+ }} catch (err) {if (!cancelled) setError(err.message);} finally {@@ -98,15 +205,31 @@ const ConfigDiffModal = ({ appId, snapId, against = 'previous', onClose, onRestoreturn () => {cancelled = true;};- }, [appId, snapId, against]);+ }, [against, appId, restorePointId, snapId, t]);async function handleRestore() {+ const confirmed = await confirm({+ title: isRestorePoint+ ? t('app.configDiffModal.restoreRestorePoint', 'Restore this restore point?')+ : t('app.configDiffModal.restoreConfiguration', 'Restore this configuration?'),+ message: isRestorePoint+ ? t('app.configDiffModal.restorePointConfirmation', 'ServerKit will capture the current managed state first, then apply the recoverable values from this restore point.')+ : t('app.configDiffModal.restoreConfigurationConfirmation', 'This configuration will be restored and a redeploy will start.'),+ confirmText: t('app.configDiffModal.confirmRestore', 'Confirm restore'),+ variant: 'danger',+ });+ if (!confirmed) return;+setRestoring(true);try {- const res = await api.restoreSnapshot(appId, snapId);+ const res = isRestorePoint+ ? await api.restoreRestorePoint(restorePointId)+ : await api.restoreSnapshot(appId, snapId);if (res.success) {- toast.success(t('app.configDiffModal.configurationRestoredRedeployTriggered', 'Configuration restored. Redeploy triggered.'));- if (onRestored) onRestored(res);+ toast.success(isRestorePoint+ ? t('app.configDiffModal.restorePointRestored', 'Restore point applied successfully.')+ : t('app.configDiffModal.configurationRestoredRedeployTriggered', 'Configuration restored. Redeploy triggered.'));+ onRestored?.(res);} else {toast.error(res.error || t('app.configDiffModal.restoreFailed', 'Restore failed'));}@@ -114,96 +237,185 @@ const ConfigDiffModal = ({ appId, snapId, against = 'previous', onClose, onRestotoast.error(err.message);} finally {setRestoring(false);- setConfirmRestore(false);}}+ const footer = (+ <>+ <Button variant="outline" onClick={onClose} disabled={restoring}>+ {t('common.actions.close', 'Close')}+ </Button>+ <Button+ onClick={handleRestore}+ disabled={loading || restoring || (isRestorePoint ? (!preview || !preview.can_restore) : Boolean(error))}+ >+ <RotateCcw size={14} />+ {restoring+ ? t('app.configDiffModal.restoring', 'Restoring…')+ : (isRestorePoint+ ? t('app.configDiffModal.applyRestorePoint', 'Apply restore point')+ : t('app.configDiffModal.restoreThisConfig', 'Restore this config'))}+ </Button>+ </>+ );+return (- <Modal open onClose={onClose} title={t('app.configDiffModal.configurationDiff', 'Configuration diff')} size="xl" className="config-diff">+ <Modal+ open+ onClose={onClose}+ title={isRestorePoint+ ? t('app.configDiffModal.restorePointPreview', 'Restore point preview')+ : t('app.configDiffModal.configurationDiff', 'Configuration diff')}+ size="xl"+ className="config-diff"+ footer={footer}+ ><div className="config-diff__body">- {loading && <p className="config-diff__loading">{t('app.configDiffModal.loadingDiff', 'Loading diff…')}</p>}- {error && <div className="alert alert-danger">{error}</div>}-- {!loading && !error && diff && (- <>- {meta && (- <div className="config-diff__summary-banner" role="status">- <Info size={16} className="config-diff__summary-icon" />- <div className="config-diff__summary-text">- <span className="config-diff__summary-label">- {t('app.configDiffModal.inPlainLanguage', 'In plain language')}- </span>- <p className="config-diff__summary">- {meta.hasChanges && meta.summary- ? meta.summary- : 'No configuration changes vs the compared checkpoint.'}- </p>- </div>+ {loading && (+ <p className="config-diff__loading" role="status" aria-live="polite">+ {t('app.configDiffModal.loadingDiff', 'Loading diff…')}+ </p>+ )}+ {error && !isRestorePoint && <div className="alert alert-danger">{error}</div>}++ {!loading && !error && diff && !isRestorePoint && (+ <>+ {meta && (+ <div className="config-diff__summary-banner" role="status">+ <Info size={16} className="config-diff__summary-icon" />+ <div className="config-diff__summary-text">+ <span className="config-diff__summary-label">+ {t('app.configDiffModal.inPlainLanguage', 'In plain language')}+ </span>+ <p className="config-diff__summary">+ {meta.hasChanges && meta.summary+ ? meta.summary+ : t('app.configDiffModal.noConfigurationChanges', 'No configuration changes compared with this checkpoint.')}+ </p></div>+ </div>+ )}++ <DiffList+ title={t('app.configDiffModal.environmentVariables', 'Environment variables')}+ added={diff.env?.added}+ removed={diff.env?.removed}+ changed={diff.env?.changed}+ />+ <DiffList+ title={t('common.labels.domains', 'Domains')}+ added={diff.domains?.added}+ removed={diff.domains?.removed}+ />+ <DiffList+ title={t('app.configDiffModal.volumes', 'Volumes')}+ added={diff.volumes?.added}+ removed={diff.volumes?.removed}+ />+ <ScalarDiff+ title={t('app.configDiffModal.imageTag', 'Image / tag')}+ oldVal={diff.image?.old}+ newVal={diff.image?.new}+ changed={diff.image?.changed}+ />+ <ScalarDiff+ title={t('app.configDiffModal.buildMethod', 'Build method')}+ oldVal={diff.build_method?.old}+ newVal={diff.build_method?.new}+ changed={diff.build_method?.changed}+ />+ </>+ )}++ {!loading && isRestorePoint && (+ <>+ <div className="config-diff__point-meta">+ <div>+ <span className="config-diff__summary-label">+ {t('app.configDiffModal.savedCheckpoint', 'Saved checkpoint')}+ </span>+ <p className="config-diff__summary">+ {restorePoint?.label || t('app.configDiffModal.unlabelledRestorePoint', 'Unlabelled restore point')}+ </p>+ </div>+ <Pill kind={previewError ? 'amber' : (preview?.can_restore ? 'green' : 'red')} dot={false}>+ {previewError+ ? t('app.configDiffModal.previewUnavailable', 'Restore preview unavailable')+ : (preview?.can_restore+ ? t('app.configDiffModal.readyToRestore', 'Ready to restore')+ : t('app.configDiffModal.restoreBlocked', 'Restore blocked'))}+ </Pill>+ </div>++ <div className="config-diff__group">+ <div className="config-diff__group-heading">+ <h3>{t('app.configDiffModal.currentRestorePreview', 'Current restore preview')}</h3>+ <p>{t('app.configDiffModal.currentRestorePreviewDescription', 'These changes compare the current state with the selected restore point.')}</p>+ </div>+ {previewError ? (+ <div className="alert alert-warning" role="status">{previewError}</div>+ ) : (+ <GenericDiff+ title={t('app.configDiffModal.changesToApply', 'Changes to apply')}+ diff={preview?.diff}+ />)}+ </div>- <DiffList- title={t('app.configDiffModal.environmentVariables', 'Environment variables')}- added={diff.env?.added}- removed={diff.env?.removed}- changed={diff.env?.changed}- />- <DiffList- title={t('common.labels.domains', 'Domains')}- added={diff.domains?.added}- removed={diff.domains?.removed}- />- <DiffList- title={t('app.configDiffModal.volumes', 'Volumes')}- added={diff.volumes?.added}- removed={diff.volumes?.removed}- />- <ScalarDiff- title={t('app.configDiffModal.imageTag', 'Image / tag')}- oldVal={diff.image?.old}- newVal={diff.image?.new}- changed={diff.image?.changed}- />- <ScalarDiff- title={t('app.configDiffModal.buildMethod', 'Build method')}- oldVal={diff.build_method?.old}- newVal={diff.build_method?.new}- changed={diff.build_method?.changed}- />- </>- )}- </div>+ <div className="config-diff__coverage">+ <div className="config-diff__coverage-heading">+ <ShieldCheck size={17} />+ <div>+ <h3>{t('app.configDiffModal.coverageAndLimits', 'Coverage and limits')}</h3>+ <p>{t('app.configDiffModal.coverageDescription', 'Review what this checkpoint does not restore before continuing.')}</p>+ </div>+ </div>+ {((preview?.outside_checkpoint || restorePoint?.coverage || []).length > 0) ? (+ <ul>+ {(preview?.outside_checkpoint || restorePoint?.coverage || []).map((item) => (+ <li key={item}>{item}</li>+ ))}+ </ul>+ ) : (+ <p className="config-diff__none">+ {t('app.configDiffModal.noCoverageGaps', 'The checkpoint reported nothing outside its coverage.')}+ </p>+ )}+ </div>- <div className="modal-actions">- {confirmRestore ? (- <>- <span className="config-diff__confirm-text">- {meta && meta.hasChanges && meta.summary- ? `Restore this configuration and redeploy? ${meta.summary}.`- : 'Restore this configuration and redeploy?'}- </span>- <Button- variant="outline"- onClick={() => setConfirmRestore(false)}- disabled={restoring}- >- {t('common.actions.cancel', 'Cancel')}- </Button>- <Button onClick={handleRestore} disabled={restoring}>- {restoring ? 'Restoring…' : 'Confirm restore'}- </Button>- </>- ) : (- <>- <Button variant="outline" onClick={onClose}>- {t('common.actions.close', 'Close')}- </Button>- <Button onClick={() => setConfirmRestore(true)} disabled={loading || !!error}>- <RotateCcw size={14} /> {t('app.configDiffModal.restoreThisConfig', 'Restore this config')}- </Button>- </>- )}- </div>+ {preview?.refusals?.length > 0 && (+ <div className="config-diff__refusals" role="alert">+ <AlertTriangle size={17} />+ <div>+ <h3>{t('app.configDiffModal.restoreRefusals', 'Restore blockers')}</h3>+ <ul>+ {preview.refusals.map((item) => <li key={item}>{item}</li>)}+ </ul>+ </div>+ </div>+ )}++ <div className="config-diff__group">+ <div className="config-diff__group-heading">+ <h3>{t('app.configDiffModal.historicalDiff', 'Historical diff')}</h3>+ <p>{error+ ? t('app.configDiffModal.historicalDiffUnavailable', 'The comparison with the previous checkpoint could not be loaded.')+ : (meta?.againstId+ ? t('app.configDiffModal.historicalDiffDescription', 'These changes compare this restore point with the checkpoint captured before it.')+ : t('app.configDiffModal.firstRestorePoint', 'This is the first restore point in this scope.'))}</p>+ </div>+ {error ? (+ <div className="alert alert-warning" role="status">{error}</div>+ ) : (+ <GenericDiff+ title={t('app.configDiffModal.savedChanges', 'Saved changes')}+ diff={diff}+ />+ )}+ </div>+ </>+ )}+ </div></Modal>);};diff --git a/frontend/src/components/deployments/DeploymentTimeline.jsx b/frontend/src/components/deployments/DeploymentTimeline.jsxindex 41b6974f..cc30a2f2 100644--- a/frontend/src/components/deployments/DeploymentTimeline.jsx+++ b/frontend/src/components/deployments/DeploymentTimeline.jsx@@ -1,16 +1,20 @@-import { useState, useEffect, useCallback } from 'react';-import { GitBranch, Box, Clock, FileDiff } from 'lucide-react';+import { useCallback, useEffect, useRef, useState } from 'react';+import {+ Box,+ Clock,+ FileDiff,+ GitBranch,+ History,+ RotateCcw,+ ScrollText,+} from 'lucide-react';import api from '../../services/api';-import { Pill } from '@/components/ds';+import EmptyState from '@/components/EmptyState';+import { ListToolbar, Pill, SegControl } from '@/components/ds';import { Button } from '@/components/ui/button';import ConfigDiffModal from './ConfigDiffModal';import { useTranslation } from 'react-i18next';-// Vertical timeline of an app's config snapshots. Each node shows the image /-// build method, a "config changed" badge (derived from the per-snapshot-// summary), and the capture time. Clicking a node opens the config diff vs the-// previous snapshot. Snapshots never carry secret values (masked at capture).-function formatTime(iso) {if (!iso) return '';try {@@ -20,20 +24,18 @@ function formatTime(iso) {}}-// A snapshot's `summary` reads like "no config changes" when nothing changed,-// or e.g. "3 env vars changed; image updated" otherwise.function snapshotChanged(summary) {if (!summary) return false;- const s = summary.toLowerCase();- return !(s === 'no config changes' || s === 'initial config snapshot');+ const normalized = summary.toLowerCase();+ return !(normalized === 'no config changes' || normalized === 'initial config snapshot');}-const DeploymentTimeline = ({ appId }) => {+function AppDeploymentTimeline({ appId }) {const { t } = useTranslation();const [snapshots, setSnapshots] = useState([]);const [loading, setLoading] = useState(true);const [error, setError] = useState(null);- const [activeDiff, setActiveDiff] = useState(null); // { snapId }+ const [activeDiff, setActiveDiff] = useState(null);const loadSnapshots = useCallback(async () => {try {@@ -72,16 +74,16 @@ const DeploymentTimeline = ({ appId }) => {return (<div className="deploy-timeline"><ol className="deploy-timeline__list">- {snapshots.map((snap, idx) => {+ {snapshots.map((snap, index) => {const cfg = snap.config || {};const changed = snapshotChanged(snap.summary);- const isLatest = idx === 0;+ const isLatest = index === 0;return (<li key={snap.id} className="deploy-timeline__item"><spanclassName={- 'deploy-timeline__marker' +- (isLatest ? ' deploy-timeline__marker--current' : '')+ 'deploy-timeline__marker'+ + (isLatest ? ' deploy-timeline__marker--current' : '')}aria-hidden="true"/>@@ -120,8 +122,9 @@ const DeploymentTimeline = ({ appId }) => {)}{cfg.env_keys && (<span className="deploy-timeline__chip">- {cfg.env_keys.length} {t('app.deploymentTimeline.envVar', 'env var')}- {cfg.env_keys.length === 1 ? '' : 's'}+ {t('app.deploymentTimeline.envVarCount', '{{count}} env vars', {+ count: cfg.env_keys.length,+ })}</span>)}</div>@@ -148,6 +151,258 @@ const DeploymentTimeline = ({ appId }) => {)}</div>);+}++function eventTitle(event, t) {+ if (event.type === 'restore_point') {+ return event.label || t('app.deploymentTimeline.environmentRestorePoint', 'Environment restore point');+ }+ if (event.type === 'deployment_snapshot') {+ return event.application_name+ ? t('app.deploymentTimeline.deploymentCheckpointFor', 'Deployment checkpoint for {{name}}', { name: event.application_name })+ : t('app.deploymentTimeline.deploymentCheckpoint', 'Deployment checkpoint');+ }+ return String(event.action || t('app.deploymentTimeline.auditEvent', 'Audit event'))+ .replaceAll('.', ' ')+ .replaceAll('_', ' ');+}++function eventKind(event, t) {+ if (event.type === 'restore_point') return t('app.deploymentTimeline.restorePoint', 'Restore point');+ if (event.type === 'deployment_snapshot') return t('app.deploymentTimeline.deployment', 'Deployment');+ return t('app.deploymentTimeline.audit', 'Audit');+}++function eventPillKind(type) {+ if (type === 'restore_point') return 'violet';+ if (type === 'deployment_snapshot') return 'cyan';+ return 'gray';+}++function humanizeToken(value) {+ const text = String(value || '').replaceAll('_', ' ').trim();+ return text ? text.charAt(0).toUpperCase() + text.slice(1) : '';+}++function EventIcon({ type }) {+ if (type === 'restore_point') return <RotateCcw size={15} />;+ if (type === 'deployment_snapshot') return <Box size={15} />;+ return <ScrollText size={15} />;+}++function ServerTimelineEvent({ event, onReview }) {+ const { t } = useTranslation();+ const detailEntries = Object.entries(event.details || {}).slice(0, 4);+ return (+ <li className={`deploy-timeline__item deploy-timeline__item--${event.type}`}>+ <span className={`deploy-timeline__marker deploy-timeline__marker--${event.type}`} aria-hidden="true">+ <EventIcon type={event.type} />+ </span>+ <article className="deploy-timeline__card">+ <div className="deploy-timeline__row">+ <div className="deploy-timeline__meta">+ <Pill kind={eventPillKind(event.type)} dot={false}>{eventKind(event, t)}</Pill>+ <span className="deploy-timeline__time">+ <Clock size={13} /> {formatTime(event.created_at)}+ </span>+ </div>+ {event.type !== 'audit' && (+ <Button variant="outline" size="sm" onClick={() => onReview(event)}>+ <FileDiff size={14} />+ {event.type === 'restore_point'+ ? t('app.deploymentTimeline.previewRestore', 'Preview restore')+ : t('app.deploymentTimeline.viewDiff', 'View diff')}+ </Button>+ )}+ </div>++ <div className="deploy-timeline__event-heading">+ <h3>{eventTitle(event, t)}</h3>+ {event.actor_username && (+ <span>{t('app.deploymentTimeline.byActor', 'by {{actor}}', { actor: event.actor_username })}</span>+ )}+ </div>++ {event.type === 'restore_point' && (+ <>+ <div className="deploy-timeline__details">+ <span className="deploy-timeline__chip">{humanizeToken(event.scope_type)}</span>+ <span className="deploy-timeline__chip">{humanizeToken(event.trigger)}</span>+ </div>+ {event.coverage?.length > 0 && (+ <p className="deploy-timeline__coverage-note">+ {t('app.deploymentTimeline.coverageLimitCount', '{{count}} coverage limits', {+ count: event.coverage.length,+ })}+ </p>+ )}+ </>+ )}++ {event.type === 'deployment_snapshot' && event.summary && (+ <p className="deploy-timeline__summary">{event.summary}</p>+ )}++ {event.type === 'audit' && (+ <div className="deploy-timeline__details">+ {event.target_type && (+ <span className="deploy-timeline__chip">{event.target_type}</span>+ )}+ {detailEntries.map(([key, value]) => (+ <span key={key} className="deploy-timeline__chip">+ {key.replaceAll('_', ' ')}: {String(value)}+ </span>+ ))}+ </div>+ )}+ </article>+ </li>+ );+}++function ServerActivityTimeline({ serverId, refreshKey = 0 }) {+ const { t } = useTranslation();+ const [filter, setFilter] = useState('all');+ const [events, setEvents] = useState([]);+ const [nextCursor, setNextCursor] = useState(null);+ const [loading, setLoading] = useState(true);+ const [loadingMore, setLoadingMore] = useState(false);+ const [error, setError] = useState(null);+ const [activeDiff, setActiveDiff] = useState(null);+ const requestGeneration = useRef(0);++ const selectedTypes = filter === 'all' ? [] : [filter];++ const loadPage = useCallback(async ({ before = null, append = false } = {}) => {+ const generation = ++requestGeneration.current;+ try {+ if (append) setLoadingMore(true);+ else setLoading(true);+ const res = await api.getServerTimeline(serverId, {+ types: filter === 'all' ? [] : [filter],+ before,+ limit: 30,+ });+ if (generation !== requestGeneration.current) return;+ setEvents((current) => append ? [...current, ...(res.events || [])] : (res.events || []));+ setNextCursor(res.next_cursor || null);+ setError(null);+ } catch (err) {+ if (generation === requestGeneration.current) setError(err.message);+ } finally {+ if (generation === requestGeneration.current) {+ setLoading(false);+ setLoadingMore(false);+ }+ }+ }, [filter, serverId]);++ useEffect(() => {+ setEvents([]);+ setNextCursor(null);+ loadPage();+ }, [loadPage, refreshKey]);++ const filterOptions = [+ { value: 'all', label: t('common.labels.all', 'All') },+ { value: 'restore_point', label: t('app.deploymentTimeline.restorePoints', 'Restore points') },+ { value: 'deployment_snapshot', label: t('app.deploymentTimeline.deployments', 'Deployments') },+ { value: 'audit', label: t('app.deploymentTimeline.audit', 'Audit') },+ ];++ function openEvent(event) {+ if (event.type === 'restore_point') {+ setActiveDiff({ restorePointId: event.source_id, restorePoint: event });+ } else if (event.type === 'deployment_snapshot') {+ setActiveDiff({ appId: event.application_id, snapId: event.source_id });+ }+ }++ if (loading) {+ return (+ <div className="deploy-timeline deploy-timeline--server">+ <ListToolbar+ filters={<SegControl options={filterOptions} value={filter} onChange={setFilter} />}+ />+ <EmptyState loading loadingVariant="feed" title={t('app.deploymentTimeline.loadingServerTimeline', 'Loading server timeline')} />+ </div>+ );+ }++ return (+ <div className="deploy-timeline deploy-timeline--server">+ <ListToolbar+ filters={<SegControl options={filterOptions} value={filter} onChange={setFilter} />}+ tools={(+ <span className="deploy-timeline__count">+ {t('app.deploymentTimeline.eventCount', '{{count}} events', { count: events.length })}+ </span>+ )}+ />++ {error && (+ <div className="deploy-timeline__error alert alert-danger">+ <span>{error}</span>+ <Button variant="outline" size="sm" onClick={() => loadPage()}>+ {t('common.actions.retry', 'Retry')}+ </Button>+ </div>+ )}++ {!error && events.length === 0 && (+ <EmptyState+ icon={History}+ title={t('app.deploymentTimeline.noServerEvents', 'No timeline events yet')}+ description={selectedTypes.length+ ? t('app.deploymentTimeline.noFilteredEvents', 'No events match this timeline filter.')+ : t('app.deploymentTimeline.noServerEventsDescription', 'Quicksaves, deployments, and server audit activity will appear here.')}+ size="lg"+ />+ )}++ {events.length > 0 && (+ <ol className="deploy-timeline__list">+ {events.map((event) => (+ <ServerTimelineEvent key={event.id} event={event} onReview={openEvent} />+ ))}+ </ol>+ )}++ {nextCursor && (+ <div className="deploy-timeline__footer">+ <Button+ variant="outline"+ onClick={() => loadPage({ before: nextCursor, append: true })}+ disabled={loadingMore}+ >+ {loadingMore+ ? t('common.state.loading', 'Loading')+ : t('common.actions.loadMore', 'Load more')}+ </Button>+ </div>+ )}++ {activeDiff && (+ <ConfigDiffModal+ {...activeDiff}+ onClose={() => setActiveDiff(null)}+ onRestored={() => {+ setActiveDiff(null);+ setEvents([]);+ setNextCursor(null);+ loadPage();+ }}+ />+ )}+ </div>+ );+}++const DeploymentTimeline = ({ appId, serverId, refreshKey = 0 }) => {+ if (serverId) {+ return <ServerActivityTimeline serverId={serverId} refreshKey={refreshKey} />;+ }+ return <AppDeploymentTimeline appId={appId} />;};export default DeploymentTimeline;diff --git a/frontend/src/components/serverdetail/ServerRestorePointsTab.jsx b/frontend/src/components/serverdetail/ServerRestorePointsTab.jsxnew file mode 100644index 00000000..283cde02--- /dev/null+++ b/frontend/src/components/serverdetail/ServerRestorePointsTab.jsx@@ -0,0 +1,206 @@+import { useCallback, useEffect, useMemo, useState } from 'react';+import { Info, RefreshCw, Save } from 'lucide-react';+import api from '../../services/api';+import Modal from '../Modal';+import FormField from '../FormField';+import DeploymentTimeline from '../deployments/DeploymentTimeline';+import { Button } from '../ui/button';+import { useToast } from '../../contexts/ToastContext';+import { useTranslation } from 'react-i18next';++export default function ServerRestorePointsTab({ serverId }) {+ const { t } = useTranslation();+ const toast = useToast();+ const [apps, setApps] = useState([]);+ const [appsLoading, setAppsLoading] = useState(true);+ const [appsError, setAppsError] = useState(null);+ const [showQuicksave, setShowQuicksave] = useState(false);+ const [selectedAppId, setSelectedAppId] = useState('');+ const [label, setLabel] = useState('');+ const [saving, setSaving] = useState(false);+ const [saveError, setSaveError] = useState(null);+ const [timelineRefreshKey, setTimelineRefreshKey] = useState(0);++ const loadApps = useCallback(async () => {+ try {+ setAppsLoading(true);+ const data = await api.getApps({ allWorkspaces: true });+ setApps(data.apps || []);+ setAppsError(null);+ } catch (err) {+ setAppsError(err.message);+ } finally {+ setAppsLoading(false);+ }+ }, []);++ useEffect(() => {+ loadApps();+ }, [loadApps]);++ const serverApps = useMemo(+ () => apps+ .filter((app) => String(app.server_id || '') === String(serverId))+ .sort((left, right) => left.name.localeCompare(right.name)),+ [apps, serverId],+ );++ function openQuicksave() {+ setSelectedAppId(serverApps.length === 1 ? String(serverApps[0].id) : '');+ setLabel('');+ setSaveError(null);+ setShowQuicksave(true);+ }++ function handleRefresh() {+ loadApps();+ setTimelineRefreshKey((value) => value + 1);+ }++ async function handleQuicksave() {+ if (!selectedAppId) {+ setSaveError(t('app.serverRestorePoints.chooseApplication', 'Choose an application to quicksave.'));+ return;+ }+ try {+ setSaving(true);+ setSaveError(null);+ await api.createRestorePoint({+ scopeType: 'env',+ scopeId: selectedAppId,+ label: label.trim() || null,+ });+ setShowQuicksave(false);+ setTimelineRefreshKey((value) => value + 1);+ toast.success(t('app.serverRestorePoints.quicksaveCreated', 'Environment quicksave created.'));+ } catch (err) {+ setSaveError(err.message);+ toast.error(err.message || t('app.serverRestorePoints.quicksaveFailed', 'Failed to create quicksave.'));+ } finally {+ setSaving(false);+ }+ }++ const quicksaveFooter = (+ <>+ <Button type="button" variant="outline" onClick={() => setShowQuicksave(false)} disabled={saving}>+ {t('common.actions.cancel', 'Cancel')}+ </Button>+ <Button type="submit" disabled={saving || !selectedAppId}>+ <Save size={14} />+ {saving+ ? t('app.serverRestorePoints.saving', 'Saving…')+ : t('app.serverRestorePoints.createQuicksave', 'Create quicksave')}+ </Button>+ </>+ );++ return (+ <section className="server-restore-points">+ <header className="server-restore-points__header">+ <div>+ <h2>{t('app.serverRestorePoints.title', 'Restore points')}</h2>+ <p>{t('app.serverRestorePoints.description', 'Review checkpoints, deployments, and server audit activity in one timeline.')}</p>+ </div>+ <div className="server-restore-points__actions">+ <Button+ variant="outline"+ size="sm"+ onClick={handleRefresh}+ >+ <RefreshCw size={14} /> {t('common.actions.refresh', 'Refresh')}+ </Button>+ <Button+ size="sm"+ onClick={openQuicksave}+ disabled={appsLoading || serverApps.length === 0}+ >+ <Save size={14} /> {t('app.serverRestorePoints.quicksave', 'Quicksave')}+ </Button>+ </div>+ </header>++ <div className="server-restore-points__scope-note">+ <Info size={17} />+ <p>{t('app.serverRestorePoints.scopeNote', 'Remote quicksave currently covers application environment variables stored by ServerKit. Secret values are masked and cannot be recovered. Shared variable groups and host-level cron, firewall, DNS, and Nginx are not included.')}</p>+ </div>++ {appsLoading && (+ <div className="server-restore-points__apps-status" role="status">+ {t('app.serverRestorePoints.loadingApplications', 'Loading applications for this server…')}+ </div>+ )}++ {appsError && (+ <div className="server-restore-points__apps-status alert alert-danger">+ <span>{appsError}</span>+ <Button variant="outline" size="sm" onClick={loadApps}>+ {t('common.actions.retry', 'Retry')}+ </Button>+ </div>+ )}++ {!appsLoading && !appsError && serverApps.length === 0 && (+ <div className="server-restore-points__apps-status server-restore-points__apps-status--empty">+ <Save size={16} />+ <div>+ <strong>{t('app.serverRestorePoints.noApplications', 'No applications are available for quicksave')}</strong>+ <span>{t('app.serverRestorePoints.noApplicationsDescription', 'The timeline remains available. Add or gain access to an application on this server to create an environment quicksave.')}</span>+ </div>+ </div>+ )}++ <DeploymentTimeline serverId={serverId} refreshKey={timelineRefreshKey} />++ {showQuicksave && (+ <Modal+ open+ onClose={() => setShowQuicksave(false)}+ title={t('app.serverRestorePoints.createEnvironmentQuicksave', 'Create environment quicksave')}+ onSubmit={handleQuicksave}+ footer={quicksaveFooter}+ >+ <div className="server-restore-points__form">+ <p className="server-restore-points__form-intro">+ {t('app.serverRestorePoints.formDescription', 'Choose one application on this server. Only its ServerKit-managed environment variables will be captured.')}+ </p>+ <FormField+ label={t('app.serverRestorePoints.application', 'Application')}+ htmlFor="restore-point-app"+ required+ >+ <select+ id="restore-point-app"+ value={selectedAppId}+ onChange={(event) => {+ setSelectedAppId(event.target.value);+ setSaveError(null);+ }}+ required+ >+ <option value="">{t('app.serverRestorePoints.selectApplication', 'Select an application')}</option>+ {serverApps.map((app) => (+ <option key={app.id} value={app.id}>{app.name}</option>+ ))}+ </select>+ </FormField>+ <FormField+ label={t('app.serverRestorePoints.label', 'Label (optional)')}+ htmlFor="restore-point-label"+ >+ <input+ id="restore-point-label"+ type="text"+ maxLength={255}+ value={label}+ onChange={(event) => setLabel(event.target.value)}+ placeholder={t('app.serverRestorePoints.labelPlaceholder', 'Before environment change')}+ />+ </FormField>+ {saveError && <div className="error-message" role="alert">{saveError}</div>}+ </div>+ </Modal>+ )}+ </section>+ );+}diff --git a/frontend/src/i18n/locales/en.json b/frontend/src/i18n/locales/en.jsonindex e0253ef6..a74d9b1c 100644--- a/frontend/src/i18n/locales/en.json+++ b/frontend/src/i18n/locales/en.json@@ -816,17 +816,47 @@"send": "Send"},"configDiffModal": {+ "applyRestorePoint": "Apply restore point","buildMethod": "Build method",+ "changesToApply": "Changes to apply","configurationDiff": "Configuration diff","configurationRestoredRedeployTriggered": "Configuration restored. Redeploy triggered.",+ "confirmRestore": "Confirm restore",+ "coverageAndLimits": "Coverage and limits",+ "coverageDescription": "Review what this checkpoint does not restore before continuing.",+ "currentRestorePreview": "Current restore preview",+ "currentRestorePreviewDescription": "These changes compare the current state with the selected restore point.",+ "diffUnavailable": "Diff unavailable","environmentVariables": "Environment variables",+ "firstRestorePoint": "This is the first restore point in this scope.",+ "historicalDiff": "Historical diff",+ "historicalDiffDescription": "These changes compare this restore point with the checkpoint captured before it.",+ "historicalDiffUnavailable": "The comparison with the previous checkpoint could not be loaded.","imageTag": "Image / tag","inPlainLanguage": "In plain language","loadingDiff": "Loading diff…",- "noChange": "No change (",+ "noChangeValue": "No change ({{value}})","noChanges": "No changes",+ "noConfigurationChanges": "No configuration changes compared with this checkpoint.",+ "noCoverageGaps": "The checkpoint reported nothing outside its coverage.",+ "notSet": "Not set",+ "previewUnavailable": "Restore preview unavailable",+ "readyToRestore": "Ready to restore",+ "restoreBlocked": "Restore blocked",+ "restoreConfiguration": "Restore this configuration?",+ "restoreConfigurationConfirmation": "This configuration will be restored and a redeploy will start.","restoreFailed": "Restore failed",+ "restorePointConfirmation": "ServerKit will capture the current managed state first, then apply the recoverable values from this restore point.",+ "restorePointPreview": "Restore point preview",+ "restorePointRestored": "Restore point applied successfully.",+ "restoreRefusals": "Restore blockers",+ "restoreRestorePoint": "Restore this restore point?","restoreThisConfig": "Restore this config",+ "restoring": "Restoring…",+ "savedChanges": "Saved changes",+ "savedCheckpoint": "Saved checkpoint",+ "unlabelledRestorePoint": "Unlabelled restore point",+ "value": "Value","volumes": "Volumes"},"configTunerPanel": {@@ -1572,10 +1602,27 @@"troubleReachingTheDeploymentJob": "Trouble reaching the deployment job:"},"deploymentTimeline": {+ "audit": "Audit",+ "auditEvent": "Audit event",+ "byActor": "by {{actor}}","configChanged": "Config changed",- "envVar": "env var",+ "coverageLimitCount": "{{count}} coverage limits",+ "deployment": "Deployment",+ "deploymentCheckpoint": "Deployment checkpoint",+ "deploymentCheckpointFor": "Deployment checkpoint for {{name}}",+ "deployments": "Deployments",+ "envVarCount": "{{count}} env vars",+ "environmentRestorePoint": "Environment restore point",+ "eventCount": "{{count}} events","loadingDeploymentTimeline": "Loading deployment timeline…",+ "loadingServerTimeline": "Loading server timeline","noConfigCheckpointsYetOneIs": "No config checkpoints yet. One is captured before each deployment.",+ "noFilteredEvents": "No events match this timeline filter.",+ "noServerEvents": "No timeline events yet",+ "noServerEventsDescription": "Quicksaves, deployments, and server audit activity will appear here.",+ "previewRestore": "Preview restore",+ "restorePoint": "Restore point",+ "restorePoints": "Restore points","viewDiff": "View diff"},"deployments": {@@ -4806,6 +4853,7 @@"proxy": "Proxy","remoteAccess": "Remote Access","removeServer": "Remove Server",+ "restorePoints": "Restore Points","serverDidNotRespond": "Server did not respond","serverNotFound": "Server Not Found","serverRemovedSuccessfully": "Server removed successfully",@@ -4915,6 +4963,26 @@"findAServer": "Find a server…","noServersMatch": "No servers match."},+ "serverRestorePoints": {+ "application": "Application",+ "chooseApplication": "Choose an application to quicksave.",+ "createEnvironmentQuicksave": "Create environment quicksave",+ "createQuicksave": "Create quicksave",+ "description": "Review checkpoints, deployments, and server audit activity in one timeline.",+ "formDescription": "Choose one application on this server. Only its ServerKit-managed environment variables will be captured.",+ "label": "Label (optional)",+ "labelPlaceholder": "Before environment change",+ "loadingApplications": "Loading applications for this server…",+ "noApplications": "No applications are available for quicksave",+ "noApplicationsDescription": "The timeline remains available. Add or gain access to an application on this server to create an environment quicksave.",+ "quicksave": "Quicksave",+ "quicksaveCreated": "Environment quicksave created.",+ "quicksaveFailed": "Failed to create quicksave.",+ "saving": "Saving…",+ "scopeNote": "Remote quicksave currently covers application environment variables stored by ServerKit. Secret values are masked and cannot be recovered. Shared variable groups and host-level cron, firewall, DNS, and Nginx are not included.",+ "selectApplication": "Select an application",+ "title": "Restore points"+ },"serverScopePicker": {"chooseWhichServerToMonitor": "Choose which server to monitor","theMachineRunningThePanel": "The machine running the panel",@@ -7070,6 +7138,7 @@"download": "Download","edit": "Edit","enable": "Enable",+ "loadMore": "Load more","logOut": "Log out","open": "Open","refresh": "Refresh",diff --git a/frontend/src/pages/ServerDetail.jsx b/frontend/src/pages/ServerDetail.jsxindex bb9bd9b7..ef8c230f 100644--- a/frontend/src/pages/ServerDetail.jsx+++ b/frontend/src/pages/ServerDetail.jsx@@ -29,6 +29,8 @@ import RemoteAccess from '../pages/RemoteAccess';import EmptyState from '../components/EmptyState';import { usePolling } from '@/hooks/usePolling';import { useTranslation } from 'react-i18next';+import { useAuth } from '../contexts/AuthContext';+import ServerRestorePointsTab from '../components/serverdetail/ServerRestorePointsTab';// Live host metrics cadence while the server is online.const METRICS_POLL_MS = 10000;@@ -37,6 +39,7 @@ const ServerDetail = () => {const { t } = useTranslation();const { id, tab } = useParams();const navigate = useNavigate();+ const { isDeveloper } = useAuth();const { confirm } = useConfirm();const [server, setServer] = useState(null);useRecordVisit(server && {@@ -50,7 +53,21 @@ const ServerDetail = () => {const [securityAlerts, setSecurityAlerts] = useState([]);const toast = useToast();- const validTabs = ['overview', 'docker', 'proxy', 'cron', 'cloudflared', 'packages', 'services', 'survey', 'metrics', 'alerts', 'remote-access', 'settings'];+ const validTabs = [+ 'overview',+ ...(isDeveloper ? ['restore-points'] : []),+ 'docker',+ 'proxy',+ 'cron',+ 'cloudflared',+ 'packages',+ 'services',+ 'survey',+ 'metrics',+ 'alerts',+ 'remote-access',+ 'settings',+ ];const activeTab = validTabs.includes(tab) ? tab : 'overview';const loadServer = useCallback(async () => {@@ -90,6 +107,12 @@ const ServerDetail = () => {loadServer();}, [loadServer]);+ useEffect(() => {+ if (tab === 'restore-points' && !isDeveloper) {+ navigate(`/servers/${id}`, { replace: true });+ }+ }, [id, isDeveloper, navigate, tab]);+const loadSecurityAlerts = useCallback(async () => {try {const data = await api.getServerSecurityAlerts(id, { status: 'open', limit: 25 });@@ -230,20 +253,21 @@ const ServerDetail = () => {// hiding the tab matches the rest of the panel's "don't expose what// the host can't do" behaviour.const tabs = [- { id: 'overview', labelKey: 'common.labels.overview', label: 'Overview' },- { id: 'docker', labelKey: 'common.labels.docker', label: 'Docker' },- { id: 'proxy', labelKey: 'app.serverDetail.proxy', label: 'Proxy' },- ...(server.capabilities?.cron ? [{ id: 'cron', labelKey: 'app.serverDetail.cron', label: 'Cron' }] : []),- ...(server.capabilities?.cloudflared ? [{ id: 'cloudflared', labelKey: 'app.serverDetail.tunnels', label: 'Tunnels' }] : []),- ...(server.capabilities?.packages ? [{ id: 'packages', labelKey: 'app.serverDetail.packages', label: 'Packages' }] : []),- ...(server.capabilities?.systemd ? [{ id: 'services', labelKey: 'common.labels.services', label: 'Services' }] : []),- ...(server.capabilities?.survey ? [{ id: 'survey', labelKey: 'app.serverDetail.survey', label: 'Survey' }] : []),- { id: 'metrics', labelKey: 'app.serverDetail.metrics', label: 'Metrics' },+ { id: 'overview', label: t('common.labels.overview', 'Overview') },+ ...(isDeveloper ? [{ id: 'restore-points', label: t('app.serverDetail.restorePoints', 'Restore Points') }] : []),+ { id: 'docker', label: t('common.labels.docker', 'Docker') },+ { id: 'proxy', label: t('app.serverDetail.proxy', 'Proxy') },+ ...(server.capabilities?.cron ? [{ id: 'cron', label: t('app.serverDetail.cron', 'Cron') }] : []),+ ...(server.capabilities?.cloudflared ? [{ id: 'cloudflared', label: t('app.serverDetail.tunnels', 'Tunnels') }] : []),+ ...(server.capabilities?.packages ? [{ id: 'packages', label: t('app.serverDetail.packages', 'Packages') }] : []),+ ...(server.capabilities?.systemd ? [{ id: 'services', label: t('common.labels.services', 'Services') }] : []),+ ...(server.capabilities?.survey ? [{ id: 'survey', label: t('app.serverDetail.survey', 'Survey') }] : []),+ { id: 'metrics', label: t('app.serverDetail.metrics', 'Metrics') },...(totalAlertCount > 0- ? [{ id: 'alerts', labelKey: 'app.serverDetail.alerts', label: 'Alerts', badge: totalAlertCount }]- : [{ id: 'alerts', labelKey: 'app.serverDetail.alerts', label: 'Alerts' }]),- ...(server.capabilities?.wireguard ? [{ id: 'remote-access', labelKey: 'app.serverDetail.remoteAccess', label: 'Remote Access' }] : []),- { id: 'settings', labelKey: 'common.labels.settings', label: 'Settings' }+ ? [{ id: 'alerts', label: t('app.serverDetail.alerts', 'Alerts'), badge: totalAlertCount }]+ : [{ id: 'alerts', label: t('app.serverDetail.alerts', 'Alerts') }]),+ ...(server.capabilities?.wireguard ? [{ id: 'remote-access', label: t('app.serverDetail.remoteAccess', 'Remote Access') }] : []),+ { id: 'settings', label: t('common.labels.settings', 'Settings') }];return (@@ -323,10 +347,10 @@ const ServerDetail = () => {}><TabsList>- {tabs.map(t => (- <TabsTrigger key={t.id} value={t.id}>- {t.label}- {t.badge ? <span className="tab-badge">{t.badge}</span> : null}+ {tabs.map((item) => (+ <TabsTrigger key={item.id} value={item.id}>+ {item.label}+ {item.badge ? <span className="tab-badge">{item.badge}</span> : null}</TabsTrigger>))}</TabsList>@@ -340,6 +364,11 @@ const ServerDetail = () => {onRefreshServer={loadServer}/></TabsContent>+ {isDeveloper && (+ <TabsContent value="restore-points">+ <ServerRestorePointsTab serverId={id} />+ </TabsContent>+ )}<TabsContent value="docker"><ServerDockerTab serverId={id} serverStatus={server.status} server={server} /></TabsContent>diff --git a/frontend/src/services/api/index.js b/frontend/src/services/api/index.jsindex bbb2e272..b56f84e7 100644--- a/frontend/src/services/api/index.js+++ b/frontend/src/services/api/index.js@@ -54,6 +54,7 @@ import * as errorLogMethods from './errorLogs.js';import * as walkthroughMethods from './walkthroughs.js';import * as diskMethods from './disk.js';import * as recipeMethods from './recipes.js';+import * as restorePointMethods from './restorePoints.js';class ApiService extends ApiClient {constructor() {@@ -115,6 +116,7 @@ class ApiService extends ApiClient {walkthroughMethods,diskMethods,recipeMethods,+ restorePointMethods,];for (const mod of modules) {for (const [key, fn] of Object.entries(mod)) {diff --git a/frontend/src/services/api/restorePoints.js b/frontend/src/services/api/restorePoints.jsnew file mode 100644index 00000000..9d0ed8f2--- /dev/null+++ b/frontend/src/services/api/restorePoints.js@@ -0,0 +1,38 @@+// Generic restore points and the merged per-server activity timeline.++export async function getServerTimeline(serverId, {+ types = [],+ before = null,+ limit = 50,+} = {}) {+ const params = new URLSearchParams({ limit: String(limit) });+ if (types.length) params.set('types', types.join(','));+ if (before) params.set('before', before);+ return this.request(`/servers/${serverId}/timeline?${params.toString()}`);+}++export async function createRestorePoint({ scopeType, scopeId, label = null }) {+ const body = {+ scope_type: scopeType,+ scope_id: String(scopeId),+ };+ if (label) body.label = label;+ return this.request('/restore-points', { method: 'POST', body });+}++export async function getRestorePoint(pointId) {+ return this.request(`/restore-points/${pointId}`);+}++export async function getRestorePointDiff(pointId, against = 'previous') {+ const query = against ? `?against=${encodeURIComponent(against)}` : '';+ return this.request(`/restore-points/${pointId}/diff${query}`);+}++export async function previewRestorePoint(pointId) {+ return this.request(`/restore-points/${pointId}/preview`, { method: 'POST' });+}++export async function restoreRestorePoint(pointId) {+ return this.request(`/restore-points/${pointId}/restore`, { method: 'POST' });+}diff --git a/frontend/src/styles/components/_deployments.scss b/frontend/src/styles/components/_deployments.scssindex 283fa70f..e2fe5648 100644--- a/frontend/src/styles/components/_deployments.scss+++ b/frontend/src/styles/components/_deployments.scss@@ -40,13 +40,13 @@// The vertical spine that connects markers.&__item {position: relative;- padding-left: $space-8;+ padding-inline-start: $space-8;padding-bottom: $space-4;&::before {content: '';position: absolute;- left: 7px;+ inset-inline-start: 7px;top: 0;bottom: 0;width: 2px;@@ -61,7 +61,7 @@&__marker {position: absolute;- left: 0;+ inset-inline-start: 0;top: 4px;width: 16px;height: 16px;@@ -134,6 +134,194 @@color: $text-secondary;font-size: 0.8125rem;}++ &--server {+ gap: $space-5;++ .sk-listhead {+ margin: 0;+ }++ .deploy-timeline__item {+ padding-inline-start: 44px;++ &::before {+ inset-inline-start: 13px;+ }+ }++ .deploy-timeline__marker {+ inset-inline-start: 0;+ width: 28px;+ height: 28px;+ display: inline-flex;+ align-items: center;+ justify-content: center;+ color: $text-secondary;+ background: $bg-elevated;++ &--restore_point {+ color: $violet;+ border-color: $violet;+ background: $violet-bg;+ }++ &--deployment_snapshot {+ color: $cyan;+ border-color: $cyan;+ background: $cyan-bg;+ }++ &--audit {+ color: $text-secondary;+ border-color: $border-active;+ }+ }+ }++ &__count {+ color: $text-tertiary;+ font-family: $font-mono;+ font-size: $font-size-sm;+ white-space: nowrap;+ }++ &__event-heading {+ display: flex;+ align-items: baseline;+ gap: $space-2;+ flex-wrap: wrap;++ h3 {+ margin: 0;+ color: $text-primary;+ font-size: $font-size-base;+ font-weight: $font-weight-semibold;+ }++ span {+ color: $text-tertiary;+ font-size: $font-size-sm;+ }+ }++ &__coverage-note {+ margin: 0;+ color: $warning;+ font-size: $font-size-sm;+ }++ &__error,+ &__footer {+ display: flex;+ align-items: center;+ justify-content: center;+ gap: $space-3;+ }+}++// -------------------------------------------------------- Server restore tab+.server-restore-points {+ display: flex;+ flex-direction: column;+ gap: $space-5;++ &__header {+ display: flex;+ align-items: flex-start;+ justify-content: space-between;+ gap: $space-4;++ h2 {+ margin: 0;+ color: $text-primary;+ font-size: $font-size-xl;+ }++ p {+ margin: $space-1 0 0;+ color: $text-secondary;+ max-width: 70ch;+ }+ }++ &__actions {+ display: flex;+ gap: $space-2;+ flex-shrink: 0;+ }++ &__scope-note {+ display: flex;+ align-items: flex-start;+ gap: $space-3;+ padding: $space-3 $space-4;+ @include status-variant($info, $info-bg, $info-border);+ border: 1px solid $info-border;+ border-radius: $radius-lg;++ svg {+ flex-shrink: 0;+ margin-block-start: 2px;+ }++ p {+ margin: 0;+ color: $text-secondary;+ line-height: $line-height-normal;+ }+ }++ &__apps-status {+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: $space-3;+ color: $text-secondary;+ font-size: $font-size-sm;++ &--empty {+ justify-content: flex-start;+ align-items: flex-start;+ padding: $space-3 $space-4;+ background: $bg-elevated;+ border: 1px solid $border-subtle;+ border-radius: $radius-lg;++ > svg {+ flex-shrink: 0;+ margin-block-start: 2px;+ color: $text-tertiary;+ }++ div {+ display: flex;+ flex-direction: column;+ gap: $space-1;+ }++ strong {+ color: $text-primary;+ font-weight: $font-weight-semibold;+ }++ span {+ color: $text-secondary;+ }+ }+ }++ &__form {+ display: flex;+ flex-direction: column;+ gap: $space-4;+ }++ &__form-intro {+ margin: 0;+ color: $text-secondary;+ line-height: $line-height-normal;+ }}// ---------------------------------------------------------------- Timeline card@@ -241,6 +429,7 @@border-radius: $radius-sm;font-family: $font-mono;font-size: 0.8125rem;+ min-width: 0;&--add {@include status-variant($success, $success-bg);@@ -262,6 +451,19 @@text-align: center;}+ &__path {+ flex-shrink: 0;+ font-weight: $font-weight-semibold;+ }++ &__value {+ margin-inline-start: auto;+ min-width: 0;+ color: $text-secondary;+ overflow-wrap: anywhere;+ text-align: end;+ }+&__scalar {display: flex;align-items: center;@@ -289,4 +491,138 @@color: $text-secondary;font-size: 0.875rem;}++ &__point-meta {+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: $space-3;+ padding-block-end: $space-3;+ border-bottom: 1px solid $border-subtle;+ }++ &__group {+ display: flex;+ flex-direction: column;+ gap: $space-3;+ }++ &__group-heading,+ &__coverage-heading {+ h3 {+ margin: 0;+ color: $text-primary;+ font-size: $font-size-base;+ }++ p {+ margin: $space-1 0 0;+ color: $text-secondary;+ font-size: $font-size-sm;+ line-height: $line-height-normal;+ }+ }++ &__coverage {+ display: flex;+ flex-direction: column;+ gap: $space-3;+ padding: $space-4;+ background: $warning-bg;+ border: 1px solid $warning-border;+ border-radius: $radius-lg;++ > ul {+ margin: 0;+ padding-inline-start: $space-5;+ color: $text-secondary;+ font-size: $font-size-sm;+ }+ }++ &__coverage-heading {+ display: flex;+ align-items: flex-start;+ gap: $space-2;++ > svg {+ flex-shrink: 0;+ margin-block-start: 1px;+ color: $warning;+ }+ }++ &__refusals {+ display: flex;+ align-items: flex-start;+ gap: $space-2;+ padding: $space-4;+ background: $danger-bg;+ border: 1px solid $danger-border;+ border-radius: $radius-lg;+ color: $danger;++ > svg {+ flex-shrink: 0;+ margin-block-start: 1px;+ }++ h3 {+ margin: 0 0 $space-2;+ color: $text-primary;+ font-size: $font-size-base;+ }++ ul {+ margin: 0;+ padding-inline-start: $space-5;+ color: $text-secondary;+ font-size: $font-size-sm;+ }+ }+}++@media (max-width: $breakpoint-md) {+ .server-restore-points {+ &__header {+ flex-direction: column;+ }++ &__actions {+ width: 100%;++ .btn {+ flex: 1;+ }+ }+ }++ .deploy-timeline--server {+ .sk-listhead {+ align-items: stretch;+ }++ .sk-seg {+ width: 100%;+ overflow-x: auto;+ }+ }++ .config-diff {+ &__point-meta {+ align-items: flex-start;+ flex-direction: column;+ }++ &__line {+ align-items: flex-start;+ flex-wrap: wrap;+ }++ &__value {+ width: 100%;+ margin-inline-start: 20px;+ text-align: start;+ }+ }}