feat: restyle the web UI as a spaceship cockpit

The map is a canopy with a bezel, an inset window and a sill carrying a
Window | Radar view switch. Consoles open as centered screens; Orbits,
Outposts, Activity and the snapshot sheet follow one vocabulary of recessed
fields, bevelled keys and lamps that stay distinct by shape.

- Activity replaces the Restore tab with one log of backups and restores.
  Rows lead to a snapshot or an orbit; restores and exports start from the
  snapshot. The model is a pure function with tests.
- Restore opens from a snapshot as a two column screen: choose and confirm on
  the left, job progress or countdown on the right.
- Add Segmented and a themed Select (portal list, keyboard and form support).
- Add a spotlight-style search panel.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-14 12:23:31 +07:00
parent 34b2f346af
commit c74694cf1f
27 changed files with 1971 additions and 628 deletions

View File

@@ -12,7 +12,18 @@ The persistent viewport maps backup jobs and recovery points. The black hole rep
- **Big Screen** expands the map and keeps summary counts, motion controls, and a floating navigation dock. The map and dock spring into position within the current browser viewport. Use **Exit big screen** or Escape to return to the workspace. - **Big Screen** expands the map and keeps summary counts, motion controls, and a floating navigation dock. The map and dock spring into position within the current browser viewport. Use **Exit big screen** or Escape to return to the workspace.
- Drag the active navbar item sideways and release to open the destination. The regular navbar uses text and a sliding underline. The Big Screen dock uses labeled icons and a liquid highlight. - Drag the active navbar item sideways and release to open the destination. The regular navbar uses text and a sliding underline. The Big Screen dock uses labeled icons and a liquid highlight.
- The navbar stays available above the side panel so you can switch directly between consoles. In the regular workspace it becomes a floating text dock in the same top position. Big Screen keeps its icon dock at the bottom. - The navbar stays available above the side panel so you can switch directly between consoles. In the regular workspace it becomes a floating text dock in the same top position. Big Screen keeps its icon dock at the bottom.
- Use **Search**, **⌘K**, or **Ctrl+K** from the vault, a console, or Big Screen. An empty field shows navigation shortcuts. Type to find destinations, orbits by name, ID, or provider, and snapshots by orbit name, ID, or displayed capture date. Search uses the summaries already loaded by the vault. Use the arrow keys and Enter, or select a result with a pointer. Escape closes search and returns focus to its button. - Use **Search**, **⌘K**, or **Ctrl+K** from the vault, a console, or Big Screen. An empty field shows navigation shortcuts. Type to find destinations, orbits by name, ID, or provider, and snapshots by orbit name, ID, or displayed capture date. Search uses the summaries already loaded by the vault. Use the arrow keys and Enter, or select a result with a pointer. Escape closes search and returns focus to its button. Search is a spotlight panel over a dimmed, lightly blurred deck: a large input, grouped results with a kind label on the right (the active row adds an Enter mark), a footer of key hints and the result count, and a "No signal" message when nothing matches.
## Consoles
- Orbits, Outposts, Activity and Snapshot open as console screens, and Restore opens from a snapshot: a centered panel under the navbar with an engraved label, a title and an Esc key, sized per console (`panelWidths` in `App.tsx`). They fade and rise with the shared spring, and the map behind is inert while one is open.
- Orbits is two columns. The left holds the outpost job history and one card per orbit (a failed orbit gets an ember edge; Capture is the single amber key). The right is the permanent New orbit form: Folder | Database and Via hub | Via outpost are `Segmented` switches, fields are recessed, and Cancel resets the form. Below 860 px the form stacks under the list.
- Outposts is a gate. With no code it shows a dark eye inside violet rings and one key, Open a wormhole. With a code it shows the code in large mono, a burn bar and a ticking time left (the bar counts down from the time the code was first seen, since the hub sends only the expiry), the agent command with a Copy key, and Generate fresh code. Outpost health is a roster with a lamp, last activity and an Online or Silent label; an outpost is online if it was seen in the last two minutes.
- Selects are themed (`ui/Select.tsx`, a drop-in for `<select>` that reads `<option>` children). The trigger is a recessed field with a chevron set in from the edge. The list is drawn in a portal so a console's scroll never clips it, flips above when there is no room below, and shows the active row with an amber edge and the chosen row with a check. Arrow keys, Home, End, type-ahead, Enter and Space work with focus kept on the trigger, and Escape closes only the list. A hidden input carries the value into forms, so `required` still validates.
- Activity is one log of backups and restores, and it only leads somewhere; it never acts. A row opens its snapshot (restores start there) or, for a backup that is running or failed and has no snapshot yet, its orbit. Rows are grouped Needs you (a restore in `recovery_required`, or a hub orbit whose last backup failed), Running now (with a five-tick position) and then days. A backup that stored a snapshot is one row. A restore whose snapshot retention has removed is shown without a link. Filter by text or by Backups and Restores. The Activity tab lamp turns ember while anything needs you. Data comes from the snapshot list, `GET /api/v1/capture-jobs`, which covers outpost orbits, `GET /api/v1/restore-jobs`, and the last status of hub orbits, which have no job list, so a failed one has no time. File exports are not logged: the hub keeps those sessions in memory and cannot list them, so a running export is followed from the Restore screen, which the footer reopens while one is active. The model is in `web/src/lib/activity.ts`.
- The Restore screen is two columns. The left chooses and confirms: the recovery point as a card, the snapshot select, and a Restore to database | Export file on hub switch (shown for managed database snapshots). Database mode picks a registered target, shows an amber warning that the target is replaced, and asks for the typed confirmation before Queue database restore is enabled. The right follows the work. For a database it is the newest restore job as a five-step progress list (Queued, Verifying, Safety backup, Applying restore, Complete); a failed step becomes an ember diamond with the hub's reason, and recovery acknowledgement appears there when the job needs it. Older jobs are listed compactly. For a file export it is the countdown ring, which keeps counting from the hub's session, with Abort on the left. Below 860 px the right column stacks under the left.
- The snapshot sheet opens from a moon, a history row or search. Its label says where the point sits (Recovery point · 1 of 4). A hero shows a small orbit with up to four moons and the chosen one lit; Captured, Payload (with the change against the previous snapshot of the same orbit) and Recovery sit in one plate; the id has a Copy key. Database recovery options (or Export file on hub) is the primary key, Download is secondary, and Delete is deliberately quiet and asks for confirmation in an ember panel.
- Buttons are bevelled keys (`Button`, `.console-control`): raised with a top highlight, pressed with an inset shadow. Amber marks the one primary action, ember marks a destructive one.
## Data and rendering ## Data and rendering
@@ -33,7 +44,10 @@ The persistent viewport maps backup jobs and recovery points. The black hole rep
- The galaxy loop publishes its disk clock and the capture absorption to the renderer through a shared signal, so Flowing, coasting and capture spin-up drive the disk. A locked map renders once and sleeps. - The galaxy loop publishes its disk clock and the capture absorption to the renderer through a shared signal, so Flowing, coasting and capture spin-up drive the disk. A locked map renders once and sleeps.
- Quality adapts to the device. A few synchronised frames are timed at startup and after a resize, and the tier steps down until the median fits the frame budget: `high`, `medium`, `low`, `minimal`, then `still`, which freezes ambient motion. Ambient drawing is capped at 30 fps or lower. Tiers and the governor live in `quality.ts`. - Quality adapts to the device. A few synchronised frames are timed at startup and after a resize, and the tier steps down until the median fits the frame budget: `high`, `medium`, `low`, `minimal`, then `still`, which freezes ambient motion. Ambient drawing is capped at 30 fps or lower. Tiers and the governor live in `quality.ts`.
- Without WebGL2, or after a lost context, the scene falls back to the SVG core and backdrop. - Without WebGL2, or after a lost context, the scene falls back to the SVG core and backdrop.
- **Radar view** in the map toolbar switches between the realistic and radar looks. The choice is remembered per browser. Without WebGL2 the button is hidden. The radar sweep runs on its own clock rather than the scene's, so it keeps turning on a locked map. Reduced motion switches looks at once and holds the sweep still and evenly lit, and the still quality tier does the same. A page that loads with the radar look applies it at once, with no wave. While the sweep runs the map redraws at the tier's frame-rate cap, so radar costs more battery than a locked realistic map, which draws nothing. - The map is a cockpit canopy: chamfered corners with a bezel line and corner screws (`.canopy-frame`, drawn over the map and ignoring pointer events), clipped by `.vault-scene`'s `clip-path`. Big Screen drops the frame. The bezel stays neutral in both looks.
- The deck around the canopy follows the same vocabulary: the navbar is a tray of switches with a lamp per tab (the thumb still springs and drags), the overview is a slim telemetry rail, consoles carry an engraved label and a corner screw, and status lamps glow and stay distinct by shape. The canopy's sill holds the legend, the view switch and the motion and big-screen controls; below 760 px, and in Big Screen, the controls move up to the map toolbar.
- Icon-only keys (Pause or Resume motion, Big screen, Sign out, Search) share one size, `--key`, and one gap, `--key-gap`, and keep their names in `aria-label` and the tooltip. Read-outs that sit beside keys (Hub online, the Big Screen status and telemetry) are recessed plates of the same height. Telemetry readings carry a lamp: ice for orbits, mint for failed at zero, ember diamond for failed above zero, a pale diamond for snapshots, violet for payload.
- **Window | Radar** is a two-position view switch on the canopy sill (`ViewSwitch` in `VaultScene.tsx`, a `radiogroup`; arrow keys move between positions). Its thumb rides the shared spring and tints amber for the window and mint for radar. It switches between the realistic and radar looks. The choice is remembered per browser. Without WebGL2 the button is hidden. The radar sweep runs on its own clock rather than the scene's, so it keeps turning on a locked map. Reduced motion switches looks at once and holds the sweep still and evenly lit, and the still quality tier does the same. A page that loads with the radar look applies it at once, with no wave. While the sweep runs the map redraws at the tier's frame-rate cap, so radar costs more battery than a locked realistic map, which draws nothing.
- The radar look draws range rings every 6 M, a bearing scale at 30 M just outside the disk, a crosshair and a rotating sweep head whose phosphor fades behind it. The lensed grid only shows outside about 20 M, so it never crowds the disk. The disk is drawn as contour bands equal in log brightness, and the long dim outer disk stays faint so the inner contours carry the weight. - The radar look draws range rings every 6 M, a bearing scale at 30 M just outside the disk, a crosshair and a rotating sweep head whose phosphor fades behind it. The lensed grid only shows outside about 20 M, so it never crowds the disk. The disk is drawn as contour bands equal in log brightness, and the long dim outer disk stays faint so the inner contours carry the weight.
- A realistic and a stylized radar look share the same trace. The radar look arrives as a wave spreading outward from the hole: each pixel picks its look from its distance to a spring-driven front, with a thin leading edge (mint going to radar, amber coming back). `look.ts` holds the spring and queues a request made mid-wave rather than reversing it. `web/blackhole-proto.html` is a standalone page for tuning the look; Vite serves it in development and the build ignores it. Add `?throttle=N` to emulate a GPU N times slower. - A realistic and a stylized radar look share the same trace. The radar look arrives as a wave spreading outward from the hole: each pixel picks its look from its distance to a spring-driven front, with a thin leading edge (mint going to radar, amber coming back). `look.ts` holds the spring and queues a request made mid-wave rather than reversing it. `web/blackhole-proto.html` is a standalone page for tuning the look; Vite serves it in development and the build ignores it. Add `?throttle=N` to emulate a GPU N times slower.

View File

@@ -0,0 +1,80 @@
import assert from "node:assert/strict";
import test from "node:test";
import { activityCounts, buildActivity, dayLabel } from "../src/lib/activity.ts";
const NOW = Date.parse("2026-11-14T12:00:00Z");
const sec = (iso) => Date.parse(iso) / 1000;
const snapshot = (id, orbit_name, taken_at, size_bytes = 1024 ** 3) => ({ id, orbit_name, orbit_id: orbit_name, taken_at, size_bytes });
const target = { id: "t", name: "pg-staging", outpost_id: "o", engine: "postgres", application_id: "a", identity: { instance: "1", database: "orders" } };
const restore = (id, status, phase, at, extra = {}) => ({ id, snapshot_id: "s1", target, actor: "sen", status, phase, safety_snapshot_id: null, created_at: sec(at), updated_at: sec(at), ...extra });
const orbit = (id, last_status, extra = {}) => ({ id, name: id, provider: "filesystem", source: "filesystem", access: "hub", last_status, dry_run: false, ...extra });
const build = (input) => buildActivity({ snapshots: [], orbits: [], captureJobs: [], restoreJobs: [], now: NOW, ...input });
test("puts what needs a person first, then running work, then history newest first", () => {
const snapshots = [snapshot("s1", "media-vault", "2026-11-14T02:00:00Z"), snapshot("s2", "nightly-pg", "2026-11-13T01:00:00Z")];
const restoreJobs = [
restore("done", "completed", "completed", "2026-11-12T15:00:00Z"),
restore("locked", "recovery_required", "apply_failed", "2026-11-13T22:10:00Z"),
restore("live", "running", "safety", "2026-11-14T10:52:00Z"),
];
const entries = build({ snapshots, restoreJobs });
assert.deepEqual(entries.map(({ group }) => group), ["needs", "running", "history", "history", "history"]);
assert.deepEqual(entries.map(({ id }) => id), ["restore-locked", "restore-live", "snapshot-s1", "snapshot-s2", "restore-done"]);
assert.deepEqual(activityCounts(entries), { running: 1, needs: 1 });
});
test("names a restore by direction and tells where it leads", () => {
const [entry] = build({ snapshots: [snapshot("s1", "media-vault", "2026-11-14T02:00:00Z")], restoreJobs: [restore("a", "completed", "completed", "2026-11-14T03:00:00Z")] })
.filter(({ kind }) => kind === "restore");
assert.match(entry.title, /^media-vault · .+ → pg-staging \/ orders$/);
assert.deepEqual(entry.opens, { kind: "snapshot", id: "s1" });
const [orphan] = build({ restoreJobs: [restore("b", "completed", "completed", "2026-11-14T03:00:00Z", { snapshot_id: "gone-1234-5678" })] });
assert.equal(orphan.opens, null);
assert.match(orphan.title, /^Snapshot gone-123 →/);
});
test("shows the step of a job in flight and ends each state in the right tone", () => {
const entries = build({ restoreJobs: [
restore("q", "queued", "queued", "2026-11-14T10:00:00Z"),
restore("s", "running", "safety", "2026-11-14T10:01:00Z"),
restore("p", "applying", "applying", "2026-11-14T10:02:00Z"),
restore("f", "failed", "wrong_target", "2026-11-14T09:00:00Z"),
restore("c", "cancelled", "cancelled", "2026-11-14T08:00:00Z"),
restore("r", "reconciled", "reconciled", "2026-11-14T07:00:00Z"),
] });
const by = Object.fromEntries(entries.map((entry) => [entry.id, entry]));
assert.equal(by["restore-q"].progress, 0);
assert.equal(by["restore-s"].progress, 2);
assert.equal(by["restore-p"].progress, 3);
assert.deepEqual([by["restore-f"].tone, by["restore-c"].tone, by["restore-r"].tone], ["red", "grey", "green"]);
assert.equal(by["restore-r"].state, "Recovered");
});
test("folds an outpost backup into its snapshot, and keeps unfinished or failed ones", () => {
const orbits = [orbit("mail", "running", { access: "outpost", application_id: "app" })];
const profile = { application_id: "app", orbit_id: "mail", outpost_id: "o", format: "filesystem" };
const job = (id, status, phase, snapshot_id = null) => ({ id, profile, actor: "schedule", status, phase, created_at: sec("2026-11-14T09:00:00Z"), snapshot_id, offsite_status: null });
const entries = build({
snapshots: [snapshot("s1", "mail", "2026-11-14T09:05:00Z")],
orbits,
captureJobs: [job("done", "completed", "completed", "s1"), job("live", "running", "uploading"), job("bad", "failed", "upload_failed")],
});
assert.equal(entries.filter(({ kind }) => kind === "backup").length, 3);
const stored = entries.find(({ id }) => id === "snapshot-s1");
assert.match(stored.meta, /via Outpost · by schedule/);
assert.equal(entries.find(({ id }) => id === "backup-live").progress, 3);
assert.equal(entries.find(({ id }) => id === "backup-bad").tone, "red");
assert.equal(entries.some(({ id }) => id.startsWith("orbit-mail")), false);
});
test("reads a hub orbit's last status when the hub keeps no job list for it", () => {
const entries = build({ orbits: [orbit("a", "running"), orbit("b", "failed"), orbit("c", "completed")], now: NOW });
assert.deepEqual(entries.map(({ id, group }) => [id, group]), [["orbit-b-failed", "needs"], ["orbit-a-running", "running"]]);
assert.equal(entries[0].at, null);
});
test("labels days relative to now", () => {
assert.equal(dayLabel(NOW - 3600_000, NOW), "Today");
assert.equal(dayLabel(NOW - 86_400_000, NOW), "Yesterday");
assert.notEqual(dayLabel(NOW - 5 * 86_400_000, NOW), "Today");
});

View File

@@ -12,12 +12,14 @@ import { SearchIcon, VaultSearch } from "./components/hud/VaultSearch";
import { OperatorGate } from "./components/operator/OperatorGate"; import { OperatorGate } from "./components/operator/OperatorGate";
import { OrbitsView } from "./components/orbits/OrbitsView"; import { OrbitsView } from "./components/orbits/OrbitsView";
import { WormholeView } from "./components/outposts/WormholeView"; import { WormholeView } from "./components/outposts/WormholeView";
import { ActivityView } from "./components/activity/ActivityView";
import { ReconstituteWizard } from "./components/reconstitute/ReconstituteWizard"; import { ReconstituteWizard } from "./components/reconstitute/ReconstituteWizard";
import { VaultScene } from "./components/scene/VaultScene"; import { VaultScene } from "./components/scene/VaultScene";
import { EmptyState } from "./components/ui/EmptyState"; import { EmptyState } from "./components/ui/EmptyState";
import { QueryGate } from "./components/ui/QueryGate"; import { QueryGate } from "./components/ui/QueryGate";
import { SpringPane } from "./components/ui/SpringPane"; import { SpringPane } from "./components/ui/SpringPane";
import { SnapshotSheet } from "./components/vault/SnapshotSheet"; import { SnapshotSheet } from "./components/vault/SnapshotSheet";
import { useActivity } from "./hooks/useActivity";
import { useReducedMotion } from "./hooks/useReducedMotion"; import { useReducedMotion } from "./hooks/useReducedMotion";
import { orbitStatus } from "./lib/format"; import { orbitStatus } from "./lib/format";
import { groupSnapshots } from "./lib/galaxyLayout"; import { groupSnapshots } from "./lib/galaxyLayout";
@@ -26,11 +28,21 @@ import type { SearchResult } from "./lib/vaultSearch";
const panelTitles: Record<HUDMode, string> = { const panelTitles: Record<HUDMode, string> = {
scene: "Vault", scene: "Vault",
orbits: "Orbit management", orbits: "Orbits",
wormhole: "Wormhole uplink", wormhole: "Wormhole uplink",
activity: "Activity",
reconstitute: "Restore snapshot", reconstitute: "Restore snapshot",
snapshot: "Snapshot detail", snapshot: "Snapshot detail",
}; };
const panelLabels: Record<HUDMode, string> = {
scene: "Vault console",
orbits: "Console 02 · Orbit management",
wormhole: "Console 03 · Outposts",
activity: "Console 04 · Activity",
reconstitute: "Restore from a snapshot",
snapshot: "Recovery point",
};
const panelWidths: Record<HUDMode, number> = { scene: 640, orbits: 1120, wormhole: 760, activity: 1120, reconstitute: 760, snapshot: 640 };
const LOOK_KEY = "tessera.look"; const LOOK_KEY = "tessera.look";
@@ -184,12 +196,18 @@ function VaultApp({ actor, onLogout }: { actor?: string; onLogout?: () => Promis
const selected = sceneOrbits.find(({ id }) => id === orbitId); const selected = sceneOrbits.find(({ id }) => id === orbitId);
const history = (selected && grouped.get(selected.id)) ?? []; const history = (selected && grouped.get(selected.id)) ?? [];
const snapshot = snaps.data?.find(({ id }) => id === snapshotId); const snapshot = snaps.data?.find(({ id }) => id === snapshotId);
const snapshotSiblings = useMemo(
() => (snapshot && [...grouped.values()].find((group) => group.some(({ id }) => id === snapshot.id))) || [],
[grouped, snapshot],
);
const snapshotIndex = snapshot ? snapshotSiblings.findIndex(({ id }) => id === snapshot.id) : -1;
const captureGlow = useMotionValue(0); const captureGlow = useMotionValue(0);
const captureOrbitId = capture.variables?.id; const captureOrbitId = capture.variables?.id;
const captureEffect = useMemo(() => captureOrbitId && (capture.isError || capture.data) const captureEffect = useMemo(() => captureOrbitId && (capture.isError || capture.data)
? { orbitId: captureOrbitId, key: capture.submittedAt, snapshotId: capture.data ?? undefined } ? { orbitId: captureOrbitId, key: capture.submittedAt, snapshotId: capture.data ?? undefined }
: undefined, [captureOrbitId, capture.submittedAt, capture.isError, capture.data]); : undefined, [captureOrbitId, capture.submittedAt, capture.isError, capture.data]);
const captureReady = !!captureEffect?.snapshotId && !!snaps.data?.some(({ id }) => id === captureEffect.snapshotId); const captureReady = !!captureEffect?.snapshotId && !!snaps.data?.some(({ id }) => id === captureEffect.snapshotId);
const activity = useActivity(snaps.data, orbits.data);
const failedCount = sceneOrbits.filter(({ last_status }) => last_status === "failed").length; const failedCount = sceneOrbits.filter(({ last_status }) => last_status === "failed").length;
const orbitMessage = orbits.isPending ? "Receiving orbit telemetry…" : orbits.isError const orbitMessage = orbits.isPending ? "Receiving orbit telemetry…" : orbits.isError
@@ -263,25 +281,25 @@ function VaultApp({ actor, onLogout }: { actor?: string; onLogout?: () => Promis
<ellipse cx="19" cy="19" rx="17" ry="5.8" transform="rotate(-32 19 19)" fill="none" stroke="currentColor" /> <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" /> <circle cx="19" cy="19" r="3" fill="currentColor" />
</svg> </svg>
<div><strong>Tessera</strong><span>Backup control</span></div> <div><strong>Tessera</strong><span>Flight deck · Backup control</span></div>
</div> </div>
<HUDRail active={mode === "snapshot" ? "scene" : mode} floating={bigScreen} panelOpen={panelOpen} reducedMotion={reducedMotion} onSelect={openConsole} /> <HUDRail active={mode === "snapshot" || mode === "reconstitute" ? "scene" : mode} alerts={{ activity: activity.counts.needs > 0 }} floating={bigScreen} panelOpen={panelOpen} reducedMotion={reducedMotion} onSelect={openConsole} />
<div className="vault-topbar-tools"> <div className="vault-topbar-tools">
<p className="hub-link" role="status"> <p className="hub-link" role="status">
<span className={`register-signal signal-${online ? "green" : "grey"}`} /> <span className={`register-signal signal-${online ? "green" : "grey"}`} />
{online ? "Hub online" : health.isPending ? "Connecting" : "Hub offline"} {online ? "Hub online" : health.isPending ? "Connecting" : "Hub offline"}
</p> </p>
{onLogout && <button type="button" className="console-control" aria-label="Sign out" {onLogout && <button type="button" className="console-control icon-key" aria-label="Sign out" title="Sign out"
onClick={() => void onLogout().catch(() => setLogoutError(true))}> onClick={() => void onLogout().catch(() => setLogoutError(true))}>
Sign out <span className="sr-only">{actor}</span> <svg viewBox="0 0 16 16" width="15" height="15" aria-hidden="true" fill="none" stroke="currentColor"
strokeWidth="1.3" strokeLinecap="round" strokeLinejoin="round"><path d="M6.5 2.5h-3v11h3M10 5l3 3-3 3M13 8H6.5" /></svg>
<span className="sr-only">{actor}</span>
</button>} </button>}
{logoutError && <p role="alert" className="text-sm text-orbit-red">Could not sign out.</p>} {logoutError && <p role="alert" className="text-sm text-orbit-red">Could not sign out.</p>}
<button type="button" ref={searchTrigger} className="console-control search-trigger" <button type="button" ref={searchTrigger} className="console-control icon-key search-trigger"
aria-label="Search" aria-haspopup="dialog" aria-expanded={searchOpen} aria-keyshortcuts="Meta+K Control+K" aria-label="Search" title="Search (⌘K)" aria-haspopup="dialog" aria-expanded={searchOpen} aria-keyshortcuts="Meta+K Control+K"
onClick={() => setSearchOpen(true)}> onClick={() => setSearchOpen(true)}>
<SearchIcon /> <SearchIcon />
<span>Search</span>
<kbd aria-hidden="true">⌘K / Ctrl+K</kbd>
</button> </button>
</div> </div>
</header> </header>
@@ -335,7 +353,9 @@ function VaultApp({ actor, onLogout }: { actor?: string; onLogout?: () => Promis
</div> </div>
<footer className="vault-footer"> <footer className="vault-footer">
{(!noticeInInspector && mode !== "orbits" && captureNotice) || <p>Vault telemetry</p>} {(!noticeInInspector && mode !== "orbits" && captureNotice) || <p>Vault telemetry</p>}
<p role="status">{restoreBusy ? "Restore active · open Restore to monitor" : "Local backup station"}</p> <p role="status">{restoreBusy
? <button type="button" className="footer-link" onClick={() => openConsole("reconstitute")}>Restore active · open to monitor</button>
: "Local backup station"}</p>
</footer> </footer>
</main> </main>
@@ -343,6 +363,9 @@ function VaultApp({ actor, onLogout }: { actor?: string; onLogout?: () => Promis
open={panelOpen} open={panelOpen}
inert={searchOpen} inert={searchOpen}
title={panelTitles[mode]} title={panelTitles[mode]}
label={mode === "snapshot" && snapshotIndex >= 0 ? `Recovery point · ${snapshotIndex + 1} of ${snapshotSiblings.length}` : panelLabels[mode]}
width={panelWidths[mode]}
flush={mode === "orbits" || mode === "reconstitute"}
subtitle={mode === "reconstitute" ? "Review the destination before starting the restore." : undefined} subtitle={mode === "reconstitute" ? "Review the destination before starting the restore." : undefined}
onClose={() => setMode("scene")} onClose={() => setMode("scene")}
> >
@@ -354,13 +377,28 @@ function VaultApp({ actor, onLogout }: { actor?: string; onLogout?: () => Promis
</QueryGate> </QueryGate>
</SpringPane> </SpringPane>
)} )}
{mode === "activity" && (
<SpringPane key="activity">
<ActivityView
entries={activity.entries} counts={activity.counts} updatedAt={activity.updatedAt}
restoresUnavailable={activity.restoresUnavailable} capturesUnavailable={activity.capturesUnavailable}
onOpen={(target) => {
if (target.kind === "snapshot") openSnapshot(target.id);
else {
selectOrbit(target.id);
setMode("scene");
}
}}
/>
</SpringPane>
)}
{mode === "wormhole" && ( {mode === "wormhole" && (
<SpringPane key="wormhole"><WormholeView pairing={pairing} onPaired={setPairing} /></SpringPane> <SpringPane key="wormhole"><WormholeView pairing={pairing} onPaired={setPairing} /></SpringPane>
)} )}
{mode === "snapshot" && ( {mode === "snapshot" && (
<SpringPane key="snapshot"> <SpringPane key="snapshot">
{snapshot {snapshot
? <SnapshotSheet snap={snapshot} onDeleted={() => openConsole("scene")} onReconstitute={() => openConsole("reconstitute", snapshot.id)} /> ? <SnapshotSheet snap={snapshot} siblings={snapshotSiblings} onDeleted={() => openConsole("scene")} onReconstitute={() => openConsole("reconstitute", snapshot.id)} />
: <EmptyState title="Snapshot unavailable" body="It may have expired under the retention policy." />} : <EmptyState title="Snapshot unavailable" body="It may have expired under the retention policy." />}
</SpringPane> </SpringPane>
)} )}

View File

@@ -248,8 +248,17 @@ export type RestoreJob = {
status: "queued" | "running" | "applying" | "failed" | "completed" | "recovery_required" | "reconciled" | "cancelled"; status: "queued" | "running" | "applying" | "failed" | "completed" | "recovery_required" | "reconciled" | "cancelled";
phase: string; phase: string;
safety_snapshot_id: string | null; safety_snapshot_id: string | null;
actor: string;
/** Seconds since the epoch. */
created_at: number;
updated_at: number;
}; };
/** The newest restore jobs across every snapshot. Older hubs answer 404 or 405. */
export function fetchRecentRestoreJobs(limit = 100): Promise<RestoreJob[]> {
return api(`/api/v1/restore-jobs?limit=${limit}`);
}
export function fetchRestoreTargets(snapshot: string): Promise<SnapshotRestoreTarget[]> { export function fetchRestoreTargets(snapshot: string): Promise<SnapshotRestoreTarget[]> {
return api(`/api/v1/snapshots/${snapshot}/restore-targets`); return api(`/api/v1/snapshots/${snapshot}/restore-targets`);
} }

View File

@@ -0,0 +1,122 @@
import { useEffect, useState } from "react";
import type { ActivityEntry, ActivityTarget } from "../../lib/activity";
import { clock, dayLabel } from "../../lib/activity";
import { Segmented } from "../ui/Segmented";
type Kind = "all" | "backup" | "restore";
const PAGE = 80;
function Row({ entry, now, onOpen }: { entry: ActivityEntry; now: number; onOpen: (target: ActivityTarget) => void }) {
const opens = entry.opens;
const content = (
<>
<span className="act-time">{entry.group === "running" && entry.id.startsWith("orbit-") ? "now" : entry.at === null ? "—" : clock(entry.at)}</span>
<span className="act-kind" data-kind={entry.kind}>
<i className="act-glyph" data-tone={entry.tone} aria-hidden="true" />
{entry.kind === "backup" ? "Backup" : "Restore"}
</span>
<span className="act-text">
<span className="act-title">{entry.title}</span>
<small>{entry.meta}</small>
</span>
<span className="act-state" data-tone={entry.tone}>
{entry.state}
{entry.progress !== undefined && (
<span className="act-ticks" aria-hidden="true">
{[0, 1, 2, 3, 4].map((tick) => (
<i key={tick} data-state={tick < entry.progress! ? "done" : tick === entry.progress ? "now" : "todo"} />
))}
</span>
)}
</span>
<span className="act-open">{opens ? `${opens.kind} ›` : "removed"}</span>
</>
);
void now;
return opens ? (
<button type="button" className="act-row" data-group={entry.group} data-tone={entry.tone} onClick={() => onOpen(opens)}>{content}</button>
) : (
<div className="act-row" data-group={entry.group} data-tone={entry.tone} data-static="true">{content}</div>
);
}
export function ActivityView({ entries, counts, restoresUnavailable, capturesUnavailable, updatedAt, onOpen }: {
entries: ActivityEntry[];
counts: { running: number; needs: number };
restoresUnavailable: boolean;
capturesUnavailable: boolean;
updatedAt: number;
onOpen: (target: ActivityTarget) => void;
}) {
const [kind, setKind] = useState<Kind>("all");
const [query, setQuery] = useState("");
const [shown, setShown] = useState(PAGE);
const [now, setNow] = useState(() => Date.now());
useEffect(() => {
const timer = window.setInterval(() => setNow(Date.now()), 1000);
return () => window.clearInterval(timer);
}, []);
const term = query.trim().toLowerCase();
const matching = entries.filter((entry) =>
(kind === "all" || entry.kind === kind) && (!term || `${entry.title} ${entry.meta}`.toLowerCase().includes(term)));
const visible = matching.slice(0, Math.max(shown, matching.filter(({ group }) => group !== "history").length));
const sections: { label: string; tone?: string; items: ActivityEntry[] }[] = [];
for (const entry of visible) {
const label = entry.group === "needs" ? "Needs you" : entry.group === "running" ? "Running now"
: entry.at === null ? "Earlier" : dayLabel(entry.at, now);
const last = sections.at(-1);
if (last?.label === label) last.items.push(entry);
else sections.push({ label, tone: entry.group === "history" ? undefined : entry.group, items: [entry] });
}
const age = updatedAt ? Math.max(0, Math.round((now - updatedAt) / 1000)) : undefined;
return (
<div className="activity">
<div className="activity-bar">
<p className="activity-lead">One log of everything that has run or is running. Open an entry to see its snapshot; restores and exports start there.</p>
<dl className="activity-counts">
<div><dt><i className="act-glyph" data-tone="amber" aria-hidden="true" />Running</dt><dd>{counts.running}</dd></div>
<div data-alert={counts.needs > 0}><dt><i className="act-glyph" data-tone="red" aria-hidden="true" />Needs you</dt><dd>{counts.needs}</dd></div>
</dl>
</div>
<div className="activity-tools">
<label className="activity-search">
<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" aria-hidden="true">
<circle cx="7" cy="7" r="4.5" /><path d="m10.5 10.5 3.5 3.5" />
</svg>
<input type="text" value={query} placeholder="Filter by orbit or target" aria-label="Filter the log"
onChange={(event) => { setQuery(event.target.value); setShown(PAGE); }} />
</label>
<Segmented label="Kind" value={kind} onChange={(value) => { setKind(value); setShown(PAGE); }}
options={[{ value: "all", label: "All" }, { value: "backup", label: "Backups" }, { value: "restore", label: "Restores" }]} />
<span className="activity-age" role="status">{age === undefined ? "Loading…" : `Updated ${age} s ago`}</span>
</div>
{(restoresUnavailable || capturesUnavailable) && (
<p role="alert" className="activity-warning">
{restoresUnavailable ? "Restore history is unavailable. This hub may be too old to list restore jobs." : "Outpost backup jobs are unavailable."}
{" "}The rest of the log is still shown.
</p>
)}
<div className="activity-list">
{sections.map((section) => (
<section key={section.label} aria-label={section.label}>
<h3 data-tone={section.tone}>{section.label}</h3>
{section.items.map((entry) => <Row key={entry.id} entry={entry} now={now} onOpen={onOpen} />)}
</section>
))}
{!sections.length && (
<div className="activity-empty">
<p>{entries.length ? "No entries" : "Nothing yet"}</p>
<span>{entries.length ? "Nothing in the log matches that filter." : "Backups and restores will appear here as they run."}</span>
</div>
)}
{matching.length > visible.length && (
<button type="button" className="activity-more" onClick={() => setShown(shown + PAGE)}>
Show older · {matching.length - visible.length} more
</button>
)}
</div>
</div>
);
}

View File

@@ -40,12 +40,12 @@ export function TelemetryStrip({
useScreenTransition(strip, bigScreen, reducedMotion, undefined, true); useScreenTransition(strip, bigScreen, reducedMotion, undefined, true);
return ( return (
<dl ref={strip} className="vault-telemetry"> <dl ref={strip} className="vault-telemetry">
<div><dt>Orbits</dt><dd><TelemetryValue value={orbitCount} /></dd></div> <div data-metric="orbits"><dt>Orbits</dt><dd><TelemetryValue value={orbitCount} /></dd></div>
<div><dt>Failed</dt><dd className={failedCount ? "telemetry-alert" : ""}> <div data-metric="failed" data-state={failedCount ? "alert" : "ok"}><dt>Failed</dt><dd className={failedCount ? "telemetry-alert" : ""}>
<TelemetryValue value={orbitCount === undefined ? undefined : failedCount} /> <TelemetryValue value={orbitCount === undefined ? undefined : failedCount} />
</dd></div> </dd></div>
<div><dt>Snapshots</dt><dd><TelemetryValue value={snapCount} /></dd></div> <div data-metric="snapshots"><dt>Snapshots</dt><dd><TelemetryValue value={snapCount} /></dd></div>
<div><dt>Payload</dt><dd><TelemetryValue value={snapCount === undefined ? undefined : totalBytes} bytes /></dd></div> <div data-metric="payload"><dt>Payload</dt><dd><TelemetryValue value={snapCount === undefined ? undefined : totalBytes} bytes /></dd></div>
</dl> </dl>
); );
} }
@@ -76,8 +76,8 @@ export function OrbitRegister({
<motion.section className="vault-console orbit-register" aria-labelledby="register-title" inert={bigScreen} <motion.section className="vault-console orbit-register" aria-labelledby="register-title" inert={bigScreen}
initial={false} animate={{ opacity: bigScreen ? 0 : 1 }}> initial={false} animate={{ opacity: bigScreen ? 0 : 1 }}>
<header className="console-heading"> <header className="console-heading">
<p className="instrument-label">Flight register</p> <p className="instrument-label">Orbit register · L</p>
<h2 id="register-title">Orbits</h2> <h2 id="register-title">{orbits.length === 1 ? "1 orbit" : `${orbits.length} orbits`}</h2>
</header> </header>
{message && <p className="console-empty" role="status">{message}</p>} {message && <p className="console-empty" role="status">{message}</p>}
<motion.ul className="register-list" layoutScroll> <motion.ul className="register-list" layoutScroll>
@@ -132,7 +132,7 @@ export function OrbitInspector({
<motion.section className="vault-console orbit-inspector" aria-labelledby="inspector-title" inert={bigScreen} <motion.section className="vault-console orbit-inspector" aria-labelledby="inspector-title" inert={bigScreen}
initial={false} animate={{ opacity: bigScreen ? 0 : 1 }}> initial={false} animate={{ opacity: bigScreen ? 0 : 1 }}>
<header className="console-heading"> <header className="console-heading">
<p className="instrument-label">Orbit detail</p> <p className="instrument-label">Orbit inspector · R</p>
<h2 id="inspector-title">{orbit?.name ?? "Select an orbit"}</h2> <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>} {orbit && <p className={`inspector-state tone-${status.tone}`}><span className={`register-signal signal-${status.tone}`} />{status.label}</p>}
</header> </header>

View File

@@ -1,11 +1,17 @@
import { motion } from "motion/react"; import { motion } from "motion/react";
import { useEffect, useId, useLayoutEffect, useRef, type ReactNode } from "react"; import { useEffect, useId, useLayoutEffect, useRef, type CSSProperties, type ReactNode } from "react";
export function HUDPanel({ export function HUDPanel({
open, title, subtitle, onClose, children, inert, open, title, label = "Vault console", width = 640, flush = false, subtitle, onClose, children, inert,
}: { }: {
open: boolean; open: boolean;
title: string; title: string;
/** Engraved line above the title, e.g. "Console 02 · Orbit management". */
label?: string;
/** Console screen width in px; it never exceeds the viewport. */
width?: number;
/** Drop the content padding so a view can lay out its own columns. */
flush?: boolean;
subtitle?: string; subtitle?: string;
onClose: () => void; onClose: () => void;
children: ReactNode; children: ReactNode;
@@ -64,19 +70,21 @@ export function HUDPanel({
aria-hidden={!open} aria-hidden={!open}
inert={!open || inert} inert={!open || inert}
initial={false} initial={false}
animate={{ x: open ? "0%" : "100%" }} style={{ "--console-width": `${width}px` } as CSSProperties}
animate={{ opacity: open ? 1 : 0, y: open ? 0 : 18 }}
> >
<header className="dialog-heading"> <header className="dialog-heading">
<div> <div>
<p className="instrument-label">Vault console</p> <p className="instrument-label">{label}</p>
<h2 id={labelId} ref={heading} tabIndex={-1}>{display.title}</h2> <h2 id={labelId} ref={heading} tabIndex={-1}>{display.title}</h2>
{display.subtitle && <p id={descriptionId}>{display.subtitle}</p>} {display.subtitle && <p id={descriptionId}>{display.subtitle}</p>}
</div> </div>
<button type="button" className="console-control" onClick={onClose}> <button type="button" className="console-control dialog-close" aria-label="Close console" title="Close (Esc)" onClick={onClose}>
Close <span aria-hidden="true">×</span> <span aria-hidden="true">ESC</span>
<svg viewBox="0 0 16 16" width="12" height="12" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" aria-hidden="true"><path d="m3 3 10 10M13 3 3 13" /></svg>
</button> </button>
</header> </header>
<div className="dialog-content"><div className="spring-stack">{children}</div></div> <div className={flush ? "dialog-content dialog-content--flush" : "dialog-content"}><div className="spring-stack">{children}</div></div>
</motion.aside> </motion.aside>
</div> </div>
); );

View File

@@ -3,22 +3,24 @@ import { useCallback, useId, useLayoutEffect, useRef, type PointerEvent } from "
import { useScreenTransition } from "../../hooks/useScreenTransition"; import { useScreenTransition } from "../../hooks/useScreenTransition";
import { uiSpring } from "../../lib/motion"; import { uiSpring } from "../../lib/motion";
export type HUDMode = "scene" | "orbits" | "wormhole" | "reconstitute" | "snapshot"; export type HUDMode = "scene" | "orbits" | "wormhole" | "activity" | "reconstitute" | "snapshot";
export const hudItems = [ export const hudItems = [
{ id: "scene", label: "Vault", icon: "M4 9l8-4 8 4v6l-8 4-8-4z M4 9l8 4 8-4 M12 13v6" }, { id: "scene", label: "Vault", icon: "M4 9l8-4 8 4v6l-8 4-8-4z M4 9l8 4 8-4 M12 13v6" },
{ id: "orbits", label: "Orbits", icon: "M21 12a9 5 0 1 1-18 0 9 5 0 1 1 18 0z M12 10.5a1.5 1.5 0 1 1 0 3 1.5 1.5 0 1 1 0-3z M18 5h.01" }, { id: "orbits", label: "Orbits", icon: "M21 12a9 5 0 1 1-18 0 9 5 0 1 1 18 0z M12 10.5a1.5 1.5 0 1 1 0 3 1.5 1.5 0 1 1 0-3z M18 5h.01" },
{ id: "wormhole", label: "Outposts", icon: "M12 3v3 M4.2 7.5l2.6 1.5 M4.2 16.5 6.8 15 M12 18v3 M17.2 15l2.6 1.5 M17.2 9l2.6-1.5 M15.5 12a3.5 3.5 0 1 1-7 0 3.5 3.5 0 1 1 7 0z" }, { id: "wormhole", label: "Outposts", icon: "M12 3v3 M4.2 7.5l2.6 1.5 M4.2 16.5 6.8 15 M12 18v3 M17.2 15l2.6 1.5 M17.2 9l2.6-1.5 M15.5 12a3.5 3.5 0 1 1-7 0 3.5 3.5 0 1 1 7 0z" },
{ id: "reconstitute", label: "Restore", icon: "M4 12a8 8 0 1 1 2.3 5.7 M4 6v6h6 M12 8v4l3 2" }, { id: "activity", label: "Activity", icon: "M3 12h4l3-7 4 14 3-7h4" },
] as const; ] as const;
type Slot = { center: number; width: number }; type Slot = { center: number; width: number };
type Gesture = { pointer: number; x: number; y: number; origin?: number }; type Gesture = { pointer: number; x: number; y: number; origin?: number };
export function HUDRail({ export function HUDRail({
active, floating, panelOpen, reducedMotion, onSelect, active, floating, panelOpen, reducedMotion, alerts, onSelect,
}: { }: {
active: HUDMode; active: HUDMode;
/** Tabs with something that needs a person: their lamp turns ember even when they are not the active tab. */
alerts?: Partial<Record<HUDMode, boolean>>;
floating: boolean; floating: boolean;
panelOpen: boolean; panelOpen: boolean;
reducedMotion: boolean; reducedMotion: boolean;
@@ -169,6 +171,8 @@ export function HUDRail({
key={id} key={id}
type="button" type="button"
aria-label={label} aria-label={label}
data-tab={id}
data-alert={alerts?.[id] ? "true" : undefined}
title={floating ? label : undefined} title={floating ? label : undefined}
onClick={() => onSelect(id)} onClick={() => onSelect(id)}
aria-current={active === id ? "page" : undefined} aria-current={active === id ? "page" : undefined}

View File

@@ -123,7 +123,7 @@ export function VaultSearch({ open, reducedMotion, orbits, snapshots, orbitStatu
<input ref={input} type="text" role="combobox" aria-label="Search vault" <input ref={input} type="text" role="combobox" aria-label="Search vault"
aria-autocomplete="list" aria-expanded={!!results.length} aria-controls={`${id}-results`} aria-autocomplete="list" aria-expanded={!!results.length} aria-controls={`${id}-results`}
aria-activedescendant={activeOption} aria-activedescendant={activeOption}
autoComplete="off" autoCapitalize="none" spellCheck={false} placeholder="Search the vault…" autoComplete="off" autoCapitalize="none" spellCheck={false} placeholder="Search orbits, snapshots, consoles…"
value={query} onChange={event => { value={query} onChange={event => {
setQuery(event.currentTarget.value); setQuery(event.currentTarget.value);
setActiveId(undefined); setActiveId(undefined);
@@ -152,19 +152,31 @@ export function VaultSearch({ open, reducedMotion, orbits, snapshots, orbitStatu
<span>{result.label}</span> <span>{result.label}</span>
{result.detail && <small>{result.detail}</small>} {result.detail && <small>{result.detail}</small>}
</span> </span>
<span className="search-result-hint" aria-hidden="true">
{result.kind === "navigation" ? "Console" : result.kind === "orbit" ? "Orbit" : "Snapshot"}
</span>
</div> </div>
); );
})} })}
</div> </div>
))} ))}
</div> </div>
{!results.length && (
<div className="search-empty" aria-hidden="true">
<p>No signal</p>
<span>Nothing matches that. Try an orbit name, ID, provider, or a capture date.</span>
</div>
)}
</div>
</motion.div>
<footer className="search-footer">
<span className="search-keys" aria-hidden="true"><span>↑↓ Move</span><span>↵ Open</span><span>Esc Close</span></span>
<p className="search-status" role="status"> <p className="search-status" role="status">
<span>{results.length ? `${results.length} ${query.trim() ? "results shown" : "destinations"}` : "No matching results."}</span> <span>{results.length ? `${results.length} ${query.trim() ? "results shown" : "destinations"}` : "No matching results."}</span>
{orbitStatus && <span>{orbitStatus}</span>} {orbitStatus && <span>{orbitStatus}</span>}
{snapshotStatus && <span>{snapshotStatus}</span>} {snapshotStatus && <span>{snapshotStatus}</span>}
</p> </p>
</div> </footer>
</motion.div>
</motion.section> </motion.section>
</motion.div> </motion.div>
); );

View File

@@ -4,8 +4,9 @@ import { registerCaptureProfile, type BackupSource, type CaptureProfile } from "
import { OutpostField } from "../outposts/OutpostField"; import { OutpostField } from "../outposts/OutpostField";
import { Button } from "../ui/Button"; import { Button } from "../ui/Button";
import { Hint } from "../ui/EmptyState"; import { Hint } from "../ui/EmptyState";
import { Select } from "../ui/Select";
const field = "mt-1 w-full rounded-xl bg-space-950 border border-space-700 px-3 py-2"; const field = "field";
const uuidPattern = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"; const uuidPattern = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}";
export function CaptureProfileForm({ orbitId, source, onClose }: { orbitId: string; source: BackupSource | null; onClose: () => void }) { export function CaptureProfileForm({ orbitId, source, onClose }: { orbitId: string; source: BackupSource | null; onClose: () => void }) {
@@ -45,10 +46,10 @@ export function CaptureProfileForm({ orbitId, source, onClose }: { orbitId: stri
<OutpostField className={field} /> <OutpostField className={field} />
{source !== "filesystem" && <label className="block text-sm text-star-300"> {source !== "filesystem" && <label className="block text-sm text-star-300">
Database engine Database engine
<select name="format" className={field}> <Select name="format">
<option value="postgres_sql">PostgreSQL</option> <option value="postgres_sql">PostgreSQL</option>
<option value="mysql_sql">MySQL</option> <option value="mysql_sql">MySQL</option>
</select> </Select>
</label>} </label>}
<label className="block text-sm text-star-300"> <label className="block text-sm text-star-300">
Daily backup time (UTC, optional) Daily backup time (UTC, optional)

View File

@@ -3,6 +3,7 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { enqueueCapture, fetchCaptureEvents, fetchCaptureJobs, fetchSnapshots, type CaptureProfile, type Orbit } from "../../api"; import { enqueueCapture, fetchCaptureEvents, fetchCaptureJobs, fetchSnapshots, type CaptureProfile, type Orbit } from "../../api";
import { formatWhen } from "../../lib/format"; import { formatWhen } from "../../lib/format";
import { Button } from "../ui/Button"; import { Button } from "../ui/Button";
import { Select } from "../ui/Select";
const labels: Record<string, string> = { const labels: Record<string, string> = {
queued: "Waiting for outpost", queued: "Waiting for outpost",
@@ -14,7 +15,7 @@ const labels: Record<string, string> = {
completed: "Backup completed", completed: "Backup completed",
}; };
const input = "mt-1 block w-full rounded-xl border border-space-700 bg-space-950 px-3 py-2 text-star-100"; const input = "field";
export function JobHistory({ export function JobHistory({
profiles, orbits, snapshots, onOpenSnapshot, profiles, orbits, snapshots, onOpenSnapshot,
@@ -52,28 +53,28 @@ export function JobHistory({
}); });
return ( return (
<section className="mb-6 space-y-4 rounded-2xl border border-space-700 bg-space-800/50 p-4"> <section className="orbit-panel mb-4 space-y-4">
<div> <div>
<h3 className="font-semibold text-star-100">Outpost backup jobs</h3> <h3 className="orbit-panel-title">Outpost backup jobs</h3>
<p className="mt-1 text-sm text-star-300">Jobs wait for the assigned outpost when it is offline.</p> <p className="mt-1 text-sm text-star-300">Jobs wait for the assigned outpost when it is offline.</p>
</div> </div>
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2"> <div className="grid grid-cols-1 gap-3 sm:grid-cols-2">
<div> <div>
<label className="text-sm text-star-300" htmlFor={`${filters}-application`}>Application</label> <label className="field-label" htmlFor={`${filters}-application`}>Application</label>
<select id={`${filters}-application`} className={input} value={application} onChange={(event) => setApplication(event.target.value)}> <Select id={`${filters}-application`} value={application} onChange={(event) => setApplication(event.target.value)}>
<option value="">All applications</option> <option value="">All applications</option>
{profiles.map((profile) => <option key={profile.application_id} value={profile.application_id}>{name(profile)}</option>)} {profiles.map((profile) => <option key={profile.application_id} value={profile.application_id}>{name(profile)}</option>)}
</select> </Select>
</div> </div>
<div> <div>
<label className="text-sm text-star-300" htmlFor={`${filters}-status`}>Job status</label> <label className="field-label" htmlFor={`${filters}-status`}>Job status</label>
<select id={`${filters}-status`} className={input} value={status} onChange={(event) => setStatus(event.target.value)}> <Select id={`${filters}-status`} value={status} onChange={(event) => setStatus(event.target.value)}>
<option value="">Any status</option> <option value="">Any status</option>
<option value="queued">Queued</option> <option value="queued">Queued</option>
<option value="running">Running</option> <option value="running">Running</option>
<option value="completed">Completed</option> <option value="completed">Completed</option>
<option value="failed">Failed</option> <option value="failed">Failed</option>
</select> </Select>
</div> </div>
</div> </div>
<Button variant="success" disabled={!application || enqueue.isPending} <Button variant="success" disabled={!application || enqueue.isPending}
@@ -87,7 +88,7 @@ export function JobHistory({
{jobs.data?.length === 0 && <p className="text-sm text-star-300">No jobs match these filters.</p>} {jobs.data?.length === 0 && <p className="text-sm text-star-300">No jobs match these filters.</p>}
<ul className="space-y-2"> <ul className="space-y-2">
{jobs.data?.map((job) => ( {jobs.data?.map((job) => (
<li key={job.id} className="rounded-xl border border-space-700 px-3 py-2"> <li key={job.id} className="orbit-job">
<button type="button" aria-expanded={selected === job.id} <button type="button" aria-expanded={selected === job.id}
className="flex w-full flex-wrap items-center justify-between gap-2 py-1 text-left text-sm text-star-100" className="flex w-full flex-wrap items-center justify-between gap-2 py-1 text-left text-sm text-star-100"
onClick={() => setSelected(selected === job.id ? undefined : job.id)}> onClick={() => setSelected(selected === job.id ? undefined : job.id)}>

View File

@@ -1,5 +1,4 @@
import { useState, type ReactNode } from "react"; import { useState, type ReactNode } from "react";
import { AnimatePresence } from "motion/react";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import type { BackupAccess, BackupSource, Orbit, Snapshot } from "../../api"; import type { BackupAccess, BackupSource, Orbit, Snapshot } from "../../api";
import { createOrbit, fetchCaptureProfiles, updateOrbitRetention } from "../../api"; import { createOrbit, fetchCaptureProfiles, updateOrbitRetention } from "../../api";
@@ -8,10 +7,10 @@ import { CaptureProfileForm } from "./CaptureProfileForm";
import { JobHistory } from "./JobHistory"; import { JobHistory } from "./JobHistory";
import { describeRetention, retentionDraft, RetentionFields, retentionSettings } from "./RetentionFields"; import { describeRetention, retentionDraft, RetentionFields, retentionSettings } from "./RetentionFields";
import { Button } from "../ui/Button"; import { Button } from "../ui/Button";
import { OrbitStatusDot } from "../ui/StatusDot"; import { Segmented } from "../ui/Segmented";
import { TelemetryPanel } from "../ui/Telemetry"; import { TelemetryPanel } from "../ui/Telemetry";
import { Hint } from "../ui/EmptyState"; import { Hint } from "../ui/EmptyState";
import { SpringPane } from "../ui/SpringPane"; import { Select } from "../ui/Select";
export function OrbitsView({ export function OrbitsView({
orbits, snapshots, onRun, onOpenSnapshot, captureDisabled, notice, orbits, snapshots, onRun, onOpenSnapshot, captureDisabled, notice,
@@ -23,7 +22,6 @@ export function OrbitsView({
captureDisabled: boolean; captureDisabled: boolean;
notice?: ReactNode; notice?: ReactNode;
}) { }) {
const [editing, setEditing] = useState(false);
const qc = useQueryClient(); const qc = useQueryClient();
const profiles = useQuery({ queryKey: ["capture-profiles"], queryFn: fetchCaptureProfiles }); const profiles = useQuery({ queryKey: ["capture-profiles"], queryFn: fetchCaptureProfiles });
const [name, setName] = useState("nightly-docs"); const [name, setName] = useState("nightly-docs");
@@ -64,12 +62,24 @@ export function OrbitsView({
onSuccess: (orbit) => { onSuccess: (orbit) => {
void qc.invalidateQueries({ queryKey: ["orbits"] }); void qc.invalidateQueries({ queryKey: ["orbits"] });
if (orbit.access === "outpost") setProfileOrbit(orbit.id); if (orbit.access === "outpost") setProfileOrbit(orbit.id);
setEditing(false); resetForm();
}, },
}); });
const resetForm = () => {
setName("nightly-docs");
setSource("filesystem");
setAccess("hub");
setEngine("postgres");
setPath("./docs");
setSchedule("0 2 * * *");
setRetention(retentionDraft());
setRehearse(false);
create.reset();
};
return ( return (
<div> <div className="orbits-layout">
<div className="orbits-list">
{notice} {notice}
{profiles.isError && <p role="alert" className="mb-4 text-sm text-orbit-red">Outpost backup profiles are unavailable.</p>} {profiles.isError && <p role="alert" className="mb-4 text-sm text-orbit-red">Outpost backup profiles are unavailable.</p>}
<JobHistory profiles={profiles.data ?? []} orbits={orbits} <JobHistory profiles={profiles.data ?? []} orbits={orbits}
@@ -77,44 +87,37 @@ export function OrbitsView({
{profiles.data?.length === 0 && <p className="mb-4 text-sm text-star-300"> {profiles.data?.length === 0 && <p className="mb-4 text-sm text-star-300">
Register an Outpost capture profile to start queueing jobs. Register an Outpost capture profile to start queueing jobs.
</p>} </p>}
<div className="orbit-cards">
<div className="space-y-3 mb-6"> {orbits.map((o) => {
{orbits.map((o) => ( const status = orbitStatus(o.last_status);
<article const blocked = (o.access === "outpost" && !o.application_id) || captureDisabled || status.busy;
key={o.id} return (
className="rounded-2xl border border-space-700 bg-space-800/50 p-4 backdrop-blur-sm" <article key={o.id} className="orbit-card" data-status={status.tone}>
> <div className="orbit-card-head">
<div className="flex items-start gap-3"> <span className={`register-signal signal-${status.tone}`} aria-hidden="true" />
<OrbitStatusDot status={o.last_status} /> <div className="min-w-0">
<div className="flex-1 min-w-0"> <h3>
<h3 className="font-semibold text-star-100 truncate">{o.name}</h3> {o.name}
<p className="text-sm text-star-300">{orbitStatus(o.last_status).label}</p> {o.dry_run && <span className="orbit-tag">Rehearse mode</span>}
<p className="text-xs text-star-400"> </h3>
{o.source === "filesystem" ? "Filesystem / Folder" : o.source === "database" ? "Database" : "Backup"} · {o.access === "outpost" ? "Via Outpost" : "Via Hub"} <p className="orbit-meta">
{o.source === "filesystem" ? "Filesystem" : o.source === "database" ? "Database" : "Backup"}
{" · "}{o.access === "outpost" ? "via Outpost" : "via Hub"}
{" · "}{schedulePhrase(o)}
</p> </p>
<p className="text-xs text-star-400 mt-0.5">{schedulePhrase(o)}</p> <p className="orbit-meta">{describeRetention(o)}</p>
<p className="text-xs text-star-400 mt-0.5">{describeRetention(o)}</p> <p className={`orbit-state tone-${status.tone}`}>{status.label}</p>
{o.dry_run && (
<span className="inline-block mt-2 text-[10px] uppercase tracking-wider text-orbit-amber border border-orbit-amber/30 rounded px-2 py-0.5">
Rehearse mode
</span>
)}
</div> </div>
</div> <div className="orbit-card-actions">
<div className="flex gap-2 mt-4"> <Button variant="primary" disabled={blocked} onClick={() => onRun(o)}>
<Button
variant="success"
className="flex-1 text-xs py-2"
disabled={(o.access === "outpost" && !o.application_id) || captureDisabled || orbitStatus(o.last_status).busy}
onClick={() => onRun(o)}
>
{o.application_id ? "Queue backup" : o.access === "outpost" ? "Outpost capture" : o.dry_run ? "Rehearse" : "Capture now"} {o.application_id ? "Queue backup" : o.access === "outpost" ? "Outpost capture" : o.dry_run ? "Rehearse" : "Capture now"}
</Button> </Button>
<Button className="flex-1 text-xs py-2" onClick={() => setEditingRetention(o.id)} <Button onClick={() => setEditingRetention(o.id)}
disabled={editingRetention === o.id || o.retention_source === "profile"}> disabled={editingRetention === o.id || o.retention_source === "profile"}>
Edit retention Edit retention
</Button> </Button>
</div> </div>
</div>
{editingRetention === o.id && <OrbitRetentionEditor orbit={o} onClose={() => setEditingRetention(null)} />} {editingRetention === o.id && <OrbitRetentionEditor orbit={o} onClose={() => setEditingRetention(null)} />}
{o.access === "outpost" && !o.dry_run && !o.application_id && ( {o.access === "outpost" && !o.dry_run && !o.application_id && (
profileOrbit === o.id profileOrbit === o.id
@@ -125,111 +128,68 @@ export function OrbitsView({
{JSON.stringify(o, null, 2)} {JSON.stringify(o, null, 2)}
</TelemetryPanel> </TelemetryPanel>
</article> </article>
))} );
})}
</div> </div>
</div>
<div className="spring-stack"> <form className="orbits-new" aria-label="New orbit"
<AnimatePresence initial={false}>
{editing ? (
<SpringPane key="form">
<form className="rounded-2xl border border-wormhole-violet/30 bg-space-900 p-4 space-y-3"
onSubmit={(event) => { event.preventDefault(); if (!create.isPending) create.mutate(new FormData(event.currentTarget)); }}> onSubmit={(event) => { event.preventDefault(); if (!create.isPending) create.mutate(new FormData(event.currentTarget)); }}>
<h3 className="font-medium text-star-100">New orbit</h3> <div>
<p className="orbits-new-label">New orbit</p>
<p className="mt-1 text-[13px] text-star-400">Plot a backup job around the vault.</p>
</div>
<label className="block text-sm"> <label className="block text-sm">
<span className="text-star-400">Name</span> <span className="field-label">Name</span>
<input <input className="field" required value={name} onChange={(e) => setName(e.target.value)} />
className="mt-1 w-full rounded-xl bg-space-950 border border-space-700 px-3 py-2"
required value={name}
onChange={(e) => setName(e.target.value)}
/>
</label>
<label className="block text-sm">
<span className="text-star-400">Backup source</span>
<select className="mt-1 w-full rounded-xl bg-space-950 border border-space-700 px-3 py-2"
value={source} onChange={(event) => setSource(event.target.value as BackupSource)}>
<option value="filesystem">Filesystem / Folder</option>
<option value="database">Database</option>
</select>
</label>
<label className="block text-sm">
<span className="text-star-400">Access</span>
<select className="mt-1 w-full rounded-xl bg-space-950 border border-space-700 px-3 py-2"
value={access} onChange={(event) => setAccess(event.target.value as BackupAccess)}>
<option value="hub">Via Hub</option>
<option value="outpost">Via Outpost</option>
</select>
</label> </label>
<Segmented label="Backup source" value={source} onChange={setSource}
options={[{ value: "filesystem", label: "Folder" }, { value: "database", label: "Database" }]} />
<Segmented label="Access" value={access} onChange={setAccess}
options={[{ value: "hub", label: "Via hub" }, { value: "outpost", label: "Via outpost" }]} />
{!viaOutpost && source === "filesystem" && <label className="block text-sm"> {!viaOutpost && source === "filesystem" && <label className="block text-sm">
<span className="text-star-400">Folder path visible to the hub</span> <span className="field-label">Folder path visible to the hub</span>
<input className="mt-1 w-full rounded-xl bg-space-950 border border-space-700 px-3 py-2 font-mono text-xs" <input className="field field-mono" required value={path} onChange={(e) => setPath(e.target.value)} />
required value={path} onChange={(e) => setPath(e.target.value)} />
</label>} </label>}
{!viaOutpost && source === "database" && <> {!viaOutpost && source === "database" && <>
<label className="block text-sm text-star-400"> <label className="block text-sm">
Database engine <span className="field-label">Database engine</span>
<select className="mt-1 w-full rounded-xl bg-space-950 border border-space-700 px-3 py-2" <Select value={engine} onChange={(event) => setEngine(event.target.value as typeof engine)}>
value={engine} onChange={(event) => setEngine(event.target.value as typeof engine)}>
<option value="postgres">PostgreSQL</option> <option value="postgres">PostgreSQL</option>
<option value="mysql">MySQL</option> <option value="mysql">MySQL</option>
</select> </Select>
</label> </label>
{[ {[
["host", "Database host"], ["port", "Port (optional)"], ["database", "Database name"], ["host", "Database host"], ["port", "Port (optional)"], ["database", "Database name"],
["user", "Database user"], ["password_file", "Absolute password file path on hub"], ["user", "Database user"], ["password_file", "Absolute password file path on hub"],
["ca_file", "CA certificate path on hub (optional)"], ["ca_file", "CA certificate path on hub (optional)"],
].map(([key, label]) => <label key={key} className="block text-sm text-star-400"> ].map(([key, label]) => <label key={key} className="block text-sm">
{label} <span className="field-label">{label}</span>
<input name={key} required={key !== "port" && key !== "ca_file"} type={key === "port" ? "number" : "text"} <input name={key} required={key !== "port" && key !== "ca_file"} type={key === "port" ? "number" : "text"}
min={key === "port" ? 1 : undefined} max={key === "port" ? 65535 : undefined} min={key === "port" ? 1 : undefined} max={key === "port" ? 65535 : undefined} className="field" />
className="mt-1 w-full rounded-xl bg-space-950 border border-space-700 px-3 py-2" />
</label>)} </label>)}
</>} </>}
{!viaOutpost && <label className="block text-sm"> {!viaOutpost && <label className="block text-sm">
<span className="text-star-400">Schedule (cron, UTC)</span> <span className="field-label">Schedule · cron, UTC</span>
<input <input className="field field-mono" value={schedule} onChange={(e) => setSchedule(e.target.value)} />
className="mt-1 w-full rounded-xl bg-space-950 border border-space-700 px-3 py-2 font-mono text-xs" <span className="mt-1.5 block text-xs leading-normal text-star-400">Leave blank for manual capture. Use weekday names such as MON to avoid ambiguity.</span>
value={schedule}
onChange={(e) => setSchedule(e.target.value)}
/>
<span className="text-xs text-star-400">Leave blank for manual capture. Use weekday names such as MON to avoid ambiguity.</span>
</label>} </label>}
{viaOutpost && <Hint>After saving, assign a paired Outpost and schedule. Configure the source and Restic repository on the agent.</Hint>} {viaOutpost && <Hint>After saving, assign a paired Outpost and schedule. Configure the source and Restic repository on the agent.</Hint>}
<RetentionFields draft={retention} onChange={setRetention} managed={viaOutpost} /> <RetentionFields draft={retention} onChange={setRetention} managed={viaOutpost} />
{!viaOutpost && <div className="space-y-1"> {!viaOutpost && <div className="space-y-1">
<label className="flex items-center gap-2 text-sm text-star-300"> <label className="flex items-center gap-2.5 text-[13px] text-star-200">
<input type="checkbox" checked={rehearse} onChange={(e) => setRehearse(e.target.checked)} /> <input type="checkbox" className="orbits-check" checked={rehearse} onChange={(e) => setRehearse(e.target.checked)} />
Rehearse only (dry run) Rehearse only <span className="text-star-400">· never prunes</span>
</label> </label>
<p className="text-xs text-star-400">A rehearsal never prunes snapshots.</p>
</div>} </div>}
{create.isError && <p role="alert" className="text-sm text-orbit-red">{create.error.message}</p>} {create.isError && <p role="alert" className="text-sm text-orbit-red">{create.error.message}</p>}
<div className="flex gap-2"> <div className="orbits-new-actions">
<Button type="button" className="flex-1" disabled={create.isPending} onClick={() => { <Button type="button" className="flex-1" disabled={create.isPending} onClick={resetForm}>Cancel</Button>
setEditing(false); <Button variant="primary" className="flex-1" type="submit"
create.reset(); disabled={create.isPending || !name.trim() || !retentionSettings(retention)}>
}}>
Cancel
</Button>
<Button
variant="primary"
className="flex-1"
type="submit"
disabled={create.isPending || !name.trim() || !retentionSettings(retention)}
>
Save orbit Save orbit
</Button> </Button>
</div> </div>
</form> </form>
</SpringPane>
) : (
<SpringPane key="add">
<Button variant="primary" className="w-full" onClick={() => setEditing(true)}>
Add an orbit
</Button>
</SpringPane>
)}
</AnimatePresence>
</div>
</div> </div>
); );
} }

View File

@@ -1,5 +1,6 @@
import type { Orbit, RetentionPolicy, RetentionSettings } from "../../api"; import type { Orbit, RetentionPolicy, RetentionSettings } from "../../api";
import { DECAY_PRESETS } from "../../lib/format"; import { DECAY_PRESETS } from "../../lib/format";
import { Select } from "../ui/Select";
const tiers = [ const tiers = [
["keep_daily", "Daily"], ["keep_daily", "Daily"],
@@ -8,7 +9,7 @@ const tiers = [
["keep_yearly", "Yearly"], ["keep_yearly", "Yearly"],
] as const; ] as const;
const maxCount = 4_294_967_295; const maxCount = 4_294_967_295;
const inputClass = "mt-1 w-full rounded-xl bg-space-950 border border-space-700 px-3 py-2"; const inputClass = "field";
type Draft = { preset: string; counts: Record<keyof RetentionPolicy, string> }; type Draft = { preset: string; counts: Record<keyof RetentionPolicy, string> };
@@ -59,8 +60,8 @@ export function RetentionFields({ draft, onChange, managed = false }: {
return ( return (
<div className="space-y-3"> <div className="space-y-3">
<label className="block text-sm"> <label className="block text-sm">
<span className="text-star-400">Retention</span> <span className="field-label">Retention</span>
<select className={inputClass} value={managed && draft.preset !== "custom" ? DECAY_PRESETS[0].id : draft.preset} <Select value={managed && draft.preset !== "custom" ? DECAY_PRESETS[0].id : draft.preset}
onChange={(e) => onChange({ ...draft, preset: e.target.value })}> onChange={(e) => onChange({ ...draft, preset: e.target.value })}>
{managed ? <option value={DECAY_PRESETS[0].id}>Managed default</option> : <> {managed ? <option value={DECAY_PRESETS[0].id}>Managed default</option> : <>
{!DECAY_PRESETS.some((item) => item.id === draft.preset) && draft.preset !== "custom" && ( {!DECAY_PRESETS.some((item) => item.id === draft.preset) && draft.preset !== "custom" && (
@@ -69,14 +70,14 @@ export function RetentionFields({ draft, onChange, managed = false }: {
{DECAY_PRESETS.map((preset) => <option key={preset.id} value={preset.id}>{preset.title}</option>)} {DECAY_PRESETS.map((preset) => <option key={preset.id} value={preset.id}>{preset.title}</option>)}
</>} </>}
<option value="custom">Custom (GFS)</option> <option value="custom">Custom (GFS)</option>
</select> </Select>
</label> </label>
{draft.preset === "custom" && ( {draft.preset === "custom" && (
<fieldset className="space-y-2"> <fieldset className="space-y-2">
<legend className="text-sm text-star-400">Snapshots to keep</legend> <legend className="field-label">Snapshots to keep</legend>
<div className="grid grid-cols-2 gap-2"> <div className="grid grid-cols-2 gap-2">
{tiers.map(([key, label]) => ( {tiers.map(([key, label]) => (
<label key={key} className="block min-w-0 text-sm text-star-300"> <label key={key} className="block min-w-0 text-[11px] text-star-400">
{label} {label}
<input className={inputClass} type="number" inputMode="numeric" min={0} max={maxCount} step={1} <input className={inputClass} type="number" inputMode="numeric" min={0} max={maxCount} step={1}
value={draft.counts[key]} value={draft.counts[key]}

View File

@@ -1,5 +1,6 @@
import { useQuery } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query";
import { fetchOutposts } from "../../api"; import { fetchOutposts } from "../../api";
import { Select } from "../ui/Select";
export function OutpostField({ className }: { className: string }) { export function OutpostField({ className }: { className: string }) {
const outposts = useQuery({ queryKey: ["outposts"], queryFn: fetchOutposts, refetchInterval: 5_000 }); const outposts = useQuery({ queryKey: ["outposts"], queryFn: fetchOutposts, refetchInterval: 5_000 });
@@ -7,10 +8,10 @@ export function OutpostField({ className }: { className: string }) {
return ( return (
<label className="block text-sm text-star-300"> <label className="block text-sm text-star-300">
Assigned Outpost Assigned Outpost
<select name="outpost" required className={className} defaultValue=""> <Select name="outpost" required defaultValue="">
<option value="">Choose a paired Outpost</option> <option value="">Choose a paired Outpost</option>
{paired?.map(({ id, name }) => <option key={id} value={id}>{name || "Outpost"} · {id}</option>)} {paired?.map(({ id, name }) => <option key={id} value={id}>{name || "Outpost"} · {id}</option>)}
</select> </Select>
{outposts.isError && <span role="alert">Could not load paired Outposts.</span>} {outposts.isError && <span role="alert">Could not load paired Outposts.</span>}
{paired?.length === 0 && <span>Pair an agent in Outposts first.</span>} {paired?.length === 0 && <span>Pair an agent in Outposts first.</span>}
</label> </label>

View File

@@ -1,3 +1,4 @@
import { useEffect, useState } from "react";
import { useMutation, useQuery } from "@tanstack/react-query"; import { useMutation, useQuery } from "@tanstack/react-query";
import { motion } from "motion/react"; import { motion } from "motion/react";
import { fetchOutposts, startPairing } from "../../api"; import { fetchOutposts, startPairing } from "../../api";
@@ -5,15 +6,38 @@ import { formatWhen } from "../../lib/format";
import { useReducedMotion } from "../../hooks/useReducedMotion"; import { useReducedMotion } from "../../hooks/useReducedMotion";
import { ambientPulse } from "../../lib/motion"; import { ambientPulse } from "../../lib/motion";
import { Button } from "../ui/Button"; import { Button } from "../ui/Button";
import { Hint } from "../ui/EmptyState";
import { TelemetryPanel } from "../ui/Telemetry"; import { TelemetryPanel } from "../ui/Telemetry";
type Pairing = { code: string; expires_at: string };
const OUTPOST_ONLINE_MS = 120_000;
/** Seconds left on a code, ticking once a second, plus the seconds it had when first seen (for the burn bar). */
function useBurn(pairing: Pairing | null) {
const [now, setNow] = useState(() => Date.now());
const [total, setTotal] = useState(1);
useEffect(() => {
if (!pairing) return;
const start = Date.now();
setNow(start);
const seconds = Math.round((Date.parse(pairing.expires_at) - start) / 1000);
setTotal(Number.isFinite(seconds) ? Math.max(1, seconds) : 1);
const timer = window.setInterval(() => setNow(Date.now()), 1000);
return () => window.clearInterval(timer);
}, [pairing]);
if (!pairing) return { left: 0, total: 1 };
const seconds = Math.round((Date.parse(pairing.expires_at) - now) / 1000);
return { left: Number.isFinite(seconds) ? Math.max(0, seconds) : 0, total };
}
const clock = (seconds: number) => `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, "0")}`;
export function WormholeView({ export function WormholeView({
pairing, pairing,
onPaired, onPaired,
}: { }: {
pairing: { code: string; expires_at: string } | null; pairing: Pairing | null;
onPaired: (p: { code: string; expires_at: string }) => void; onPaired: (p: Pairing) => void;
}) { }) {
const gen = useMutation({ const gen = useMutation({
mutationFn: startPairing, mutationFn: startPairing,
@@ -21,91 +45,121 @@ export function WormholeView({
}); });
const reducedMotion = useReducedMotion(); const reducedMotion = useReducedMotion();
const outposts = useQuery({ queryKey: ["outposts"], queryFn: fetchOutposts, refetchInterval: 5_000 }); const outposts = useQuery({ queryKey: ["outposts"], queryFn: fetchOutposts, refetchInterval: 5_000 });
const { left, total } = useBurn(pairing);
const [copied, setCopied] = useState(false);
const expires = pairing ? new Date(pairing.expires_at).toLocaleTimeString() : ""; const expires = pairing ? new Date(pairing.expires_at).toLocaleTimeString() : "";
const command = pairing
? `tessera-agent --hub-url ${window.location.origin} --credentials wormhole.json pair ${pairing.code}`
: "";
const isOnline = (lastSeen?: string | null) => !!lastSeen && Date.now() - Date.parse(lastSeen) < OUTPOST_ONLINE_MS;
const onlineCount = outposts.data?.filter((outpost) => isOnline(outpost.last_seen)).length ?? 0;
async function copy() {
try {
await navigator.clipboard.writeText(command);
setCopied(true);
window.setTimeout(() => setCopied(false), 1600);
} catch {
// Clipboard access can be blocked; the command stays selectable on the page.
}
}
return ( return (
<div className="h-full overflow-y-auto px-4 py-4 pb-28"> <div className="wormhole">
<h2 className="text-2xl font-semibold text-star-100">Outposts & wormholes</h2> <p className="wormhole-intro">
<p className="text-sm text-star-300 mt-1 mb-6"> Link a remote machine once. It then sends snapshots through an encrypted wormhole.
Link a remote machine once — it beams snapshots through an encrypted wormhole.
</p> </p>
<div className="gate">
<svg className="gate-rings" aria-hidden="true" viewBox="0 0 400 180" preserveAspectRatio="xMidYMid slice">
<g fill="none" stroke="#b4b9e1">
<ellipse cx="200" cy="90" rx="190" ry="84" strokeOpacity=".07" />
<ellipse cx="200" cy="90" rx="150" ry="66" strokeOpacity=".09" />
<ellipse cx="200" cy="90" rx="110" ry="48" strokeOpacity=".12" />
<ellipse cx="200" cy="90" rx="70" ry="30" strokeOpacity=".16" />
</g>
</svg>
{!pairing ? ( {!pairing ? (
<EmptyWormhole onGenerate={() => gen.mutate()} loading={gen.isPending} /> <div className="gate-body">
<div className="gate-eye">
<motion.span
aria-hidden="true"
className="gate-glow"
initial={{ opacity: 0 }}
animate={{ opacity: reducedMotion ? 0.6 : [0.2, 1] }}
transition={reducedMotion ? { type: false } : ambientPulse}
/>
<span className="gate-core" aria-hidden="true" />
</div>
<h3>No wormhole open</h3>
<p>Generate a one-time code and enter it on the remote machine to pair it.</p>
<Button variant="primary" className="mt-5 px-6" disabled={gen.isPending} onClick={() => gen.mutate()}>
{gen.isPending ? "Opening…" : "Open a wormhole"}
</Button>
{gen.isError && <p role="alert" className="mt-3 text-sm text-orbit-red">Could not open a wormhole.</p>}
</div>
) : ( ) : (
<motion.div <motion.div
className="rounded-2xl border border-wormhole-violet/35 bg-gradient-to-b from-wormhole-violet/10 to-space-900 p-6 text-center" className="gate-body"
initial={reducedMotion ? false : { scale: 0.95, opacity: 0 }} initial={reducedMotion ? false : { scale: 0.96, opacity: 0 }}
animate={{ scale: 1, opacity: 1 }} animate={{ scale: 1, opacity: 1 }}
> >
<p className="text-xs uppercase tracking-[0.2em] text-wormhole-violet mb-4"> <p className="gate-label">Pairing code</p>
Pairing code <p className="gate-code" aria-label={`Pairing code ${(pairing.code ?? "").split("").join(" ")}`}>{pairing.code}</p>
</p> <div className="gate-burn" role="timer" aria-label={left ? `${clock(left)} until the code burns` : "Code expired"}>
<p className="text-4xl font-mono tracking-[0.35em] text-star-100">{pairing.code}</p> <div className="gate-burn-track"><div className="gate-burn-fill" style={{ width: `${(left / total) * 100}%` }} /></div>
<p className="text-sm text-star-400 mt-4">Burns at {expires}</p> <div className="gate-burn-meta"><span>Burns at {expires}</span><span>{left ? `${clock(left)} left` : "Expired"}</span></div>
<Hint> </div>
On the outpost:{" "} <div className="gate-cmd">
<code className="font-mono text-orbit-amber">tessera-agent --hub-url {window.location.origin} --credentials wormhole.json pair {pairing.code}</code> <div className="gate-cmd-head">
</Hint> <span>On the outpost</span>
<Button variant="ghost" className="mt-4 w-full" onClick={() => gen.mutate()}> <button type="button" className="gate-copy" onClick={() => void copy()}>{copied ? "COPIED" : "COPY"}</button>
Generate fresh code </div>
<code>{command}</code>
</div>
<Button className="mt-4" onClick={() => gen.mutate()} disabled={gen.isPending}>
{gen.isPending ? "Opening…" : "Generate fresh code"}
</Button> </Button>
{gen.isError && <p role="alert" className="mt-3 text-sm text-orbit-red">Could not open a wormhole.</p>}
<div className="w-full text-left">
<TelemetryPanel label="Pairing metadata"> <TelemetryPanel label="Pairing metadata">
{JSON.stringify(pairing, null, 2)} {JSON.stringify(pairing, null, 2)}
</TelemetryPanel> </TelemetryPanel>
</div>
</motion.div> </motion.div>
)} )}
</div>
<section className="mt-8 space-y-3"> <section className="outpost-health" aria-label="Outpost health">
<h3 className="text-sm font-medium text-star-200">Outpost health</h3> <div className="outpost-health-head">
{outposts.isPending && <p role="status" className="text-sm text-star-300">Loading paired outposts…</p>} <h3>Outpost health</h3>
{outposts.isError && <p role="alert" className="text-sm text-orbit-red">Could not read outpost health.</p>} {outposts.data && <span>{outposts.data.length} paired · {onlineCount} online</span>}
{outposts.data?.length === 0 && <p className="text-sm text-star-300">No outposts paired yet.</p>} </div>
{outposts.data?.map((outpost) => { {outposts.isPending && <p role="status" className="outpost-note">Loading paired outposts…</p>}
const online = outpost.last_seen && Date.now() - Date.parse(outpost.last_seen) < 120_000; {outposts.isError && <p role="alert" className="outpost-note text-orbit-red">Could not read outpost health.</p>}
{outposts.data?.length === 0 && <p className="outpost-note">No outposts paired yet.</p>}
{!!outposts.data?.length && (
<ul>
{outposts.data.map((outpost) => {
const online = isOnline(outpost.last_seen);
return ( return (
<div key={outpost.id} className="flex items-center gap-3 rounded-xl border border-space-700 bg-space-800/40 p-4"> <li key={outpost.id}>
<span aria-hidden="true" className={`register-signal signal-${online ? "green" : "grey"}`} /> <span aria-hidden="true" className={`register-signal signal-${online ? "green" : "grey"}`} />
<div className="min-w-0"> <div className="min-w-0">
<p className="break-words text-sm text-star-100">{outpost.name || "Outpost"}</p> <p className="outpost-name">{outpost.name || "Outpost"}</p>
<p className="text-xs text-star-400">{outpost.last_seen ? `Last activity ${formatWhen(outpost.last_seen)}` : "No agent activity recorded"} · {outpost.id}</p> <p className="outpost-meta">
</div> {outpost.last_seen ? `Last activity ${formatWhen(outpost.last_seen)}` : "No agent activity recorded"} · {outpost.id}
</p>
</div> </div>
<span className={`outpost-state ${online ? "tone-green" : "tone-grey"}`}>{online ? "Online" : "Silent"}</span>
</li>
); );
})} })}
</ul>
)}
</section> </section>
</div> </div>
); );
} }
function EmptyWormhole({
onGenerate,
loading,
}: {
onGenerate: () => void;
loading: boolean;
}) {
const reducedMotion = useReducedMotion();
const outposts = useQuery({ queryKey: ["outposts"], queryFn: fetchOutposts, refetchInterval: 5_000 });
return (
<div className="text-center py-8">
<div className="relative mx-auto w-24 h-24 rounded-full border border-wormhole-violet/30 flex items-center justify-center text-3xl">
<motion.span
aria-hidden="true"
className="pointer-events-none absolute inset-0 rounded-full shadow-[0_0_32px_rgba(167,139,250,0.25)]"
initial={{ opacity: 0 }}
animate={{ opacity: reducedMotion ? 0 : [0, 1] }}
transition={reducedMotion ? { type: false } : ambientPulse}
/>
◉
</div>
<p className="mt-4 text-star-300 text-sm max-w-xs mx-auto">
Open a wormhole when you&apos;re ready to claim an outpost.
</p>
<Button variant="primary" className="mt-6 w-full max-w-xs mx-auto" disabled={loading} onClick={onGenerate}>
{loading ? "Opening…" : "Show pairing code"}
</Button>
</div>
);
}

View File

@@ -3,8 +3,8 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { cancelRestore, enqueueRestore, fetchOutposts, fetchRestoreJobs, fetchRestoreTargets, reconcileRestore, type RestoreJob, type RestoreTarget } from "../../api"; import { cancelRestore, enqueueRestore, fetchOutposts, fetchRestoreJobs, fetchRestoreTargets, reconcileRestore, type RestoreJob, type RestoreTarget } from "../../api";
import { RestoreTargetForm } from "./RestoreTargetForm"; import { RestoreTargetForm } from "./RestoreTargetForm";
import { Button } from "../ui/Button"; import { Button } from "../ui/Button";
import { Select } from "../ui/Select";
const field = "mt-1 w-full rounded-xl border border-space-700 bg-space-950 px-3 py-2 text-star-100";
const phases: Record<string, string> = { const phases: Record<string, string> = {
queued: "Waiting for outpost", queued: "Waiting for outpost",
claimed: "Assigned to agent", claimed: "Assigned to agent",
@@ -59,25 +59,24 @@ export function DatabaseRestore({ snapshot, application, engine }: {
}, },
}); });
const required = `RESTORE ${snapshot} TO ${target}`; const required = `RESTORE ${snapshot} TO ${target}`;
const ready = !!selected && confirmation === required && !submit.isPending;
return ( return (
<section className="space-y-4 rounded-xl border border-space-700 bg-space-800/50 p-4"> <>
<h3 className="font-semibold text-star-100">Database restore</h3> <div className="restore-fields">
{targets.isPending && <p role="status" className="text-sm text-star-300">Loading registered targets…</p>} {targets.isPending && <p role="status" className="text-sm text-star-300">Loading registered targets…</p>}
{targets.isError && <p role="alert" className="text-sm text-orbit-red">Could not read restore targets.</p>} {targets.isError && <p role="alert" className="text-sm text-orbit-red">Could not read restore targets.</p>}
{targets.data?.length === 0 && <p className="text-sm text-star-300">This application has no registered restore targets.</p>} {targets.data?.length === 0 && <p className="text-sm text-star-300">This application has no registered restore targets.</p>}
{registering
? <RestoreTargetForm application={application} engine={engine} onClose={() => setRegistering(false)} />
: <Button type="button" onClick={() => setRegistering(true)}>Register restore target</Button>}
{targets.data?.length && !targets.data.some((entry) => !entry.ineligible_reason) {targets.data?.length && !targets.data.some((entry) => !entry.ineligible_reason)
? <p className="text-sm text-star-300">No registered targets are eligible for this snapshot.</p> ? <p className="text-sm text-star-300">No registered targets are eligible for this snapshot.</p>
: null} : null}
{!!targets.data?.length && ( {!!targets.data?.length && (
<form className="space-y-3" onSubmit={(event) => { <form className="restore-form" onSubmit={(event) => {
event.preventDefault(); event.preventDefault();
if (selected && confirmation === required && !submit.isPending) submit.mutate(); if (ready) submit.mutate();
}}> }}>
<label htmlFor={fieldId} className="block text-sm text-star-300">Registered target</label> <div>
<select id={fieldId} className={field} value={target} <label htmlFor={fieldId} className="field-label">Registered target</label>
<Select id={fieldId} value={target}
onChange={(event) => { setTarget(event.target.value); setConfirmation(""); }}> onChange={(event) => { setTarget(event.target.value); setConfirmation(""); }}>
<option value="">Choose a target</option> <option value="">Choose a target</option>
{targets.data.map((entry) => ( {targets.data.map((entry) => (
@@ -85,49 +84,103 @@ export function DatabaseRestore({ snapshot, application, engine }: {
{targetLabel(entry)}{entry.ineligible_reason ? ` · ${entry.ineligible_reason}` : ""} {targetLabel(entry)}{entry.ineligible_reason ? ` · ${entry.ineligible_reason}` : ""}
</option> </option>
))} ))}
</select> </Select>
</div>
{selected && <> {selected && <>
<p className="break-words text-sm text-star-100"> <p className="break-words text-sm text-star-100">
Restore to {selected.identity.database} on {outposts.data?.find(({ id }) => id === selected.outpost_id)?.name || "Outpost"} ({selected.outpost_id}) Restore to {selected.identity.database} on {outposts.data?.find(({ id }) => id === selected.outpost_id)?.name || "Outpost"} ({selected.outpost_id})
· {selected.engine} instance {selected.identity.instance} · {selected.engine} instance {selected.identity.instance}
</p> </p>
<p className="text-sm text-star-300">The agent will verify the target and save a safety backup before applying this snapshot.</p> <div className="restore-warning" role="note">
<label className="block text-sm text-star-300"> <svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M8 2 14.5 13.5h-13Z" /><path d="M8 6.5v3M8 11.5v.01" /></svg>
Confirmation <p>The agent will verify the target and save a safety backup before applying this snapshot. Data on the target will be replaced.</p>
<code className="my-1 block break-all text-xs text-star-100">{required}</code> </div>
<input aria-label="Restore confirmation" className={field} value={confirmation} autoComplete="off" <label className="block text-sm">
<span className="field-label">Type to confirm</span>
<code className="restore-required">{required}</code>
<input aria-label="Restore confirmation" className="field field-mono" value={confirmation} autoComplete="off"
onChange={(event) => setConfirmation(event.target.value)} /> onChange={(event) => setConfirmation(event.target.value)} />
</label> </label>
</>} </>}
<Button type="submit" variant="warn" disabled={!selected || confirmation !== required || submit.isPending}> <div className="flex gap-2.5">
<Button type="submit" variant="primary" className="flex-1" disabled={!ready}>
{submit.isPending ? "Queueing…" : "Queue database restore"} {submit.isPending ? "Queueing…" : "Queue database restore"}
</Button> </Button>
{!registering && <Button type="button" onClick={() => setRegistering(true)}>Register target</Button>}
</div>
{submit.isError && <p role="alert" className="text-sm text-orbit-red">Restore could not be queued. Verify the selected target and confirmation.</p>} {submit.isError && <p role="alert" className="text-sm text-orbit-red">Restore could not be queued. Verify the selected target and confirmation.</p>}
</form> </form>
)} )}
{registering
? <RestoreTargetForm application={application} engine={engine} onClose={() => setRegistering(false)} />
: !targets.data?.length && <Button type="button" onClick={() => setRegistering(true)}>Register restore target</Button>}
</div>
<aside className="restore-status">
<p className="restore-status-label">Restore job</p>
{jobs.isError && <p role="alert" className="text-sm text-orbit-red">Restore history is unavailable.</p>} {jobs.isError && <p role="alert" className="text-sm text-orbit-red">Restore history is unavailable.</p>}
{!jobs.data?.length && !jobs.isError && (
<p className="restore-idle">No restore has been queued for this snapshot. Queue one to follow it here.</p>
)}
{!!jobs.data?.length && ( {!!jobs.data?.length && (
<ul className="space-y-2"> <ul className="restore-jobs">
{jobs.data.map((job) => <RestoreStatus key={job.id} job={job} destination={targetLabel(job.target)} refresh={refresh} />)} {jobs.data.map((job, index) => (
<RestoreStatus key={job.id} job={job} full={index === 0} destination={targetLabel(job.target)} refresh={refresh} />
))}
</ul> </ul>
)} )}
</section> </aside>
</>
); );
} }
function RestoreStatus({ job, destination, refresh }: { job: RestoreJob; destination: string; refresh: () => void }) { const steps = [
{ phases: ["queued", "claimed"], label: "Queued", detail: "Waiting for outpost" },
{ phases: ["checking"], label: "Verifying", detail: "Archive and target identity" },
{ phases: ["safety"], label: "Safety backup", detail: "Copying the target first" },
{ phases: ["ready", "applying"], label: "Applying restore", detail: "Writing the snapshot" },
{ phases: ["completed", "reconciled"], label: "Complete", detail: "" },
];
const failedAt: Record<string, number> = { wrong_target: 1, invalid_payload: 1, safety_failed: 2, apply_failed: 3, lease_lost: 3 };
/** Where a job is along the five steps, and whether it stopped there. */
function progressOf(job: RestoreJob) {
const failed = job.phase in failedAt;
const at = failed ? failedAt[job.phase] : steps.findIndex((step) => step.phases.includes(job.phase));
const done = job.phase === "completed" || job.phase === "reconciled";
return { at: at < 0 ? 0 : at, failed, done };
}
function RestoreStatus({ job, destination, refresh, full }: { job: RestoreJob; destination: string; refresh: () => void; full: boolean }) {
const [acknowledgement, setAcknowledgement] = useState(""); const [acknowledgement, setAcknowledgement] = useState("");
const required = `RECONCILE ${job.id}`; const required = `RECONCILE ${job.id}`;
const cancel = useMutation({ mutationFn: () => cancelRestore(job.id), onSuccess: refresh }); const cancel = useMutation({ mutationFn: () => cancelRestore(job.id), onSuccess: refresh });
const reconcile = useMutation({ const reconcile = useMutation({
mutationFn: () => reconcileRestore(job.id, acknowledgement), onSuccess: refresh, mutationFn: () => reconcileRestore(job.id, acknowledgement), onSuccess: refresh,
}); });
const { at, failed, done } = progressOf(job);
const bad = failed || job.status === "recovery_required" || job.status === "failed";
return ( return (
<li className="space-y-2 rounded-xl border border-space-700 p-3 text-sm"> <li className="restore-job">
<strong className="text-star-100">{destination}</strong> <strong>{destination}</strong>
<p role="status" className={job.status === "recovery_required" || job.status === "failed" ? "text-orbit-red" : "text-star-300"}> <p role="status" className={bad ? "text-orbit-red" : "text-star-300"}>{phases[job.phase] ?? job.status}</p>
{phases[job.phase] ?? job.status} {full && job.phase !== "cancelled" && (
</p> <ol className="restore-steps" aria-label="Restore progress">
{steps.map((step, index) => {
const state = done || index < at ? "done" : index === at ? (failed ? "failed" : "current") : "todo";
return (
<li key={step.label} data-state={state}>
<span className="restore-step-mark" aria-hidden="true">{state === "done" ? "✓" : ""}</span>
<div>
<p>{step.label}</p>
{state === "current" && step.detail && <small>{step.detail}</small>}
{state === "failed" && <small>{phases[job.phase]}</small>}
</div>
</li>
);
})}
</ol>
)}
{job.safety_snapshot_id && ( {job.safety_snapshot_id && (
<a className="break-all text-orbit-amber underline" href={`/api/v1/snapshots/${job.safety_snapshot_id}/download`} download> <a className="break-all text-orbit-amber underline" href={`/api/v1/snapshots/${job.safety_snapshot_id}/download`} download>
Safety backup {job.safety_snapshot_id} Safety backup {job.safety_snapshot_id}
@@ -138,13 +191,13 @@ function RestoreStatus({ job, destination, refresh }: { job: RestoreJob; destina
)} )}
{job.status === "recovery_required" && ( {job.status === "recovery_required" && (
<div className="space-y-2"> <div className="space-y-2">
<label className="block text-star-300"> <label className="block text-sm text-star-300">
Verify the target data before releasing its lock. Verify the target data before releasing its lock.
<code className="my-1 block break-all text-xs text-star-100">{required}</code> <code className="restore-required">{required}</code>
<input aria-label="Reconciliation confirmation" className={field} value={acknowledgement} <input aria-label="Reconciliation confirmation" className="field field-mono" value={acknowledgement}
onChange={(event) => setAcknowledgement(event.target.value)} /> onChange={(event) => setAcknowledgement(event.target.value)} />
</label> </label>
<Button variant="warn" disabled={acknowledgement !== required || reconcile.isPending} <Button variant="primary" disabled={acknowledgement !== required || reconcile.isPending}
onClick={() => reconcile.mutate()}>Mark target recovered</Button> onClick={() => reconcile.mutate()}>Mark target recovered</Button>
</div> </div>
)} )}

View File

@@ -6,6 +6,8 @@ import { formatBytes, formatWhen } from "../../lib/format";
import { Button } from "../ui/Button"; import { Button } from "../ui/Button";
import { Hint } from "../ui/EmptyState"; import { Hint } from "../ui/EmptyState";
import { TelemetryPanel } from "../ui/Telemetry"; import { TelemetryPanel } from "../ui/Telemetry";
import { Segmented } from "../ui/Segmented";
import { Select } from "../ui/Select";
const GRACE = 12; const GRACE = 12;
@@ -74,23 +76,25 @@ export function ReconstituteWizard({
}; };
}, [sessionId, onPoll]); }, [sessionId, onPoll]);
const radius = 52;
const circumference = 2 * Math.PI * radius;
const progress = Math.max(0, Math.min(1, remaining / GRACE));
return ( return (
<div className="space-y-4"> <div className="restore-layout">
<p className="text-sm text-star-300"> <div className="restore-top">
Choose a recovery point and a destination. <p className="restore-lead">Choose a recovery point and a destination.</p>
</p>
{snap && ( {snap && (
<div className="rounded-xl border border-space-700 bg-space-800/50 p-3 text-sm"> <div className="restore-snap">
<p className="text-star-100 font-medium">{snap.orbit_name}</p> <span className="restore-snap-glyph" aria-hidden="true">◇</span>
<p className="text-star-400 text-xs mt-1">{formatWhen(snap.taken_at)} · {formatBytes(snap.size_bytes)}</p> <div className="min-w-0">
<p className="restore-snap-name">{snap.orbit_name}</p>
<p className="restore-snap-meta">{formatWhen(snap.taken_at)} · {formatBytes(snap.size_bytes)} · {snap.id.slice(0, 8)}</p>
</div>
</div> </div>
)} )}
<label className="block text-sm"> <label className="block text-sm">
<span className="text-star-400">Snapshot</span> <span className="field-label">Snapshot</span>
<select <Select
className="mt-1 w-full rounded-xl bg-space-950 border border-space-700 px-3 py-2.5"
value={snapId} value={snapId}
onChange={(e) => { setSnapId(e.target.value); setDatabaseMode(true); }} onChange={(e) => { setSnapId(e.target.value); setDatabaseMode(true); }}
disabled={busy} disabled={busy}
@@ -100,67 +104,28 @@ export function ReconstituteWizard({
{s.orbit_name} · {formatWhen(s.taken_at)} · {formatBytes(s.size_bytes)} {s.orbit_name} · {formatWhen(s.taken_at)} · {formatBytes(s.size_bytes)}
</option> </option>
))} ))}
</select> </Select>
</label> </label>
{managed && ( {managed && (
<div className="flex flex-wrap gap-2" aria-label="Recovery destination" role="group"> <div>
<Button type="button" aria-pressed={databaseMode} disabled={busy} <p className="field-label mb-1.5">Destination</p>
variant={databaseMode ? "primary" : "ghost"} onClick={() => setDatabaseMode(true)}> <Segmented label="Recovery destination" value={databaseMode ? "database" : "file"} disabled={busy}
Restore to database onChange={(value) => setDatabaseMode(value === "database")}
</Button> options={[{ value: "database", label: "Restore to database" }, { value: "file", label: "Export file on hub" }]} />
<Button type="button" aria-pressed={!databaseMode} disabled={busy}
variant={databaseMode ? "ghost" : "primary"} onClick={() => setDatabaseMode(false)}>
Export file on hub
</Button>
</div> </div>
)} )}
</div>
{managed && databaseMode ? ( {managed && databaseMode ? (
<DatabaseRestore key={snapId} snapshot={snapId} application={managed.application_id} <DatabaseRestore key={snapId} snapshot={snapId} application={managed.application_id} engine={managed.engine} />
engine={managed.engine} />
) : <> ) : <>
<div className="restore-fields">
<label className="block text-sm"> <label className="block text-sm">
<span className="text-star-400">{scopedExport ? "Export filename on hub" : "Export file path on hub"}</span> <span className="field-label">{scopedExport ? "Export filename on hub" : "Export file path on hub"}</span>
<input <input className="field field-mono" value={target} onChange={(e) => setTarget(e.target.value)} disabled={busy} />
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={busy}
/>
</label> </label>
<Hint>{scopedExport ? "The hub writes to its exports directory after the countdown." : "The hub writes after the countdown. An existing file at the destination may be overwritten."}</Hint>
{inCountdown && ( <div className="flex gap-2.5">
<motion.div
className="relative rounded-2xl border border-orbit-amber/40 bg-orbit-amber/10 p-6 text-center"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
>
<div className="relative mx-auto w-20 h-20">
<svg viewBox="0 0 36 36" className="w-full h-full -rotate-90">
<circle cx="18" cy="18" r="16" fill="none" stroke="#1e2647" strokeWidth="3" />
<motion.circle
cx="18"
cy="18"
r="16"
fill="none"
stroke="#f0c468"
strokeWidth="3"
initial={false}
animate={{ pathLength: Math.max(0, Math.min(1, remaining / GRACE)) }}
/>
</svg>
<span className="absolute inset-0 flex items-center justify-center text-2xl font-semibold text-orbit-amber">
{remaining}
</span>
</div>
<p className="mt-3 text-orbit-amber text-sm font-medium">
Reconstituting in {remaining}s — abort restores nothing.
</p>
</motion.div>
)}
<div className="flex gap-2">
<Button <Button
variant="danger" variant="danger"
className="flex-1" className="flex-1"
@@ -180,7 +145,7 @@ export function ReconstituteWizard({
Abort Abort
</Button> </Button>
<Button <Button
variant="warn" variant="primary"
className="flex-1" className="flex-1"
disabled={!snap || !target.trim() || busy} disabled={!snap || !target.trim() || busy}
onClick={async () => { onClick={async () => {
@@ -201,30 +166,37 @@ export function ReconstituteWizard({
Begin file export Begin file export
</Button> </Button>
</div> </div>
{error && <p role="alert" className="text-orbit-red text-sm">{error}</p>} {error && <p role="alert" className="text-orbit-red text-sm">{error}</p>}
</div>
<aside className="restore-status">
<p className="restore-status-label">Countdown</p>
{inCountdown ? (
<motion.div className="restore-count" initial={{ opacity: 0 }} animate={{ opacity: 1 }}>
<div className="restore-ring">
<svg viewBox="0 0 120 120" width="132" height="132" aria-hidden="true">
<circle cx="60" cy="60" r={radius} fill="none" stroke="#2a2218" strokeWidth="5" />
<motion.circle cx="60" cy="60" r={radius} fill="none" stroke="#e8b57e" strokeWidth="5" strokeLinecap="round"
strokeDasharray={circumference} initial={false} animate={{ strokeDashoffset: circumference * (1 - progress) }} />
</svg>
<span className="restore-ring-text"><b>{remaining}</b><i>seconds</i></span>
</div>
<p className="restore-count-note">Reconstituting in {remaining}s.<br />Abort restores nothing.</p>
</motion.div>
) : <p className="restore-idle">No export is running. Begin an export to start the countdown.</p>}
{reconnecting && <p role="status" className="text-orbit-amber text-sm">Reconnecting to the export session…</p>} {reconnecting && <p role="status" className="text-orbit-amber text-sm">Reconnecting to the export session…</p>}
{state === "restoring" && <p role="status" className="text-orbit-amber text-sm">Exporting snapshot…</p>} {state === "restoring" && <p role="status" className="text-orbit-amber text-sm">Exporting snapshot…</p>}
{state === "unavailable" && ( {state === "unavailable" && (
<p role="alert" className="text-orbit-red text-sm">The hub no longer has this export session. Check the destination before retrying.</p> <p role="alert" className="text-orbit-red text-sm">The hub no longer has this export session. Check the destination before retrying.</p>
)} )}
{state === "completed" && ( {state === "completed" && <p className="text-orbit-green text-sm">File export complete.</p>}
<p className="text-orbit-green text-sm text-center">File export complete.</p> {state === "aborted" && <p className="text-star-300 text-sm">File export cancelled.</p>}
)} {state === "failed" && <p className="text-orbit-red text-sm">File export failed. Check telemetry.</p>}
{state === "aborted" && (
<p className="text-star-300 text-sm text-center">File export cancelled.</p>
)}
{state === "failed" && (
<p className="text-orbit-red text-sm text-center">File export failed. Check telemetry.</p>
)}
<Hint>{scopedExport ? "The hub writes to its exports directory after the countdown." : "The hub writes after the countdown. An existing file at the destination may be overwritten."}</Hint>
{sessionId && ( {sessionId && (
<TelemetryPanel label="Session"> <TelemetryPanel label="Session">
{JSON.stringify({ sessionId, state, remaining }, null, 2)} {JSON.stringify({ sessionId, state, remaining }, null, 2)}
</TelemetryPanel> </TelemetryPanel>
)} )}
</aside>
</>} </>}
</div> </div>
); );

View File

@@ -5,7 +5,7 @@ import { OutpostField } from "../outposts/OutpostField";
import { Button } from "../ui/Button"; import { Button } from "../ui/Button";
import { Hint } from "../ui/EmptyState"; import { Hint } from "../ui/EmptyState";
const field = "mt-1 w-full rounded-xl border border-space-700 bg-space-950 px-3 py-2 text-star-100"; const field = "field";
const uuidPattern = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"; const uuidPattern = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}";
export function RestoreTargetForm({ application, engine, onClose }: { export function RestoreTargetForm({ application, engine, onClose }: {
@@ -23,7 +23,7 @@ export function RestoreTargetForm({ application, engine, onClose }: {
}, },
}); });
return ( return (
<form className="space-y-3 rounded-xl border border-space-700 p-3" onSubmit={(event) => { <form className="orbit-panel space-y-3" onSubmit={(event) => {
event.preventDefault(); event.preventDefault();
if (register.isPending) return; if (register.isPending) return;
const data = new FormData(event.currentTarget); const data = new FormData(event.currentTarget);

View File

@@ -1,5 +1,5 @@
import { BlackholeGalaxy, type CaptureEffect } from "./BlackholeGalaxy"; import { BlackholeGalaxy, type CaptureEffect } from "./BlackholeGalaxy";
import { useCallback, useState } from "react"; import { useCallback, useState, type KeyboardEvent } from "react";
import { BlackholeBackdrop } from "./BlackholeBackdrop"; import { BlackholeBackdrop } from "./BlackholeBackdrop";
import { SpaceBackdrop } from "./SpaceBackdrop"; import { SpaceBackdrop } from "./SpaceBackdrop";
import type { CoreSignal } from "../../lib/blackhole/controller"; import type { CoreSignal } from "../../lib/blackhole/controller";
@@ -34,7 +34,7 @@ export function VaultScene({
const showSvgCore = useCallback(() => setSvgCore(true), []); const showSvgCore = useCallback(() => setSvgCore(true), []);
const selected = orbits.find(({ id }) => id === selectedOrbitId); const selected = orbits.find(({ id }) => id === selectedOrbitId);
const screenLabel = bigScreen ? "Exit big screen" : "Big screen"; const screenLabel = bigScreen ? "Exit big screen" : "Big screen";
const radarLabel = radar ? "Realistic view" : "Radar view"; const flowLabel = reducedMotion ? "Reduced motion" : flowing ? "Pause motion" : "Resume motion";
return ( return (
<section className="vault-scene" aria-label="Orbital map"> <section className="vault-scene" aria-label="Orbital map">
{svgCore ? <SpaceBackdrop /> : <BlackholeBackdrop signal={signal} bigScreen={bigScreen} radar={radar} reducedMotion={reducedMotion} onUnavailable={showSvgCore} />} {svgCore ? <SpaceBackdrop /> : <BlackholeBackdrop signal={signal} bigScreen={bigScreen} radar={radar} reducedMotion={reducedMotion} onUnavailable={showSvgCore} />}
@@ -52,34 +52,18 @@ export function VaultScene({
</p> </p>
</div> </div>
<div className="scene-controls"> <div className="scene-controls">
<button className="console-control" onClick={onToggleFlow} disabled={reducedMotion} type="button"> {!svgCore && <ViewSwitch radar={radar} onChange={(next) => next !== radar && onToggleRadar()} />}
<div className="scene-controls-end">
<button className="console-control icon-key" onClick={onToggleFlow} disabled={reducedMotion} type="button"
aria-label={flowLabel} title={flowLabel}>
<svg viewBox="0 0 16 16" width="15" height="15" aria-hidden="true"> <svg viewBox="0 0 16 16" width="15" height="15" aria-hidden="true">
{flowing {flowing
? <path d="M6 3v10M10 3v10" stroke="currentColor" strokeWidth="1.5" /> ? <path d="M6 3v10M10 3v10" stroke="currentColor" strokeWidth="1.5" />
: <path d="m6 3 7 5-7 5Z" fill="none" stroke="currentColor" strokeLinejoin="round" />} : <path d="m6 3 7 5-7 5Z" fill="none" stroke="currentColor" strokeLinejoin="round" />}
</svg> </svg>
{reducedMotion ? "Reduced motion" : flowing ? "Pause motion" : "Resume motion"}
</button> </button>
{!svgCore && (
<button <button
className="console-control scene-screen-control scene-look-control" className="console-control icon-key scene-screen-control"
onClick={onToggleRadar}
aria-pressed={radar}
aria-label={radarLabel}
title={radarLabel}
type="button"
>
<svg viewBox="0 0 16 16" width="15" height="15" aria-hidden="true" fill="none"
stroke="currentColor" strokeWidth="1.25" strokeLinecap="round" strokeLinejoin="round">
<circle cx="8" cy="8" r="6" />
<circle cx="8" cy="8" r="2.6" opacity=".55" />
<path d="M8 8 12.2 3.8" />
</svg>
<span>{radarLabel}</span>
</button>
)}
<button
className="console-control scene-screen-control"
onClick={onToggleBigScreen} onClick={onToggleBigScreen}
aria-label={screenLabel} aria-label={screenLabel}
title={screenLabel} title={screenLabel}
@@ -91,8 +75,9 @@ export function VaultScene({
? <path d="M2 5h3V2m9 3h-3V2M2 11h3v3m9-3h-3v3" /> ? <path d="M2 5h3V2m9 3h-3V2M2 11h3v3m9-3h-3v3" />
: <path d="M5 2H2v3m9-3h3v3M5 14H2v-3m9 3h3v-3" />} : <path d="M5 2H2v3m9-3h3v3M5 14H2v-3m9 3h3v-3" />}
</svg> </svg>
<span>{screenLabel}</span>
</button> </button>
<span className="sill-caption" aria-hidden="true">Motion · Screen</span>
</div>
</div> </div>
</div> </div>
<BlackholeGalaxy <BlackholeGalaxy
@@ -117,8 +102,59 @@ export function VaultScene({
<span><i className="legend-orbit" /> Orbit</span> <span><i className="legend-orbit" /> Orbit</span>
<span><i className="legend-failed" /> Failed</span> <span><i className="legend-failed" /> Failed</span>
<span><i className="legend-snapshot" /> Snapshot</span> <span><i className="legend-snapshot" /> Snapshot</span>
<span className="sill-caption" aria-hidden="true">Legend</span>
</div> </div>
</div> </div>
<div className="canopy-frame" aria-hidden="true">
<i className="canopy-bezel canopy-bezel--edge" />
<i className="canopy-bezel" />
<i className="canopy-corner canopy-corner--tl" />
<i className="canopy-corner canopy-corner--tr" />
<i className="canopy-corner canopy-corner--bl" />
<i className="canopy-corner canopy-corner--br" />
<i className="canopy-screw canopy-screw--l" />
<i className="canopy-screw canopy-screw--r" />
<span className="canopy-plate">Canopy 01 · Forward</span>
</div>
</section> </section>
); );
} }
const switchLook = {
window: { backgroundColor: "#31241d", borderColor: "#76533d", x: "0%" },
radar: { backgroundColor: "#17302a", borderColor: "#3e7a66", x: "100%" },
} as const;
/** The two looks of the canopy as a two-position switch. The thumb rides the shared MotionConfig spring. */
function ViewSwitch({ radar, onChange }: { radar: boolean; onChange: (radar: boolean) => void }) {
const arrows = (event: KeyboardEvent) => {
if (event.key === "ArrowLeft" || event.key === "ArrowUp") onChange(false);
else if (event.key === "ArrowRight" || event.key === "ArrowDown") onChange(true);
else return;
event.preventDefault();
const next = event.currentTarget.parentElement?.querySelectorAll<HTMLElement>("[role=radio]")[
event.key === "ArrowLeft" || event.key === "ArrowUp" ? 0 : 1];
next?.focus();
};
return (
<div className="view-switch" role="radiogroup" aria-label="Canopy view">
<span className="sill-caption" aria-hidden="true">View select</span>
<motion.span className="view-switch-thumb" aria-hidden="true" initial={false}
animate={radar ? switchLook.radar : switchLook.window} />
<button type="button" role="radio" aria-checked={!radar} aria-label="Window view" title="Window view"
tabIndex={radar ? -1 : 0} className="scene-screen-control scene-look-control" data-look="window"
onClick={() => onChange(false)} onKeyDown={arrows}>
<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true" fill="none" stroke="currentColor"
strokeWidth="1.3" strokeLinejoin="round"><path d="M3 13V6l2.5-3h5L13 6v7Z" /><path d="M3 8.5h10" /></svg>
<span>Window</span>
</button>
<button type="button" role="radio" aria-checked={radar} aria-label="Radar view" title="Radar view"
tabIndex={radar ? 0 : -1} className="scene-screen-control scene-look-control" data-look="radar"
onClick={() => onChange(true)} onKeyDown={arrows}>
<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true" fill="none" stroke="currentColor"
strokeWidth="1.3" strokeLinecap="round"><circle cx="8" cy="8" r="5.5" /><circle cx="8" cy="8" r="2.2" opacity=".55" /><path d="M8 8l3.8-3.8" /></svg>
<span>Radar</span>
</button>
</div>
);
}

View File

@@ -1,12 +1,11 @@
import { motion, type HTMLMotionProps } from "motion/react"; import { motion, type HTMLMotionProps } from "motion/react";
const variants = { const variants = {
primary: primary: "text-[#ffd0a9] border-[#76533d] [--button-color:var(--accent)] [--button-rest:19%] [--button-hover:30%]",
"text-star-100 border-wormhole-violet/40 [--button-color:var(--color-wormhole-violet)] [--button-rest:25%] [--button-hover:35%]", ghost: "text-star-200 border-[#3b4148] [--button-color:#2a2f37] [--button-rest:70%] [--button-hover:100%]",
ghost: "text-star-200 border-space-700 [--button-color:var(--color-space-800)] [--button-rest:60%] [--button-hover:100%]", danger: "text-orbit-red border-[#7a403d] [--button-color:var(--color-orbit-red)] [--button-rest:14%] [--button-hover:24%]",
danger: "text-orbit-red border-orbit-red/35 [--button-color:var(--color-orbit-red)]", success: "text-[#ffd0a9] border-[#76533d] [--button-color:var(--accent)] [--button-rest:19%] [--button-hover:30%]",
success: "text-orbit-green border-orbit-green/35 [--button-color:var(--color-orbit-green)]", warn: "text-[#ffd0a9] border-[#76533d] [--button-color:var(--accent)] [--button-rest:19%] [--button-hover:30%]",
warn: "text-orbit-amber border-orbit-amber/40 [--button-color:var(--color-orbit-amber)]",
}; };
export function Button({ export function Button({
@@ -19,7 +18,7 @@ export function Button({
return ( return (
<motion.button <motion.button
type="button" type="button"
className={`vault-button px-4 py-2.5 rounded-xl text-sm font-medium border disabled:opacity-40 ${variants[variant]} ${className}`} className={`vault-button px-4 min-h-10 rounded-md text-[13px] font-medium border disabled:opacity-40 ${variants[variant]} ${className}`}
initial={false} initial={false}
animate={{ "--button-mix": "0%" }} animate={{ "--button-mix": "0%" }}
whileHover={{ "--button-mix": "100%" }} whileHover={{ "--button-mix": "100%" }}

View File

@@ -28,7 +28,7 @@ export function EmptyState({
export function Hint({ children }: { children: ReactNode }) { export function Hint({ children }: { children: ReactNode }) {
return ( return (
<p className="text-xs text-star-400 leading-relaxed border border-space-700 rounded-xl px-3 py-2 bg-space-800/40"> <p className="hint">
{children} {children}
</p> </p>
); );

View File

@@ -0,0 +1,36 @@
import { motion } from "motion/react";
import type { CSSProperties, KeyboardEvent } from "react";
/**
* A recessed track with a lit thumb: the same two-or-more-position switch as the canopy's view switch. The thumb
* rides the shared MotionConfig spring, so a retarget mid-flight keeps its velocity.
*/
export function Segmented<T extends string>({ label, value, options, onChange, disabled = false }: {
label: string;
value: T;
options: readonly { value: T; label: string }[];
onChange: (value: T) => void;
disabled?: boolean;
}) {
const index = Math.max(0, options.findIndex((option) => option.value === value));
const arrows = (event: KeyboardEvent<HTMLButtonElement>) => {
const step = event.key === "ArrowRight" || event.key === "ArrowDown" ? 1
: event.key === "ArrowLeft" || event.key === "ArrowUp" ? -1 : 0;
if (!step) return;
event.preventDefault();
const next = (index + step + options.length) % options.length;
onChange(options[next].value);
event.currentTarget.parentElement?.querySelectorAll<HTMLElement>("[role=radio]")[next]?.focus();
};
return (
<div className="segmented" role="radiogroup" aria-label={label} style={{ "--n": options.length } as CSSProperties}>
<motion.span className="segmented-thumb" aria-hidden="true" initial={false} animate={{ x: `${index * 100}%` }} />
{options.map((option, i) => (
<button key={option.value} type="button" role="radio" aria-checked={i === index} disabled={disabled}
tabIndex={i === index ? 0 : -1} onClick={() => onChange(option.value)} onKeyDown={arrows}>
{option.label}
</button>
))}
</div>
);
}

View File

@@ -0,0 +1,188 @@
import { Children, Fragment, isValidElement, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, type KeyboardEvent, type ReactElement, type ReactNode } from "react";
import { createPortal } from "react-dom";
import { motion } from "motion/react";
type Option = { value: string; label: string; disabled: boolean };
type ChangeLike = { target: { value: string }; currentTarget: { value: string } };
/** Reads `<option>` children (including fragments and conditionals) so call sites keep the native shape. */
function readOptions(children: ReactNode): Option[] {
const out: Option[] = [];
const visit = (node: ReactNode) => {
Children.forEach(node, (child) => {
if (!isValidElement(child)) return;
const element = child as ReactElement<{ value?: string; disabled?: boolean; children?: ReactNode }>;
if (element.type === Fragment) visit(element.props.children);
else if (element.type === "option") {
const label = Children.toArray(element.props.children).join("");
out.push({ value: String(element.props.value ?? label), label, disabled: !!element.props.disabled });
}
});
};
visit(children);
return out;
}
type Place = { left: number; width: number; top?: number; bottom?: number; maxHeight: number };
/**
* A themed drop-in for `<select>`. The list is drawn in a portal so a console's own scroll never clips it, focus stays
* on the trigger (the list is driven by `aria-activedescendant`), and a hidden input carries the value into forms.
*/
export function Select({
id, name, value, defaultValue = "", onChange, required, disabled, children, "aria-label": ariaLabel,
}: {
id?: string;
name?: string;
value?: string;
defaultValue?: string;
onChange?: (event: ChangeLike) => void;
required?: boolean;
disabled?: boolean;
children: ReactNode;
"aria-label"?: string;
}) {
const options = readOptions(children);
const [inner, setInner] = useState(defaultValue);
const current = value ?? inner;
const selected = options.find((option) => option.value === current);
const [open, setOpen] = useState(false);
const [active, setActive] = useState(0);
const [place, setPlace] = useState<Place>();
const trigger = useRef<HTMLButtonElement>(null);
const list = useRef<HTMLUListElement>(null);
const typed = useRef({ text: "", at: 0 });
const listId = useId();
const optionId = (index: number) => `${listId}-${index}`;
const enabled = useMemo(() => options.map((option, index) => (option.disabled ? -1 : index)).filter((index) => index >= 0), [options]);
function choose(index: number) {
const option = options[index];
if (!option || option.disabled) return;
setInner(option.value);
onChange?.({ target: { value: option.value }, currentTarget: { value: option.value } });
setOpen(false);
trigger.current?.focus();
}
function show() {
if (disabled) return;
const at = options.findIndex((option) => option.value === current && !option.disabled);
setActive(at >= 0 ? at : (enabled[0] ?? 0));
setOpen(true);
}
useLayoutEffect(() => {
if (!open) return;
const rect = trigger.current!.getBoundingClientRect();
const below = window.innerHeight - rect.bottom - 12;
const above = rect.top - 12;
const flip = below < 180 && above > below;
const room = Math.max(120, flip ? above : below);
setPlace({
left: rect.left, width: rect.width, maxHeight: Math.min(320, room),
...(flip ? { bottom: window.innerHeight - rect.top + 6 } : { top: rect.bottom + 6 }),
});
}, [open]);
useEffect(() => {
if (!open) return;
const close = () => setOpen(false);
const outside = (event: PointerEvent) => {
const target = event.target as Node;
if (!list.current?.contains(target) && !trigger.current?.contains(target)) setOpen(false);
};
const scroll = (event: Event) => {
if (!list.current?.contains(event.target as Node)) setOpen(false);
};
window.addEventListener("pointerdown", outside, true);
window.addEventListener("resize", close);
window.addEventListener("scroll", scroll, true);
return () => {
window.removeEventListener("pointerdown", outside, true);
window.removeEventListener("resize", close);
window.removeEventListener("scroll", scroll, true);
};
}, [open]);
useEffect(() => {
if (open && place) document.getElementById(optionId(active))?.scrollIntoView({ block: "nearest" });
}, [open, place, active]); // eslint-disable-line react-hooks/exhaustive-deps
function move(step: number) {
const at = enabled.indexOf(active);
setActive(enabled[(Math.max(0, at) + step + enabled.length) % enabled.length] ?? active);
}
function keys(event: KeyboardEvent<HTMLButtonElement>) {
if (disabled) return;
const key = event.key;
if (!open) {
if (key === "ArrowDown" || key === "ArrowUp" || key === "Enter" || key === " ") {
event.preventDefault();
show();
}
return;
}
if (key === "Escape") {
event.preventDefault();
setOpen(false);
} else if (key === "ArrowDown" || key === "ArrowUp") {
event.preventDefault();
move(key === "ArrowDown" ? 1 : -1);
} else if (key === "Home" || key === "End") {
event.preventDefault();
setActive(key === "Home" ? enabled[0] : enabled[enabled.length - 1]);
} else if (key === "Enter" || key === " ") {
event.preventDefault();
choose(active);
} else if (key === "Tab") {
setOpen(false);
} else if (key.length === 1 && !event.metaKey && !event.ctrlKey) {
const now = Date.now();
typed.current = { text: (now - typed.current.at < 700 ? typed.current.text : "") + key.toLowerCase(), at: now };
const hit = options.findIndex((option, index) => !option.disabled && index >= 0 && option.label.toLowerCase().startsWith(typed.current.text));
if (hit >= 0) setActive(hit);
}
}
return (
<>
<button
ref={trigger} id={id} type="button" role="combobox" className="field select-trigger" disabled={disabled}
aria-label={ariaLabel} aria-haspopup="listbox" aria-expanded={open} aria-controls={open ? listId : undefined}
aria-activedescendant={open ? optionId(active) : undefined} aria-required={required || undefined}
onClick={() => (open ? setOpen(false) : show())} onKeyDown={keys}
>
<span className="select-value">{selected?.label ?? options[0]?.label ?? ""}</span>
<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" strokeWidth="1.5"
strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" className="select-chevron"><path d="m4 6 4 4 4-4" /></svg>
</button>
<input className="select-proxy" tabIndex={-1} aria-hidden="true" name={name} value={current} required={required}
disabled={disabled} onChange={() => {}} />
{open && place && createPortal(
<motion.ul
ref={list} id={listId} role="listbox" aria-label={ariaLabel} className="select-list"
style={{ left: place.left, width: place.width, top: place.top, bottom: place.bottom, maxHeight: place.maxHeight }}
initial={{ opacity: 0, y: place.bottom === undefined ? -6 : 6 }} animate={{ opacity: 1, y: 0 }}
onPointerDown={(event) => event.preventDefault()}
>
{options.map((option, index) => (
<li
key={`${option.value}-${index}`} id={optionId(index)} role="option" aria-selected={option.value === current}
aria-disabled={option.disabled || undefined} data-active={index === active || undefined}
onPointerEnter={() => !option.disabled && setActive(index)} onClick={() => choose(index)}
>
<span>{option.label}</span>
{option.value === current && (
<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" strokeWidth="1.6"
strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="m3.5 8.5 3 3 6-7" /></svg>
)}
</li>
))}
</motion.ul>,
document.body,
)}
</>
);
}

View File

@@ -5,16 +5,27 @@ import { formatBytes, formatWhen } from "../../lib/format";
import { Button } from "../ui/Button"; import { Button } from "../ui/Button";
import { TelemetryPanel } from "../ui/Telemetry"; import { TelemetryPanel } from "../ui/Telemetry";
/** Moon spots along the little orbit in the hero, nearest the hole last. */
const moons = [[126, 36], [104, 20], [52, 89], [20, 62]] as const;
function signedBytes(delta: number) {
return `${delta < 0 ? "−" : "+"}${formatBytes(Math.abs(delta))}`;
}
export function SnapshotSheet({ export function SnapshotSheet({
snap, snap,
siblings = [],
onReconstitute, onReconstitute,
onDeleted, onDeleted,
}: { }: {
snap: Snapshot; snap: Snapshot;
/** Every snapshot of the same orbit, newest first, including this one. */
siblings?: Snapshot[];
onReconstitute: () => void; onReconstitute: () => void;
onDeleted: () => void; onDeleted: () => void;
}) { }) {
const [confirmDelete, setConfirmDelete] = useState(false); const [confirmDelete, setConfirmDelete] = useState(false);
const [copied, setCopied] = useState(false);
const qc = useQueryClient(); const qc = useQueryClient();
const deletion = useMutation({ const deletion = useMutation({
mutationFn: () => deleteSnapshot(snap.id), mutationFn: () => deleteSnapshot(snap.id),
@@ -23,33 +34,97 @@ export function SnapshotSheet({
onDeleted(); onDeleted();
}, },
}); });
const index = siblings.findIndex(({ id }) => id === snap.id);
const previous = index >= 0 ? siblings[index + 1] : undefined;
const shown = Math.min(siblings.length, moons.length);
const lit = Math.min(Math.max(index, 0), moons.length - 1);
const database = !!snap.capture?.restore_ready;
const taken = new Date(snap.taken_at);
async function copy() {
try {
await navigator.clipboard.writeText(snap.id);
setCopied(true);
window.setTimeout(() => setCopied(false), 1600);
} catch {
// Clipboard access can be blocked; the id stays selectable on the page.
}
}
return ( return (
<div className="space-y-4"> <div className="sheet">
<p className="text-sm text-star-300"> <div className="sheet-hero">
Recovery point for <strong className="text-star-100">{snap.orbit_name}</strong>. <svg viewBox="0 0 150 110" width="150" height="110" role="img"
</p> aria-label={index >= 0 ? `Snapshot ${index + 1} of ${siblings.length} on its orbit` : "Snapshot on its orbit"}>
<div className="rounded-xl bg-space-800/60 p-3 border border-space-700 text-sm"> <ellipse cx="75" cy="55" rx="64" ry="38" fill="none" stroke="#dfe4ef" strokeOpacity=".14" />
<p className="text-star-400 text-xs">Captured</p> <circle cx="75" cy="55" r="7" fill="#000" stroke="#ffe5c8" strokeOpacity=".7" />
<p className="text-star-100 mt-1">{formatWhen(snap.taken_at)}</p> {moons.slice(0, Math.max(shown, 1)).map(([x, y], i) => (
<p className="text-star-400 text-xs mt-3">Payload</p> <path key={i} d={`M${x} ${y - 4}l4 4-4 4-4-4z`} fill={i === lit ? "#f1bc9033" : "none"}
<p className="text-star-100">{formatBytes(snap.size_bytes)}</p> stroke={i === lit ? "#f1bc90" : "#dfe4ef"} strokeOpacity={i === lit ? 1 : Math.max(0.25, 0.6 - i * 0.12)} />
))}
</svg>
<div className="min-w-0">
<p className="field-label">Recovery point for</p>
<p className="sheet-name">{snap.orbit_name}</p>
{index === 0 && (
<p className="sheet-note"><span className="register-signal signal-green" aria-hidden="true" />Newest snapshot of this orbit</p>
)}
</div> </div>
<Button variant="warn" className="w-full" onClick={onReconstitute}> </div>
{snap.capture?.restore_ready ? "Database recovery options" : "Export file on hub"}
<dl className="sheet-facts">
<div>
<dt>Captured</dt>
<dd>{formatWhen(snap.taken_at)}</dd>
<dd className="sheet-sub">{taken.toISOString().slice(0, 16).replace("T", " ")} UTC</dd>
</div>
<div>
<dt>Payload</dt>
<dd className="sheet-mono">{formatBytes(snap.size_bytes)}</dd>
{previous && <dd className="sheet-sub">{signedBytes(snap.size_bytes - previous.size_bytes)} vs previous</dd>}
</div>
<div>
<dt>Recovery</dt>
<dd>{database ? "Database ready" : "File export"}</dd>
{snap.capture && <dd className="sheet-sub">{snap.capture.engine} · {snap.capture.format}</dd>}
</div>
</dl>
<div className="gate-cmd">
<div className="gate-cmd-head">
<span>Snapshot ID</span>
<button type="button" className="gate-copy" onClick={() => void copy()}>{copied ? "COPIED" : "COPY"}</button>
</div>
<code className="sheet-id">{snap.id}</code>
</div>
<div className="sheet-actions">
<Button variant="primary" className="sheet-primary" onClick={onReconstitute}>
{database ? "Database recovery options" : "Export file on hub"}
<span aria-hidden="true">→</span>
</Button> </Button>
<a href={`/api/v1/snapshots/${snap.id}/download`} download <a href={`/api/v1/snapshots/${snap.id}/download`} download className="console-control sheet-link">
className="console-control block w-full text-center">Download snapshot</a> Download snapshot
<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
<path d="M8 2v8M4.5 7 8 10.5 11.5 7M3 13.5h10" />
</svg>
</a>
{confirmDelete ? ( {confirmDelete ? (
<div className="space-y-2 rounded-xl border border-orbit-red/40 p-3"> <div className="sheet-confirm" role="alertdialog" aria-label="Confirm deletion">
<p className="text-sm text-star-300">Remove this recovery point from the hub catalogue?</p> <p>Remove this recovery point from the hub catalogue? This cannot be undone.</p>
{deletion.isError && <p role="alert" className="text-sm text-orbit-red">Snapshot could not be removed. It may be in use.</p>} {deletion.isError && <p role="alert" className="text-orbit-red">Snapshot could not be removed. It may be in use.</p>}
<div className="flex gap-2"> <div className="flex gap-2.5">
<Button disabled={deletion.isPending} onClick={() => setConfirmDelete(false)}>Cancel</Button> <Button className="flex-1" disabled={deletion.isPending} onClick={() => setConfirmDelete(false)}>Cancel</Button>
<Button variant="warn" disabled={deletion.isPending} onClick={() => deletion.mutate()}>Confirm deletion</Button> <Button variant="danger" className="flex-1" disabled={deletion.isPending} onClick={() => deletion.mutate()}>
Confirm deletion
</Button>
</div> </div>
</div> </div>
) : <Button className="w-full" onClick={() => setConfirmDelete(true)}>Delete snapshot</Button>} ) : (
<TelemetryPanel label="Snapshot ID">{snap.id}</TelemetryPanel> <button type="button" className="sheet-delete" onClick={() => setConfirmDelete(true)}>Delete snapshot</button>
)}
</div>
<TelemetryPanel label="Snapshot record">{JSON.stringify(snap, null, 2)}</TelemetryPanel>
</div> </div>
); );
} }

View File

@@ -0,0 +1,26 @@
import { useMemo } from "react";
import { useQuery } from "@tanstack/react-query";
import { fetchCaptureJobs, fetchRecentRestoreJobs, type Orbit, type Snapshot } from "../api";
import { activityCounts, buildActivity } from "../lib/activity";
/** Everything the hub reports as backups and restores, folded into one log. Polling shares keys with the Orbits console. */
export function useActivity(snapshots?: Snapshot[], orbits?: Orbit[]) {
const restores = useQuery({ queryKey: ["restore-jobs-recent"], queryFn: () => fetchRecentRestoreJobs(100), refetchInterval: 5_000, retry: false });
const captures = useQuery({ queryKey: ["capture-jobs", "", ""], queryFn: () => fetchCaptureJobs("", ""), refetchInterval: 5_000, retry: 1 });
const restoreData = restores.data;
const captureData = captures.data;
const entries = useMemo(() => buildActivity({
snapshots: snapshots ?? [],
orbits: orbits ?? [],
captureJobs: captureData ?? [],
restoreJobs: restoreData ?? [],
now: Date.now(),
}), [snapshots, orbits, captureData, restoreData]);
return {
entries,
counts: activityCounts(entries),
restoresUnavailable: restores.isError,
capturesUnavailable: captures.isError,
updatedAt: Math.max(restores.dataUpdatedAt, captures.dataUpdatedAt),
};
}

View File

@@ -37,6 +37,8 @@ body {
button:enabled { cursor: pointer; } button:enabled { cursor: pointer; }
button:disabled { cursor: default; } button:disabled { cursor: default; }
.vault-button { .vault-button {
background-image: linear-gradient(#ffffff14, transparent 60%);
box-shadow: inset 0 1px 0 #ffffff1c, inset 0 -1px 0 #0009, 0 2px 3px #000a;
background-color: color-mix( background-color: color-mix(
in oklab, in oklab,
color-mix(in oklab, var(--button-color) var(--button-rest, 15%), transparent), color-mix(in oklab, var(--button-color) var(--button-rest, 15%), transparent),
@@ -44,9 +46,10 @@ button:disabled { cursor: default; }
); );
} }
:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; } :focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.vault-button:enabled:active { transform: translateY(1px); box-shadow: inset 0 2px 5px #000c; }
.scrollbar-none { scrollbar-width: none; } .scrollbar-none { scrollbar-width: none; }
.vault-app { --vault-header-height: 70px; } .vault-app { --vault-header-height: 70px; --key: 40px; --key-gap: 8px; }
.vault-topbar { .vault-topbar {
position: sticky; position: sticky;
top: 0; top: 0;
@@ -126,7 +129,7 @@ button:disabled { cursor: default; }
} }
.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; } .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-topbar-tools { justify-self: end; display: flex; align-items: center; gap: clamp(8px, 1.5vw, 20px); } .vault-topbar-tools { justify-self: end; display: flex; align-items: center; gap: var(--key-gap); }
.search-trigger kbd { color: var(--quiet); font: 10px var(--font-mono); } .search-trigger kbd { color: var(--quiet); font: 10px var(--font-mono); }
.big-screen .vault-topbar-tools { .big-screen .vault-topbar-tools {
position: absolute; position: absolute;
@@ -137,8 +140,8 @@ button:disabled { cursor: default; }
.search-overlay { .search-overlay {
--search-viewport: 100dvh; --search-viewport: 100dvh;
--search-top: clamp(12px, calc(var(--search-viewport) * .09), 84px); --search-top: clamp(12px, calc(var(--search-viewport) * .12), 112px);
--search-body-limit: max(0px, calc(var(--search-viewport) - var(--search-top) - 74px)); --search-body-limit: max(0px, calc(var(--search-viewport) - var(--search-top) - 64px - 40px - 16px));
position: fixed; position: fixed;
inset: var(--search-viewport-top, 0px) 0 auto; inset: var(--search-viewport-top, 0px) 0 auto;
height: var(--search-viewport); height: var(--search-viewport);
@@ -147,59 +150,73 @@ button:disabled { cursor: default; }
justify-items: center; justify-items: center;
align-items: start; align-items: start;
padding: var(--search-top) 12px 12px; padding: var(--search-top) 12px 12px;
background: #030508a6; background: #05060acc;
backdrop-filter: blur(3px);
} }
.search-overlay[inert] { pointer-events: none; } .search-overlay[inert] { pointer-events: none; }
/* A spotlight panel: a lit input, a quiet list, and a footer of key hints. */
.search-panel { .search-panel {
width: min(100%, 560px); width: min(100%, 700px);
min-width: 0; min-width: 0;
overflow: clip; overflow: clip;
border: 1px solid #44434a; border: 1px solid #3a3f46;
border-radius: 12px; border-radius: 14px;
background: #15181cf5; background: #111418;
backdrop-filter: blur(16px); box-shadow: 0 30px 80px #000c, inset 0 1px 0 #ffffff10;
box-shadow: 0 18px 64px #0009;
} }
.search-field { .search-field {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 12px; gap: 14px;
padding: 8px 10px 8px 16px; box-sizing: border-box;
height: 60px; height: 64px;
padding: 0 14px 0 20px;
border-bottom: 1px solid var(--line); border-bottom: 1px solid var(--line);
color: var(--accent); color: var(--accent);
} }
.search-field > svg { flex: none; } .search-field > svg { flex: none; }
.search-field input { flex: 1; min-width: 0; padding: 6px; font-size: 16px; color: var(--color-star-100); } .search-field input { flex: 1; min-width: 0; height: 44px; font-size: 19px; letter-spacing: -.015em; color: var(--color-star-100); }
.search-field input::placeholder { color: var(--quiet); } .search-field input:focus-visible { outline: none; }
.search-field .search-close { justify-content: center; width: 44px; height: 44px; padding: 0; } .search-field input::placeholder { color: #6d737b; }
.search-field .search-close { justify-content: center; width: var(--key); height: var(--key); min-height: var(--key); padding: 0; }
.search-list-frame, .search-body { max-height: var(--search-body-limit); } .search-list-frame, .search-body { max-height: var(--search-body-limit); }
.search-list-frame { overflow: clip; } .search-list-frame { overflow: clip; }
.search-body { overflow: auto; overscroll-behavior: contain; } .search-body { overflow: auto; overscroll-behavior: contain; padding: 8px 8px 10px; scrollbar-width: thin; scrollbar-color: #454952 transparent; }
.search-group { padding: 10px 14px 4px; } .search-empty { padding: 30px 20px 34px; text-align: center; }
.search-empty p { font: 500 10px/1 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.search-empty span { display: block; margin-top: 10px; font-size: 14px; color: var(--quiet); }
.search-group { padding: 12px 12px 6px; font-size: 9.5px; letter-spacing: .14em; }
.search-result { .search-result {
display: flex; display: grid;
grid-template-columns: 22px minmax(0, 1fr) auto;
align-items: center; align-items: center;
gap: 10px; gap: 12px;
margin-inline: 6px; min-height: 52px;
min-height: 44px; padding: 8px 12px;
padding: 6px 8px; border-radius: 8px;
border-radius: 6px;
cursor: pointer; cursor: pointer;
font-size: 14px; font-size: 14px;
} }
.search-result > svg { flex: none; color: var(--accent); } .search-result > svg { flex: none; justify-self: center; color: var(--accent); }
.search-result[aria-selected="true"] { background: #493329; box-shadow: inset 2px 0 var(--accent); } .search-result[aria-selected="true"] { background: #1e1c20; box-shadow: inset 2px 0 var(--accent); }
.search-result:hover { background: #352c29; } .search-result:hover { background: #191c20; }
.search-result[aria-selected="true"]:hover { background: #1e1c20; }
.search-result-text { min-width: 0; } .search-result-text { min-width: 0; }
.search-result-text > * { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .search-result-text > * { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result-text small, .search-status { font: 11px/1.5 var(--font-mono); color: var(--quiet); } .search-result-text > span:first-child { font-weight: 500; letter-spacing: -.01em; }
.search-status { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 10px 14px; } .search-result-text small { margin-top: 2px; font: 10.5px/1.3 var(--font-mono); color: var(--quiet); }
.search-result-hint { font: 500 10px/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: #6d737b; }
@media (max-width: 840px) { .search-result[aria-selected="true"] .search-result-hint { color: #ffd0a9; }
.vault-topbar-tools .search-trigger { justify-content: center; width: 44px; min-height: 44px; padding: 0; } .search-result[aria-selected="true"] .search-result-hint::before { content: "↵ "; }
.search-trigger span { display: none; } .search-footer {
display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
min-height: 40px; box-sizing: border-box; padding: 8px 16px; border-top: 1px solid var(--line); background: #0e1013;
font: 500 9.5px/1.4 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--quiet);
} }
.search-keys { display: flex; gap: 16px; }
.search-status { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 0; }
@media (max-width: 520px) { .search-keys { display: none; } }
@media (max-width: 1120px) { @media (max-width: 1120px) {
.search-trigger kbd { display: none; } .search-trigger kbd { display: none; }
} }
@@ -219,7 +236,7 @@ button:disabled { cursor: default; }
.vault-telemetry .telemetry-alert { color: var(--color-orbit-red); } .vault-telemetry .telemetry-alert { color: var(--color-orbit-red); }
.vault-workspace { .vault-workspace {
--workspace-height: clamp(480px, calc(100dvh - 288px), 760px); --workspace-height: clamp(480px, calc(100dvh - 170px), 820px);
display: grid; display: grid;
grid-template-columns: minmax(190px, .91fr) minmax(0, 3.1fr) minmax(224px, 1fr); grid-template-columns: minmax(190px, .91fr) minmax(0, 3.1fr) minmax(224px, 1fr);
grid-template-areas: "register map inspector"; grid-template-areas: "register map inspector";
@@ -228,6 +245,15 @@ button:disabled { cursor: default; }
} }
.vault-console, .vault-scene { position: relative; min-width: 0; border: 1px solid var(--line); border-radius: 10px; } .vault-console, .vault-scene { position: relative; min-width: 0; border: 1px solid var(--line); border-radius: 10px; }
/* The map is a cockpit canopy: chamfered corners, a bezel with an inset window, and a view switch on the sill. */
.vault-scene {
--bezel: #323940;
--chamfer: 52px;
--wl: 16px; --wt: 26px; --wb: 76px; --wc: 34px; --e: 1.5px;
border-color: var(--bezel);
border-radius: 0;
clip-path: polygon(var(--chamfer) 0, calc(100% - var(--chamfer)) 0, 100% var(--chamfer), 100% calc(100% - 12px), calc(100% - 12px) 100%, 12px 100%, 0 calc(100% - 12px), 0 var(--chamfer));
}
.vault-console { background: var(--panel); display: flex; flex-direction: column; min-height: 0; } .vault-console { background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.orbit-register { grid-area: register; } .orbit-register { grid-area: register; }
.orbit-inspector { grid-area: inspector; } .orbit-inspector { grid-area: inspector; }
@@ -279,6 +305,7 @@ button:disabled { cursor: default; }
font-size: 12px; font-size: 12px;
font-weight: 550; font-weight: 550;
text-align: left; text-align: left;
white-space: nowrap;
} }
.console-control:enabled:hover { border-color: #74777b; background: #20242a; } .console-control:enabled:hover { border-color: #74777b; background: #20242a; }
.console-control:disabled { color: var(--quiet); } .console-control:disabled { color: var(--quiet); }
@@ -320,7 +347,48 @@ button:disabled { cursor: default; }
content: ""; content: "";
background: radial-gradient(ellipse at 48% 52%, transparent 42%, #080a0dd9 100%); 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, .scene-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 46px 54px 12px; }
.scene-footer { padding: 12px 40px 14px; }
.vault-scene > .canopy-frame { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.vault-scene > .scene-footer { z-index: 2; }
.vault-scene > .scene-toolbar { z-index: 3; }
/* The bezel is the panel minus the window: an even-odd cut-out, plus a one-pixel edge ring just outside the glass. */
.canopy-bezel {
position: absolute; inset: 0; background: #15181d;
--x0: calc(var(--wl) - var(--e)); --x1: calc(100% - var(--wl) + var(--e));
--y0: calc(var(--wt) - var(--e)); --y1: calc(100% - var(--wb) + var(--e)); --c: calc(var(--wc) + var(--e));
clip-path: polygon(evenodd, 0 0, 100% 0, 100% 100%, 0 100%, 0 0,
calc(var(--x0) + var(--c)) var(--y0), calc(var(--x1) - var(--c)) var(--y0), var(--x1) calc(var(--y0) + var(--c)),
var(--x1) var(--y1), var(--x0) var(--y1), var(--x0) calc(var(--y0) + var(--c)),
calc(var(--x0) + var(--c)) var(--y0), 0 0);
}
.canopy-bezel--edge {
background: #323940;
--x0: var(--wl); --x1: calc(100% - var(--wl)); --y0: var(--wt); --y1: calc(100% - var(--wb)); --c: var(--wc);
}
.canopy-corner { position: absolute; width: var(--chamfer); height: var(--chamfer); }
.canopy-corner--tl, .canopy-corner--br { --dir: to bottom right; }
.canopy-corner--tr, .canopy-corner--bl { --dir: to bottom left; }
.canopy-corner {
background: linear-gradient(var(--dir), transparent calc(50% - .75px), var(--bezel) calc(50% - .75px), var(--bezel) calc(50% + .75px), transparent calc(50% + .75px));
}
.canopy-corner--tl { top: -1px; left: -1px; }
.canopy-corner--tr { top: -1px; right: -1px; }
.canopy-corner--bl, .canopy-corner--br { width: 12px; height: 12px; bottom: -1px; }
.canopy-corner--bl { left: -1px; }
.canopy-corner--br { right: -1px; }
.canopy-screw { position: absolute; top: 9px; width: 5px; height: 5px; border-radius: 50%; background: #20252b; box-shadow: inset 0 1px 1px #000; }
.canopy-screw--l { left: 62px; }
.canopy-screw--r { right: 62px; }
.canopy-plate { position: absolute; top: 4px; left: 50%; transform: translateX(-50%); font: 500 8px/1 var(--font-mono); letter-spacing: .2em; text-transform: uppercase; color: #5f656d; white-space: nowrap; }
.view-switch { position: relative; flex: none; display: grid; grid-template-columns: 1fr 1fr; height: var(--key); padding: 3px; box-sizing: border-box; background: #0a0c0f; border: 1px solid #23272c; border-radius: 9px; box-shadow: inset 0 2px 5px #000b; }
.view-switch-thumb { position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px); border: 1px solid; border-radius: 6px; box-shadow: inset 0 1px 0 #ffffff14; }
.view-switch button { position: relative; display: flex; align-items: center; justify-content: center; gap: 7px; min-width: 88px; padding: 0 10px; border-radius: 6px; font: 500 10.5px/1 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--quiet); }
.view-switch button[aria-checked="true"][data-look="window"] { color: #ffd0a9; }
.view-switch button[aria-checked="true"][data-look="radar"] { color: #b9ecd8; }
.view-switch button:focus-visible { outline-offset: 1px; }
.scene-toolbar { z-index: 1; } .scene-toolbar { z-index: 1; }
.scene-toolbar > div { min-width: 0; } .scene-toolbar > div { min-width: 0; }
.scene-controls { display: flex; align-items: center; gap: 6px; } .scene-controls { display: flex; align-items: center; gap: 6px; }
@@ -336,7 +404,7 @@ button:disabled { cursor: default; }
.legend-orbit { background: #dfe4ef; border-radius: 50%; } .legend-orbit { background: #dfe4ef; border-radius: 50%; }
.legend-failed { border: 1px solid var(--color-orbit-red); transform: rotate(45deg); } .legend-failed { border: 1px solid var(--color-orbit-red); transform: rotate(45deg); }
.legend-snapshot { border: 1px solid #dfe4ef; 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 { width: 100%; max-width: calc((var(--workspace-height) - 176px) * 1.375); aspect-ratio: 11 / 8; align-self: center; justify-self: center; }
.galaxy-frame > svg { display: block; width: 100%; height: 100%; overflow: hidden; } .galaxy-frame > svg { display: block; width: 100%; height: 100%; overflow: hidden; }
.orbit-tracks { fill: none; stroke: #949eaa; stroke-width: .75; } .orbit-tracks { fill: none; stroke: #949eaa; stroke-width: .75; }
.orbit-tracks ellipse { stroke-opacity: var(--track, .12); } .orbit-tracks ellipse { stroke-opacity: var(--track, .12); }
@@ -391,21 +459,31 @@ button:disabled { cursor: default; }
.vault-scrim { position: absolute; inset: 0; background: #030508b3; } .vault-scrim { position: absolute; inset: 0; background: #030508b3; }
.vault-dialog { .vault-dialog {
position: absolute; position: absolute;
inset: var(--vault-header-height) 0 0 auto; top: calc(var(--vault-header-height) + 20px);
width: min(440px, 100%); left: 0;
right: 0;
margin-inline: auto;
width: min(var(--console-width, 640px), calc(100% - 24px));
max-height: calc(100dvh - var(--vault-header-height) - 40px);
overflow: auto; overflow: auto;
overscroll-behavior: contain; overscroll-behavior: contain;
pointer-events: auto; pointer-events: auto;
background: #121519; background: #111418;
color: var(--color-star-100); color: var(--color-star-100);
border-left: 1px solid #3b4048; border: 1px solid #3a3f46;
border-radius: 14px;
box-shadow: 0 30px 80px #000c, inset 0 1px 0 #ffffff10;
scrollbar-width: thin;
scrollbar-color: #454952 transparent;
} }
.vault-dialog[inert] { pointer-events: none; } .vault-dialog[inert] { pointer-events: none; }
.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 { display: flex; gap: 12px; justify-content: space-between; align-items: center; min-height: 76px; box-sizing: border-box; padding: 10px 24px; position: sticky; top: 0; z-index: 2; background: #0e1013; border-bottom: 1px solid var(--line); }
.dialog-heading h2 { font-size: 23px; font-weight: 550; letter-spacing: -.035em; margin-top: 3px; } .dialog-heading h2 { font-size: 22px; font-weight: 600; letter-spacing: -.03em; margin-top: 4px; }
.dialog-heading h2:focus { outline: none; } .dialog-heading h2:focus { outline: none; }
.dialog-heading h2 + p { margin-top: 4px; color: var(--quiet); font-size: 13px; } .dialog-heading h2 + p { margin-top: 4px; color: var(--quiet); font-size: 13px; }
.dialog-content { padding: 18px 20px; } .dialog-close { flex: none; gap: 8px; min-height: 34px; padding: 0 11px; font: 500 10px/1 var(--font-mono); letter-spacing: .1em; }
.dialog-content { padding: 22px 24px 26px; }
.dialog-content--flush { padding: 0; }
.spring-stack { position: relative; min-width: 0; } .spring-stack { position: relative; min-width: 0; }
.spring-stack > .spring-pane[inert] { position: absolute; inset: 0 0 auto; pointer-events: none; } .spring-stack > .spring-pane[inert] { position: absolute; inset: 0 0 auto; pointer-events: none; }
.inspector-stack, .inspector-stack > .spring-pane { display: flex; flex: 1; flex-direction: column; min-height: 0; } .inspector-stack, .inspector-stack > .spring-pane { display: flex; flex: 1; flex-direction: column; min-height: 0; }
@@ -421,7 +499,7 @@ button:disabled { cursor: default; }
} }
.big-screen .vault-topbar { display: contents; } .big-screen .vault-topbar { display: contents; }
.big-screen .vault-dialog { top: var(--screen-top); bottom: calc(var(--screen-bottom) + 64px); } .big-screen .vault-dialog { top: var(--screen-top); max-height: calc(100dvh - var(--screen-top) - var(--screen-bottom) - 72px); }
.big-screen :is(.vault-brand, .hub-link, .vault-footer, .scene-footer) { display: none; } .big-screen :is(.vault-brand, .hub-link, .vault-footer, .scene-footer) { display: none; }
.big-screen .vault-main { padding: 0; } .big-screen .vault-main { padding: 0; }
.big-screen .vault-console { .big-screen .vault-console {
@@ -434,6 +512,8 @@ button:disabled { cursor: default; }
} }
.big-screen .orbit-register { left: clamp(16px, 3vw, 44px); } .big-screen .orbit-register { left: clamp(16px, 3vw, 44px); }
.big-screen .orbit-inspector { right: clamp(16px, 3vw, 44px); } .big-screen .orbit-inspector { right: clamp(16px, 3vw, 44px); }
.big-screen .vault-scene { clip-path: none; }
.big-screen .canopy-frame { display: none; }
.big-screen .vault-workspace, .big-screen .vault-workspace,
.big-screen .vault-scene { position: absolute; inset: 0; display: grid; } .big-screen .vault-scene { position: absolute; inset: 0; display: grid; }
.big-screen .vault-workspace { grid-template: 1fr / 1fr; height: auto; } .big-screen .vault-workspace { grid-template: 1fr / 1fr; height: auto; }
@@ -515,7 +595,9 @@ button:disabled { cursor: default; }
.orbit-inspector { max-height: 480px; padding-bottom: 8px; } .orbit-inspector { max-height: 480px; padding-bottom: 8px; }
.inspector-stack .console-empty { padding-bottom: 8px; } .inspector-stack .console-empty { padding-bottom: 8px; }
.galaxy-frame { max-width: none; } .galaxy-frame { max-width: none; }
.scene-toolbar, .scene-footer { padding: 9px; } .vault-scene { --chamfer: 14px; }
.canopy-plate, .canopy-screw { display: none; }
.scene-toolbar { padding: 30px 22px 8px; }
.scene-footer > p { display: none; } .scene-footer > p { display: none; }
.scene-footer { justify-content: center; } .scene-footer { justify-content: center; }
.vault-footer > p:last-child { text-align: right; } .vault-footer > p:last-child { text-align: right; }
@@ -537,11 +619,409 @@ button:disabled { cursor: default; }
} }
@media (max-width: 520px) { @media (max-width: 520px) {
.vault-app:not(.big-screen) .scene-screen-control { min-width: 44px; justify-content: center; } .view-switch .scene-look-control span { display: none; }
.vault-app:not(.big-screen) .scene-screen-control span { display: none; } .view-switch .scene-look-control { min-width: 44px; padding: 0; }
.vault-app { --key: 44px; }
} }
@media (max-width: 380px) { @media (max-width: 380px) {
.big-screen .vault-nav { gap: 2px; } .big-screen .vault-nav { gap: 2px; }
.big-screen .vault-telemetry > div { padding-inline: 7px; } .big-screen .vault-telemetry > div { padding-inline: 7px; }
} }
/* Flight deck: panels, lamps, the nav as a switch tray, and the sill under the canopy. */
.vault-console { box-shadow: inset 0 1px 0 #ffffff0a; }
.vault-console::after { content: ""; position: absolute; top: 8px; right: 9px; width: 5px; height: 5px; border-radius: 50%; background: #20252b; box-shadow: inset 0 1px 1px #000; pointer-events: none; }
.big-screen .vault-console::after { display: none; }
.register-row { min-height: 56px; }
.signal-green { box-shadow: 0 0 8px #8bcbb388; }
.signal-red { box-shadow: 0 0 8px #ffa29c88; }
.signal-amber { box-shadow: 0 0 8px #e8b57e66; }
.register-row[aria-pressed="true"] { background: #1e1c20; }
.console-bottom button { height: 40px; min-height: 40px; }
.vault-app:not(.big-screen) .vault-main { padding-top: 16px; }
.vault-app:not(.big-screen) .vault-overview { align-items: center; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid #1c2024; }
.vault-app:not(.big-screen) .overview-label { display: none; }
.vault-app:not(.big-screen) .vault-overview > div:first-child { display: flex; align-items: baseline; gap: 14px; }
.vault-app:not(.big-screen) .vault-overview h1 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.02em; line-height: 1.3; }
.vault-app:not(.big-screen) .overview-copy { font-size: 12.5px; }
.vault-app:not(.big-screen) .vault-telemetry { display: flex; border: 0; padding: 0; }
.vault-app:not(.big-screen) .vault-telemetry > div { display: flex; align-items: baseline; gap: 9px; padding-inline: 20px; }
.vault-app:not(.big-screen) .vault-telemetry > div:last-child { padding-right: 0; }
.vault-app:not(.big-screen) .vault-telemetry dt { font-size: 9.5px; }
.vault-app:not(.big-screen) .vault-telemetry dd { font-size: 14px; line-height: 1.5; }
.vault-app:not(.big-screen) .vault-nav {
align-self: center; gap: 6px; padding: 5px;
background: #0a0c0f; border: 1px solid #23272c; border-radius: 9px; box-shadow: inset 0 1px 3px #000a;
}
.vault-app:not(.big-screen) .vault-nav button {
display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 15px; border-radius: 6px;
font: 500 10.5px/1 var(--font-mono); letter-spacing: .1em; text-transform: uppercase;
}
.vault-app:not(.big-screen) .vault-nav button::before {
content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: #2f343b;
}
.vault-app:not(.big-screen) .vault-nav button[aria-current]::before { background: var(--lamp, #f1bc90); box-shadow: 0 0 7px var(--lamp, #f1bc90); }
.vault-nav button[data-tab="wormhole"] { --lamp: #b4b9e1; }
.vault-nav button[data-tab="activity"] { --lamp: #e8b57e; }
.vault-app:not(.big-screen) .nav-text-dock { display: none; }
.vault-app:not(.big-screen) .nav-underline { top: 5px; bottom: 5px; height: auto; }
.vault-app:not(.big-screen) .nav-underline::before {
inset: 0 -5px; border-radius: 6px; background: #1b1f25; border: 1px solid #3a3f46; box-shadow: inset 0 1px 0 #ffffff12;
}
.vault-footer { border-top: 1px solid #1c2024; padding-top: 6px; min-height: 28px; font-size: 9.5px; }
/* the sill: legend on the left, the view switch in the middle, motion and big screen on the right */
.vault-app:not(.big-screen) .scene-toolbar { position: static; }
.vault-app:not(.big-screen) .scene-controls {
position: absolute; z-index: 3; inset: auto 40px 8px; height: 56px; padding-top: 0;
display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; pointer-events: none;
}
.vault-app:not(.big-screen) .scene-controls > * { pointer-events: auto; }
.vault-app:not(.big-screen) .scene-footer { height: var(--wb); box-sizing: border-box; padding-block: 12px 8px; align-items: flex-start; border-top: 0; background: none; }
.vault-app:not(.big-screen) .scene-legend { height: var(--key); align-items: center; flex-wrap: nowrap; }
.vault-app:not(.big-screen) .scene-footer > p { display: none; }
.view-switch { grid-column: 2; }
.scene-controls-end { grid-column: 3; justify-self: end; display: flex; gap: var(--key-gap); }
.icon-key { width: var(--key); height: var(--key); min-height: var(--key); padding: 0; justify-content: center; }
.sill-caption { position: absolute; top: calc(100% + 7px); left: 50%; transform: translateX(-50%); white-space: nowrap; text-align: center; font: 500 8.5px/1 var(--font-mono); letter-spacing: .24em; text-transform: uppercase; color: #6d737b; pointer-events: none; }
.scene-controls-end, .scene-legend { position: relative; }
.scene-legend .sill-caption { display: block; }
.big-screen .scene-controls-end { display: flex; gap: 6px; }
.big-screen .sill-caption { display: none; }
.big-screen .scene-controls { display: flex; align-items: center; gap: 6px; }
@media (max-width: 760px) {
.vault-scene { --wl: 10px; --wt: 20px; --wb: 44px; --wc: 16px; }
.scene-toolbar { padding: 30px 22px 8px; }
.vault-app:not(.big-screen) .scene-toolbar { position: relative; }
.vault-app:not(.big-screen) .scene-controls { position: static; display: flex; height: auto; pointer-events: auto; }
.vault-app:not(.big-screen) .scene-footer { height: var(--wb); padding: 0 12px; align-items: center; justify-content: center; }
.sill-caption { display: none; }
}
@media (max-width: 640px) {
.vault-app:not(.big-screen) .vault-nav button { padding: 0 8px; gap: 6px; font-size: 9.5px; }
.vault-app:not(.big-screen) .vault-nav button::before { display: none; }
.vault-app:not(.big-screen) .vault-nav { padding: 3px; }
.vault-app:not(.big-screen) .vault-overview { align-items: stretch; }
.vault-app:not(.big-screen) .vault-overview > div:first-child { flex-direction: column; align-items: flex-start; gap: 2px; }
.vault-app:not(.big-screen) .vault-telemetry { display: grid; }
.vault-app:not(.big-screen) .vault-telemetry > div { display: block; padding-inline: 8px; }
.vault-app:not(.big-screen) .vault-telemetry > div:last-child { padding-right: 8px; }
}
/* Bevelled hardware: raised keys that press in, and a lit thumb with a highlight. */
.console-control {
border-color: #3b4148;
background: linear-gradient(#262b32, #181b20);
box-shadow: inset 0 1px 0 #ffffff1f, inset 0 -1px 0 #0009, 0 2px 3px #000a, 0 0 0 1px #0a0c0f;
}
.console-control:enabled:hover { border-color: #5a6068; background: linear-gradient(#2d333b, #1c2026); }
.console-control:enabled:active {
background: #14171b; transform: translateY(1px);
box-shadow: inset 0 2px 5px #000c, inset 0 0 0 1px #0007, 0 0 0 1px #0a0c0f;
}
.console-control:disabled { background: #15171b; box-shadow: inset 0 1px 0 #ffffff0d, 0 0 0 1px #0a0c0f; }
.capture-button { background: linear-gradient(#3f2e23, #2a1f18); border-color: #86593f; box-shadow: inset 0 1px 0 #ffd0a926, inset 0 -1px 0 #0009, 0 2px 3px #000a, 0 0 0 1px #0a0c0f; }
.capture-button:enabled:hover { background: linear-gradient(#4d3628, #33251c); }
.capture-button:enabled:active { background: #261a13; box-shadow: inset 0 2px 5px #000c, 0 0 0 1px #0a0c0f; }
.capture-button:disabled { background: #17181b; border-color: #2d3036; }
.view-switch-thumb { box-shadow: inset 0 1px 0 #ffffff2e, inset 0 -1px 0 #0007, 0 2px 4px #000b; }
.view-switch-thumb::after { content: ""; position: absolute; inset: 0; border-radius: 5px; background: linear-gradient(#ffffff18, transparent 60%); }
.vault-app:not(.big-screen) .nav-underline::before { background: linear-gradient(#272c34, #1a1d22); box-shadow: inset 0 1px 0 #ffffff1f, inset 0 -1px 0 #0009, 0 2px 3px #000a; }
.vault-app:not(.big-screen) .vault-nav { box-shadow: inset 0 2px 5px #000b, 0 1px 0 #ffffff0a; }
/* Annunciator plates: recessed, same height as the keys, used for read-outs next to them. */
.hub-link, .big-screen .scene-toolbar > div:first-child, .big-screen .vault-telemetry {
display: flex; align-items: center; box-sizing: border-box; height: var(--key); padding: 0 14px;
background: #0a0c0f; border: 1px solid #23272c; border-radius: 9px; box-shadow: inset 0 2px 5px #000b, 0 1px 0 #ffffff0a;
backdrop-filter: none;
}
.hub-link { gap: 9px; font: 500 10px/1 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--quiet); }
.hub-link .register-signal { width: 7px; height: 7px; }
/* Big Screen: one gutter, one key height, one gap, one plate style on all four edges. */
.big-screen .scene-toolbar { gap: var(--key-gap); }
.big-screen .scene-toolbar > div:first-child { max-width: none; margin-right: 0; }
.big-screen .scene-toolbar > div:first-child .scene-mode { margin: 0; font: 500 10px/1 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--color-star-200); }
.big-screen .scene-focus { max-width: 14ch; }
.big-screen .scene-controls { gap: var(--key-gap); }
.big-screen .vault-telemetry { padding: 0; }
.big-screen .vault-telemetry > div { display: flex; align-items: baseline; gap: 9px; padding-inline: 16px; }
.big-screen .vault-telemetry > div + div { border-left: 1px solid #23272c; }
.big-screen .vault-telemetry dd { font-size: 14px; line-height: 1; }
.big-screen .vault-telemetry dt { font-size: 9.5px; }
@media (min-width: 421px) {
/* centre the bottom-right keys on the dock's centre line */
.big-screen .vault-topbar-tools { bottom: calc(var(--screen-bottom) + (54px - var(--key)) / 2); }
}
@media (max-width: 740px) {
.big-screen .scene-toolbar > div:first-child { display: none; }
.big-screen .vault-telemetry { display: grid; grid-template-columns: repeat(2, auto); height: auto; padding-block: 6px; }
.big-screen .vault-telemetry > div { padding-block: 5px; }
.big-screen .vault-telemetry > div:nth-child(odd) { border-left: 0; }
}
/* Telemetry colour coding: each reading owns a lamp that matches its mark on the map. */
.vault-telemetry > div { --metric: #dfe4ef; }
.vault-telemetry [data-metric="snapshots"], .vault-telemetry > [data-metric="snapshots"] { --metric: #9db8e8; }
.vault-telemetry > [data-metric="payload"] { --metric: #b4b9e1; }
.vault-telemetry > [data-metric="failed"] { --metric: var(--color-orbit-green); }
.vault-telemetry > [data-metric="failed"][data-state="alert"] { --metric: var(--color-orbit-red); }
.vault-telemetry dt::before {
content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 8px; vertical-align: 1px;
border-radius: 50%; background: var(--metric); box-shadow: 0 0 7px color-mix(in oklab, var(--metric) 70%, transparent);
}
.vault-telemetry > [data-metric="failed"][data-state="alert"] dt::before { border-radius: 1px; transform: rotate(45deg); }
.vault-telemetry > [data-metric="snapshots"] dt::before { border-radius: 1px; transform: rotate(45deg); background: transparent; border: 1px solid var(--metric); box-sizing: border-box; box-shadow: none; }
.vault-telemetry > [data-metric="failed"][data-state="ok"] dd { color: var(--color-orbit-green); }
/* Console forms and cards: recessed fields, engraved labels, raised keys. */
.field { display: block; margin-top: 6px; width: 100%; box-sizing: border-box; height: 40px; padding: 0 12px; background: #090b0e; border: 1px solid #2f343b; border-radius: 7px; color: var(--color-star-100); font: 14px var(--font-sans); box-shadow: inset 0 1px 3px #0008; }
.field:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field-mono { font: 12px var(--font-mono); }
.field-label { display: block; font: 500 9.5px/1.4 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--quiet); }
.hint { padding: 9px 12px; border: 1px solid #282c31; border-radius: 8px; background: #0e1013; font-size: 12px; line-height: 1.55; color: var(--quiet); }
.segmented { position: relative; display: grid; grid-template-columns: repeat(var(--n, 2), 1fr); height: 38px; padding: 3px; box-sizing: border-box; background: #0a0c0f; border: 1px solid #23272c; border-radius: 9px; box-shadow: inset 0 2px 5px #000b; }
.segmented-thumb { position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc((100% - 6px) / var(--n, 2)); border-radius: 6px; background: #31241d; border: 1px solid #76533d; box-shadow: inset 0 1px 0 #ffffff2e, inset 0 -1px 0 #0007, 0 2px 4px #000b; }
.segmented-thumb::after { content: ""; position: absolute; inset: 0; border-radius: 5px; background: linear-gradient(#ffffff18, transparent 60%); }
.segmented button { position: relative; display: flex; align-items: center; justify-content: center; border-radius: 6px; font: 500 10.5px/1 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--quiet); }
.segmented button[aria-checked="true"] { color: #ffd0a9; }
.segmented button:disabled { opacity: .5; }
.orbits-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.orbits-list { min-width: 0; padding: 22px; border-right: 1px solid var(--line); }
.orbits-new { min-width: 0; padding: 22px; display: flex; flex-direction: column; gap: 14px; background: #0f1215; border-bottom-right-radius: 14px; }
.orbits-new-label { font: 500 9.5px/1.4 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.orbits-new-actions { display: flex; gap: 10px; margin-top: 4px; }
.orbits-check { width: 16px; height: 16px; accent-color: var(--accent); }
.orbit-panel { padding: 14px 16px; border: 1px solid #282c31; border-radius: 10px; background: #0e1013; }
.orbit-panel-title { font-size: 14px; font-weight: 600; }
.orbit-job { padding: 6px 12px; border: 1px solid #23272c; border-radius: 8px; background: #0b0d10; }
.orbit-cards { display: flex; flex-direction: column; gap: 12px; }
.orbit-card { padding: 14px 16px; border: 1px solid #282c31; border-radius: 10px; background: #14171b; }
.orbit-card[data-status="red"] { border-color: #4a3030; background: #1a1416; box-shadow: inset 2px 0 var(--color-orbit-red); }
.orbit-card-head { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 12px; align-items: start; }
.orbit-card-head > .register-signal { margin-top: 6px; }
.orbit-card h3 { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.orbit-tag { font: 500 9px/1 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--color-orbit-amber); border: 1px solid #6b5538; border-radius: 4px; padding: 3px 6px; }
.orbit-meta { margin-top: 3px; font: 10.5px/1.5 var(--font-mono); color: var(--quiet); }
.orbit-state { margin-top: 6px; font-size: 12.5px; }
.orbit-card-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.orbit-card-actions > button { min-height: 34px; padding-inline: 13px; font-size: 12px; }
@media (max-width: 860px) {
.orbits-layout { grid-template-columns: minmax(0, 1fr); }
.orbits-list { border-right: 0; border-bottom: 1px solid var(--line); padding: 16px; }
.orbits-new { padding: 16px; border-bottom-right-radius: 14px; border-bottom-left-radius: 14px; }
.orbit-card-head { grid-template-columns: 12px minmax(0, 1fr); }
.orbit-card-actions { grid-column: 1 / -1; justify-content: stretch; }
.orbit-card-actions > button { flex: 1; }
}
/* Outposts console: the gate, its code and the health roster. */
.wormhole { display: flex; flex-direction: column; gap: 22px; }
.wormhole-intro { max-width: 560px; font-size: 14px; line-height: 1.6; color: var(--color-star-300); }
.gate { position: relative; overflow: hidden; border: 1px solid #2f3345; border-radius: 12px; background: #0e1014; }
.gate-rings { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.gate-body { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 34px 28px; }
.gate-eye { position: relative; display: flex; align-items: center; justify-content: center; width: 92px; height: 92px; border-radius: 50%; border: 1px solid #b4b9e155; box-shadow: inset 0 0 20px #b4b9e122; }
.gate-glow { position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 36px #b4b9e155; pointer-events: none; }
.gate-core { width: 30px; height: 30px; border-radius: 50%; background: #000; box-shadow: 0 0 0 1px #b4b9e1aa; }
.gate-body h3 { margin-top: 18px; font-size: 18px; font-weight: 600; letter-spacing: -.02em; }
.gate-body > p:not(.gate-label):not(.gate-code) { margin-top: 6px; max-width: 380px; font-size: 13.5px; line-height: 1.6; color: var(--quiet); }
.gate-label { font: 500 10px/1 var(--font-mono); letter-spacing: .2em; text-transform: uppercase; color: var(--color-wormhole-violet); }
.gate-code { margin-top: 14px; padding-left: .3em; font: 500 clamp(26px, 5vw, 46px)/1 var(--font-mono); letter-spacing: .3em; overflow-wrap: anywhere; }
.gate-burn { width: min(100%, 300px); margin-top: 18px; }
.gate-burn-track { height: 4px; border-radius: 2px; background: #1e2130; overflow: hidden; }
.gate-burn-fill { height: 100%; background: var(--color-wormhole-violet); }
.gate-burn-meta { display: flex; justify-content: space-between; margin-top: 8px; font: 500 10px/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--quiet); }
.gate-cmd { width: 100%; margin-top: 22px; box-sizing: border-box; text-align: left; border: 1px solid #282c31; border-radius: 8px; background: #090b0e; }
.gate-cmd-head { display: flex; justify-content: space-between; align-items: center; padding: 7px 12px; border-bottom: 1px solid #1f2327; font: 500 9.5px/1 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--quiet); }
.gate-copy { height: 24px; padding: 0 9px; border: 1px solid #393e45; border-radius: 5px; background: linear-gradient(#262b32, #181b20); box-shadow: inset 0 1px 0 #ffffff1f, 0 1px 2px #000a; font: 500 9.5px/1 var(--font-mono); letter-spacing: .1em; color: var(--color-star-100); }
.gate-copy:active { transform: translateY(1px); box-shadow: inset 0 2px 4px #000c; }
.gate-cmd code { display: block; padding: 12px; font: 12px/1.7 var(--font-mono); color: var(--color-orbit-amber); overflow-wrap: anywhere; user-select: all; }
.outpost-health-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.outpost-health-head h3 { font: 500 9.5px/1.4 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--quiet); }
.outpost-health-head span { font: 500 10px/1 var(--font-mono); color: var(--quiet); }
.outpost-health ul { list-style: none; border: 1px solid #282c31; border-radius: 10px; background: #0e1013; }
.outpost-health li { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 13px 16px; }
.outpost-health li + li { border-top: 1px solid #1f2327; }
.outpost-name { font-size: 14px; overflow-wrap: anywhere; }
.outpost-meta { margin-top: 2px; font: 10.5px/1.4 var(--font-mono); color: var(--quiet); overflow-wrap: anywhere; }
.outpost-state { font: 500 10px/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; }
.outpost-note { font-size: 13px; color: var(--quiet); }
/* Themed select: a recessed trigger with room around its chevron, and a console-styled list in a portal. */
.select-trigger { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px 0 12px; text-align: left; cursor: pointer; }
.select-trigger:disabled { opacity: .5; cursor: default; }
.select-trigger[aria-expanded="true"] { border-color: #5a6068; }
.select-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-chevron { flex: none; color: var(--accent); }
.select-proxy { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.select-list {
position: fixed; z-index: 80; margin: 0; padding: 5px; list-style: none; overflow: auto; box-sizing: border-box;
background: #111418; border: 1px solid #3a3f46; border-radius: 9px;
box-shadow: 0 18px 50px #000c, inset 0 1px 0 #ffffff10; scrollbar-width: thin; scrollbar-color: #454952 transparent;
}
.select-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 38px; padding: 6px 10px; border-radius: 6px; font-size: 14px; color: var(--color-star-200); cursor: pointer; }
.select-list li span { min-width: 0; overflow-wrap: anywhere; }
.select-list li[data-active] { background: #1e1c20; box-shadow: inset 2px 0 var(--accent); color: var(--color-star-100); }
.select-list li[aria-selected="true"] { color: #ffd0a9; }
.select-list li[aria-selected="true"] svg { flex: none; color: var(--accent); }
.select-list li[aria-disabled="true"] { opacity: .45; cursor: default; }
/* Restore console: choose and confirm on the left, the job or countdown on the right. */
.restore-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; grid-template-rows: auto 1fr; }
.restore-top, .restore-fields { min-width: 0; padding-inline: 24px; display: flex; flex-direction: column; gap: 18px; }
.restore-top { padding-top: 24px; padding-bottom: 18px; }
.restore-fields { padding-bottom: 26px; }
.restore-status { grid-column: 2; grid-row: 1 / span 2; min-width: 0; padding: 24px; display: flex; flex-direction: column; gap: 18px; background: #0f1215; border-left: 1px solid var(--line); border-bottom-right-radius: 14px; }
.restore-status-label { font: 500 9.5px/1.4 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.restore-lead { font-size: 14px; color: var(--color-star-300); }
.restore-snap { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: center; padding: 14px 16px; border: 1px solid #282c31; border-radius: 10px; background: #0e1013; box-shadow: inset 2px 0 var(--accent); }
.restore-snap-glyph { font-size: 20px; color: #c6d2e6; }
.restore-snap-name { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.restore-snap-meta { margin-top: 2px; font: 10.5px/1.4 var(--font-mono); color: var(--quiet); }
.restore-form { display: flex; flex-direction: column; gap: 16px; }
.restore-warning { display: grid; grid-template-columns: 18px 1fr; gap: 10px; padding: 12px 14px; border: 1px solid #5a4630; border-radius: 8px; background: #1c1710; color: #e8b57e; }
.restore-warning p { font-size: 13px; line-height: 1.6; color: #e6cfae; }
.restore-required { display: block; margin: 6px 0; font: 11.5px/1.5 var(--font-mono); color: var(--color-star-100); overflow-wrap: anywhere; }
.restore-idle { font-size: 13px; line-height: 1.6; color: var(--quiet); }
.restore-jobs { list-style: none; display: flex; flex-direction: column; gap: 14px; }
.restore-job { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.restore-job + .restore-job { padding-top: 14px; border-top: 1px solid #1f2327; }
.restore-job > strong { font-size: 13.5px; overflow-wrap: anywhere; }
.restore-steps { list-style: none; display: flex; flex-direction: column; margin-block: 6px 10px; }
.restore-steps li { position: relative; display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 12px; padding-bottom: 18px; }
.restore-steps li:last-child { padding-bottom: 0; }
.restore-steps li:not(:last-child)::before { content: ""; position: absolute; left: 9px; top: 20px; bottom: 0; width: 1px; background: #2f343b; }
.restore-steps li[data-state="done"]:not(:last-child)::before { background: #8bcbb355; }
.restore-steps p { font-size: 13.5px; color: var(--quiet); }
.restore-steps small { display: block; margin-top: 2px; font: 10.5px/1.4 var(--font-mono); color: var(--quiet); }
.restore-step-mark { display: flex; align-items: center; justify-content: center; box-sizing: border-box; width: 18px; height: 18px; border: 1.5px solid #2f343b; border-radius: 50%; font-size: 11px; font-weight: 700; }
.restore-steps [data-state="done"] .restore-step-mark { background: var(--color-orbit-green); border-color: var(--color-orbit-green); color: #06130e; }
.restore-steps [data-state="done"] p { color: var(--color-star-100); }
.restore-steps [data-state="current"] .restore-step-mark { border-color: var(--color-orbit-amber); box-shadow: 0 0 10px #e8b57e66; }
.restore-steps [data-state="current"] p { color: var(--color-orbit-amber); }
.restore-steps [data-state="failed"] .restore-step-mark { border-color: var(--color-orbit-red); border-radius: 2px; transform: rotate(45deg) scale(.8); box-shadow: 0 0 10px #ffa29c66; }
.restore-steps [data-state="failed"] p { color: var(--color-orbit-red); }
.restore-count { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 18px 8px; border: 1px solid #5a4630; border-radius: 12px; background: #1a150f; }
.restore-ring { position: relative; width: 132px; height: 132px; }
.restore-ring svg { transform: rotate(-90deg); }
.restore-ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.restore-ring-text b { font: 500 40px/1 var(--font-mono); color: var(--color-orbit-amber); }
.restore-ring-text i { margin-top: 4px; font: 500 9px/1 var(--font-mono); font-style: normal; letter-spacing: .2em; text-transform: uppercase; color: var(--quiet); }
.restore-count-note { margin-top: 16px; font-size: 13.5px; line-height: 1.5; font-weight: 500; color: var(--color-orbit-amber); }
@media (max-width: 860px) {
.restore-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
.restore-top, .restore-fields { padding-inline: 16px; }
.restore-top { padding-top: 18px; }
.restore-status { grid-column: 1; grid-row: auto; padding: 18px 16px; border-left: 0; border-top: 1px solid var(--line); border-bottom-left-radius: 14px; }
}
/* Snapshot sheet: where the recovery point sits, what it holds, and what can be done with it. */
.sheet { display: flex; flex-direction: column; gap: 20px; }
.sheet-hero { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 22px; align-items: center; padding: 18px 20px; border: 1px solid #282c31; border-radius: 12px; background: #0b0d10; }
.sheet-name { margin-top: 4px; font-size: 24px; font-weight: 600; letter-spacing: -.035em; overflow-wrap: anywhere; }
.sheet-note { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12.5px; color: var(--color-orbit-green); }
.sheet-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid #282c31; border-radius: 10px; background: #0e1013; }
.sheet-facts > div { padding: 14px 16px; min-width: 0; }
.sheet-facts > div + div { border-left: 1px solid #23272c; }
.sheet-facts dt { font: 500 9.5px/1.4 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--quiet); }
.sheet-facts dd { margin-top: 6px; font-size: 15px; overflow-wrap: anywhere; }
.sheet-facts dd.sheet-mono { font: 500 17px/1.4 var(--font-mono); }
.sheet-facts dd.sheet-sub { margin-top: 2px; font: 10.5px/1.4 var(--font-mono); color: var(--quiet); }
.sheet-id { display: block; padding: 11px 12px; font: 12px/1.5 var(--font-mono); color: var(--color-star-200); overflow-wrap: anywhere; user-select: all; }
.sheet-actions { display: flex; flex-direction: column; gap: 10px; }
.sheet .gate-cmd { margin-top: 0; }
.sheet-actions > .sheet-primary { display: flex; align-items: center; justify-content: space-between; min-height: 46px; padding-inline: 16px; font-size: 13.5px; }
.sheet-link { align-items: center; justify-content: space-between; min-height: 44px; padding-inline: 16px; font-size: 13.5px; text-decoration: none; }
.sheet-delete { display: flex; align-items: center; min-height: 40px; padding: 0 16px; border: 1px solid #2a2e34; border-radius: 6px; font-size: 13px; font-weight: 550; color: var(--color-star-300); }
.sheet-delete:hover { border-color: #5a2f2d; color: var(--color-orbit-red); }
.sheet-confirm { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px; border: 1px solid #5a2f2d; border-radius: 8px; background: #1d1214; font-size: 13.5px; line-height: 1.55; color: #e8cfcc; }
@media (max-width: 520px) {
.sheet-hero { grid-template-columns: minmax(0, 1fr); justify-items: start; gap: 12px; }
.sheet-facts { grid-template-columns: minmax(0, 1fr); }
.sheet-facts > div + div { border-left: 0; border-top: 1px solid #23272c; }
}
/* Activity: one log of backups and restores. Rows lead to a snapshot or an orbit; they never act themselves. */
.vault-app:not(.big-screen) .vault-nav button[data-alert="true"]::before { background: var(--color-orbit-red); border-radius: 1px; transform: rotate(45deg); box-shadow: 0 0 7px var(--color-orbit-red); }
.footer-link { font: inherit; letter-spacing: inherit; text-transform: inherit; color: var(--color-orbit-amber); text-decoration: underline; text-underline-offset: 3px; }
.activity { margin: -22px -24px -26px; display: flex; flex-direction: column; min-height: 0; }
.activity-bar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 24px 4px; }
.activity-lead { max-width: 560px; font-size: 13px; line-height: 1.55; color: var(--quiet); }
.activity-counts { display: flex; flex: none; }
.activity-counts > div { display: flex; align-items: baseline; gap: 9px; padding-inline: 16px; }
.activity-counts > div + div { border-left: 1px solid #23272c; padding-right: 0; }
.activity-counts .act-glyph { margin-right: 8px; vertical-align: 1px; }
.activity-counts dt { font: 500 9.5px/1 var(--font-mono); letter-spacing: .105em; text-transform: uppercase; color: var(--quiet); }
.activity-counts dd { font: 500 14px/1 var(--font-mono); }
.activity-counts [data-alert="true"] dd { color: var(--color-orbit-red); }
.activity-tools { display: flex; align-items: center; gap: 8px; padding: 12px 24px; }
.activity-tools .segmented { width: 300px; height: 40px; flex: none; }
.activity-age { margin-left: auto; font: 500 10px/1 var(--font-mono); color: var(--quiet); }
.activity-search { display: flex; align-items: center; gap: 8px; width: 250px; height: 40px; box-sizing: border-box; padding: 0 12px; background: #090b0e; border: 1px solid #2f343b; border-radius: 7px; box-shadow: inset 0 1px 3px #0008; color: #6d737b; }
.activity-search input { flex: 1; min-width: 0; font: 13px var(--font-sans); color: var(--color-star-100); }
.activity-search input:focus-visible { outline: none; }
.activity-search:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.activity-warning { margin: 0 24px 12px; padding: 9px 12px; border: 1px solid #5a4630; border-radius: 8px; background: #1c1710; font-size: 12.5px; color: #e6cfae; }
.activity-list { margin: 0 24px 26px; border: 1px solid #282c31; border-radius: 10px; background: #0e1013; overflow: hidden; }
.activity-list h3 { padding: 10px 16px 6px; background: #0b0d10; border-bottom: 1px solid #1f2327; font: 500 9.5px/1.4 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--quiet); }
.activity-list h3[data-tone="needs"] { color: var(--color-orbit-red); }
.activity-list h3[data-tone="running"] { color: var(--color-orbit-amber); }
.act-row { width: 100%; box-sizing: border-box; display: grid; grid-template-columns: 56px 82px minmax(0, 1fr) 188px 84px; gap: 14px; align-items: center; min-height: 52px; padding: 6px 16px; border-bottom: 1px solid #1a1d21; text-align: left; }
button.act-row:hover { background: #14171b; }
.act-row[data-group="needs"] { background: #1a1214; box-shadow: inset 2px 0 var(--color-orbit-red); }
button.act-row[data-group="needs"]:hover { background: #20161a; }
.act-row[data-static] { opacity: .65; }
.act-time { font: 11px var(--font-mono); color: var(--quiet); }
.act-kind { display: flex; align-items: center; gap: 7px; font: 500 9.5px/1 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; }
.act-kind[data-kind="backup"] { color: #9db8e8; }
.act-kind[data-kind="restore"] { color: var(--color-orbit-amber); }
.act-glyph { display: inline-block; flex: none; width: 7px; height: 7px; border-radius: 50%; box-sizing: border-box; }
.act-glyph[data-tone="green"] { background: var(--color-orbit-green); box-shadow: 0 0 8px #8bcbb388; }
.act-glyph[data-tone="amber"] { border: 1px solid var(--color-orbit-amber); box-shadow: 0 0 8px #e8b57e66; }
.act-glyph[data-tone="red"] { border-radius: 1px; transform: rotate(45deg); background: var(--color-orbit-red); box-shadow: 0 0 8px #ffa29c88; }
.act-glyph[data-tone="grey"] { background: #4a4f57; }
.act-text { min-width: 0; }
.act-title { display: block; font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-text small { display: block; margin-top: 2px; font: 10.5px/1.3 var(--font-mono); color: var(--quiet); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-state { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font: 500 10px/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; text-align: right; }
.act-state[data-tone="green"] { color: var(--color-orbit-green); }
.act-state[data-tone="amber"] { color: var(--color-orbit-amber); }
.act-state[data-tone="red"] { color: var(--color-orbit-red); }
.act-state[data-tone="grey"] { color: var(--quiet); }
.act-ticks { display: flex; gap: 3px; }
.act-ticks i { display: block; width: 26px; height: 3px; border-radius: 2px; background: #2f343b; }
.act-ticks i[data-state="done"] { background: var(--color-orbit-green); }
.act-ticks i[data-state="now"] { background: var(--color-orbit-amber); }
.act-open { justify-self: end; font: 500 10px/1 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.act-row[data-static] .act-open { color: var(--quiet); }
.activity-empty { padding: 56px 20px; text-align: center; }
.activity-empty p { font: 500 10px/1 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.activity-empty span { display: block; margin-top: 10px; font-size: 14px; color: var(--quiet); }
.activity-more { width: 100%; padding: 12px; font: 500 10px/1 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--accent); text-align: center; }
@media (max-width: 860px) {
.activity { margin: -16px; }
.activity-bar { flex-direction: column; align-items: flex-start; gap: 10px; padding: 16px 16px 4px; }
.activity-tools { flex-wrap: wrap; padding: 10px 16px; }
.activity-search, .activity-tools .segmented { width: 100%; }
.activity-age { margin-left: 0; }
.activity-list { margin: 0 16px 20px; }
.act-row { grid-template-columns: 52px minmax(0, 1fr) auto; row-gap: 6px; }
.act-kind { grid-column: 2; grid-row: 1; }
.act-time { grid-row: 1; }
.act-text { grid-column: 1 / -1; grid-row: 2; }
.act-state { grid-column: 3; grid-row: 1; flex-direction: row; align-items: center; gap: 8px; }
.act-open { grid-column: 1 / -1; grid-row: 3; justify-self: start; }
}

173
web/src/lib/activity.ts Normal file
View File

@@ -0,0 +1,173 @@
import type { CaptureJob, Orbit, RestoreJob, Snapshot } from "../api";
import { formatBytes, formatWhen } from "./format.ts";
/** Where an entry leads. Restores and exports start from a snapshot, so that is where most entries go. */
export type ActivityTarget = { kind: "snapshot" | "orbit"; id: string };
export type ActivityEntry = {
id: string;
kind: "backup" | "restore";
/** Milliseconds since the epoch, or null when the hub does not say when it happened. */
at: number | null;
tone: "red" | "amber" | "green" | "grey";
state: string;
title: string;
meta: string;
group: "needs" | "running" | "history";
opens: ActivityTarget | null;
/** Position along the five phases of a job in flight, 0 to 4. */
progress?: number;
};
const captureLabels: Record<string, string> = {
queued: "Waiting for outpost",
claimed: "Assigned to agent",
dumping: "Preparing source",
uploading: "Saving backup",
dump_failed: "Source preparation failed or timed out",
upload_failed: "Backup transfer failed",
completed: "Backup completed",
};
const captureOrder = ["queued", "claimed", "dumping", "uploading", "completed"];
const restoreLabels: Record<string, string> = {
queued: "Waiting for outpost",
claimed: "Assigned to agent",
checking: "Verifying archive and target",
safety: "Saving a copy of the target",
ready: "Safety copy verified",
applying: "Applying restore",
completed: "Restore complete",
wrong_target: "Target identity check failed",
invalid_payload: "Archive check failed",
safety_failed: "Safety copy could not be verified",
apply_failed: "Apply failed",
lease_lost: "Agent disconnected during apply",
reconciled: "Recovery verified",
cancelled: "Cancelled",
};
const restoreOrder: string[][] = [["queued", "claimed"], ["checking"], ["safety"], ["ready", "applying"], ["completed", "reconciled"]];
const shortId = (id: string) => id.slice(0, 8);
const inFlight = (status: string) => status === "queued" || status === "running" || status === "applying";
function restoreEntry(job: RestoreJob, snapshots: Map<string, Snapshot>): ActivityEntry {
const source = snapshots.get(job.snapshot_id);
const from = source ? `${source.orbit_name} · ${formatWhen(source.taken_at)}` : `Snapshot ${shortId(job.snapshot_id)}`;
const phase = restoreLabels[job.phase] ?? job.status;
const base = {
id: `restore-${job.id}`,
kind: "restore" as const,
at: job.created_at * 1000,
title: `${from} → ${job.target.name} / ${job.target.identity.database}`,
opens: source ? { kind: "snapshot" as const, id: source.id } : null,
};
if (job.status === "recovery_required") {
return { ...base, group: "needs", tone: "red", state: "Recovery required",
meta: `Restore · ${phase.toLowerCase()} · target locked until verified · open the snapshot` };
}
if (inFlight(job.status)) {
const progress = Math.max(0, restoreOrder.findIndex((phases) => phases.includes(job.phase)));
return { ...base, group: "running", tone: "amber", state: restoreLabels[job.phase] ?? "Running", progress,
meta: `Restore · step ${progress + 1} of 5 · by ${job.actor}` };
}
if (job.status === "failed") {
return { ...base, group: "history", tone: "red", state: "Failed", meta: `Restore · ${phase.toLowerCase()} · by ${job.actor}` };
}
if (job.status === "cancelled") {
return { ...base, group: "history", tone: "grey", state: "Cancelled", meta: `Restore · by ${job.actor}` };
}
const recovered = job.status === "reconciled";
return { ...base, group: "history", tone: "green", state: recovered ? "Recovered" : "Complete",
meta: `Restore · ${job.safety_snapshot_id ? "safety copy kept · " : ""}by ${job.actor}` };
}
function captureEntry(job: CaptureJob, orbits: Map<string, Orbit>): ActivityEntry | undefined {
const orbit = orbits.get(job.profile.orbit_id);
const name = orbit?.name ?? job.profile.application_id;
const base = {
id: `backup-${job.id}`,
kind: "backup" as const,
at: job.created_at * 1000,
title: name,
opens: orbit ? { kind: "orbit" as const, id: orbit.id } : null,
};
const phase = captureLabels[job.phase] ?? job.status;
if (job.status === "queued" || job.status === "running") {
const progress = Math.max(0, captureOrder.indexOf(job.phase));
return { ...base, group: "running", tone: "amber", state: phase, progress,
meta: `Backup via Outpost · step ${progress + 1} of 5 · by ${job.actor}` };
}
if (job.status === "failed") {
return { ...base, group: "history", tone: "red", state: "Failed", meta: `Backup via Outpost · ${phase.toLowerCase()} · nothing was stored` };
}
return undefined;
}
export function buildActivity({ snapshots, orbits, captureJobs, restoreJobs, now }: {
snapshots: readonly Snapshot[];
orbits: readonly Orbit[];
captureJobs: readonly CaptureJob[];
restoreJobs: readonly RestoreJob[];
now: number;
}): ActivityEntry[] {
const snapshotById = new Map(snapshots.map((snapshot) => [snapshot.id, snapshot]));
const orbitById = new Map(orbits.map((orbit) => [orbit.id, orbit]));
const jobForSnapshot = new Map(captureJobs.filter((job) => job.snapshot_id).map((job) => [job.snapshot_id!, job]));
const entries: ActivityEntry[] = [];
for (const snapshot of snapshots) {
const job = jobForSnapshot.get(snapshot.id);
entries.push({
id: `snapshot-${snapshot.id}`,
kind: "backup",
at: Date.parse(snapshot.taken_at) || null,
tone: "green",
state: "Stored",
title: `${snapshot.orbit_name} → ${formatBytes(snapshot.size_bytes)} snapshot`,
meta: `Backup${job ? ` via Outpost · by ${job.actor}` : ""} · ${shortId(snapshot.id)}`,
group: "history",
opens: { kind: "snapshot", id: snapshot.id },
});
}
for (const job of captureJobs) {
const entry = captureEntry(job, orbitById);
if (entry) entries.push(entry);
}
// Orbits the hub runs itself have no job list, only their last status; an outpost orbit is covered by its jobs above.
for (const orbit of orbits) {
if (orbit.application_id || orbit.access === "outpost") continue;
if (orbit.last_status === "running" || orbit.last_status === "queued" || orbit.last_status === "rehearsing") {
entries.push({ id: `orbit-${orbit.id}-running`, kind: "backup", at: now, tone: "amber", state: "Running",
title: orbit.name, meta: "Backup via Hub", group: "running", opens: { kind: "orbit", id: orbit.id } });
} else if (orbit.last_status === "failed") {
entries.push({ id: `orbit-${orbit.id}-failed`, kind: "backup", at: null, tone: "red", state: "Last backup failed",
title: orbit.name, meta: "Backup via Hub · the hub does not record when it failed", group: "needs",
opens: { kind: "orbit", id: orbit.id } });
}
}
for (const job of restoreJobs) entries.push(restoreEntry(job, snapshotById));
const rank = { needs: 0, running: 1, history: 2 } as const;
return entries.sort((a, b) => rank[a.group] - rank[b.group] || (b.at ?? -Infinity) - (a.at ?? -Infinity) || a.id.localeCompare(b.id));
}
export function activityCounts(entries: readonly ActivityEntry[]) {
return {
running: entries.filter(({ group }) => group === "running").length,
needs: entries.filter(({ group }) => group === "needs").length,
};
}
/** "Today", "Yesterday" or a short date, in the viewer's time zone. */
export function dayLabel(at: number, now: number): string {
const day = (time: number) => new Date(time).setHours(0, 0, 0, 0);
const gap = Math.round((day(now) - day(at)) / 86_400_000);
if (gap <= 0) return "Today";
if (gap === 1) return "Yesterday";
return new Date(at).toLocaleDateString(undefined, { month: "short", day: "numeric", ...(gap > 300 ? { year: "numeric" } : {}) });
}
export function clock(at: number): string {
return new Date(at).toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit", hour12: false });
}