import { useState, useEffect } from 'react' import { Link, useNavigate } from 'react-router-dom' import { AlertTriangle, ChevronDown, ChevronRight, Hash } from 'lucide-react' import { aiSessionsApi } from '@/api/aiSessions' import type { AISessionSummary } from '@/types/ai-session' import { timeAgo } from '@/lib/timeAgo' import { cn } from '@/lib/utils' export function PendingEscalations() { const [escalations, setEscalations] = useState([]) // Single expansion at a time — keeps the dashboard compact even when // multiple escalations are pending. Click a row again to collapse. const [expandedId, setExpandedId] = useState(null) const navigate = useNavigate() useEffect(() => { aiSessionsApi.getEscalationQueue() .then(setEscalations) .catch(() => {}) }, []) if (escalations.length === 0) return null return (

Pending Escalations {escalations.length}

View all
{escalations.slice(0, 3).map((esc, i) => { const isExpanded = expandedId === esc.id const isLast = i >= Math.min(escalations.length, 3) - 1 return (
{isExpanded && (
{esc.escalation_reason && (

Why escalated

{esc.escalation_reason}

)}
{esc.step_count}{' '} diagnostic {esc.step_count === 1 ? 'step' : 'steps'} on record {esc.confidence_tier && ( Confidence: {esc.confidence_tier} )}
{!esc.escalation_reason && (

No reason note from the original engineer. Pick up to see the full session context and AI assessment.

)}
)}
) })}
) }