'use client'; import { useEffect, useState } from 'react'; import Link from 'next/link'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { Skeleton } from '@/components/ui/skeleton'; import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'; import { AlertTriangle } from 'lucide-react'; import type { PersistedAnalysis } from '@/lib/types/analyzer'; export default function AnalyzerQueuePage() { const [analyses, setAnalyses] = useState(null); const [error, setError] = useState(null); useEffect(() => { let cancelled = false; (async () => { try { const res = await fetch(`/api/analyzer/needs-review?limit=100`); if (!res.ok) { const data = (await res.json().catch(() => ({}))) as { error?: string }; throw new Error(data.error ?? `Request failed: ${res.status}`); } const { analyses } = (await res.json()) as { analyses: PersistedAnalysis[] }; if (!cancelled) setAnalyses(analyses); } catch (err) { if (!cancelled) setError(err instanceof Error ? err.message : 'Unknown error'); } })(); return () => { cancelled = true; }; }, []); return (

Needs human review

AI analyses that flagged themselves for human review โ€” high-severity gaps, low confidence, conflicting evidence, or cost-ceiling skips.

{error && ( Couldn’t load review queue {error} )} Queue {analyses && ( {analyses.length} )} {analyses === null && !error ? (
) : analyses && analyses.length === 0 ? (

Nothing flagged. ๐ŸŽ‰

) : (
    {(analyses ?? []).map((a) => (
  • {a.ticketNumber} ยท v{a.analysisVersion} {a.summary && (

    {a.summary}

    )} {(a.humanReviewReasons ?? []).length > 0 && (
      {(a.humanReviewReasons ?? []).slice(0, 3).map((r, i) => (
    • {r}
    • ))}
    )}

    {new Date(a.triggeredAt).toLocaleString()}

    {a.confidenceScore !== null && ( {Math.round(a.confidenceScore * 100)}% )} {(a.gaps ?? []).some((g) => g.severity === 'high') && ( high gap )}
  • ))}
)}
); }