Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

799 B
Raw Blame
import type { AcceptanceStatus, VerifyRunStatus } from '@lobechat/types';

interface RepairProgress {
  deliveryRunStatus?: VerifyRunStatus | null;
  deliveryStatus?: AcceptanceStatus;
  previewUrl?: string;
  state: 'failed' | 'finished' | 'running' | 'starting';
}

export const repairPresentation = (repair: RepairProgress) => {
  if (repair.state !== 'finished') return repair.state;
  if (repair.deliveryStatus === 'verifying' || repair.deliveryStatus === 'planned')
    return 'verifying';
  if (!repair.deliveryRunStatus) return 'awaitingDelivery';
  if (['failed', 'uncertain', 'errored'].includes(repair.deliveryRunStatus))
    return 'verificationFailed';
  if (repair.deliveryRunStatus !== 'passed') return 'awaitingDelivery';
  return repair.previewUrl ? 'ready' : 'awaitingPreview';
};