import React from 'react'; import { Box, Text } from '@anthropic/ink'; import type { Theme } from '../../utils/theme.js'; export type AutofixPhase = | 'detecting' | 'checking_eligibility' | 'acquiring_lock' | 'launching' | 'registered' | 'done' | 'error'; interface AutofixProgressProps { phase: AutofixPhase; target: string; sessionUrl?: string; errorMessage?: string; } const PHASE_LABELS: Record = { detecting: 'Detecting repository...', checking_eligibility: 'Checking remote agent eligibility...', acquiring_lock: 'Acquiring monitor lock...', launching: 'Launching remote session...', registered: 'Session registered', done: 'Autofix launched', error: 'Error', }; const PHASE_ORDER: AutofixPhase[] = [ 'detecting', 'checking_eligibility', 'acquiring_lock', 'launching', 'registered', 'done', ]; function phaseIndex(phase: AutofixPhase): number { return PHASE_ORDER.indexOf(phase); } /** * Inline progress component for /autofix-pr. * Rendered by the REPL alongside the onDone text message. */ export function AutofixProgress({ phase, target, sessionUrl, errorMessage }: AutofixProgressProps): React.ReactElement { const currentIdx = phaseIndex(phase); const isError = phase === 'error'; return ( Autofix PR {target} {PHASE_ORDER.map((p, i) => { const isDone = currentIdx > i; const isActive = currentIdx === i && !isError; const symbol = isDone ? 'โœ“' : isActive ? 'โ†’' : 'ยท'; const color: keyof Theme = isDone ? 'success' : isActive ? 'warning' : 'subtle'; return ( {symbol} {PHASE_LABELS[p]} ); })} {isError && errorMessage && ( โœ— {errorMessage} )} {sessionUrl && ( Track: {sessionUrl} )} ); }