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

@@ -6,6 +6,8 @@ import { formatBytes, formatWhen } from "../../lib/format";
import { Button } from "../ui/Button";
import { Hint } from "../ui/EmptyState";
import { TelemetryPanel } from "../ui/Telemetry";
import { Segmented } from "../ui/Segmented";
import { Select } from "../ui/Select";
const GRACE = 12;
@@ -74,157 +76,127 @@ export function ReconstituteWizard({
};
}, [sessionId, onPoll]);
const radius = 52;
const circumference = 2 * Math.PI * radius;
const progress = Math.max(0, Math.min(1, remaining / GRACE));
return (
<div className="space-y-4">
<p className="text-sm text-star-300">
Choose a recovery point and a destination.
</p>
{snap && (
<div className="rounded-xl border border-space-700 bg-space-800/50 p-3 text-sm">
<p className="text-star-100 font-medium">{snap.orbit_name}</p>
<p className="text-star-400 text-xs mt-1">{formatWhen(snap.taken_at)} · {formatBytes(snap.size_bytes)}</p>
</div>
)}
<label className="block text-sm">
<span className="text-star-400">Snapshot</span>
<select
className="mt-1 w-full rounded-xl bg-space-950 border border-space-700 px-3 py-2.5"
value={snapId}
onChange={(e) => { setSnapId(e.target.value); setDatabaseMode(true); }}
disabled={busy}
>
{snapshots.map((s) => (
<option key={s.id} value={s.id}>
{s.orbit_name} · {formatWhen(s.taken_at)} · {formatBytes(s.size_bytes)}
</option>
))}
</select>
</label>
{managed && (
<div className="flex flex-wrap gap-2" aria-label="Recovery destination" role="group">
<Button type="button" aria-pressed={databaseMode} disabled={busy}
variant={databaseMode ? "primary" : "ghost"} onClick={() => setDatabaseMode(true)}>
Restore to database
</Button>
<Button type="button" aria-pressed={!databaseMode} disabled={busy}
variant={databaseMode ? "ghost" : "primary"} onClick={() => setDatabaseMode(false)}>
Export file on hub
</Button>
</div>
)}
{managed && databaseMode ? (
<DatabaseRestore key={snapId} snapshot={snapId} application={managed.application_id}
engine={managed.engine} />
) : <>
<label className="block text-sm">
<span className="text-star-400">{scopedExport ? "Export filename on hub" : "Export file path on hub"}</span>
<input
className="mt-1 w-full rounded-xl bg-space-950 border border-space-700 px-3 py-2.5 font-mono text-xs"
value={target}
onChange={(e) => setTarget(e.target.value)}
disabled={busy}
/>
</label>
{inCountdown && (
<motion.div
className="relative rounded-2xl border border-orbit-amber/40 bg-orbit-amber/10 p-6 text-center"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
>
<div className="relative mx-auto w-20 h-20">
<svg viewBox="0 0 36 36" className="w-full h-full -rotate-90">
<circle cx="18" cy="18" r="16" fill="none" stroke="#1e2647" strokeWidth="3" />
<motion.circle
cx="18"
cy="18"
r="16"
fill="none"
stroke="#f0c468"
strokeWidth="3"
initial={false}
animate={{ pathLength: Math.max(0, Math.min(1, remaining / GRACE)) }}
/>
</svg>
<span className="absolute inset-0 flex items-center justify-center text-2xl font-semibold text-orbit-amber">
{remaining}
</span>
<div className="restore-layout">
<div className="restore-top">
<p className="restore-lead">Choose a recovery point and a destination.</p>
{snap && (
<div className="restore-snap">
<span className="restore-snap-glyph" aria-hidden="true">◇</span>
<div className="min-w-0">
<p className="restore-snap-name">{snap.orbit_name}</p>
<p className="restore-snap-meta">{formatWhen(snap.taken_at)} · {formatBytes(snap.size_bytes)} · {snap.id.slice(0, 8)}</p>
</div>
</div>
<p className="mt-3 text-orbit-amber text-sm font-medium">
Reconstituting in {remaining}s — abort restores nothing.
</p>
</motion.div>
)}
<div className="flex gap-2">
<Button
variant="danger"
className="flex-1"
disabled={!sessionId || !inCountdown || !!action}
onClick={async () => {
if (!sessionId) return;
setAction("aborting");
setError(undefined);
try {
await onAbort(sessionId);
} catch {
setAction(undefined);
setError("Could not cancel the file export. Check the current session status.");
}
}}
>
Abort
</Button>
<Button
variant="warn"
className="flex-1"
disabled={!snap || !target.trim() || busy}
onClick={async () => {
setAction("starting");
setError(undefined);
try {
const res = await onStart(snapId, target);
setSessionId(res.session_id);
setState(res.session.state);
setRemaining(res.session.seconds_remaining);
} catch {
setError("Could not confirm that the hub started writing to the destination.");
} finally {
setAction(undefined);
}
}}
>
Begin file export
</Button>
)}
<label className="block text-sm">
<span className="field-label">Snapshot</span>
<Select
value={snapId}
onChange={(e) => { setSnapId(e.target.value); setDatabaseMode(true); }}
disabled={busy}
>
{snapshots.map((s) => (
<option key={s.id} value={s.id}>
{s.orbit_name} · {formatWhen(s.taken_at)} · {formatBytes(s.size_bytes)}
</option>
))}
</Select>
</label>
{managed && (
<div>
<p className="field-label mb-1.5">Destination</p>
<Segmented label="Recovery destination" value={databaseMode ? "database" : "file"} disabled={busy}
onChange={(value) => setDatabaseMode(value === "database")}
options={[{ value: "database", label: "Restore to database" }, { value: "file", label: "Export file on hub" }]} />
</div>
)}
</div>
{error && <p role="alert" className="text-orbit-red text-sm">{error}</p>}
{reconnecting && <p role="status" className="text-orbit-amber text-sm">Reconnecting to the export session…</p>}
{state === "restoring" && <p role="status" className="text-orbit-amber text-sm">Exporting snapshot…</p>}
{state === "unavailable" && (
<p role="alert" className="text-orbit-red text-sm">The hub no longer has this export session. Check the destination before retrying.</p>
)}
{state === "completed" && (
<p className="text-orbit-green text-sm text-center">File export complete.</p>
)}
{state === "aborted" && (
<p className="text-star-300 text-sm text-center">File export cancelled.</p>
)}
{state === "failed" && (
<p className="text-orbit-red text-sm text-center">File export failed. Check telemetry.</p>
)}
<Hint>{scopedExport ? "The hub writes to its exports directory after the countdown." : "The hub writes after the countdown. An existing file at the destination may be overwritten."}</Hint>
{sessionId && (
<TelemetryPanel label="Session">
{JSON.stringify({ sessionId, state, remaining }, null, 2)}
</TelemetryPanel>
)}
{managed && databaseMode ? (
<DatabaseRestore key={snapId} snapshot={snapId} application={managed.application_id} engine={managed.engine} />
) : <>
<div className="restore-fields">
<label className="block text-sm">
<span className="field-label">{scopedExport ? "Export filename on hub" : "Export file path on hub"}</span>
<input className="field field-mono" value={target} onChange={(e) => setTarget(e.target.value)} disabled={busy} />
</label>
<Hint>{scopedExport ? "The hub writes to its exports directory after the countdown." : "The hub writes after the countdown. An existing file at the destination may be overwritten."}</Hint>
<div className="flex gap-2.5">
<Button
variant="danger"
className="flex-1"
disabled={!sessionId || !inCountdown || !!action}
onClick={async () => {
if (!sessionId) return;
setAction("aborting");
setError(undefined);
try {
await onAbort(sessionId);
} catch {
setAction(undefined);
setError("Could not cancel the file export. Check the current session status.");
}
}}
>
Abort
</Button>
<Button
variant="primary"
className="flex-1"
disabled={!snap || !target.trim() || busy}
onClick={async () => {
setAction("starting");
setError(undefined);
try {
const res = await onStart(snapId, target);
setSessionId(res.session_id);
setState(res.session.state);
setRemaining(res.session.seconds_remaining);
} catch {
setError("Could not confirm that the hub started writing to the destination.");
} finally {
setAction(undefined);
}
}}
>
Begin file export
</Button>
</div>
{error && <p role="alert" className="text-orbit-red text-sm">{error}</p>}
</div>
<aside className="restore-status">
<p className="restore-status-label">Countdown</p>
{inCountdown ? (
<motion.div className="restore-count" initial={{ opacity: 0 }} animate={{ opacity: 1 }}>
<div className="restore-ring">
<svg viewBox="0 0 120 120" width="132" height="132" aria-hidden="true">
<circle cx="60" cy="60" r={radius} fill="none" stroke="#2a2218" strokeWidth="5" />
<motion.circle cx="60" cy="60" r={radius} fill="none" stroke="#e8b57e" strokeWidth="5" strokeLinecap="round"
strokeDasharray={circumference} initial={false} animate={{ strokeDashoffset: circumference * (1 - progress) }} />
</svg>
<span className="restore-ring-text"><b>{remaining}</b><i>seconds</i></span>
</div>
<p className="restore-count-note">Reconstituting in {remaining}s.<br />Abort restores nothing.</p>
</motion.div>
) : <p className="restore-idle">No export is running. Begin an export to start the countdown.</p>}
{reconnecting && <p role="status" className="text-orbit-amber text-sm">Reconnecting to the export session…</p>}
{state === "restoring" && <p role="status" className="text-orbit-amber text-sm">Exporting snapshot…</p>}
{state === "unavailable" && (
<p role="alert" className="text-orbit-red text-sm">The hub no longer has this export session. Check the destination before retrying.</p>
)}
{state === "completed" && <p className="text-orbit-green text-sm">File export complete.</p>}
{state === "aborted" && <p className="text-star-300 text-sm">File export cancelled.</p>}
{state === "failed" && <p className="text-orbit-red text-sm">File export failed. Check telemetry.</p>}
{sessionId && (
<TelemetryPanel label="Session">
{JSON.stringify({ sessionId, state, remaining }, null, 2)}
</TelemetryPanel>
)}
</aside>
</>}
</div>
);