feat: rebuild the orbital vault as an operational map
This commit is contained in:
370
web/src/App.tsx
370
web/src/App.tsx
@@ -1,209 +1,215 @@
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { useMemo, useState } from "react";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import {
|
||||
abortReconstitute,
|
||||
fetchHealth,
|
||||
fetchOrbits,
|
||||
fetchSnapshots,
|
||||
pollReconstitute,
|
||||
runOrbit,
|
||||
startReconstitute,
|
||||
abortReconstitute, fetchHealth, fetchOrbits, fetchSnapshots, pollReconstitute,
|
||||
runOrbit, startReconstitute, type Orbit,
|
||||
} from "./api";
|
||||
import { vaultStatusFromOrbits } from "./lib/format";
|
||||
import { DecayView } from "./components/decay/DecayView";
|
||||
import { OrbitInspector, OrbitRegister, TelemetryStrip } from "./components/hud/DiegeticHUD";
|
||||
import { HUDPanel } from "./components/hud/HUDPanel";
|
||||
import { HUDRail, type HUDMode } from "./components/hud/HUDRail";
|
||||
import { OrbitsView } from "./components/orbits/OrbitsView";
|
||||
import { WormholeView } from "./components/outposts/WormholeView";
|
||||
import { ReconstituteWizard } from "./components/reconstitute/ReconstituteWizard";
|
||||
import { VaultScene } from "./components/scene/VaultScene";
|
||||
import { SnapshotSheet } from "./components/vault/SnapshotSheet";
|
||||
import {
|
||||
CockpitFrame,
|
||||
SnapshotsMiniList,
|
||||
TelemetryStrip,
|
||||
} from "./components/hud/DiegeticHUD";
|
||||
import { HUDPanel, SceneAction } from "./components/hud/HUDPanel";
|
||||
import { HUDRail, type HUDMode } from "./components/hud/HUDRail";
|
||||
import { EmptyState } from "./components/ui/EmptyState";
|
||||
import { QueryGate } from "./components/ui/QueryGate";
|
||||
import { SnapshotSheet } from "./components/vault/SnapshotSheet";
|
||||
import { useReducedMotion } from "./hooks/useReducedMotion";
|
||||
import { orbitStatus } from "./lib/format";
|
||||
import { groupSnapshots } from "./lib/galaxyLayout";
|
||||
|
||||
const panelTitles: Record<HUDMode, string> = {
|
||||
scene: "Vault",
|
||||
orbits: "Orbit management",
|
||||
wormhole: "Wormhole uplink",
|
||||
decay: "Snapshot retention",
|
||||
reconstitute: "Restore snapshot",
|
||||
snapshot: "Snapshot detail",
|
||||
};
|
||||
|
||||
function priority(orbit: Orbit) {
|
||||
if (orbit.last_status === "failed") return 0;
|
||||
return orbitStatus(orbit.last_status).busy ? 1 : 2;
|
||||
}
|
||||
|
||||
export default function App() {
|
||||
const [mode, setMode] = useState<HUDMode>("scene");
|
||||
const [selectedSnap, setSelectedSnap] = useState<string | null>(null);
|
||||
const [orbitId, setOrbitId] = useState<string>();
|
||||
const [snapshotId, setSnapshotId] = useState<string | null>(null);
|
||||
const [pairing, setPairing] = useState<{ code: string; expires_at: string } | null>(null);
|
||||
const [galaxyFlowing, setGalaxyFlowing] = useState(true);
|
||||
const [capturePulse, setCapturePulse] = useState(0);
|
||||
const [play, setPlay] = useState(true);
|
||||
const [restoreBusy, setRestoreBusy] = useState(false);
|
||||
const [restoreTarget, setRestoreTarget] = useState<{ id: string | null }>();
|
||||
const reducedMotion = useReducedMotion();
|
||||
const qc = useQueryClient();
|
||||
|
||||
const health = useQuery({
|
||||
queryKey: ["health"],
|
||||
queryFn: fetchHealth,
|
||||
refetchInterval: 30_000,
|
||||
retry: 1,
|
||||
});
|
||||
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 totalBytes = useMemo(
|
||||
() => (snaps.data ?? []).reduce((a, s) => a + s.size_bytes, 0),
|
||||
[snaps.data],
|
||||
);
|
||||
|
||||
const capturing =
|
||||
orbits.data?.some((o) => o.last_status === "running") ?? false;
|
||||
|
||||
const health = useQuery({ queryKey: ["health"], queryFn: fetchHealth, refetchInterval: 15_000, retry: 1 });
|
||||
const snaps = useQuery({ queryKey: ["snapshots"], queryFn: fetchSnapshots, refetchInterval: 8_000, retry: 1 });
|
||||
const orbits = useQuery({ queryKey: ["orbits"], queryFn: fetchOrbits, refetchInterval: 8_000, retry: 1 });
|
||||
const capture = useMutation({
|
||||
mutationFn: async () => {
|
||||
const target = orbits.data?.[0];
|
||||
if (!target) throw new Error("no-orbit");
|
||||
await runOrbit(target.id);
|
||||
mutationFn: (target: Orbit) => runOrbit(target.id),
|
||||
onSettled: () => {
|
||||
void qc.invalidateQueries({ queryKey: ["orbits"] });
|
||||
void qc.invalidateQueries({ queryKey: ["snapshots"] });
|
||||
},
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ["snapshots", "orbits"] }),
|
||||
});
|
||||
|
||||
const selectedSnapshot = snaps.data?.find((s) => s.id === selectedSnap);
|
||||
const online = health.isSuccess;
|
||||
const activeId = capture.isPending ? capture.variables.id : undefined;
|
||||
const sceneOrbits = useMemo(() => (orbits.data ?? []).map((orbit) =>
|
||||
orbit.id === activeId ? { ...orbit, last_status: orbit.dry_run ? "rehearsing" : "running" } : orbit,
|
||||
), [orbits.data, activeId]);
|
||||
const register = useMemo(() => [...sceneOrbits].sort((a, b) => priority(a) - priority(b)), [sceneOrbits]);
|
||||
const grouped = useMemo(() => groupSnapshots(orbits.data ?? [], snaps.data ?? []), [orbits.data, snaps.data]);
|
||||
const totalBytes = useMemo(() => (snaps.data ?? []).reduce((sum, snap) => sum + snap.size_bytes, 0), [snaps.data]);
|
||||
const selected = sceneOrbits.find(({ id }) => id === orbitId);
|
||||
const history = (selected && grouped.get(selected.id)) ?? [];
|
||||
const snapshot = snaps.data?.find(({ id }) => id === snapshotId);
|
||||
const completedOrbitId = capture.isSuccess ? capture.variables.id : undefined;
|
||||
const arrival = useMemo(() => !reducedMotion && completedOrbitId && capture.data
|
||||
? { orbitId: completedOrbitId, snapshotId: capture.data }
|
||||
: undefined, [reducedMotion, completedOrbitId, capture.data]);
|
||||
const failedCount = sceneOrbits.filter(({ last_status }) => last_status === "failed").length;
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
if (e.key === "Escape" && mode !== "scene") setMode("scene");
|
||||
};
|
||||
window.addEventListener("keydown", onKey);
|
||||
return () => window.removeEventListener("keydown", onKey);
|
||||
}, [mode]);
|
||||
const orbitMessage = orbits.isPending ? "Receiving orbit telemetry…" : orbits.isError
|
||||
? orbits.data ? "Live telemetry unavailable. Showing last known orbits." : "Orbit telemetry unavailable."
|
||||
: register.length ? undefined : "No backup jobs yet. Set up an orbit to begin.";
|
||||
const snapshotMessage = snaps.isPending ? "Loading snapshot history…" : snaps.isError
|
||||
? snaps.data ? "Showing last known snapshots." : "Snapshot history unavailable."
|
||||
: history.length ? undefined : "This orbit has no snapshots yet.";
|
||||
const captureLabel = capture.isPending ? capture.variables.dry_run ? "Rehearsing" : "Capturing"
|
||||
: capture.isError ? "Capture failed for"
|
||||
: capture.variables?.dry_run ? "Rehearsal complete for"
|
||||
: capture.data ? "Snapshot secured from" : "Capture finished for";
|
||||
const captureNotice = capture.variables && (
|
||||
<p className={`capture-notice${capture.isError ? " tone-red" : ""}`} role="status">
|
||||
{captureLabel} {capture.variables.name}{capture.isPending ? "…" : "."}
|
||||
</p>
|
||||
);
|
||||
const noticeInInspector = !!selected && selected.id === capture.variables?.id;
|
||||
|
||||
const snapshotPanel = selectedSnapshot && mode === "scene";
|
||||
function selectOrbit(id: string) {
|
||||
setOrbitId(id);
|
||||
setPlay(false);
|
||||
}
|
||||
|
||||
function openSnapshot(id: string) {
|
||||
document.getElementById(`snapshot-${id}`)?.focus({ preventScroll: true });
|
||||
setSnapshotId(id);
|
||||
setMode("snapshot");
|
||||
}
|
||||
|
||||
function runCapture(target: Orbit) {
|
||||
selectOrbit(target.id);
|
||||
capture.mutate(target);
|
||||
}
|
||||
|
||||
function openConsole(next: HUDMode, target: string | null = null) {
|
||||
if (next === "reconstitute" && !restoreBusy &&
|
||||
(!restoreTarget || (target !== null && target !== restoreTarget.id))) {
|
||||
setRestoreTarget({ id: target });
|
||||
}
|
||||
setMode(next);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="h-[100dvh] w-full overflow-hidden bg-space-950 text-star-100 relative">
|
||||
<VaultScene
|
||||
orbits={orbits.data ?? []}
|
||||
snapshots={snaps.data ?? []}
|
||||
flowing={galaxyFlowing}
|
||||
onToggleFlow={() => setGalaxyFlowing((f) => !f)}
|
||||
capturing={capturing || capture.isPending}
|
||||
capturePulse={capturePulse}
|
||||
selectedSnapshotId={selectedSnap}
|
||||
onSelect={(id) => setSelectedSnap(id)}
|
||||
onSelectOrbit={() => {
|
||||
setGalaxyFlowing(false);
|
||||
setMode("orbits");
|
||||
}}
|
||||
/>
|
||||
|
||||
<CockpitFrame>
|
||||
<TelemetryStrip
|
||||
status={vaultStatus}
|
||||
online={hubOnline}
|
||||
snapCount={snaps.data?.length ?? 0}
|
||||
totalBytes={totalBytes}
|
||||
/>
|
||||
<SnapshotsMiniList
|
||||
snapshots={snaps.data ?? []}
|
||||
selected={selectedSnap}
|
||||
onSelect={(id) => setSelectedSnap(id)}
|
||||
/>
|
||||
</CockpitFrame>
|
||||
|
||||
<div className="absolute bottom-24 left-1/2 -translate-x-1/2 z-30 flex gap-3 pointer-events-none">
|
||||
<SceneAction
|
||||
label={capture.isPending ? "ORBIT ACTIVE…" : "CAPTURE NOW"}
|
||||
disabled={capture.isPending}
|
||||
onClick={() => {
|
||||
if (!(orbits.data?.length ?? 0)) setMode("orbits");
|
||||
else {
|
||||
setCapturePulse((n) => n + 1);
|
||||
capture.mutate();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<HUDRail active={mode} onSelect={setMode} capturing={capturing} />
|
||||
|
||||
<HUDPanel
|
||||
open={!!snapshotPanel}
|
||||
title="Snapshot tile"
|
||||
subtitle="Point-in-time mass on the ring"
|
||||
side="left"
|
||||
onClose={() => setSelectedSnap(null)}
|
||||
>
|
||||
{selectedSnapshot && (
|
||||
<SnapshotSheet
|
||||
snap={selectedSnapshot}
|
||||
onReconstitute={() => setMode("reconstitute")}
|
||||
/>
|
||||
)}
|
||||
</HUDPanel>
|
||||
|
||||
<HUDPanel
|
||||
open={mode === "orbits"}
|
||||
title="Orbit console"
|
||||
subtitle="Schedule circles — not a spreadsheet"
|
||||
onClose={() => setMode("scene")}
|
||||
>
|
||||
<QueryGate query={orbits} empty={<OrbitsView orbits={[]} />}>
|
||||
{(data) => <OrbitsView orbits={data} />}
|
||||
</QueryGate>
|
||||
</HUDPanel>
|
||||
|
||||
<HUDPanel
|
||||
open={mode === "wormhole"}
|
||||
title="Wormhole uplink"
|
||||
subtitle="Pair an outpost once"
|
||||
onClose={() => setMode("scene")}
|
||||
>
|
||||
<WormholeView pairing={pairing} onPaired={setPairing} />
|
||||
</HUDPanel>
|
||||
|
||||
<HUDPanel
|
||||
open={mode === "decay"}
|
||||
title="Decay field"
|
||||
subtitle="What fades, on purpose"
|
||||
onClose={() => setMode("scene")}
|
||||
>
|
||||
<DecayView
|
||||
appliedPresets={(orbits.data ?? []).map(
|
||||
(o) => o.decay_preset ?? "week-of-dailies",
|
||||
)}
|
||||
/>
|
||||
</HUDPanel>
|
||||
|
||||
<HUDPanel
|
||||
open={mode === "reconstitute"}
|
||||
title="Reconstitute"
|
||||
subtitle="12s grace — abort restores nothing"
|
||||
side="bottom"
|
||||
onClose={() => setMode("scene")}
|
||||
>
|
||||
{(snaps.data?.length ?? 0) === 0 ? (
|
||||
<EmptyState
|
||||
title="No tiles to restore"
|
||||
body="Capture an orbit first, then return here."
|
||||
/>
|
||||
) : (
|
||||
<ReconstituteWizard
|
||||
snapshots={snaps.data ?? []}
|
||||
selected={selectedSnap}
|
||||
onStart={startReconstitute}
|
||||
onPoll={pollReconstitute}
|
||||
onAbort={abortReconstitute}
|
||||
/>
|
||||
)}
|
||||
</HUDPanel>
|
||||
|
||||
{capture.isError && (
|
||||
<p className="absolute top-24 inset-x-0 text-center text-[10px] font-mono text-orbit-amber z-30">
|
||||
NO ORBIT — OPEN ⟳ CONSOLE
|
||||
<div className="vault-app">
|
||||
<header className="vault-topbar">
|
||||
<div className="vault-brand">
|
||||
<svg viewBox="0 0 38 38" width="34" height="34" aria-hidden="true">
|
||||
<circle cx="19" cy="19" r="10.5" fill="none" stroke="currentColor" opacity=".5" />
|
||||
<ellipse cx="19" cy="19" rx="17" ry="5.8" transform="rotate(-32 19 19)" fill="none" stroke="currentColor" />
|
||||
<circle cx="19" cy="19" r="3" fill="currentColor" />
|
||||
</svg>
|
||||
<div><strong>Tessera</strong><span>Backup control</span></div>
|
||||
</div>
|
||||
<HUDRail active={mode === "snapshot" ? "scene" : mode} onSelect={openConsole} />
|
||||
<p className="hub-link" role="status">
|
||||
<span className={`register-signal signal-${online ? "green" : "grey"}`} />
|
||||
{online ? "Hub online" : health.isPending ? "Connecting" : "Hub offline"}
|
||||
</p>
|
||||
)}
|
||||
</header>
|
||||
|
||||
<main className="vault-main">
|
||||
<div className="vault-overview">
|
||||
<div>
|
||||
<p className="instrument-label overview-label"><span aria-hidden="true">◈</span> Vault / 01</p>
|
||||
<h1>Orbital vault</h1>
|
||||
<p className="overview-copy">Backup jobs and recovery points</p>
|
||||
</div>
|
||||
<TelemetryStrip orbitCount={orbits.data?.length} failedCount={failedCount} snapCount={snaps.data?.length} totalBytes={totalBytes} />
|
||||
</div>
|
||||
|
||||
<div className="vault-workspace">
|
||||
<VaultScene
|
||||
orbits={sceneOrbits} selectedOrbitId={selected?.id} recentSnapshots={history.slice(0, 3)}
|
||||
flowing={play && !reducedMotion} reducedMotion={reducedMotion} arrival={arrival}
|
||||
onToggleFlow={() => setPlay((value) => !value)}
|
||||
onSelectOrbit={(id) => {
|
||||
selectOrbit(id);
|
||||
document.getElementById(`register-${id}`)?.focus({ preventScroll: true });
|
||||
}}
|
||||
onSelectSnapshot={openSnapshot}
|
||||
/>
|
||||
<OrbitRegister
|
||||
orbits={register} selected={selected?.id} message={orbitMessage}
|
||||
onSelect={selectOrbit} onManage={() => setMode("orbits")}
|
||||
/>
|
||||
<OrbitInspector
|
||||
orbit={selected} snapshots={history} snapshotMessage={snapshotMessage}
|
||||
onSelectSnapshot={openSnapshot}
|
||||
capture={selected && (
|
||||
<>
|
||||
<button
|
||||
type="button" className="console-control capture-button"
|
||||
onClick={() => runCapture(selected)}
|
||||
disabled={!online || capture.isPending || orbitStatus(selected.last_status).busy}
|
||||
>
|
||||
<span aria-hidden="true">↘</span>
|
||||
<span>{selected.dry_run ? "Rehearse" : "Capture"} {selected.name}</span>
|
||||
</button>
|
||||
{noticeInInspector && mode !== "orbits" && captureNotice}
|
||||
</>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<footer className="vault-footer">
|
||||
{(!noticeInInspector && mode !== "orbits" && captureNotice) || <p>Vault telemetry</p>}
|
||||
<p role="status">{restoreBusy ? "Restore active · open Restore to monitor" : "Local backup station"}</p>
|
||||
</footer>
|
||||
</main>
|
||||
|
||||
<HUDPanel
|
||||
open={mode !== "scene"}
|
||||
title={panelTitles[mode]}
|
||||
subtitle={mode === "reconstitute" ? "Review the destination before starting the restore." : undefined}
|
||||
onClose={() => setMode("scene")}
|
||||
>
|
||||
{mode === "orbits" && (
|
||||
<QueryGate query={orbits}>
|
||||
{() => <OrbitsView orbits={sceneOrbits} onRun={runCapture} captureDisabled={!online || capture.isPending} notice={captureNotice} />}
|
||||
</QueryGate>
|
||||
)}
|
||||
{mode === "wormhole" && <WormholeView pairing={pairing} onPaired={setPairing} />}
|
||||
{mode === "decay" && <DecayView appliedPresets={sceneOrbits.map((orbit) => orbit.decay_preset ?? "week-of-dailies")} />}
|
||||
{mode === "snapshot" && (snapshot ? (
|
||||
<SnapshotSheet snap={snapshot} onReconstitute={() => openConsole("reconstitute", snapshot.id)} />
|
||||
) : <EmptyState title="Snapshot unavailable" body="It may have expired under the retention policy." />)}
|
||||
<div hidden={mode !== "reconstitute"}>
|
||||
{restoreTarget && (snaps.data?.length || restoreBusy ? (
|
||||
<ReconstituteWizard
|
||||
key={restoreTarget.id ?? "manual"}
|
||||
snapshots={snaps.data ?? []} selected={restoreTarget.id}
|
||||
onStart={startReconstitute} onPoll={pollReconstitute} onAbort={abortReconstitute} onBusyChange={setRestoreBusy}
|
||||
/>
|
||||
) : (
|
||||
<QueryGate query={snaps} empty={<EmptyState title="No snapshots to restore" body="Capture an orbit to create a recovery point." />}>
|
||||
{() => null}
|
||||
</QueryGate>
|
||||
))}
|
||||
</div>
|
||||
</HUDPanel>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
export type Snapshot = {
|
||||
id: string;
|
||||
orbit_id?: string;
|
||||
taken_at: string;
|
||||
orbit_name: string;
|
||||
size_bytes: number;
|
||||
@@ -25,12 +26,17 @@ export type CreateOrbitInput = {
|
||||
dry_run: boolean;
|
||||
};
|
||||
|
||||
async function api<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
async function request(path: string, init?: RequestInit): Promise<Response> {
|
||||
const r = await fetch(path, init);
|
||||
if (!r.ok) {
|
||||
const text = await r.text().catch(() => "");
|
||||
throw new Error(text || `${path} failed`);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
async function api<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
const r = await request(path, init);
|
||||
if (r.status === 204) return undefined as T;
|
||||
return r.json();
|
||||
}
|
||||
@@ -68,9 +74,9 @@ export async function startPairing(): Promise<{ code: string; expires_at: string
|
||||
return api("/api/v1/wormhole/pairing", { 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 runOrbit(id: string): Promise<string | null> {
|
||||
const response = await request(`/api/v1/orbits/${id}/run`, { method: "POST" });
|
||||
return response.headers.get("X-Tessera-Snapshot-Id");
|
||||
}
|
||||
|
||||
export async function startReconstitute(
|
||||
@@ -92,7 +98,8 @@ export async function abortReconstitute(sessionId: string): Promise<void> {
|
||||
}
|
||||
|
||||
export async function pollReconstitute(sessionId: string) {
|
||||
return api<{ state: string; seconds_remaining: number }>(
|
||||
`/api/v1/reconstitute/${sessionId}`,
|
||||
);
|
||||
const response = await fetch(`/api/v1/reconstitute/${sessionId}`);
|
||||
if (response.status === 404) return { state: "unavailable", seconds_remaining: 0 };
|
||||
if (!response.ok) throw new Error("Could not read restore status");
|
||||
return response.json() as Promise<{ state: string; seconds_remaining: number }>;
|
||||
}
|
||||
|
||||
@@ -1,89 +1,132 @@
|
||||
import type { ReactNode } from "react";
|
||||
import type { VaultStatus } from "../../lib/format";
|
||||
import { StatusDot } from "../ui/StatusDot";
|
||||
import { formatBytes } from "../../lib/format";
|
||||
import type { Snapshot } from "../../api";
|
||||
|
||||
export function CockpitFrame({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<div className="absolute inset-0 pointer-events-none z-20">
|
||||
<motionBorder />
|
||||
<p className="absolute top-3 left-4 text-[10px] font-mono tracking-[0.35em] text-star-400/80 uppercase">
|
||||
Tessera · orbital vault
|
||||
</p>
|
||||
<p className="absolute top-3 right-4 text-[10px] font-mono text-star-400/60">
|
||||
SYS // VAULT-01
|
||||
</p>
|
||||
<div className="absolute bottom-3 left-4 right-4 h-px bg-gradient-to-r from-transparent via-wormhole-violet/40 to-transparent" />
|
||||
<div className="vignette" />
|
||||
<div className="scanlines" />
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function motionBorder() {
|
||||
return (
|
||||
<>
|
||||
<span className="absolute top-8 left-6 w-12 h-12 border-l-2 border-t-2 border-wormhole-violet/50 rounded-tl" />
|
||||
<span className="absolute top-8 right-6 w-12 h-12 border-r-2 border-t-2 border-wormhole-violet/50 rounded-tr" />
|
||||
<span className="absolute bottom-16 left-6 w-16 h-10 border-l-2 border-b-2 border-star-400/25 rounded-bl" />
|
||||
<span className="absolute bottom-16 right-6 w-16 h-10 border-r-2 border-b-2 border-star-400/25 rounded-br" />
|
||||
</>
|
||||
);
|
||||
}
|
||||
import type { KeyboardEvent, ReactNode } from "react";
|
||||
import type { Orbit, Snapshot } from "../../api";
|
||||
import { formatBytes, formatWhen, orbitStatus, schedulePhrase } from "../../lib/format";
|
||||
|
||||
export function TelemetryStrip({
|
||||
status,
|
||||
online,
|
||||
snapCount,
|
||||
totalBytes,
|
||||
orbitCount, failedCount, snapCount, totalBytes,
|
||||
}: {
|
||||
status: VaultStatus;
|
||||
online: boolean;
|
||||
snapCount: number;
|
||||
orbitCount?: number;
|
||||
failedCount: number;
|
||||
snapCount?: number;
|
||||
totalBytes: number;
|
||||
}) {
|
||||
return (
|
||||
<div className="pointer-events-none absolute top-12 left-4 right-4 flex justify-between items-start gap-2 text-[11px] font-mono">
|
||||
<div className="flex items-center gap-2 bg-space-950/50 backdrop-blur-sm border border-space-700/50 rounded px-2 py-1">
|
||||
<StatusDot status={online ? status : "grey"} size="sm" />
|
||||
<span className="text-star-300">{online ? "LINK OK" : "NO LINK"}</span>
|
||||
</div>
|
||||
<div className="text-right text-star-400/90 bg-space-950/40 px-2 py-1 rounded border border-space-800/40">
|
||||
<div>TILES {snapCount}</div>
|
||||
<div className="text-[10px] opacity-70">{formatBytes(totalBytes)} mass</div>
|
||||
</div>
|
||||
</div>
|
||||
<dl className="vault-telemetry">
|
||||
<div><dt>Orbits</dt><dd>{orbitCount ?? "—"}</dd></div>
|
||||
<div><dt>Failed</dt><dd className={failedCount ? "telemetry-alert" : ""}>{orbitCount === undefined ? "—" : failedCount}</dd></div>
|
||||
<div><dt>Snapshots</dt><dd>{snapCount ?? "—"}</dd></div>
|
||||
<div><dt>Payload</dt><dd>{snapCount === undefined ? "—" : formatBytes(totalBytes)}</dd></div>
|
||||
</dl>
|
||||
);
|
||||
}
|
||||
|
||||
export function SnapshotsMiniList({
|
||||
snapshots,
|
||||
selected,
|
||||
onSelect,
|
||||
export function OrbitRegister({
|
||||
orbits, selected, message, onSelect, onManage,
|
||||
}: {
|
||||
snapshots: Snapshot[];
|
||||
selected: string | null;
|
||||
orbits: Orbit[];
|
||||
selected?: string;
|
||||
message?: string;
|
||||
onSelect: (id: string) => void;
|
||||
onManage: () => void;
|
||||
}) {
|
||||
if (!snapshots.length) return null;
|
||||
const active = orbits.some(({ id }) => id === selected) ? selected : orbits[0]?.id;
|
||||
|
||||
function moveFocus(event: KeyboardEvent<HTMLButtonElement>, index: number) {
|
||||
const next = { ArrowUp: index - 1, ArrowDown: index + 1, Home: 0, End: orbits.length - 1 }[event.key];
|
||||
if (next === undefined) return;
|
||||
event.preventDefault();
|
||||
const target = orbits[Math.min(orbits.length - 1, Math.max(0, next))];
|
||||
onSelect(target.id);
|
||||
document.getElementById(`register-${target.id}`)?.focus();
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="pointer-events-auto absolute left-4 bottom-24 max-w-[140px] space-y-1">
|
||||
{snapshots.slice(0, 4).map((s, i) => (
|
||||
<button
|
||||
key={s.id}
|
||||
type="button"
|
||||
onClick={() => onSelect(s.id)}
|
||||
className={`w-full text-left text-[10px] font-mono px-2 py-1 rounded border transition-colors ${
|
||||
selected === s.id
|
||||
? "border-orbit-green/60 bg-orbit-green/10 text-orbit-green"
|
||||
: "border-space-700/50 bg-space-950/60 text-star-400 hover:border-star-400/40"
|
||||
}`}
|
||||
>
|
||||
{String(i + 1).padStart(2, "0")} · {s.orbit_name.slice(0, 12)}
|
||||
<section className="vault-console orbit-register" aria-labelledby="register-title">
|
||||
<header className="console-heading">
|
||||
<p className="instrument-label">Flight register</p>
|
||||
<h2 id="register-title">Orbits</h2>
|
||||
</header>
|
||||
{message && <p className="console-empty" role="status">{message}</p>}
|
||||
<ul className="register-list">
|
||||
{orbits.map((orbit, index) => {
|
||||
const status = orbitStatus(orbit.last_status);
|
||||
return (
|
||||
<li key={orbit.id}>
|
||||
<button
|
||||
type="button"
|
||||
id={`register-${orbit.id}`}
|
||||
className="register-row"
|
||||
aria-pressed={selected === orbit.id}
|
||||
tabIndex={active === orbit.id ? 0 : -1}
|
||||
onClick={() => onSelect(orbit.id)}
|
||||
onKeyDown={(event) => moveFocus(event, index)}
|
||||
>
|
||||
<span className={`register-signal signal-${status.tone}`} aria-hidden="true" />
|
||||
<span className="register-content">
|
||||
<span title={orbit.name}>{orbit.name}</span>
|
||||
<small>{orbit.provider}</small>
|
||||
</span>
|
||||
<span className={`register-state tone-${status.tone}`}>{status.label}</span>
|
||||
</button>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
<div className="console-bottom">
|
||||
<button type="button" className="console-control" onClick={onManage}>
|
||||
{orbits.length ? "Manage orbits" : "Set up an orbit"} <span aria-hidden="true">↗</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
export function OrbitInspector({
|
||||
orbit, snapshots, snapshotMessage, capture, onSelectSnapshot,
|
||||
}: {
|
||||
orbit?: Orbit;
|
||||
snapshots: Snapshot[];
|
||||
snapshotMessage?: string;
|
||||
capture?: ReactNode;
|
||||
onSelectSnapshot: (id: string) => void;
|
||||
}) {
|
||||
const status = orbitStatus(orbit?.last_status ?? "idle");
|
||||
return (
|
||||
<section className="vault-console orbit-inspector" aria-labelledby="inspector-title">
|
||||
<header className="console-heading">
|
||||
<p className="instrument-label">Orbit detail</p>
|
||||
<h2 id="inspector-title">{orbit?.name ?? "Select an orbit"}</h2>
|
||||
{orbit && <p className={`inspector-state tone-${status.tone}`}><span className={`register-signal signal-${status.tone}`} />{status.label}</p>}
|
||||
</header>
|
||||
{orbit ? (
|
||||
<>
|
||||
<p className="inspector-schedule">{schedulePhrase(orbit.schedule, orbit.dry_run)}</p>
|
||||
<div className="inspector-capture">{capture}</div>
|
||||
<section className="inspector-history" aria-labelledby="history-title">
|
||||
<header>
|
||||
<h3 id="history-title">Snapshot history</h3>
|
||||
<span>{snapshots.length.toString().padStart(2, "0")}</span>
|
||||
</header>
|
||||
{snapshotMessage && <p className="console-empty" role="status">{snapshotMessage}</p>}
|
||||
<ul>
|
||||
{snapshots.map((snapshot, index) => (
|
||||
<li key={snapshot.id}>
|
||||
<button id={`snapshot-${snapshot.id}`} type="button" className="snapshot-row" onClick={() => onSelectSnapshot(snapshot.id)}>
|
||||
<span className="snapshot-glyph" aria-hidden="true">◇</span>
|
||||
<span>
|
||||
<strong>{formatWhen(snapshot.taken_at)}</strong>
|
||||
<small>{formatBytes(snapshot.size_bytes)}{index === 0 ? " · Latest" : ""}</small>
|
||||
</span>
|
||||
<span className="snapshot-arrow" aria-hidden="true">›</span>
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
</>
|
||||
) : (
|
||||
<p className="console-empty">Choose a star on the map or an orbit in the register to inspect its status and recovery points.</p>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,96 +1,54 @@
|
||||
import { motion, AnimatePresence } from "motion/react";
|
||||
import type { ReactNode } from "react";
|
||||
import { useId, useLayoutEffect, useRef, type ReactNode } from "react";
|
||||
|
||||
export function HUDPanel({
|
||||
open,
|
||||
title,
|
||||
subtitle,
|
||||
onClose,
|
||||
children,
|
||||
side = "right",
|
||||
open, title, subtitle, onClose, children,
|
||||
}: {
|
||||
open: boolean;
|
||||
title: string;
|
||||
subtitle?: string;
|
||||
onClose: () => void;
|
||||
children: ReactNode;
|
||||
side?: "left" | "right" | "bottom";
|
||||
}) {
|
||||
const pos =
|
||||
side === "left"
|
||||
? "left-0 top-12 bottom-20 w-[min(100%,380px)] border-r"
|
||||
: side === "bottom"
|
||||
? "inset-x-0 bottom-20 top-auto max-h-[55dvh] border-t"
|
||||
: "right-0 top-12 bottom-20 w-[min(100%,400px)] border-l";
|
||||
const dialog = useRef<HTMLDialogElement>(null);
|
||||
const heading = useRef<HTMLHeadingElement>(null);
|
||||
const labelId = useId();
|
||||
const descriptionId = useId();
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const panel = dialog.current;
|
||||
if (!open || !panel) return;
|
||||
panel.showModal();
|
||||
return () => panel.close();
|
||||
}, [open]);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (open) heading.current?.focus();
|
||||
}, [open, title]);
|
||||
|
||||
return (
|
||||
<AnimatePresence>
|
||||
{open && (
|
||||
<>
|
||||
<motion.button
|
||||
type="button"
|
||||
aria-label="Dismiss overlay"
|
||||
className="fixed inset-0 z-40 bg-space-950/50 backdrop-blur-[2px]"
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
exit={{ opacity: 0 }}
|
||||
onClick={onClose}
|
||||
/>
|
||||
<motion.aside
|
||||
className={`fixed z-50 ${pos} border-wormhole-violet/20 bg-space-900/92 backdrop-blur-xl overflow-y-auto scrollbar-none`}
|
||||
initial={{ opacity: 0, x: side === "right" ? 40 : side === "left" ? -40 : 0, y: side === "bottom" ? 40 : 0 }}
|
||||
animate={{ opacity: 1, x: 0, y: 0 }}
|
||||
exit={{ opacity: 0, x: side === "right" ? 20 : 0, y: side === "bottom" ? 20 : 0 }}
|
||||
transition={{ type: "spring", damping: 26, stiffness: 280 }}
|
||||
>
|
||||
<header className="sticky top-0 bg-space-900/95 border-b border-space-700/60 px-4 py-3 flex items-start justify-between gap-3">
|
||||
<div>
|
||||
<p className="text-[10px] font-mono text-wormhole-violet tracking-widest uppercase">
|
||||
Console
|
||||
</p>
|
||||
<h2 className="text-lg font-semibold text-star-100">{title}</h2>
|
||||
{subtitle && <p className="text-xs text-star-400 mt-0.5">{subtitle}</p>}
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="font-mono text-xs text-star-400 border border-space-700 rounded px-2 py-1 hover:text-star-200"
|
||||
>
|
||||
ESC
|
||||
</button>
|
||||
</header>
|
||||
<div className="p-4 pb-8">{children}</div>
|
||||
</motion.aside>
|
||||
</>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
);
|
||||
}
|
||||
|
||||
export function SceneAction({
|
||||
label,
|
||||
onClick,
|
||||
disabled,
|
||||
variant = "primary",
|
||||
}: {
|
||||
label: string;
|
||||
onClick: () => void;
|
||||
disabled?: boolean;
|
||||
variant?: "primary" | "ghost";
|
||||
}) {
|
||||
return (
|
||||
<motion.button
|
||||
type="button"
|
||||
disabled={disabled}
|
||||
onClick={onClick}
|
||||
className={`pointer-events-auto font-mono text-xs tracking-wide px-5 py-2.5 rounded border ${
|
||||
variant === "primary"
|
||||
? "border-orbit-green/50 text-orbit-green bg-orbit-green/10 hover:bg-orbit-green/20"
|
||||
: "border-star-400/30 text-star-300 bg-space-950/60"
|
||||
} disabled:opacity-40`}
|
||||
whileTap={{ scale: 0.97 }}
|
||||
<dialog
|
||||
ref={dialog}
|
||||
className="vault-dialog"
|
||||
aria-labelledby={labelId}
|
||||
aria-describedby={subtitle ? descriptionId : undefined}
|
||||
onCancel={(event) => {
|
||||
event.preventDefault();
|
||||
onClose();
|
||||
}}
|
||||
>
|
||||
{label}
|
||||
</motion.button>
|
||||
{open && (
|
||||
<header className="dialog-heading">
|
||||
<div>
|
||||
<p className="instrument-label">Vault console</p>
|
||||
<h2 id={labelId} ref={heading} tabIndex={-1}>{title}</h2>
|
||||
{subtitle && <p id={descriptionId}>{subtitle}</p>}
|
||||
</div>
|
||||
<button type="button" className="console-control" onClick={onClose}>
|
||||
Close <span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</header>
|
||||
)}
|
||||
<div className="dialog-content">{children}</div>
|
||||
</dialog>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,60 +1,31 @@
|
||||
import { motion } from "motion/react";
|
||||
export type HUDMode = "scene" | "orbits" | "wormhole" | "decay" | "reconstitute" | "snapshot";
|
||||
|
||||
export type HUDMode = "scene" | "orbits" | "wormhole" | "decay" | "reconstitute";
|
||||
|
||||
const items: { id: HUDMode; label: string; glyph: string; hint: string }[] = [
|
||||
{ id: "scene", label: "Viewport", glyph: "◎", hint: "Vault ring" },
|
||||
{ id: "orbits", label: "Orbits", glyph: "⟳", hint: "Flight paths" },
|
||||
{ id: "wormhole", label: "Wormhole", glyph: "◉", hint: "Outpost link" },
|
||||
{ id: "decay", label: "Decay", glyph: "◇", hint: "Fade policy" },
|
||||
{ id: "reconstitute", label: "Restore", glyph: "↩", hint: "Reconstitute" },
|
||||
];
|
||||
const items = [
|
||||
{ id: "scene", label: "Vault" },
|
||||
{ id: "orbits", label: "Orbits" },
|
||||
{ id: "wormhole", label: "Outposts" },
|
||||
{ id: "decay", label: "Retention" },
|
||||
{ id: "reconstitute", label: "Restore" },
|
||||
] as const;
|
||||
|
||||
export function HUDRail({
|
||||
active,
|
||||
onSelect,
|
||||
capturing,
|
||||
active, onSelect,
|
||||
}: {
|
||||
active: HUDMode;
|
||||
onSelect: (m: HUDMode) => void;
|
||||
capturing?: boolean;
|
||||
onSelect: (mode: HUDMode) => void;
|
||||
}) {
|
||||
return (
|
||||
<nav
|
||||
className="pointer-events-auto absolute bottom-6 left-1/2 -translate-x-1/2 z-30 flex gap-1 px-2 py-1.5 rounded-full border border-wormhole-violet/25 bg-space-950/75 backdrop-blur-xl shadow-[0_0_40px_rgba(5,6,15,0.8)]"
|
||||
aria-label="Ship systems"
|
||||
>
|
||||
{items.map((item) => {
|
||||
const on = active === item.id;
|
||||
return (
|
||||
<motion.button
|
||||
key={item.id}
|
||||
type="button"
|
||||
title={item.hint}
|
||||
onClick={() => onSelect(item.id)}
|
||||
className={`relative px-3 py-2 rounded-full text-xs font-mono transition-colors ${
|
||||
on
|
||||
? "text-wormhole-violet bg-wormhole-violet/15"
|
||||
: "text-star-400 hover:text-star-200"
|
||||
}`}
|
||||
whileTap={{ scale: 0.94 }}
|
||||
>
|
||||
<span className="sr-only">{item.label}</span>
|
||||
<span aria-hidden className="text-sm">
|
||||
{item.glyph}
|
||||
</span>
|
||||
{on && (
|
||||
<motion.span
|
||||
layoutId="hud-pip"
|
||||
className="absolute -bottom-1 left-1/2 w-1 h-1 -translate-x-1/2 rounded-full bg-orbit-green"
|
||||
/>
|
||||
)}
|
||||
{item.id === "orbits" && capturing && (
|
||||
<span className="absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-orbit-amber animate-pulse" />
|
||||
)}
|
||||
</motion.button>
|
||||
);
|
||||
})}
|
||||
<nav className="vault-nav" aria-label="Vault systems">
|
||||
{items.map(({ id, label }) => (
|
||||
<button
|
||||
key={id}
|
||||
type="button"
|
||||
onClick={() => onSelect(id)}
|
||||
aria-current={active === id ? "page" : undefined}
|
||||
>
|
||||
{label}
|
||||
</button>
|
||||
))}
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
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>
|
||||
);
|
||||
}
|
||||
@@ -1,19 +1,26 @@
|
||||
import { useState } from "react";
|
||||
import { useState, type ReactNode } 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 { createOrbit } from "../../api";
|
||||
import { DECAY_PRESETS, orbitStatus, 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[] }) {
|
||||
export function OrbitsView({
|
||||
orbits, onRun, captureDisabled, notice,
|
||||
}: {
|
||||
orbits: Orbit[];
|
||||
onRun: (orbit: Orbit) => void;
|
||||
captureDisabled: boolean;
|
||||
notice?: ReactNode;
|
||||
}) {
|
||||
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 [preset, setPreset] = useState<string>(DECAY_PRESETS[0].id);
|
||||
const [rehearse, setRehearse] = useState(false);
|
||||
const [schedule, setSchedule] = useState("0 2 * * *");
|
||||
|
||||
@@ -33,19 +40,9 @@ export function OrbitsView({ orbits }: { orbits: Orbit[] }) {
|
||||
},
|
||||
});
|
||||
|
||||
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>
|
||||
{notice}
|
||||
|
||||
<div className="space-y-3 mb-6">
|
||||
{orbits.map((o) => (
|
||||
@@ -57,6 +54,7 @@ export function OrbitsView({ orbits }: { orbits: Orbit[] }) {
|
||||
<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-sm text-star-300">{orbitStatus(o.last_status).label}</p>
|
||||
<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">
|
||||
@@ -69,10 +67,10 @@ export function OrbitsView({ orbits }: { orbits: Orbit[] }) {
|
||||
<Button
|
||||
variant="success"
|
||||
className="flex-1 text-xs py-2"
|
||||
disabled={run.isPending || o.last_status === "running"}
|
||||
onClick={() => run.mutate(o.id)}
|
||||
disabled={captureDisabled || orbitStatus(o.last_status).busy}
|
||||
onClick={() => onRun(o)}
|
||||
>
|
||||
Capture now
|
||||
{o.dry_run ? "Rehearse" : "Capture now"}
|
||||
</Button>
|
||||
</div>
|
||||
<TelemetryPanel>
|
||||
@@ -130,6 +128,7 @@ export function OrbitsView({ orbits }: { orbits: Orbit[] }) {
|
||||
<Hint>
|
||||
Rehearse orbits prove the path without writing to the vault — status shows amber “rehearsed”.
|
||||
</Hint>
|
||||
{create.isError && <p role="alert" className="text-sm text-orbit-red">The orbit could not be saved.</p>}
|
||||
<div className="flex gap-2">
|
||||
<Button className="flex-1" onClick={() => setEditing(false)}>
|
||||
Cancel
|
||||
@@ -152,5 +151,3 @@ export function OrbitsView({ orbits }: { orbits: Orbit[] }) {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// fix motion.collapse - use div
|
||||
@@ -1,5 +1,4 @@
|
||||
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";
|
||||
@@ -14,6 +13,7 @@ export function ReconstituteWizard({
|
||||
onStart,
|
||||
onPoll,
|
||||
onAbort,
|
||||
onBusyChange,
|
||||
}: {
|
||||
snapshots: Snapshot[];
|
||||
selected: string | null;
|
||||
@@ -23,35 +23,55 @@ export function ReconstituteWizard({
|
||||
}>;
|
||||
onPoll: (id: string) => Promise<{ state: string; seconds_remaining: number }>;
|
||||
onAbort: (id: string) => Promise<void>;
|
||||
onBusyChange: (busy: boolean) => 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 [action, setAction] = useState<"starting" | "aborting">();
|
||||
const [error, setError] = useState<string>();
|
||||
const [reconnecting, setReconnecting] = useState(false);
|
||||
|
||||
const snap = snapshots.find((s) => s.id === snapId);
|
||||
const inCountdown = state === "countdown" || state === "confirming";
|
||||
const busy = !!action || inCountdown || state === "restoring";
|
||||
|
||||
useEffect(() => { onBusyChange(busy); }, [busy, onBusyChange]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!sessionId) return;
|
||||
const t = setInterval(async () => {
|
||||
let cancelled = false;
|
||||
let timer: number;
|
||||
const poll = async () => {
|
||||
try {
|
||||
const s = await onPoll(sessionId);
|
||||
if (cancelled) return;
|
||||
setReconnecting(false);
|
||||
setState(s.state);
|
||||
setRemaining(s.seconds_remaining ?? 0);
|
||||
if (["completed", "aborted", "failed", "unavailable"].includes(s.state)) {
|
||||
setAction(undefined);
|
||||
return;
|
||||
}
|
||||
} catch {
|
||||
/* hub may clear session */
|
||||
if (cancelled) return;
|
||||
setReconnecting(true);
|
||||
}
|
||||
}, 400);
|
||||
return () => clearInterval(t);
|
||||
timer = window.setTimeout(poll, 400);
|
||||
};
|
||||
timer = window.setTimeout(poll, 400);
|
||||
return () => {
|
||||
cancelled = true;
|
||||
clearTimeout(timer);
|
||||
};
|
||||
}, [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.
|
||||
Choose a snapshot and a destination on the hub.
|
||||
</p>
|
||||
|
||||
{snap && (
|
||||
@@ -67,11 +87,11 @@ export function ReconstituteWizard({
|
||||
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"}
|
||||
disabled={busy}
|
||||
>
|
||||
{snapshots.map((s) => (
|
||||
<option key={s.id} value={s.id}>
|
||||
{s.orbit_name} — {new Date(s.taken_at).toLocaleDateString()}
|
||||
{s.orbit_name} · {formatWhen(s.taken_at)} · {formatBytes(s.size_bytes)}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
@@ -83,15 +103,13 @@ export function ReconstituteWizard({
|
||||
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"}
|
||||
disabled={busy}
|
||||
/>
|
||||
</label>
|
||||
|
||||
{inCountdown && (
|
||||
<motion.div
|
||||
<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">
|
||||
@@ -114,33 +132,57 @@ export function ReconstituteWizard({
|
||||
<p className="mt-3 text-orbit-amber text-sm font-medium">
|
||||
Reconstituting in {remaining}s — abort restores nothing.
|
||||
</p>
|
||||
</motion.div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
variant="danger"
|
||||
className="flex-1"
|
||||
disabled={!sessionId || state === "completed"}
|
||||
onClick={() => sessionId && onAbort(sessionId)}
|
||||
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 restore. Check the current session status.");
|
||||
}
|
||||
}}
|
||||
>
|
||||
Abort
|
||||
</Button>
|
||||
<Button
|
||||
variant="warn"
|
||||
className="flex-1"
|
||||
disabled={!snapId || inCountdown || state === "restoring"}
|
||||
disabled={!snap || !target.trim() || busy}
|
||||
onClick={async () => {
|
||||
const res = await onStart(snapId, target);
|
||||
setSessionId(res.session_id);
|
||||
setState(res.session.state);
|
||||
setRemaining(res.session.seconds_remaining);
|
||||
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 the restore.");
|
||||
} finally {
|
||||
setAction(undefined);
|
||||
}
|
||||
}}
|
||||
>
|
||||
Begin reconstitute
|
||||
Begin restore
|
||||
</Button>
|
||||
</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 restore session…</p>}
|
||||
{state === "restoring" && <p role="status" className="text-orbit-amber text-sm">Restoring snapshot…</p>}
|
||||
{state === "unavailable" && (
|
||||
<p role="alert" className="text-orbit-red text-sm">The hub no longer has this restore session. Check the destination before retrying.</p>
|
||||
)}
|
||||
{state === "completed" && (
|
||||
<p className="text-orbit-green text-sm text-center">Reconstitute complete.</p>
|
||||
)}
|
||||
@@ -151,7 +193,7 @@ export function ReconstituteWizard({
|
||||
<p className="text-orbit-red text-sm text-center">Reconstitute failed — check telemetry.</p>
|
||||
)}
|
||||
|
||||
<Hint>Destructive-capable. Evidence above is what we'll write to disk after the timer.</Hint>
|
||||
<Hint>The hub writes after the countdown. An existing file at the destination may be overwritten.</Hint>
|
||||
|
||||
{sessionId && (
|
||||
<TelemetryPanel label="Session">
|
||||
|
||||
@@ -1,283 +1,203 @@
|
||||
import { useEffect, useMemo, useRef, useState, type RefObject } from "react";
|
||||
import type { Orbit } from "../../api";
|
||||
import { useCallback, useLayoutEffect, useMemo, useRef, useState } from "react";
|
||||
import type { Orbit, Snapshot } from "../../api";
|
||||
import { orbitStatus } from "../../lib/format";
|
||||
import { LABEL_HEIGHT, placeLabels, type Rect } from "../../lib/galaxyLabelLayout";
|
||||
import {
|
||||
assignShells,
|
||||
shellPose,
|
||||
spiralPoint,
|
||||
type Vec2,
|
||||
assignOrbitSlots, moonPoses, orbitCapacity, orbitPose, orbitRadii, ORBIT_TILT,
|
||||
SCENE_HEIGHT, SCENE_WIDTH, spiralPoint, type Vec2,
|
||||
} from "../../lib/galaxyLayout";
|
||||
import { useGalaxyTime } from "../../hooks/useGalaxyMotion";
|
||||
import { useGalaxyMotion } from "../../hooks/useGalaxyMotion";
|
||||
import { VaultCore } from "./VaultCore";
|
||||
|
||||
const METEOR_MS = 2600;
|
||||
export type CaptureArrival = { orbitId: string; snapshotId: string };
|
||||
|
||||
function shorten(name: string) {
|
||||
return name.length > 16 ? `${name.slice(0, 14)}…` : name;
|
||||
}
|
||||
type Props = {
|
||||
orbits: Orbit[];
|
||||
selectedOrbitId?: string;
|
||||
recentSnapshots: Snapshot[];
|
||||
flowing: boolean;
|
||||
arrival?: CaptureArrival;
|
||||
onSelectOrbit: (id: string) => void;
|
||||
onSelectSnapshot: (id: string) => void;
|
||||
};
|
||||
|
||||
const HALF_WIDTH = SCENE_WIDTH / 2;
|
||||
const HALF_HEIGHT = SCENE_HEIGHT / 2;
|
||||
const labelFont = "500 11px ui-monospace, monospace";
|
||||
const MAX_LABELS = 12;
|
||||
const METEOR_SECONDS = 1.4;
|
||||
|
||||
export function BlackholeGalaxy({
|
||||
orbits,
|
||||
flowing,
|
||||
capturing,
|
||||
capturePulse = 0,
|
||||
onToggleFlow,
|
||||
onSelectOrbit,
|
||||
}: {
|
||||
orbits: Orbit[];
|
||||
snapshots?: unknown;
|
||||
flowing: boolean;
|
||||
capturing?: boolean;
|
||||
capturePulse?: number;
|
||||
onToggleFlow: () => void;
|
||||
onSelectSnapshot?: (id: string) => void;
|
||||
onSelectOrbit: (id: string) => void;
|
||||
selectedSnapshotId?: string | null;
|
||||
}) {
|
||||
const t = useGalaxyTime(!flowing);
|
||||
const shells = useMemo(() => assignShells(orbits.length), [orbits.length]);
|
||||
orbits, selectedOrbitId, recentSnapshots, flowing, arrival, onSelectOrbit, onSelectSnapshot,
|
||||
}: Props) {
|
||||
const frame = useRef<HTMLDivElement>(null);
|
||||
const bodyNodes = useRef(new Map<SVGGElement, { id: string; far: boolean }>());
|
||||
const slotsBefore = useRef<ReturnType<typeof assignOrbitSlots>>(undefined);
|
||||
const elapsed = useRef(0);
|
||||
const meteor = useRef<{ id: string; time: number; source: Vec2 }>(undefined);
|
||||
const trail = useRef<SVGPathElement>(null);
|
||||
const head = useRef<SVGCircleElement>(null);
|
||||
const effect = useRef<SVGGElement>(null);
|
||||
const [width, setWidth] = useState(0);
|
||||
|
||||
const poses = shells.map((body) => shellPose(body, t));
|
||||
const poseRef = useRef(poses);
|
||||
poseRef.current = poses;
|
||||
const meteor = useMeteor(capturePulse, poseRef);
|
||||
const slots = useMemo(
|
||||
() => assignOrbitSlots(orbits.map(({ id }) => id), slotsBefore.current, selectedOrbitId),
|
||||
[orbits, selectedOrbitId],
|
||||
);
|
||||
useLayoutEffect(() => { slotsBefore.current = slots; }, [slots]);
|
||||
useLayoutEffect(() => {
|
||||
const element = frame.current;
|
||||
if (!element) return;
|
||||
const measure = () => setWidth(element.clientWidth);
|
||||
const observer = new ResizeObserver(measure);
|
||||
observer.observe(element);
|
||||
measure();
|
||||
return () => observer.disconnect();
|
||||
}, []);
|
||||
|
||||
const draw = useCallback((delta: number) => {
|
||||
const moving = flowing && slots.size > 0;
|
||||
if (moving) elapsed.current += delta;
|
||||
for (const [node, { id, far }] of bodyNodes.current) {
|
||||
const slot = slots.get(id);
|
||||
if (!slot) continue;
|
||||
const { x, y } = orbitPose(slot, elapsed.current);
|
||||
const visible = far === (y < 0);
|
||||
const display = visible ? "" : "none";
|
||||
if (node.style.display !== display) node.style.display = display;
|
||||
if (!visible) continue;
|
||||
node.setAttribute("transform", `translate(${x} ${y})`);
|
||||
}
|
||||
|
||||
if (!arrival) {
|
||||
effect.current?.setAttribute("opacity", "0");
|
||||
return moving;
|
||||
}
|
||||
const slot = slots.get(arrival.orbitId);
|
||||
if (meteor.current?.id !== arrival.snapshotId && slot) {
|
||||
const source = orbitPose(slot, elapsed.current);
|
||||
meteor.current = { id: arrival.snapshotId, time: 0, source };
|
||||
const points = Array.from({ length: 36 }, (_, i) => spiralPoint(source, i / 35));
|
||||
trail.current?.setAttribute("d", points.map(({ x, y }, i) => `${i ? "L" : "M"} ${x} ${y}`).join(" "));
|
||||
}
|
||||
const current = meteor.current;
|
||||
if (!current || current.id !== arrival.snapshotId) return moving;
|
||||
current.time += delta;
|
||||
const progress = Math.min(1, current.time / METEOR_SECONDS);
|
||||
const { x, y } = spiralPoint(current.source, progress);
|
||||
head.current?.setAttribute("cx", String(x));
|
||||
head.current?.setAttribute("cy", String(y));
|
||||
trail.current?.setAttribute("stroke-dashoffset", String(0.2 - progress));
|
||||
effect.current?.setAttribute("opacity", String(progress >= 1 ? 0 : Math.min(1, (1 - progress) * 6)));
|
||||
return moving || progress < 1;
|
||||
}, [arrival, flowing, slots]);
|
||||
|
||||
useGalaxyMotion((flowing && slots.size > 0) || !!arrival, draw);
|
||||
|
||||
const scale = width / SCENE_WIDTH;
|
||||
const height = SCENE_HEIGHT * scale;
|
||||
const hitRadius = Math.max(12, scale ? 12 / scale : 12);
|
||||
const selectedSlot = selectedOrbitId ? slots.get(selectedOrbitId) : undefined;
|
||||
const selectedPosition = !flowing && selectedSlot ? orbitPose(selectedSlot, elapsed.current) : undefined;
|
||||
const positions = !flowing ? [...slots.values()].map((slot) => orbitPose(slot, elapsed.current)) : [];
|
||||
const moons = selectedPosition
|
||||
? moonPoses(selectedPosition, recentSnapshots.length, 2 * hitRadius + 3, positions)
|
||||
: [];
|
||||
const screen = ({ x, y }: Vec2) => ({ x: (x + HALF_WIDTH) * scale, y: (y + HALF_HEIGHT) * scale });
|
||||
|
||||
const visible = orbits.filter(({ id }) => slots.has(id));
|
||||
const byPriority = (orbit: Orbit) =>
|
||||
orbit.id === selectedOrbitId ? 0 : orbit.last_status === "failed" ? 1 : orbitStatus(orbit.last_status).busy ? 2 : 3;
|
||||
const labelCandidates = [...visible].sort((a, b) => byPriority(a) - byPriority(b))
|
||||
.filter((orbit) => width >= 530 || orbit.id === selectedOrbitId)
|
||||
.slice(0, MAX_LABELS);
|
||||
const box = (point: Vec2, r: number): Rect => {
|
||||
const { x, y } = screen(point);
|
||||
return { x: x - r, y: y - r, width: r * 2, height: r * 2 };
|
||||
};
|
||||
|
||||
let labels: ReturnType<typeof placeLabels> = [];
|
||||
if (!flowing && width && labelCandidates.length) {
|
||||
const measure = document.createElement("canvas").getContext("2d");
|
||||
if (measure) measure.font = labelFont;
|
||||
const markers = positions.map((point) => box(point, 7));
|
||||
const core = box({ x: 0, y: 0 }, 65 * scale);
|
||||
labels = placeLabels(labelCandidates.map(({ id, name }) => {
|
||||
const point = screen(orbitPose(slots.get(id)!, elapsed.current));
|
||||
return { id, ...point, width: Math.min(146, Math.ceil(measure?.measureText(name).width ?? name.length * 7) + 16) };
|
||||
}), width, height, [core, ...markers, ...moons.map((moon) => box(moon, 12))]);
|
||||
}
|
||||
const focusLabel = labels.find(({ id }) => id === selectedOrbitId);
|
||||
|
||||
const renderOrbits = (far: boolean) => visible.map((orbit) => {
|
||||
const point = orbitPose(slots.get(orbit.id)!, elapsed.current);
|
||||
// Each marker switches layers when it crosses the orbital plane.
|
||||
const selected = orbit.id === selectedOrbitId;
|
||||
const status = orbitStatus(orbit.last_status);
|
||||
return (
|
||||
<g
|
||||
key={orbit.id}
|
||||
ref={(node) => {
|
||||
if (!node) return;
|
||||
bodyNodes.current.set(node, { id: orbit.id, far });
|
||||
return () => { bodyNodes.current.delete(node); };
|
||||
}}
|
||||
transform={`translate(${point.x} ${point.y})`}
|
||||
style={{ display: far === (point.y < 0) ? "" : "none" }}
|
||||
data-orbit-marker={orbit.id}
|
||||
className={`orbit-marker orbit-marker--${status.tone}${selected ? " orbit-marker--selected" : ""}`}
|
||||
>
|
||||
<circle className="orbit-halo" r={selected ? 16 : 10} />
|
||||
{status.tone === "red" && <path className="orbit-alert" d="M0 -8 8 0 0 8 -8 0Z" />}
|
||||
{status.busy && <circle className="orbit-busy" r="8.5" />}
|
||||
{selected && <circle className="orbit-selection" r="13" />}
|
||||
<circle className="orbit-light" r="4.6" />
|
||||
<circle className="orbit-hit" r={hitRadius} onClick={() => onSelectOrbit(orbit.id)} />
|
||||
</g>
|
||||
);
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="absolute inset-0 flex items-center justify-center pt-14 pb-24 px-4 pointer-events-none">
|
||||
<svg
|
||||
viewBox="-300 -300 600 600"
|
||||
className="h-full w-full max-h-[min(86dvh,920px)] max-w-[min(96vw,1100px)] pointer-events-auto"
|
||||
role="img"
|
||||
aria-label="Vault orrery"
|
||||
>
|
||||
<defs>
|
||||
<linearGradient id="diskBand" x1="0%" y1="0%" x2="100%" y2="0%">
|
||||
<stop offset="0%" stopColor="#6a3414" stopOpacity="0" />
|
||||
<stop offset="18%" stopColor="#c4622a" stopOpacity="0.55" />
|
||||
<stop offset="42%" stopColor="#ffb15e" stopOpacity="0.95" />
|
||||
<stop offset="58%" stopColor="#fff1d4" stopOpacity="1" />
|
||||
<stop offset="78%" stopColor="#ff8a3a" stopOpacity="0.85" />
|
||||
<stop offset="100%" stopColor="#6a3414" stopOpacity="0" />
|
||||
</linearGradient>
|
||||
<linearGradient id="topArc" x1="0%" y1="0%" x2="100%" y2="0%">
|
||||
<stop offset="0%" stopColor="#ff9a4a" stopOpacity="0" />
|
||||
<stop offset="50%" stopColor="#ffd7a4" stopOpacity="0.95" />
|
||||
<stop offset="100%" stopColor="#ff9a4a" stopOpacity="0" />
|
||||
</linearGradient>
|
||||
<radialGradient id="warmBody" cx="36%" cy="32%" r="68%">
|
||||
<stop offset="0%" stopColor="#fff6ea" />
|
||||
<stop offset="42%" stopColor="#ffb15a" />
|
||||
<stop offset="100%" stopColor="#c4621e" />
|
||||
</radialGradient>
|
||||
<radialGradient id="coolBody" cx="36%" cy="32%" r="68%">
|
||||
<stop offset="0%" stopColor="#ffffff" />
|
||||
<stop offset="45%" stopColor="#e7eefc" />
|
||||
<stop offset="100%" stopColor="#9aa6c4" />
|
||||
</radialGradient>
|
||||
<filter id="softGlow" x="-40%" y="-40%" width="180%" height="180%">
|
||||
<feGaussianBlur stdDeviation="2.2" />
|
||||
</filter>
|
||||
<filter id="diskGlow" x="-20%" y="-80%" width="140%" height="260%">
|
||||
<feGaussianBlur stdDeviation="1.4" />
|
||||
</filter>
|
||||
</defs>
|
||||
|
||||
<LensedHole t={t} onToggle={onToggleFlow} />
|
||||
|
||||
{shells.map((body, i) => {
|
||||
const pose = poses[i];
|
||||
const behind = pose.angle - 0.28;
|
||||
const wake = {
|
||||
x: Math.cos(behind) * body.radius,
|
||||
y: Math.sin(behind) * body.radius,
|
||||
};
|
||||
const color = body.warm ? "#ffb15a" : "#d5def4";
|
||||
<div ref={frame} className="galaxy-frame" data-flowing={flowing}>
|
||||
<svg viewBox={`${-HALF_WIDTH} ${-HALF_HEIGHT} ${SCENE_WIDTH} ${SCENE_HEIGHT}`} aria-hidden="true">
|
||||
<g className="orbit-tracks" pointerEvents="none">
|
||||
{orbitRadii.map((radius) => (
|
||||
<ellipse key={radius} rx={radius} ry={radius * ORBIT_TILT} className={selectedSlot?.radius === radius ? "is-selected" : ""} />
|
||||
))}
|
||||
</g>
|
||||
<g className="orbit-layer orbit-layer--far">{renderOrbits(true)}</g>
|
||||
<VaultCore />
|
||||
<g className="orbit-layer orbit-layer--near">{renderOrbits(false)}</g>
|
||||
{selectedPosition && moons.map(({ x, y }, index) => {
|
||||
const snapshot = recentSnapshots[index];
|
||||
return (
|
||||
<g key={orbits[i].id}>
|
||||
<line
|
||||
x1={wake.x}
|
||||
y1={wake.y}
|
||||
x2={pose.x}
|
||||
y2={pose.y}
|
||||
stroke={color}
|
||||
strokeWidth={body.warm ? 2.4 : 1.5}
|
||||
strokeLinecap="round"
|
||||
opacity={0.45}
|
||||
/>
|
||||
<circle
|
||||
cx={pose.x}
|
||||
cy={pose.y}
|
||||
r={body.size * 2.1}
|
||||
fill={color}
|
||||
opacity={0.16}
|
||||
filter="url(#softGlow)"
|
||||
/>
|
||||
<circle
|
||||
cx={pose.x}
|
||||
cy={pose.y}
|
||||
r={body.size}
|
||||
fill={body.warm ? "url(#warmBody)" : "url(#coolBody)"}
|
||||
className={!flowing ? "cursor-pointer" : undefined}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
if (!flowing) onSelectOrbit(orbits[i].id);
|
||||
}}
|
||||
/>
|
||||
{!flowing && (
|
||||
<text
|
||||
x={pose.x + Math.cos(pose.angle) * (body.size + 14)}
|
||||
y={pose.y + Math.sin(pose.angle) * (body.size + 14)}
|
||||
textAnchor="middle"
|
||||
fill="#c9d4ea"
|
||||
fontSize="10"
|
||||
className="font-mono pointer-events-none"
|
||||
>
|
||||
{shorten(orbits[i].name)}
|
||||
</text>
|
||||
)}
|
||||
<g key={snapshot.id} data-snapshot-marker={snapshot.id} className="snapshot-marker">
|
||||
<line x1={selectedPosition.x} y1={selectedPosition.y} x2={x} y2={y} />
|
||||
<rect className="snapshot-light" x={x - 4} y={y - 4} width="8" height="8" rx="1" transform={`rotate(45 ${x} ${y})`} />
|
||||
<circle className="orbit-hit" cx={x} cy={y} r={hitRadius} onClick={() => onSelectSnapshot(snapshot.id)} />
|
||||
</g>
|
||||
);
|
||||
})}
|
||||
|
||||
{meteor && <InboundMeteor source={meteor.source} u={meteor.u} />}
|
||||
{selectedPosition && focusLabel && (
|
||||
<line className="focus-leader"
|
||||
x1={selectedPosition.x} y1={selectedPosition.y}
|
||||
x2={(focusLabel.x + focusLabel.width / 2) / scale - HALF_WIDTH}
|
||||
y2={(focusLabel.y + LABEL_HEIGHT / 2) / scale - HALF_HEIGHT}
|
||||
/>
|
||||
)}
|
||||
<g ref={effect} className="capture-arrival" opacity="0" pointerEvents="none">
|
||||
<path ref={trail} pathLength="1" strokeDasharray=".2 1" fill="none" />
|
||||
<circle ref={head} r="3.5" />
|
||||
</g>
|
||||
</svg>
|
||||
<div aria-hidden="true" className="scene-labels" style={{ font: labelFont }}>
|
||||
{labels.map(({ id, x, y, width: labelWidth }) => (
|
||||
<span key={id} style={{ left: x, top: y, width: labelWidth }} className={id === selectedOrbitId ? "is-selected" : ""}>
|
||||
{labelCandidates.find((orbit) => orbit.id === id)?.name}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
{orbits.length >= orbitCapacity && <p className="scene-density">Select an orbit in the list to inspect it</p>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function LensedHole({ t, onToggle }: { t: number; onToggle: () => void }) {
|
||||
const shimmer = 0.82 + 0.18 * Math.sin(t * 0.8);
|
||||
return (
|
||||
<g>
|
||||
<ellipse
|
||||
cx="0"
|
||||
cy="0"
|
||||
rx="168"
|
||||
ry="22"
|
||||
fill="none"
|
||||
stroke="url(#diskBand)"
|
||||
strokeWidth="16"
|
||||
opacity={0.55 * shimmer}
|
||||
filter="url(#diskGlow)"
|
||||
/>
|
||||
<ellipse
|
||||
cx="18"
|
||||
cy="0"
|
||||
rx="150"
|
||||
ry="11"
|
||||
fill="none"
|
||||
stroke="url(#diskBand)"
|
||||
strokeWidth="5"
|
||||
opacity="0.95"
|
||||
/>
|
||||
<path
|
||||
d="M -120,10 Q 10,28 168,6"
|
||||
fill="none"
|
||||
stroke="url(#diskBand)"
|
||||
strokeWidth="4.5"
|
||||
strokeLinecap="round"
|
||||
opacity="0.8"
|
||||
/>
|
||||
<circle cx="0" cy="0" r="38" fill="#000" />
|
||||
<circle
|
||||
cx="0"
|
||||
cy="0"
|
||||
r="41"
|
||||
fill="none"
|
||||
stroke="#fff4e4"
|
||||
strokeWidth="1.7"
|
||||
opacity="0.95"
|
||||
/>
|
||||
<circle
|
||||
cx="0"
|
||||
cy="0"
|
||||
r="45"
|
||||
fill="none"
|
||||
stroke="#ffb15a"
|
||||
strokeWidth="3.2"
|
||||
opacity="0.55"
|
||||
/>
|
||||
<path
|
||||
d="M -108,-6 C -46,-102 46,-102 108,-6"
|
||||
fill="none"
|
||||
stroke="url(#topArc)"
|
||||
strokeWidth="10"
|
||||
strokeLinecap="round"
|
||||
opacity={0.95 * shimmer}
|
||||
filter="url(#diskGlow)"
|
||||
/>
|
||||
<circle
|
||||
cx="0"
|
||||
cy="0"
|
||||
r="48"
|
||||
fill="transparent"
|
||||
className="cursor-pointer"
|
||||
onClick={onToggle}
|
||||
/>
|
||||
</g>
|
||||
);
|
||||
}
|
||||
|
||||
function InboundMeteor({ source, u }: { source: Vec2; u: number }) {
|
||||
const head = spiralPoint(source, u);
|
||||
const samples = Array.from({ length: 14 }, (_, i) => {
|
||||
const k = u - (i / 13) * 0.42;
|
||||
return spiralPoint(source, Math.max(0, k));
|
||||
});
|
||||
const fade = u > 0.88 ? 1 - (u - 0.88) / 0.12 : 1;
|
||||
const trail = [...samples].reverse();
|
||||
const d = trail
|
||||
.map((p, i) => `${i === 0 ? "M" : "L"} ${p.x.toFixed(1)} ${p.y.toFixed(1)}`)
|
||||
.join(" ");
|
||||
return (
|
||||
<g opacity={Math.max(0, fade)} pointerEvents="none">
|
||||
<path
|
||||
d={d}
|
||||
fill="none"
|
||||
stroke="#ffb15a"
|
||||
strokeWidth="5"
|
||||
strokeLinecap="round"
|
||||
opacity="0.4"
|
||||
filter="url(#softGlow)"
|
||||
/>
|
||||
<path
|
||||
d={d}
|
||||
fill="none"
|
||||
stroke="#ffe6c4"
|
||||
strokeWidth="1.7"
|
||||
strokeLinecap="round"
|
||||
/>
|
||||
<circle cx={head.x} cy={head.y} r="4.2" fill="#fffaf3" />
|
||||
</g>
|
||||
);
|
||||
}
|
||||
|
||||
function useMeteor(
|
||||
pulse: number,
|
||||
poseRef: RefObject<{ x: number; y: number }[]>,
|
||||
) {
|
||||
const [run, setRun] = useState<{ started: number; source: Vec2 } | null>(null);
|
||||
const [now, setNow] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
if (!pulse) return;
|
||||
const live = poseRef.current?.[0];
|
||||
if (!live) return;
|
||||
setNow(0);
|
||||
setRun({ started: performance.now(), source: { x: live.x, y: live.y } });
|
||||
}, [pulse, poseRef]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!run) return;
|
||||
let raf = 0;
|
||||
const tick = () => {
|
||||
const u = (performance.now() - run.started) / METEOR_MS;
|
||||
setNow(u);
|
||||
if (u < 1) raf = requestAnimationFrame(tick);
|
||||
else setRun(null);
|
||||
};
|
||||
raf = requestAnimationFrame(tick);
|
||||
return () => cancelAnimationFrame(raf);
|
||||
}, [run]);
|
||||
|
||||
if (!run || now >= 1) return null;
|
||||
return { source: run.source, u: now };
|
||||
}
|
||||
|
||||
@@ -1,69 +1,35 @@
|
||||
import { useMemo } from "react";
|
||||
|
||||
function rand(seed: number) {
|
||||
let a = seed >>> 0;
|
||||
let state = seed >>> 0;
|
||||
return () => {
|
||||
a = (a + 0x6d2b79f5) | 0;
|
||||
let t = Math.imul(a ^ (a >>> 15), 1 | a);
|
||||
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
|
||||
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
||||
state = (Math.imul(state, 1664525) + 1013904223) >>> 0;
|
||||
return state / 2 ** 32;
|
||||
};
|
||||
}
|
||||
|
||||
/** Deep starfield and a soft dust lane. Nothing here is clickable. */
|
||||
export function SpaceBackdrop() {
|
||||
const stars = useMemo(() => {
|
||||
const next = rand(0x51e11a);
|
||||
return Array.from({ length: 170 }, (_, i) => {
|
||||
const bright = next() > 0.92;
|
||||
return {
|
||||
id: i,
|
||||
left: `${next() * 100}%`,
|
||||
top: `${next() * 100}%`,
|
||||
size: bright ? 1.7 : next() > 0.7 ? 1.15 : 0.8,
|
||||
opacity: bright ? 0.75 : 0.18 + next() * 0.38,
|
||||
warm: next() > 0.82,
|
||||
};
|
||||
});
|
||||
}, []);
|
||||
const next = rand(0x51e11a);
|
||||
const stars = Array.from({ length: 120 }, (_, id) => ({
|
||||
id,
|
||||
x: next() * 1000,
|
||||
y: next() * 650,
|
||||
radius: 0.35 + next() ** 3 * 1.05,
|
||||
opacity: 0.17 + next() * 0.48,
|
||||
}));
|
||||
|
||||
export function SpaceBackdrop() {
|
||||
return (
|
||||
<div
|
||||
className="pointer-events-none absolute inset-0 overflow-hidden select-none"
|
||||
aria-hidden
|
||||
>
|
||||
<div className="absolute inset-0 bg-[#05060c]" />
|
||||
<div className="absolute inset-0 bg-[radial-gradient(ellipse_at_center,rgba(16,18,32,0.2)_0%,rgba(5,6,12,0.92)_68%)]" />
|
||||
<div
|
||||
className="absolute left-1/2 top-1/2 h-[38vh] w-[160vw] -translate-x-1/2 -translate-y-1/2 -rotate-[24deg] opacity-70"
|
||||
style={{
|
||||
background:
|
||||
"radial-gradient(ellipse at center, rgba(90,78,70,0.28) 0%, rgba(40,34,32,0.14) 36%, transparent 68%)",
|
||||
filter: "blur(10px)",
|
||||
}}
|
||||
/>
|
||||
<div
|
||||
className="absolute left-1/2 top-1/2 h-[8vh] w-[120vw] -translate-x-1/2 -translate-y-1/2 -rotate-[16deg]"
|
||||
style={{
|
||||
background:
|
||||
"linear-gradient(90deg, transparent 0%, rgba(180,140,100,0.16) 38%, rgba(220,190,160,0.22) 52%, rgba(140,100,80,0.12) 70%, transparent 100%)",
|
||||
filter: "blur(10px)",
|
||||
}}
|
||||
/>
|
||||
{stars.map((s) => (
|
||||
<span
|
||||
key={s.id}
|
||||
className="absolute rounded-full"
|
||||
style={{
|
||||
left: s.left,
|
||||
top: s.top,
|
||||
width: s.size,
|
||||
height: s.size,
|
||||
opacity: s.opacity,
|
||||
background: s.warm ? "#f0d2b0" : "#e7ecff",
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
<div className="space-backdrop" aria-hidden="true">
|
||||
<svg width="100%" height="100%" viewBox="0 0 1000 650" preserveAspectRatio="xMidYMid slice">
|
||||
<defs>
|
||||
<radialGradient id="vault-dust">
|
||||
<stop stopColor="#6a4a36" stopOpacity=".25" />
|
||||
<stop offset="1" stopColor="#332931" stopOpacity="0" />
|
||||
</radialGradient>
|
||||
</defs>
|
||||
<ellipse cx="500" cy="328" rx="480" ry="148" fill="url(#vault-dust)" transform="rotate(-13 500 328)" />
|
||||
{stars.map(({ id, x, y, radius, opacity }) => (
|
||||
<circle key={id} cx={x} cy={y} r={radius} opacity={opacity} fill="#cbd4e4" />
|
||||
))}
|
||||
</svg>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
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>
|
||||
);
|
||||
}
|
||||
73
web/src/components/scene/VaultCore.tsx
Normal file
73
web/src/components/scene/VaultCore.tsx
Normal file
@@ -0,0 +1,73 @@
|
||||
import { memo, useId } from "react";
|
||||
|
||||
const streams = [
|
||||
{ rx: 122, ry: 19, y: 10, width: 0.7, opacity: 0.30 },
|
||||
{ rx: 116, ry: 19, y: 11, width: 1.1, opacity: 0.52 },
|
||||
{ rx: 106, ry: 17, y: 12, width: 2.4, opacity: 0.72 },
|
||||
{ rx: 92, ry: 15, y: 13, width: 3.6, opacity: 1 },
|
||||
{ rx: 79, ry: 14, y: 14, width: 2.3, opacity: 0.9 },
|
||||
{ rx: 66, ry: 12, y: 15, width: 0.9, opacity: 0.75 },
|
||||
];
|
||||
|
||||
export const VaultCore = memo(function VaultCore() {
|
||||
const id = useId();
|
||||
const paint = (name: string) => `url(#${id}-${name})`;
|
||||
return (
|
||||
<g data-vault-core pointerEvents="none">
|
||||
<defs>
|
||||
<radialGradient id={`${id}-halo`}>
|
||||
<stop stopColor="#e78347" stopOpacity=".2" />
|
||||
<stop offset=".42" stopColor="#ac572e" stopOpacity=".17" />
|
||||
<stop offset="1" stopColor="#7a3925" stopOpacity="0" />
|
||||
</radialGradient>
|
||||
<linearGradient id={`${id}-disk`}>
|
||||
<stop stopColor="#923b1d" stopOpacity="0" />
|
||||
<stop offset=".18" stopColor="#bc5f34" stopOpacity=".62" />
|
||||
<stop offset=".42" stopColor="#d47c4a" />
|
||||
<stop offset=".65" stopColor="#ffe6bb" />
|
||||
<stop offset=".82" stopColor="#ffc38a" />
|
||||
<stop offset="1" stopColor="#8b4328" stopOpacity="0" />
|
||||
</linearGradient>
|
||||
<linearGradient id={`${id}-lens`} x1="5%" y1="100%" x2="82%" y2="0%">
|
||||
<stop stopColor="#b6532d" stopOpacity=".26" />
|
||||
<stop offset=".46" stopColor="#d1885c" stopOpacity=".86" />
|
||||
<stop offset=".72" stopColor="#ffe2b3" />
|
||||
<stop offset="1" stopColor="#e49767" stopOpacity=".25" />
|
||||
</linearGradient>
|
||||
<filter id={`${id}-bloom`} x="-30%" y="-65%" width="160%" height="230%">
|
||||
<feGaussianBlur stdDeviation="4.5" />
|
||||
</filter>
|
||||
<filter id={`${id}-soft`} x="-22%" y="-70%" width="144%" height="240%">
|
||||
<feGaussianBlur stdDeviation="1.25" />
|
||||
</filter>
|
||||
</defs>
|
||||
<ellipse rx="162" ry="81" cy="6" fill={paint("halo")} />
|
||||
<g transform="rotate(-11)">
|
||||
<path
|
||||
d="M-115 12 C-68 9 -67 -66 -9 -68 C52 -71 61 -10 111 6 M-114 13 C-62 38 -28 53 13 51 C54 48 89 27 111 6"
|
||||
fill="none" stroke={paint("lens")} strokeWidth="11" opacity=".42" filter={paint("bloom")}
|
||||
/>
|
||||
<path
|
||||
d="M-115 12 C-68 9 -67 -66 -9 -68 C52 -71 61 -10 111 6"
|
||||
fill="none" stroke={paint("lens")} strokeWidth="3.4" filter={paint("soft")}
|
||||
/>
|
||||
<path
|
||||
d="M-103 12 C-59 5 -61 -61 -8 -63 C42 -66 55 -12 99 7"
|
||||
fill="none" stroke={paint("lens")} strokeWidth="1.2" opacity=".8"
|
||||
/>
|
||||
<ellipse cy="12" rx="115" ry="17" fill="none" stroke={paint("disk")} strokeWidth="6" opacity=".35" />
|
||||
<circle r="49" fill="#030405" />
|
||||
<circle r="49.6" fill="none" stroke={paint("lens")} strokeWidth="1.15" opacity=".78" />
|
||||
<path d="M-92 17 C-60 39 43 48 106 14" fill="none" stroke={paint("disk")} strokeWidth="14" opacity=".5" filter={paint("bloom")} />
|
||||
{streams.map(({ rx, ry, y, width, opacity }) => (
|
||||
<path
|
||||
key={rx}
|
||||
d={`M${-rx} ${y} A${rx} ${ry} 0 0 0 ${rx} ${y}`}
|
||||
fill="none" stroke={paint("disk")} strokeWidth={width} opacity={opacity}
|
||||
/>
|
||||
))}
|
||||
<path d="M-76 20 C-39 34 32 39 82 21" fill="none" stroke={paint("disk")} strokeWidth=".85" opacity=".7" />
|
||||
</g>
|
||||
</g>
|
||||
);
|
||||
});
|
||||
@@ -1,44 +1,60 @@
|
||||
import type { Orbit, Snapshot } from "../../api";
|
||||
import { BlackholeGalaxy, type CaptureArrival } from "./BlackholeGalaxy";
|
||||
import { SpaceBackdrop } from "./SpaceBackdrop";
|
||||
import { BlackholeGalaxy } from "./BlackholeGalaxy";
|
||||
import type { Orbit, Snapshot } from "../../api";
|
||||
|
||||
export function VaultScene({
|
||||
orbits,
|
||||
snapshots,
|
||||
flowing,
|
||||
onToggleFlow,
|
||||
onSelect,
|
||||
onSelectOrbit,
|
||||
selectedSnapshotId,
|
||||
capturing,
|
||||
capturePulse = 0,
|
||||
orbits, selectedOrbitId, recentSnapshots, flowing, reducedMotion, arrival,
|
||||
onToggleFlow, onSelectOrbit, onSelectSnapshot,
|
||||
}: {
|
||||
orbits: Orbit[];
|
||||
snapshots: Snapshot[];
|
||||
selectedOrbitId?: string;
|
||||
recentSnapshots: Snapshot[];
|
||||
flowing: boolean;
|
||||
reducedMotion: boolean;
|
||||
arrival?: CaptureArrival;
|
||||
onToggleFlow: () => void;
|
||||
onSelect: (id: string) => void;
|
||||
onSelectOrbit: (id: string) => void;
|
||||
selectedSnapshotId?: string | null;
|
||||
capturing?: boolean;
|
||||
capturePulse?: number;
|
||||
onSelectSnapshot: (id: string) => void;
|
||||
}) {
|
||||
const selected = orbits.find(({ id }) => id === selectedOrbitId);
|
||||
return (
|
||||
<div className="absolute inset-0 overflow-hidden bg-space-950">
|
||||
<section className="vault-scene" aria-label="Orbital map">
|
||||
<SpaceBackdrop />
|
||||
<div className="relative z-10 h-full w-full">
|
||||
<BlackholeGalaxy
|
||||
orbits={orbits}
|
||||
snapshots={snapshots}
|
||||
flowing={flowing}
|
||||
capturing={capturing}
|
||||
capturePulse={capturePulse}
|
||||
onToggleFlow={onToggleFlow}
|
||||
onSelectSnapshot={onSelect}
|
||||
onSelectOrbit={onSelectOrbit}
|
||||
selectedSnapshotId={selectedSnapshotId}
|
||||
/>
|
||||
<div className="scene-toolbar">
|
||||
<div>
|
||||
<p className="instrument-label">Vault map</p>
|
||||
<p className="scene-mode">
|
||||
<span className={`mode-signal${flowing ? " is-live" : ""}`} />
|
||||
{flowing ? "Flowing" : "Locked"}
|
||||
{!flowing && selected && <span className="scene-focus" title={selected.name}>· {selected.name}</span>}
|
||||
</p>
|
||||
</div>
|
||||
<button className="console-control" onClick={onToggleFlow} disabled={reducedMotion} type="button">
|
||||
<svg viewBox="0 0 16 16" width="15" height="15" aria-hidden="true">
|
||||
{flowing
|
||||
? <path d="M6 3v10M10 3v10" stroke="currentColor" strokeWidth="1.5" />
|
||||
: <path d="m6 3 7 5-7 5Z" fill="none" stroke="currentColor" strokeLinejoin="round" />}
|
||||
</svg>
|
||||
{reducedMotion ? "Reduced motion" : flowing ? "Pause motion" : "Resume motion"}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<BlackholeGalaxy
|
||||
orbits={orbits}
|
||||
selectedOrbitId={selectedOrbitId}
|
||||
recentSnapshots={recentSnapshots}
|
||||
flowing={flowing}
|
||||
arrival={arrival}
|
||||
onSelectOrbit={onSelectOrbit}
|
||||
onSelectSnapshot={onSelectSnapshot}
|
||||
/>
|
||||
<div className="scene-footer">
|
||||
<p>01 <span>·</span> Orbital projection</p>
|
||||
<div className="scene-legend" aria-label="Map legend">
|
||||
<span><i className="legend-orbit" /> Orbit</span>
|
||||
<span><i className="legend-failed" /> Failed</span>
|
||||
<span><i className="legend-snapshot" /> Snapshot</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,18 +13,16 @@ export function SnapshotSheet({
|
||||
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>.
|
||||
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>
|
||||
<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…
|
||||
Restore this snapshot
|
||||
</Button>
|
||||
<TelemetryPanel label="Snapshot ID">{snap.id}</TelemetryPanel>
|
||||
</div>
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
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-[10px] font-mono text-star-400/80 max-w-xs text-center uppercase tracking-wider">
|
||||
Select tile · stardust delta only
|
||||
</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>
|
||||
);
|
||||
}
|
||||
@@ -1,34 +1,25 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useLayoutEffect } from "react";
|
||||
|
||||
/** Seconds since mount, frozen while paused. */
|
||||
export function useGalaxyTime(paused: boolean): number {
|
||||
const [t, setT] = useState(0);
|
||||
const start = useRef(performance.now());
|
||||
const frozen = useRef(0);
|
||||
const wasPaused = useRef(paused);
|
||||
|
||||
useEffect(() => {
|
||||
if (paused) {
|
||||
frozen.current = (performance.now() - start.current) / 1000;
|
||||
wasPaused.current = true;
|
||||
return;
|
||||
}
|
||||
if (wasPaused.current) {
|
||||
start.current = performance.now() - frozen.current * 1000;
|
||||
wasPaused.current = false;
|
||||
}
|
||||
let raf = 0;
|
||||
const tick = () => {
|
||||
setT((performance.now() - start.current) / 1000);
|
||||
raf = requestAnimationFrame(tick);
|
||||
export function useGalaxyMotion(active: boolean, draw: (elapsed: number) => boolean) {
|
||||
useLayoutEffect(() => {
|
||||
let frame = 0;
|
||||
let previous: number | undefined;
|
||||
const tick = (now: number) => {
|
||||
const keepDrawing = draw(previous === undefined ? 0 : (now - previous) / 1000);
|
||||
previous = now;
|
||||
if (keepDrawing) frame = requestAnimationFrame(tick);
|
||||
};
|
||||
raf = requestAnimationFrame(tick);
|
||||
return () => cancelAnimationFrame(raf);
|
||||
}, [paused]);
|
||||
|
||||
return paused ? frozen.current : t;
|
||||
}
|
||||
|
||||
export function easeOutCubic(x: number): number {
|
||||
return 1 - Math.pow(1 - x, 3);
|
||||
const sync = () => {
|
||||
cancelAnimationFrame(frame);
|
||||
previous = undefined;
|
||||
if (!document.hidden && active) frame = requestAnimationFrame(tick);
|
||||
};
|
||||
draw(0);
|
||||
sync();
|
||||
document.addEventListener("visibilitychange", sync);
|
||||
return () => {
|
||||
cancelAnimationFrame(frame);
|
||||
document.removeEventListener("visibilitychange", sync);
|
||||
};
|
||||
}, [active, draw]);
|
||||
}
|
||||
|
||||
12
web/src/hooks/useReducedMotion.ts
Normal file
12
web/src/hooks/useReducedMotion.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { useSyncExternalStore } from "react";
|
||||
|
||||
const query = "(prefers-reduced-motion: reduce)";
|
||||
function subscribe(change: () => void) {
|
||||
const media = window.matchMedia(query);
|
||||
media.addEventListener("change", change);
|
||||
return () => media.removeEventListener("change", change);
|
||||
}
|
||||
|
||||
export function useReducedMotion() {
|
||||
return useSyncExternalStore(subscribe, () => window.matchMedia(query).matches);
|
||||
}
|
||||
@@ -2,76 +2,285 @@
|
||||
@import "tailwindcss";
|
||||
|
||||
@theme {
|
||||
--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;
|
||||
--color-space-950: #090b0e;
|
||||
--color-space-900: #111418;
|
||||
--color-space-800: #191d22;
|
||||
--color-space-700: #2b3138;
|
||||
--color-star-100: #f0f0ec;
|
||||
--color-star-200: #d9dad6;
|
||||
--color-star-300: #b6b9bc;
|
||||
--color-star-400: #9298a0;
|
||||
--color-orbit-amber: #e8b57e;
|
||||
--color-orbit-green: #8bcbb3;
|
||||
--color-orbit-red: #ffa29c;
|
||||
--color-wormhole-violet: #b4b9e1;
|
||||
--font-sans: "DM Sans", system-ui, sans-serif;
|
||||
--font-mono: "JetBrains Mono", ui-monospace, monospace;
|
||||
}
|
||||
|
||||
html {
|
||||
font-family: var(--font-sans);
|
||||
:root {
|
||||
color-scheme: dark;
|
||||
--line: #282c31;
|
||||
--quiet: #a0a6ad;
|
||||
--accent: #f1bc90;
|
||||
--panel: #111418;
|
||||
}
|
||||
|
||||
html,
|
||||
body,
|
||||
#root {
|
||||
height: 100%;
|
||||
body {
|
||||
margin: 0;
|
||||
min-width: 0;
|
||||
font-family: var(--font-sans);
|
||||
color: var(--color-star-100);
|
||||
background: var(--color-space-950);
|
||||
}
|
||||
|
||||
@layer utilities {
|
||||
.font-mono {
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
.scrollbar-none {
|
||||
scrollbar-width: none;
|
||||
}
|
||||
.scrollbar-none::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
button:enabled { cursor: pointer; }
|
||||
button:disabled { cursor: default; }
|
||||
:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
|
||||
.scrollbar-none { scrollbar-width: none; }
|
||||
|
||||
.vault-topbar {
|
||||
min-height: 70px;
|
||||
padding: 0 clamp(16px, 3vw, 44px);
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto 1fr;
|
||||
align-items: center;
|
||||
border-bottom: 1px solid var(--line);
|
||||
background: #0e1013;
|
||||
}
|
||||
|
||||
.stars-drift {
|
||||
animation: drift 120s linear infinite;
|
||||
.vault-brand { display: flex; align-items: center; gap: 11px; }
|
||||
.vault-brand svg { flex: none; color: var(--accent); }
|
||||
.vault-brand strong { display: block; font-size: 18px; font-weight: 650; line-height: 1.05; letter-spacing: -.035em; }
|
||||
.vault-brand span, .instrument-label, .vault-telemetry dt, .scene-footer, .vault-footer {
|
||||
font: 500 10px/1.5 var(--font-mono);
|
||||
letter-spacing: .105em;
|
||||
text-transform: uppercase;
|
||||
color: var(--quiet);
|
||||
}
|
||||
|
||||
@keyframes drift {
|
||||
from {
|
||||
transform: translateY(0);
|
||||
}
|
||||
to {
|
||||
transform: translateY(-120px);
|
||||
}
|
||||
.vault-brand span { display: block; margin-top: 5px; font-size: 9px; }
|
||||
.vault-nav { display: flex; align-self: stretch; gap: clamp(8px, 2vw, 27px); }
|
||||
.vault-nav button {
|
||||
position: relative;
|
||||
min-height: 44px;
|
||||
padding: 0 6px;
|
||||
color: var(--quiet);
|
||||
font-size: 13px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.vault-nav button:hover, .vault-nav button[aria-current] { color: var(--color-star-100); }
|
||||
.vault-nav button[aria-current]::after { position: absolute; inset: auto 5px -1px; height: 2px; content: ""; background: var(--accent); }
|
||||
|
||||
.hub-link { justify-self: end; display: flex; align-items: center; gap: 8px; color: var(--color-star-300); font: 500 11px var(--font-mono); white-space: nowrap; }
|
||||
.vault-main { max-width: 1720px; padding: 30px clamp(16px, 3vw, 44px) 10px; margin-inline: auto; }
|
||||
.vault-overview { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 25px; }
|
||||
.overview-label span { color: var(--accent); margin-right: 5px; }
|
||||
.vault-overview h1 { font-weight: 550; letter-spacing: -.055em; font-size: clamp(34px, 4vw, 55px); line-height: 1.02; margin: 7px 0; }
|
||||
.overview-copy { font-size: 14px; color: var(--quiet); }
|
||||
.vault-telemetry { display: grid; grid-template-columns: repeat(4, minmax(78px, auto)); border-block: 1px solid var(--line); padding-block: 10px; }
|
||||
.vault-telemetry > div { padding-inline: clamp(8px, 1.5vw, 20px); }
|
||||
.vault-telemetry > div + div { border-left: 1px solid var(--line); }
|
||||
.vault-telemetry dd { font: 500 17px/1.6 var(--font-mono); white-space: nowrap; }
|
||||
.vault-telemetry .telemetry-alert { color: var(--color-orbit-red); }
|
||||
|
||||
.vault-workspace {
|
||||
--workspace-height: clamp(480px, calc(100dvh - 288px), 760px);
|
||||
display: grid;
|
||||
grid-template-columns: minmax(190px, .91fr) minmax(0, 3.1fr) minmax(224px, 1fr);
|
||||
grid-template-areas: "register map inspector";
|
||||
gap: 12px;
|
||||
height: var(--workspace-height);
|
||||
}
|
||||
|
||||
.vignette::after {
|
||||
content: "";
|
||||
.vault-console, .vault-scene { position: relative; min-width: 0; border: 1px solid var(--line); border-radius: 10px; }
|
||||
.vault-console { background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
|
||||
.orbit-register { grid-area: register; }
|
||||
.orbit-inspector { grid-area: inspector; }
|
||||
.console-heading { padding: 17px 16px 14px; }
|
||||
.console-heading h2 { margin-top: 5px; font-weight: 600; font-size: 18px; line-height: 1.18; letter-spacing: -.025em; overflow-wrap: anywhere; }
|
||||
.orbit-register .console-heading { border-bottom: 1px solid var(--line); }
|
||||
.console-empty { padding: 0 16px; color: var(--quiet); font-size: 13px; line-height: 1.6; }
|
||||
.orbit-register > .console-empty { padding-block: 12px; }
|
||||
.register-list, .inspector-history ul { min-height: 0; overflow: auto; scrollbar-width: thin; scrollbar-color: #454952 transparent; }
|
||||
.register-list { flex: 1; }
|
||||
.register-list li + li, .inspector-history li + li { border-top: 1px solid #24282c; }
|
||||
.register-row {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
min-height: 48px;
|
||||
display: grid;
|
||||
grid-template-columns: 9px minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 7px 10px;
|
||||
text-align: left;
|
||||
}
|
||||
.register-row:hover, .snapshot-row:hover { background: #1b1e23; }
|
||||
.register-row[aria-pressed="true"] { background: #222025; box-shadow: inset 2px 0 var(--accent); }
|
||||
.register-content { min-width: 0; }
|
||||
.register-content span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
|
||||
.register-content small { display: block; margin-top: 2px; font: 10px/1.3 var(--font-mono); color: var(--quiet); }
|
||||
.register-state { font: 10px/1.3 var(--font-mono); }
|
||||
.tone-red { color: var(--color-orbit-red); }
|
||||
.tone-amber { color: var(--color-orbit-amber); }
|
||||
.tone-green { color: var(--color-orbit-green); }
|
||||
.tone-grey { color: var(--quiet); }
|
||||
.register-signal { flex: none; display: inline-block; width: 7px; height: 7px; background: var(--quiet); border-radius: 50%; }
|
||||
.signal-red { border-radius: 1px; transform: rotate(45deg); background: var(--color-orbit-red); }
|
||||
.signal-amber { background: transparent; border: 1px solid var(--color-orbit-amber); }
|
||||
.signal-green { background: var(--color-orbit-green); }
|
||||
.console-bottom { margin-top: auto; padding: 9px 10px; border-top: 1px solid var(--line); }
|
||||
.console-bottom button { width: 100%; justify-content: space-between; }
|
||||
.console-control {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-height: 44px;
|
||||
border: 1px solid #393e45;
|
||||
border-radius: 6px;
|
||||
padding: 0 11px;
|
||||
background: #16191d;
|
||||
color: var(--color-star-100);
|
||||
font-size: 12px;
|
||||
font-weight: 550;
|
||||
text-align: left;
|
||||
}
|
||||
.console-control:enabled:hover { border-color: #74777b; background: #20242a; }
|
||||
.console-control:disabled { color: var(--quiet); }
|
||||
.console-control svg { color: var(--accent); }
|
||||
.inspector-state { display: flex; align-items: center; gap: 7px; margin-top: 10px; font-size: 12px; }
|
||||
.inspector-schedule { padding: 0 16px; color: var(--quiet); font-size: 13px; }
|
||||
.inspector-capture { padding: 12px 16px 17px; }
|
||||
.inspector-capture .capture-notice { margin-top: 8px; }
|
||||
.capture-button { width: 100%; padding-block: 8px; background: #31241d; border-color: #76533d; color: #ffd0a9; }
|
||||
.capture-button span:last-child { min-width: 0; overflow-wrap: anywhere; }
|
||||
.capture-button:enabled:hover { background: #483125; border-color: var(--accent); }
|
||||
.capture-button:disabled { background: #191a1d; }
|
||||
.inspector-history { display: flex; flex-direction: column; min-height: 0; }
|
||||
.inspector-history header { display: flex; justify-content: space-between; align-items: center; border-block: 1px solid var(--line); padding: 10px 16px; }
|
||||
.inspector-history h3 { font-size: 12px; font-weight: 550; }
|
||||
.inspector-history header span { color: var(--quiet); font: 11px var(--font-mono); }
|
||||
.inspector-history .console-empty { padding-top: 10px; }
|
||||
.snapshot-row { width: 100%; min-height: 52px; display: grid; grid-template-columns: 17px minmax(0, 1fr) 12px; align-items: center; gap: 8px; padding: 7px 13px; text-align: left; }
|
||||
.snapshot-row strong { display: block; font-size: 12px; font-weight: 550; }
|
||||
.snapshot-row small { display: block; margin-top: 3px; font: 10px/1.3 var(--font-mono); color: var(--quiet); }
|
||||
.snapshot-glyph { color: #c6d2e6; font-size: 18px; }
|
||||
.snapshot-arrow { color: var(--quiet); }
|
||||
|
||||
.vault-scene {
|
||||
grid-area: map;
|
||||
isolation: isolate;
|
||||
display: grid;
|
||||
grid-template-rows: auto 1fr auto;
|
||||
background: #0a0c10;
|
||||
overflow: hidden;
|
||||
}
|
||||
.vault-scene > :not(.space-backdrop) { position: relative; }
|
||||
.space-backdrop { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
|
||||
.space-backdrop::after {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
pointer-events: none;
|
||||
box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.65);
|
||||
content: "";
|
||||
background: radial-gradient(ellipse at 48% 52%, transparent 42%, #080a0dd9 100%);
|
||||
}
|
||||
.scene-toolbar, .scene-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px; }
|
||||
.scene-toolbar { z-index: 1; }
|
||||
.scene-toolbar > div { min-width: 0; }
|
||||
.scene-toolbar button { flex: none; }
|
||||
.scene-mode { display: flex; align-items: center; gap: 7px; margin-top: 3px; font-size: 13px; }
|
||||
.mode-signal { flex: none; width: 6px; height: 6px; background: var(--accent); transform: rotate(45deg); border-radius: 1px; }
|
||||
.mode-signal.is-live { background: var(--color-orbit-green); border-radius: 50%; transform: none; }
|
||||
.scene-focus { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--quiet); }
|
||||
.scene-footer { border-top: 1px solid #24282c; background: #0a0c10bb; }
|
||||
.scene-footer > p span { color: var(--accent); }
|
||||
.scene-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; color: var(--color-star-300); }
|
||||
.scene-legend span { display: inline-flex; align-items: center; gap: 6px; }
|
||||
.scene-legend i { width: 6px; height: 6px; display: inline-block; }
|
||||
.legend-orbit { background: #dfe4ef; border-radius: 50%; }
|
||||
.legend-failed { border: 1px solid var(--color-orbit-red); transform: rotate(45deg); }
|
||||
.legend-snapshot { border: 1px solid #dfe4ef; transform: rotate(45deg); }
|
||||
.galaxy-frame { width: 100%; max-width: calc((var(--workspace-height) - 120px) * 1.375); aspect-ratio: 11 / 8; align-self: center; justify-self: center; }
|
||||
.galaxy-frame > svg { display: block; width: 100%; height: 100%; overflow: hidden; }
|
||||
.orbit-tracks { fill: none; stroke: #949eaa; stroke-width: .75; opacity: .28; }
|
||||
.orbit-tracks .is-selected { stroke: #eebf92; stroke-dasharray: 3 4; stroke-width: 1.6; }
|
||||
.orbit-marker { color: #c3c9d0; }
|
||||
.orbit-marker--red { color: var(--color-orbit-red); }
|
||||
.orbit-marker--amber { color: var(--color-orbit-amber); }
|
||||
.orbit-marker--green { color: var(--color-orbit-green); }
|
||||
.orbit-light, .orbit-halo { fill: currentColor; pointer-events: none; }
|
||||
.orbit-halo { opacity: .08; }
|
||||
.orbit-alert, .orbit-selection, .orbit-busy { fill: none; stroke: currentColor; stroke-width: 1.15; pointer-events: none; }
|
||||
.orbit-selection { stroke: #f8eadc; stroke-width: 1; }
|
||||
.orbit-busy { stroke-dasharray: 3 3; }
|
||||
.orbit-layer--far .orbit-marker:not(.orbit-marker--red, .orbit-marker--selected) { opacity: .76; }
|
||||
.orbit-hit { fill: transparent; cursor: pointer; }
|
||||
.orbit-marker:hover .orbit-halo { opacity: .3; }
|
||||
.snapshot-marker line { stroke: #bdc4ce; opacity: .58; stroke-dasharray: 2 3; pointer-events: none; }
|
||||
.snapshot-light { fill: #dce5f7; stroke: #272c35; stroke-width: 1.1; pointer-events: none; }
|
||||
.snapshot-marker:hover .snapshot-light { fill: #fff; }
|
||||
.focus-leader { stroke: var(--accent); opacity: .65; pointer-events: none; }
|
||||
.capture-arrival path { stroke: #ffce9b; stroke-width: 2.3; stroke-linecap: round; }
|
||||
.capture-arrival circle { fill: #fff0d9; }
|
||||
.scene-labels { position: absolute; inset: 0; pointer-events: none; }
|
||||
.scene-labels span { display: block; position: absolute; height: 24px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; line-height: 22px; color: #dde0e6; background: #111519ed; border: 1px solid #353c46; border-radius: 4px; padding-inline: 7px; }
|
||||
.scene-labels span.is-selected { color: #ffe5cb; border-color: #8b6349; }
|
||||
.scene-density { position: absolute; inset: auto 10px 0; color: var(--quiet); font-size: 11px; text-align: center; pointer-events: none; }
|
||||
|
||||
.vault-footer { min-height: 44px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
|
||||
.capture-notice { margin-block: 4px; font: 500 12px/1.5 var(--font-mono); color: var(--color-star-200); text-transform: none; letter-spacing: 0; }
|
||||
.capture-notice.tone-red { color: var(--color-orbit-red); }
|
||||
|
||||
.vault-dialog {
|
||||
position: fixed;
|
||||
inset: 0 0 0 auto;
|
||||
margin: 0;
|
||||
width: min(440px, 100%);
|
||||
height: 100dvh;
|
||||
max-width: none;
|
||||
max-height: none;
|
||||
overflow: auto;
|
||||
padding: 0;
|
||||
background: #121519;
|
||||
color: var(--color-star-100);
|
||||
border-left: 1px solid #3b4048;
|
||||
}
|
||||
.vault-dialog::backdrop { background: #030508b3; }
|
||||
.dialog-heading { display: flex; gap: 12px; justify-content: space-between; align-items: start; padding: 18px 20px; position: sticky; top: 0; z-index: 1; background: #121519; border-bottom: 1px solid var(--line); }
|
||||
.dialog-heading h2 { font-size: 23px; font-weight: 550; letter-spacing: -.035em; margin-top: 3px; }
|
||||
.dialog-heading h2:focus { outline: none; }
|
||||
.dialog-heading h2 + p { margin-top: 4px; color: var(--quiet); font-size: 13px; }
|
||||
.dialog-content { padding: 18px 20px; }
|
||||
|
||||
@media (max-width: 1060px) {
|
||||
.vault-workspace { grid-template-areas: "map map" "register inspector"; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); height: auto; }
|
||||
.vault-console { min-height: 240px; max-height: 420px; }
|
||||
}
|
||||
|
||||
.scanlines::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
pointer-events: none;
|
||||
opacity: 0.04;
|
||||
background: repeating-linear-gradient(
|
||||
0deg,
|
||||
transparent,
|
||||
transparent 2px,
|
||||
rgba(255, 255, 255, 0.15) 3px
|
||||
);
|
||||
@media (max-width: 640px) {
|
||||
.vault-topbar { grid-template-columns: 1fr auto; gap: 0 10px; padding-top: 11px; }
|
||||
.vault-nav { grid-row: 2; grid-column: 1 / -1; justify-content: space-between; margin-top: 7px; gap: 3px; }
|
||||
.vault-nav button { padding-inline: 5px; font-size: 12px; }
|
||||
.vault-main { padding: 19px 12px 9px; }
|
||||
.vault-overview { align-items: stretch; flex-direction: column; gap: 14px; margin-bottom: 14px; }
|
||||
.vault-telemetry { grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(76px, auto); }
|
||||
.vault-telemetry dd { font-size: 14px; }
|
||||
.vault-workspace { grid-template-areas: "map" "register" "inspector"; grid-template-columns: minmax(0, 1fr); gap: 10px; }
|
||||
.vault-console { min-height: 0; }
|
||||
.register-list { max-height: 196px; }
|
||||
.orbit-inspector { max-height: 480px; padding-bottom: 8px; }
|
||||
.orbit-inspector > .console-empty { padding-bottom: 8px; }
|
||||
.galaxy-frame { max-width: none; }
|
||||
.scene-toolbar, .scene-footer { padding: 9px; }
|
||||
.scene-footer > p { display: none; }
|
||||
.scene-footer { justify-content: center; }
|
||||
.vault-footer > p:last-child { text-align: right; }
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
*, *::before, *::after {
|
||||
animation-duration: .01ms !important;
|
||||
animation-iteration-count: 1 !important;
|
||||
transition-duration: .01ms !important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,18 @@ export function schedulePhrase(cron?: string | null, dryRun?: boolean): string {
|
||||
|
||||
export type VaultStatus = "green" | "amber" | "grey" | "red";
|
||||
|
||||
export function orbitStatus(status: string): { label: string; tone: VaultStatus; busy?: boolean } {
|
||||
switch (status) {
|
||||
case "failed": return { label: "Failed", tone: "red" };
|
||||
case "running": return { label: "Running", tone: "amber", busy: true };
|
||||
case "rehearsing": return { label: "Rehearsing", tone: "amber", busy: true };
|
||||
case "rehearsed": return { label: "Rehearsed", tone: "amber" };
|
||||
case "completed": return { label: "Completed", tone: "green" };
|
||||
case "idle": return { label: "Idle", tone: "grey" };
|
||||
default: return { label: status || "Unknown", tone: "grey" };
|
||||
}
|
||||
}
|
||||
|
||||
export function vaultStatusFromOrbits(
|
||||
orbits: { last_status: string }[],
|
||||
): VaultStatus {
|
||||
|
||||
@@ -1,137 +1,38 @@
|
||||
import type { Vec2 } from "./galaxyLayout";
|
||||
export type Rect = { x: number; y: number; width: number; height: number };
|
||||
type Label = { id: string; x: number; y: number; width: number };
|
||||
export const LABEL_HEIGHT = 24;
|
||||
const GAP = 4;
|
||||
|
||||
export type LabelPlacement = {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
|
||||
const CHAR_W = 6.4;
|
||||
const LABEL_H = 14;
|
||||
const LABEL_PAD = 6;
|
||||
|
||||
function labelWidth(name: string): number {
|
||||
const n = name.length > 16 ? 15 : name.length;
|
||||
return n * CHAR_W;
|
||||
function overlaps(a: Rect, b: Rect) {
|
||||
return a.x < b.x + b.width + GAP && a.x + a.width + GAP > b.x &&
|
||||
a.y < b.y + b.height + GAP && a.y + a.height + GAP > b.y;
|
||||
}
|
||||
|
||||
function dist(a: LabelPlacement, b: LabelPlacement): number {
|
||||
return Math.hypot(a.x - b.x, a.y - b.y);
|
||||
}
|
||||
|
||||
/** Radial outward labels with simple bbox separation (lock mode). */
|
||||
export function layoutLockLabels(
|
||||
starPositions: Vec2[],
|
||||
names: string[],
|
||||
starR: number,
|
||||
): LabelPlacement[] {
|
||||
const vaultPad = 108;
|
||||
const labels: LabelPlacement[] = starPositions.map((p, i) => {
|
||||
const ang = Math.atan2(p.y, p.x);
|
||||
const base = starR + 28;
|
||||
return {
|
||||
x: p.x + Math.cos(ang) * base,
|
||||
y: p.y + Math.sin(ang) * base,
|
||||
};
|
||||
});
|
||||
|
||||
for (let iter = 0; iter < 48; iter++) {
|
||||
for (let i = 0; i < labels.length; i++) {
|
||||
const p = starPositions[i];
|
||||
const r = dist(labels[i], { x: 0, y: 0 });
|
||||
if (r < vaultPad) {
|
||||
const ang = Math.atan2(labels[i].y, labels[i].x);
|
||||
labels[i].x = Math.cos(ang) * vaultPad;
|
||||
labels[i].y = Math.sin(ang) * vaultPad;
|
||||
}
|
||||
|
||||
for (let j = i + 1; j < labels.length; j++) {
|
||||
const wi = labelWidth(names[i]);
|
||||
const wj = labelWidth(names[j]);
|
||||
const dx = labels[j].x - labels[i].x;
|
||||
const dy = labels[j].y - labels[i].y;
|
||||
const needX = (wi + wj) / 2 + LABEL_PAD;
|
||||
const needY = LABEL_H + LABEL_PAD;
|
||||
if (Math.abs(dx) < needX && Math.abs(dy) < needY) {
|
||||
const push = (needX - Math.abs(dx) + needY - Math.abs(dy)) * 0.35;
|
||||
const ang = Math.atan2(dy, dx) || 0;
|
||||
labels[i].x -= Math.cos(ang) * push;
|
||||
labels[i].y -= Math.sin(ang) * push;
|
||||
labels[j].x += Math.cos(ang) * push;
|
||||
labels[j].y += Math.sin(ang) * push;
|
||||
}
|
||||
}
|
||||
|
||||
const outward = Math.atan2(
|
||||
labels[i].y - starPositions[i].y,
|
||||
labels[i].x - starPositions[i].x,
|
||||
);
|
||||
const minDist = starR + 26;
|
||||
const dStar = dist(labels[i], starPositions[i]);
|
||||
if (dStar < minDist) {
|
||||
labels[i].x = starPositions[i].x + Math.cos(outward) * minDist;
|
||||
labels[i].y = starPositions[i].y + Math.sin(outward) * minDist;
|
||||
export function placeLabels(
|
||||
candidates: Label[],
|
||||
width: number,
|
||||
height: number,
|
||||
obstacles: Rect[],
|
||||
): Label[] {
|
||||
const occupied = [...obstacles];
|
||||
const placed: Label[] = [];
|
||||
for (const label of candidates) {
|
||||
const { x, y, width: w } = label;
|
||||
const offsets = [12, 28, 44].flatMap((gap) => [
|
||||
[gap, -LABEL_HEIGHT / 2], [-w - gap, -LABEL_HEIGHT / 2],
|
||||
[-w / 2, -LABEL_HEIGHT - gap], [-w / 2, gap],
|
||||
[gap, -LABEL_HEIGHT - gap / 2], [-w - gap, gap / 2],
|
||||
]);
|
||||
for (const [dx, dy] of offsets) {
|
||||
const rect = { x: x + dx, y: y + dy, width: w, height: LABEL_HEIGHT };
|
||||
if (rect.x < GAP || rect.y < GAP || rect.x + w > width - GAP ||
|
||||
rect.y + LABEL_HEIGHT > height - GAP || occupied.some((other) => overlaps(rect, other))) {
|
||||
continue;
|
||||
}
|
||||
occupied.push(rect);
|
||||
placed.push({ id: label.id, ...rect });
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const yMin = -160;
|
||||
const yMax = 108;
|
||||
const xMin = -230;
|
||||
const xMax = 230;
|
||||
for (let i = 0; i < labels.length; i++) {
|
||||
const star = starPositions[i];
|
||||
const hitsChrome =
|
||||
labels[i].y < yMin ||
|
||||
labels[i].y > yMax ||
|
||||
labels[i].x < xMin ||
|
||||
labels[i].x > xMax;
|
||||
const hitsNeighbor = starPositions.some(
|
||||
(other, k) => k !== i && dist(labels[i], other) < starR + 20,
|
||||
);
|
||||
if (hitsChrome || hitsNeighbor) {
|
||||
const ang = Math.atan2(star.y, star.x);
|
||||
labels[i] = {
|
||||
x: star.x - Math.cos(ang) * (starR + 34),
|
||||
y: star.y - Math.sin(ang) * (starR + 34),
|
||||
};
|
||||
}
|
||||
labels[i].x = Math.max(xMin, Math.min(xMax, labels[i].x));
|
||||
labels[i].y = Math.max(yMin, Math.min(yMax, labels[i].y));
|
||||
const gap = dist(labels[i], star);
|
||||
if (gap < starR + 16) {
|
||||
const ang = Math.atan2(labels[i].y - star.y, labels[i].x - star.x) || 0;
|
||||
labels[i].x = star.x + Math.cos(ang) * (starR + 18);
|
||||
labels[i].y = Math.max(
|
||||
yMin,
|
||||
Math.min(yMax, star.y + Math.sin(ang) * (starR + 18)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
for (let iter = 0; iter < 24; iter++) {
|
||||
for (let i = 0; i < labels.length; i++) {
|
||||
for (let j = i + 1; j < labels.length; j++) {
|
||||
const wi = labelWidth(names[i]);
|
||||
const wj = labelWidth(names[j]);
|
||||
const dx = labels[j].x - labels[i].x;
|
||||
const dy = labels[j].y - labels[i].y;
|
||||
const needX = (wi + wj) / 2 + 8;
|
||||
const needY = LABEL_H + 6;
|
||||
if (Math.abs(dx) < needX && Math.abs(dy) < needY) {
|
||||
const push = (needX - Math.abs(dx)) * 0.55 + 1;
|
||||
const dir = dx === 0 ? (i % 2 === 0 ? -1 : 1) : Math.sign(dx);
|
||||
labels[i].x -= dir * push;
|
||||
labels[j].x += dir * push;
|
||||
}
|
||||
}
|
||||
labels[i].x = Math.max(xMin, Math.min(xMax, labels[i].x));
|
||||
labels[i].y = Math.max(yMin, Math.min(yMax, labels[i].y));
|
||||
}
|
||||
}
|
||||
|
||||
return labels;
|
||||
}
|
||||
|
||||
export function shortenOrbitName(name: string): string {
|
||||
return name.length > 16 ? `${name.slice(0, 14)}…` : name;
|
||||
return placed;
|
||||
}
|
||||
|
||||
@@ -1,68 +1,105 @@
|
||||
/** Face-on orrery: two even shells around the vault. */
|
||||
import type { Orbit, Snapshot } from "../api";
|
||||
|
||||
export type Vec2 = { x: number; y: number };
|
||||
type OrbitSlot = { radius: number; angle: number; speed: number };
|
||||
|
||||
export type ShellBody = {
|
||||
index: number;
|
||||
shell: "inner" | "outer";
|
||||
radius: number;
|
||||
baseAngle: number;
|
||||
size: number;
|
||||
warm: boolean;
|
||||
};
|
||||
export const SCENE_WIDTH = 660;
|
||||
export const SCENE_HEIGHT = 480;
|
||||
export const ORBIT_TILT = 0.68;
|
||||
|
||||
const INNER_R = 112;
|
||||
const OUTER_R = 178;
|
||||
const shells = [
|
||||
{ radius: 128, count: 10, step: 3, speed: 0.047 },
|
||||
{ radius: 190, count: 18, step: 7, speed: 0.033 },
|
||||
{ radius: 260, count: 28, step: 11, speed: 0.023 },
|
||||
];
|
||||
|
||||
/** Inner shell is fewer, larger, warmer. Outer shell is the rest. */
|
||||
export function assignShells(count: number): ShellBody[] {
|
||||
if (count <= 0) return [];
|
||||
let innerCount = Math.max(1, Math.round(count * 0.38));
|
||||
if (count > 4) innerCount = Math.max(3, innerCount);
|
||||
innerCount = Math.min(innerCount, count);
|
||||
const outerCount = count - innerCount;
|
||||
const bodies: ShellBody[] = [];
|
||||
for (let i = 0; i < innerCount; i++) {
|
||||
bodies.push({
|
||||
index: i,
|
||||
shell: "inner",
|
||||
radius: INNER_R,
|
||||
baseAngle: -Math.PI / 2 + (i / innerCount) * Math.PI * 2,
|
||||
size: 11,
|
||||
warm: true,
|
||||
});
|
||||
const slots = Array.from({ length: 28 }, (_, index) =>
|
||||
shells.flatMap(({ radius, count, step, speed }, shell) =>
|
||||
index < count
|
||||
? [{ radius, speed, angle: ((index * step) / count) * 2 * Math.PI - 1.2 + shell * 0.9 }]
|
||||
: [],
|
||||
),
|
||||
).flat();
|
||||
|
||||
export const orbitRadii = shells.map(({ radius }) => radius);
|
||||
export const orbitCapacity = slots.length;
|
||||
|
||||
export function assignOrbitSlots(
|
||||
ids: string[],
|
||||
previous = new Map<string, OrbitSlot>(),
|
||||
selected?: string,
|
||||
): Map<string, OrbitSlot> {
|
||||
const currentIds = new Set(ids);
|
||||
const next = new Map([...previous].filter(([id]) => currentIds.has(id)));
|
||||
const occupied = new Set(next.values());
|
||||
const free = slots.filter((slot) => !occupied.has(slot));
|
||||
|
||||
// shortcut: overview has a fixed number of slots, add level of detail if dense fleets need spatial navigation.
|
||||
// Reserve the final slot for inspection when the overview is full.
|
||||
const selectedSlot = slots[slots.length - 1];
|
||||
for (const [id, slot] of next) {
|
||||
if (slot === selectedSlot && id !== selected) next.delete(id);
|
||||
}
|
||||
for (let i = 0; i < outerCount; i++) {
|
||||
bodies.push({
|
||||
index: innerCount + i,
|
||||
shell: "outer",
|
||||
radius: OUTER_R,
|
||||
baseAngle: -Math.PI / 2 + ((i + 0.5) / outerCount) * Math.PI * 2,
|
||||
size: 6.4,
|
||||
warm: false,
|
||||
});
|
||||
const available = free.filter((slot) => slot !== selectedSlot);
|
||||
for (const id of ids) {
|
||||
if (next.has(id)) continue;
|
||||
const slot = available.shift();
|
||||
if (!slot) break;
|
||||
next.set(id, slot);
|
||||
}
|
||||
return bodies;
|
||||
if (selected && currentIds.has(selected) && !next.has(selected)) {
|
||||
next.set(selected, selectedSlot);
|
||||
}
|
||||
return next;
|
||||
}
|
||||
|
||||
export function shellPose(body: ShellBody, time: number): Vec2 & { angle: number } {
|
||||
const speed = body.shell === "inner" ? 0.18 : 0.11;
|
||||
const angle = body.baseAngle + time * speed;
|
||||
export function orbitPose(slot: OrbitSlot, time: number): Vec2 {
|
||||
const angle = slot.angle + time * slot.speed;
|
||||
return {
|
||||
angle,
|
||||
x: Math.cos(angle) * body.radius,
|
||||
y: Math.sin(angle) * body.radius,
|
||||
x: Math.cos(angle) * slot.radius,
|
||||
y: Math.sin(angle) * slot.radius * ORBIT_TILT,
|
||||
};
|
||||
}
|
||||
|
||||
/** Point on a smooth inward spiral. u = 0 is the source; u = 1 is the shadow. */
|
||||
export function spiralPoint(source: Vec2, u: number): Vec2 {
|
||||
const clamped = Math.min(1, Math.max(0, u));
|
||||
const a0 = Math.atan2(source.y, source.x);
|
||||
const r0 = Math.hypot(source.x, source.y);
|
||||
const fall = 1 - Math.pow(clamped, 0.92);
|
||||
const spin = clamped * Math.PI * 1.05;
|
||||
const r = r0 * fall;
|
||||
const a = a0 + spin;
|
||||
return { x: Math.cos(a) * r, y: Math.sin(a) * r };
|
||||
export function moonPoses(star: Vec2, count: number, distance: number, obstacles: Vec2[] = []): Vec2[] {
|
||||
const direction = Math.atan2(star.y, star.x);
|
||||
const margin = distance / 2;
|
||||
for (const offset of [0, Math.PI / 4, -Math.PI / 4, Math.PI / 2, -Math.PI / 2, Math.PI]) {
|
||||
const positions = Array.from({ length: count }, (_, index) => {
|
||||
const angle = direction + offset + (index - (count - 1) / 2) * Math.PI / 3;
|
||||
return { x: star.x + Math.cos(angle) * distance, y: star.y + Math.sin(angle) * distance };
|
||||
});
|
||||
if (positions.every(({ x, y }) =>
|
||||
Math.abs(x) < SCENE_WIDTH / 2 - margin && Math.abs(y) < SCENE_HEIGHT / 2 - margin &&
|
||||
obstacles.every((point) => Math.hypot(point.x - x, point.y - y) >= 14),
|
||||
)) return positions;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
export function groupSnapshots(orbits: Orbit[], snapshots: Snapshot[]): Map<string, Snapshot[]> {
|
||||
const ids = new Set(orbits.map(({ id }) => id));
|
||||
const names = new Map<string, string | null>();
|
||||
for (const { id, name } of orbits) {
|
||||
names.set(name, names.has(name) ? null : id);
|
||||
}
|
||||
const groups = new Map<string, Snapshot[]>();
|
||||
for (const snapshot of snapshots) {
|
||||
const id = snapshot.orbit_id ?? names.get(snapshot.orbit_name);
|
||||
if (!id || !ids.has(id)) continue;
|
||||
const group = groups.get(id) ?? [];
|
||||
group.push(snapshot);
|
||||
groups.set(id, group);
|
||||
}
|
||||
for (const group of groups.values()) {
|
||||
group.sort((a, b) => Date.parse(b.taken_at) - Date.parse(a.taken_at));
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
|
||||
export function spiralPoint(source: Vec2, progress: number): Vec2 {
|
||||
const u = Math.min(1, Math.max(0, progress));
|
||||
const angle = Math.atan2(source.y, source.x) + u * Math.PI * 1.15;
|
||||
const radius = Math.hypot(source.x, source.y) * (1 - u ** 1.4);
|
||||
return { x: Math.cos(angle) * radius, y: Math.sin(angle) * radius };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user