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

81.81% Statements 9/11
91.66% Branches 22/24
77.77% Functions 7/9
81.81% Lines 9/11

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 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195                                2x         140x                                         2x                                                             20x                     20x             20x             20x                     20x                                                               20x                                                                                                          
import {
  AlertCircle,
  BookOpen,
  Bot,
  Check,
  FolderOpen,
  Hammer,
  Layers3,
  Loader2,
  Shield,
  Users,
  Zap,
} from "lucide-react";
import React from "react";
import { SectionCard } from "../primitives";
 
const SummaryRow: React.FC<{
  icon: React.ElementType;
  label: string;
  items: string[];
}> = ({ icon: Icon, label, items }) => (
  <div className="flex items-start gap-3">
    <div className="p-1.5 rounded-lg bg-gray-100 dark:bg-gray-700 shrink-0">
      <Icon className="size-3.5 text-gray-500 dark:text-gray-400" />
    </div>
    <div className="min-w-0">
      <div className="text-sm font-medium text-gray-700 dark:text-gray-300">
        {label}
      </div>
      {items.length > 0 ? (
        <div className="text-xs text-gray-500 dark:text-gray-400 mt-0.5">
          {items.join(" · ")}
        </div>
      ) : (
        <div className="text-xs text-gray-400 dark:text-gray-500 mt-0.5">
          None
        </div>
      )}
    </div>
  </div>
);
 
const ConfirmStep: React.FC<{
  agentName: string;
  newSkillNames: string[];
  newKnowledgeNames: string[];
  newWorkerNames: string[];
  attachedRepositoryNames: string[];
  newRepositoryNames: string[];
  attachedSkillsetNames: string[];
  newSkillsetNames: string[];
  attachedToolkitNames: string[];
  newToolkitNames: string[];
  newRuleNames: string[];
  error: string | null;
  creating: boolean;
  onCreate: () => void;
}> = ({
  agentName,
  newSkillNames,
  newKnowledgeNames,
  newWorkerNames,
  attachedRepositoryNames,
  newRepositoryNames,
  attachedSkillsetNames,
  newSkillsetNames,
  attachedToolkitNames,
  newToolkitNames,
  newRuleNames,
  error,
  creating,
  onCreate,
}) => (
  <div className="space-y-4">
    <SectionCard
      icon={Bot}
      title="Ready to create"
      description="Everything below is created together — if anything fails, nothing is created."
    >
      <SummaryRow icon={Bot} label={`Agent “${agentName}”`} items={[]} />
      {newSkillNames.length > 0 && (
        <SummaryRow
          icon={Zap}
          label={`New skills created (${newSkillNames.length})`}
          items={newSkillNames.map((name) => `${name} (new)`)}
        />
      )}
      {newWorkerNames.length > 0 && (
        <SummaryRow
          icon={Users}
          label={`Workers (${newWorkerNames.length})`}
          items={newWorkerNames.map((name) => `${name} (new)`)}
        />
      )}
      {newKnowledgeNames.length > 0 && (
        <SummaryRow
          icon={BookOpen}
          label={`New knowledge bases (${newKnowledgeNames.length})`}
          items={newKnowledgeNames.map((name) => `${name} (new, empty)`)}
        />
      )}
      {attachedRepositoryNames.length + newRepositoryNames.length > 0 && (
        <SummaryRow
          icon={FolderOpen}
          label={`Knowledge repositories (${
            attachedRepositoryNames.length + newRepositoryNames.length
          })`}
          items={[
            ...attachedRepositoryNames,
            ...newRepositoryNames.map((name) => `${name} (new)`),
          ]}
        />
      )}
      {attachedSkillsetNames.length + newSkillsetNames.length > 0 && (
        <SummaryRow
          icon={Layers3}
          label={`Skillsets (${
            attachedSkillsetNames.length + newSkillsetNames.length
          })`}
          items={[
            ...attachedSkillsetNames,
            ...newSkillsetNames.map((name) => `${name} (new)`),
          ]}
        />
      )}
      {attachedToolkitNames.length + newToolkitNames.length > 0 && (
        <SummaryRow
          icon={Hammer}
          label={`Toolkits (${
            attachedToolkitNames.length + newToolkitNames.length
          })`}
          items={[
            ...attachedToolkitNames,
            ...newToolkitNames.map((name) => `${name} (new)`),
          ]}
        />
      )}
      {newRuleNames.length > 0 && (
        <SummaryRow
          icon={Shield}
          label={`Governance rules (${newRuleNames.length})`}
          items={newRuleNames.map((name) => `${name} (new)`)}
        />
      )}
      {newKnowledgeNames.length > 0 && (
        <p className="text-xs text-gray-400 dark:text-gray-500">
          Remember to upload content to the new knowledge bases after creation.
        </p>
      )}
      {newSkillNames.length > 0 && (
        <p className="text-xs text-gray-400 dark:text-gray-500">
          A new skill only becomes usable by this agent once it's a member
          of a skillset attached to it — skillsets created above already do
          this for their members; bundle any others into a skillset
          afterward.
        </p>
      )}
      <p className="text-xs text-gray-400 dark:text-gray-500">
        Everything created here is tagged as AI-generated and records this
        agent as its origin.
      </p>
    </SectionCard>
 
    {error && (
      <div className="flex items-center gap-2 px-4 py-3 rounded-lg bg-red-50 dark:bg-red-950/40 border border-red-200 dark:border-red-800 text-red-700 dark:text-red-300 text-sm">
        <AlertCircle className="size-4 shrink-0" />
        {error}
      </div>
    )}
 
    <div className="flex justify-end">
      <button
        type="button"
        onClick={onCreate}
        disabled={creating}
        className="flex items-center gap-1.5 px-4 py-2 rounded-lg bg-gray-900 dark:bg-white text-white dark:text-gray-900 text-sm font-medium hover:opacity-80 disabled:opacity-50 transition-opacity"
      >
        {creating ? (
          <>
            <Loader2 className="size-4 animate-spin" />
            Creating…
          </>
        ) : (
          <>
            <Check className="size-4" />
            Create Agent
          </>
        )}
      </button>
    </div>
  </div>
);
 
export default ConfirmStep;