"use client"; import React, { useEffect, useState } from "react"; import { loadInvestigation } from "@/lib/storage/investigation-storage"; import Link from "next/link"; export default function ReportPage() { const [existing, setExisting] = useState(null); const [hydrated, setHydrated] = useState(false); useEffect(() => { setExisting(loadInvestigation()); setHydrated(true); }, []); const report = existing?.investigationReport || null; const scenario = hydrated ? (existing?.scenario || "") : null; const paragraphs = (report?.understanding || "") .split("\n") .filter(Boolean); return (

Investigation Report

{/* Situation */} {scenario && (

Situation

{scenario}

)} {/* What we understand */} {report ? ( <> {paragraphs.length > 0 ? ( paragraphs.map((p, i) => (

What we understand

{p}

)) ) : (

What we understand

{report.understanding || ""}

)} {/* What remains plausible — conditional */} {report.hasPlausibleInterpretations && report.plausibleInterpretations ? (

What remains plausible

{report.plausibleInterpretations}

) : null} ) : ( /* Skeleton / loading state when no persisted report exists */ <>

What we understand

Report generation pending. A summary will appear here once the investigation reaches milestone.

)} {/* Back to investigation */}
Back to investigation
{/* Back to portfolio */}
Back to portfolio
); }