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:
Tessera Agent
2026-11-09 09:59:42 +00:00
commit a5ffb2c1b4
54 changed files with 8379 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
import type { Orbit } from "../api";
export function OrbitsPanel({
orbits,
onRun,
}: {
orbits: Orbit[];
onRun: (id: string) => void;
}) {
if (!orbits.length) return null;
return (
<section className="shrink-0 border-t border-space-800 px-4 py-2 overflow-x-auto flex gap-2 scrollbar-none">
{orbits.map((o) => (
<article
key={o.id}
className="min-w-[160px] rounded-xl bg-space-900 border border-space-800 p-3 text-sm"
>
<div className="flex items-center gap-2">
<StatusDot status={o.last_status} />
<span className="font-medium truncate">{o.name}</span>
</div>
<p className="text-xs text-star-300 mt-1">
{o.dry_run ? "Rehearse orbit" : scheduleLabel(o.schedule)}
</p>
<button
type="button"
className="mt-2 text-xs text-orbit-green"
onClick={() => onRun(o.id)}
>
Capture now
</button>
</article>
))}
</section>
);
}
function StatusDot({ status }: { status: string }) {
const color =
status === "failed"
? "bg-orbit-red"
: status === "running" || status === "rehearsed"
? "bg-orbit-amber"
: status === "completed"
? "bg-orbit-green"
: "bg-star-300/40";
return <span className={`w-2 h-2 rounded-full ${color}`} />;
}
function scheduleLabel(schedule?: string | null) {
if (!schedule) return "On demand";
if (schedule.includes("0 2")) return "Every night at 2am";
return schedule;
}

View File

@@ -0,0 +1,90 @@
import { useEffect, useState } from "react";
import type { Snapshot } from "../api";
export function ReconstituteWizard({
snapshots,
selected,
onStart,
onPoll,
onAbort,
}: {
snapshots: Snapshot[];
selected: string | null;
onStart: (snapId: string, target: string) => Promise<{ session_id: string; session: { seconds_remaining: number; state: string } }>;
onPoll: (id: string) => Promise<{ state: string; seconds_remaining: number }>;
onAbort: (id: string) => Promise<void>;
}) {
const [snapId, setSnapId] = useState(selected ?? snapshots[0]?.id ?? "");
const [target, setTarget] = useState("./restore/out");
const [sessionId, setSessionId] = useState<string | null>(null);
const [remaining, setRemaining] = useState(12);
const [state, setState] = useState<string>("idle");
useEffect(() => {
if (!sessionId) return;
const t = setInterval(async () => {
const s = await onPoll(sessionId);
setState(s.state);
setRemaining(s.seconds_remaining ?? 0);
}, 500);
return () => clearInterval(t);
}, [sessionId, onPoll]);
return (
<div className="space-y-4">
<h2 className="text-xl font-medium">Reconstitute</h2>
<p className="text-sm text-star-300">Pick a snapshot and where it should land.</p>
<label className="block text-sm">
Snapshot
<select
className="mt-1 w-full bg-space-800 rounded px-2 py-2"
value={snapId}
onChange={(e) => setSnapId(e.target.value)}
>
{snapshots.map((s) => (
<option key={s.id} value={s.id}>
{s.orbit_name} — {new Date(s.taken_at).toLocaleDateString()}
</option>
))}
</select>
</label>
<label className="block text-sm">
Target path
<input
className="mt-1 w-full bg-space-800 rounded px-2 py-2"
value={target}
onChange={(e) => setTarget(e.target.value)}
/>
</label>
{state === "countdown" && (
<p className="text-orbit-amber text-center py-2">
Reconstituting in {remaining}s — abort restores nothing.
</p>
)}
<div className="flex gap-2">
<button
type="button"
className="flex-1 py-2 rounded-lg bg-orbit-red/20 text-orbit-red border border-orbit-red/30"
disabled={!sessionId}
onClick={() => sessionId && onAbort(sessionId)}
>
Abort
</button>
<button
type="button"
className="flex-1 py-2 rounded-lg bg-orbit-green/20 text-orbit-green border border-orbit-green/40"
onClick={async () => {
const res = await onStart(snapId, target);
setSessionId(res.session_id);
setState(res.session.state);
setRemaining(res.session.seconds_remaining);
}}
>
Begin
</button>
</div>
{state === "completed" && <p className="text-orbit-green text-sm">Reconstitute complete.</p>}
{state === "aborted" && <p className="text-star-300 text-sm">Reconstitute cancelled. Nothing was changed.</p>}
</div>
);
}

View File

@@ -0,0 +1,47 @@
import { motion } from "motion/react";
import type { Snapshot } from "../api";
export function VaultRing({
snapshots,
onSelect,
}: {
snapshots: Snapshot[];
onSelect: (id: string) => void;
}) {
const count = Math.max(snapshots.length, 6);
const radius = Math.min(140, typeof window !== "undefined" ? window.innerWidth * 0.35 : 140);
return (
<div className="h-full flex items-center justify-center overflow-hidden touch-none">
<svg
viewBox="-200 -200 400 400"
className="w-full h-full max-w-[min(100vw,480px)] max-h-[min(70dvh,480px)]"
role="img"
aria-label="Vault snapshot ring"
>
<circle cx="0" cy="0" r={radius + 20} fill="none" stroke="#252d55" strokeWidth="2" strokeDasharray="4 8" />
<text x="0" y="-8" textAnchor="middle" fill="#a8b4e8" fontSize="14">
Vault
</text>
{snapshots.slice(0, 12).map((snap, i) => {
const angle = (i / count) * Math.PI * 2 - Math.PI / 2;
const x = Math.cos(angle) * radius;
const y = Math.sin(angle) * radius;
return (
<motion.g
key={snap.id}
initial={{ scale: 0 }}
animate={{ scale: 1 }}
whileTap={{ scale: 0.92 }}
style={{ cursor: "pointer" }}
onClick={() => onSelect(snap.id)}
>
<circle cx={x} cy={y} r="18" fill="#151b3a" stroke="#5ee6a8" strokeWidth="2" />
<title>{snap.orbit_name}</title>
</motion.g>
);
})}
</svg>
</div>
);
}