import { useNavigate, useParams } from 'react-router-dom'; import { Brain, ChevronRight, Radar } from 'lucide-react'; import { useQuery, useZino } from '../api/provider'; import { FINDING_KIND, QUEUES, RECORD_VIEW, STAGE_TONE } from '../api/config'; import { Badge, Button, Empty, ErrorNote, Spinner } from '../components/core'; import type { Row } from '../api/types'; import { dateTime, headline, money, num, prose, sentences, str, workStatement } from '../format'; /** * A queue, as a morning briefing. * * The first thing on the page is not a list: it is one strip that says what * Ava did and what is waiting — "reviewed everything, one thing needs you, * worth $1.09M". A manager who reads only that line has the day's status. * The cases follow, each led by its one-sentence verdict and the money. * * POLLS, because cases move on their own — Investigating → Awaiting Review with * no user action to hang a refresh off. A stale list looks like a stuck system. */ export function QueueScreen() { const { q } = useParams(); const navigate = useNavigate(); const { client } = useZino(); const queue = QUEUES.find((x) => x.path === q) ?? QUEUES[0]; const rows = useQuery( () => client.rows(RECORD_VIEW, { limit: 100, sortBy: 'updated_at', sortDir: 'desc', filters: queue.stage ? [{ field_key: 'current_state_name', value: queue.stage, data_type: 'text' }] : [], }), [queue.path], true, 8000, ); // The briefing needs the whole picture, whichever queue is open. const all = useQuery(() => client.rows(RECORD_VIEW, { limit: 100, sortBy: 'updated_at', sortDir: 'desc' }), [], true, 15000); const list = rows.data ?? []; return (
{queue.hint}
Daily review{latest ? ` · last run ${dateTime(latest.updated_at)}` : ''}
{waiting.length === 0 && working.length === 0 && needsHuman.length === 0 ? 'No cases awaiting decision.' : [ waiting.length > 0 && `${waiting.length} case${waiting.length === 1 ? '' : 's'} awaiting decision${ recoverable > 0 ? ` · ${money(recoverable)} recoverable` : '' }`, working.length > 0 && `${working.length} review${working.length === 1 ? '' : 's'} in progress`, needsHuman.length > 0 && `${needsHuman.length} escalated`, ] .filter(Boolean) .join(' · ')}
Automated review of all payers, departments and front desks. A case is opened only when a change clears the materiality threshold.