diff --git a/docs/UI.md b/docs/UI.md index 86921f7..364e41e 100644 --- a/docs/UI.md +++ b/docs/UI.md @@ -1,22 +1,39 @@ -# Tessera canvas — screen map +# Tessera canvas — Space Engine mode -One viewport (`100dvh`) with bottom tabs; detail flows use sheets (Labuh-style). +Diegetic **cockpit HUD** over a persistent **vault viewport**. No admin tabs — systems open as translucent console overlays. -| Tab | Purpose | -|-----|---------| -| **Vault** | Starfield + orbital SVG ring; snapshot tiles; Capture now; entry to reconstitute sheet | -| **Orbits** | Orbit cards (status dot, schedule phrase, rehearse badge); add orbit editor; capture; telemetry | -| **Wormhole** | Pairing code for outposts; placeholder outpost health (grey = offline) | -| **Decay** | Preset library with “in use” from orbit metadata | +## Viewport (always on) -### Sheets (overlays) +- Starfield + nebula wash, orbital snapshot ring (SVG) +- Corner brackets, scanlines, vignette +- Telemetry strip: link status, tile count, stored mass +- Left rail: last four snapshot targets (mono labels) +- Center action: **CAPTURE NOW** -- **Snapshot tile** — evidence (time, size), reconstitute CTA, snapshot ID telemetry -- **Reconstitute** — pick snapshot/target, 12s grace ring + abort, state copy per SPEC +## HUD rail (glyph console) -### API wiring +| Glyph | System | Overlay | +|-------|--------|---------| +| ◎ | Viewport | Dismiss overlays — pure scene | +| ⟳ | Orbits | Right console — schedules, rehearse, create | +| ◉ | Wormhole | Outpost pairing uplink | +| ◇ | Decay | Retention presets in use | +| ↩ | Restore | Bottom console — reconstitute + 12s grace | -- `GET /api/v1/snapshots`, `/orbits`, `/health` -- `POST /api/v1/orbits`, `/orbits/:id/run`, `/reconstitute`, `/wormhole/pairing` +**Esc** closes an open console. -See `web/README.md` for dev commands. +## Overlays (not pages) + +- **Snapshot tile** — slides from left when a ring tile is selected on viewport +- **Orbit / Wormhole / Decay / Reconstitute** — HUD panels with console chrome + +## API + +Unchanged — see prior polish notes; TanStack Query on `/api/v1/*` and `/health`. + +## Build + +```bash +cd web && npm run build +cargo build --release -p tessera-hub # embeds dist +``` diff --git a/web/src/App.tsx b/web/src/App.tsx index a59c07d..9d268b0 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -1,6 +1,5 @@ -import { useState } from "react"; +import { useEffect, useMemo, useState } from "react"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; -import { AnimatePresence } from "motion/react"; import { abortReconstitute, fetchHealth, @@ -12,24 +11,22 @@ import { } from "./api"; import { vaultStatusFromOrbits } from "./lib/format"; import { DecayView } from "./components/decay/DecayView"; -import { AppHeader, NavBar, type Tab } from "./components/layout/NavBar"; import { OrbitsView } from "./components/orbits/OrbitsView"; import { WormholeView } from "./components/outposts/WormholeView"; import { ReconstituteWizard } from "./components/reconstitute/ReconstituteWizard"; -import { Starfield } from "./components/scene/Starfield"; +import { VaultScene } from "./components/scene/VaultScene"; import { SnapshotSheet } from "./components/vault/SnapshotSheet"; -import { VaultRing } from "./components/vault/VaultRing"; +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 { Sheet } from "./components/ui/Sheet"; -import { StatusDot } from "./components/ui/StatusDot"; -import { Button } from "./components/ui/Button"; - -type Overlay = "none" | "snapshot" | "reconstitute"; - export default function App() { - const [tab, setTab] = useState("vault"); - const [overlay, setOverlay] = useState("none"); + const [mode, setMode] = useState("scene"); const [selectedSnap, setSelectedSnap] = useState(null); const [pairing, setPairing] = useState<{ code: string; expires_at: string } | null>(null); const qc = useQueryClient(); @@ -40,13 +37,11 @@ export default function App() { refetchInterval: 30_000, retry: 1, }); - const snaps = useQuery({ queryKey: ["snapshots"], queryFn: fetchSnapshots, refetchInterval: 8_000, }); - const orbits = useQuery({ queryKey: ["orbits"], queryFn: fetchOrbits, @@ -55,122 +50,160 @@ export default function App() { 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 capture = useMutation({ mutationFn: async () => { - const list = orbits.data ?? []; - const target = list[0]; + const target = orbits.data?.[0]; if (!target) throw new Error("no-orbit"); await runOrbit(target.id); }, - onSuccess: () => { - qc.invalidateQueries({ queryKey: ["snapshots", "orbits"] }); - }, + onSuccess: () => qc.invalidateQueries({ queryKey: ["snapshots", "orbits"] }), }); const selectedSnapshot = snaps.data?.find((s) => s.id === selectedSnap); - return ( -
- - } - subtitle={hubOnline ? "Orbital backup vault" : "Hub unreachable"} - /> + useEffect(() => { + const onKey = (e: KeyboardEvent) => { + if (e.key === "Escape" && mode !== "scene") setMode("scene"); + }; + window.addEventListener("keydown", onKey); + return () => window.removeEventListener("keydown", onKey); + }, [mode]); -
- {tab === "vault" && ( - setTab("orbits"), - }} - /> - } - > - {(data) => ( - o.last_status === "running")} - onCapture={() => { - if (!(orbits.data?.length ?? 0)) setTab("orbits"); - else capture.mutate(); - }} - onSelect={(id) => { - setSelectedSnap(id); - setOverlay("snapshot"); - }} - /> - )} - - )} - {tab === "orbits" && ( - } - > - {(data) => } - - )} - {tab === "outposts" && ( - setPairing(p)} + const snapshotPanel = selectedSnapshot && mode === "scene"; + + return ( +
+ {/* Scene always visible */} + {}} capturing={capturing} /> + } + > + {(data) => ( + { + if (!(orbits.data?.length ?? 0)) setMode("orbits"); + else capture.mutate(); + }} + onSelect={(id) => { + setSelectedSnap(id); + }} /> )} - {tab === "decay" && ( - o.decay_preset ?? "week-of-dailies")} /> - )} + - {tab === "vault" && ( -
- -
- )} -
+ + + setSelectedSnap(id)} + /> + - +
+ { + if (!(orbits.data?.length ?? 0)) setMode("orbits"); + else capture.mutate(); + }} + /> +
- - {overlay === "snapshot" && selectedSnapshot && ( - setOverlay("none")} - > - setOverlay("reconstitute")} - /> - + + + setSelectedSnap(null)} + > + {selectedSnapshot && ( + setMode("reconstitute")} + /> )} - {overlay === "reconstitute" && ( - setOverlay("none")}> - - + + + setMode("scene")} + > + }> + {(data) => } + + + + setMode("scene")} + > + + + + setMode("scene")} + > + o.decay_preset ?? "week-of-dailies", + )} + /> + + + setMode("scene")} + > + {(snaps.data?.length ?? 0) === 0 ? ( + + ) : ( + )} - + {capture.isError && ( -

- Add an orbit first, then capture. +

+ NO ORBIT — OPEN ⟳ CONSOLE

)}
diff --git a/web/src/components/hud/DiegeticHUD.tsx b/web/src/components/hud/DiegeticHUD.tsx new file mode 100644 index 0000000..0d74438 --- /dev/null +++ b/web/src/components/hud/DiegeticHUD.tsx @@ -0,0 +1,89 @@ +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 ( +
+ +

+ Tessera · orbital vault +

+

+ SYS // VAULT-01 +

+
+
+
+ {children} +
+ ); +} + +function motionBorder() { + return ( + <> + + + + + + ); +} + +export function TelemetryStrip({ + status, + online, + snapCount, + totalBytes, +}: { + status: VaultStatus; + online: boolean; + snapCount: number; + totalBytes: number; +}) { + return ( +
+
+ + {online ? "LINK OK" : "NO LINK"} +
+
+
TILES {snapCount}
+
{formatBytes(totalBytes)} mass
+
+
+ ); +} + +export function SnapshotsMiniList({ + snapshots, + selected, + onSelect, +}: { + snapshots: Snapshot[]; + selected: string | null; + onSelect: (id: string) => void; +}) { + if (!snapshots.length) return null; + return ( +
+ {snapshots.slice(0, 4).map((s, i) => ( + + ))} +
+ ); +} diff --git a/web/src/components/hud/HUDPanel.tsx b/web/src/components/hud/HUDPanel.tsx new file mode 100644 index 0000000..c8a0ddb --- /dev/null +++ b/web/src/components/hud/HUDPanel.tsx @@ -0,0 +1,96 @@ +import { motion, AnimatePresence } from "motion/react"; +import type { ReactNode } from "react"; + +export function HUDPanel({ + open, + title, + subtitle, + onClose, + children, + side = "right", +}: { + 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"; + + return ( + + {open && ( + <> + + +
+
+

+ Console +

+

{title}

+ {subtitle &&

{subtitle}

} +
+ +
+
{children}
+
+ + )} +
+ ); +} + +export function SceneAction({ + label, + onClick, + disabled, + variant = "primary", +}: { + label: string; + onClick: () => void; + disabled?: boolean; + variant?: "primary" | "ghost"; +}) { + return ( + + {label} + + ); +} diff --git a/web/src/components/hud/HUDRail.tsx b/web/src/components/hud/HUDRail.tsx new file mode 100644 index 0000000..85abf46 --- /dev/null +++ b/web/src/components/hud/HUDRail.tsx @@ -0,0 +1,60 @@ +import { motion } from "motion/react"; + +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" }, +]; + +export function HUDRail({ + active, + onSelect, + capturing, +}: { + active: HUDMode; + onSelect: (m: HUDMode) => void; + capturing?: boolean; +}) { + return ( + + ); +} diff --git a/web/src/components/scene/VaultScene.tsx b/web/src/components/scene/VaultScene.tsx new file mode 100644 index 0000000..ef05f1e --- /dev/null +++ b/web/src/components/scene/VaultScene.tsx @@ -0,0 +1,36 @@ +import { motion } from "motion/react"; +import type { Snapshot } from "../../api"; +import { VaultRing } from "../vault/VaultRing"; +import { Starfield } from "./Starfield"; + +export function VaultScene({ + snapshots, + onSelect, + onCapture, + capturing, +}: { + snapshots: Snapshot[]; + onSelect: (id: string) => void; + onCapture?: () => void; + capturing?: boolean; +}) { + return ( +
+
+ + +
+ +
+
+ ); +} diff --git a/web/src/components/vault/VaultRing.tsx b/web/src/components/vault/VaultRing.tsx index 14467df..f4d2ea4 100644 --- a/web/src/components/vault/VaultRing.tsx +++ b/web/src/components/vault/VaultRing.tsx @@ -109,8 +109,8 @@ export function VaultRing({ {capturing ? "Orbit in progress…" : "Capture now"} )} -

- Tap a tile for snapshot detail. Only stardust that changed. +

+ Select tile · stardust delta only

); diff --git a/web/src/index.css b/web/src/index.css index 1b56b18..b69216b 100644 --- a/web/src/index.css +++ b/web/src/index.css @@ -53,3 +53,25 @@ body, transform: translateY(-120px); } } + +.vignette::after { + content: ""; + position: absolute; + inset: 0; + pointer-events: none; + box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.65); +} + +.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 + ); +}