'use client'; /** * Control Panel Component * * Provides controls for pausing/resuming memory creation * and displays server status including uptime. */ import { useControlStatus, usePauseMemory, useResumeMemory, useConsolidate } from '@/hooks/useMemories'; import { Button } from '@/components/ui/button'; import { VersionPanel } from './VersionPanel'; export function ControlPanel() { const { data: status, isLoading } = useControlStatus(); const pauseMutation = usePauseMemory(); const resumeMutation = useResumeMemory(); const consolidateMutation = useConsolidate(); const isPaused = status?.paused ?? false; const isToggling = pauseMutation.isPending || resumeMutation.isPending; const handleTogglePause = () => { if (isPaused) { resumeMutation.mutate(); } else { pauseMutation.mutate(); } }; const handleConsolidate = () => { consolidateMutation.mutate(); }; if (isLoading) { return (
); } return (
{/* Status Banner (only when paused) */} {isPaused && (
Memory creation paused
)} {/* Server Status */}
Server Status
{isPaused ? 'Paused' : 'Active'}
Uptime: {status?.uptimeFormatted || '—'}
{/* Control Buttons */}
{/* Version Panel */}
); }