All files / src/apps/user/pages/agents/setup NewAgentChoice.tsx

75% Statements 6/8
100% Branches 8/8
60% Functions 3/5
75% Lines 6/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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116            1x                 6x                                                               18x                                           1x 3x   3x                                                                                      
import SubPage from "@/components/page/SubPage/SubPage";
import { APP_ROUTES } from "@/routes/const";
import { ArrowRight, PencilLine, Sparkles } from "lucide-react";
import React from "react";
import { useNavigate } from "react-router-dom";
 
const ChoiceCard: React.FC<{
  icon: React.ElementType;
  title: string;
  description: string;
  bullets: string[];
  cta: string;
  highlight?: boolean;
  onClick: () => void;
}> = ({ icon: Icon, title, description, bullets, cta, highlight, onClick }) => (
  <button
    type="button"
    onClick={onClick}
    className={`group flex flex-col text-left rounded-xl border p-6 transition-all hover:shadow-md ${
      highlight
        ? "border-violet-300 dark:border-violet-600 bg-violet-50/50 dark:bg-violet-900/10 hover:border-violet-400 dark:hover:border-violet-500"
        : "border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 hover:border-gray-300 dark:hover:border-gray-500"
    }`}
  >
    <div
      className={`p-2.5 rounded-lg w-fit mb-4 ${
        highlight
          ? "bg-violet-100 dark:bg-violet-900/40"
          : "bg-gray-100 dark:bg-gray-700"
      }`}
    >
      <Icon
        className={`size-5 ${
          highlight
            ? "text-violet-600 dark:text-violet-400"
            : "text-gray-600 dark:text-gray-300"
        }`}
      />
    </div>
    <h3 className="text-base font-semibold text-gray-800 dark:text-gray-200">
      {title}
    </h3>
    <p className="text-sm text-gray-500 dark:text-gray-400 mt-1.5">
      {description}
    </p>
    <ul className="mt-4 space-y-1.5 flex-1">
      {bullets.map((b) => (
        <li
          key={b}
          className="flex items-start gap-2 text-xs text-gray-500 dark:text-gray-400"
        >
          <span className="mt-1.5 size-1 rounded-full bg-gray-400 dark:bg-gray-500 shrink-0" />
          {b}
        </li>
      ))}
    </ul>
    <div
      className={`mt-5 flex items-center gap-1.5 text-sm font-medium ${
        highlight
          ? "text-violet-600 dark:text-violet-400"
          : "text-gray-700 dark:text-gray-300"
      }`}
    >
      {cta}
      <ArrowRight className="size-4 transition-transform group-hover:translate-x-0.5" />
    </div>
  </button>
);
 
const NewAgentChoice: React.FC = () => {
  const navigate = useNavigate();
 
  return (
    <SubPage title="New Agent">
      <div className="max-w-3xl">
        <p className="text-sm text-gray-500 dark:text-gray-400 mb-6">
          How would you like to set up your new agent?
        </p>
        <div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
          <ChoiceCard
            icon={Sparkles}
            title="Generate with AI"
            description="Describe your problem and let an AI architect design the full agent for you."
            bullets={[
              "Detailed system prompt written for your use case",
              "Relevant skills and knowledge bases selected or proposed",
              "Review and edit everything before creating",
            ]}
            cta="Start generating"
            highlight
            onClick={() =>
              void navigate(APP_ROUTES.USER.INFERENCE.AGENTS.new_generative)
            }
          />
          <ChoiceCard
            icon={PencilLine}
            title="Manual setup"
            description="Build the agent yourself with full control over every field."
            bullets={[
              "Write the system prompt from scratch",
              "Pick skills and knowledge bases by hand",
              "Best when you know exactly what you want",
            ]}
            cta="Set up manually"
            onClick={() =>
              void navigate(APP_ROUTES.USER.INFERENCE.AGENTS.new_manual)
            }
          />
        </div>
      </div>
    </SubPage>
  );
};
 
export default NewAgentChoice;