import type { SearchProgress, SearchTaskStatus } from '@/services/automationService';

type SearchManualInterventionState = NonNullable<NonNullable<SearchProgress['result']>['manualIntervention']>;

export function getDisplaySearchTaskStatus(
  status: SearchTaskStatus,
  manualIntervention?: SearchManualInterventionState | null,
): SearchTaskStatus {
  if (status === 'waiting_for_manual' && manualIntervention?.active === false) {
    return 'processing';
  }

  return status;
}
