import { h } from "preact"; import { useState, useEffect } from "preact/hooks"; import "./settings.css"; import { api } from "../base/api.jsx"; import { statusKind, statusLabel } from "../base/task-meta.jsx"; import { Pill } from "../base/pill.jsx"; import { Row } from "./config-row.jsx"; import { UpdateStatusCard } from "./update-status.jsx"; function Empty({ title, detail }) { return (
{title}
{detail &&
{detail}
}
); } function Section({ title, sub, children }) { return (

{title}

{sub}

{children}
); } function ProvenanceCard({ origins }) { if (!origins?.length) return (
); return (
{origins.map((origin, i) => ( ))}
); } function roleButtonClass(kind) { return kind === "quiet" ? "btn-quiet" : kind === "danger" ? "btn-danger" : ""; } function LifecycleCard({ data, error }) { if (error) { return (
); } const statuses = data?.statuses || []; const actions = data?.actions || []; return (

Statuses

{statuses.length ? (
{statuses.map(s => { const label = s.label ?? statusLabel(s.id); const kind = s.kind ?? statusKind(s.id); return (
{s.id}
); })}
) : ( )}

Actions

{actions.length ? (
{actions.map(a => { const label = a.label ?? a.id; const cls = roleButtonClass(a.kind); return (
{a.id}
); })}
) : ( )}
); } function RepoBoolCell({ r, field, onSaved }) { const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const [checked, setChecked] = useState(!!r[field]); const handleChange = async (e) => { const next = e.target.checked; setChecked(next); setLoading(true); setError(null); try { await api.configRepoUpdate(r.owner, r.name, field, next); onSaved?.(); } catch (err) { setChecked(!next); setError(String(err.message || err)); } finally { setLoading(false); } }; return ( {error && {error}} ); } function RepoIntCell({ r, field, onSaved }) { const [val, setVal] = useState(String(r[field] ?? 0)); const [error, setError] = useState(null); const [loading, setLoading] = useState(false); const commit = async () => { const n = parseInt(val, 10); if (Number.isNaN(n)) { setError("Enter a whole number"); return; } setLoading(true); setError(null); try { await api.configRepoUpdate(r.owner, r.name, field, n); onSaved?.(); } catch (err) { setError(String(err.message || err)); } finally { setLoading(false); } }; const handleKeyDown = (e) => { if (e.key === "Enter") { e.preventDefault(); e.target.blur(); } }; return ( setVal(e.target.value)} onBlur={commit} onKeyDown={handleKeyDown} disabled={loading} /> {error && {error}} ); } function RepositoriesCard({ repos, onSaved }) { if (!repos?.length) { return (
); } const gateSummary = (gate) => { if (!gate?.length) return "—"; return gate.map((cmd) => cmd.join(" ")).join(" → "); }; return (
{repos.map((r, i) => ( ))}
RepositoryBase branchEcosystemQuality gateProtected pathsConcurrentMax retriesSelf-review
{r.owner}/{r.name} {r.base} {r.ecosystem || "go"} {gateSummary(r.gate)} {r.protect?.length ? r.protect.join(", ") : "—"}
); } function roleLabel(role) { if (!role) return "Unknown role"; return role.charAt(0).toUpperCase() + role.slice(1).replace(/_/g, " "); } function ModelsAndProvidersCard({ models, providers }) { const modelEntries = Object.entries(models || {}); const providerEntries = Object.entries(providers || {}); return (

Model roles

{modelEntries.length ? (
{modelEntries.map(([role, ref]) => ( ))}
) : ( )}

Providers

{providerEntries.length ? (
{providerEntries.map(([name, p]) => ( ))}
ProviderClassBase URLAPI key env varStatus
{name} {p.class} {p.base_url || "default"} {p.api_key_env || "—"} {p.configured ? : }
) : ( )}
); } function SettingsApp() { const [cfg, setCfg] = useState(null); const [cfgError, setCfgError] = useState(null); const [versionData, setVersionData] = useState(null); const [versionError, setVersionError] = useState(null); const [versionMissing, setVersionMissing] = useState(false); const [lifecycleData, setLifecycleData] = useState(null); const [lifecycleError, setLifecycleError] = useState(null); const loadAll = () => { loadCfg(); loadVersion(); loadLifecycle(); }; const loadCfg = async () => { try { const data = await api.config(); setCfg(data); setCfgError(null); } catch (err) { setCfgError(String(err.message || err)); } }; const loadVersion = async () => { try { const data = await api.version(); setVersionData(data?.components || []); setVersionError(null); setVersionMissing(false); } catch (err) { if (err?.status === 501) { setVersionMissing(true); } else { setVersionError(String(err.message || err)); } } }; const loadLifecycle = async () => { try { const data = await api.taskMeta(); setLifecycleData(data); setLifecycleError(null); } catch (err) { setLifecycleError(String(err.message || err)); } }; useEffect(() => { loadAll(); }, []); return (

Configuration

What archied is actually running with right now.

{!versionMissing && ( versionError ? (
) : versionData ? ( ) : null )}
{cfgError ? (
) : !cfg || Object.keys(cfg).length === 0 ? (
) : ( <> {cfg.reload?.overlay_unavailable && (

The runtime config overlay is not in effect: {cfg.reload.overlay_unavailable}

)} {cfg.reload?.last_error && (

The last config reload failed; the running config is unchanged: {cfg.reload.last_error}

)} {(cfg.schema || []).map((s, i) => { const rows = s.fields.filter(f => f.type !== "structured"); if (!rows.length) return null; return (
{rows.map(f => ( ))}
); })} )}
); } export function settingsPage(query) { return ; }