Polish Tessera web canvas: multi-tab vault UI

Vault ring scene, orbits editor, wormhole pairing, decay presets,
reconstitute grace UI, shared components, and API wiring per SPEC.
This commit is contained in:
Tessera Agent
2026-11-09 10:23:57 +00:00
parent a5ffb2c1b4
commit 1a67876f19
23 changed files with 1302 additions and 347 deletions

22
docs/UI.md Normal file
View File

@@ -0,0 +1,22 @@
# Tessera canvas — screen map
One viewport (`100dvh`) with bottom tabs; detail flows use sheets (Labuh-style).
| Tab | Purpose |
|-----|---------|
| **Vault** | Starfield + orbital SVG ring; snapshot tiles; Capture now; entry to reconstitute sheet |
| **Orbits** | Orbit cards (status dot, schedule phrase, rehearse badge); add orbit editor; capture; telemetry |
| **Wormhole** | Pairing code for outposts; placeholder outpost health (grey = offline) |
| **Decay** | Preset library with “in use” from orbit metadata |
### Sheets (overlays)
- **Snapshot tile** — evidence (time, size), reconstitute CTA, snapshot ID telemetry
- **Reconstitute** — pick snapshot/target, 12s grace ring + abort, state copy per SPEC
### API wiring
- `GET /api/v1/snapshots`, `/orbits`, `/health`
- `POST /api/v1/orbits`, `/orbits/:id/run`, `/reconstitute`, `/wormhole/pairing`
See `web/README.md` for dev commands.

28
web/README.md Normal file
View File

@@ -0,0 +1,28 @@
# Tessera web canvas
React 19 + Vite + Tailwind 4 + TanStack Query + Motion.
## Dev
```bash
npm ci
npm run dev
```
Proxies `/api` and `/health` to `http://127.0.0.1:8787` (see `vite.config.ts`).
## Production
```bash
npm run build
```
Hub embeds `web/dist` at compile time — rebuild `tessera-hub` after UI changes:
```bash
cargo build --release -p tessera-hub
```
## Screen map
See [../docs/UI.md](../docs/UI.md).

View File

@@ -1,159 +1,178 @@
import { useState } from "react";
import { useQuery } from "@tanstack/react-query";
import { motion, AnimatePresence } from "motion/react";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { AnimatePresence } from "motion/react";
import {
abortReconstitute,
fetchHealth,
fetchOrbits,
fetchSnapshots,
runOrbit,
startPairing,
startReconstitute,
abortReconstitute,
pollReconstitute,
runOrbit,
startReconstitute,
} from "./api";
import { VaultRing } from "./components/VaultRing";
import { OrbitsPanel } from "./components/OrbitsPanel";
import { ReconstituteWizard } from "./components/ReconstituteWizard";
import { vaultStatusFromOrbits } from "./lib/format";
import { DecayView } from "./components/decay/DecayView";
import { AppHeader, NavBar, type Tab } from "./components/layout/NavBar";
import { OrbitsView } from "./components/orbits/OrbitsView";
import { WormholeView } from "./components/outposts/WormholeView";
import { ReconstituteWizard } from "./components/reconstitute/ReconstituteWizard";
import { Starfield } from "./components/scene/Starfield";
import { SnapshotSheet } from "./components/vault/SnapshotSheet";
import { VaultRing } from "./components/vault/VaultRing";
import { EmptyState } from "./components/ui/EmptyState";
import { QueryGate } from "./components/ui/QueryGate";
import { Sheet } from "./components/ui/Sheet";
import { StatusDot } from "./components/ui/StatusDot";
import { Button } from "./components/ui/Button";
type Sheet = "none" | "snapshot" | "reconstitute" | "wormhole";
type Overlay = "none" | "snapshot" | "reconstitute";
export default function App() {
const [sheet, setSheet] = useState<Sheet>("none");
const [tab, setTab] = useState<Tab>("vault");
const [overlay, setOverlay] = useState<Overlay>("none");
const [selectedSnap, setSelectedSnap] = useState<string | null>(null);
const [pairing, setPairing] = useState<{ code: string; expires_at: string } | null>(null);
const qc = useQueryClient();
const snaps = useQuery({ queryKey: ["snapshots"], queryFn: fetchSnapshots, refetchInterval: 8000 });
const orbits = useQuery({ queryKey: ["orbits"], queryFn: fetchOrbits, refetchInterval: 8000 });
const health = useQuery({
queryKey: ["health"],
queryFn: fetchHealth,
refetchInterval: 30_000,
retry: 1,
});
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";
const snaps = useQuery({
queryKey: ["snapshots"],
queryFn: fetchSnapshots,
refetchInterval: 8_000,
});
const orbits = useQuery({
queryKey: ["orbits"],
queryFn: fetchOrbits,
refetchInterval: 8_000,
});
const vaultStatus = vaultStatusFromOrbits(orbits.data ?? []);
const hubOnline = health.isSuccess;
const capture = useMutation({
mutationFn: async () => {
const list = orbits.data ?? [];
const target = list[0];
if (!target) throw new Error("no-orbit");
await runOrbit(target.id);
},
onSuccess: () => {
qc.invalidateQueries({ queryKey: ["snapshots", "orbits"] });
},
});
const selectedSnapshot = snaps.data?.find((s) => s.id === selectedSnap);
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>
<div className="h-[100dvh] flex flex-col bg-space-950 text-star-100 overflow-hidden relative">
<Starfield />
<AppHeader
statusDot={<StatusDot status={hubOnline ? vaultStatus : "grey"} size="lg" />}
subtitle={hubOnline ? "Orbital backup vault" : "Hub unreachable"}
/>
<main className="flex-1 min-h-0 relative">
<main className="flex-1 min-h-0 relative z-[1]">
{tab === "vault" && (
<QueryGate
query={snaps}
empty={
<EmptyState
title="Quiet vault"
body="No snapshots on the ring yet. Add an orbit or capture now."
action={{
label: "Go to orbits",
onClick: () => setTab("orbits"),
}}
/>
}
>
{(data) => (
<VaultRing
snapshots={snaps.data ?? []}
snapshots={data}
capturing={capture.isPending || orbits.data?.some((o) => o.last_status === "running")}
onCapture={() => {
if (!(orbits.data?.length ?? 0)) setTab("orbits");
else capture.mutate();
}}
onSelect={(id) => {
setSelectedSnap(id);
setSheet("snapshot");
setOverlay("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" && (
</QueryGate>
)}
{tab === "orbits" && (
<QueryGate
query={orbits}
empty={<OrbitsView orbits={[]} />}
>
{(data) => <OrbitsView orbits={data} />}
</QueryGate>
)}
{tab === "outposts" && (
<WormholeView
pairing={pairing}
onPaired={(p) => setPairing(p)}
/>
)}
{tab === "decay" && (
<DecayView appliedPresets={(orbits.data ?? []).map((o) => o.decay_preset ?? "week-of-dailies")} />
)}
{tab === "vault" && (
<div className="absolute bottom-20 inset-x-0 flex justify-center px-4 pointer-events-none">
<Button
variant="ghost"
className="pointer-events-auto text-xs shadow-lg backdrop-blur-md"
onClick={() => setOverlay("reconstitute")}
>
Reconstitute…
</Button>
</div>
)}
</main>
<NavBar active={tab} onChange={setTab} />
<AnimatePresence>
{overlay === "snapshot" && selectedSnapshot && (
<Sheet
open
title="Snapshot tile"
onClose={() => setOverlay("none")}
>
<SnapshotSheet
snap={selectedSnapshot}
onReconstitute={() => setOverlay("reconstitute")}
/>
</Sheet>
)}
{overlay === "reconstitute" && (
<Sheet open title="Reconstitute" onClose={() => setOverlay("none")}>
<ReconstituteWizard
snapshots={snaps.data ?? []}
selected={selectedSnap}
onAbort={abortReconstitute}
onStart={startReconstitute}
onPoll={pollReconstitute}
onAbort={abortReconstitute}
/>
)}
{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>
</Sheet>
)}
</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>
{capture.isError && (
<p className="absolute top-14 inset-x-0 text-center text-xs text-orbit-amber pointer-events-none">
Add an orbit first, then capture.
</p>
)}
</div>
);
}

View File

@@ -9,49 +9,90 @@ export type Orbit = {
id: string;
name: string;
provider: string;
provider_config?: string;
last_status: string;
dry_run: boolean;
schedule?: string | null;
decay_preset?: string;
};
export async function fetchSnapshots(): Promise<Snapshot[]> {
const r = await fetch("/api/v1/snapshots");
if (!r.ok) throw new Error("snapshots");
export type CreateOrbitInput = {
name: string;
provider: "filesystem" | "postgres";
paths: string[];
schedule?: string;
decay_preset: string;
dry_run: boolean;
};
async function api<T>(path: string, init?: RequestInit): Promise<T> {
const r = await fetch(path, init);
if (!r.ok) {
const text = await r.text().catch(() => "");
throw new Error(text || `${path} failed`);
}
if (r.status === 204) return undefined as T;
return r.json();
}
export async function fetchHealth(): Promise<string> {
const r = await fetch("/health");
if (!r.ok) throw new Error("hub offline");
return r.text();
}
export async function fetchSnapshots(): Promise<Snapshot[]> {
return api("/api/v1/snapshots");
}
export async function fetchOrbits(): Promise<Orbit[]> {
const r = await fetch("/api/v1/orbits");
if (!r.ok) throw new Error("orbits");
return r.json();
return api("/api/v1/orbits");
}
export async function createOrbit(input: CreateOrbitInput): Promise<Orbit> {
return api("/api/v1/orbits", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
name: input.name,
provider: input.provider,
provider_config: { paths: input.paths },
schedule: input.schedule || null,
decay_preset: input.decay_preset,
dry_run: input.dry_run,
}),
});
}
export async function startPairing(): Promise<{ code: string; expires_at: string }> {
const r = await fetch("/api/v1/wormhole/pairing", { method: "POST" });
return r.json();
return api("/api/v1/wormhole/pairing", { method: "POST" });
}
export async function runOrbit(id: string): Promise<void> {
await fetch(`/api/v1/orbits/${id}/run`, { method: "POST" });
export async function runOrbit(id: string, rehearse = false): Promise<void> {
await api(`/api/v1/orbits/${id}/run`, { method: "POST" });
if (rehearse) return;
}
export async function startReconstitute(snapshotId: string, target: string): Promise<{
export async function startReconstitute(
snapshotId: string,
target: string,
): Promise<{
session_id: string;
session: { seconds_remaining: number; state: string };
}> {
const r = await fetch("/api/v1/reconstitute", {
return api("/api/v1/reconstitute", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ snapshot_id: snapshotId, target_path: target }),
});
return r.json();
}
export async function abortReconstitute(sessionId: string): Promise<void> {
await fetch(`/api/v1/reconstitute/${sessionId}`, { method: "DELETE" });
await api(`/api/v1/reconstitute/${sessionId}`, { method: "DELETE" });
}
export async function pollReconstitute(sessionId: string) {
const r = await fetch(`/api/v1/reconstitute/${sessionId}`);
return r.json();
return api<{ state: string; seconds_remaining: number }>(
`/api/v1/reconstitute/${sessionId}`,
);
}

View File

@@ -1,54 +0,0 @@
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

@@ -1,90 +0,0 @@
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

@@ -1,47 +0,0 @@
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>
);
}

View File

@@ -0,0 +1,51 @@
import { DECAY_PRESETS } from "../../lib/format";
import { Hint } from "../ui/EmptyState";
import { TelemetryPanel } from "../ui/Telemetry";
export function DecayView({ appliedPresets }: { appliedPresets: string[] }) {
const unique = [...new Set(appliedPresets)];
return (
<div className="h-full overflow-y-auto px-4 py-4 pb-28">
<h2 className="text-2xl font-semibold text-star-100">Decay</h2>
<p className="text-sm text-star-300 mt-1 mb-6">
Old snapshots fade on purpose — friendly presets, not retention spreadsheets.
</p>
<span className="text-xs text-star-400">Presets — pick one when you create an orbit</span>
<ul className="space-y-3 mt-3">
{DECAY_PRESETS.map((p) => {
const active = unique.includes(p.id);
return (
<li
key={p.id}
className={`rounded-2xl border p-4 ${
active
? "border-orbit-green/35 bg-orbit-green/5"
: "border-space-700 bg-space-800/40"
}`}
>
<div className="flex items-start gap-2 flex-wrap">
<h3 className="font-medium text-star-100">{p.title}</h3>
{active && (
<span className="text-[10px] text-orbit-green border border-orbit-green/30 rounded px-1.5">
In use
</span>
)}
</div>
<p className="text-sm text-star-400 mt-1">{p.blurb}</p>
</li>
);
})}
</ul>
<Hint>
Decay runs after a successful capture — rehearsed orbits never prune the vault.
</Hint>
<TelemetryPanel label="Decay policy IDs">
{JSON.stringify(DECAY_PRESETS.map((p) => p.id), null, 2)}
</TelemetryPanel>
</div>
);
}

View File

@@ -0,0 +1,55 @@
import type { ReactNode } from "react";
export type Tab = "vault" | "orbits" | "outposts" | "decay";
const tabs: { id: Tab; label: string }[] = [
{ id: "vault", label: "Vault" },
{ id: "orbits", label: "Orbits" },
{ id: "outposts", label: "Wormhole" },
{ id: "decay", label: "Decay" },
];
export function NavBar({
active,
onChange,
}: {
active: Tab;
onChange: (t: Tab) => void;
}) {
return (
<nav className="shrink-0 flex border-t border-space-800 bg-space-900/90 backdrop-blur-md safe-area-pb">
{tabs.map((t) => (
<button
key={t.id}
type="button"
onClick={() => onChange(t.id)}
className={`flex-1 py-3 text-xs font-medium transition-colors ${
active === t.id
? "text-wormhole-violet border-t-2 border-wormhole-violet -mt-px"
: "text-star-400"
}`}
>
{t.label}
</button>
))}
</nav>
);
}
export function AppHeader({
statusDot,
subtitle,
}: {
statusDot: ReactNode;
subtitle: string;
}) {
return (
<header className="shrink-0 px-4 py-3 flex items-center justify-between border-b border-space-800/80 bg-space-950/80 backdrop-blur-sm z-10">
<div>
<h1 className="text-lg font-semibold tracking-tight text-star-100">Tessera</h1>
<p className="text-xs text-star-400">{subtitle}</p>
</div>
{statusDot}
</header>
);
}

View File

@@ -0,0 +1,156 @@
import { useState } from "react";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import type { Orbit } from "../../api";
import { createOrbit, runOrbit } from "../../api";
import { DECAY_PRESETS, schedulePhrase } from "../../lib/format";
import { Button } from "../ui/Button";
import { OrbitStatusDot } from "../ui/StatusDot";
import { TelemetryPanel } from "../ui/Telemetry";
import { Hint } from "../ui/EmptyState";
export function OrbitsView({ orbits }: { orbits: Orbit[] }) {
const [editing, setEditing] = useState(false);
const qc = useQueryClient();
const [name, setName] = useState("nightly-docs");
const [path, setPath] = useState("./docs");
const [preset, setPreset] = useState(DECAY_PRESETS[0].id);
const [rehearse, setRehearse] = useState(false);
const [schedule, setSchedule] = useState("0 2 * * *");
const create = useMutation({
mutationFn: () =>
createOrbit({
name,
provider: "filesystem",
paths: [path],
schedule: schedule || undefined,
decay_preset: preset,
dry_run: rehearse,
}),
onSuccess: () => {
qc.invalidateQueries({ queryKey: ["orbits"] });
setEditing(false);
},
});
const run = useMutation({
mutationFn: (id: string) => runOrbit(id),
onSuccess: () => qc.invalidateQueries({ queryKey: ["orbits", "snapshots"] }),
});
return (
<div className="h-full overflow-y-auto px-4 py-4 pb-28 scrollbar-none">
<header className="mb-4">
<h2 className="text-2xl font-semibold text-star-100">Orbits</h2>
<p className="text-sm text-star-300 mt-1">
Scheduled circles around your vault — not cron jargon in the headline.
</p>
</header>
<div className="space-y-3 mb-6">
{orbits.map((o) => (
<article
key={o.id}
className="rounded-2xl border border-space-700 bg-space-800/50 p-4 backdrop-blur-sm"
>
<div className="flex items-start gap-3">
<OrbitStatusDot status={o.last_status} />
<div className="flex-1 min-w-0">
<h3 className="font-semibold text-star-100 truncate">{o.name}</h3>
<p className="text-xs text-star-400 mt-0.5">{schedulePhrase(o.schedule, o.dry_run)}</p>
{o.dry_run && (
<span className="inline-block mt-2 text-[10px] uppercase tracking-wider text-orbit-amber border border-orbit-amber/30 rounded px-2 py-0.5">
Rehearse mode
</span>
)}
</div>
</div>
<div className="flex gap-2 mt-4">
<Button
variant="success"
className="flex-1 text-xs py-2"
disabled={run.isPending || o.last_status === "running"}
onClick={() => run.mutate(o.id)}
>
Capture now
</Button>
</div>
<TelemetryPanel>
{JSON.stringify(o, null, 2)}
</TelemetryPanel>
</article>
))}
</div>
{editing ? (
<div className="rounded-2xl border border-wormhole-violet/30 bg-space-900 p-4 space-y-3">
<h3 className="font-medium text-star-100">New orbit</h3>
<label className="block text-sm">
<span className="text-star-400">Name</span>
<input
className="mt-1 w-full rounded-xl bg-space-950 border border-space-700 px-3 py-2"
value={name}
onChange={(e) => setName(e.target.value)}
/>
</label>
<label className="block text-sm">
<span className="text-star-400">Folder path</span>
<input
className="mt-1 w-full rounded-xl bg-space-950 border border-space-700 px-3 py-2 font-mono text-xs"
value={path}
onChange={(e) => setPath(e.target.value)}
/>
</label>
<label className="block text-sm">
<span className="text-star-400">Schedule (cron)</span>
<input
className="mt-1 w-full rounded-xl bg-space-950 border border-space-700 px-3 py-2 font-mono text-xs"
value={schedule}
onChange={(e) => setSchedule(e.target.value)}
/>
</label>
<label className="block text-sm">
<span className="text-star-400">Decay</span>
<select
className="mt-1 w-full rounded-xl bg-space-950 border border-space-700 px-3 py-2"
value={preset}
onChange={(e) => setPreset(e.target.value)}
>
{DECAY_PRESETS.map((p) => (
<option key={p.id} value={p.id}>
{p.title}
</option>
))}
</select>
</label>
<label className="flex items-center gap-2 text-sm text-star-300">
<input type="checkbox" checked={rehearse} onChange={(e) => setRehearse(e.target.checked)} />
Rehearse only (dry run)
</label>
<Hint>
Rehearse orbits prove the path without writing to the vault — status shows amber “rehearsed”.
</Hint>
<div className="flex gap-2">
<Button className="flex-1" onClick={() => setEditing(false)}>
Cancel
</Button>
<Button
variant="primary"
className="flex-1"
disabled={create.isPending}
onClick={() => create.mutate()}
>
Save orbit
</Button>
</div>
</div>
) : (
<Button variant="primary" className="w-full" onClick={() => setEditing(true)}>
Add an orbit
</Button>
)}
</div>
);
}
// fix motion.collapse - use div

View File

@@ -0,0 +1,93 @@
import { useMutation } from "@tanstack/react-query";
import { motion } from "motion/react";
import { startPairing } from "../../api";
import { Button } from "../ui/Button";
import { Hint } from "../ui/EmptyState";
import { TelemetryPanel } from "../ui/Telemetry";
export function WormholeView({
pairing,
onPaired,
}: {
pairing: { code: string; expires_at: string } | null;
onPaired: (p: { code: string; expires_at: string }) => void;
}) {
const gen = useMutation({
mutationFn: startPairing,
onSuccess: onPaired,
});
const expires = pairing ? new Date(pairing.expires_at).toLocaleTimeString() : "";
return (
<div className="h-full overflow-y-auto px-4 py-4 pb-28">
<h2 className="text-2xl font-semibold text-star-100">Outposts & wormholes</h2>
<p className="text-sm text-star-300 mt-1 mb-6">
Link a remote machine once — it beams snapshots through an encrypted wormhole.
</p>
{!pairing ? (
<EmptyWormhole onGenerate={() => gen.mutate()} loading={gen.isPending} />
) : (
<motion.div
className="rounded-2xl border border-wormhole-violet/35 bg-gradient-to-b from-wormhole-violet/10 to-space-900 p-6 text-center"
initial={{ scale: 0.95, opacity: 0 }}
animate={{ scale: 1, opacity: 1 }}
>
<p className="text-xs uppercase tracking-[0.2em] text-wormhole-violet mb-4">
Pairing code
</p>
<p className="text-4xl font-mono tracking-[0.35em] text-star-100">{pairing.code}</p>
<p className="text-sm text-star-400 mt-4">Burns at {expires}</p>
<Hint>
On the outpost:{" "}
<code className="font-mono text-orbit-amber">tessera-agent pair {pairing.code}</code>
</Hint>
<Button variant="ghost" className="mt-4 w-full" onClick={() => gen.mutate()}>
Generate fresh code
</Button>
<TelemetryPanel label="Pairing metadata">
{JSON.stringify(pairing, null, 2)}
</TelemetryPanel>
</motion.div>
)}
<section className="mt-8 space-y-3">
<h3 className="text-sm font-medium text-star-200">Outpost health</h3>
<div className="rounded-xl border border-space-700 bg-space-800/40 p-4 flex items-center gap-3">
<span className="w-2 h-2 rounded-full bg-star-400/50" />
<div>
<p className="text-sm text-star-300">No outposts paired yet</p>
<p className="text-xs text-star-400">Grey dot means offline or waiting.</p>
</div>
</div>
</section>
</div>
);
}
function EmptyWormhole({
onGenerate,
loading,
}: {
onGenerate: () => void;
loading: boolean;
}) {
return (
<div className="text-center py-8">
<motion.div
className="mx-auto w-24 h-24 rounded-full border border-wormhole-violet/30 flex items-center justify-center text-3xl"
animate={{ boxShadow: ["0 0 0 rgba(167,139,250,0)", "0 0 32px rgba(167,139,250,0.25)", "0 0 0 rgba(167,139,250,0)"] }}
transition={{ duration: 3, repeat: Infinity }}
>
◉
</motion.div>
<p className="mt-4 text-star-300 text-sm max-w-xs mx-auto">
Open a wormhole when you&apos;re ready to claim an outpost.
</p>
<Button variant="primary" className="mt-6 w-full max-w-xs mx-auto" disabled={loading} onClick={onGenerate}>
{loading ? "Opening…" : "Show pairing code"}
</Button>
</div>
);
}

View File

@@ -0,0 +1,163 @@
import { useEffect, useState } from "react";
import { motion } from "motion/react";
import type { Snapshot } from "../../api";
import { formatBytes, formatWhen } from "../../lib/format";
import { Button } from "../ui/Button";
import { Hint } from "../ui/EmptyState";
import { TelemetryPanel } from "../ui/Telemetry";
const GRACE = 12;
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(GRACE);
const [state, setState] = useState("idle");
const snap = snapshots.find((s) => s.id === snapId);
useEffect(() => {
if (!sessionId) return;
const t = setInterval(async () => {
try {
const s = await onPoll(sessionId);
setState(s.state);
setRemaining(s.seconds_remaining ?? 0);
} catch {
/* hub may clear session */
}
}, 400);
return () => clearInterval(t);
}, [sessionId, onPoll]);
const inCountdown = state === "countdown";
return (
<div className="space-y-4">
<p className="text-sm text-star-300">
Pick a snapshot, choose where it lands, then wait through the grace window.
</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)}
disabled={inCountdown || state === "restoring"}
>
{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">
<span className="text-star-400">Target path</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={inCountdown || state === "restoring"}
/>
</label>
{inCountdown && (
<motion.div
className="relative rounded-2xl border border-orbit-amber/40 bg-orbit-amber/10 p-6 text-center"
animate={{ opacity: [1, 0.85, 1] }}
transition={{ duration: 1.2, repeat: Infinity }}
>
<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" />
<circle
cx="18"
cy="18"
r="16"
fill="none"
stroke="#f0c468"
strokeWidth="3"
strokeDasharray={`${(remaining / GRACE) * 100} 100`}
pathLength={100}
/>
</svg>
<span className="absolute inset-0 flex items-center justify-center text-2xl font-semibold text-orbit-amber">
{remaining}
</span>
</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 || state === "completed"}
onClick={() => sessionId && onAbort(sessionId)}
>
Abort
</Button>
<Button
variant="warn"
className="flex-1"
disabled={!snapId || inCountdown || state === "restoring"}
onClick={async () => {
const res = await onStart(snapId, target);
setSessionId(res.session_id);
setState(res.session.state);
setRemaining(res.session.seconds_remaining);
}}
>
Begin reconstitute
</Button>
</div>
{state === "completed" && (
<p className="text-orbit-green text-sm text-center">Reconstitute complete.</p>
)}
{state === "aborted" && (
<p className="text-star-300 text-sm text-center">Reconstitute cancelled. Nothing was changed.</p>
)}
{state === "failed" && (
<p className="text-orbit-red text-sm text-center">Reconstitute failed — check telemetry.</p>
)}
<Hint>Destructive-capable. Evidence above is what we&apos;ll write to disk after the timer.</Hint>
{sessionId && (
<TelemetryPanel label="Session">
{JSON.stringify({ sessionId, state, remaining }, null, 2)}
</TelemetryPanel>
)}
</div>
);
}

View File

@@ -0,0 +1,46 @@
import { useMemo } from "react";
export function Starfield() {
const stars = useMemo(
() =>
Array.from({ length: 48 }, (_, i) => ({
id: i,
left: `${(i * 17 + 7) % 100}%`,
top: `${(i * 23 + 11) % 100}%`,
size: i % 3 === 0 ? 2 : 1,
opacity: 0.2 + (i % 5) * 0.12,
delay: `${(i % 8) * 0.4}s`,
})),
[],
);
return (
<div
className="pointer-events-none absolute inset-0 overflow-hidden opacity-60"
aria-hidden
>
<div className="stars-drift absolute inset-0 -top-[120px] h-[calc(100%+240px)]">
{stars.map((s) => (
<span
key={s.id}
className="absolute rounded-full bg-star-200"
style={{
left: s.left,
top: s.top,
width: s.size,
height: s.size,
opacity: s.opacity,
animation: `twinkle 4s ease-in-out ${s.delay} infinite alternate`,
}}
/>
))}
</div>
<style>{`
@keyframes twinkle {
from { opacity: 0.2; }
to { opacity: 0.9; }
}
`}</style>
</div>
);
}

View File

@@ -0,0 +1,26 @@
import type { ButtonHTMLAttributes } from "react";
const variants = {
primary:
"bg-wormhole-violet/25 text-star-100 border-wormhole-violet/40 hover:bg-wormhole-violet/35",
ghost: "bg-space-800/60 text-star-200 border-space-700 hover:bg-space-800",
danger: "bg-orbit-red/15 text-orbit-red border-orbit-red/35 hover:bg-orbit-red/25",
success: "bg-orbit-green/15 text-orbit-green border-orbit-green/35 hover:bg-orbit-green/25",
warn: "bg-orbit-amber/15 text-orbit-amber border-orbit-amber/40 hover:bg-orbit-amber/25",
};
export function Button({
variant = "ghost",
className = "",
...props
}: ButtonHTMLAttributes<HTMLButtonElement> & {
variant?: keyof typeof variants;
}) {
return (
<button
type="button"
className={`px-4 py-2.5 rounded-xl text-sm font-medium border transition-colors disabled:opacity-40 ${variants[variant]} ${className}`}
{...props}
/>
);
}

View File

@@ -0,0 +1,35 @@
import type { ReactNode } from "react";
import { Button } from "./Button";
export function EmptyState({
title,
body,
action,
}: {
title: string;
body: string;
action?: { label: string; onClick: () => void };
}) {
return (
<div className="text-center py-12 px-4 max-w-sm mx-auto">
<p className="text-4xl mb-3 opacity-80" aria-hidden>
✦
</p>
<h3 className="text-lg font-semibold text-star-100">{title}</h3>
<p className="mt-2 text-sm text-star-300 leading-relaxed">{body}</p>
{action && (
<Button variant="primary" className="mt-5 w-full" onClick={action.onClick}>
{action.label}
</Button>
)}
</div>
);
}
export function Hint({ children }: { children: ReactNode }) {
return (
<p className="text-xs text-star-400 leading-relaxed border border-space-700 rounded-xl px-3 py-2 bg-space-800/40">
{children}
</p>
);
}

View File

@@ -0,0 +1,36 @@
import type { UseQueryResult } from "@tanstack/react-query";
import type { ReactNode } from "react";
import { Button } from "./Button";
export function QueryGate<T>({
query,
empty,
children,
}: {
query: UseQueryResult<T, Error>;
empty?: ReactNode;
children: (data: T) => ReactNode;
}) {
if (query.isLoading) {
return (
<div className="flex flex-col items-center justify-center py-16 text-star-400">
<div className="w-10 h-10 rounded-full border-2 border-wormhole-violet/40 border-t-wormhole-violet animate-spin" />
<p className="mt-3 text-sm">Pulling telemetry from the vault…</p>
</div>
);
}
if (query.isError) {
return (
<div className="rounded-2xl border border-orbit-red/30 bg-orbit-red/10 p-4 text-center space-y-3">
<p className="text-orbit-red text-sm">We couldn’t reach the hub right now.</p>
<Button variant="ghost" onClick={() => query.refetch()}>
Try again
</Button>
</div>
);
}
const data = query.data;
const isEmpty = Array.isArray(data) && data.length === 0;
if (isEmpty && empty) return <>{empty}</>;
return <>{children(data as T)}</>;
}

View File

@@ -0,0 +1,51 @@
import { motion } from "motion/react";
import type { ReactNode } from "react";
export function Sheet({
open,
onClose,
title,
children,
}: {
open: boolean;
onClose: () => void;
title: string;
children: ReactNode;
}) {
if (!open) return null;
return (
<motion.div
className="fixed inset-0 z-40 flex flex-col justify-end"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
>
<button
type="button"
className="absolute inset-0 bg-space-950/70 backdrop-blur-sm"
aria-label="Close"
onClick={onClose}
/>
<motion.aside
className="relative z-10 max-h-[78dvh] overflow-y-auto rounded-t-3xl border-t border-space-700 bg-space-900/98 px-5 pt-4 pb-8 shadow-2xl"
initial={{ y: "100%" }}
animate={{ y: 0 }}
exit={{ y: "100%" }}
transition={{ type: "spring", damping: 28, stiffness: 320 }}
>
<div className="mx-auto mb-3 h-1 w-10 rounded-full bg-space-700" />
<div className="flex items-center justify-between gap-3 mb-4">
<h2 className="text-xl font-semibold text-star-100">{title}</h2>
<button
type="button"
onClick={onClose}
className="text-star-400 text-sm hover:text-star-200"
>
Close
</button>
</div>
{children}
</motion.aside>
</motion.div>
);
}

View File

@@ -0,0 +1,41 @@
import type { VaultStatus } from "../../lib/format";
const colors: Record<VaultStatus, string> = {
green: "bg-orbit-green shadow-[0_0_12px_rgba(74,222,154,0.6)]",
amber: "bg-orbit-amber shadow-[0_0_12px_rgba(240,196,104,0.5)]",
grey: "bg-star-400/50",
red: "bg-orbit-red shadow-[0_0_12px_rgba(248,113,113,0.5)]",
};
const labels: Record<VaultStatus, string> = {
green: "All orbits current",
amber: "Something needs you",
grey: "Quiet vault — no orbits yet",
red: "Last capture failed",
};
export function StatusDot({
status,
size = "md",
}: {
status: VaultStatus;
size?: "sm" | "md" | "lg";
}) {
const sizeClass =
size === "sm" ? "w-2 h-2" : size === "lg" ? "w-4 h-4" : "w-3 h-3";
return (
<span
className={`inline-block rounded-full ${sizeClass} ${colors[status]}`}
title={labels[status]}
aria-label={labels[status]}
/>
);
}
export function OrbitStatusDot({ status }: { status: string }) {
let vault: VaultStatus = "grey";
if (status === "failed") vault = "red";
else if (status === "running" || status === "rehearsed") vault = "amber";
else if (status === "completed") vault = "green";
return <StatusDot status={vault} size="sm" />;
}

View File

@@ -0,0 +1,29 @@
import { useState, type ReactNode } from "react";
export function TelemetryPanel({
label,
children,
}: {
label?: string;
children: ReactNode;
}) {
const [open, setOpen] = useState(false);
return (
<div className="mt-4 border-t border-space-700 pt-3">
<button
type="button"
className="text-xs text-star-400 flex items-center gap-2 w-full"
onClick={() => setOpen((v) => !v)}
>
<span className="text-wormhole-violet">◈</span>
{label ?? "Admin telemetry"}
<span className="ml-auto opacity-60">{open ? "▾" : "▸"}</span>
</button>
{open && (
<pre className="mt-2 text-[11px] font-mono text-star-400 bg-space-950/80 rounded-lg p-3 overflow-x-auto whitespace-pre-wrap">
{children}
</pre>
)}
</div>
);
}

View File

@@ -0,0 +1,32 @@
import type { Snapshot } from "../../api";
import { formatBytes, formatWhen } from "../../lib/format";
import { Button } from "../ui/Button";
import { TelemetryPanel } from "../ui/Telemetry";
export function SnapshotSheet({
snap,
onReconstitute,
}: {
snap: Snapshot;
onReconstitute: () => void;
}) {
return (
<div className="space-y-4">
<p className="text-sm text-star-300">
A point-in-time tile on the vault ring — from orbit{" "}
<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>
<p className="text-star-400 text-xs mt-2 italic">Only stardust that changed</p>
</div>
<Button variant="warn" className="w-full" onClick={onReconstitute}>
Reconstitute this snapshot…
</Button>
<TelemetryPanel label="Snapshot ID">{snap.id}</TelemetryPanel>
</div>
);
}

View File

@@ -0,0 +1,126 @@
import { motion } from "motion/react";
import type { Snapshot } from "../../api";
import { formatBytes, formatWhen } from "../../lib/format";
export function VaultRing({
snapshots,
onSelect,
onCapture,
capturing,
}: {
snapshots: Snapshot[];
onSelect: (id: string) => void;
onCapture?: () => void;
capturing?: boolean;
}) {
const count = Math.max(snapshots.length, 1);
const radius = 128;
const tiles = snapshots.slice(0, 16);
return (
<div className="relative h-full w-full flex flex-col items-center justify-center px-4">
<div className="relative w-full max-w-[min(100vw,420px)] aspect-square flex items-center justify-center">
<svg
viewBox="-220 -220 440 440"
className="w-full h-full drop-shadow-[0_0_40px_rgba(167,139,250,0.12)]"
role="img"
aria-label="Orbital vault ring of snapshots"
>
<defs>
<radialGradient id="vaultGlow" cx="50%" cy="50%" r="50%">
<stop offset="0%" stopColor="#1e2647" stopOpacity="0.9" />
<stop offset="100%" stopColor="#04050c" stopOpacity="0" />
</radialGradient>
</defs>
<circle cx="0" cy="0" r="200" fill="url(#vaultGlow)" />
<circle
cx="0"
cy="0"
r={radius + 28}
fill="none"
stroke="#2d3a6b"
strokeWidth="1.5"
strokeDasharray="6 10"
opacity="0.7"
/>
<motion.circle
cx="0"
cy="0"
r={radius + 28}
fill="none"
stroke="#a78bfa"
strokeWidth="1"
strokeDasharray="40 200"
strokeLinecap="round"
opacity="0.35"
animate={{ rotate: 360 }}
transition={{ duration: 90, repeat: Infinity, ease: "linear" }}
style={{ transformOrigin: "0px 0px" }}
/>
<text
x="0"
y="-6"
textAnchor="middle"
fill="#94a3d4"
fontSize="13"
fontWeight="500"
>
Vault
</text>
<text x="0" y="14" textAnchor="middle" fill="#6b7ab8" fontSize="9">
{snapshots.length} snapshot{tiles.length === 1 ? "" : "s"}
</text>
{tiles.length === 0 && (
<text x="0" y="50" textAnchor="middle" fill="#6b7ab8" fontSize="10">
Capture your first orbit
</text>
)}
{tiles.map((snap, i) => {
const angle = (i / Math.max(count, tiles.length)) * 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, opacity: 0 }}
animate={{ scale: 1, opacity: 1 }}
transition={{ delay: i * 0.04 }}
style={{ cursor: "pointer" }}
onClick={() => onSelect(snap.id)}
>
<circle cx={x} cy={y} r="22" fill="#141a36" stroke="#4ade9a" strokeWidth="2" />
<circle cx={x} cy={y} r="14" fill="#1e2647" opacity="0.8" />
<title>
{snap.orbit_name} · {formatWhen(snap.taken_at)}
</title>
</motion.g>
);
})}
</svg>
</div>
{onCapture && (
<motion.button
type="button"
disabled={capturing}
onClick={onCapture}
className="mt-2 px-6 py-3 rounded-full bg-orbit-green/20 border border-orbit-green/45 text-orbit-green font-medium text-sm disabled:opacity-50"
whileTap={{ scale: 0.96 }}
>
{capturing ? "Orbit in progress…" : "Capture now"}
</motion.button>
)}
<p className="mt-2 text-xs text-star-400 max-w-xs text-center">
Tap a tile for snapshot detail. Only stardust that changed.
</p>
</div>
);
}
export function SnapshotSummaryRow({ snap }: { snap: Snapshot }) {
return (
<div className="flex justify-between text-sm py-2 border-b border-space-700/50">
<span className="text-star-200">{snap.orbit_name}</span>
<span className="text-star-400 text-xs">{formatBytes(snap.size_bytes)}</span>
</div>
);
}

View File

@@ -1,14 +1,25 @@
@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700&family=JetBrains+Mono:wght@400;500&display=swap");
@import "tailwindcss";
@theme {
--color-space-950: #05060f;
--color-space-900: #0c1024;
--color-space-800: #151b3a;
--color-star-100: #e8ecff;
--color-star-300: #a8b4e8;
--color-orbit-amber: #f5c56b;
--color-orbit-green: #5ee6a8;
--color-orbit-red: #ff6b7a;
--color-space-950: #04050c;
--color-space-900: #0a0e1f;
--color-space-800: #141a36;
--color-space-700: #1e2647;
--color-star-100: #eef1ff;
--color-star-200: #c9d2f5;
--color-star-300: #94a3d4;
--color-star-400: #6b7ab8;
--color-orbit-amber: #f0c468;
--color-orbit-green: #4ade9a;
--color-orbit-red: #f87171;
--color-wormhole-violet: #a78bfa;
--font-sans: "DM Sans", system-ui, sans-serif;
--font-mono: "JetBrains Mono", ui-monospace, monospace;
}
html {
font-family: var(--font-sans);
}
html,
@@ -17,3 +28,28 @@ body,
height: 100%;
margin: 0;
}
@layer utilities {
.font-mono {
font-family: var(--font-mono);
}
.scrollbar-none {
scrollbar-width: none;
}
.scrollbar-none::-webkit-scrollbar {
display: none;
}
}
.stars-drift {
animation: drift 120s linear infinite;
}
@keyframes drift {
from {
transform: translateY(0);
}
to {
transform: translateY(-120px);
}
}

60
web/src/lib/format.ts Normal file
View File

@@ -0,0 +1,60 @@
export function formatBytes(n: number): string {
if (n < 1024) return `${n} B`;
if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`;
if (n < 1024 * 1024 * 1024) return `${(n / (1024 * 1024)).toFixed(1)} MB`;
return `${(n / (1024 * 1024 * 1024)).toFixed(2)} GB`;
}
export function formatWhen(iso: string): string {
return new Date(iso).toLocaleString(undefined, {
dateStyle: "medium",
timeStyle: "short",
});
}
export function schedulePhrase(cron?: string | null, dryRun?: boolean): string {
if (dryRun) return "Rehearse — no vault write";
if (!cron) return "On your command";
if (cron.includes("0 2")) return "Every night at 2am";
if (cron.includes("0 */6")) return "Every six hours";
return cron;
}
export type VaultStatus = "green" | "amber" | "grey" | "red";
export function vaultStatusFromOrbits(
orbits: { last_status: string }[],
): VaultStatus {
if (!orbits.length) return "grey";
if (orbits.some((o) => o.last_status === "failed")) return "red";
if (
orbits.some(
(o) =>
o.last_status === "running" ||
o.last_status === "rehearsed" ||
o.last_status === "rehearsing",
)
)
return "amber";
if (orbits.every((o) => o.last_status === "completed" || o.last_status === "idle"))
return "green";
return "amber";
}
export const DECAY_PRESETS = [
{
id: "week-of-dailies",
title: "A week of dailies",
blurb: "Keep 7 nightly snapshots, let the rest decay.",
},
{
id: "month-of-weeklies",
title: "A month of weeklies",
blurb: "One snapshot per week, keep the last 4.",
},
{
id: "year-of-monthlies",
title: "A year of monthlies",
blurb: "Twelve monthly tiles on the ring.",
},
] as const;