feat: restyle the web UI as a spaceship cockpit

The map is a canopy with a bezel, an inset window and a sill carrying a
Window | Radar view switch. Consoles open as centered screens; Orbits,
Outposts, Activity and the snapshot sheet follow one vocabulary of recessed
fields, bevelled keys and lamps that stay distinct by shape.

- Activity replaces the Restore tab with one log of backups and restores.
  Rows lead to a snapshot or an orbit; restores and exports start from the
  snapshot. The model is a pure function with tests.
- Restore opens from a snapshot as a two column screen: choose and confirm on
  the left, job progress or countdown on the right.
- Add Segmented and a themed Select (portal list, keyboard and form support).
- Add a spotlight-style search panel.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-14 12:23:31 +07:00
parent 34b2f346af
commit c74694cf1f
27 changed files with 1971 additions and 628 deletions

View File

@@ -5,16 +5,27 @@ import { formatBytes, formatWhen } from "../../lib/format";
import { Button } from "../ui/Button";
import { TelemetryPanel } from "../ui/Telemetry";
/** Moon spots along the little orbit in the hero, nearest the hole last. */
const moons = [[126, 36], [104, 20], [52, 89], [20, 62]] as const;
function signedBytes(delta: number) {
return `${delta < 0 ? "−" : "+"}${formatBytes(Math.abs(delta))}`;
}
export function SnapshotSheet({
snap,
siblings = [],
onReconstitute,
onDeleted,
}: {
snap: Snapshot;
/** Every snapshot of the same orbit, newest first, including this one. */
siblings?: Snapshot[];
onReconstitute: () => void;
onDeleted: () => void;
}) {
const [confirmDelete, setConfirmDelete] = useState(false);
const [copied, setCopied] = useState(false);
const qc = useQueryClient();
const deletion = useMutation({
mutationFn: () => deleteSnapshot(snap.id),
@@ -23,33 +34,97 @@ export function SnapshotSheet({
onDeleted();
},
});
const index = siblings.findIndex(({ id }) => id === snap.id);
const previous = index >= 0 ? siblings[index + 1] : undefined;
const shown = Math.min(siblings.length, moons.length);
const lit = Math.min(Math.max(index, 0), moons.length - 1);
const database = !!snap.capture?.restore_ready;
const taken = new Date(snap.taken_at);
async function copy() {
try {
await navigator.clipboard.writeText(snap.id);
setCopied(true);
window.setTimeout(() => setCopied(false), 1600);
} catch {
// Clipboard access can be blocked; the id stays selectable on the page.
}
}
return (
<div className="space-y-4">
<p className="text-sm text-star-300">
Recovery point for <strong className="text-star-100">{snap.orbit_name}</strong>.
</p>
<div className="rounded-xl bg-space-800/60 p-3 border border-space-700 text-sm">
<p className="text-star-400 text-xs">Captured</p>
<p className="text-star-100 mt-1">{formatWhen(snap.taken_at)}</p>
<p className="text-star-400 text-xs mt-3">Payload</p>
<p className="text-star-100">{formatBytes(snap.size_bytes)}</p>
</div>
<Button variant="warn" className="w-full" onClick={onReconstitute}>
{snap.capture?.restore_ready ? "Database recovery options" : "Export file on hub"}
</Button>
<a href={`/api/v1/snapshots/${snap.id}/download`} download
className="console-control block w-full text-center">Download snapshot</a>
{confirmDelete ? (
<div className="space-y-2 rounded-xl border border-orbit-red/40 p-3">
<p className="text-sm text-star-300">Remove this recovery point from the hub catalogue?</p>
{deletion.isError && <p role="alert" className="text-sm text-orbit-red">Snapshot could not be removed. It may be in use.</p>}
<div className="flex gap-2">
<Button disabled={deletion.isPending} onClick={() => setConfirmDelete(false)}>Cancel</Button>
<Button variant="warn" disabled={deletion.isPending} onClick={() => deletion.mutate()}>Confirm deletion</Button>
</div>
<div className="sheet">
<div className="sheet-hero">
<svg viewBox="0 0 150 110" width="150" height="110" role="img"
aria-label={index >= 0 ? `Snapshot ${index + 1} of ${siblings.length} on its orbit` : "Snapshot on its orbit"}>
<ellipse cx="75" cy="55" rx="64" ry="38" fill="none" stroke="#dfe4ef" strokeOpacity=".14" />
<circle cx="75" cy="55" r="7" fill="#000" stroke="#ffe5c8" strokeOpacity=".7" />
{moons.slice(0, Math.max(shown, 1)).map(([x, y], i) => (
<path key={i} d={`M${x} ${y - 4}l4 4-4 4-4-4z`} fill={i === lit ? "#f1bc9033" : "none"}
stroke={i === lit ? "#f1bc90" : "#dfe4ef"} strokeOpacity={i === lit ? 1 : Math.max(0.25, 0.6 - i * 0.12)} />
))}
</svg>
<div className="min-w-0">
<p className="field-label">Recovery point for</p>
<p className="sheet-name">{snap.orbit_name}</p>
{index === 0 && (
<p className="sheet-note"><span className="register-signal signal-green" aria-hidden="true" />Newest snapshot of this orbit</p>
)}
</div>
) : <Button className="w-full" onClick={() => setConfirmDelete(true)}>Delete snapshot</Button>}
<TelemetryPanel label="Snapshot ID">{snap.id}</TelemetryPanel>
</div>
<dl className="sheet-facts">
<div>
<dt>Captured</dt>
<dd>{formatWhen(snap.taken_at)}</dd>
<dd className="sheet-sub">{taken.toISOString().slice(0, 16).replace("T", " ")} UTC</dd>
</div>
<div>
<dt>Payload</dt>
<dd className="sheet-mono">{formatBytes(snap.size_bytes)}</dd>
{previous && <dd className="sheet-sub">{signedBytes(snap.size_bytes - previous.size_bytes)} vs previous</dd>}
</div>
<div>
<dt>Recovery</dt>
<dd>{database ? "Database ready" : "File export"}</dd>
{snap.capture && <dd className="sheet-sub">{snap.capture.engine} · {snap.capture.format}</dd>}
</div>
</dl>
<div className="gate-cmd">
<div className="gate-cmd-head">
<span>Snapshot ID</span>
<button type="button" className="gate-copy" onClick={() => void copy()}>{copied ? "COPIED" : "COPY"}</button>
</div>
<code className="sheet-id">{snap.id}</code>
</div>
<div className="sheet-actions">
<Button variant="primary" className="sheet-primary" onClick={onReconstitute}>
{database ? "Database recovery options" : "Export file on hub"}
<span aria-hidden="true">→</span>
</Button>
<a href={`/api/v1/snapshots/${snap.id}/download`} download className="console-control sheet-link">
Download snapshot
<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
<path d="M8 2v8M4.5 7 8 10.5 11.5 7M3 13.5h10" />
</svg>
</a>
{confirmDelete ? (
<div className="sheet-confirm" role="alertdialog" aria-label="Confirm deletion">
<p>Remove this recovery point from the hub catalogue? This cannot be undone.</p>
{deletion.isError && <p role="alert" className="text-orbit-red">Snapshot could not be removed. It may be in use.</p>}
<div className="flex gap-2.5">
<Button className="flex-1" disabled={deletion.isPending} onClick={() => setConfirmDelete(false)}>Cancel</Button>
<Button variant="danger" className="flex-1" disabled={deletion.isPending} onClick={() => deletion.mutate()}>
Confirm deletion
</Button>
</div>
</div>
) : (
<button type="button" className="sheet-delete" onClick={() => setConfirmDelete(true)}>Delete snapshot</button>
)}
</div>
<TelemetryPanel label="Snapshot record">{JSON.stringify(snap, null, 2)}</TelemetryPanel>
</div>
);
}