Compare commits

...

10 Commits

Author SHA1 Message Date
Tessera Agent
e95d1553ff Rebuild the vault as a lensed orrery with an inbound capture meteor 2026-11-09 14:08:49 +00:00
Tessera Agent
0ee32fcf8f Apply the eight galaxy visual refinements from the review 2026-11-09 12:19:04 +00:00
Tessera Agent
5b40536e37 Layer inclined orbits in flow and even-ring lock spacing 2026-11-09 11:18:30 +00:00
Tessera Agent
32493b640e Fix galaxy flow motion and lock overlap separation 2026-11-09 11:14:15 +00:00
Tessera Agent
6646c12ab1 Graphics pass: calm space backdrop, refined BH/stars, label solver 2026-11-09 11:10:39 +00:00
Tessera Agent
2085b35cfa Widen galaxy orbits, relax lock layout, enlarge vault disk 2026-11-09 10:56:21 +00:00
Tessera Agent
a920235feb Scale galaxy viewport: spread orbits, larger vault, lock solver 2026-11-09 10:54:52 +00:00
Tessera Agent
fa708f545d Galaxy vault: black hole scene with flow/lock interaction
Stars per orbit, snapshot moons when locked, toggle on singularity.
2026-11-09 10:48:30 +00:00
Tessera Agent
50fe4ffffa Add dev demo seed for busy HUD previews
tessera-demo crate, seed-demo CLI, TESSERA_SEED_DEMO hub hook,
12 orbits and 30 historical snapshots.
2026-11-09 10:40:55 +00:00
Tessera Agent
d358c73291 Game UI: diegetic HUD over persistent vault scene
Space Engine-style viewport with cockpit frame, glyph rail,
console overlays for orbits/wormhole/decay/reconstitute.
2026-11-09 10:36:21 +00:00
22 changed files with 1544 additions and 128 deletions

View File

@@ -7,6 +7,7 @@ members = [
"crates/tessera-hub",
"crates/tessera-agent",
"crates/tessera-cli",
"crates/tessera-demo",
]
[workspace.package]

View File

@@ -11,6 +11,7 @@ path = "src/main.rs"
[dependencies]
tessera-core = { path = "../tessera-core" }
tessera-store = { path = "../tessera-store" }
tessera-demo = { path = "../tessera-demo" }
tessera-providers = { path = "../tessera-providers" }
anyhow.workspace = true
clap.workspace = true

View File

@@ -50,6 +50,15 @@ enum Commands {
#[command(subcommand)]
cmd: WormholeCmd,
},
/// Dev-only: populate demo orbits and snapshot history for UI previews.
SeedDemo {
/// Replace existing demo seed data.
#[arg(long)]
force: bool,
/// Remove demo data (orbits/snapshots marker) only.
#[arg(long)]
reset: bool,
},
}
#[derive(Subcommand, Clone)]
@@ -84,6 +93,29 @@ fn main() -> Result<()> {
Commands::Wormhole { ref cmd } => match cmd {
WormholeCmd::Pair { code, name } => wormhole_pair(&cli, code, name)?,
},
Commands::SeedDemo { force, reset } => cmd_seed_demo(&cli, force, reset)?,
}
Ok(())
}
fn cmd_seed_demo(cli: &Cli, force: bool, reset: bool) -> Result<()> {
let data = std::path::Path::new(&cli.data_dir);
if reset {
tessera_demo::clear_demo(data, &cli.vault_pass)?;
println!("Demo seed cleared.");
return Ok(());
}
let report = tessera_demo::apply(data, &cli.vault_pass, force)?;
if report.skipped {
println!(
"Demo seed already applied ({} orbits, {} snapshots). Use --force to re-seed.",
report.orbits, report.snapshots
);
} else {
println!(
"Demo seed complete: {} orbits, {} snapshots, {} outposts.",
report.orbits, report.snapshots, report.outposts
);
}
Ok(())
}

View File

@@ -0,0 +1,16 @@
[package]
name = "tessera-demo"
version.workspace = true
edition.workspace = true
license.workspace = true
[dependencies]
tessera-core = { path = "../tessera-core" }
tessera-store = { path = "../tessera-store" }
anyhow.workspace = true
chrono.workspace = true
rusqlite.workspace = true
serde.workspace = true
serde_json.workspace = true
uuid = { workspace = true, features = ["v4", "v5", "serde"] }
tracing.workspace = true

View File

@@ -0,0 +1,369 @@
//! Dev-only demo seed for HUD previews. Gated by CLI or `TESSERA_SEED_DEMO=1`.
use anyhow::{Context, Result};
use chrono::{Duration, Utc};
use rusqlite::{params, Connection};
use serde::{Deserialize, Serialize};
use std::fs;
use std::path::Path;
use tessera_core::manifest::SnapshotManifest;
use tessera_store::Vault;
use uuid::Uuid;
const MARKER: &str = ".tessera-demo-seed-v1.json";
const DEMO_NS: &str = "tessera-demo-v1";
#[derive(Debug, Serialize, Deserialize)]
pub struct SeedReport {
pub skipped: bool,
pub orbits: usize,
pub snapshots: usize,
pub outposts: usize,
}
#[derive(Clone)]
struct DemoOrbit {
slug: &'static str,
provider: &'static str,
config: serde_json::Value,
schedule: &'static str,
decay: &'static str,
dry_run: bool,
status: &'static str,
snap_count: usize,
base_size_kb: u32,
}
fn demo_id(kind: &str, name: &str) -> Uuid {
Uuid::new_v5(&Uuid::NAMESPACE_OID, format!("{DEMO_NS}:{kind}:{name}").as_bytes())
}
pub fn apply(data_dir: &Path, vault_pass: &str, force: bool) -> Result<SeedReport> {
let marker_path = data_dir.join(MARKER);
if marker_path.exists() && !force {
let existing: StoredMarker = serde_json::from_str(&fs::read_to_string(&marker_path)?)?;
return Ok(SeedReport {
skipped: true,
orbits: existing.orbits,
snapshots: existing.snapshots,
outposts: existing.outposts,
});
}
if force {
clear_demo(data_dir, vault_pass)?;
}
fs::create_dir_all(data_dir)?;
let db_path = data_dir.join("tessera.db");
let conn = Connection::open(&db_path).context("open sqlite")?;
migrate(&conn)?;
let vault_path = data_dir.join("vault");
let mut vault = if vault_path.join("config").exists() {
Vault::open(&vault_path, vault_pass)?
} else {
Vault::init(&vault_path, vault_pass)?
};
let orbits = demo_orbits();
let mut snap_total = 0;
let now = Utc::now();
for o in &orbits {
let orbit_id = demo_id("orbit", o.slug);
let config = serde_json::to_string(&o.config)?;
conn.execute(
r#"INSERT INTO orbits (id, name, provider, provider_config, schedule, decay_preset, dry_run, last_status)
VALUES (?1,?2,?3,?4,?5,?6,?7,?8)
ON CONFLICT(id) DO UPDATE SET
name=excluded.name, provider=excluded.provider, provider_config=excluded.provider_config,
schedule=excluded.schedule, decay_preset=excluded.decay_preset, dry_run=excluded.dry_run,
last_status=excluded.last_status"#,
params![
orbit_id.to_string(),
o.slug,
o.provider,
config,
o.schedule,
o.decay,
o.dry_run as i64,
o.status,
],
)?;
if o.dry_run {
continue;
}
for i in 0..o.snap_count {
let snap_id = demo_id("snap", &format!("{}:{}", o.slug, i));
let taken_at = now - Duration::hours((i as i64 + 1) * 9 + (o.slug.len() as i64 % 5));
let payload = synthetic_payload(o.slug, o.base_size_kb + (i as u32) * 17);
let manifest = SnapshotManifest {
snapshot_id: snap_id,
orbit_id,
orbit_name: o.slug.into(),
labels: vec![o.provider.into()],
provider: o.provider.into(),
paths: vec![format!("/var/backups/{}", o.slug)],
restore_hints: serde_json::json!({ "demo": true }),
};
vault.snapshot_at(manifest, &payload, false, taken_at)?;
snap_total += 1;
}
}
let outposts = seed_outposts(&conn)?;
let report = StoredMarker {
orbits: orbits.len(),
snapshots: snap_total,
outposts,
seeded_at: now.to_rfc3339(),
};
fs::write(&marker_path, serde_json::to_string_pretty(&report)?)?;
Ok(SeedReport {
skipped: false,
orbits: orbits.len(),
snapshots: snap_total,
outposts,
})
}
pub fn clear_demo(data_dir: &Path, vault_pass: &str) -> Result<()> {
let marker_path = data_dir.join(MARKER);
let db_path = data_dir.join("tessera.db");
if db_path.exists() {
let conn = Connection::open(&db_path)?;
migrate(&conn)?;
for o in demo_orbits() {
let id = demo_id("orbit", o.slug).to_string();
conn.execute("DELETE FROM orbits WHERE id = ?1", params![id])?;
}
conn.execute(
"DELETE FROM outposts WHERE id LIKE 'demo-%'",
[],
)?;
}
let vault_path = data_dir.join("vault");
if vault_path.join("config").exists() {
let vault = Vault::open(&vault_path, vault_pass)?;
for o in demo_orbits() {
if o.dry_run {
continue;
}
for i in 0..o.snap_count {
let snap_id = demo_id("snap", &format!("{}:{}", o.slug, i));
let p = vault
.root()
.join("snapshots")
.join(format!("{snap_id}.json"));
if p.exists() {
fs::remove_file(p)?;
}
}
}
}
if marker_path.exists() {
fs::remove_file(marker_path)?;
}
Ok(())
}
#[derive(Serialize, Deserialize)]
struct StoredMarker {
orbits: usize,
snapshots: usize,
outposts: usize,
seeded_at: String,
}
fn migrate(conn: &Connection) -> Result<()> {
conn.execute_batch(
r#"
CREATE TABLE IF NOT EXISTS orbits (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
provider TEXT NOT NULL,
provider_config TEXT NOT NULL,
schedule TEXT,
decay_preset TEXT NOT NULL DEFAULT 'week-of-dailies',
dry_run INTEGER NOT NULL DEFAULT 0,
last_status TEXT NOT NULL DEFAULT 'idle'
);
CREATE TABLE IF NOT EXISTS outposts (
id TEXT PRIMARY KEY,
name TEXT,
last_seen TEXT,
pairing_state TEXT NOT NULL DEFAULT 'unpaired'
);
"#,
)?;
Ok(())
}
fn seed_outposts(conn: &Connection) -> Result<usize> {
let rows = [
("demo-edge-1", "homelab-edge", "active"),
("demo-edge-2", "office-nuc", "active"),
("demo-edge-3", "dr-site-cold", "offline"),
];
for (id, name, state) in rows {
conn.execute(
"INSERT INTO outposts (id, name, last_seen, pairing_state) VALUES (?1,?2,datetime('now'),?3)
ON CONFLICT(id) DO UPDATE SET name=excluded.name, pairing_state=excluded.pairing_state",
params![id, name, state],
)?;
}
Ok(rows.len())
}
fn synthetic_payload(slug: &str, size_kb: u32) -> Vec<u8> {
let unit = format!("tessera-demo::{slug}::").into_bytes();
let target = (size_kb as usize).saturating_mul(1024).max(256);
let mut out = Vec::with_capacity(target);
while out.len() < target {
let take = (target - out.len()).min(unit.len());
out.extend_from_slice(&unit[..take]);
}
out
}
fn demo_orbits() -> Vec<DemoOrbit> {
vec![
DemoOrbit {
slug: "prod-api",
provider: "postgres",
config: serde_json::json!({ "connection_url": "postgres://demo/prod" }),
schedule: "0 2 * * *",
decay: "year-of-monthlies",
dry_run: false,
status: "completed",
snap_count: 4,
base_size_kb: 420,
},
DemoOrbit {
slug: "wiki",
provider: "filesystem",
config: serde_json::json!({ "paths": ["/data/wiki"] }),
schedule: "0 3 * * *",
decay: "week-of-dailies",
dry_run: false,
status: "completed",
snap_count: 3,
base_size_kb: 88,
},
DemoOrbit {
slug: "gitea",
provider: "filesystem",
config: serde_json::json!({ "paths": ["/var/gitea"] }),
schedule: "0 1 * * *",
decay: "month-of-weeklies",
dry_run: false,
status: "running",
snap_count: 3,
base_size_kb: 220,
},
DemoOrbit {
slug: "monitoring",
provider: "filesystem",
config: serde_json::json!({ "paths": ["/etc/prometheus", "/var/lib/grafana"] }),
schedule: "0 */6 * * *",
decay: "week-of-dailies",
dry_run: false,
status: "completed",
snap_count: 3,
base_size_kb: 64,
},
DemoOrbit {
slug: "staging-db",
provider: "postgres",
config: serde_json::json!({ "connection_url": "postgres://demo/staging" }),
schedule: "0 4 * * 0",
decay: "week-of-dailies",
dry_run: false,
status: "failed",
snap_count: 2,
base_size_kb: 310,
},
DemoOrbit {
slug: "legal-docs",
provider: "filesystem",
config: serde_json::json!({ "paths": ["/vault/legal"] }),
schedule: "0 0 * * 1",
decay: "year-of-monthlies",
dry_run: false,
status: "completed",
snap_count: 2,
base_size_kb: 1200,
},
DemoOrbit {
slug: "matrix-synapse",
provider: "filesystem",
config: serde_json::json!({ "paths": ["/var/matrix"] }),
schedule: "0 2 * * *",
decay: "month-of-weeklies",
dry_run: false,
status: "completed",
snap_count: 3,
base_size_kb: 540,
},
DemoOrbit {
slug: "home-assistant",
provider: "filesystem",
config: serde_json::json!({ "paths": ["/config"] }),
schedule: "0 */12 * * *",
decay: "week-of-dailies",
dry_run: false,
status: "completed",
snap_count: 2,
base_size_kb: 45,
},
DemoOrbit {
slug: "deno-api",
provider: "filesystem",
config: serde_json::json!({ "paths": ["/app/deno"] }),
schedule: "0 5 * * *",
decay: "week-of-dailies",
dry_run: false,
status: "completed",
snap_count: 3,
base_size_kb: 96,
},
DemoOrbit {
slug: "mail-archive",
provider: "filesystem",
config: serde_json::json!({ "paths": ["/mail/archive"] }),
schedule: "0 3 * * 6",
decay: "year-of-monthlies",
dry_run: false,
status: "completed",
snap_count: 2,
base_size_kb: 890,
},
DemoOrbit {
slug: "rehearse-nightly",
provider: "filesystem",
config: serde_json::json!({ "paths": ["/tmp/rehearse"] }),
schedule: "0 2 * * *",
decay: "week-of-dailies",
dry_run: true,
status: "rehearsed",
snap_count: 0,
base_size_kb: 0,
},
DemoOrbit {
slug: "observability-pg",
provider: "postgres",
config: serde_json::json!({ "connection_url": "postgres://demo/metrics" }),
schedule: "0 1 * * *",
decay: "month-of-weeklies",
dry_run: false,
status: "completed",
snap_count: 3,
base_size_kb: 180,
},
]
}

View File

@@ -12,6 +12,7 @@ path = "src/main.rs"
tessera-core = { path = "../tessera-core" }
tessera-store = { path = "../tessera-store" }
tessera-providers = { path = "../tessera-providers" }
tessera-demo = { path = "../tessera-demo" }
anyhow.workspace = true
axum.workspace = true
chrono.workspace = true

View File

@@ -19,6 +19,27 @@ async fn main() -> Result<()> {
let vault_pass = std::env::var("TESSERA_VAULT_PASSPHRASE").unwrap_or_else(|_| "dev-vault-key".into());
let state = HubState::bootstrap(&data_dir, &vault_pass).await?;
if std::env::var("TESSERA_SEED_DEMO")
.map(|v| v == "1" || v == "true")
.unwrap_or(false)
{
match tessera_demo::apply(std::path::Path::new(&data_dir), &vault_pass, false) {
Ok(r) if !r.skipped => {
tracing::info!(
"demo seed: {} orbits, {} snapshots",
r.orbits,
r.snapshots
);
let vault_path = std::path::Path::new(&data_dir).join("vault");
let vault = tessera_store::Vault::open(&vault_path, &vault_pass)?;
*state.vault.write().await = vault;
}
Ok(r) => tracing::info!("demo seed skipped (already applied, {} orbits)", r.orbits),
Err(e) => tracing::warn!("demo seed failed: {e}"),
}
}
scheduler::start_orbit_scheduler(state.clone()).await?;
let app = api::router(state);

View File

@@ -117,11 +117,22 @@ impl Vault {
manifest: SnapshotManifest,
payload: &[u8],
dry_run: bool,
) -> Result<StoredSnapshot> {
self.snapshot_at(manifest, payload, dry_run, Utc::now())
}
/// Like `snapshot`, but allows a custom timestamp (demo/historical imports).
pub fn snapshot_at(
&mut self,
manifest: SnapshotManifest,
payload: &[u8],
dry_run: bool,
taken_at: DateTime<Utc>,
) -> Result<StoredSnapshot> {
if dry_run {
return Ok(StoredSnapshot {
id: manifest.snapshot_id,
taken_at: Utc::now(),
taken_at,
manifest,
size_bytes: payload.len() as u64,
tree_root: "dry-run".into(),
@@ -133,7 +144,7 @@ impl Vault {
let snap = StoredSnapshot {
id: manifest.snapshot_id,
taken_at: Utc::now(),
taken_at,
manifest,
size_bytes: payload.len() as u64,
tree_root: chunk_id,

View File

@@ -1,22 +1,32 @@
# Tessera canvas — screen map
# Tessera canvas — galaxy vault (Space Engine mode)
One viewport (`100dvh`) with bottom tabs; detail flows use sheets (Labuh-style).
Diegetic **cockpit HUD** over a persistent **galaxy viewport**. The vault is a **black hole** at center; each **orbit** is a **star** on an elliptical path; **snapshots** are **moons** around that star (when locked).
| 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 modes
### Sheets (overlays)
| Mode | Behavior |
|------|----------|
| **Flowing** (default) | Stars orbit the singularity; accretion disk spins; moons hidden; targets not clickable |
| **Locked** | Click **black hole** once — bodies ease into spaced slots and **stop**; star opens orbit console; moon opens snapshot tile |
- **Snapshot tile** — evidence (time, size), reconstitute CTA, snapshot ID telemetry
- **Reconstitute** — pick snapshot/target, 12s grace ring + abort, state copy per SPEC
Click the **black hole** again to resume flow. HUD line under telemetry: green “flowing” / amber “locked”.
### API wiring
## HUD rail
- `GET /api/v1/snapshots`, `/orbits`, `/health`
- `POST /api/v1/orbits`, `/orbits/:id/run`, `/reconstitute`, `/wormhole/pairing`
Unchanged — ◎ ⟳ ◉ ◇ ↩ consoles; **Esc** dismisses.
See `web/README.md` for dev commands.
## Data
- Stars: `GET /api/v1/orbits` (status → star color)
- Moons: `GET /api/v1/snapshots` grouped by `orbit_name`, max 6 per star
## Demo
`TESSERA_DATA_DIR=... tessera seed-demo --force` for 12+ stars.
## Build
```bash
cd web && npm run build
cargo build --release -p tessera-hub
```

View File

@@ -0,0 +1,21 @@
import { chromium } from "playwright";
const base = process.env.TESSERA_URL ?? "http://127.0.0.1:8787/";
const outFlow =
process.env.FLOW_SHOT ?? "/cursor/stores/self/media/tessera-galaxy-flow-polish.png";
const outLock =
process.env.LOCK_SHOT ?? "/cursor/stores/self/media/tessera-galaxy-locked-polish.png";
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
await page.goto(base, { waitUntil: "networkidle", timeout: 30_000 });
await page.waitForTimeout(2500);
await page.screenshot({ path: outFlow, fullPage: false });
const svg = page.locator('[aria-label="Galaxy vault viewport"]');
const box = await svg.boundingBox();
if (!box) throw new Error("galaxy svg not found");
await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2);
await page.waitForTimeout(1400);
await page.screenshot({ path: outLock, fullPage: false });
await browser.close();
console.log("saved", outFlow, outLock);

View File

@@ -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,26 +11,26 @@ 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<Tab>("vault");
const [overlay, setOverlay] = useState<Overlay>("none");
const [mode, setMode] = useState<HUDMode>("scene");
const [selectedSnap, setSelectedSnap] = 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 qc = useQueryClient();
const health = useQuery({
@@ -40,13 +39,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,108 +52,143 @@ 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);
useEffect(() => {
const onKey = (e: KeyboardEvent) => {
if (e.key === "Escape" && mode !== "scene") setMode("scene");
};
window.addEventListener("keydown", onKey);
return () => window.removeEventListener("keydown", onKey);
}, [mode]);
const snapshotPanel = selectedSnapshot && mode === "scene";
return (
<div className="h-[100dvh] flex flex-col bg-space-950 text-star-100 overflow-hidden relative">
<Starfield />
<AppHeader
statusDot={<StatusDot status={hubOnline ? vaultStatus : "grey"} size="lg" />}
subtitle={hubOnline ? "Orbital backup vault" : "Hub unreachable"}
/>
<main className="flex-1 min-h-0 relative z-[1]">
{tab === "vault" && (
<QueryGate
query={snaps}
empty={
<EmptyState
title="Quiet vault"
body="No snapshots on the ring yet. Add an orbit or capture now."
action={{
label: "Go to orbits",
onClick: () => setTab("orbits"),
<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();
}
>
{(data) => (
<VaultRing
snapshots={data}
capturing={capture.isPending || orbits.data?.some((o) => o.last_status === "running")}
onCapture={() => {
if (!(orbits.data?.length ?? 0)) setTab("orbits");
else capture.mutate();
}}
onSelect={(id) => {
setSelectedSnap(id);
setOverlay("snapshot");
}}
/>
)}
</QueryGate>
)}
{tab === "orbits" && (
<QueryGate
query={orbits}
empty={<OrbitsView orbits={[]} />}
>
{(data) => <OrbitsView orbits={data} />}
</QueryGate>
)}
{tab === "outposts" && (
<WormholeView
pairing={pairing}
onPaired={(p) => setPairing(p)}
/>
)}
{tab === "decay" && (
<DecayView appliedPresets={(orbits.data ?? []).map((o) => o.decay_preset ?? "week-of-dailies")} />
)}
{tab === "vault" && (
<div className="absolute bottom-20 inset-x-0 flex justify-center px-4 pointer-events-none">
<Button
variant="ghost"
className="pointer-events-auto text-xs shadow-lg backdrop-blur-md"
onClick={() => setOverlay("reconstitute")}
>
Reconstitute…
</Button>
</div>
)}
</main>
<NavBar active={tab} onChange={setTab} />
<HUDRail active={mode} onSelect={setMode} capturing={capturing} />
<AnimatePresence>
{overlay === "snapshot" && selectedSnapshot && (
<Sheet
open
<HUDPanel
open={!!snapshotPanel}
title="Snapshot tile"
onClose={() => setOverlay("none")}
subtitle="Point-in-time mass on the ring"
side="left"
onClose={() => setSelectedSnap(null)}
>
{selectedSnapshot && (
<SnapshotSheet
snap={selectedSnapshot}
onReconstitute={() => setOverlay("reconstitute")}
onReconstitute={() => setMode("reconstitute")}
/>
</Sheet>
)}
{overlay === "reconstitute" && (
<Sheet open title="Reconstitute" onClose={() => setOverlay("none")}>
</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}
@@ -164,13 +196,12 @@ export default function App() {
onPoll={pollReconstitute}
onAbort={abortReconstitute}
/>
</Sheet>
)}
</AnimatePresence>
</HUDPanel>
{capture.isError && (
<p className="absolute top-14 inset-x-0 text-center text-xs text-orbit-amber pointer-events-none">
Add an orbit first, then capture.
<p className="absolute top-24 inset-x-0 text-center text-[10px] font-mono text-orbit-amber z-30">
NO ORBIT — OPEN ⟳ CONSOLE
</p>
)}
</div>

View File

@@ -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 (
<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" />
</>
);
}
export function TelemetryStrip({
status,
online,
snapCount,
totalBytes,
}: {
status: VaultStatus;
online: boolean;
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>
);
}
export function SnapshotsMiniList({
snapshots,
selected,
onSelect,
}: {
snapshots: Snapshot[];
selected: string | null;
onSelect: (id: string) => void;
}) {
if (!snapshots.length) return null;
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)}
</button>
))}
</div>
);
}

View File

@@ -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 (
<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 }}
>
{label}
</motion.button>
);
}

View File

@@ -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 (
<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>
);
}

View File

@@ -0,0 +1,283 @@
import { useEffect, useMemo, useRef, useState, type RefObject } from "react";
import type { Orbit } from "../../api";
import {
assignShells,
shellPose,
spiralPoint,
type Vec2,
} from "../../lib/galaxyLayout";
import { useGalaxyTime } from "../../hooks/useGalaxyMotion";
const METEOR_MS = 2600;
function shorten(name: string) {
return name.length > 16 ? `${name.slice(0, 14)}…` : name;
}
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]);
const poses = shells.map((body) => shellPose(body, t));
const poseRef = useRef(poses);
poseRef.current = poses;
const meteor = useMeteor(capturePulse, poseRef);
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";
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>
);
})}
{meteor && <InboundMeteor source={meteor.source} u={meteor.u} />}
</svg>
</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 };
}

View File

@@ -0,0 +1,69 @@
import { useMemo } from "react";
function rand(seed: number) {
let a = 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;
};
}
/** 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,
};
});
}, []);
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>
);
}

View File

@@ -0,0 +1,44 @@
import type { Orbit, Snapshot } from "../../api";
import { SpaceBackdrop } from "./SpaceBackdrop";
import { BlackholeGalaxy } from "./BlackholeGalaxy";
export function VaultScene({
orbits,
snapshots,
flowing,
onToggleFlow,
onSelect,
onSelectOrbit,
selectedSnapshotId,
capturing,
capturePulse = 0,
}: {
orbits: Orbit[];
snapshots: Snapshot[];
flowing: boolean;
onToggleFlow: () => void;
onSelect: (id: string) => void;
onSelectOrbit: (id: string) => void;
selectedSnapshotId?: string | null;
capturing?: boolean;
capturePulse?: number;
}) {
return (
<div className="absolute inset-0 overflow-hidden bg-space-950">
<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>
</div>
);
}

View File

@@ -109,8 +109,8 @@ export function VaultRing({
{capturing ? "Orbit in progress…" : "Capture now"}
</motion.button>
)}
<p className="mt-2 text-xs text-star-400 max-w-xs text-center">
Tap a tile for snapshot detail. Only stardust that changed.
<p 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>
);

View File

@@ -0,0 +1,34 @@
import { useEffect, useRef, useState } 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);
};
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);
}

View File

@@ -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
);
}

View File

@@ -0,0 +1,137 @@
import type { Vec2 } from "./galaxyLayout";
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 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;
}
}
}
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;
}

View File

@@ -0,0 +1,68 @@
/** Face-on orrery: two even shells around the vault. */
export type Vec2 = { x: number; y: number };
export type ShellBody = {
index: number;
shell: "inner" | "outer";
radius: number;
baseAngle: number;
size: number;
warm: boolean;
};
const INNER_R = 112;
const OUTER_R = 178;
/** 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,
});
}
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,
});
}
return bodies;
}
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;
return {
angle,
x: Math.cos(angle) * body.radius,
y: Math.sin(angle) * body.radius,
};
}
/** 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 };
}