/** * MemoryManagerPanel Component * Enhanced memory management with categories, edit/delete, and API integration * OQI-007: LLM Strategy Agent - Memory Management UI */ import React, { useState, useMemo, useCallback } from 'react'; import { CircleStackIcon, PencilIcon, TrashIcon, PlusIcon, FolderIcon, LightBulbIcon, ChartBarIcon, ClockIcon, CheckIcon, XMarkIcon, MagnifyingGlassIcon, ArrowPathIcon, ExclamationTriangleIcon, } from '@heroicons/react/24/outline'; // ============================================================================ // Types // ============================================================================ export type MemoryCategory = 'preferences' | 'strategies' | 'history' | 'custom'; export interface MemoryItem { id: string; category: MemoryCategory; key: string; value: string; metadata?: Record; createdAt: string; updatedAt: string; isPinned?: boolean; } export interface MemoryStats { totalItems: number; totalTokens: number; maxTokens: number; byCategory: Record; } interface MemoryManagerPanelProps { memories: MemoryItem[]; stats: MemoryStats; onAddMemory: (memory: Omit) => Promise; onUpdateMemory: (id: string, updates: Partial) => Promise; onDeleteMemory: (id: string) => Promise; onClearCategory?: (category: MemoryCategory) => Promise; onRefresh?: () => Promise; isLoading?: boolean; } // ============================================================================ // Constants // ============================================================================ const CATEGORY_INFO: Record = { preferences: { label: 'Preferencias', icon: LightBulbIcon, color: 'text-amber-500 bg-amber-500/10' }, strategies: { label: 'Estrategias', icon: ChartBarIcon, color: 'text-blue-500 bg-blue-500/10' }, history: { label: 'Historial', icon: ClockIcon, color: 'text-purple-500 bg-purple-500/10' }, custom: { label: 'Personalizado', icon: FolderIcon, color: 'text-gray-500 bg-gray-500/10' }, }; // ============================================================================ // Sub-Components // ============================================================================ interface MemoryItemCardProps { memory: MemoryItem; onEdit: () => void; onDelete: () => void; isEditing: boolean; editValue: string; onEditChange: (value: string) => void; onSave: () => void; onCancel: () => void; } const MemoryItemCard: React.FC = ({ memory, onEdit, onDelete, isEditing, editValue, onEditChange, onSave, onCancel, }) => { const [confirmDelete, setConfirmDelete] = useState(false); const category = CATEGORY_INFO[memory.category]; const CategoryIcon = category.icon; return (
{memory.key} {memory.isPinned && ( Fijado )}
{isEditing ? (