import { useEffect, useState, type ReactNode } from 'react'; import { api, BlobSummary, TagSummary, RefSummary, SnapshotSummary, fmtBytes, fmtAge, } from '../lib/api'; type Tab = 'blobs' | 'tags' | 'refs' | 'snapshots'; interface Props { tab: Tab; } export function StorageBrowser({ tab }: Props) { return (

Storage · {tab}

{tab === 'blobs' && } {tab === 'tags' && } {tab === 'refs' && } {tab === 'snapshots' && }
); } function BlobsList() { const [rows, setRows] = useState([]); const [err, setErr] = useState(null); useEffect(() => { api.blobs().then(setRows).catch((e) => setErr(String(e))); }, []); return ( <> {err && } [ , {r.blob_id_hex.slice(0, 24)}… , fmtBytes(r.size_bytes), r.chunk_count.toString(), ])} />
); } function TagsList() { const [rows, setRows] = useState([]); const [prefix, setPrefix] = useState(''); const [err, setErr] = useState(null); useEffect(() => { api.tags(prefix).then(setRows).catch((e) => setErr(String(e))); }, [prefix]); return ( <> setPrefix(e.target.value)} placeholder="filter prefix — e.g. clawverse:" className="w-full sm:w-96 rounded bg-slate-900 border border-slate-800 px-3 py-2 text-sm font-mono" /> {err && }
[ , {r.key} , {r.value_hex.slice(0, 24)}… , ])} />
); } function RefsList() { const [rows, setRows] = useState([]); const [err, setErr] = useState(null); useEffect(() => { api.refs().then(setRows).catch((e) => setErr(String(e))); }, []); return ( <> {err && }
[ , {r.fingerprint_hex.slice(0, 24)}… , {r.blob_id_hex.slice(0, 24)}… , ])} />
); } function SnapshotsList() { const [rows, setRows] = useState([]); const [err, setErr] = useState(null); useEffect(() => { api.snapshots().then(setRows).catch((e) => setErr(String(e))); }, []); return ( <> {err && }
[ , {r.name} , fmtAge(r.created_at_unix), r.blob_count.toString(), fmtBytes(r.file_bytes), ])} />
); } function Table({ headers, rows, }: { headers: string[]; rows: ReactNode[][]; }) { return (
{headers.map((h) => ( ))} {rows.length === 0 && ( )} {rows.map((row, i) => ( {row.map((cell, j) => ( ))} ))}
{h}
nothing here yet
{cell}
); } function Footer({ count }: { count: number }) { return (
{count} row{count === 1 ? '' : 's'}
); } function ErrorBox({ msg }: { msg: string }) { return (
{msg}
); } /// Small pill badge for the originating node — clickable to /// drill into that node's detail page. function NodePill({ node }: { node: string }) { return ( {node} ); }