mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-03 08:53:36 +00:00
feat: enhanced ai profiles view
- Refactored profiles view into modular components for better maintainability - Fixed input/textarea borders showing consistently when not focused (border-input -> border-border) - Added animated hover effects on profile cards (border color and icon animations) - Removed redundant Create Profile button, made empty state interactive - Added confirmation dialog for profile deletion to prevent accidental removal - Improved dialog scrolling behavior with max-height constraints - Added ARIA labels to profile card buttons for better accessibility - Created reusable DeleteConfirmDialog component
This commit is contained in:
@@ -15,7 +15,7 @@ function Input({ className, type, startAddon, endAddon, ...props }: InputProps)
|
|||||||
type={type}
|
type={type}
|
||||||
data-slot="input"
|
data-slot="input"
|
||||||
className={cn(
|
className={cn(
|
||||||
"file:text-foreground placeholder:text-muted-foreground/60 selection:bg-primary selection:text-primary-foreground bg-input border-input h-9 w-full min-w-0 rounded-md border px-3 py-1 text-base shadow-xs outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
"file:text-foreground placeholder:text-muted-foreground/60 selection:bg-primary selection:text-primary-foreground bg-input border-border h-9 w-full min-w-0 rounded-md border px-3 py-1 text-base shadow-xs outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
||||||
// Inner shadow for depth
|
// Inner shadow for depth
|
||||||
"shadow-[inset_0_1px_2px_rgba(0,0,0,0.05)]",
|
"shadow-[inset_0_1px_2px_rgba(0,0,0,0.05)]",
|
||||||
// Animated focus ring
|
// Animated focus ring
|
||||||
@@ -39,7 +39,7 @@ function Input({ className, type, startAddon, endAddon, ...props }: InputProps)
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex items-center h-9 w-full rounded-md border border-input bg-input shadow-xs",
|
"flex items-center h-9 w-full rounded-md border border-border bg-input shadow-xs",
|
||||||
"shadow-[inset_0_1px_2px_rgba(0,0,0,0.05)]",
|
"shadow-[inset_0_1px_2px_rgba(0,0,0,0.05)]",
|
||||||
"transition-[box-shadow,border-color] duration-200 ease-out",
|
"transition-[box-shadow,border-color] duration-200 ease-out",
|
||||||
"focus-within:border-ring focus-within:ring-ring/50 focus-within:ring-[3px]",
|
"focus-within:border-ring focus-within:ring-ring/50 focus-within:ring-[3px]",
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
|
|||||||
<textarea
|
<textarea
|
||||||
data-slot="textarea"
|
data-slot="textarea"
|
||||||
className={cn(
|
className={cn(
|
||||||
"placeholder:text-muted-foreground/60 selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input min-h-[80px] w-full min-w-0 rounded-md border bg-transparent px-3 py-2 text-base outline-none disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm resize-none",
|
"placeholder:text-muted-foreground/60 selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-border min-h-[80px] w-full min-w-0 rounded-md border bg-transparent px-3 py-2 text-base outline-none disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm resize-none",
|
||||||
// Inner shadow for depth
|
// Inner shadow for depth
|
||||||
"shadow-[inset_0_1px_2px_rgba(0,0,0,0.05)]",
|
"shadow-[inset_0_1px_2px_rgba(0,0,0,0.05)]",
|
||||||
// Animated focus ring
|
// Animated focus ring
|
||||||
|
|||||||
@@ -1,19 +1,10 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useState, useMemo, useCallback, useEffect } from "react";
|
import { useState, useMemo, useCallback } from "react";
|
||||||
import {
|
import {
|
||||||
useAppStore,
|
useAppStore,
|
||||||
AIProfile,
|
AIProfile,
|
||||||
AgentModel,
|
|
||||||
ThinkingLevel,
|
|
||||||
ModelProvider,
|
|
||||||
} from "@/store/app-store";
|
} from "@/store/app-store";
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import { HotkeyButton } from "@/components/ui/hotkey-button";
|
|
||||||
import { Input } from "@/components/ui/input";
|
|
||||||
import { Label } from "@/components/ui/label";
|
|
||||||
import { Textarea } from "@/components/ui/textarea";
|
|
||||||
import { cn, modelSupportsThinking } from "@/lib/utils";
|
|
||||||
import {
|
import {
|
||||||
useKeyboardShortcuts,
|
useKeyboardShortcuts,
|
||||||
useKeyboardShortcutsConfig,
|
useKeyboardShortcutsConfig,
|
||||||
@@ -23,27 +14,12 @@ import {
|
|||||||
Dialog,
|
Dialog,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
DialogDescription,
|
DialogDescription,
|
||||||
DialogFooter,
|
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@/components/ui/dialog";
|
} from "@/components/ui/dialog";
|
||||||
import {
|
import { Sparkles } from "lucide-react";
|
||||||
UserCircle,
|
|
||||||
Plus,
|
|
||||||
Pencil,
|
|
||||||
Trash2,
|
|
||||||
Brain,
|
|
||||||
Zap,
|
|
||||||
Scale,
|
|
||||||
Cpu,
|
|
||||||
Rocket,
|
|
||||||
Sparkles,
|
|
||||||
GripVertical,
|
|
||||||
Lock,
|
|
||||||
Check,
|
|
||||||
RefreshCw,
|
|
||||||
} from "lucide-react";
|
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
import { DeleteConfirmDialog } from "@/components/ui/delete-confirm-dialog";
|
||||||
import {
|
import {
|
||||||
DndContext,
|
DndContext,
|
||||||
DragEndEvent,
|
DragEndEvent,
|
||||||
@@ -54,353 +30,13 @@ import {
|
|||||||
} from "@dnd-kit/core";
|
} from "@dnd-kit/core";
|
||||||
import {
|
import {
|
||||||
SortableContext,
|
SortableContext,
|
||||||
useSortable,
|
|
||||||
verticalListSortingStrategy,
|
verticalListSortingStrategy,
|
||||||
} from "@dnd-kit/sortable";
|
} from "@dnd-kit/sortable";
|
||||||
import { CSS } from "@dnd-kit/utilities";
|
import {
|
||||||
|
SortableProfileCard,
|
||||||
// Icon mapping for profiles
|
ProfileForm,
|
||||||
const PROFILE_ICONS: Record<
|
ProfilesHeader,
|
||||||
string,
|
} from "./profiles-view/components";
|
||||||
React.ComponentType<{ className?: string }>
|
|
||||||
> = {
|
|
||||||
Brain,
|
|
||||||
Zap,
|
|
||||||
Scale,
|
|
||||||
Cpu,
|
|
||||||
Rocket,
|
|
||||||
Sparkles,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Available icons for selection
|
|
||||||
const ICON_OPTIONS = [
|
|
||||||
{ name: "Brain", icon: Brain },
|
|
||||||
{ name: "Zap", icon: Zap },
|
|
||||||
{ name: "Scale", icon: Scale },
|
|
||||||
{ name: "Cpu", icon: Cpu },
|
|
||||||
{ name: "Rocket", icon: Rocket },
|
|
||||||
{ name: "Sparkles", icon: Sparkles },
|
|
||||||
];
|
|
||||||
|
|
||||||
// Model options for the form
|
|
||||||
const CLAUDE_MODELS: { id: AgentModel; label: string }[] = [
|
|
||||||
{ id: "haiku", label: "Claude Haiku" },
|
|
||||||
{ id: "sonnet", label: "Claude Sonnet" },
|
|
||||||
{ id: "opus", label: "Claude Opus" },
|
|
||||||
];
|
|
||||||
|
|
||||||
const THINKING_LEVELS: { id: ThinkingLevel; label: string }[] = [
|
|
||||||
{ id: "none", label: "None" },
|
|
||||||
{ id: "low", label: "Low" },
|
|
||||||
{ id: "medium", label: "Medium" },
|
|
||||||
{ id: "high", label: "High" },
|
|
||||||
{ id: "ultrathink", label: "Ultrathink" },
|
|
||||||
];
|
|
||||||
|
|
||||||
// Helper to determine provider from model
|
|
||||||
function getProviderFromModel(model: AgentModel): ModelProvider {
|
|
||||||
return "claude";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sortable Profile Card Component
|
|
||||||
function SortableProfileCard({
|
|
||||||
profile,
|
|
||||||
onEdit,
|
|
||||||
onDelete,
|
|
||||||
}: {
|
|
||||||
profile: AIProfile;
|
|
||||||
onEdit: () => void;
|
|
||||||
onDelete: () => void;
|
|
||||||
}) {
|
|
||||||
const {
|
|
||||||
attributes,
|
|
||||||
listeners,
|
|
||||||
setNodeRef,
|
|
||||||
transform,
|
|
||||||
transition,
|
|
||||||
isDragging,
|
|
||||||
} = useSortable({ id: profile.id });
|
|
||||||
|
|
||||||
const style = {
|
|
||||||
transform: CSS.Transform.toString(transform),
|
|
||||||
transition,
|
|
||||||
opacity: isDragging ? 0.5 : 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
const IconComponent = profile.icon ? PROFILE_ICONS[profile.icon] : Brain;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
ref={setNodeRef}
|
|
||||||
style={style}
|
|
||||||
className={cn(
|
|
||||||
"group relative flex items-start gap-4 p-4 rounded-xl border bg-card transition-all",
|
|
||||||
isDragging && "shadow-lg",
|
|
||||||
profile.isBuiltIn
|
|
||||||
? "border-border/50"
|
|
||||||
: "border-border hover:border-primary/50 hover:shadow-sm"
|
|
||||||
)}
|
|
||||||
data-testid={`profile-card-${profile.id}`}
|
|
||||||
>
|
|
||||||
{/* Drag Handle */}
|
|
||||||
<button
|
|
||||||
{...attributes}
|
|
||||||
{...listeners}
|
|
||||||
className="p-1 rounded hover:bg-accent cursor-grab active:cursor-grabbing flex-shrink-0 mt-1"
|
|
||||||
data-testid={`profile-drag-handle-${profile.id}`}
|
|
||||||
onClick={(e) => e.stopPropagation()}
|
|
||||||
>
|
|
||||||
<GripVertical className="h-4 w-4 text-muted-foreground" />
|
|
||||||
</button>
|
|
||||||
|
|
||||||
{/* Icon */}
|
|
||||||
<div
|
|
||||||
className="flex-shrink-0 w-10 h-10 rounded-lg flex items-center justify-center bg-primary/10"
|
|
||||||
>
|
|
||||||
{IconComponent && (
|
|
||||||
<IconComponent className="w-5 h-5 text-primary" />
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Content */}
|
|
||||||
<div className="flex-1 min-w-0">
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<h3 className="font-semibold text-foreground">{profile.name}</h3>
|
|
||||||
{profile.isBuiltIn && (
|
|
||||||
<span className="flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded-full bg-muted text-muted-foreground">
|
|
||||||
<Lock className="w-2.5 h-2.5" />
|
|
||||||
Built-in
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<p className="text-sm text-muted-foreground mt-0.5 line-clamp-2">
|
|
||||||
{profile.description}
|
|
||||||
</p>
|
|
||||||
<div className="flex items-center gap-2 mt-2 flex-wrap">
|
|
||||||
<span
|
|
||||||
className="text-xs px-2 py-0.5 rounded-full border border-primary/30 text-primary bg-primary/10"
|
|
||||||
>
|
|
||||||
{profile.model}
|
|
||||||
</span>
|
|
||||||
{profile.thinkingLevel !== "none" && (
|
|
||||||
<span className="text-xs px-2 py-0.5 rounded-full border border-amber-500/30 text-amber-600 dark:text-amber-400 bg-amber-500/10">
|
|
||||||
{profile.thinkingLevel}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Actions */}
|
|
||||||
{!profile.isBuiltIn && (
|
|
||||||
<div className="flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity">
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
onClick={onEdit}
|
|
||||||
className="h-8 w-8 p-0"
|
|
||||||
data-testid={`edit-profile-${profile.id}`}
|
|
||||||
>
|
|
||||||
<Pencil className="w-4 h-4" />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
onClick={onDelete}
|
|
||||||
className="h-8 w-8 p-0 text-destructive hover:text-destructive"
|
|
||||||
data-testid={`delete-profile-${profile.id}`}
|
|
||||||
>
|
|
||||||
<Trash2 className="w-4 h-4" />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Profile Form Component
|
|
||||||
function ProfileForm({
|
|
||||||
profile,
|
|
||||||
onSave,
|
|
||||||
onCancel,
|
|
||||||
isEditing,
|
|
||||||
hotkeyActive,
|
|
||||||
}: {
|
|
||||||
profile: Partial<AIProfile>;
|
|
||||||
onSave: (profile: Omit<AIProfile, "id">) => void;
|
|
||||||
onCancel: () => void;
|
|
||||||
isEditing: boolean;
|
|
||||||
hotkeyActive: boolean;
|
|
||||||
}) {
|
|
||||||
const [formData, setFormData] = useState({
|
|
||||||
name: profile.name || "",
|
|
||||||
description: profile.description || "",
|
|
||||||
model: profile.model || ("opus" as AgentModel),
|
|
||||||
thinkingLevel: profile.thinkingLevel || ("none" as ThinkingLevel),
|
|
||||||
icon: profile.icon || "Brain",
|
|
||||||
});
|
|
||||||
|
|
||||||
const provider = getProviderFromModel(formData.model);
|
|
||||||
const supportsThinking = modelSupportsThinking(formData.model);
|
|
||||||
|
|
||||||
const handleModelChange = (model: AgentModel) => {
|
|
||||||
setFormData({
|
|
||||||
...formData,
|
|
||||||
model,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSubmit = () => {
|
|
||||||
if (!formData.name.trim()) {
|
|
||||||
toast.error("Please enter a profile name");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
onSave({
|
|
||||||
name: formData.name.trim(),
|
|
||||||
description: formData.description.trim(),
|
|
||||||
model: formData.model,
|
|
||||||
thinkingLevel: supportsThinking ? formData.thinkingLevel : "none",
|
|
||||||
provider,
|
|
||||||
isBuiltIn: false,
|
|
||||||
icon: formData.icon,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="space-y-4">
|
|
||||||
{/* Name */}
|
|
||||||
<div className="space-y-2">
|
|
||||||
<Label htmlFor="profile-name">Profile Name</Label>
|
|
||||||
<Input
|
|
||||||
id="profile-name"
|
|
||||||
value={formData.name}
|
|
||||||
onChange={(e) => setFormData({ ...formData, name: e.target.value })}
|
|
||||||
placeholder="e.g., Heavy Task, Quick Fix"
|
|
||||||
data-testid="profile-name-input"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Description */}
|
|
||||||
<div className="space-y-2">
|
|
||||||
<Label htmlFor="profile-description">Description</Label>
|
|
||||||
<Textarea
|
|
||||||
id="profile-description"
|
|
||||||
value={formData.description}
|
|
||||||
onChange={(e) =>
|
|
||||||
setFormData({ ...formData, description: e.target.value })
|
|
||||||
}
|
|
||||||
placeholder="Describe when to use this profile..."
|
|
||||||
rows={2}
|
|
||||||
data-testid="profile-description-input"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Icon Selection */}
|
|
||||||
<div className="space-y-2">
|
|
||||||
<Label>Icon</Label>
|
|
||||||
<div className="flex gap-2 flex-wrap">
|
|
||||||
{ICON_OPTIONS.map(({ name, icon: Icon }) => (
|
|
||||||
<button
|
|
||||||
key={name}
|
|
||||||
type="button"
|
|
||||||
onClick={() => setFormData({ ...formData, icon: name })}
|
|
||||||
className={cn(
|
|
||||||
"w-10 h-10 rounded-lg flex items-center justify-center border transition-colors",
|
|
||||||
formData.icon === name
|
|
||||||
? "bg-primary text-primary-foreground border-primary"
|
|
||||||
: "bg-background hover:bg-accent border-input"
|
|
||||||
)}
|
|
||||||
data-testid={`icon-select-${name}`}
|
|
||||||
>
|
|
||||||
<Icon className="w-5 h-5" />
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Model Selection */}
|
|
||||||
<div className="space-y-2">
|
|
||||||
<Label className="flex items-center gap-2">
|
|
||||||
<Brain className="w-4 h-4 text-primary" />
|
|
||||||
Model
|
|
||||||
</Label>
|
|
||||||
<div className="flex gap-2 flex-wrap">
|
|
||||||
{CLAUDE_MODELS.map(({ id, label }) => (
|
|
||||||
<button
|
|
||||||
key={id}
|
|
||||||
type="button"
|
|
||||||
onClick={() => handleModelChange(id)}
|
|
||||||
className={cn(
|
|
||||||
"flex-1 min-w-[100px] px-3 py-2 rounded-md border text-sm font-medium transition-colors",
|
|
||||||
formData.model === id
|
|
||||||
? "bg-primary text-primary-foreground border-primary"
|
|
||||||
: "bg-background hover:bg-accent border-input"
|
|
||||||
)}
|
|
||||||
data-testid={`model-select-${id}`}
|
|
||||||
>
|
|
||||||
{label.replace("Claude ", "")}
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Thinking Level */}
|
|
||||||
{supportsThinking && (
|
|
||||||
<div className="space-y-2">
|
|
||||||
<Label className="flex items-center gap-2">
|
|
||||||
<Brain className="w-4 h-4 text-amber-500" />
|
|
||||||
Thinking Level
|
|
||||||
</Label>
|
|
||||||
<div className="flex gap-2 flex-wrap">
|
|
||||||
{THINKING_LEVELS.map(({ id, label }) => (
|
|
||||||
<button
|
|
||||||
key={id}
|
|
||||||
type="button"
|
|
||||||
onClick={() => {
|
|
||||||
setFormData({ ...formData, thinkingLevel: id });
|
|
||||||
if (id === "ultrathink") {
|
|
||||||
toast.warning("Ultrathink uses extensive reasoning", {
|
|
||||||
description:
|
|
||||||
"Best for complex architecture, migrations, or deep debugging (~$0.48/task).",
|
|
||||||
duration: 4000,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
className={cn(
|
|
||||||
"flex-1 min-w-[70px] px-3 py-2 rounded-md border text-sm font-medium transition-colors",
|
|
||||||
formData.thinkingLevel === id
|
|
||||||
? "bg-amber-500 text-white border-amber-400"
|
|
||||||
: "bg-background hover:bg-accent border-input"
|
|
||||||
)}
|
|
||||||
data-testid={`thinking-select-${id}`}
|
|
||||||
>
|
|
||||||
{label}
|
|
||||||
</button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
<p className="text-xs text-muted-foreground">
|
|
||||||
Higher levels give more time to reason through complex problems.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Actions */}
|
|
||||||
<DialogFooter className="pt-4">
|
|
||||||
<Button variant="ghost" onClick={onCancel}>
|
|
||||||
Cancel
|
|
||||||
</Button>
|
|
||||||
<HotkeyButton
|
|
||||||
onClick={handleSubmit}
|
|
||||||
hotkey={{ key: "Enter", cmdCtrl: true }}
|
|
||||||
hotkeyActive={hotkeyActive}
|
|
||||||
data-testid="save-profile-button"
|
|
||||||
>
|
|
||||||
{isEditing ? "Save Changes" : "Create Profile"}
|
|
||||||
</HotkeyButton>
|
|
||||||
</DialogFooter>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function ProfilesView() {
|
export function ProfilesView() {
|
||||||
const {
|
const {
|
||||||
@@ -415,6 +51,7 @@ export function ProfilesView() {
|
|||||||
|
|
||||||
const [showAddDialog, setShowAddDialog] = useState(false);
|
const [showAddDialog, setShowAddDialog] = useState(false);
|
||||||
const [editingProfile, setEditingProfile] = useState<AIProfile | null>(null);
|
const [editingProfile, setEditingProfile] = useState<AIProfile | null>(null);
|
||||||
|
const [profileToDelete, setProfileToDelete] = useState<AIProfile | null>(null);
|
||||||
|
|
||||||
// Sensors for drag-and-drop
|
// Sensors for drag-and-drop
|
||||||
const sensors = useSensors(
|
const sensors = useSensors(
|
||||||
@@ -469,13 +106,14 @@ export function ProfilesView() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDeleteProfile = (profile: AIProfile) => {
|
const confirmDeleteProfile = () => {
|
||||||
if (profile.isBuiltIn) return;
|
if (!profileToDelete) return;
|
||||||
|
|
||||||
removeAIProfile(profile.id);
|
removeAIProfile(profileToDelete.id);
|
||||||
toast.success("Profile deleted", {
|
toast.success("Profile deleted", {
|
||||||
description: `Deleted "${profile.name}" profile`,
|
description: `Deleted "${profileToDelete.name}" profile`,
|
||||||
});
|
});
|
||||||
|
setProfileToDelete(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleResetProfiles = () => {
|
const handleResetProfiles = () => {
|
||||||
@@ -508,45 +146,11 @@ export function ProfilesView() {
|
|||||||
data-testid="profiles-view"
|
data-testid="profiles-view"
|
||||||
>
|
>
|
||||||
{/* Header Section */}
|
{/* Header Section */}
|
||||||
<div className="shrink-0 border-b border-border bg-glass backdrop-blur-md">
|
<ProfilesHeader
|
||||||
<div className="px-8 py-6">
|
onResetProfiles={handleResetProfiles}
|
||||||
<div className="flex items-center justify-between">
|
onAddProfile={() => setShowAddDialog(true)}
|
||||||
<div className="flex items-center gap-3">
|
addProfileHotkey={shortcuts.addProfile}
|
||||||
<div className="w-10 h-10 rounded-xl bg-linear-to-br from-brand-500 to-brand-600 shadow-lg shadow-brand-500/20 flex items-center justify-center">
|
/>
|
||||||
<UserCircle className="w-5 h-5 text-primary-foreground" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<h1 className="text-2xl font-bold text-foreground">
|
|
||||||
AI Profiles
|
|
||||||
</h1>
|
|
||||||
<p className="text-sm text-muted-foreground">
|
|
||||||
Create and manage model configuration presets
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<Button
|
|
||||||
variant="outline"
|
|
||||||
onClick={handleResetProfiles}
|
|
||||||
data-testid="refresh-profiles-button"
|
|
||||||
className="gap-2"
|
|
||||||
>
|
|
||||||
<RefreshCw className="w-4 h-4" />
|
|
||||||
Refresh Defaults
|
|
||||||
</Button>
|
|
||||||
<HotkeyButton
|
|
||||||
onClick={() => setShowAddDialog(true)}
|
|
||||||
hotkey={shortcuts.addProfile}
|
|
||||||
hotkeyActive={false}
|
|
||||||
data-testid="add-profile-button"
|
|
||||||
>
|
|
||||||
<Plus className="w-4 h-4 mr-2" />
|
|
||||||
New Profile
|
|
||||||
</HotkeyButton>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Content */}
|
{/* Content */}
|
||||||
<div className="flex-1 overflow-y-auto p-8">
|
<div className="flex-1 overflow-y-auto p-8">
|
||||||
@@ -562,19 +166,14 @@ export function ProfilesView() {
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{customProfiles.length === 0 ? (
|
{customProfiles.length === 0 ? (
|
||||||
<div className="rounded-xl border border-dashed border-border p-8 text-center">
|
<div
|
||||||
<Sparkles className="w-10 h-10 text-muted-foreground mx-auto mb-3 opacity-50" />
|
className="group rounded-xl border border-dashed border-border p-8 text-center transition-all duration-300 hover:border-primary hover:bg-primary/5 cursor-pointer"
|
||||||
<p className="text-muted-foreground">
|
onClick={() => setShowAddDialog(true)}
|
||||||
|
>
|
||||||
|
<Sparkles className="w-10 h-10 text-muted-foreground mx-auto mb-3 opacity-50 transition-all duration-300 group-hover:text-primary group-hover:opacity-100 group-hover:scale-110 group-hover:rotate-12" />
|
||||||
|
<p className="text-muted-foreground transition-colors duration-300 group-hover:text-foreground">
|
||||||
No custom profiles yet. Create one to get started!
|
No custom profiles yet. Create one to get started!
|
||||||
</p>
|
</p>
|
||||||
<Button
|
|
||||||
variant="outline"
|
|
||||||
className="mt-4"
|
|
||||||
onClick={() => setShowAddDialog(true)}
|
|
||||||
>
|
|
||||||
<Plus className="w-4 h-4 mr-2" />
|
|
||||||
Create Profile
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<DndContext
|
<DndContext
|
||||||
@@ -592,7 +191,7 @@ export function ProfilesView() {
|
|||||||
key={profile.id}
|
key={profile.id}
|
||||||
profile={profile}
|
profile={profile}
|
||||||
onEdit={() => setEditingProfile(profile)}
|
onEdit={() => setEditingProfile(profile)}
|
||||||
onDelete={() => handleDeleteProfile(profile)}
|
onDelete={() => setProfileToDelete(profile)}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@@ -642,8 +241,8 @@ export function ProfilesView() {
|
|||||||
|
|
||||||
{/* Add Profile Dialog */}
|
{/* Add Profile Dialog */}
|
||||||
<Dialog open={showAddDialog} onOpenChange={setShowAddDialog}>
|
<Dialog open={showAddDialog} onOpenChange={setShowAddDialog}>
|
||||||
<DialogContent data-testid="add-profile-dialog">
|
<DialogContent data-testid="add-profile-dialog" className="flex flex-col max-h-[calc(100vh-4rem)]">
|
||||||
<DialogHeader>
|
<DialogHeader className="shrink-0">
|
||||||
<DialogTitle>Create New Profile</DialogTitle>
|
<DialogTitle>Create New Profile</DialogTitle>
|
||||||
<DialogDescription>
|
<DialogDescription>
|
||||||
Define a reusable model configuration preset.
|
Define a reusable model configuration preset.
|
||||||
@@ -664,8 +263,8 @@ export function ProfilesView() {
|
|||||||
open={!!editingProfile}
|
open={!!editingProfile}
|
||||||
onOpenChange={() => setEditingProfile(null)}
|
onOpenChange={() => setEditingProfile(null)}
|
||||||
>
|
>
|
||||||
<DialogContent data-testid="edit-profile-dialog">
|
<DialogContent data-testid="edit-profile-dialog" className="flex flex-col max-h-[calc(100vh-4rem)]">
|
||||||
<DialogHeader>
|
<DialogHeader className="shrink-0">
|
||||||
<DialogTitle>Edit Profile</DialogTitle>
|
<DialogTitle>Edit Profile</DialogTitle>
|
||||||
<DialogDescription>Modify your profile settings.</DialogDescription>
|
<DialogDescription>Modify your profile settings.</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
@@ -680,6 +279,22 @@ export function ProfilesView() {
|
|||||||
)}
|
)}
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
||||||
|
{/* Delete Confirmation Dialog */}
|
||||||
|
<DeleteConfirmDialog
|
||||||
|
open={!!profileToDelete}
|
||||||
|
onOpenChange={(open) => !open && setProfileToDelete(null)}
|
||||||
|
onConfirm={confirmDeleteProfile}
|
||||||
|
title="Delete Profile"
|
||||||
|
description={
|
||||||
|
profileToDelete
|
||||||
|
? `Are you sure you want to delete "${profileToDelete.name}"? This action cannot be undone.`
|
||||||
|
: ""
|
||||||
|
}
|
||||||
|
confirmText="Delete Profile"
|
||||||
|
testId="delete-profile-confirm-dialog"
|
||||||
|
confirmTestId="confirm-delete-profile-button"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export { SortableProfileCard } from "./sortable-profile-card";
|
||||||
|
export { ProfileForm } from "./profile-form";
|
||||||
|
export { ProfilesHeader } from "./profiles-header";
|
||||||
@@ -0,0 +1,204 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useState } from "react";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { HotkeyButton } from "@/components/ui/hotkey-button";
|
||||||
|
import { Input } from "@/components/ui/input";
|
||||||
|
import { Label } from "@/components/ui/label";
|
||||||
|
import { Textarea } from "@/components/ui/textarea";
|
||||||
|
import { cn, modelSupportsThinking } from "@/lib/utils";
|
||||||
|
import { DialogFooter } from "@/components/ui/dialog";
|
||||||
|
import { Brain } from "lucide-react";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
import type { AIProfile, AgentModel, ThinkingLevel } from "@/store/app-store";
|
||||||
|
import { CLAUDE_MODELS, THINKING_LEVELS, ICON_OPTIONS } from "../constants";
|
||||||
|
import { getProviderFromModel } from "../utils";
|
||||||
|
|
||||||
|
interface ProfileFormProps {
|
||||||
|
profile: Partial<AIProfile>;
|
||||||
|
onSave: (profile: Omit<AIProfile, "id">) => void;
|
||||||
|
onCancel: () => void;
|
||||||
|
isEditing: boolean;
|
||||||
|
hotkeyActive: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ProfileForm({
|
||||||
|
profile,
|
||||||
|
onSave,
|
||||||
|
onCancel,
|
||||||
|
isEditing,
|
||||||
|
hotkeyActive,
|
||||||
|
}: ProfileFormProps) {
|
||||||
|
const [formData, setFormData] = useState({
|
||||||
|
name: profile.name || "",
|
||||||
|
description: profile.description || "",
|
||||||
|
model: profile.model || ("opus" as AgentModel),
|
||||||
|
thinkingLevel: profile.thinkingLevel || ("none" as ThinkingLevel),
|
||||||
|
icon: profile.icon || "Brain",
|
||||||
|
});
|
||||||
|
|
||||||
|
const provider = getProviderFromModel(formData.model);
|
||||||
|
const supportsThinking = modelSupportsThinking(formData.model);
|
||||||
|
|
||||||
|
const handleModelChange = (model: AgentModel) => {
|
||||||
|
setFormData({
|
||||||
|
...formData,
|
||||||
|
model,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSubmit = () => {
|
||||||
|
if (!formData.name.trim()) {
|
||||||
|
toast.error("Please enter a profile name");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
onSave({
|
||||||
|
name: formData.name.trim(),
|
||||||
|
description: formData.description.trim(),
|
||||||
|
model: formData.model,
|
||||||
|
thinkingLevel: supportsThinking ? formData.thinkingLevel : "none",
|
||||||
|
provider,
|
||||||
|
isBuiltIn: false,
|
||||||
|
icon: formData.icon,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="overflow-y-auto flex-1 min-h-0 space-y-4 pr-3 -mr-3 pl-1">
|
||||||
|
{/* Name */}
|
||||||
|
<div className="mt-2 space-y-2">
|
||||||
|
<Label htmlFor="profile-name">Profile Name</Label>
|
||||||
|
<Input
|
||||||
|
id="profile-name"
|
||||||
|
value={formData.name}
|
||||||
|
onChange={(e) => setFormData({ ...formData, name: e.target.value })}
|
||||||
|
placeholder="e.g., Heavy Task, Quick Fix"
|
||||||
|
data-testid="profile-name-input"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Description */}
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label htmlFor="profile-description">Description</Label>
|
||||||
|
<Textarea
|
||||||
|
id="profile-description"
|
||||||
|
value={formData.description}
|
||||||
|
onChange={(e) =>
|
||||||
|
setFormData({ ...formData, description: e.target.value })
|
||||||
|
}
|
||||||
|
placeholder="Describe when to use this profile..."
|
||||||
|
rows={2}
|
||||||
|
data-testid="profile-description-input"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Icon Selection */}
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label>Icon</Label>
|
||||||
|
<div className="flex gap-2 flex-wrap">
|
||||||
|
{ICON_OPTIONS.map(({ name, icon: Icon }) => (
|
||||||
|
<button
|
||||||
|
key={name}
|
||||||
|
type="button"
|
||||||
|
onClick={() => setFormData({ ...formData, icon: name })}
|
||||||
|
className={cn(
|
||||||
|
"w-10 h-10 rounded-lg flex items-center justify-center border transition-colors",
|
||||||
|
formData.icon === name
|
||||||
|
? "bg-primary text-primary-foreground border-primary"
|
||||||
|
: "bg-background hover:bg-accent border-border"
|
||||||
|
)}
|
||||||
|
data-testid={`icon-select-${name}`}
|
||||||
|
>
|
||||||
|
<Icon className="w-5 h-5" />
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Model Selection */}
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label className="flex items-center gap-2">
|
||||||
|
<Brain className="w-4 h-4 text-primary" />
|
||||||
|
Model
|
||||||
|
</Label>
|
||||||
|
<div className="flex gap-2 flex-wrap">
|
||||||
|
{CLAUDE_MODELS.map(({ id, label }) => (
|
||||||
|
<button
|
||||||
|
key={id}
|
||||||
|
type="button"
|
||||||
|
onClick={() => handleModelChange(id)}
|
||||||
|
className={cn(
|
||||||
|
"flex-1 min-w-[100px] px-3 py-2 rounded-md border text-sm font-medium transition-colors",
|
||||||
|
formData.model === id
|
||||||
|
? "bg-primary text-primary-foreground border-primary"
|
||||||
|
: "bg-background hover:bg-accent border-border"
|
||||||
|
)}
|
||||||
|
data-testid={`model-select-${id}`}
|
||||||
|
>
|
||||||
|
{label.replace("Claude ", "")}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Thinking Level */}
|
||||||
|
{supportsThinking && (
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label className="flex items-center gap-2">
|
||||||
|
<Brain className="w-4 h-4 text-amber-500" />
|
||||||
|
Thinking Level
|
||||||
|
</Label>
|
||||||
|
<div className="flex gap-2 flex-wrap">
|
||||||
|
{THINKING_LEVELS.map(({ id, label }) => (
|
||||||
|
<button
|
||||||
|
key={id}
|
||||||
|
type="button"
|
||||||
|
onClick={() => {
|
||||||
|
setFormData({ ...formData, thinkingLevel: id });
|
||||||
|
if (id === "ultrathink") {
|
||||||
|
toast.warning("Ultrathink uses extensive reasoning", {
|
||||||
|
description:
|
||||||
|
"Best for complex architecture, migrations, or deep debugging (~$0.48/task).",
|
||||||
|
duration: 4000,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
className={cn(
|
||||||
|
"flex-1 min-w-[70px] px-3 py-2 rounded-md border text-sm font-medium transition-colors",
|
||||||
|
formData.thinkingLevel === id
|
||||||
|
? "bg-amber-500 text-white border-amber-400"
|
||||||
|
: "bg-background hover:bg-accent border-border"
|
||||||
|
)}
|
||||||
|
data-testid={`thinking-select-${id}`}
|
||||||
|
>
|
||||||
|
{label}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<p className="text-xs text-muted-foreground">
|
||||||
|
Higher levels give more time to reason through complex problems.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Actions */}
|
||||||
|
<DialogFooter className="pt-4 border-t border-border mt-4 shrink-0">
|
||||||
|
<Button variant="ghost" onClick={onCancel}>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
<HotkeyButton
|
||||||
|
onClick={handleSubmit}
|
||||||
|
hotkey={{ key: "Enter", cmdCtrl: true }}
|
||||||
|
hotkeyActive={hotkeyActive}
|
||||||
|
data-testid="save-profile-button"
|
||||||
|
>
|
||||||
|
{isEditing ? "Save Changes" : "Create Profile"}
|
||||||
|
</HotkeyButton>
|
||||||
|
</DialogFooter>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { HotkeyButton } from "@/components/ui/hotkey-button";
|
||||||
|
import { UserCircle, Plus, RefreshCw } from "lucide-react";
|
||||||
|
|
||||||
|
interface ProfilesHeaderProps {
|
||||||
|
onResetProfiles: () => void;
|
||||||
|
onAddProfile: () => void;
|
||||||
|
addProfileHotkey: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ProfilesHeader({
|
||||||
|
onResetProfiles,
|
||||||
|
onAddProfile,
|
||||||
|
addProfileHotkey,
|
||||||
|
}: ProfilesHeaderProps) {
|
||||||
|
return (
|
||||||
|
<div className="shrink-0 border-b border-border bg-glass backdrop-blur-md">
|
||||||
|
<div className="px-8 py-6">
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<div className="w-10 h-10 rounded-xl bg-linear-to-br from-brand-500 to-brand-600 shadow-lg shadow-brand-500/20 flex items-center justify-center">
|
||||||
|
<UserCircle className="w-5 h-5 text-primary-foreground" />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h1 className="text-2xl font-bold text-foreground">
|
||||||
|
AI Profiles
|
||||||
|
</h1>
|
||||||
|
<p className="text-sm text-muted-foreground">
|
||||||
|
Create and manage model configuration presets
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
onClick={onResetProfiles}
|
||||||
|
data-testid="refresh-profiles-button"
|
||||||
|
className="gap-2"
|
||||||
|
>
|
||||||
|
<RefreshCw className="w-4 h-4" />
|
||||||
|
Refresh Defaults
|
||||||
|
</Button>
|
||||||
|
<HotkeyButton
|
||||||
|
onClick={onAddProfile}
|
||||||
|
hotkey={addProfileHotkey}
|
||||||
|
hotkeyActive={false}
|
||||||
|
data-testid="add-profile-button"
|
||||||
|
>
|
||||||
|
<Plus className="w-4 h-4 mr-2" />
|
||||||
|
New Profile
|
||||||
|
</HotkeyButton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
import { GripVertical, Lock, Pencil, Trash2, Brain } from "lucide-react";
|
||||||
|
import { useSortable } from "@dnd-kit/sortable";
|
||||||
|
import { CSS } from "@dnd-kit/utilities";
|
||||||
|
import type { AIProfile } from "@/store/app-store";
|
||||||
|
import { PROFILE_ICONS } from "../constants";
|
||||||
|
|
||||||
|
interface SortableProfileCardProps {
|
||||||
|
profile: AIProfile;
|
||||||
|
onEdit: () => void;
|
||||||
|
onDelete: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function SortableProfileCard({
|
||||||
|
profile,
|
||||||
|
onEdit,
|
||||||
|
onDelete,
|
||||||
|
}: SortableProfileCardProps) {
|
||||||
|
const {
|
||||||
|
attributes,
|
||||||
|
listeners,
|
||||||
|
setNodeRef,
|
||||||
|
transform,
|
||||||
|
transition,
|
||||||
|
isDragging,
|
||||||
|
} = useSortable({ id: profile.id });
|
||||||
|
|
||||||
|
const style = {
|
||||||
|
transform: CSS.Transform.toString(transform),
|
||||||
|
transition,
|
||||||
|
opacity: isDragging ? 0.5 : 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
const IconComponent = profile.icon ? PROFILE_ICONS[profile.icon] : Brain;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
ref={setNodeRef}
|
||||||
|
style={style}
|
||||||
|
className={cn(
|
||||||
|
"group relative flex items-start gap-4 p-4 rounded-xl border bg-card transition-all",
|
||||||
|
isDragging && "shadow-lg",
|
||||||
|
profile.isBuiltIn
|
||||||
|
? "border-border/50"
|
||||||
|
: "border-border hover:border-primary/50 hover:shadow-sm"
|
||||||
|
)}
|
||||||
|
data-testid={`profile-card-${profile.id}`}
|
||||||
|
>
|
||||||
|
{/* Drag Handle */}
|
||||||
|
<button
|
||||||
|
{...attributes}
|
||||||
|
{...listeners}
|
||||||
|
className="p-1 rounded hover:bg-accent cursor-grab active:cursor-grabbing flex-shrink-0 mt-1"
|
||||||
|
data-testid={`profile-drag-handle-${profile.id}`}
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
aria-label={`Reorder ${profile.name} profile`}
|
||||||
|
>
|
||||||
|
<GripVertical className="h-4 w-4 text-muted-foreground" />
|
||||||
|
</button>
|
||||||
|
|
||||||
|
{/* Icon */}
|
||||||
|
<div
|
||||||
|
className="flex-shrink-0 w-10 h-10 rounded-lg flex items-center justify-center bg-primary/10"
|
||||||
|
>
|
||||||
|
{IconComponent && (
|
||||||
|
<IconComponent className="w-5 h-5 text-primary" />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Content */}
|
||||||
|
<div className="flex-1 min-w-0">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<h3 className="font-semibold text-foreground">{profile.name}</h3>
|
||||||
|
{profile.isBuiltIn && (
|
||||||
|
<span className="flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded-full bg-muted text-muted-foreground">
|
||||||
|
<Lock className="w-2.5 h-2.5" />
|
||||||
|
Built-in
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<p className="text-sm text-muted-foreground mt-0.5 line-clamp-2">
|
||||||
|
{profile.description}
|
||||||
|
</p>
|
||||||
|
<div className="flex items-center gap-2 mt-2 flex-wrap">
|
||||||
|
<span
|
||||||
|
className="text-xs px-2 py-0.5 rounded-full border border-primary/30 text-primary bg-primary/10"
|
||||||
|
>
|
||||||
|
{profile.model}
|
||||||
|
</span>
|
||||||
|
{profile.thinkingLevel !== "none" && (
|
||||||
|
<span className="text-xs px-2 py-0.5 rounded-full border border-amber-500/30 text-amber-600 dark:text-amber-400 bg-amber-500/10">
|
||||||
|
{profile.thinkingLevel}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Actions */}
|
||||||
|
{!profile.isBuiltIn && (
|
||||||
|
<div className="flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity">
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
onClick={onEdit}
|
||||||
|
className="h-8 w-8 p-0"
|
||||||
|
data-testid={`edit-profile-${profile.id}`}
|
||||||
|
aria-label={`Edit ${profile.name} profile`}
|
||||||
|
>
|
||||||
|
<Pencil className="w-4 h-4" />
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
onClick={onDelete}
|
||||||
|
className="h-8 w-8 p-0 text-destructive hover:text-destructive"
|
||||||
|
data-testid={`delete-profile-${profile.id}`}
|
||||||
|
aria-label={`Delete ${profile.name} profile`}
|
||||||
|
>
|
||||||
|
<Trash2 className="w-4 h-4" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
48
apps/app/src/components/views/profiles-view/constants.ts
Normal file
48
apps/app/src/components/views/profiles-view/constants.ts
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import {
|
||||||
|
Brain,
|
||||||
|
Zap,
|
||||||
|
Scale,
|
||||||
|
Cpu,
|
||||||
|
Rocket,
|
||||||
|
Sparkles,
|
||||||
|
} from "lucide-react";
|
||||||
|
import type { AgentModel, ThinkingLevel } from "@/store/app-store";
|
||||||
|
|
||||||
|
// Icon mapping for profiles
|
||||||
|
export const PROFILE_ICONS: Record<
|
||||||
|
string,
|
||||||
|
React.ComponentType<{ className?: string }>
|
||||||
|
> = {
|
||||||
|
Brain,
|
||||||
|
Zap,
|
||||||
|
Scale,
|
||||||
|
Cpu,
|
||||||
|
Rocket,
|
||||||
|
Sparkles,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Available icons for selection
|
||||||
|
export const ICON_OPTIONS = [
|
||||||
|
{ name: "Brain", icon: Brain },
|
||||||
|
{ name: "Zap", icon: Zap },
|
||||||
|
{ name: "Scale", icon: Scale },
|
||||||
|
{ name: "Cpu", icon: Cpu },
|
||||||
|
{ name: "Rocket", icon: Rocket },
|
||||||
|
{ name: "Sparkles", icon: Sparkles },
|
||||||
|
];
|
||||||
|
|
||||||
|
// Model options for the form
|
||||||
|
export const CLAUDE_MODELS: { id: AgentModel; label: string }[] = [
|
||||||
|
{ id: "haiku", label: "Claude Haiku" },
|
||||||
|
{ id: "sonnet", label: "Claude Sonnet" },
|
||||||
|
{ id: "opus", label: "Claude Opus" },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const THINKING_LEVELS: { id: ThinkingLevel; label: string }[] = [
|
||||||
|
{ id: "none", label: "None" },
|
||||||
|
{ id: "low", label: "Low" },
|
||||||
|
{ id: "medium", label: "Medium" },
|
||||||
|
{ id: "high", label: "High" },
|
||||||
|
{ id: "ultrathink", label: "Ultrathink" },
|
||||||
|
];
|
||||||
|
|
||||||
7
apps/app/src/components/views/profiles-view/utils.ts
Normal file
7
apps/app/src/components/views/profiles-view/utils.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import type { AgentModel, ModelProvider } from "@/store/app-store";
|
||||||
|
|
||||||
|
// Helper to determine provider from model
|
||||||
|
export function getProviderFromModel(model: AgentModel): ModelProvider {
|
||||||
|
return "claude";
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user