import { useQuery } from '@tanstack/react-query' import { useCallback, useState } from 'react' import { settingsApi } from '../api/client' function fmtSize(bytes: number): string { if (bytes === 0) return '0 B' const units = ['B', 'KB', 'MB', 'GB', 'TB'] const i = Math.min(Math.floor(Math.log(bytes) / Math.log(1024)), units.length - 1) return (bytes / Math.pow(1024, i)).toFixed(1) + ' ' + units[i] } function fmtPercent(p: number): string { return p.toFixed(1) + '%' } function CopyPath({ path }: { path: string }) { const [copied, setCopied] = useState(false) const copy = useCallback(async () => { try { await navigator.clipboard.writeText(path) setCopied(true) setTimeout(() => setCopied(false), 1500) } catch {} }, [path]) return ( {path} {copied && } ) } export default function Status() { const { data, isLoading, error } = useQuery({ queryKey: ['server-health'], queryFn: settingsApi.health, refetchInterval: 10000, }) if (isLoading) return

Loading status...

if (error) return

Failed to load status: {(error as Error).message}

if (!data) return null return (

Deploy Status

{data.server.binary_path && ( } /> )}
: '-'} />
{data.paths.map((p, i) => ( ))}
Path Exists Writable
{data.disk.map((d, i) => ( ))}
Path Total Free Used
{fmtSize(d.total_bytes)} {fmtSize(d.free_bytes)} 90 ? 'text-red-400' : d.used_percent > 75 ? 'text-yellow-400' : ''}> {fmtPercent(d.used_percent)}
) } function Section({ title, children }: { title: string; children: React.ReactNode }) { return (

{title}

{children}
) } function StatusRow({ label, value, ok, warn }: { label: string; value: React.ReactNode; ok?: boolean; warn?: boolean }) { return (
{label} {ok !== undefined && } {warn && } {value}
) } function Badge({ ok, label }: { ok: boolean; label: string }) { return ( {label} ) } function Dot({ color }: { color: string }) { return }