"use client"; import { useEffect, useState } from "react"; export type RunningVersion = { /** App version from package.json (bumped once per task). */ version?: string; commit: string; short: string; builtAt: string | null; release: string | null; dev: boolean; }; /** Which release is running (from /api/healthz), for the Settings details. */ export function useVersion(): RunningVersion | null { const [version, setVersion] = useState(null); useEffect(() => { let cancelled = false; void (async () => { try { const response = await fetch("/api/healthz", { cache: "no-store" }); if (!response.ok) return; const body = (await response.json()) as RunningVersion; if (!cancelled) setVersion(body); } catch { /* offline or old server — the row stays hidden */ } })(); return () => { cancelled = true; }; }, []); return version; }