feat: add managed database capture and operator restore

PostgreSQL and MySQL backups run through paired outposts, with operator sign-in, off-site copies, and legacy import. Retention stays on each orbit, so the unused retention console is removed.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-10 23:26:49 +07:00
parent 30a1a9b8f0
commit 6320b6f244
96 changed files with 11061 additions and 725 deletions

View File

@@ -1,34 +1,62 @@
import { AnimatePresence, motion } from "motion/react";
import type { KeyboardEvent, ReactNode } from "react";
import { AnimatePresence, motion, useMotionValue, useSpring, useTransform, type MotionValue } from "motion/react";
import { useLayoutEffect, useRef, type KeyboardEvent, type ReactNode } from "react";
import type { Orbit, Snapshot } from "../../api";
import { useScreenTransition } from "../../hooks/useScreenTransition";
import { gentleSpring } from "../../lib/motion";
import { useReducedMotion } from "../../hooks/useReducedMotion";
import { formatBytes, formatWhen, orbitStatus, schedulePhrase } from "../../lib/format";
import { SpringPane } from "../ui/SpringPane";
function TelemetryValue({ value, bytes = false }: { value?: number; bytes?: boolean }) {
const reducedMotion = useReducedMotion();
const target = useMotionValue(value ?? 0);
const count = useSpring(target, gentleSpring);
const text = useTransform(count, number => bytes ? formatBytes(Math.max(0, number)) : String(Math.round(number)));
useLayoutEffect(() => {
if (reducedMotion || value === undefined) count.jump(value ?? 0);
target.set(value ?? 0);
}, [value, reducedMotion, target, count]);
if (value === undefined) return "—";
return (
<>
<span className="sr-only">{bytes ? formatBytes(value) : value}</span>
<motion.span aria-hidden="true">{text}</motion.span>
</>
);
}
export function TelemetryStrip({
orbitCount, failedCount, snapCount, totalBytes,
orbitCount, failedCount, snapCount, totalBytes, bigScreen, reducedMotion,
}: {
orbitCount?: number;
failedCount: number;
snapCount?: number;
totalBytes: number;
bigScreen: boolean;
reducedMotion: boolean;
}) {
const strip = useRef<HTMLDListElement>(null);
useScreenTransition(strip, bigScreen, reducedMotion, undefined, true);
return (
<dl className="vault-telemetry">
<div><dt>Orbits</dt><dd>{orbitCount ?? "—"}</dd></div>
<div><dt>Failed</dt><dd className={failedCount ? "telemetry-alert" : ""}>{orbitCount === undefined ? "—" : failedCount}</dd></div>
<div><dt>Snapshots</dt><dd>{snapCount ?? "—"}</dd></div>
<div><dt>Payload</dt><dd>{snapCount === undefined ? "—" : formatBytes(totalBytes)}</dd></div>
<dl ref={strip} className="vault-telemetry">
<div><dt>Orbits</dt><dd><TelemetryValue value={orbitCount} /></dd></div>
<div><dt>Failed</dt><dd className={failedCount ? "telemetry-alert" : ""}>
<TelemetryValue value={orbitCount === undefined ? undefined : failedCount} />
</dd></div>
<div><dt>Snapshots</dt><dd><TelemetryValue value={snapCount} /></dd></div>
<div><dt>Payload</dt><dd><TelemetryValue value={snapCount === undefined ? undefined : totalBytes} bytes /></dd></div>
</dl>
);
}
export function OrbitRegister({
orbits, selected, message, onSelect, onManage,
orbits, selected, message, bigScreen, onSelect, onManage,
}: {
orbits: Orbit[];
selected?: string;
message?: string;
bigScreen: boolean;
onSelect: (id: string) => void;
onManage: () => void;
}) {
@@ -45,7 +73,8 @@ export function OrbitRegister({
}
return (
<section className="vault-console orbit-register" aria-labelledby="register-title">
<motion.section className="vault-console orbit-register" aria-labelledby="register-title" inert={bigScreen}
initial={false} animate={{ opacity: bigScreen ? 0 : 1 }}>
<header className="console-heading">
<p className="instrument-label">Flight register</p>
<h2 id="register-title">Orbits</h2>
@@ -56,13 +85,14 @@ export function OrbitRegister({
const status = orbitStatus(orbit.last_status);
return (
<motion.li key={orbit.id} layout={reducedMotion ? false : "position"}>
<button
<motion.button
type="button"
id={`register-${orbit.id}`}
className="register-row"
aria-pressed={selected === orbit.id}
tabIndex={active === orbit.id ? 0 : -1}
onClick={() => onSelect(orbit.id)}
whileHover={{ backgroundColor: selected === orbit.id ? "#28252b" : "#1b1e23" }}
onKeyDown={(event) => moveFocus(event, index)}
>
<span className={`register-signal signal-${status.tone}`} aria-hidden="true" />
@@ -71,7 +101,7 @@ export function OrbitRegister({
<small>{orbit.provider}</small>
</span>
<span className={`register-state tone-${status.tone}`}>{status.label}</span>
</button>
</motion.button>
</motion.li>
);
})}
@@ -81,22 +111,26 @@ export function OrbitRegister({
{orbits.length ? "Manage orbits" : "Set up an orbit"} <span aria-hidden="true">↗</span>
</button>
</div>
</section>
</motion.section>
);
}
export function OrbitInspector({
orbit, snapshots, snapshotMessage, capture, onSelectSnapshot,
orbit, snapshots, snapshotMessage, capture, highlightedId, captureGlow, bigScreen, onSelectSnapshot,
}: {
orbit?: Orbit;
snapshots: Snapshot[];
snapshotMessage?: string;
capture?: ReactNode;
highlightedId?: string;
captureGlow: MotionValue<number>;
bigScreen: boolean;
onSelectSnapshot: (id: string) => void;
}) {
const status = orbitStatus(orbit?.last_status ?? "idle");
return (
<section className="vault-console orbit-inspector" aria-labelledby="inspector-title">
<motion.section className="vault-console orbit-inspector" aria-labelledby="inspector-title" inert={bigScreen}
initial={false} animate={{ opacity: bigScreen ? 0 : 1 }}>
<header className="console-heading">
<p className="instrument-label">Orbit detail</p>
<h2 id="inspector-title">{orbit?.name ?? "Select an orbit"}</h2>
@@ -106,7 +140,7 @@ export function OrbitInspector({
<AnimatePresence initial={false}>
{orbit ? (
<SpringPane key={orbit.id}>
<p className="inspector-schedule">{schedulePhrase(orbit.schedule, orbit.dry_run)}</p>
<p className="inspector-schedule">{schedulePhrase(orbit)}</p>
<div className="inspector-capture">{capture}</div>
<section className="inspector-history" aria-label="Snapshot history">
<header>
@@ -118,6 +152,9 @@ export function OrbitInspector({
{snapshots.map((snapshot, index) => (
<li key={snapshot.id}>
<button id={`snapshot-${snapshot.id}`} type="button" className="snapshot-row" onClick={() => onSelectSnapshot(snapshot.id)}>
{snapshot.id === highlightedId && (
<motion.span className="snapshot-row-flash" aria-hidden="true" style={{ opacity: captureGlow }} />
)}
<span className="snapshot-glyph" aria-hidden="true">◇</span>
<span>
<strong>{formatWhen(snapshot.taken_at)}</strong>
@@ -137,6 +174,6 @@ export function OrbitInspector({
)}
</AnimatePresence>
</div>
</section>
</motion.section>
);
}