// Excavation archive — scan history, navigates to Dashboard for viewing const ARCHIVE_API = 'https://r5vefiej3l.execute-api.eu-central-1.amazonaws.com/prod'; const ARCH_COG = '7nffjheavp985k7b4bgug45jf4'; function archToken() { const last = localStorage.getItem(`CognitoIdentityServiceProvider.${ARCH_COG}.LastAuthUser`); if (last) { const t = localStorage.getItem(`CognitoIdentityServiceProvider.${ARCH_COG}.${last}.idToken`); if (t) return t; } return window.getIdToken ? window.getIdToken() : ''; } async function archApi(method, path) { const res = await fetch(`${ARCHIVE_API}${path}`, { method, headers: { Authorization: `Bearer ${archToken()}` } }); const d = await res.json().catch(() => ({})); if (!res.ok) throw new Error(d.error || `HTTP ${res.status}`); return d; } function getHistory() { try { return JSON.parse(localStorage.getItem('fossyl_job_history') || '[]'); } catch { return []; } } function fmtDate(iso) { if (!iso) return '—'; try { return new Date(iso).toLocaleDateString('en-GB', { day: '2-digit', month: 'short', year: 'numeric' }); } catch { return iso.slice(0, 10); } } function fmtNum(n) { return n && n > 0 ? n.toLocaleString() : '—'; } function ReportPage() { const { go } = useNav(); const { toast } = useToast(); const [history, setHistory] = useState(getHistory); const [downloading, setDownloading] = useState(false); const [deleting, setDeleting] = useState(null); // job_id being confirmed const openReport = (jobId) => { localStorage.setItem('fossyl_active_job', jobId); go('report'); }; const handleDownload = async (jobId) => { setDownloading(true); try { const d = await archApi('GET', `/download/${jobId}`); window.location.href = d.download_url; } catch (e) { toast(e.message || 'Download failed', { tone: 'error' }); } finally { setDownloading(false); } }; const handleShare = async (jobId) => { try { const d = await archApi('GET', `/download/${jobId}?view=1`); navigator.clipboard?.writeText(d.download_url).catch(() => {}); toast('Link copied — valid 1 hour', { tone: 'success' }); } catch (e) { toast(e.message || 'Failed', { tone: 'error' }); } }; const handleDelete = (jobId) => { // Remove from localStorage history const updated = history.filter(j => j.job_id !== jobId); localStorage.setItem('fossyl_job_history', JSON.stringify(updated)); // If this was the active job, clear it if (localStorage.getItem('fossyl_active_job') === jobId) { localStorage.removeItem('fossyl_active_job'); } setHistory(updated); setDeleting(null); toast('Excavation removed from history', { tone: 'success' }); }; return (
{/* Delete confirmation modal */} {deleting && (
setDeleting(null)}>
e.stopPropagation()} style={{ width: 440, background: 'var(--bg)', border: '1px solid var(--rust-dim)', borderRadius: 3, padding: 28 }}>
Remove excavation

This removes {deleting.slice(0, 8)} from your history. The report file will expire per your plan retention. This cannot be undone.

)} {history.length === 0 && (
No excavations yet

Run your first excavation →

Upload a codebase ZIP + ZODB export to generate your first archaeological map.

)} {history.length > 0 && (
Excavation history
{history.map(j => ( j.status === 'done' && openReport(j.job_id)}> ))}
Scan IDDateStatusSizeTTW scriptsDependencies
{j.job_id.slice(0, 8)} {fmtDate(j.created_at)} {j.status} {j.report_size_kb ? `${j.report_size_kb} KB` : '—'} {fmtNum(j.ttw_count)} {fmtNum(j.edge_count)} {j.status === 'done' && (
e.stopPropagation()}>
)} {j.status !== 'done' && (
e.stopPropagation()}>
)}
)} {history.length > 0 && (
What each report contains
{[ ['§ 01','Overview','Summary metrics and risk indicators'], ['§ 02','ZODB Divergence','Filesystem vs live database delta'], ['§ 03','Dependency graph','Node-edge coupling map, entry points'], ['§ 04','High coupling','Artifacts risky to modify'], ['§ 05','Version groups','Duplicate script variants'], ['§ 06','AI explanations','Plain-English field notes per artifact'], ['§ 07','Dead code','Uncalled scripts safe to remove'], ['§ 08','Source browser','Full annotated source of every artifact'], ].map(([num, title, desc]) => (
{num}
{title}
{desc}
))}
)}
); } Object.assign(window, { ReportPage });