All files / src/apps/user/pages/agents/setup/steps GeneratingStep.tsx

80% Statements 8/10
100% Branches 0/0
60% Functions 3/5
87.5% Lines 7/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51      2x               2x     13x 13x 13x       13x     13x                                                      
import { Loader2, Sparkles } from "lucide-react";
import React, { useEffect, useState } from "react";
 
const PHASES = [
  "Analysing your problem…",
  "Drafting the system prompt…",
  "Matching skills and knowledge bases…",
  "Designing new skill workflows…",
  "Assembling the configuration…",
];
 
const GeneratingStep: React.FC<{ onCancel: () => void }> = ({ onCancel }) => {
  // Purely cosmetic pacing — the request is a single call; these phases give
  // the user a sense of progress during the 30-90s generation.
  const [phase, setPhase] = useState(0);
  useEffect(() => {
    const timer = setInterval(
      () => setPhase((p) => Math.min(p + 1, PHASES.length - 1)),
      6000,
    );
    return () => clearInterval(timer);
  }, []);
 
  return (
    <div className="rounded-xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 shadow-sm px-6 py-16 flex flex-col items-center text-center">
      <div className="relative mb-6">
        <div className="p-4 rounded-full bg-violet-100 dark:bg-violet-900/40">
          <Sparkles className="size-7 text-violet-600 dark:text-violet-400" />
        </div>
        <Loader2 className="absolute -bottom-1 -right-1 size-5 animate-spin text-gray-400 dark:text-gray-500" />
      </div>
      <p className="text-sm font-medium text-gray-700 dark:text-gray-300">
        {PHASES[phase]}
      </p>
      <p className="text-xs text-gray-400 dark:text-gray-500 mt-2 max-w-sm">
        The AI architect is designing your agent. This usually takes under a
        minute.
      </p>
      <button
        type="button"
        onClick={onCancel}
        className="mt-8 px-4 py-2 rounded-lg text-sm font-medium text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors"
      >
        Cancel
      </button>
    </div>
  );
};
 
export default GeneratingStep;