import { Tooltip } from '@mantine/core'; import { Link } from 'react-router-dom'; import type { Schemas } from '../../api/client'; import { decisionWords, RUN_STATUS_WORDS } from '../../glossary'; import { runAreas, runTitle, shortWhen } from '../../runName'; import type { EnvKind } from './EnvSwitcher'; import { isWaiting, useWaitsOnMe, waitingForWords } from '../../waiting'; import { runState, StatusDot } from './StatusDot'; type RunSummary = Schemas['RunSummary']; // Accessible names avoid the phrase "scenario review": that is the name of the review region itself. export const runStatusWords = (r: Pick, mine = true) => isWaiting(r) && !mine ? waitingForWords(r.pending_gate).toLowerCase() : r.pending_gate === 'approve_cases' ? 'waiting for you to approve the scenarios' : r.pending_gate === 'human_review' ? 'waiting for your decision on failures' : r.status === 'waiting_approval' || r.status === 'waiting_review' ? 'waiting for you' : RUN_STATUS_WORDS[r.status] ?? r.status.replace('_', ' '); /** One short status for a run row: dot + word (UI-SIMPLIFY 3.1). */ export const rowWords = (r: Pick, decision?: string | null, mine = true) => isWaiting(r) && !mine ? waitingForWords(r.pending_gate) : r.pending_gate === 'approve_cases' ? 'Needs your approval' : r.pending_gate === 'human_review' ? 'Needs your decision' : r.status === 'queued' ? 'Starting' : r.status === 'running' ? 'Testing' : r.status === 'completed' ? (decision ? decisionWords(decision) : 'Finished') : r.status === 'interrupted' ? 'Paused' : r.status === 'cancelled' ? 'Cancelled' : 'Stopped'; /** A test run in the sidebar, like a conversation: state dot, business area, when, where, and what it needs from you. */ export function RunListItem({ run, active, compact = false, envKind }: { run: RunSummary; active: boolean; compact?: boolean; envKind?: EnvKind }) { const state = runState(run); const mine = useWaitsOnMe()(run); const words = runStatusWords(run, mine); const label = `${runTitle(run)}, ${words}`; const d = run.decision ?? Object.values(run.decisions ?? {})[0] ?? null; if (compact) { return ( ); } void envKind; return ( {runAreas(run)} {shortWhen(run.created_at)} ยท {rowWords(run, d, mine)} ); }