/** * Simulated processing-phase text with an animated ellipsis, shown while * /api/process is in flight. There is no real progress signal from the * backend - it's one synchronous request - so this is a client-side * timer cycling through an honestly-ordered sequence of what the * pipeline is actually doing (see backend/services/pipeline_service.py's * own run() order), not a measurement of real completion. */ import { ref, computed } from 'vue' const PHASES = [ 'Reading document', 'Extracting transactions', 'Cross-checking with a second engine', 'Running verification checks', 'Preparing results', ] const PHASE_INTERVAL_MS = 1800 const DOT_INTERVAL_MS = 400 export function useProcessingPhases() { const isProcessing = ref(false) const phaseIndex = ref(0) const dotCount = ref(1) let phaseTimer = null let dotTimer = null const phaseText = computed(() => { const dots = '.'.repeat(dotCount.value) return `${PHASES[phaseIndex.value]}${dots}` }) function start() { isProcessing.value = true phaseIndex.value = 0 dotCount.value = 1 // Advances through PHASES on a timer; holds on the last one if the // real request takes longer than the simulated sequence rather than // looping back to "Reading document" - looping would misleadingly // suggest the work restarted. phaseTimer = setInterval(() => { if (phaseIndex.value < PHASES.length - 1) phaseIndex.value++ }, PHASE_INTERVAL_MS) dotTimer = setInterval(() => { dotCount.value = (dotCount.value % 3) + 1 }, DOT_INTERVAL_MS) } function stop() { isProcessing.value = false clearInterval(phaseTimer) clearInterval(dotTimer) phaseTimer = null dotTimer = null } return { isProcessing, phaseText, start, stop } }