/* * GenerationProgress.tsx * Purpose: A polished full-screen progress overlay shown while the AI generates a deck. * The backend call is a single async request with no streaming progress, so this eases a * determinate-looking bar toward ~92% and cycles through human-readable stage labels, then * snaps to 100% when it unmounts (i.e. generation finished). * Used by: GoogleSlidesEditor (rendered while isGenerating is true). * Depends on: React only. */ 'use client'; import React, { useEffect, useRef, useState } from 'react'; const STAGES = [ 'Understanding your topic', 'Outlining the structure', 'Writing slide content', 'Designing the layout', 'Applying your theme', 'Finishing touches', ]; export default function GenerationProgress() { const [progress, setProgress] = useState(8); const progressRef = useRef(8); useEffect(() => { // Ease toward a ceiling so the bar always feels alive but never "completes" early. // The real completion is the component unmounting, which removes the overlay entirely. const id = window.setInterval(() => { const current = progressRef.current; const ceiling = 92; const next = Math.min(ceiling, current + Math.max(0.4, (ceiling - current) * 0.06)); progressRef.current = next; setProgress(next); }, 220); return () => window.clearInterval(id); }, []); const pct = Math.round(progress); const stageIndex = Math.min(STAGES.length - 1, Math.floor((progress / 100) * STAGES.length)); return (
This usually takes a few moments. Please don’t refresh the page.