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