mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-03 22:44:28 +00:00
Merge pull request #120 from shumaiOne/feat/replace-overflow-with-scrollarea
feat(webui): replace native overflow with shadcn ScrollArea in settings
This commit is contained in:
@@ -6,11 +6,11 @@ import { Badge } from '@/ui/components/ui/badge'
|
|||||||
import { Button } from '@/ui/components/ui/button'
|
import { Button } from '@/ui/components/ui/button'
|
||||||
import { Checkbox } from '@/ui/components/ui/checkbox'
|
import { Checkbox } from '@/ui/components/ui/checkbox'
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from '@/ui/components/ui/dropdown-menu'
|
} from '@/ui/components/ui/dropdown-menu'
|
||||||
import { EditableText } from '@/ui/components/ui/editable-text'
|
import { EditableText } from '@/ui/components/ui/editable-text'
|
||||||
import { Skeleton } from '@/ui/components/ui/skeleton'
|
import { Skeleton } from '@/ui/components/ui/skeleton'
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
||||||
import { client } from '@/ui/api/client'
|
import { client } from '@/ui/api/client'
|
||||||
|
import { ScrollArea } from '@/ui/components/ui/scroll-area'
|
||||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/ui/components/ui/card'
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/ui/components/ui/card'
|
||||||
import { Switch } from '@/ui/components/ui/switch'
|
import { Switch } from '@/ui/components/ui/switch'
|
||||||
import {
|
import {
|
||||||
@@ -65,163 +66,169 @@ export function NotificationSettings({ teamId }: { teamId: string }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="h-full overflow-y-auto space-y-6 pr-1">
|
<ScrollArea className="h-full">
|
||||||
{/* Comments Settings */}
|
<div className="space-y-6 pr-4 pb-8">
|
||||||
<Card className="border border-slate-200 dark:border-slate-800">
|
{/* Comments Settings */}
|
||||||
<CardHeader className="border-b border-slate-100 dark:border-slate-800 bg-slate-50/50 dark:bg-slate-900/50">
|
<Card className="border border-slate-200 dark:border-slate-800">
|
||||||
<div className="flex items-center gap-2">
|
<CardHeader className="border-b border-slate-100 dark:border-slate-800 bg-slate-50/50 dark:bg-slate-900/50">
|
||||||
<MessageSquare className="w-5 h-5 text-blue-500" />
|
<div className="flex items-center gap-2">
|
||||||
<CardTitle className="text-lg">Comments & Replies</CardTitle>
|
<MessageSquare className="w-5 h-5 text-blue-500" />
|
||||||
</div>
|
<CardTitle className="text-lg">Comments & Replies</CardTitle>
|
||||||
<CardDescription>
|
</div>
|
||||||
Control notification preferences when other users comment on assets you collaborate on
|
<CardDescription>
|
||||||
or mention you.
|
Control notification preferences when other users comment on assets you collaborate on
|
||||||
</CardDescription>
|
or mention you.
|
||||||
</CardHeader>
|
</CardDescription>
|
||||||
<CardContent className="divide-y divide-slate-100 dark:divide-slate-800 p-0">
|
</CardHeader>
|
||||||
{/* General Comments */}
|
<CardContent className="divide-y divide-slate-100 dark:divide-slate-800 p-0">
|
||||||
<div className="flex items-center justify-between p-6">
|
{/* General Comments */}
|
||||||
<div className="flex gap-4">
|
<div className="flex items-center justify-between p-6">
|
||||||
<div className="mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400">
|
<div className="flex gap-4">
|
||||||
<MessageSquare className="w-4 h-4" />
|
<div className="mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-blue-50 dark:bg-blue-900/20 text-blue-600 dark:text-blue-400">
|
||||||
|
<MessageSquare className="w-4 h-4" />
|
||||||
|
</div>
|
||||||
|
<div className="space-y-0.5">
|
||||||
|
<h4 className="text-sm font-semibold text-slate-900 dark:text-white">
|
||||||
|
General Comments
|
||||||
|
</h4>
|
||||||
|
<p className="text-sm text-slate-500 dark:text-slate-400">
|
||||||
|
When someone comments on an asset
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-0.5">
|
<Switch
|
||||||
<h4 className="text-sm font-semibold text-slate-900 dark:text-white">
|
checked={settings?.comments ?? true}
|
||||||
General Comments
|
onCheckedChange={() => handleToggle('comments')}
|
||||||
</h4>
|
disabled={isUpdating}
|
||||||
<p className="text-sm text-slate-500 dark:text-slate-400">
|
/>
|
||||||
When someone comments on an asset
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<Switch
|
|
||||||
checked={settings?.comments ?? true}
|
|
||||||
onCheckedChange={() => handleToggle('comments')}
|
|
||||||
disabled={isUpdating}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Comment Replies */}
|
{/* Comment Replies */}
|
||||||
<div className="flex items-center justify-between p-6">
|
<div className="flex items-center justify-between p-6">
|
||||||
<div className="flex gap-4">
|
<div className="flex gap-4">
|
||||||
<div className="mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-purple-50 dark:bg-purple-900/20 text-purple-600 dark:text-purple-400">
|
<div className="mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-purple-50 dark:bg-purple-900/20 text-purple-600 dark:text-purple-400">
|
||||||
<MessageCircle className="w-4 h-4" />
|
<MessageCircle className="w-4 h-4" />
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-0.5">
|
<div className="space-y-0.5">
|
||||||
<h4 className="text-sm font-semibold text-slate-900 dark:text-white">
|
<h4 className="text-sm font-semibold text-slate-900 dark:text-white">
|
||||||
Comment Replies
|
Comment Replies
|
||||||
</h4>
|
</h4>
|
||||||
<p className="text-sm text-slate-500 dark:text-slate-400">
|
<p className="text-sm text-slate-500 dark:text-slate-400">
|
||||||
When someone replies to your comment
|
When someone replies to your comment
|
||||||
</p>
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<Switch
|
||||||
|
checked={settings?.replies ?? true}
|
||||||
|
onCheckedChange={() => handleToggle('replies')}
|
||||||
|
disabled={isUpdating}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Switch
|
|
||||||
checked={settings?.replies ?? true}
|
|
||||||
onCheckedChange={() => handleToggle('replies')}
|
|
||||||
disabled={isUpdating}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Mentions */}
|
{/* Mentions */}
|
||||||
<div className="flex items-center justify-between p-6">
|
<div className="flex items-center justify-between p-6">
|
||||||
<div className="flex gap-4">
|
<div className="flex gap-4">
|
||||||
<div className="mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-pink-50 dark:bg-pink-900/20 text-pink-600 dark:text-pink-400">
|
<div className="mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-pink-50 dark:bg-pink-900/20 text-pink-600 dark:text-pink-400">
|
||||||
<AtSign className="w-4 h-4" />
|
<AtSign className="w-4 h-4" />
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-0.5">
|
<div className="space-y-0.5">
|
||||||
<h4 className="text-sm font-semibold text-slate-900 dark:text-white">@Mentions</h4>
|
<h4 className="text-sm font-semibold text-slate-900 dark:text-white">
|
||||||
<p className="text-sm text-slate-500 dark:text-slate-400">
|
@Mentions
|
||||||
When someone @mentions you in a comment
|
</h4>
|
||||||
</p>
|
<p className="text-sm text-slate-500 dark:text-slate-400">
|
||||||
|
When someone @mentions you in a comment
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<Switch
|
||||||
|
checked={settings?.mentions ?? true}
|
||||||
|
onCheckedChange={() => handleToggle('mentions')}
|
||||||
|
disabled={isUpdating}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Switch
|
</CardContent>
|
||||||
checked={settings?.mentions ?? true}
|
</Card>
|
||||||
onCheckedChange={() => handleToggle('mentions')}
|
|
||||||
disabled={isUpdating}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
{/* Assets Settings */}
|
{/* Assets Settings */}
|
||||||
<Card className="border border-slate-200 dark:border-slate-800">
|
<Card className="border border-slate-200 dark:border-slate-800">
|
||||||
<CardHeader className="border-b border-slate-100 dark:border-slate-800 bg-slate-50/50 dark:bg-slate-900/50">
|
<CardHeader className="border-b border-slate-100 dark:border-slate-800 bg-slate-50/50 dark:bg-slate-900/50">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<UploadCloud className="w-5 h-5 text-emerald-500" />
|
<UploadCloud className="w-5 h-5 text-emerald-500" />
|
||||||
<CardTitle className="text-lg">Assets & Statuses</CardTitle>
|
<CardTitle className="text-lg">Assets & Statuses</CardTitle>
|
||||||
</div>
|
</div>
|
||||||
<CardDescription>
|
<CardDescription>
|
||||||
Manage notifications related to file uploads and metadata field status updates.
|
Manage notifications related to file uploads and metadata field status updates.
|
||||||
</CardDescription>
|
</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="divide-y divide-slate-100 dark:divide-slate-800 p-0">
|
<CardContent className="divide-y divide-slate-100 dark:divide-slate-800 p-0">
|
||||||
{/* Your Uploads */}
|
{/* Your Uploads */}
|
||||||
<div className="flex items-center justify-between p-6">
|
<div className="flex items-center justify-between p-6">
|
||||||
<div className="flex gap-4">
|
<div className="flex gap-4">
|
||||||
<div className="mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-400">
|
<div className="mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-400">
|
||||||
<Bell className="w-4 h-4" />
|
<Bell className="w-4 h-4" />
|
||||||
|
</div>
|
||||||
|
<div className="space-y-0.5">
|
||||||
|
<h4 className="text-sm font-semibold text-slate-900 dark:text-white">
|
||||||
|
Your Uploads
|
||||||
|
</h4>
|
||||||
|
<p className="text-sm text-slate-500 dark:text-slate-400">
|
||||||
|
When you upload assets
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-0.5">
|
<Switch
|
||||||
<h4 className="text-sm font-semibold text-slate-900 dark:text-white">
|
checked={settings?.yourUploads ?? false}
|
||||||
Your Uploads
|
onCheckedChange={() => handleToggle('yourUploads')}
|
||||||
</h4>
|
disabled={isUpdating}
|
||||||
<p className="text-sm text-slate-500 dark:text-slate-400">When you upload assets</p>
|
/>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<Switch
|
|
||||||
checked={settings?.yourUploads ?? false}
|
|
||||||
onCheckedChange={() => handleToggle('yourUploads')}
|
|
||||||
disabled={isUpdating}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Other Uploads */}
|
{/* Other Uploads */}
|
||||||
<div className="flex items-center justify-between p-6">
|
<div className="flex items-center justify-between p-6">
|
||||||
<div className="flex gap-4">
|
<div className="flex gap-4">
|
||||||
<div className="mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-emerald-50 dark:bg-emerald-900/20 text-emerald-600 dark:text-emerald-400">
|
<div className="mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-emerald-50 dark:bg-emerald-900/20 text-emerald-600 dark:text-emerald-400">
|
||||||
<UploadCloud className="w-4 h-4" />
|
<UploadCloud className="w-4 h-4" />
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-0.5">
|
<div className="space-y-0.5">
|
||||||
<h4 className="text-sm font-semibold text-slate-900 dark:text-white">
|
<h4 className="text-sm font-semibold text-slate-900 dark:text-white">
|
||||||
Other Uploads
|
Other Uploads
|
||||||
</h4>
|
</h4>
|
||||||
<p className="text-sm text-slate-500 dark:text-slate-400">
|
<p className="text-sm text-slate-500 dark:text-slate-400">
|
||||||
When other users upload assets
|
When other users upload assets
|
||||||
</p>
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<Switch
|
||||||
|
checked={settings?.otherUploads ?? true}
|
||||||
|
onCheckedChange={() => handleToggle('otherUploads')}
|
||||||
|
disabled={isUpdating}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Switch
|
|
||||||
checked={settings?.otherUploads ?? true}
|
|
||||||
onCheckedChange={() => handleToggle('otherUploads')}
|
|
||||||
disabled={isUpdating}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Status Updates */}
|
{/* Status Updates */}
|
||||||
<div className="flex items-center justify-between p-6">
|
<div className="flex items-center justify-between p-6">
|
||||||
<div className="flex gap-4">
|
<div className="flex gap-4">
|
||||||
<div className="mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-amber-50 dark:bg-amber-900/20 text-amber-600 dark:text-amber-400">
|
<div className="mt-1 flex items-center justify-center w-8 h-8 rounded-lg bg-amber-50 dark:bg-amber-900/20 text-amber-600 dark:text-amber-400">
|
||||||
<Activity className="w-4 h-4" />
|
<Activity className="w-4 h-4" />
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-0.5">
|
<div className="space-y-0.5">
|
||||||
<h4 className="text-sm font-semibold text-slate-900 dark:text-white">
|
<h4 className="text-sm font-semibold text-slate-900 dark:text-white">
|
||||||
Status Updates
|
Status Updates
|
||||||
</h4>
|
</h4>
|
||||||
<p className="text-sm text-slate-500 dark:text-slate-400">
|
<p className="text-sm text-slate-500 dark:text-slate-400">
|
||||||
When someone changes an asset’s status
|
When someone changes an asset’s status
|
||||||
</p>
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<Switch
|
||||||
|
checked={settings?.statusUpdates ?? true}
|
||||||
|
onCheckedChange={() => handleToggle('statusUpdates')}
|
||||||
|
disabled={isUpdating}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Switch
|
</CardContent>
|
||||||
checked={settings?.statusUpdates ?? true}
|
</Card>
|
||||||
onCheckedChange={() => handleToggle('statusUpdates')}
|
</div>
|
||||||
disabled={isUpdating}
|
</ScrollArea>
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
</div>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,40 +1,41 @@
|
|||||||
import { client } from '@/ui/api/client'
|
import { client } from '@/ui/api/client'
|
||||||
|
import { ScrollArea } from '@/ui/components/ui/scroll-area'
|
||||||
import {
|
import {
|
||||||
AlertDialog,
|
AlertDialog,
|
||||||
AlertDialogAction,
|
AlertDialogAction,
|
||||||
AlertDialogCancel,
|
AlertDialogCancel,
|
||||||
AlertDialogContent,
|
AlertDialogContent,
|
||||||
AlertDialogDescription,
|
AlertDialogDescription,
|
||||||
AlertDialogFooter,
|
AlertDialogFooter,
|
||||||
AlertDialogHeader,
|
AlertDialogHeader,
|
||||||
AlertDialogTitle,
|
AlertDialogTitle,
|
||||||
} from '@/ui/components/ui/alert-dialog'
|
} from '@/ui/components/ui/alert-dialog'
|
||||||
import { Badge } from '@/ui/components/ui/badge'
|
import { Badge } from '@/ui/components/ui/badge'
|
||||||
import { Button } from '@/ui/components/ui/button'
|
import { Button } from '@/ui/components/ui/button'
|
||||||
import { Card, CardContent } from '@/ui/components/ui/card'
|
import { Card, CardContent } from '@/ui/components/ui/card'
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
DialogDescription,
|
DialogDescription,
|
||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from '@/ui/components/ui/dialog'
|
} from '@/ui/components/ui/dialog'
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from '@/ui/components/ui/dropdown-menu'
|
} from '@/ui/components/ui/dropdown-menu'
|
||||||
import { Field, FieldDescription, FieldError, FieldLabel } from '@/ui/components/ui/field'
|
import { Field, FieldDescription, FieldError, FieldLabel } from '@/ui/components/ui/field'
|
||||||
import { Input } from '@/ui/components/ui/input'
|
import { Input } from '@/ui/components/ui/input'
|
||||||
import { Label } from '@/ui/components/ui/label'
|
import { Label } from '@/ui/components/ui/label'
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
SelectContent,
|
SelectContent,
|
||||||
SelectItem,
|
SelectItem,
|
||||||
SelectTrigger,
|
SelectTrigger,
|
||||||
SelectValue,
|
SelectValue,
|
||||||
} from '@/ui/components/ui/select'
|
} from '@/ui/components/ui/select'
|
||||||
import { Switch } from '@/ui/components/ui/switch'
|
import { Switch } from '@/ui/components/ui/switch'
|
||||||
import { providerConfigSchema, providerModelSchema } from '@shumai/dtos'
|
import { providerConfigSchema, providerModelSchema } from '@shumai/dtos'
|
||||||
@@ -42,18 +43,18 @@ import { useForm } from '@tanstack/react-form'
|
|||||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||||
import { InferResponseType } from 'hono/client'
|
import { InferResponseType } from 'hono/client'
|
||||||
import {
|
import {
|
||||||
ChevronRight,
|
ChevronRight,
|
||||||
Cpu,
|
Cpu,
|
||||||
DollarSign,
|
DollarSign,
|
||||||
Globe,
|
Globe,
|
||||||
Info,
|
Info,
|
||||||
Loader2,
|
Loader2,
|
||||||
Maximize2,
|
Maximize2,
|
||||||
MoreVertical,
|
MoreVertical,
|
||||||
Plus,
|
Plus,
|
||||||
Search,
|
Search,
|
||||||
Trash2,
|
Trash2,
|
||||||
Zap,
|
Zap,
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
import { useEffect, useMemo, useState } from 'react'
|
import { useEffect, useMemo, useState } from 'react'
|
||||||
import { toast } from 'sonner'
|
import { toast } from 'sonner'
|
||||||
@@ -227,8 +228,8 @@ export function ProvidersSettings({ teamId }: ProvidersSettingsProps) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex-1 overflow-y-auto pr-2 min-h-0 overflow-x-hidden">
|
<ScrollArea className="flex-1 min-h-0">
|
||||||
<div className="grid grid-cols-1 gap-4 py-2">
|
<div className="pr-4 py-2 grid grid-cols-1 gap-4">
|
||||||
{filteredProviders.map((provider) => (
|
{filteredProviders.map((provider) => (
|
||||||
<Card
|
<Card
|
||||||
key={provider.id}
|
key={provider.id}
|
||||||
@@ -337,7 +338,7 @@ export function ProvidersSettings({ teamId }: ProvidersSettingsProps) {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</ScrollArea>
|
||||||
|
|
||||||
<ProviderFormDialog
|
<ProviderFormDialog
|
||||||
isOpen={isCreateDialogOpen}
|
isOpen={isCreateDialogOpen}
|
||||||
@@ -505,386 +506,390 @@ function ProviderFormDialog({
|
|||||||
}}
|
}}
|
||||||
className="flex flex-col flex-1 overflow-hidden"
|
className="flex flex-col flex-1 overflow-hidden"
|
||||||
>
|
>
|
||||||
<div className="flex-1 overflow-y-auto p-6 pt-2 space-y-8">
|
<ScrollArea className="flex-1 min-h-0">
|
||||||
{/* Row 1: Basic Config */}
|
<div className="p-6 pt-2 space-y-8 pr-4">
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 p-6 rounded-2xl border">
|
{/* Row 1: Basic Config */}
|
||||||
<form.Field
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 p-6 rounded-2xl border">
|
||||||
name="name"
|
|
||||||
children={(field) => {
|
|
||||||
const isInvalid = !!field.state.meta.errors.length && field.state.meta.isTouched
|
|
||||||
return (
|
|
||||||
<Field data-invalid={isInvalid}>
|
|
||||||
<FieldLabel htmlFor={field.name}>Provider Name</FieldLabel>
|
|
||||||
<Input
|
|
||||||
id={field.name}
|
|
||||||
name={field.name}
|
|
||||||
value={field.state.value}
|
|
||||||
onBlur={field.handleBlur}
|
|
||||||
onChange={(e) => field.handleChange(e.target.value)}
|
|
||||||
placeholder="e.g., My OpenAI"
|
|
||||||
disabled={isBuiltin}
|
|
||||||
aria-invalid={isInvalid}
|
|
||||||
/>
|
|
||||||
{isInvalid && <FieldError errors={mapErrors(field.state.meta.errors)} />}
|
|
||||||
</Field>
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<form.Field
|
|
||||||
name="config.api"
|
|
||||||
children={(field) => {
|
|
||||||
const isInvalid = !!field.state.meta.errors.length && field.state.meta.isTouched
|
|
||||||
return (
|
|
||||||
<Field data-invalid={isInvalid}>
|
|
||||||
<FieldLabel htmlFor={field.name}>Global API Protocol</FieldLabel>
|
|
||||||
<Select
|
|
||||||
onValueChange={field.handleChange}
|
|
||||||
value={field.state.value}
|
|
||||||
disabled={isBuiltin}
|
|
||||||
>
|
|
||||||
<SelectTrigger id={field.name} aria-invalid={isInvalid}>
|
|
||||||
<SelectValue placeholder="Select API Protocol" />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
<SelectItem value="openai-completions">OpenAI Completions</SelectItem>
|
|
||||||
<SelectItem value="anthropic-messages">Anthropic Messages</SelectItem>
|
|
||||||
<SelectItem value="google-genai">Google GenAI</SelectItem>
|
|
||||||
<SelectItem value="bedrock-converse-stream">AWS Bedrock</SelectItem>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
{isInvalid && <FieldError errors={mapErrors(field.state.meta.errors)} />}
|
|
||||||
</Field>
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div className="md:col-span-2">
|
|
||||||
<form.Field
|
<form.Field
|
||||||
name="config.baseUrl"
|
name="name"
|
||||||
children={(field) => {
|
children={(field) => {
|
||||||
const isInvalid = !!field.state.meta.errors.length && field.state.meta.isTouched
|
const isInvalid = !!field.state.meta.errors.length && field.state.meta.isTouched
|
||||||
return (
|
return (
|
||||||
<Field data-invalid={isInvalid}>
|
<Field data-invalid={isInvalid}>
|
||||||
<FieldLabel htmlFor={field.name}>Base URL (Optional)</FieldLabel>
|
<FieldLabel htmlFor={field.name}>Provider Name</FieldLabel>
|
||||||
<Input
|
<Input
|
||||||
id={field.name}
|
id={field.name}
|
||||||
name={field.name}
|
name={field.name}
|
||||||
value={field.state.value || ''}
|
value={field.state.value}
|
||||||
onBlur={field.handleBlur}
|
onBlur={field.handleBlur}
|
||||||
onChange={(e) => field.handleChange(e.target.value)}
|
onChange={(e) => field.handleChange(e.target.value)}
|
||||||
placeholder="https://api.openai.com/v1"
|
placeholder="e.g., My OpenAI"
|
||||||
|
disabled={isBuiltin}
|
||||||
aria-invalid={isInvalid}
|
aria-invalid={isInvalid}
|
||||||
/>
|
/>
|
||||||
<FieldDescription>Override the default endpoint.</FieldDescription>
|
|
||||||
{isInvalid && <FieldError errors={mapErrors(field.state.meta.errors)} />}
|
{isInvalid && <FieldError errors={mapErrors(field.state.meta.errors)} />}
|
||||||
</Field>
|
</Field>
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<form.Field
|
||||||
|
name="config.api"
|
||||||
|
children={(field) => {
|
||||||
|
const isInvalid = !!field.state.meta.errors.length && field.state.meta.isTouched
|
||||||
|
return (
|
||||||
|
<Field data-invalid={isInvalid}>
|
||||||
|
<FieldLabel htmlFor={field.name}>Global API Protocol</FieldLabel>
|
||||||
|
<Select
|
||||||
|
onValueChange={field.handleChange}
|
||||||
|
value={field.state.value}
|
||||||
|
disabled={isBuiltin}
|
||||||
|
>
|
||||||
|
<SelectTrigger id={field.name} aria-invalid={isInvalid}>
|
||||||
|
<SelectValue placeholder="Select API Protocol" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="openai-completions">OpenAI Completions</SelectItem>
|
||||||
|
<SelectItem value="anthropic-messages">Anthropic Messages</SelectItem>
|
||||||
|
<SelectItem value="google-genai">Google GenAI</SelectItem>
|
||||||
|
<SelectItem value="bedrock-converse-stream">AWS Bedrock</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
{isInvalid && <FieldError errors={mapErrors(field.state.meta.errors)} />}
|
||||||
|
</Field>
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div className="md:col-span-2">
|
||||||
|
<form.Field
|
||||||
|
name="config.baseUrl"
|
||||||
|
children={(field) => {
|
||||||
|
const isInvalid =
|
||||||
|
!!field.state.meta.errors.length && field.state.meta.isTouched
|
||||||
|
return (
|
||||||
|
<Field data-invalid={isInvalid}>
|
||||||
|
<FieldLabel htmlFor={field.name}>Base URL (Optional)</FieldLabel>
|
||||||
|
<Input
|
||||||
|
id={field.name}
|
||||||
|
name={field.name}
|
||||||
|
value={field.state.value || ''}
|
||||||
|
onBlur={field.handleBlur}
|
||||||
|
onChange={(e) => field.handleChange(e.target.value)}
|
||||||
|
placeholder="https://api.openai.com/v1"
|
||||||
|
aria-invalid={isInvalid}
|
||||||
|
/>
|
||||||
|
<FieldDescription>Override the default endpoint.</FieldDescription>
|
||||||
|
{isInvalid && <FieldError errors={mapErrors(field.state.meta.errors)} />}
|
||||||
|
</Field>
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Row 2: API Key Card */}
|
||||||
|
<Card className="rounded-2xl border bg-transparent">
|
||||||
|
<CardContent className="p-6 pt-2">
|
||||||
|
<form.Field
|
||||||
|
name="config.apiKey"
|
||||||
|
children={(field) => {
|
||||||
|
const isInvalid =
|
||||||
|
!!field.state.meta.errors.length && field.state.meta.isTouched
|
||||||
|
return (
|
||||||
|
<Field data-invalid={isInvalid}>
|
||||||
|
<FieldLabel htmlFor={field.name} className="text-base font-semibold">
|
||||||
|
API Key
|
||||||
|
</FieldLabel>
|
||||||
|
<Input
|
||||||
|
id={field.name}
|
||||||
|
name={field.name}
|
||||||
|
type="text"
|
||||||
|
value={field.state.value || ''}
|
||||||
|
onBlur={field.handleBlur}
|
||||||
|
onChange={(e) => field.handleChange(e.target.value)}
|
||||||
|
placeholder="Enter API Key or Environment Variable"
|
||||||
|
aria-invalid={isInvalid}
|
||||||
|
/>
|
||||||
|
<FieldDescription className="text-xs mt-2">
|
||||||
|
You can provide a literal value (e.g.{' '}
|
||||||
|
<code className="bg-muted px-1 rounded text-primary">sk-...</code>) or
|
||||||
|
an Environment variable name (e.g.{' '}
|
||||||
|
<code className="bg-muted px-1 rounded text-primary">MY_API_KEY</code>
|
||||||
|
).
|
||||||
|
</FieldDescription>
|
||||||
|
{isInvalid && <FieldError errors={mapErrors(field.state.meta.errors)} />}
|
||||||
|
</Field>
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
{/* Models Section */}
|
||||||
|
<div className="space-y-4">
|
||||||
|
<form.Field
|
||||||
|
name="models"
|
||||||
|
mode="array"
|
||||||
|
children={(modelsField) => (
|
||||||
|
<div className="space-y-4">
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<Label className="text-lg font-bold">Models Configuration</Label>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
onClick={() =>
|
||||||
|
modelsField.pushValue({
|
||||||
|
modelId: '',
|
||||||
|
name: '',
|
||||||
|
config: {
|
||||||
|
api: form.getFieldValue('config.api'),
|
||||||
|
reasoning: false,
|
||||||
|
input: ['text'],
|
||||||
|
contextWindow: 128000,
|
||||||
|
maxTokens: 4096,
|
||||||
|
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
className="gap-2"
|
||||||
|
>
|
||||||
|
<Plus className="w-4 h-4" />
|
||||||
|
Add Model
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-6">
|
||||||
|
{modelsField.state.value.map((_, index) => (
|
||||||
|
<div
|
||||||
|
key={index}
|
||||||
|
className="group relative p-6 bg-transparent rounded-2xl border shadow-sm animate-in fade-in zoom-in-95 duration-300"
|
||||||
|
>
|
||||||
|
{/* Row 1: ID and Name */}
|
||||||
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||||
|
<form.Field
|
||||||
|
name={`models[${index}].modelId`}
|
||||||
|
children={(field) => {
|
||||||
|
const isInvalid =
|
||||||
|
!!field.state.meta.errors.length && field.state.meta.isTouched
|
||||||
|
return (
|
||||||
|
<Field data-invalid={isInvalid}>
|
||||||
|
<FieldLabel htmlFor={field.name}>Model ID</FieldLabel>
|
||||||
|
<Input
|
||||||
|
id={field.name}
|
||||||
|
name={field.name}
|
||||||
|
value={field.state.value}
|
||||||
|
onBlur={field.handleBlur}
|
||||||
|
onChange={(e) => field.handleChange(e.target.value)}
|
||||||
|
placeholder="gpt-4o"
|
||||||
|
aria-invalid={isInvalid}
|
||||||
|
/>
|
||||||
|
{isInvalid && (
|
||||||
|
<FieldError errors={mapErrors(field.state.meta.errors)} />
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<form.Field
|
||||||
|
name={`models[${index}].name`}
|
||||||
|
children={(field) => {
|
||||||
|
const isInvalid =
|
||||||
|
!!field.state.meta.errors.length && field.state.meta.isTouched
|
||||||
|
return (
|
||||||
|
<Field data-invalid={isInvalid}>
|
||||||
|
<FieldLabel htmlFor={field.name}>
|
||||||
|
Display Name (Optional)
|
||||||
|
</FieldLabel>
|
||||||
|
<Input
|
||||||
|
id={field.name}
|
||||||
|
name={field.name}
|
||||||
|
value={field.state.value}
|
||||||
|
onBlur={field.handleBlur}
|
||||||
|
onChange={(e) => field.handleChange(e.target.value)}
|
||||||
|
placeholder="e.g., GPT-4o"
|
||||||
|
aria-invalid={isInvalid}
|
||||||
|
disabled={isBuiltin}
|
||||||
|
/>
|
||||||
|
{isInvalid && (
|
||||||
|
<FieldError errors={mapErrors(field.state.meta.errors)} />
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Row 2: Reasoning and Context Window */}
|
||||||
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 mt-6">
|
||||||
|
<form.Field
|
||||||
|
name={`models[${index}].config.reasoning`}
|
||||||
|
children={(field) => (
|
||||||
|
<Field
|
||||||
|
orientation="horizontal"
|
||||||
|
className="rounded-lg border border-border p-3 shadow-sm bg-muted/50 justify-between"
|
||||||
|
>
|
||||||
|
<FieldLabel htmlFor={field.name}>Reasoning Support</FieldLabel>
|
||||||
|
<Switch
|
||||||
|
id={field.name}
|
||||||
|
checked={field.state.value}
|
||||||
|
onCheckedChange={field.handleChange}
|
||||||
|
disabled={isBuiltin}
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<form.Field
|
||||||
|
name={`models[${index}].config.contextWindow`}
|
||||||
|
children={(field) => {
|
||||||
|
const isInvalid =
|
||||||
|
!!field.state.meta.errors.length && field.state.meta.isTouched
|
||||||
|
return (
|
||||||
|
<Field data-invalid={isInvalid}>
|
||||||
|
<FieldLabel htmlFor={field.name} className="text-xs">
|
||||||
|
Context Window (tokens)
|
||||||
|
</FieldLabel>
|
||||||
|
<Input
|
||||||
|
id={field.name}
|
||||||
|
name={field.name}
|
||||||
|
type="number"
|
||||||
|
value={field.state.value}
|
||||||
|
onBlur={field.handleBlur}
|
||||||
|
onChange={(e) =>
|
||||||
|
field.handleChange(parseInt(e.target.value) || 0)
|
||||||
|
}
|
||||||
|
aria-invalid={isInvalid}
|
||||||
|
disabled={isBuiltin}
|
||||||
|
/>
|
||||||
|
{isInvalid && (
|
||||||
|
<FieldError errors={mapErrors(field.state.meta.errors)} />
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Row 3: Constraints and Cost */}
|
||||||
|
<div className="grid grid-cols-1 md:grid-cols-3 gap-4 mt-6">
|
||||||
|
<form.Field
|
||||||
|
name={`models[${index}].config.maxTokens`}
|
||||||
|
children={(field) => {
|
||||||
|
const isInvalid =
|
||||||
|
!!field.state.meta.errors.length && field.state.meta.isTouched
|
||||||
|
return (
|
||||||
|
<Field data-invalid={isInvalid}>
|
||||||
|
<FieldLabel htmlFor={field.name} className="text-xs">
|
||||||
|
Max Output Tokens
|
||||||
|
</FieldLabel>
|
||||||
|
<Input
|
||||||
|
id={field.name}
|
||||||
|
name={field.name}
|
||||||
|
type="number"
|
||||||
|
value={field.state.value}
|
||||||
|
onBlur={field.handleBlur}
|
||||||
|
onChange={(e) =>
|
||||||
|
field.handleChange(parseInt(e.target.value) || 0)
|
||||||
|
}
|
||||||
|
aria-invalid={isInvalid}
|
||||||
|
disabled={isBuiltin}
|
||||||
|
/>
|
||||||
|
{isInvalid && (
|
||||||
|
<FieldError errors={mapErrors(field.state.meta.errors)} />
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<form.Field
|
||||||
|
name={`models[${index}].config.cost.input`}
|
||||||
|
children={(field) => {
|
||||||
|
const isInvalid =
|
||||||
|
!!field.state.meta.errors.length && field.state.meta.isTouched
|
||||||
|
return (
|
||||||
|
<Field data-invalid={isInvalid}>
|
||||||
|
<FieldLabel
|
||||||
|
htmlFor={field.name}
|
||||||
|
className="text-xs flex items-center gap-1"
|
||||||
|
>
|
||||||
|
<DollarSign className="w-3 h-3" /> Input Cost (1M)
|
||||||
|
</FieldLabel>
|
||||||
|
<Input
|
||||||
|
id={field.name}
|
||||||
|
name={field.name}
|
||||||
|
type="number"
|
||||||
|
step="0.01"
|
||||||
|
value={field.state.value}
|
||||||
|
onBlur={field.handleBlur}
|
||||||
|
onChange={(e) =>
|
||||||
|
field.handleChange(parseFloat(e.target.value) || 0)
|
||||||
|
}
|
||||||
|
aria-invalid={isInvalid}
|
||||||
|
disabled={isBuiltin}
|
||||||
|
/>
|
||||||
|
{isInvalid && (
|
||||||
|
<FieldError errors={mapErrors(field.state.meta.errors)} />
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<form.Field
|
||||||
|
name={`models[${index}].config.cost.output`}
|
||||||
|
children={(field) => {
|
||||||
|
const isInvalid =
|
||||||
|
!!field.state.meta.errors.length && field.state.meta.isTouched
|
||||||
|
return (
|
||||||
|
<Field data-invalid={isInvalid}>
|
||||||
|
<FieldLabel
|
||||||
|
htmlFor={field.name}
|
||||||
|
className="text-xs flex items-center gap-1"
|
||||||
|
>
|
||||||
|
<DollarSign className="w-3 h-3" /> Output Cost (1M)
|
||||||
|
</FieldLabel>
|
||||||
|
<Input
|
||||||
|
id={field.name}
|
||||||
|
name={field.name}
|
||||||
|
type="number"
|
||||||
|
step="0.01"
|
||||||
|
value={field.state.value}
|
||||||
|
onBlur={field.handleBlur}
|
||||||
|
onChange={(e) =>
|
||||||
|
field.handleChange(parseFloat(e.target.value) || 0)
|
||||||
|
}
|
||||||
|
aria-invalid={isInvalid}
|
||||||
|
disabled={isBuiltin}
|
||||||
|
/>
|
||||||
|
{isInvalid && (
|
||||||
|
<FieldError errors={mapErrors(field.state.meta.errors)} />
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{!isBuiltin && (
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
className="absolute -top-2 -right-2 h-8 w-8 rounded-full bg-background border border-border text-muted-foreground hover:text-destructive transition-colors shadow-sm"
|
||||||
|
onClick={() => modelsField.removeValue(index)}
|
||||||
|
>
|
||||||
|
<Trash2 className="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</ScrollArea>
|
||||||
{/* Row 2: API Key Card */}
|
|
||||||
<Card className="rounded-2xl border bg-transparent">
|
|
||||||
<CardContent className="p-6 pt-2">
|
|
||||||
<form.Field
|
|
||||||
name="config.apiKey"
|
|
||||||
children={(field) => {
|
|
||||||
const isInvalid = !!field.state.meta.errors.length && field.state.meta.isTouched
|
|
||||||
return (
|
|
||||||
<Field data-invalid={isInvalid}>
|
|
||||||
<FieldLabel htmlFor={field.name} className="text-base font-semibold">
|
|
||||||
API Key
|
|
||||||
</FieldLabel>
|
|
||||||
<Input
|
|
||||||
id={field.name}
|
|
||||||
name={field.name}
|
|
||||||
type="text"
|
|
||||||
value={field.state.value || ''}
|
|
||||||
onBlur={field.handleBlur}
|
|
||||||
onChange={(e) => field.handleChange(e.target.value)}
|
|
||||||
placeholder="Enter API Key or Environment Variable"
|
|
||||||
aria-invalid={isInvalid}
|
|
||||||
/>
|
|
||||||
<FieldDescription className="text-xs mt-2">
|
|
||||||
You can provide a literal value (e.g.{' '}
|
|
||||||
<code className="bg-muted px-1 rounded text-primary">sk-...</code>) or an
|
|
||||||
Environment variable name (e.g.{' '}
|
|
||||||
<code className="bg-muted px-1 rounded text-primary">MY_API_KEY</code>
|
|
||||||
).
|
|
||||||
</FieldDescription>
|
|
||||||
{isInvalid && <FieldError errors={mapErrors(field.state.meta.errors)} />}
|
|
||||||
</Field>
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
{/* Models Section */}
|
|
||||||
<div className="space-y-4">
|
|
||||||
<form.Field
|
|
||||||
name="models"
|
|
||||||
mode="array"
|
|
||||||
children={(modelsField) => (
|
|
||||||
<div className="space-y-4">
|
|
||||||
<div className="flex items-center justify-between">
|
|
||||||
<Label className="text-lg font-bold">Models Configuration</Label>
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
variant="outline"
|
|
||||||
size="sm"
|
|
||||||
onClick={() =>
|
|
||||||
modelsField.pushValue({
|
|
||||||
modelId: '',
|
|
||||||
name: '',
|
|
||||||
config: {
|
|
||||||
api: form.getFieldValue('config.api'),
|
|
||||||
reasoning: false,
|
|
||||||
input: ['text'],
|
|
||||||
contextWindow: 128000,
|
|
||||||
maxTokens: 4096,
|
|
||||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
className="gap-2"
|
|
||||||
>
|
|
||||||
<Plus className="w-4 h-4" />
|
|
||||||
Add Model
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="space-y-6">
|
|
||||||
{modelsField.state.value.map((_, index) => (
|
|
||||||
<div
|
|
||||||
key={index}
|
|
||||||
className="group relative p-6 bg-transparent rounded-2xl border shadow-sm animate-in fade-in zoom-in-95 duration-300"
|
|
||||||
>
|
|
||||||
{/* Row 1: ID and Name */}
|
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
|
||||||
<form.Field
|
|
||||||
name={`models[${index}].modelId`}
|
|
||||||
children={(field) => {
|
|
||||||
const isInvalid =
|
|
||||||
!!field.state.meta.errors.length && field.state.meta.isTouched
|
|
||||||
return (
|
|
||||||
<Field data-invalid={isInvalid}>
|
|
||||||
<FieldLabel htmlFor={field.name}>Model ID</FieldLabel>
|
|
||||||
<Input
|
|
||||||
id={field.name}
|
|
||||||
name={field.name}
|
|
||||||
value={field.state.value}
|
|
||||||
onBlur={field.handleBlur}
|
|
||||||
onChange={(e) => field.handleChange(e.target.value)}
|
|
||||||
placeholder="gpt-4o"
|
|
||||||
aria-invalid={isInvalid}
|
|
||||||
/>
|
|
||||||
{isInvalid && (
|
|
||||||
<FieldError errors={mapErrors(field.state.meta.errors)} />
|
|
||||||
)}
|
|
||||||
</Field>
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<form.Field
|
|
||||||
name={`models[${index}].name`}
|
|
||||||
children={(field) => {
|
|
||||||
const isInvalid =
|
|
||||||
!!field.state.meta.errors.length && field.state.meta.isTouched
|
|
||||||
return (
|
|
||||||
<Field data-invalid={isInvalid}>
|
|
||||||
<FieldLabel htmlFor={field.name}>
|
|
||||||
Display Name (Optional)
|
|
||||||
</FieldLabel>
|
|
||||||
<Input
|
|
||||||
id={field.name}
|
|
||||||
name={field.name}
|
|
||||||
value={field.state.value}
|
|
||||||
onBlur={field.handleBlur}
|
|
||||||
onChange={(e) => field.handleChange(e.target.value)}
|
|
||||||
placeholder="e.g., GPT-4o"
|
|
||||||
aria-invalid={isInvalid}
|
|
||||||
disabled={isBuiltin}
|
|
||||||
/>
|
|
||||||
{isInvalid && (
|
|
||||||
<FieldError errors={mapErrors(field.state.meta.errors)} />
|
|
||||||
)}
|
|
||||||
</Field>
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Row 2: Reasoning and Context Window */}
|
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 mt-6">
|
|
||||||
<form.Field
|
|
||||||
name={`models[${index}].config.reasoning`}
|
|
||||||
children={(field) => (
|
|
||||||
<Field
|
|
||||||
orientation="horizontal"
|
|
||||||
className="rounded-lg border border-border p-3 shadow-sm bg-muted/50 justify-between"
|
|
||||||
>
|
|
||||||
<FieldLabel htmlFor={field.name}>Reasoning Support</FieldLabel>
|
|
||||||
<Switch
|
|
||||||
id={field.name}
|
|
||||||
checked={field.state.value}
|
|
||||||
onCheckedChange={field.handleChange}
|
|
||||||
disabled={isBuiltin}
|
|
||||||
/>
|
|
||||||
</Field>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<form.Field
|
|
||||||
name={`models[${index}].config.contextWindow`}
|
|
||||||
children={(field) => {
|
|
||||||
const isInvalid =
|
|
||||||
!!field.state.meta.errors.length && field.state.meta.isTouched
|
|
||||||
return (
|
|
||||||
<Field data-invalid={isInvalid}>
|
|
||||||
<FieldLabel htmlFor={field.name} className="text-xs">
|
|
||||||
Context Window (tokens)
|
|
||||||
</FieldLabel>
|
|
||||||
<Input
|
|
||||||
id={field.name}
|
|
||||||
name={field.name}
|
|
||||||
type="number"
|
|
||||||
value={field.state.value}
|
|
||||||
onBlur={field.handleBlur}
|
|
||||||
onChange={(e) =>
|
|
||||||
field.handleChange(parseInt(e.target.value) || 0)
|
|
||||||
}
|
|
||||||
aria-invalid={isInvalid}
|
|
||||||
disabled={isBuiltin}
|
|
||||||
/>
|
|
||||||
{isInvalid && (
|
|
||||||
<FieldError errors={mapErrors(field.state.meta.errors)} />
|
|
||||||
)}
|
|
||||||
</Field>
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Row 3: Constraints and Cost */}
|
|
||||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-4 mt-6">
|
|
||||||
<form.Field
|
|
||||||
name={`models[${index}].config.maxTokens`}
|
|
||||||
children={(field) => {
|
|
||||||
const isInvalid =
|
|
||||||
!!field.state.meta.errors.length && field.state.meta.isTouched
|
|
||||||
return (
|
|
||||||
<Field data-invalid={isInvalid}>
|
|
||||||
<FieldLabel htmlFor={field.name} className="text-xs">
|
|
||||||
Max Output Tokens
|
|
||||||
</FieldLabel>
|
|
||||||
<Input
|
|
||||||
id={field.name}
|
|
||||||
name={field.name}
|
|
||||||
type="number"
|
|
||||||
value={field.state.value}
|
|
||||||
onBlur={field.handleBlur}
|
|
||||||
onChange={(e) =>
|
|
||||||
field.handleChange(parseInt(e.target.value) || 0)
|
|
||||||
}
|
|
||||||
aria-invalid={isInvalid}
|
|
||||||
disabled={isBuiltin}
|
|
||||||
/>
|
|
||||||
{isInvalid && (
|
|
||||||
<FieldError errors={mapErrors(field.state.meta.errors)} />
|
|
||||||
)}
|
|
||||||
</Field>
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<form.Field
|
|
||||||
name={`models[${index}].config.cost.input`}
|
|
||||||
children={(field) => {
|
|
||||||
const isInvalid =
|
|
||||||
!!field.state.meta.errors.length && field.state.meta.isTouched
|
|
||||||
return (
|
|
||||||
<Field data-invalid={isInvalid}>
|
|
||||||
<FieldLabel
|
|
||||||
htmlFor={field.name}
|
|
||||||
className="text-xs flex items-center gap-1"
|
|
||||||
>
|
|
||||||
<DollarSign className="w-3 h-3" /> Input Cost (1M)
|
|
||||||
</FieldLabel>
|
|
||||||
<Input
|
|
||||||
id={field.name}
|
|
||||||
name={field.name}
|
|
||||||
type="number"
|
|
||||||
step="0.01"
|
|
||||||
value={field.state.value}
|
|
||||||
onBlur={field.handleBlur}
|
|
||||||
onChange={(e) =>
|
|
||||||
field.handleChange(parseFloat(e.target.value) || 0)
|
|
||||||
}
|
|
||||||
aria-invalid={isInvalid}
|
|
||||||
disabled={isBuiltin}
|
|
||||||
/>
|
|
||||||
{isInvalid && (
|
|
||||||
<FieldError errors={mapErrors(field.state.meta.errors)} />
|
|
||||||
)}
|
|
||||||
</Field>
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<form.Field
|
|
||||||
name={`models[${index}].config.cost.output`}
|
|
||||||
children={(field) => {
|
|
||||||
const isInvalid =
|
|
||||||
!!field.state.meta.errors.length && field.state.meta.isTouched
|
|
||||||
return (
|
|
||||||
<Field data-invalid={isInvalid}>
|
|
||||||
<FieldLabel
|
|
||||||
htmlFor={field.name}
|
|
||||||
className="text-xs flex items-center gap-1"
|
|
||||||
>
|
|
||||||
<DollarSign className="w-3 h-3" /> Output Cost (1M)
|
|
||||||
</FieldLabel>
|
|
||||||
<Input
|
|
||||||
id={field.name}
|
|
||||||
name={field.name}
|
|
||||||
type="number"
|
|
||||||
step="0.01"
|
|
||||||
value={field.state.value}
|
|
||||||
onBlur={field.handleBlur}
|
|
||||||
onChange={(e) =>
|
|
||||||
field.handleChange(parseFloat(e.target.value) || 0)
|
|
||||||
}
|
|
||||||
aria-invalid={isInvalid}
|
|
||||||
disabled={isBuiltin}
|
|
||||||
/>
|
|
||||||
{isInvalid && (
|
|
||||||
<FieldError errors={mapErrors(field.state.meta.errors)} />
|
|
||||||
)}
|
|
||||||
</Field>
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{!isBuiltin && (
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="absolute -top-2 -right-2 h-8 w-8 rounded-full bg-background border border-border text-muted-foreground hover:text-destructive transition-colors shadow-sm"
|
|
||||||
onClick={() => modelsField.removeValue(index)}
|
|
||||||
>
|
|
||||||
<Trash2 className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<DialogFooter className="p-6 pt-4 border-t border-border gap-2">
|
<DialogFooter className="p-6 pt-4 border-t border-border gap-2">
|
||||||
<Button type="button" variant="outline" onClick={onClose} disabled={isLoading}>
|
<Button type="button" variant="outline" onClick={onClose} disabled={isLoading}>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
||||||
import { client } from '@/ui/api/client'
|
import { client } from '@/ui/api/client'
|
||||||
|
import { ScrollArea } from '@/ui/components/ui/scroll-area'
|
||||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/ui/components/ui/card'
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/ui/components/ui/card'
|
||||||
import { Input } from '@/ui/components/ui/input'
|
import { Input } from '@/ui/components/ui/input'
|
||||||
import { Button } from '@/ui/components/ui/button'
|
import { Button } from '@/ui/components/ui/button'
|
||||||
@@ -79,129 +80,133 @@ export function SandboxSettings({ teamId }: { teamId: string }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="h-full overflow-y-auto space-y-6 pr-1">
|
<ScrollArea className="h-full">
|
||||||
<Card>
|
<div className="space-y-6 pr-4 pb-8">
|
||||||
<CardHeader>
|
<Card>
|
||||||
<div className="flex items-center gap-2">
|
<CardHeader>
|
||||||
<Globe className="w-5 h-5 text-primary" />
|
<div className="flex items-center gap-2">
|
||||||
<CardTitle>Network Sandbox</CardTitle>
|
<Globe className="w-5 h-5 text-primary" />
|
||||||
</div>
|
<CardTitle>Network Sandbox</CardTitle>
|
||||||
<CardDescription>
|
|
||||||
Configure allowed domains for the sandboxed agent. By default, only essential domains
|
|
||||||
are allowed.
|
|
||||||
</CardDescription>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent>
|
|
||||||
<form onSubmit={handleAddDomain} className="flex gap-2 mb-6">
|
|
||||||
<Input
|
|
||||||
placeholder="e.g. api.openai.com"
|
|
||||||
value={newDomain}
|
|
||||||
onChange={(e) => setNewDomain(e.target.value)}
|
|
||||||
disabled={isUpdating}
|
|
||||||
/>
|
|
||||||
<Button type="submit" disabled={isUpdating}>
|
|
||||||
{isUpdating ? (
|
|
||||||
<Loader2 className="w-4 h-4 animate-spin" />
|
|
||||||
) : (
|
|
||||||
<Plus className="w-4 h-4 mr-2" />
|
|
||||||
)}
|
|
||||||
Add Domain
|
|
||||||
</Button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<div className="space-y-2">
|
|
||||||
<h4 className="text-sm font-medium text-muted-foreground mb-3">Allowed Domains</h4>
|
|
||||||
<div className="flex flex-wrap gap-2">
|
|
||||||
{sandbox?.allowedDomains.map((domain) => (
|
|
||||||
<div
|
|
||||||
key={domain}
|
|
||||||
className="flex items-center gap-1 px-3 py-1.5 bg-muted rounded-full text-sm border border-border transition-all hover:border-muted-foreground/50"
|
|
||||||
>
|
|
||||||
<span className="font-medium text-foreground">{domain}</span>
|
|
||||||
<button
|
|
||||||
onClick={() => handleRemoveDomain(domain)}
|
|
||||||
className="ml-1 text-muted-foreground hover:text-destructive transition-colors"
|
|
||||||
disabled={isUpdating}
|
|
||||||
>
|
|
||||||
<X className="w-3.5 h-3.5" />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
{sandbox?.allowedDomains.length === 0 && (
|
|
||||||
<div className="text-sm text-muted-foreground italic">No custom domains allowed</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<CardDescription>
|
||||||
</CardContent>
|
Configure allowed domains for the sandboxed agent. By default, only essential domains
|
||||||
</Card>
|
are allowed.
|
||||||
|
</CardDescription>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<form onSubmit={handleAddDomain} className="flex gap-2 mb-6">
|
||||||
|
<Input
|
||||||
|
placeholder="e.g. api.openai.com"
|
||||||
|
value={newDomain}
|
||||||
|
onChange={(e) => setNewDomain(e.target.value)}
|
||||||
|
disabled={isUpdating}
|
||||||
|
/>
|
||||||
|
<Button type="submit" disabled={isUpdating}>
|
||||||
|
{isUpdating ? (
|
||||||
|
<Loader2 className="w-4 h-4 animate-spin" />
|
||||||
|
) : (
|
||||||
|
<Plus className="w-4 h-4 mr-2" />
|
||||||
|
)}
|
||||||
|
Add Domain
|
||||||
|
</Button>
|
||||||
|
</form>
|
||||||
|
|
||||||
{/* Pending Domains Section */}
|
<div className="space-y-2">
|
||||||
<Card className="border-orange-500/20 bg-orange-500/5">
|
<h4 className="text-sm font-medium text-muted-foreground mb-3">Allowed Domains</h4>
|
||||||
<CardHeader>
|
<div className="flex flex-wrap gap-2">
|
||||||
<div className="flex items-center gap-2">
|
{sandbox?.allowedDomains.map((domain) => (
|
||||||
<ShieldAlert className="w-5 h-5 text-orange-500" />
|
|
||||||
<CardTitle>Pending Domain Approvals</CardTitle>
|
|
||||||
</div>
|
|
||||||
<CardDescription>
|
|
||||||
These domains were blocked during agent execution. You can approve them to allow future
|
|
||||||
network requests, or delete them from this list.
|
|
||||||
</CardDescription>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent>
|
|
||||||
<div className="space-y-3">
|
|
||||||
{sandbox?.pendingDomains && sandbox.pendingDomains.length > 0 ? (
|
|
||||||
<div className="divide-y divide-border">
|
|
||||||
{sandbox.pendingDomains.map((domain) => (
|
|
||||||
<div
|
<div
|
||||||
key={domain}
|
key={domain}
|
||||||
className="flex items-center justify-between py-2.5 first:pt-0 last:pb-0"
|
className="flex items-center gap-1 px-3 py-1.5 bg-muted rounded-full text-sm border border-border transition-all hover:border-muted-foreground/50"
|
||||||
>
|
>
|
||||||
<span className="font-mono text-sm text-foreground bg-muted px-2 py-1 rounded break-all">
|
<span className="font-medium text-foreground">{domain}</span>
|
||||||
{domain}
|
<button
|
||||||
</span>
|
onClick={() => handleRemoveDomain(domain)}
|
||||||
<div className="flex items-center gap-2">
|
className="ml-1 text-muted-foreground hover:text-destructive transition-colors"
|
||||||
<Button
|
disabled={isUpdating}
|
||||||
size="sm"
|
>
|
||||||
variant="outline"
|
<X className="w-3.5 h-3.5" />
|
||||||
className="h-8 border-emerald-500/20 text-emerald-600 hover:bg-emerald-500/10 hover:text-emerald-600 dark:text-emerald-400 dark:hover:bg-emerald-500/20"
|
</button>
|
||||||
onClick={() => handleApproveDomain(domain)}
|
|
||||||
disabled={isUpdating}
|
|
||||||
>
|
|
||||||
<Check className="w-4 h-4 mr-1.5" />
|
|
||||||
Approve
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
size="sm"
|
|
||||||
variant="outline"
|
|
||||||
className="h-8 border-destructive/20 text-destructive hover:bg-destructive/10"
|
|
||||||
onClick={() => handleDeletePendingDomain(domain)}
|
|
||||||
disabled={isUpdating}
|
|
||||||
>
|
|
||||||
<Trash2 className="w-4 h-4 mr-1.5" />
|
|
||||||
Delete
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
{sandbox?.allowedDomains.length === 0 && (
|
||||||
|
<div className="text-sm text-muted-foreground italic">
|
||||||
|
No custom domains allowed
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
) : (
|
</div>
|
||||||
<div className="text-sm text-muted-foreground italic py-2">
|
</CardContent>
|
||||||
No pending domains requiring approval
|
</Card>
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
|
|
||||||
<Card>
|
{/* Pending Domains Section */}
|
||||||
<CardHeader>
|
<Card className="border-orange-500/20 bg-orange-500/5">
|
||||||
<CardTitle>Filesystem Restriction</CardTitle>
|
<CardHeader>
|
||||||
<CardDescription>
|
<div className="flex items-center gap-2">
|
||||||
The agent is restricted to reading and writing only within the <code>.pi</code> and{' '}
|
<ShieldAlert className="w-5 h-5 text-orange-500" />
|
||||||
<code>/tmp</code> folders. These settings are currently hardcoded for security.
|
<CardTitle>Pending Domain Approvals</CardTitle>
|
||||||
</CardDescription>
|
</div>
|
||||||
</CardHeader>
|
<CardDescription>
|
||||||
</Card>
|
These domains were blocked during agent execution. You can approve them to allow
|
||||||
</div>
|
future network requests, or delete them from this list.
|
||||||
|
</CardDescription>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<div className="space-y-3">
|
||||||
|
{sandbox?.pendingDomains && sandbox.pendingDomains.length > 0 ? (
|
||||||
|
<div className="divide-y divide-border">
|
||||||
|
{sandbox.pendingDomains.map((domain) => (
|
||||||
|
<div
|
||||||
|
key={domain}
|
||||||
|
className="flex items-center justify-between py-2.5 first:pt-0 last:pb-0"
|
||||||
|
>
|
||||||
|
<span className="font-mono text-sm text-foreground bg-muted px-2 py-1 rounded break-all">
|
||||||
|
{domain}
|
||||||
|
</span>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
variant="outline"
|
||||||
|
className="h-8 border-emerald-500/20 text-emerald-600 hover:bg-emerald-500/10 hover:text-emerald-600 dark:text-emerald-400 dark:hover:bg-emerald-500/20"
|
||||||
|
onClick={() => handleApproveDomain(domain)}
|
||||||
|
disabled={isUpdating}
|
||||||
|
>
|
||||||
|
<Check className="w-4 h-4 mr-1.5" />
|
||||||
|
Approve
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
variant="outline"
|
||||||
|
className="h-8 border-destructive/20 text-destructive hover:bg-destructive/10"
|
||||||
|
onClick={() => handleDeletePendingDomain(domain)}
|
||||||
|
disabled={isUpdating}
|
||||||
|
>
|
||||||
|
<Trash2 className="w-4 h-4 mr-1.5" />
|
||||||
|
Delete
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="text-sm text-muted-foreground italic py-2">
|
||||||
|
No pending domains requiring approval
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Card>
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle>Filesystem Restriction</CardTitle>
|
||||||
|
<CardDescription>
|
||||||
|
The agent is restricted to reading and writing only within the <code>.pi</code> and{' '}
|
||||||
|
<code>/tmp</code> folders. These settings are currently hardcoded for security.
|
||||||
|
</CardDescription>
|
||||||
|
</CardHeader>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</ScrollArea>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import React, { useState, useRef } from 'react'
|
|||||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/ui/components/ui/card'
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/ui/components/ui/card'
|
||||||
import { Button } from '@/ui/components/ui/button'
|
import { Button } from '@/ui/components/ui/button'
|
||||||
import { cn } from '@/ui/lib/utils'
|
import { cn } from '@/ui/lib/utils'
|
||||||
|
import { ScrollArea } from '@/ui/components/ui/scroll-area'
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
@@ -397,9 +398,7 @@ const AddSkillDialog = ({
|
|||||||
<Upload className="w-6 h-6 text-muted-foreground group-hover:text-primary" />
|
<Upload className="w-6 h-6 text-muted-foreground group-hover:text-primary" />
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-3 text-center">
|
<div className="mt-3 text-center">
|
||||||
<p className="text-sm font-medium text-foreground">
|
<p className="text-sm font-medium text-foreground">Select ZIP file</p>
|
||||||
Select ZIP file
|
|
||||||
</p>
|
|
||||||
<p className="text-[10px] text-muted-foreground mt-1 uppercase tracking-wider font-semibold">
|
<p className="text-[10px] text-muted-foreground mt-1 uppercase tracking-wider font-semibold">
|
||||||
Packages must contain a SKILL.md
|
Packages must contain a SKILL.md
|
||||||
</p>
|
</p>
|
||||||
@@ -549,56 +548,58 @@ const ConfigSkillDialog = ({
|
|||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
|
|
||||||
<div className="py-4 space-y-4 max-h-[60vh] overflow-y-auto pr-2 custom-scrollbar">
|
<ScrollArea className="max-h-[60vh]">
|
||||||
{envVars.length === 0 ? (
|
<div className="py-4 space-y-4 pr-4">
|
||||||
<div className="text-center py-10 bg-muted/50 rounded-xl border border-dashed border-border">
|
{envVars.length === 0 ? (
|
||||||
<p className="text-muted-foreground text-sm italic">
|
<div className="text-center py-10 bg-muted/50 rounded-xl border border-dashed border-border">
|
||||||
No environment variables found. Click "Add Variable" to create one.
|
<p className="text-muted-foreground text-sm italic">
|
||||||
</p>
|
No environment variables found. Click "Add Variable" to create one.
|
||||||
</div>
|
</p>
|
||||||
) : (
|
|
||||||
envVars.map((env: { name: string; default?: string | undefined }, index: number) => (
|
|
||||||
<div
|
|
||||||
key={index}
|
|
||||||
className="p-4 bg-muted/50 rounded-xl border border-border space-y-3 relative group"
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
onClick={() => removeEnvVar(index)}
|
|
||||||
className="absolute top-2 right-2 p-1 text-muted-foreground hover:text-destructive hover:bg-destructive/10 rounded-md transition-colors opacity-0 group-hover:opacity-100"
|
|
||||||
>
|
|
||||||
<X className="w-4 h-4" />
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<div className="space-y-1.5">
|
|
||||||
<Label className="text-[10px] uppercase tracking-wider font-bold text-muted-foreground">
|
|
||||||
Variable Name
|
|
||||||
</Label>
|
|
||||||
<Input
|
|
||||||
value={env.name}
|
|
||||||
onChange={(e) => handleEnvVarNameChange(index, e.target.value)}
|
|
||||||
placeholder="e.app. API_KEY"
|
|
||||||
className="h-8 bg-background border-border text-sm font-mono"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="space-y-1.5">
|
|
||||||
<Label className="text-[10px] uppercase tracking-wider font-bold text-muted-foreground">
|
|
||||||
Default Value
|
|
||||||
</Label>
|
|
||||||
<Input
|
|
||||||
value={env.default || ''}
|
|
||||||
onChange={(e) => handleEnvVarValueChange(index, e.target.value)}
|
|
||||||
placeholder="Optional default value..."
|
|
||||||
className="h-8 bg-background border-border text-sm"
|
|
||||||
/>
|
|
||||||
<p className="text-[10px] text-muted-foreground italic">
|
|
||||||
If left empty, the value will be read from the host machine's environment.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
))
|
) : (
|
||||||
)}
|
envVars.map((env: { name: string; default?: string | undefined }, index: number) => (
|
||||||
</div>
|
<div
|
||||||
|
key={index}
|
||||||
|
className="p-4 bg-muted/50 rounded-xl border border-border space-y-3 relative group"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
onClick={() => removeEnvVar(index)}
|
||||||
|
className="absolute top-2 right-2 p-1 text-muted-foreground hover:text-destructive hover:bg-destructive/10 rounded-md transition-colors opacity-0 group-hover:opacity-100"
|
||||||
|
>
|
||||||
|
<X className="w-4 h-4" />
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div className="space-y-1.5">
|
||||||
|
<Label className="text-[10px] uppercase tracking-wider font-bold text-muted-foreground">
|
||||||
|
Variable Name
|
||||||
|
</Label>
|
||||||
|
<Input
|
||||||
|
value={env.name}
|
||||||
|
onChange={(e) => handleEnvVarNameChange(index, e.target.value)}
|
||||||
|
placeholder="e.app. API_KEY"
|
||||||
|
className="h-8 bg-background border-border text-sm font-mono"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-1.5">
|
||||||
|
<Label className="text-[10px] uppercase tracking-wider font-bold text-muted-foreground">
|
||||||
|
Default Value
|
||||||
|
</Label>
|
||||||
|
<Input
|
||||||
|
value={env.default || ''}
|
||||||
|
onChange={(e) => handleEnvVarValueChange(index, e.target.value)}
|
||||||
|
placeholder="Optional default value..."
|
||||||
|
className="h-8 bg-background border-border text-sm"
|
||||||
|
/>
|
||||||
|
<p className="text-[10px] text-muted-foreground italic">
|
||||||
|
If left empty, the value will be read from the host machine's environment.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</ScrollArea>
|
||||||
|
|
||||||
<DialogFooter className="flex items-center justify-between sm:justify-between w-full pt-2 border-t border-border">
|
<DialogFooter className="flex items-center justify-between sm:justify-between w-full pt-2 border-t border-border">
|
||||||
<Button
|
<Button
|
||||||
@@ -613,11 +614,7 @@ const ConfigSkillDialog = ({
|
|||||||
<Button variant="ghost" onClick={() => onOpenChange(false)}>
|
<Button variant="ghost" onClick={() => onOpenChange(false)}>
|
||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button onClick={handleSave} disabled={isSaving} className="px-8">
|
||||||
onClick={handleSave}
|
|
||||||
disabled={isSaving}
|
|
||||||
className="px-8"
|
|
||||||
>
|
|
||||||
{isSaving ? <Loader2 className="w-4 h-4 animate-spin mr-2" /> : null}
|
{isSaving ? <Loader2 className="w-4 h-4 animate-spin mr-2" /> : null}
|
||||||
Save Changes
|
Save Changes
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
Reference in New Issue
Block a user