import { useEffect, useState } from 'react' import { api } from '../api' import { navigate } from '../App' import { FolderIcon, DatabaseIcon, RocketIcon, TagIcon, BarChartIcon, SunIcon, MoonIcon, CpuIcon, LayersIcon, ZapIcon, } from './Icons' export default function Sidebar({ route, currentProject, theme, onToggleTheme }) { const [health, setHealth] = useState(null) const [notice, setNotice] = useState('') useEffect(() => { let timer const fetchHealth = () => { api.health().then(setHealth).catch(() => {}) } fetchHealth() timer = setInterval(fetchHealth, 3000) return () => clearInterval(timer) }, []) // REQ-192: free the SAM3 model's VRAM on demand; the 3 s health poll is what // confirms it, this only flips the badge straight away when it worked. const releaseSam3 = async () => { try { await api.releaseSam3() setHealth((current) => (current ? { ...current, model_loaded: false } : current)) } catch (exc) { setNotice(exc.message) setTimeout(() => setNotice(''), 4000) } } const pId = currentProject?.id || route.projectId || 1 const handleNav = (e, path) => { e.preventDefault() navigate(path) } return (
handleNav(e, '/projects')} style={{ cursor: 'pointer' }}> Dataset Enrichment
{health && (
GPU: {health.gpu ? health.gpu.replace('NVIDIA GeForce ', '').replace(' Laptop GPU', '') : 'CPU'} VRAM: {health.vram_free_gb ? `${health.vram_free_gb.toFixed(1)}GB` : 'N/A'} {notice && {notice}} {!health.sam3_ready ? ( SAM3: Off ) : health.model_loaded ? ( ) : ( SAM3: Idle )}
)}
) }