Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | 'use client'; import { SkillEventType } from '@shared/types/data/skill-event'; import { Badge } from '@web/components/ui/badge'; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from '@web/components/ui/card'; import { Skeleton } from '@web/components/ui/skeleton'; import { useSkillEvents } from '@web/providers/skill-events'; import { CalendarIcon, CheckCircle2Icon, FileEditIcon, LayersIcon, PlusIcon, RefreshCwIcon, ToggleLeftIcon, ToggleRightIcon, XIcon, } from 'lucide-react'; import type { ReactElement } from 'react'; import { useEffect } from 'react'; interface SkillEventsListProps { skillId: string; } const EVENT_TYPE_CONFIG: Record< SkillEventType, { label: string; icon: typeof PlusIcon; color: string } > = { [SkillEventType.MODEL_ADDED]: { label: 'Model Added', icon: PlusIcon, color: 'bg-green-100 text-green-800', }, [SkillEventType.MODEL_REMOVED]: { label: 'Model Removed', icon: XIcon, color: 'bg-red-100 text-red-800', }, [SkillEventType.REFLECTION]: { label: 'Reflection', icon: RefreshCwIcon, color: 'bg-blue-100 text-blue-800', }, [SkillEventType.EVALUATION_ADDED]: { label: 'Evaluation Added', icon: PlusIcon, color: 'bg-green-100 text-green-800', }, [SkillEventType.EVALUATION_REMOVED]: { label: 'Evaluation Removed', icon: XIcon, color: 'bg-red-100 text-red-800', }, [SkillEventType.EVALUATION_REGENERATED]: { label: 'Evaluation Regenerated', icon: LayersIcon, color: 'bg-purple-100 text-purple-800', }, [SkillEventType.PARTITION_RESET]: { label: 'Partition Reset', icon: RefreshCwIcon, color: 'bg-orange-100 text-orange-800', }, [SkillEventType.DESCRIPTION_UPDATED]: { label: 'Description Updated', icon: FileEditIcon, color: 'bg-blue-100 text-blue-800', }, [SkillEventType.PARTITIONS_RECLUSTERED]: { label: 'Partitions Reclustered', icon: LayersIcon, color: 'bg-purple-100 text-purple-800', }, [SkillEventType.OPTIMIZATION_ENABLED]: { label: 'Optimization Enabled', icon: ToggleRightIcon, color: 'bg-green-100 text-green-800', }, [SkillEventType.OPTIMIZATION_DISABLED]: { label: 'Optimization Disabled', icon: ToggleLeftIcon, color: 'bg-gray-100 text-gray-800', }, [SkillEventType.CLUSTERS_UPDATED]: { label: 'Clusters Updated', icon: RefreshCwIcon, color: 'bg-blue-100 text-blue-800', }, [SkillEventType.CONTEXT_GENERATED]: { label: 'Context Generated', icon: CheckCircle2Icon, color: 'bg-green-100 text-green-800', }, }; export function SkillEventsList({ skillId, }: SkillEventsListProps): ReactElement { const { events, isLoading, setSkillId } = useSkillEvents(); useEffect(() => { setSkillId(skillId); }, [skillId, setSkillId]); if (isLoading) { return ( <Card> <CardHeader> <CardTitle>Events</CardTitle> <CardDescription>Loading events...</CardDescription> </CardHeader> <CardContent> <div className="space-y-2"> <Skeleton className="h-16 w-full" /> <Skeleton className="h-16 w-full" /> <Skeleton className="h-16 w-full" /> </div> </CardContent> </Card> ); } if (events.length === 0) { return ( <Card> <CardHeader> <CardTitle>Events</CardTitle> <CardDescription> Track important changes to this skill </CardDescription> </CardHeader> <CardContent> <div className="text-center py-8 text-sm text-muted-foreground"> No events recorded yet </div> </CardContent> </Card> ); } return ( <Card> <CardHeader> <CardTitle>Events</CardTitle> <CardDescription> Recent changes to this skill ({events.length}) </CardDescription> </CardHeader> <CardContent> <div className="space-y-3"> {events.map((event) => { const config = EVENT_TYPE_CONFIG[event.event_type]; const Icon = config.icon; const timestamp = new Date(event.created_at).toLocaleString(); return ( <div key={event.id} className="flex items-start gap-3 p-3 rounded-lg border bg-card hover:bg-accent/50 transition-colors" > <div className={`p-2 rounded-md ${config.color}`}> <Icon className="w-4 h-4" /> </div> <div className="flex-1 min-w-0"> <div className="flex items-center gap-2 mb-1"> <Badge variant="outline" className="text-xs"> {config.label} </Badge> {event.cluster_id && ( <Badge variant="secondary" className="text-xs"> Cluster-specific </Badge> )} </div> {event.metadata.model_name ? ( <p className="text-sm font-medium"> {String(event.metadata.model_name)} </p> ) : null} <div className="flex items-center gap-1 text-xs text-muted-foreground mt-1"> <CalendarIcon className="w-3 h-3" /> <span>{timestamp}</span> </div> </div> </div> ); })} </div> </CardContent> </Card> ); } |