diff --git a/app/api/investigations/[id]/restart/route.js b/app/api/investigations/[id]/restart/route.js new file mode 100644 index 0000000..5d030fb --- /dev/null +++ b/app/api/investigations/[id]/restart/route.js @@ -0,0 +1,14 @@ +import { restartInvestigation } from "@/lib/storage/server-investigation-persistence.js"; +import { withAuthenticatedApi } from "@/lib/supabase/api-auth.js"; + +async function post(_request, { params }) { + try { + const snapshot = await restartInvestigation(params.id); + if (!snapshot) return Response.json({ error: "Investigation not found" }, { status: 404 }); + return Response.json({ snapshot }); + } catch { + return Response.json({ error: "Investigation persistence request failed" }, { status: 500 }); + } +} + +export const POST = withAuthenticatedApi(post); \ No newline at end of file diff --git a/app/investigations/[id]/page.jsx b/app/investigations/[id]/page.jsx index 8f945d2..87a42d6 100644 --- a/app/investigations/[id]/page.jsx +++ b/app/investigations/[id]/page.jsx @@ -11,10 +11,21 @@ export default function InvestigationPage({ params }) { const router = useRouter(); const routeId = typeof params?.id === "string" ? params.id : ""; const [existing, setExisting] = useState(null); + const [hydrated, setHydrated] = useState(false); useEffect(() => { - if (!routeId) return; - setExisting(loadInvestigation(routeId)); + let active = true; + setHydrated(false); + if (!routeId) { setHydrated(true); return; } + (async () => { + try { + const snapshot = await loadInvestigation(routeId); + if (active) setExisting(snapshot); + } finally { + if (active) setHydrated(true); + } + })(); + return () => { active = false; }; }, [routeId]); return ( @@ -35,7 +46,9 @@ export default function InvestigationPage({ params }) { evidence-based structured reconstruction. This is a technical vertical slice — not a production system.
- {existing ? ( + {!hydrated ? ( +Loading investigation…
+ ) : existing ? (