import { useEffect, useState } from 'react'; import { api } from '../api/client'; import type { Remote, ProbeResult } from '../api/types'; import { Badge } from '../components/Badge'; import { formatBytes } from '../components/format'; import './Probe.css'; const PRESETS: Record = { 'gitea-dl': [ { remote: 'gitea-dl', path: 'gitea/1.23.7/gitea-1.23.7-linux-amd64' }, { remote: 'gitea-dl', path: 'act_runner/0.2.11/act_runner-0.2.11-linux-amd64' }, ], 'github': [ { remote: 'github', path: 'ducaale/xh/releases/download/v0.24.0/xh-v0.24.0-x86_64-unknown-linux-musl.tar.gz' }, { remote: 'github', path: 'mikefarah/yq/releases/download/v4.45.4/yq_linux_amd64' }, { remote: 'github', path: 'neovim/neovim-releases/releases/download/v0.11.2/nvim-linux-x86_64.tar.gz' }, ], 'hashicorp-releases': [ { remote: 'hashicorp-releases', path: 'terraform/1.12.2/terraform_1.12.2_linux_amd64.zip' }, ], 'goproxy': [ { remote: 'goproxy', path: 'golang.org/x/net/@v/list' }, { remote: 'goproxy', path: 'golang.org/x/net/@v/v0.55.0.info' }, ], }; export function Probe() { const [remotes, setRemotes] = useState([]); const [remote, setRemote] = useState(''); const [path, setPath] = useState(''); const [loading, setLoading] = useState(false); const [result, setResult] = useState(null); const [history, setHistory] = useState<(ProbeResult & { remote: string; path: string })[]>([]); useEffect(() => { api.listRemotes().then(r => { setRemotes(r || []); if (r?.length && !remote) setRemote(r[0].name); }); }, []); const runProbe = async () => { if (!remote || !path) return; setLoading(true); setResult(null); try { const r = await api.probe(remote, path); setResult(r); setHistory(prev => [{ ...r, remote, path }, ...prev].slice(0, 20)); } catch (e: unknown) { setResult({ status: 0, source: '', content_type: '', size_bytes: 0, headers: {}, duration_ms: 0, error: e instanceof Error ? e.message : String(e), }); } finally { setLoading(false); } }; const applyPreset = (r: string, p: string) => { setRemote(r); setPath(p); }; const remotePresets = PRESETS[remote] || []; return (

Test Remote

Probe a remote to test connectivity and caching. The file is fetched and cached but not sent to your browser.

setPath(e.target.value)} onKeyDown={e => e.key === 'Enter' && runProbe()} />
{remotePresets.length > 0 && (
Quick tests: {remotePresets.map((p, i) => ( ))}
)} {result && (
{result.status} {result.source || 'error'} {result.duration_ms}ms
{result.error ? (
{result.error}
) : (
Content-Type
{result.content_type}
Size
{formatBytes(result.size_bytes)} ({result.size_bytes.toLocaleString()} bytes)
Source
{result.source === 'cache' ? 'Served from cache (S3)' : 'Fetched from upstream'}
Duration
{result.duration_ms}ms
{result.headers && Object.entries(result.headers).map(([k, v]) => (
{k}
{v}
))}
)}
)} {history.length > 0 && (

History

{history.map((h, i) => ( applyPreset(h.remote, h.path)} > ))}
Remote Path Status Source Size Time
{h.remote} {h.path} {h.status} {h.source || 'err'} {formatBytes(h.size_bytes)} {h.duration_ms}ms
)}
); }