Initial Tessera backup vault (M0–M2)
Scaffold Rust workspace, React canvas, vault engine, hub API, providers, agent wormhole path, and Docker compose per SPEC.
This commit is contained in:
159
web/src/App.tsx
Normal file
159
web/src/App.tsx
Normal file
@@ -0,0 +1,159 @@
|
||||
import { useState } from "react";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { motion, AnimatePresence } from "motion/react";
|
||||
import {
|
||||
fetchOrbits,
|
||||
fetchSnapshots,
|
||||
runOrbit,
|
||||
startPairing,
|
||||
startReconstitute,
|
||||
abortReconstitute,
|
||||
pollReconstitute,
|
||||
} from "./api";
|
||||
import { VaultRing } from "./components/VaultRing";
|
||||
import { OrbitsPanel } from "./components/OrbitsPanel";
|
||||
import { ReconstituteWizard } from "./components/ReconstituteWizard";
|
||||
|
||||
type Sheet = "none" | "snapshot" | "reconstitute" | "wormhole";
|
||||
|
||||
export default function App() {
|
||||
const [sheet, setSheet] = useState<Sheet>("none");
|
||||
const [selectedSnap, setSelectedSnap] = useState<string | null>(null);
|
||||
const [pairing, setPairing] = useState<{ code: string; expires_at: string } | null>(null);
|
||||
|
||||
const snaps = useQuery({ queryKey: ["snapshots"], queryFn: fetchSnapshots, refetchInterval: 8000 });
|
||||
const orbits = useQuery({ queryKey: ["orbits"], queryFn: fetchOrbits, refetchInterval: 8000 });
|
||||
|
||||
const statusColor =
|
||||
orbits.data?.some((o) => o.last_status === "failed")
|
||||
? "bg-orbit-red"
|
||||
: orbits.data?.some((o) => o.last_status === "running" || o.last_status === "rehearsed")
|
||||
? "bg-orbit-amber"
|
||||
: "bg-orbit-green";
|
||||
|
||||
return (
|
||||
<div className="h-[100dvh] flex flex-col bg-space-950 text-star-100 overflow-hidden">
|
||||
<header className="shrink-0 px-4 py-3 flex items-center justify-between border-b border-space-800">
|
||||
<div>
|
||||
<h1 className="text-lg font-semibold tracking-wide">Tessera Vault</h1>
|
||||
<p className="text-xs text-star-300">Only stardust that changed</p>
|
||||
</div>
|
||||
<span className={`w-3 h-3 rounded-full ${statusColor}`} title="vault status" />
|
||||
</header>
|
||||
|
||||
<main className="flex-1 min-h-0 relative">
|
||||
<VaultRing
|
||||
snapshots={snaps.data ?? []}
|
||||
onSelect={(id) => {
|
||||
setSelectedSnap(id);
|
||||
setSheet("snapshot");
|
||||
}}
|
||||
/>
|
||||
<nav className="absolute bottom-4 inset-x-0 flex justify-center gap-2 px-4">
|
||||
<TabButton onClick={() => setSheet("none")}>Vault</TabButton>
|
||||
<TabButton onClick={() => setSheet("reconstitute")}>Reconstitute</TabButton>
|
||||
<TabButton
|
||||
onClick={async () => {
|
||||
setPairing(await startPairing());
|
||||
setSheet("wormhole");
|
||||
}}
|
||||
>
|
||||
Wormhole
|
||||
</TabButton>
|
||||
</nav>
|
||||
</main>
|
||||
|
||||
<AnimatePresence>
|
||||
{sheet !== "none" && (
|
||||
<motion.aside
|
||||
className="absolute inset-x-0 bottom-0 top-12 bg-space-900/95 border-t border-space-800 rounded-t-2xl p-4 overflow-y-auto max-h-[70dvh]"
|
||||
initial={{ y: "100%" }}
|
||||
animate={{ y: 0 }}
|
||||
exit={{ y: "100%" }}
|
||||
transition={{ type: "spring", damping: 24 }}
|
||||
>
|
||||
{sheet === "snapshot" && selectedSnap && (
|
||||
<SnapshotDetail
|
||||
id={selectedSnap}
|
||||
snaps={snaps.data ?? []}
|
||||
onClose={() => setSheet("none")}
|
||||
onReconstitute={() => setSheet("reconstitute")}
|
||||
/>
|
||||
)}
|
||||
{sheet === "reconstitute" && (
|
||||
<ReconstituteWizard
|
||||
snapshots={snaps.data ?? []}
|
||||
selected={selectedSnap}
|
||||
onAbort={abortReconstitute}
|
||||
onStart={startReconstitute}
|
||||
onPoll={pollReconstitute}
|
||||
/>
|
||||
)}
|
||||
{sheet === "wormhole" && pairing && (
|
||||
<div className="space-y-3">
|
||||
<h2 className="text-xl font-medium">Open a wormhole</h2>
|
||||
<p className="text-star-300 text-sm">
|
||||
On your outpost, run{" "}
|
||||
<code className="text-orbit-amber">tessera-agent pair {pairing.code}</code>
|
||||
</p>
|
||||
<p className="text-4xl font-mono tracking-widest text-center py-6">{pairing.code}</p>
|
||||
</div>
|
||||
)}
|
||||
</motion.aside>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
|
||||
<OrbitsPanel
|
||||
orbits={orbits.data ?? []}
|
||||
onRun={(id) => runOrbit(id).then(() => orbits.refetch())}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function TabButton({ children, onClick }: { children: React.ReactNode; onClick: () => void }) {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClick}
|
||||
className="px-4 py-2 rounded-full bg-space-800 text-sm hover:bg-space-800/80 border border-space-800"
|
||||
>
|
||||
{children}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
function SnapshotDetail({
|
||||
id,
|
||||
snaps,
|
||||
onClose,
|
||||
onReconstitute,
|
||||
}: {
|
||||
id: string;
|
||||
snaps: { id: string; orbit_name: string; taken_at: string; size_bytes: number }[];
|
||||
onClose: () => void;
|
||||
onReconstitute: () => void;
|
||||
}) {
|
||||
const snap = snaps.find((s) => s.id === id);
|
||||
if (!snap) return null;
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
<div className="flex justify-between items-center">
|
||||
<h2 className="text-xl">Snapshot tile</h2>
|
||||
<button type="button" onClick={onClose} className="text-star-300 text-sm">
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
<p className="text-star-300 text-sm">Orbit {snap.orbit_name}</p>
|
||||
<p className="text-sm">{new Date(snap.taken_at).toLocaleString()}</p>
|
||||
<p className="text-sm">{snap.size_bytes} bytes</p>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onReconstitute}
|
||||
className="w-full py-2 rounded-lg bg-orbit-amber/20 text-orbit-amber border border-orbit-amber/40"
|
||||
>
|
||||
Reconstitute…
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user